Uzebox / uzebox

A retro-minimalist game console engine for the ATMega644
http://uzebox.org
126 stars 43 forks source link

Megatiles #60

Closed lawrencebrooks closed 7 years ago

lawrencebrooks commented 8 years ago

I've implemented mega tile compression in the gconvert tool. This allows a user to define a big level map that would normally be too large to be practical (eg. when doing big scrolling levels). The tool will then automatically create a 'mega map' with de-duplicated mega tiles. The original level map will then index the mega map instead of the tile map. The mega map in turn indexes the tile map. . Now you can draw out your entire scrolling level in your favorite graphics editor and gconvert will perform this compression for you automatically on request. Below is an example configuration and conversion. I hope the community finds this useful.

        <mega-map var-name="map_level_mega_tiles" mega-tile-width="5" mega-tile-height="5">
            <map var-name="map_level_1" left="0" top="10" width="255" height="25"/>
            <map var-name="map_level_2" left="0" top="62" width="255" height="25"/>
            <map var-name="map_level_3" left="0" top="88" width="255" height="25"/>
            <map var-name="map_level_4" left="0" top="114" width="255" height="25"/>
            <map var-name="map_level_5" left="0" top="140" width="255" height="25"/>
        </mega-map>
        <mega-map var-name="map_extra_mega_tiles" mega-tile-width="4" mega-tile-height="5">
            <map var-name="map_level_6" left="0" top="36" width="32" height="25"/>
        </mega-map>

Example conversion: ... #define MAP_LEVEL_6_WIDTH 8 #define MAP_LEVEL_6_HEIGHT 5 const char map_level_6[] PROGMEM ={ 8,5 ,0x0,0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0x0,0xa,0xb,0x0,0x3,0xc,0xd,0xe,0xf,0x10 ,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1a,0x1b,0x1c,0x6,0xc,0x1d,0x3,0x1e,0x1f,0x3,0x20``}; #define MAP_EXTRA_MEGA_TILES_MEGA_TILE_WIDTH 4 #define MAP_EXTRA_MEGA_TILES_MEGA_TILE_HEIGHT 5 #define MAP_EXTRA_MEGA_TILES_MEGA_TILE_COUNT 33 const char map_extra_mega_tiles[] PROGMEM ={ 0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1d,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, 0x0,0x0,0x0,0x1d,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0, ...

The code has been tested and works fine.

I've replied to the gconvert forum post on this topic: http://uzebox.org/forums/viewtopic.php?f=6&t=639&p=17561#p17561

weber21w commented 7 years ago

This seems a great feature to have in the main branch. It seems there is no reason not to merge?

Jubatian commented 7 years ago

Could you revise this modification? I still didn't merge it since I never looked in this part of the Uzebox repo, and well, it was up even before I gained admin rights here. If you using GConvert like this feature, then I would just merge it (does it change the interface, I mean would it impact users not being aware of this modification?).

lawrencebrooks commented 7 years ago

Would you like me to revise or review it? I don't mind making some changes if you feel some is required. This feature was built to not interfere with existing functionality. So a user not being aware of this feature, won't notice the difference. I've used this feature for Iros actively until very recently so the code shouldn't be stale (I don't think gconvert has changed at all recently).

One change that could perhaps be made is to change the terminology from 'Megatile' to 'Metatile' which seems to be a more standard way of referring to this type of feature.

Let me know what changes you would like to see and what tests I can perform to ensure you are comfortable with merging this in.

lawrencebrooks commented 7 years ago

If and when everyone is happy and this feature is merged, I will follow this up with a wiki entry.

Jubatian commented 7 years ago

OK, merged. Just had to ask since it was a little old, so to know whether it is all right and up to date!