gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Specify the color bank for 16 color tilemaps with Grit

#165022 - Chano Marrano - Sat Dec 06, 2008 9:13 pm

How to specify the color bank to use for 16 color tilemaps with Grit?

With gfx2gba it can be done with -b, but I have been reading Grit docs a while and I haven't seen anything...
_________________
Sh*tty RPG

#165023 - Cearn - Sat Dec 06, 2008 11:04 pm

In principle, color bank used for a tile will be the determined by the colors of the tile in question. If, say, the tile uses colors from the 0xF0-0xFF range, the screen-entry will use bank 15.

If you really need to use another bank for it, the easiest way would be to move the colors in the original bitmap. Alternatively, you could try the map-offset option, -ma. This adds a number each screen-entry, so if all the actual colors are in the first 16 colors, `-ma 0xF000' would effectively make each screen-entry use the last color bank.

#165026 - Chano Marrano - Sat Dec 06, 2008 11:34 pm

I think that the value of the map offset option is "moduled" (%) by 1024, so it can't be used for changing the color bank.
With '-ma 0xF000' option the output map is the same (I've also tried it with Wingrit, with identical results).
_________________
Sh*tty RPG

#165039 - Chano Marrano - Sun Dec 07, 2008 12:10 pm

The problem is in grit_prep_map function, at grit_prep.cpp:
Code:
for(ii=0; ii<mapN; ii++)
      {
         se= mapD[ii]&SE_ID_MASK;
         if(bBase0 || se)
            se += base;
         mapD[ii] &= ~SE_ID_MASK;
         mapD[ii] |= (se & SE_ID_MASK);
      }
Map offset is masked by SE_ID_MASK, so it can't be used for changing the color bank.

Code:
for(ii=0; ii<mapN; ii++)
      {
         se= mapD[ii];
         if(bBase0 || se)
            se += base;
         mapD[ii] |= se;
      }
This should fix the problem. At least it works for me :p.
_________________
Sh*tty RPG

#165040 - Cearn - Sun Dec 07, 2008 1:18 pm

Yeah. I originally did the masking thing to keep the tile indices from overflowing into other sections, but I guess it's not really necessary to do that. I'll change it soon enough.

#165041 - Chano Marrano - Sun Dec 07, 2008 3:35 pm

I think it would be better to keep offset masking and to add a specific option for the color banks because overwriting horizontal/vertical flipping section is not a good idea (I don't find a reason to change that intentionally).
_________________
Sh*tty RPG

#165045 - Cearn - Sun Dec 07, 2008 6:59 pm

I've changed it so that the offset applies to each field separately; no overwriting things that they shouldn't. It should work now.