When not to compress stuff.
Moderator: Moderators
When not to compress stuff.
Okay, so I've been reading up a lot about level compression and now have this question:
Is there anything specific that you leave out of your compressed level format? For example, to me it makes sense to store your objects (enemies, items, etc) separate from your nametable data, but what about tile attributes such as collision data (solid, nonsolid, ice)?
Also, while I'm here, I was thinking about storing palette information with my 32x32 metatiles, but would it be better to combine it with other tile attributes (solid, etc) and put it with 16x16 metatiles instead?
Is there anything specific that you leave out of your compressed level format? For example, to me it makes sense to store your objects (enemies, items, etc) separate from your nametable data, but what about tile attributes such as collision data (solid, nonsolid, ice)?
Also, while I'm here, I was thinking about storing palette information with my 32x32 metatiles, but would it be better to combine it with other tile attributes (solid, etc) and put it with 16x16 metatiles instead?
I definitely wouldn't recommend leaving out collision/physics data from being compressed in some way. Storing large arrays of collision data in ROM would be a waste. You might want to store collision data for each 32x32 block or 16x16 block, whichever you find suits you best as there isn't just 1 correct answer. Storing Attribute data in your 32x32 blocks makes sense as each attribute table byte represents that much space and could make your updating of the attribute table less complicated. Although you could do it for smaller areas by saving a copy of the attribute table in RAM somewhere as I remember some people suggesting.
If you represent your game's world as a grid of metatiles, then ideally, surface characteristics such as slope, solidity, and slipperiness should be attached to the metatiles, not the map. For example, the map might say "ice blocks here", and then you'd look up the friction for "ice block" in a table.
Which way are you scrolling? There are fairly efficient ways to build an attribute update buffer depending on this, even for 16x16 pixel metatiles.
Which way are you scrolling? There are fairly efficient ways to build an attribute update buffer depending on this, even for 16x16 pixel metatiles.
Re: When not to compress stuff.
I thing this depends a lot on the project, and specially on how much RAM and ROM you have. If you have a lot of RAM (like 8KB of it in the cart) it makes sense to have nearly everything compressed, as you can just decompress the data to this memory and use it from there. But if you don't have a lot of RAM you'll most likely have to leave some things uncompressed or compressed with a scheme that allows for random access (not the case of LZ or RLE, for example).Ian A wrote:Is there anything specific that you leave out of your compressed level format? For example, to me it makes sense to store your objects (enemies, items, etc) separate from your nametable data, but what about tile attributes such as collision data (solid, nonsolid, ice)?
I have my palette information in the 16x16 metatiles, but that's only because I have small objects that overwrite the background which need that kind of precision, but if it weren't for these objects it sure would be easier to have all the palette info be part of the 32x32 metatiles.Also, while I'm here, I was thinking about storing palette information with my 32x32 metatiles, but would it be better to combine it with other tile attributes (solid, etc) and put it with 16x16 metatiles instead?
Re: When not to compress stuff.
I was thinking four way scrolling, but with vertical mirroring.tepples wrote: Which way are you scrolling? There are fairly efficient ways to build an attribute update buffer depending on this, even for 16x16 pixel metatiles.
I'm thinking about using MMC1, so I'll probably have quite a bit of both, but I'm worried about maneuvering through the map data with being able to scroll in four directions.tokumaru wrote: I thing this depends a lot on the project, and specially on how much RAM and ROM you have. If you have a lot of RAM (like 8KB of it in the cart) it makes sense to have nearly everything compressed, as you can just decompress the data to this memory and use it from there. But if you don't have a lot of RAM you'll most likely have to leave some things uncompressed or compressed with a scheme that allows for random access (not the case of LZ or RLE, for example).
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
I always have collision information embedded in my 16x16 metatile definitions. However, I do like to have palette information tied to my 32x32 metatiles. That way all I have to do to make levels is place tiles in a grid, and since I'm only specifying which tile goes where, it allows me to free up bits for more tile definitions (so I don't have to sacrifice bits for color/collision information when designing levels). Having the color information with 32x32 metatiles also saves time, as you don't have to do as much bit manipulation as you do with 16x16 metatiles.
Re: When not to compress stuff.
I consider vertical mirroring (unique nametables side by side) the best choice for four way scrolling. Scrolling glitches are less annoying at the top and at the bottom of the screen than at the sides.Ian A wrote:I was thinking four way scrolling, but with vertical mirroring.
IMO, the fact that the nametables are 30 tiles tall kills some of the benefits of assigning attributes to the 32x32 metatiles, because you'll have to do some manipulation on the nibbles depending on the vertical scroll. Since you'll have to do bit manipulation anyway you might just decide to switch to 16x16 attribute precision.tokumaru wrote:I'm thinking about using MMC1, so I'll probably have quite a bit of both, but I'm worried about maneuvering through the map data with being able to scroll in four directions.
If you want to keep your options open, you should just stick to having all the attributes/properties be part of the 16x16 metatiles. This means you will not be able to take some shortcuts when rendering or reading that data, but it also means that you will not need to rewrite a lot of code or rearrange a lot of data in case you decide to modify something about your rendering and physics engines.
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
I was originally going to do this for one of my projects, but the problem is you sacrifice 192 metatile IDs just so you can save a lookup table. I do think this is a great solution if you are using <= 64 16x16 tiles, but for more graphically detailed/complex games where you might use more 16x16 tiles, I think it's better to use a lookup table.tepples wrote:PROTIP: Use the upper 2 bits of the 16x16 pixel metatile number as the attribute number. For example, tile $04 wound be palette 0, $B5 could be palette 2, etc. SMB1 does this, and it saves a table lookup.
Well, I think you'd still have 256 meta tiles, but they'd be in four groups organized by palette. You'd only be able to have 64 for each palette, though. That's assuming I'm understanding this correctly, though.Celius wrote:I was originally going to do this for one of my projects, but the problem is you sacrifice 192 metatile IDs just so you can save a lookup table. I do think this is a great solution if you are using <= 64 16x16 tiles, but for more graphically detailed/complex games where you might use more 16x16 tiles, I think it's better to use a lookup table.tepples wrote:PROTIP: Use the upper 2 bits of the 16x16 pixel metatile number as the attribute number. For example, tile $04 wound be palette 0, $B5 could be palette 2, etc. SMB1 does this, and it saves a table lookup.
I've got a bit to think about now, but this helped me sort out a lot of stuff. Thanks!
You understand perfectly. Metatile $41 need not have the same picture or surface information as metatile $01; they can be completely unrelated.Ian A wrote:Well, I think you'd still have 256 meta tiles, but they'd be in four groups organized by palette. You'd only be able to have 64 for each palette, though. That's assuming I'm understanding this correctly, though.Celius wrote:I was originally going to do this for one of my projects, but the problem is you sacrifice 192 metatile IDs just so you can save a lookup table.tepples wrote:Use the upper 2 bits of the 16x16 pixel metatile number as the attribute number [like] SMB1
-
Celius
- Posts: 2159
- Joined: Sun Jun 05, 2005 2:04 pm
- Location: Minneapolis, Minnesota, United States
- Contact:
Wow, I never thought about it like that, actually. Still, you're limited in what you can do, and if you have lookup tables where you use the tile ID as an index, you're forced to have it be at least 192 bytes if you want to use the fourth palette. In that case, you might actually save space by having an extra lookup table for attribute information. But of course, you have to look at your end results to see which is more efficient (once you have all your metatiles defined, try both methods and see which one saves you space/time).
Super Mario Bros. gets around this by splitting a lot of its lookup tables into four parts, but depending on what you're doing with it, that might be another lookup. So the game might use $01-$2F, $40-$56, $80-$A2, etc. This is also how it solves the problem of 1024 bytes being too much for an index register: it only takes 256 bytes for each 64-tile table.Celius wrote:Wow, I never thought about it like that, actually. Still, you're limited in what you can do, and if you have lookup tables where you use the tile ID as an index, you're forced to have it be at least 192 bytes if you want to use the fourth palette.