Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 88,487,345
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 04-26-24 12:19 PM
Guest: Register | Login

0 users currently in ROM Hacking | 4 guests

Main - ROM Hacking - Color palette display help New thread | New reply


Stifu
Posted on 03-23-07 10:28 PM Link | Quote | ID: 18507


Cobrat
Level: 56

Posts: 58/666
EXP: 1361299
Next: 36877

Since: 02-22-07

Last post: 685 days
Last view: 307 days
Sooo... I'd like to display SNES color palettes in my editor (coded in C++). Any tips ?
I know colors are defined by 2 bytes, so 4 figures... The first figure could be the alpha channel, while the 3 others are the RGB ones, or something ?
Can anyone direct me to some documentation, or program sources ? I'm currently having a look at the sources of Tile Molester, but there may be something better for me to look at...

Thanks.

Kawa
Posted on 03-23-07 10:45 PM (rev. 2 of 03-23-07 10:45 PM) Link | Quote | ID: 18511


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 124/5344
EXP: 30945013
Next: 717968

Since: 02-20-07
From: The Netherlands

Last post: 4498 days
Last view: 2633 days
1 bit wasted, 5 blue, 5 green, 5 red.
In that order.

0x0000 black, 0x7FFF white.

Same format as DS, GBA, GBC and SGB.

Fun fact: 0xFFFF is also white but the last bit is ignored so yeah.

Edit: Best I have is a VB6 program I made.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

Stifu
Posted on 03-24-07 09:17 AM Link | Quote | ID: 18663


Cobrat
Level: 56

Posts: 59/666
EXP: 1361299
Next: 36877

Since: 02-22-07

Last post: 685 days
Last view: 307 days
I'm still confused... 1+5+5+5 = 16, so that's just one byte out of 4 then ?

Got other examples other than black and white ? Thanks...

Sukasa
Posted on 03-24-07 09:39 AM (rev. 2 of 03-24-07 09:40 AM) Link | Quote | ID: 18664


Red Birdo
Level: 92

Posts: 94/2112
EXP: 7689401
Next: 67536

Since: 02-19-07

Last post: 4448 days
Last view: 3219 days
The bits are like this x b b b b b g g | g g g r r r r r

(High Byte | Low Byte)

x - Unused
b - blue
g - green
r - red

Stifu
Posted on 03-24-07 09:58 AM (rev. 2 of 03-24-07 10:02 AM) Link | Quote | ID: 18665


Cobrat
Level: 56

Posts: 60/666
EXP: 1361299
Next: 36877

Since: 02-22-07

Last post: 685 days
Last view: 307 days
Ah okay, I get it better...
Although I have no idea how to handle colors if they are shared like that. For example, the 3rd figure is 3g and 1r... How do you deal with that ? So changing that figure will affect both the green and the red ?
Or maybe I should just not set my editor to hex mode, but to another one that'd display 16 figures rather than 4 ?

I need to study that more...

Kawa
Posted on 03-24-07 10:25 AM Link | Quote | ID: 18667


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 127/5344
EXP: 30945013
Next: 717968

Since: 02-20-07
From: The Netherlands

Last post: 4498 days
Last view: 2633 days
Bit shifting, masking and scaling.

Where you'd convert a Windows-style 24/32-bit color by masking out complete bytes, you'd mask out a SNES-style 15-bit color by masking out only the right bits.

Here's the VB code I used to convert 15 to 24 bits:

snesR = snesColor And &H1F
snesG = (snesColor / 32) And &H1F
snesB = (snesColor / 1024) And &H1F
winColor = RGB(snesR * 8.3, snesG * 8.3 snesB * 8.3)

All magic is hand-calculated because VB Classic does not have bitshifting ops. Normally, you'd do bitshifts instead of / and * but that's pretty much the only difference. The 8.3 is only to make sure 0x1F really does become 0xFF.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

Stifu
Posted on 03-24-07 11:39 AM Link | Quote | ID: 18671


Cobrat
Level: 56

Posts: 61/666
EXP: 1361299
Next: 36877

Since: 02-22-07

Last post: 685 days
Last view: 307 days
Thank you.
I assume that in "snesColor", you have the data of the color palettes...
But what's in &H1F ?
I've never done anything like that, but your code looks short and simple enough (although I don't quite get it yet), so hopefully I'll get it right soon.

Kawa
Posted on 03-24-07 11:47 AM (rev. 2 of 03-24-07 11:49 AM) Link | Quote | ID: 18672


CHIKKN NI A BAAZZKIT!!!
80's Cheerilee is best pony
Level: 138

Posts: 128/5344
EXP: 30945013
Next: 717968

Since: 02-20-07
From: The Netherlands

Last post: 4498 days
Last view: 2633 days
&H is VB's 0x and its bit pattern is 00011111b.

Basically, I cut out 11111111111111100000 by anding snesColor with 0x1F. That's one. For the rest, I shift out the first five/ten bits before anding.

____________________
Wife make lunch - Shampoo
Opera - give it a spin
Spare some of your free time?
<GreyMaria> I walked around the Lake so many goddamn times that my sex drive was brutally murdered
Kawa rocks — byuu

Keitaro
Posted on 03-24-07 07:24 PM Link | Quote | ID: 18766


Mole
Level: 42

Posts: 200/351
EXP: 520941
Next: 421

Since: 02-19-07
From: Massachusetts

Last post: 5965 days
Last view: 5402 days
Another thing you could always do is enter the RGB values in to something like TLP, then save the pallet to a file. Hex edit it, and ignore the first four bytes (those are a header of sorts for the pallet file) and you have your pallet, stored in whatever format you were working with.

dirtbag
Posted on 03-24-07 10:18 PM Link | Quote | ID: 18829


Red Koopa
Level: 27

Posts: 16/128
EXP: 114678
Next: 1481

Since: 02-24-07

Last post: 3187 days
Last view: 3101 days
Posted by Keitaro
Another thing you could always do is enter the RGB values in to something like TLP, then save the pallet to a file. Hex edit it, and ignore the first four bytes (those are a header of sorts for the pallet file) and you have your pallet, stored in whatever format you were working with.


The problem with that is that the pallet would not be worked out dynamically then. It would be working on the assumption that the ROM contains the default colour pallet.

Stifu
Posted on 03-24-07 10:57 PM Link | Quote | ID: 18840


Cobrat
Level: 56

Posts: 62/666
EXP: 1361299
Next: 36877

Since: 02-22-07

Last post: 685 days
Last view: 307 days
Yeah, the whole point is to have something dynamic, else I could just display BMP pictures like Track Designer does...

Anyway, I'll work more on this later...

Main - ROM Hacking - Color palette display help New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.020 seconds. (339KB of memory used)
MySQL - queries: 72, rows: 102/103, time: 0.014 seconds.