News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

WIP - (Connect 4)

Started by zedd151, April 05, 2025, 02:44:20 PM

Previous topic - Next topic

zedd151

Quote from: adeyblue on April 06, 2025, 06:15:31 AMIt flickers after I click in both versions but the animation is fine (win 7)
thanks for confirmation. I do not know why I do not see any flickering.  :sad:

Back to the drawing board...
I will post a smaller example including the source code later today, or tomorrow. I have removed the attachments posted above.

zedd151

Okay, my first idea to resolve the flickering issue for other users.

Quote from: sinsi on April 06, 2025, 01:27:43 AMIt is now flickering every drop.

Quote from: adeyblue on April 06, 2025, 06:15:31 AMIt flickers after I click in both versions but the animation is fine (win 7)

I have omitted drawing the foreground in this example. I believe that may be where the problem lies.

Please test this version...  :smiley:

zedd151

Another version, no foreground or background painting, only the game pieces.

sinsi

test_no_foreground flickers
no_foreground_or_back ok

zedd151

Here is the very first version where I used the painting methods in the examples in all of the above posts.
Only 1 column is used here. In the other sources used above, I copied and pasted the code from this version and changed variables where necessary.
The WM_PAINT code seems proper to me, in regards to the buffering. The use of the bitmaps though, not to my liking either.
Source code included in this one.

Quote from: sinsi on April 06, 2025, 08:26:07 AMtest_no_foreground flickers
no_foreground_or_back ok
Thanks sinsi.
Probably due to my blitting the background and foreground bimtaps in 80x80 sections piecewise in every call to WM_PAINT.?.  :rolleyes:

NoCforMe

I tested all the one I could find on this page: seem OK. A little jerky, since you're only drawing at a few locations.

What happened to all the attachments on the previous page? I was trying to find the version that you used to create your avatar. Can you repost that one?
Assembly language programming should be fun. That's why I do it.

zedd151

I am going to play around with it tonight. I'll use FillRect rather than painting the background in 80x80 segments, (it's only a single color - duh), and construct the full foreground bitmap only once during initialization. And blit the larger foreground only once, replacing the 42 blits using 80x80 foreground segments.

I saw no issues on my end, but if others see flickering, I'll do my best to remedy that. I am a noob when it comes to WM_PAINT stuff after all.  :biggrin:

zedd151

Quote from: NoCforMe on April 06, 2025, 08:45:30 AMWhat happened to all the attachments on the previous page? I was trying to find the version that you used to create your avatar. Can you repost that one?
I had removed the zips containing the buggy (flicker ridden) executables, there were no sources in those attachments.
Also, I never posted the avatar related code or executable. I made full size screen captures 640x640 and made a full sized .gif in ImageReady, then resized it to 128x128 for the avatar.

sinsi

One point may still be pertinent.
If you don't handle WM_ERASEBKGND then the window manager will do it for you, presumably not double buffered. Handle it yourself and return 1.

zedd151

Quote from: sinsi on April 06, 2025, 01:06:43 PMOne point may still be pertinent.
If you don't handle WM_ERASEBKGND then the window manager will do it for you, presumably not double buffered. Handle it yourself and return 1.
Ok.

        .elseif uMsg == WM_ERASEBKGND
          mov eax, 1
          ret
Try it now.  :biggrin:
Left click for red piece, right click for blue.

sinsi

No flicker, even maximised on a 4K monitor :thumbsup:

zedd151

Quote from: sinsi on April 06, 2025, 01:20:34 PMNo flicker, even maximised on a 4K monitor :thumbsup:
ReallY??? YaY!!!   :eusa_dance:  :eusa_dance:  :eusa_dance:

Best tip then, sinsi.  :thumbsup:
Where do I send the generous payment?  :tongue:

I'll share the ugly code if you want to see it.  :tongue:
After I got the first column animating reasonably, I copied and pasted a lot of code for the other columns.
The code is pretty much linear in WndProc, no loops where there could be, or split parts of it into procedures, etc.
Just remember, it is still a work-in-progress. It is kind of messy, etc.

I was fairly certain that it was not an issue in WM_PAINT per se, which could still stand to be improved obviously.
Also, I never noticed any flickering here on either computer. So I was really stumped as to the possible cause.

Now I can work on streamlining the code, replacing the resource bimtaps, adding more commenting, etc...  before finishing up the automaton code for the 'computer' player.  :greenclp:

I do remember experimenting using WM_ERASEBKGND some time ago after seeing it suggested here somewhere, but never noticed any difference, so never bothered with it after that.  :rolleyes:

sinsi

See also
WNDCLASSEX.hbrBackground

When this member is NULL, an application must paint its own background whenever it is requested to paint in its client area.
To determine whether the background must be painted, an application can either process the WM_ERASEBKGND message
 or test the fErase member of the PAINTSTRUCT structure filled by the BeginPaint function.
Doesn't apply to a dialog, but here in case anyone is stuck :badgrin:

zedd151

Quote from: sinsi... but here in case anyone is stuck
Well, thanks.  :biggrin:

It's a more common problem than some folks would realize. Many graphics related examples only tell part of the story, unfortunately.

zedd151

Thank you to those that have participated in these tests for me. The issue is resolved as of This Post, many thanks to sinsi.
This concludes this testing and debugging session.  :smiley:  The finished game will should be released within the upcoming week, time permitting.

It will take some time to consolidate and rework some of the code, to add full commenting, to add and test the 'computer player' automation code, and other miscellany.  :eusa_dance:  :eusa_dance:

Quote from: NoCforMe on April 06, 2025, 08:45:30 AMI was trying to find the version that you used to create your avatar.

While I am reworking this current rather messy source code, I might just try making a 128x128 version, specifically for creating avatar sized bitmaps. (To be compiled into an animated .gif using ImageReady, Gimp, or other third party tool)

Whether or not I actually do that will be highly dependent how difficult or time consuming that would be to accomplish.

It will need bitmaps created specially for that purpose - as the bitmaps here are large enough (80x80) to use TransparentBlt with acceptable results.

The avatar sized version would not be able to use TransparentBlt and have acceptable results, the  much smaller (around 20% of the full sized version) bitmaps would not resemble circles as they now do in my current avatar (due to dithering while resizing in ImageReady).

I would most likely post that separately from the finished game, if I do make that version

Personally I like the idea of having a miniature sized version of my games, specifically for creating an avatar suitable for use on the forum.  :azn: