Optiroc / SuperFamiconv

Flexible and composable tile graphics converter supporting Super Nintendo, Game Boy, Game Boy Color, Game Boy Advance, Mega Drive, PC Engine and WonderSwan formats.
MIT License
154 stars 22 forks source link

Support Game Boy Advance mode #12

Closed Rangi42 closed 4 years ago

Rangi42 commented 5 years ago

The GBA 4bpp tilemap format is similar to the SNES 2bpp mode, but with a fourth palette bit instead of a priority bit:

FEDC BA98 7654 3210  SNES tilemap
|||| ||++-++++-++++- Character number (max. 0x03FF)
|||+-++------------- Palette
||+----------------- Priority
|+------------------ Flip horizontally
+------------------- Flip vertically

FEDC BA98 7654 3210  GBA tilemap
|||| ||++-++++-++++- Character number (max. 0x01FF)
|||| |+------------- Flip horizontally
|||| +-------------- Flip vertically
++++---------------- Palette

Also, each 16-color subpalette has its own color 0.

Optiroc commented 5 years ago

Why not?! 👍

Optiroc commented 4 years ago

@Rangi42 Decided to add GBA support now. Reading the nocash GBATEK docs, it seems like color 0 is always transparent, similar to how SNES works: http://problemkaputt.de/gbatek.htm#lcdcolorpalettes

While your comment suggests each subpalette should get its own, usable, color. I haven't programmed GBA personally, so at the moment I'm unsure how I should handle palettes...

Rangi42 commented 4 years ago

Color 0 of all BG and OBJ palettes is transparent. Even though palettes are described as 16 (256) color palettes, only 15 (255) colors are actually visible.

If the 256 colors are being used as 16 palettes of 16 colors each, all 16 palettes have their own color #0 which is transparent.

Example:

image

The leftmost colors are all transparent, for both BG and OBJ tiles.

Optiroc commented 4 years ago

OK, thanks. That sounds very much like SNES, then. In the SNES case, palette position 0 is used as the background color (ie. it's the color shown if everything on that pixel is transparent). Is that the case also on GBA?

Rangi42 commented 4 years ago

Yes, I think so.

Optiroc commented 4 years ago

Cool. I’ll make a release with preliminary support tonight or so, and I’ll catch possible incorrectness if anything is found.

Optiroc commented 4 years ago

I added GBA support today, with an extra gba_affine mode which is analogous to the snes_mode7 mode (very similar limitations too, with the 256 tile limit without attributes): v0.9.1

For now I haven't tested the output, except for looking at it in an hex editor without being shocked by the result. 🤔

Rangi42 commented 4 years ago

It looks accurate to me too. Files open as expected in Tilemap Studio.

Thanks for adding this!

Optiroc commented 4 years ago

Thumbs up!