In my game, the levels will be generated randomly, so I don't need to save them in the ROM.
But the game will have two screens worth of background data that simply loop.
During gameplay, they will be saved uncompressed in RAM, so that they can be quickly redrawn whenever an actual foreground/gameplay element appeared in front of them.
But what is the best way to save the layout in the ROM, so that it takes little space? And how do I do this best?
I think that I will not save the individual tiles, but abstract values that stand for a 16 x 16 element. This way, I can save 3/4 of the space.
How do I do this best? Do I declare a two-dimensional array where the Y dimension is the abstract value and the X dimension has four entries for each actual tile? Or is there a better way?
Also, how else can I compress it? I guess RLE doesn't work here since I probably won't have many identical elements next to each other. (The background will be some skyline of a city with skyscrapers, factories, cranes etc.)
Another problem: The compression algorithm and the mapping array shouldn't be bigger than the data if I just saved it uncompressed. Since I just have onebackground for the whole game, this might be an issue.
And how do I write the palettes the best?
While I understand that you can only map a palette for each 16 x 16 area instead of each tile, I never understood why one byte of the palette data is
a) mapped to a 32 x 32 pixel area instead of a 64 x 16 area (i.e. four blocks in a square instead of four blocks right after another).
b) the palette appears at the end of the background data instead of right after each tile collection that it belongs to.
What is the best way to access the correct palette value for any 16 x 16 pixel area? I mean, if palette data 1 referred to the 16 x 16 pixel blocks number 1, 2, 3 and 4 while palette data 2 referred to block 5, 6, 7 and 8, the calculation would be quite simple. But palette data 1 refers to blocks 1, 2, 17 and 18. And palette data 2 refers to 3, 4, 19 and 20.
What is the best way to set any of these palette entries in the PPU?
But the game will have two screens worth of background data that simply loop.
During gameplay, they will be saved uncompressed in RAM, so that they can be quickly redrawn whenever an actual foreground/gameplay element appeared in front of them.
But what is the best way to save the layout in the ROM, so that it takes little space? And how do I do this best?
I think that I will not save the individual tiles, but abstract values that stand for a 16 x 16 element. This way, I can save 3/4 of the space.
How do I do this best? Do I declare a two-dimensional array where the Y dimension is the abstract value and the X dimension has four entries for each actual tile? Or is there a better way?
Also, how else can I compress it? I guess RLE doesn't work here since I probably won't have many identical elements next to each other. (The background will be some skyline of a city with skyscrapers, factories, cranes etc.)
Another problem: The compression algorithm and the mapping array shouldn't be bigger than the data if I just saved it uncompressed. Since I just have onebackground for the whole game, this might be an issue.
And how do I write the palettes the best?
While I understand that you can only map a palette for each 16 x 16 area instead of each tile, I never understood why one byte of the palette data is
a) mapped to a 32 x 32 pixel area instead of a 64 x 16 area (i.e. four blocks in a square instead of four blocks right after another).
b) the palette appears at the end of the background data instead of right after each tile collection that it belongs to.
What is the best way to access the correct palette value for any 16 x 16 pixel area? I mean, if palette data 1 referred to the 16 x 16 pixel blocks number 1, 2, 3 and 4 while palette data 2 referred to block 5, 6, 7 and 8, the calculation would be quite simple. But palette data 1 refers to blocks 1, 2, 17 and 18. And palette data 2 refers to 3, 4, 19 and 20.
What is the best way to set any of these palette entries in the PPU?