I'm playing around a bit with code for a new game. This new game will have a "The Legend of Zelda"-like scrolling, i.e. screen by screen.
To store the layout of each screen in ROM, I intended to use a method where each meta tile is represented by two bytes:
Low byte 1: x position
High byte 1: y position
Byte 2: Meta sprite index
The x and the y position would be aligned to 16 pixels each, so an x value of 3 would mean that the actual tiles start at pixel position 3 * 16 = 48.
Now, when it comes to scrolling, I would update the screen in "stripes".
I.e. if you go to the screen below you, the screen would be updated from the first to the last row, one row per frame.
If you go to the screen left of you, the next screen would be updated vertically, starting from the rightmost column, continuing to the leftmost column.
But to do this, I would need to extract the screen data first.
So, I thought that I create an array with 32 * 30 items where I include all the actual graphics tile values. Then, when the scrolling is being done, the procedure could grab the corresponding values from the array and copy them to the array that includes the PPU updates which is then read during NMI.
1. Once per scrolling:
Compressed data in ROM --> Uncompressed array in RAM
2. Every frame during scrolling until everything is drawn:
Single "stripe" of uncompressed array in RAM + PPU update address + drawing information (horizontal/vertical) --> PPU help array
3. Every frame during scrolling in NMI until everything is drawn:
PPU help array --> PPU
But now there's the first problem:
The uncompressed array is 32 * 30 items (+ color information). Which is already too much for the RAM. The RAM might have $600 bytes, but I also need bytes for the C software stack and enough room for non-zeropage variables. So, I fear that it might become pretty close.
Therefore my question: Is there another way to decompress the screen data?
I cannot extract line by line because the data is saved per meta tile. And each meta tile can have a variable size.
I.e. if the X and Y position of a tree is 6 and 5, then you still don't know how wide and tall the tiles of the tree will be until you check the meta sprite definition itself. So, it's pretty hard to say: "Extract me the 18th on-screen row from the compressed data."
What can I do here? How do I extract the data, to update the screen row by row or column by column during scrolling, without wasting 32 * 30 bytes for a buffer array?
To store the layout of each screen in ROM, I intended to use a method where each meta tile is represented by two bytes:
Low byte 1: x position
High byte 1: y position
Byte 2: Meta sprite index
The x and the y position would be aligned to 16 pixels each, so an x value of 3 would mean that the actual tiles start at pixel position 3 * 16 = 48.
Now, when it comes to scrolling, I would update the screen in "stripes".
I.e. if you go to the screen below you, the screen would be updated from the first to the last row, one row per frame.
If you go to the screen left of you, the next screen would be updated vertically, starting from the rightmost column, continuing to the leftmost column.
But to do this, I would need to extract the screen data first.
So, I thought that I create an array with 32 * 30 items where I include all the actual graphics tile values. Then, when the scrolling is being done, the procedure could grab the corresponding values from the array and copy them to the array that includes the PPU updates which is then read during NMI.
1. Once per scrolling:
Compressed data in ROM --> Uncompressed array in RAM
2. Every frame during scrolling until everything is drawn:
Single "stripe" of uncompressed array in RAM + PPU update address + drawing information (horizontal/vertical) --> PPU help array
3. Every frame during scrolling in NMI until everything is drawn:
PPU help array --> PPU
But now there's the first problem:
The uncompressed array is 32 * 30 items (+ color information). Which is already too much for the RAM. The RAM might have $600 bytes, but I also need bytes for the C software stack and enough room for non-zeropage variables. So, I fear that it might become pretty close.
Therefore my question: Is there another way to decompress the screen data?
I cannot extract line by line because the data is saved per meta tile. And each meta tile can have a variable size.
I.e. if the X and Y position of a tree is 6 and 5, then you still don't know how wide and tall the tiles of the tree will be until you check the meta sprite definition itself. So, it's pretty hard to say: "Extract me the 18th on-screen row from the compressed data."
What can I do here? How do I extract the data, to update the screen row by row or column by column during scrolling, without wasting 32 * 30 bytes for a buffer array?