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

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #165 on: September 21, 2022, 10:54:53 AM »
Okay, I see the GDI object count increasing upon minimize then maximize...
But still paints okay, I see no nonpainted areas that should be painted...

I'll play with this a bit to see if I can remedy this.


I never knew that about task manager
« Last Edit: September 21, 2022, 12:20:01 PM by swordfish »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Leak Free?
« Reply #166 on: September 21, 2022, 11:40:26 AM »
Code: [Select]
      .elseif uMsg == WM_PAINT
        invoke BeginPaint, hWin, addr ps
        mov hDC, eax
        invoke CreateCompatibleDC, hDC
        mov mDC, eax
        invoke CreateCompatibleBitmap, hDC, cwidth, cheight
        mov hBmp, eax
        invoke SelectObject, mDC, hBmp
        mov hOld, eax
        invoke BitBlt, mDC, 0, 0, cwidth, cheight, hDC, 0, 0, SRCCOPY
       
        invoke MakeGrid, mDC, addr back_rect, hBlackBr, addr c01_rct, hWhiteBr
       
        invoke BitBlt, hDC, 0, 0, cwidth, cheight, mDC, 0, 0, SRCCOPY
        invoke DeleteObject, hBmp
        invoke SelectObject, mDC, hOld
        invoke DeleteDC, mDC
        invoke EndPaint, hWin, addr ps


Now you know why I avoided WM_PAINT  :badgrin:
This time looks okay, even watching gdi objects in TaskMgr  :biggrin:


I've fixed the code in the WM_test piece in the Workshop as well. It used the same base WM_PAINT code, including the errors. Deleted object 'mDC', when it was supposed to be 'hBmp'. lol how'd I miss that...copy/paste error no doubt...
« Last Edit: September 22, 2022, 01:35:39 PM by swordfish »
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Leak Free?
« Reply #167 on: September 21, 2022, 05:49:48 PM »
Now you know why I avoided WM_PAINT  :badgrin:
This time looks okay, even watching gdi objects in TaskMgr  :biggrin:

I've fixed the code in the WM_test piece in the Workshop as well. It used the same base WM_PAINT code, including the errors. Deleted object 'mDC', when it was supposed to be 'hBmp'. lol how'd I miss that...copy/paste error no doubt...

Well done :thumbsup:

I had seen that the last DeleteDC returned 0 but was too tired to investigate.

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #168 on: September 21, 2022, 08:59:32 PM »
Okay now. Now that that great big PITA is out of the way, using structures as I am does create another issue. When I need to draw a char font "simhei", size 48 into the cell I have to drop rct.top by 7 pixels for it to display properly. DT_VCENTER doesn't quite live up to its name in this instance. Will have to either find a workaround for this or not use the structs as I am doing. Makes no sense, if I have to copy to a temp structure then drop rct.top in the temp structure 7 pixels... the joys of ASM. Sigh...
Side gripe:
Writing/editing a post on this ipad is quite the challenge. It keeps auto-"correcting" words it does not recognize. Gee, thanks for the "help". Making posting asm relevant words etc. difficult. AND I CANNOT FIND ANY SETTING THAT WOULD HELP!!! In fact, I can't find any settings at all for the keyboard on this contraption. On my cellphone, if I select a "replacement" word, it gets stored as valid. So no problem using it next time. Sheesh. I like sitting on my back porch having a smoke and browsing the web on the ipad, if I could easily drag my computer out here I'd probably never go back inside. Oh, and placing the caret for an insertion - forget it. It looks for misspelled words apparently. And does not allow precise caret placement if an "invalid" word is present. It selects the supposed invalid word instead.
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Games - Research and Development
« Reply #169 on: September 21, 2022, 09:06:46 PM »
Try DT_TOP, or remove DT_SINGLELINE. If that doesn't work, DT_CALCRECT is your friend :cool:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #170 on: September 21, 2022, 09:15:52 PM »
DT_CALCRECT might work, haven't tried it yet though. When I go back in I'll investigate. Thanks for the tip. I don't use DT_SINGLELINE since only 1 char. Wouldn't make sense.
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Games - Research and Development
« Reply #171 on: September 21, 2022, 09:28:23 PM »
DT_VCENTER   Centers text vertically (single line only)

Not sure whether that means you have to specify DT_SINGLELINE explicitly, but it's worth trying.

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #172 on: September 21, 2022, 09:46:56 PM »

Quote
invoke DrawText, DC, addr str5, 1, esi, DT_CENTER or DT_VCENTER or DT_SINGLELINE


Go figure. To me it didnt make sense to specify DT_SINGLELINE. But thats what made it work. :rolleyes:

Oh and DT_CALCRECT was more like DT_CALCWRECKED tried in different combinations...

I dont exactly like the way the font is getting rendered.
« Last Edit: September 22, 2022, 10:59:27 AM by swordfish »
Regards, zedd.
:tongue:

jj2007

  • Member
  • *****
  • Posts: 13957
  • Assembly is fun ;-)
    • MasmBasic
Re: Simple Games - Research and Development
« Reply #173 on: September 21, 2022, 10:02:57 PM »
I dont exactly like the way the font is getting rendered.

True. Try if TextOut makes any difference (I doubt it). Or try another font.

GdiPlus might yield a better one, but...

Quote
GpStatus WINGDIPAPI GdipDrawString( GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *stringFormat, GDIPCONST GpBrush *brush )

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #174 on: September 21, 2022, 10:09:06 PM »
Tried a different font, no difference. Apparently using Windows color pallette for smoothing...and I have no idea exactly how to create a different one. I've seen the pallet functions, but never used em. For black text on white should be more of a greyscale pallette.
« Last Edit: September 22, 2022, 10:59:44 AM by swordfish »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #175 on: September 21, 2022, 10:21:20 PM »
GdiPlus might yield a better one...
I'm sure it would but, alas... I barely have a grasp of plain old gdi
and I get that wrong at least in one part of it most of the time.  :tongue:


Since we're on the subject of graphics, and since the paint functions appear to be working now as expected....with double buffering as well...
Why don't I just use my bitmaps with nicely rendered fonts.  :biggrin:
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: resuming sudoku R&D
« Reply #176 on: September 21, 2022, 11:32:32 PM »
Now have the code to 'select' the empty cells ... actually I had it already, before the WM_PAINT bug fiasco. But anywho, here it is
« Last Edit: September 24, 2022, 12:08:28 AM by swordfish »
Regards, zedd.
:tongue:

zedd151

  • Member
  • *****
  • Posts: 1968
Re: continuing super duper sudoku R&D :P
« Reply #177 on: September 22, 2022, 04:00:45 AM »
Added code to insert a digit (1-9) into the selected cell. Have not yet added checking the validity of digit entered, can enter invalid digit in this test piece. Already working on that code (valid digit checking...)
« Last Edit: September 24, 2022, 12:08:43 AM by swordfish »
Regards, zedd.
:tongue:

NoCforMe

  • Member
  • *****
  • Posts: 1124
Re: Simple Games - Research and Development
« Reply #178 on: September 22, 2022, 04:10:59 AM »
One thing: Are you creating your fonts with the CLEARTYPE_QUALITY value? That's the way to get the most nicely-rendered text.

zedd151

  • Member
  • *****
  • Posts: 1968
Re: Simple Games - Research and Development
« Reply #179 on: September 22, 2022, 04:11:27 AM »
Concurrent with the 'valid digit checking' I am also working on the 'candidates' code, they pretty much go hand in hand. On second thought, should only need a list of candidates for each cell. Check that list for whether chosen digit is valid or not.  :biggrin:
Regards, zedd.
:tongue: