Author Topic: Simple Games - Research and Development  (Read 13684 times)

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Games - Research and Development
« Reply #195 on: September 22, 2022, 11:24:33 AM »
MakeFont:

        MakeFont hProof, Quality:PROOF_QUALITY, Height:-32, Weight:FW_SEMIBOLD
        MakeFont hTimes, "Times New Roman", Height:-24, Weight:FW_THIN
        MakeFont hArial, "Arial", Underline:TRUE, Italic:0
        MakeFont hRussian, Quality:0, Underline:FALSE, Italic:TRUE, Weight:FW_SEMIBOLD


(but doing it by hand is much more challenging, of course :smiley: )

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Simple Games - Research and Development
« Reply #196 on: September 22, 2022, 11:34:50 AM »
(but doing it by hand is much more challenging, of course :smiley: )

Much more challenging? Not sure 'bout that. I just typed this about half an hour ago:

Code: [Select]
; Create a header/footer font using the printer's dimensions for scaling:
INVOKE _FillMem, ADDR lf, SIZEOF LOGFONT, 0
MOV EAX, $hdrFtrFontsize
MUL yPPI
MOV ECX, 72
DIV ECX ;EAX now = logical size of font.
NEG EAX
MOV lf.lfHeight, EAX
MOV lf.lfWeight, FW_NORMAL
MOV lf.lfCharSet, ANSI_CHARSET
MOV lf.lfOutPrecision, OUT_DEFAULT_PRECIS
MOV lf.lfClipPrecision, CLIP_DEFAULT_PRECIS
MOV lf.lfQuality, CLEARTYPE_QUALITY
MOV lf.lfPitchAndFamily, VARIABLE_PITCH or FF_ROMAN
INVOKE strcpy, OFFSET HdrFtrFontname, ADDR lf.lfFaceName
INVOKE CreateFontIndirect, ADDR lf
MOV hdrFtrFontHandle, EAX

And even with some scaling code and having to copy a string, still not feeling much strain from it ...

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Games - Research and Development
« Reply #197 on: September 22, 2022, 11:38:49 AM »
Well... :biggrin:

What's odd is that PROOF_QUALITY and CLEARTYPE_QUALITY don't differ (on Win7 at least), and that only Times New Roman shows antialiasing. More precisely: antialiasing starts when you assign a face name, such as "Arial" or "Times New Roman".

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #198 on: September 22, 2022, 11:40:30 AM »
 :rolleyes:  Ok guys. I had never requested an alternative way to get a font handle. If both of you would like to debate one way over another, take it elsewhere please. Thank you, much appreciated.


@jj2007:
Now you see why I preferred bitmaps. Gimp and photoshop render fonts much better than windows does.
You might want to read this: without any extra code wrangling, or apis to call.  :tongue:
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Games - Research and Development
« Reply #199 on: September 22, 2022, 11:44:51 AM »
You complained about the bad font in your Sudoku game. I just found a solution, see above "antialiasing starts..."

You might want to read this.

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #200 on: September 22, 2022, 11:49:06 AM »
You complained about the bad font in your Sudoku game. I just found a solution, see above "antialiasing starts..."
I also said, I wasn't going to waste anymore time with it at this time. Even still windows anti-aliasing leaves much to be desired. See above post of mine.
Regards, zedd.
:tongue:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Simple Games - Research and Development
« Reply #201 on: September 22, 2022, 12:20:48 PM »
You might want to read this:

Missing link? Some of us are curious ... (something about how Gimp or Photoshop render text???)

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #202 on: September 22, 2022, 01:05:06 PM »

Quote from: NoCforMe
Missing link?
You might want to read this: without any extra code wrangling, or apis to call.
Response to jj for posting his link.
Regards, zedd.
:tongue:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Simple Games - Research and Development
« Reply #203 on: September 22, 2022, 01:27:47 PM »
Sorry, still no link.
I know you meant to put it in. The underline looks kewl, though.

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #204 on: September 22, 2022, 09:06:29 PM »
NoCforMe, jj2007:
In reply #184 I had said that I would no longer pursue any fixes for the font issue at this time. A couple of posts after that, reply #187,  I resumed posting my progress on the game. It is very frustrating to try to continue where I left off after the gdi bug hunt when all this extra noise gets interspersed with my posts regarding my progress on the game. When I said I would no longer pursue any fixes for the poor font quality that was a hint that I'd like to continue with the game instead of getting dragged into arguing over things not directly related to the continuation of my progress on the game. If you find a bug in my code great. I'd like to hear about it. But all this back and forth about one way of getting a font handle over another serves no useful purpose for me, as I said I aready have my way of doing that, good or bad. Sure there may be numerous ways to write the code for this game better, etc. But I would like to finish it so that it works first, then optimize the code after. Discussion of better ways to implement the various functions used can be discussed later imo. Except of course for bugs that prevent it from running properly on a given OS. That type of reply is welcome and encouraged. Thank you for trying to understand my frustration in this matter.

