This is my 102nd post actually, but that would've been kinda funny to become a member with a JPJR update, considering this project is my first "real" one.
Anyway, I have news; neither good nor bad but with a more optimistic outlook on RAM usage. Using some cheaty methods by abusing gfx_CopyRect() from and to the buffer, I can "dummy thiccify" a single column of pixels into a really rectangle really fast. That means the 60x250 pixel tileset for the lasers is now cut down to 60x2, and I can make it one once I diagnose either a convimg YAML error or a bug with convimg itself. I can also do the same with the pause menu buttons, where both sets have gone from 50x100 to 50x56, although the compressed program size went up by 3kb so I may have to backtrack and see if it's bloated the uncompressed code. All in all, that saves 18680 bytes of RAM space. That was awesome until I realized that I'd need 88320 bytes for decompressed backgrounds. And that's why I don't understand how to categorize this development.
I save the 690x240
nice pixel background tilesets with zx7 compression, as they take up 165600 bytes uncompressed. Checking the toolchain with absolutely no idea what I'm talking about, the total RAM appears to be
around 134625 bytes. Whether or not I'm right, I can't fit the program in the RAM with all that junk. My solution is to decompress the first 8 tiles for the opening bit where Barry commits property damage and then to decompress/free the other tiles. The ninth opening tile will need to be appended when tile 0 goes offscreen completely, and the other 6 tiles are the used during most of the gameplay. I have to have at most 8 tiles out and ready, and 6 during the rest of the time. That's a difference of 22080 bytes, and so far I can only 6 malloc'd spaces by compressing all the zapper, missile, and laser sprites and commenting out their calculations. I've been staring blankly at Microsoft Paint trying to copy chunks of the backgrounds around to help unify rows for more compact images, and then smacking myself for not using GIMP's blur function like a sane person. So far, I've got the 6 tiles, but there's none of the obstacle sprites or death animations have room to be decompressed.
Here's the gibberish in my head that translates into how I'm planning for the great RAM heist:
1. Blur the background to boost compression.
2. Limit the amount of palette entries for the background since the other sprites' quality is dropping with the influx of colors.
3. THICC.
4. I can *maybe* turn the ceiling and floor into about 12 tiles each and draw them seperately, which may or may not free up another slot for backgrounds.
5. The game runs at 27-28 FPS when decompressing a single background tile every frame with just Barry on screen.
6. I have obtained 2 boxes of spearmint altoids, or 12 tins. If I consume them I will be destroyed, but for one night I will gain godlike coding skillz.
7. I need to add another compressed tile for the hole in the wall when Barry breaks in
8. I only need Barry on screen at the beginning of the game, but I'll need to add explosion sprites too.
9. Explosion sprites can just be blocks with rough gravity physics and alternating rotation so only one sprite gets changed each frame, except when I decompress something.
10. I can malloc/free RAM for the rotated death animations when the screen flashes after death, which will also add a handy delay.
11. A full code rewrite will completely change the game entropy and result in an entire engine and hopefully better code.
12. The USB bug is RAM related and can affect things other than the USB.
13. As of now, the game isn't VYSION compatible due the lack of space for code injection that leads to some spectacular graphics artifacts or "surprise crash"
14. Calculator drama is distracting.
15. I might like explaining all my logic and tricks for posterity but these posts are getting way too long.
I hope to streamline the code to a suitable point and then upload a broken version to a fork of the Github repo since Mateo wanted to check if the USB issues are due to a toolchain bug (I haven't done it yet because I didn't want to be stabbed).
As a side question that may lead to a whole new optimization rabbithole, does ti_Open() read data directly from the flash to the RAM? Is there a way I can decompress data from the flash to the RAM? Reading the compressed data into the RAM and then decompressing it takes up lots of space and I need to be as frugal as possible right now.