What's wrong with this code?
'DEFLNG A-Z
P
= _PIXELSIZE:
IF P
= 0 THEN P
= 2 '0 is a designation for text screens, which use 2 bytes per character for memory storageFrames = 48 'In our animation
UncompressedStringSize = Frames * ScreenSize 'the total size needed to store all the animation images, uncompressed (Should be about 48 MB)
UncompressedString$
= SPACE$(UncompressedStringSize
) 'a placeholder for the whole animation, uncompressed.SingleScreen$
= SPACE$(ScreenSize
) 'a placeholder for a single screen worth of info
UncompressedString$ = ""
FOR i
= 1 TO 48 'let's draw a cheesy animation demo PRINT "Steve is Awesome." _MEMGET m
, m.OFFSET
, SingleScreen$
'Get one screen of information UncompressedString$ = UncompressedString$ + SingleScreen$
MID$(UncompressedString$
, (i
- 1) * ScreenSize
+ 1, ScreenSize
) = SingleScreen$
'And put it in the proper place for storage
PRINT "Press <ANY KEY> to view the cheesy animation."
SLEEP 'and now a pause so we can restore our animation
temp$ = ""
temp$
= MID$(UncompressedString$
, i
* ScreenSize
+ 1, ScreenSize
)
Cobalt was wanting some advice on how to compress and store an animation in a single string over here:
https://www.qb64.org/forum/index.php?topic=1444.msg106409#newWorking up a demo for him wasn't that much work, using the zlib libraries as the compression tool, but it did end up giving me one odd glitch which I can't explain at all. Take a look at the code above and see if you can figure out what the BLEEP breaks it.
First, run it as is, and you'll see that it works as intended. We capture the screen info 48 times, and save it into a single string, which we later use to help reproduce our cheesy animation.
Then, change the TOGGLE value to TRUE (first line of code), and run it again. Notice how the results are completely different after the lucky 13th frame.
Now, what the BLEEP is broken???
****************************
When TOGGLE is FALSE (works), we preallocate the memory for the whole string and replace each screen of information manually.
When TOGGLE is TRUE (bugged), we start with a blank string and then simply add each new screen's data to that string.
The end result
should end up with both methods generating the exact same string, but obviously something is different once we get around frame 14, or so.
So here's the game -- See if you can figure out WTH is wrong with the second method, and explain it to us. First one to solve the mystery gets bragging rights and a highlighted "Best Answer" on this topic!
Play now, and YOU can be a big wiener!!