Banner
Views: 844,750,056
Time:
8 users online: Infinity, kebabchilla, MegaSonic1999, Nirv, OEO6,  Telinc1, The_Uber_Camper, WhiteYoshiEgg - Guests: 40 - Bots: 84 Users: 46,453 (2,758 active)
Latest: niandra
Tip: Create a thread for your hack in the Works in Progress once you have enough screenshots/videos to show.Not logged in.
4bpp GFX Format
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - 4bpp GFX Format
Pages: « 1 »
Yeah, I'm having some trouble decoding the 4bpp graphics file format It's acting all weird... Here's what I would expect to happen:

4 bits per each pixel, or 1 nybble is used for one pixel, so 2 bytes should control 4 pixels. That seems to be correct (I'm checking in transelhextion), the weird part comes next. When I make the first color use color 2 (0 indexed) and the rest of them use color 0, the first two bytes in the file are 00 and 87. If I make it use color 0 all across, I get 00 and 07. When I change the first pixel to color F, the bytes become 80 and 87. I can't see any discernible pattern here, it seems that different nybbles are controlling the same pixel depending on what the color is, but that makes no sense, so I guess I'm missing something?
If I remember correctly, the first byte that controls "half" of the color is in one area, and the second byte that controls the other "half" is x0F (maybe x1F) bytes after the first byte, or something similar that. That probably doesn't help much since I don't have my notes on hand, but I'll post a more informative reply if I can find them.
I should get a new layout.

Probably won't, though.
The format is actually pretty strange to work with, although I read a really good document somewhere that helped me understand. Which I can no longer find. Let me try and explain it.

Here's a sample .bin I'll be using to explain.

The first half of row 1 is controlled by four bytes. Assuming we're looking a .bin file, that would be 0x0, 0x1, 0x10, and 0x11. If we break those bytes into binary, we can see something like:

0x00 - AA = 10101010

0x01 - 66 = 01100110

0x10 - 1E = 00011110

0x11 - FE = 11111110

The actual colors in the file are then read going down those four bytes.

So that means the colors in the row are

1001 = 9
0101 = A
1101 = B
0011 = C
1011 = D
0111 = E
0000 = F

and those are the color values.

I know it's a bit hard to understand, but hopefully this will help.
Ah, I see. Thats... well it's super weird. Wouldn't it make more sense to have one nybble = 1 pixel? Anyways, thanks.
I am not sure if this is the reason they did it or not, but if you ever notice in yy-chr when you switch between 4bpp SNES, 2bpp GB (which the snes uses also), and 1bpp 16x16, nearby tiles tend to combine and spit into pairs. What this means is, in practical terms, combining lower color format tiles with higher color format tiles should be simpler.

Basically, for tiles, 1 4bpp = 2 2bpp = 4 1bpp

--------------------
Your layout has been removed.
Originally posted by HuFlungDu
Ah, I see. Thats... well it's super weird. Wouldn't it make more sense to have one nybble = 1 pixel? Anyways, thanks.


The GFX formats in old consoles are never designed to be easily human readable, but to make the hardware as simple as possible. Packed pixel like you suggested is used for mode7 but only because there was no other way to do it. Having 2bpp/4bpp/8bpp follow the same general format must've simplified the h/w atleast a bit. Packed pixel would've required very unique handling of all three.
Here's a document I recommend regarding the BPP stff. If I remember correctly, ORing all the bitplanes will give you the index to the palette.

--------------------
My blog. I could post stuff now and then
Orrrr use this document/tutorial. It explains most bpp formats relevant to SMW hacking.

--------------------
--------> Don't follow "Find Roy's Dignity", my hack. Because it's pretty outdated. <--------
Pages: « 1 »
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - 4bpp GFX Format

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2020 - SMW Central
Legal Information - Privacy Policy - Link To Us


Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • Super Mario Bros. X Community
  • ROMhacking.net
  • Mario Fan Games Galaxy