Edit to add: Your intentions may have been good, but all these distractions make it hard to concentrate on the tasks at hand.
Regards, zedd.
:tongue:

TimoVJL

  • Member
  • *****
  • Posts: 1320
Re: Simple Games - Research and Development
« Reply #205 on: September 22, 2022, 09:41:45 PM »
Hot topic today :tongue:
Quote
need to understand that XXXXXX has chosen its own path. There is no way back.
May the source be with you

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #206 on: September 22, 2022, 10:43:36 PM »
For those interested in following my progress with the sudoku game, I had just finished the code to get the candidates for a specified cell. Will first use that code for determining if a chosen 1-9 digit is a valid entry for the cell, if not do nothing, if valid - draw the digit into the cell and update the game board to reflect that change.
Will add the code later for displaying the candidates for each empty cell.
Later today I will post the code that I have finished so far, have to rearrange a few things in the code and remove bits of code that I no longer need (used for testing the new function).


The candidates are determined right now only upon pressing 1-9 keys but only if a cell is selected (and empty)
Later when I add the code to display the candidates for each cell, the candidates will also be determined after loading the game board and any time a new entry is made in the game board.
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #207 on: September 22, 2022, 11:48:15 PM »
Here is the function "GetCandidates"
Code: [Select]
     ;; indx:    cell offset relative to game board
     ;; lpBoard: address of game board
     ;; lpCand:  address of dword array (4) of byte arrays (row offsets, column
     ;;            offsets, box offsets, candidate byte array)
                 
    GetCandidates proc indx:dword, lpboard:dword, lpCand:dword
        push esi
        push edi
        push ebx
        push edx
        push ecx
        mov edi, lpCand     ; array of dwords
        mov eax, indx       ; cell offset
        shl eax, 4          ; mul by 16 (size of dword array)
        add edi, eax        ; add to obtain dword array for selected cell
        mov ebx, [edi]      ; row offsets
        mov edx, [edi+4]    ; col offsets
        mov esi, [edi+8]    ; box offsets
        mov edi, [edi+12]   ; candidate byte array
        xor ecx, ecx
        mov eax, 1          ; start filling byte array w. 1-9
      @@:
        mov byte ptr [edi+ecx], al          ; initialize candidate array
        inc eax
        inc ecx
        cmp ecx, 9                          ; have all 9 bytes been processed?
        jnz @b
        xor ecx, ecx
      top:
        movzx eax, byte ptr [ebx+ecx]       ; get byte offset for row
        movzx eax, byte ptr [board+eax]     ; get byte value from board
        cmp al, 0                           ; ignore if zero
        jz @f
        dec eax                             ; convet 1 based to zero based
        mov byte ptr [edi+eax], 0           ; remove value as candidate
      @@:
        movzx eax, byte ptr [edx+ecx]       ; get byte offset for column
        movzx eax, byte ptr [board+eax]     ; get byte value from board
        cmp al, 0                           ; ignore if zero
        jz @f
        dec eax                             ; convet 1 based to zero based
        mov byte ptr [edi+eax], 0           ; remove value as candidate
      @@:
        movzx eax, byte ptr [esi+ecx]       ; get byte offset for
        movzx eax, byte ptr [board+eax]     ; get byte value from board
        cmp al, 0                           ; ignore if zero
        jz @f
        dec eax                             ; convet 1 based to zero based
        mov byte ptr [edi+eax], 0           ; remove value as candidate
      @@:
        inc ecx
        cmp ecx, 9                          ; have all 9 bytes been processed?
        jnz top
        mov eax, edi                        ; return address of candidate array
        pop ecx
        pop edx
        pop ebx
        pop edi
        pop esi
        ret
    GetCandidates endp
Full source code coming later today, time permitting... I still have to write a function for the WM_KEYDOWN event to use this procedure in testing whether an entered digit would be valid or not.  :biggrin:
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #208 on: September 23, 2022, 01:05:22 AM »
Function "IsValidDigit"
Code: [Select]
    IsValidDigit proc digit:dword, cellx:dword, lpBoard:dword, lpCandx:dword
        push esi
        invoke GetCandidates, cellx, lpBoard, lpCandx
        mov edx, digit
        mov esi, eax
        xor ecx, ecx
      @@:
        mov al, [esi+ecx]
        cmp al, dl
        jz valid
        inc ecx
        cmp ecx, 9
        jnz @b
        mov eax, -1
        pop esi
        ret
      valid:
        mov eax, digit
        pop esi
        ret
    IsValidDigit endp
edit = forgot a push/pop esi fixed. In attachment also
Full source attached.
« Last Edit: September 24, 2022, 12:09:20 AM by swordfish »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #209 on: September 23, 2022, 04:08:46 AM »
A test piece for testing the candidate list.
Upon selecting a cell, a message box pops up, showing valid candidates for that cell.
« Last Edit: September 24, 2022, 12:09:34 AM by swordfish »
Regards, zedd.
:tongue: