02-19-2025, 07:54 PM
(02-19-2025, 06:00 PM)Pete Wrote: This stuff is totally foreign to me, coming from text programming, but I do like the fact we are no longer tied to the limited text displays of QuickBASIC SCREEN 0 mode, so it's certainly worth learning and rewarding when things work out.
I think the main issue was just your way of trying to do things. You just have the basic workflow ... working against itself.
Let's talk turkey for a bit -- or more important, let's talk about the places where you keep your turkey: in the fridge!!
If your wife wants to make certain you get an important message like, "I'M LEAVING!!", she'll write that directly on the fridge in bright red lipstick. Think of that as being your basic SCREEN 0 text screen. You write to it, the writing stays on it -- at least until you pull out the Windex and paper towels and issue a CLS command.

Now, how does hardware images work in relation to this fridge? They're basically magnets. They don't affect what was written on the screen whatsoever and they don't really interact with the screen at all. They just basically stick on top of it, like you'd stick a magnet on top of the fridge.
Hardware images are those children's magnets that make up the alphabet, which you paste over your wife's lipstick to say, "GOOD RIDDANCE!!"
.....
So basically, all you really need is the fridge (Screen 0) and the magnets (the hardware images), and then you can put (_PutImage) those magnets directly over the contents of whatever is written on the fridge and show them instead (_DISPLAY).
That's the basic concept I was trying to show to you in that last code snippet where I commented out everything you'd done. I just put my hardware image in place and let if cover over the SCREEN 0 text, just like that magnet over the lipstick.
What were you doing? And why was it much more complex?
You went out and measured the size of your fridge's door. Then you ordered a sheet of plywood and had it made that size. Then you used that sheet of plywood as a mold and created a sheet of glass that size. Then you drew scribbles on that glass with your own lipstick. You then glued that glass to the front of your fridge and used it to cover the door and your wife's lipstick. Then, after leaving it up for just a millisecond, you tore it down, broke it and tossed it in the trash, and repeated the same process over again, and again, and again, and... OMG!!
Stick a magnet to the fridge -- DON'T make a copy of the door out of glass, copy a magnet image on that door, place the glass door in front of the fridge, throw it away, and start all over...
See the difference in the complexity of the workflow in the two processes?
One is 0.1% difficulty (or 0.1% CPU usage)
The other is... what'd you say? 60% CPU usage?
And, here's something that's funny enough that I just have to mention it:
The code I posted uses LESS memory than yours, and that's even with me never using _FREEIMAGE on my hardware images...
YOU: Create an Overlay of 640 * 400 * 4 pixels of memory with Overlay = _NewImage(_WIDTH * _FONTWIDTH, _HEIGHT * _FONTHEIGHT, 32). Then proceeds to load button images and place them on that overlay and then free the button image, but never freeing that overlay itself...
ME: Loads an image of 87 * 28 * 4 pixels in size, and uses it directly without that overlay.



If you're going to use an image repeatedly in your programs, just load the BLEEPING thing and assign it to a handle you can remember and then leave it at that. Use it when needed, and skip all that reload/copy/free/free_copy crap. The code is soooo much simpler, both your CPU *and* anyone who ever has to maintain that code, will thank you for it.