Hey guys,
Over the past few days I've done a bit of experimentation with this myself. I was able to figure some things out, but sadly I will need community help on the rest.
First of all, here's what I discovered:
All of the games have a config.ini file. It looks something like this:
If you convert those 5-bit (or sometimes called 15-bit) colors to 32-bit ones, you'll notice that the first has shades of green while the second has shades of gray - hence the "COLOR_GRAY" heading.
As far as I can tell, that is the default coloring of all games - even GBC ones have this entry.
As a simple test, I used Tetris (the official VC release, just extracted and rebuilt) and changed the gray/green modes to GBC/SGB colors. You can see my success here:
I changed the colors of the green/gray to be the SGB and GBC colorized modes. I got the GBC info from here, and the SGB from here:
The big reason I chose Tetris is that all three layers have the same coloring - BG, OBJ0 and OBJ1.
Most games do not work that way, and they have different colors for different layers.
I was going to test out Kirby's Dream Land (the Kirby's Dream Collection disc for Wii has the first two GB games as virtual console and guess what, they use the same config.ini files! Using Dolphin I was able to tweak these a bit and see the results in real time.)
Something interesting though. This is the first part of the config from the Wii disc:
It actually doesn't use the first two settings at all - it uses the third one, with the three separate layers.
Neat, right? I was able to do this, to mimic the GBC colors (which does have separate colors on all three layers! Easiest way to tell is that Kirby himself is pink, which is on the OBJ0 layer!)
However, no such luck on the 3DS end. I tried all sorts of things, and it only used one layer worth of colors. Interestingly if I just deleted the Color0, Color1, Color2, Color3 and replaced them with the BG/OBJ colors from the Wii config, it still worked properly (with gray/green colors)... so those might be built-in as well and just reads from the config if it can.
Here's where it gets tricky.
I took the decompressed code.bin and searched for Color0 in a hex editor. I found a few references to them, but most notably these:
So I tried changing the second and third sets - to values like Color4, Color5, and then instead of 10 and 11 (since you can't change the size of a code.bin at all) I used Color$ and Color%
Anyway, it didn't work. Still only read the first three colors.
And this is where I need your help, gbatemp community. I don't know anything about ARM programming, and it's obvious that the code.bin is going to need to be edited in order to support separate colors for each layer. For simple colorations like Tetris, you can just modify it as-is, and rebuild it... but very few games have uniform coloring like that.
It might be simple, it might not be, but I thought I'd reach out for help - as well as share my progress so you know it definitely IS possible to do some crude coloration. I think it works a lot better than forced grayscale.
Some stuff I'd like to see, but a bit more heavy lifting:
And by the way, if you need an extracted VC title to look at, I can provide one if you PM me... but you can totally do it yourself using Decrypt9 and any VC game you own. All GB and GBC games use the same emulator and set of files as I said.
Thanks for reading! I'm looking forward to some more knowledgable code hackers being able to help.
Edit: totally random side question... how come when you modify a file in romFS and recompile in 3DS Builder, it takes much longer to load? I can compile the extracted VC contents (unmodified) in 3DS Builder, load it up via the Gateway and it takes maybe 1-2 seconds of showing the 3DS boot logo before it starts.
When I change the config it takes 10, sometimes up to 20 or even 30 seconds of showing the Nintendo 3DS logo before it finally starts.
Over the past few days I've done a bit of experimentation with this myself. I was able to figure some things out, but sadly I will need community help on the rest.
First of all, here's what I discovered:
- All Game Boy VC titles (not counting the Ambassador GBA) uses the exact same emulator. The "L+R+Y" color swapping is included with all of them, but something in the code.bin tells it - in layman's terms - if the ROM is not a GBC game (I'm quite sure it reads from the ROM header and if it finds a 0x00, it boots it in non-color mode, using the config.ini) Otherwise, it disables the palette swap mode and boots using the built-in palettes.
- There is an image file that represents the screen border when you boot in native-size mode. It's the same file for all GBC games and for all GB games, and is named "face_cgb.ttp" regardless if the image is a Game Boy "brick" or GBC.
- Functionally, the emulator is identical besides the image. If you want a prebuilt example, look at BigBlueBox's Pokémon Red and Blue releases - those ones use the GBC border, but since they do not have GBC data, you can hold L+R and press Y, which changes between gray and green modes. If you're in native-size mode, it also glitches the frame a little bit since Nintendo never planned on that option being usable with the GBC face.
All of the games have a config.ini file. It looks something like this:
;DMG実機再現カラーパレット
[DMG_COLOR]
Color0 = c23,31,4 ;R,G,B (0~31)
Color1 = c19,29,5
Color2 = c11,17,8
Color3 = c9,9,9
ColorLCD = c20,27,7 ;LCD
;DMGグレーカラー再現カラーパレット
[DMG_COLOR_GRAY]
Color0 = c25,25,21
Color1 = c20,20,17
Color2 = c13,13,10
Color3 = c5,5,3
ColorLCD = c25,25,21 ;LCD
If you convert those 5-bit (or sometimes called 15-bit) colors to 32-bit ones, you'll notice that the first has shades of green while the second has shades of gray - hence the "COLOR_GRAY" heading.
As far as I can tell, that is the default coloring of all games - even GBC ones have this entry.
As a simple test, I used Tetris (the official VC release, just extracted and rebuilt) and changed the gray/green modes to GBC/SGB colors. You can see my success here:
I changed the colors of the green/gray to be the SGB and GBC colorized modes. I got the GBC info from here, and the SGB from here:
The big reason I chose Tetris is that all three layers have the same coloring - BG, OBJ0 and OBJ1.
Most games do not work that way, and they have different colors for different layers.
I was going to test out Kirby's Dream Land (the Kirby's Dream Collection disc for Wii has the first two GB games as virtual console and guess what, they use the same config.ini files! Using Dolphin I was able to tweak these a bit and see the results in real time.)
Something interesting though. This is the first part of the config from the Wii disc:
;DMG実機再現カラーパレット
[DMG_COLOR]
Color0 = c23,31,4 ;R,G,B (0~31)
Color1 = c19,29,5
Color2 = c11,17,8
Color3 = c9,9,9
ColorLCD = c20,27,7 ;LCD
;DMGグレーカラー再現カラーパレット
[DMG_COLOR_GRAY]
Color0 = c25,25,21
Color1 = c20,20,17
Color2 = c13,13,10
Color3 = c5,5,3
ColorLCD = c25,25,21 ;LCD
[DMG_COLOR_COLOR]
BGColor0 = c23,23,19
BGColor1 = c17,17,14
BGColor2 = c11,11,9
BGColor3 = c6,6,3
OBJ0Color0 = c23,23,19
OBJ0Color1 = c17,17,14
OBJ0Color2 = c23,23,19
OBJ0Color3 = c6,6,3
OBJ1Color0 = c17,17,14
OBJ1Color1 = c17,17,14
OBJ1Color2 = c11,11,9
OBJ1Color3 = c6,6,3
ColorLCD = c23,23,19 ;LCD
It actually doesn't use the first two settings at all - it uses the third one, with the three separate layers.
Neat, right? I was able to do this, to mimic the GBC colors (which does have separate colors on all three layers! Easiest way to tell is that Kirby himself is pink, which is on the OBJ0 layer!)
However, no such luck on the 3DS end. I tried all sorts of things, and it only used one layer worth of colors. Interestingly if I just deleted the Color0, Color1, Color2, Color3 and replaced them with the BG/OBJ colors from the Wii config, it still worked properly (with gray/green colors)... so those might be built-in as well and just reads from the config if it can.
Here's where it gets tricky.
I took the decompressed code.bin and searched for Color0 in a hex editor. I found a few references to them, but most notably these:
Graphic>DMG Color Palette>BG
Graphic>DMG Color Palette>BG>Color0
Graphic>DMG Color Palette>BG>Color1
Graphic>DMG Color Palette>BG>Color2
Graphic>DMG Color Palette>OBJ0
Graphic>DMG Color Palette>OBJ1
Graphic>DMG Color Palette>OBJ0>Color0
Graphic>DMG Color Palette>OBJ0>Color1
Graphic>DMG Color Palette>OBJ0>Color2
Graphic>DMG Color Palette>OBJ0>Color3
Graphic>DMG Color Palette>OBJ1>Color0
Graphic>DMG Color Palette>OBJ1>Color1
Graphic>DMG Color Palette>OBJ1>Color2
Graphic>DMG Color Palette>OBJ1>Color3
So I tried changing the second and third sets - to values like Color4, Color5, and then instead of 10 and 11 (since you can't change the size of a code.bin at all) I used Color$ and Color%
Anyway, it didn't work. Still only read the first three colors.
And this is where I need your help, gbatemp community. I don't know anything about ARM programming, and it's obvious that the code.bin is going to need to be edited in order to support separate colors for each layer. For simple colorations like Tetris, you can just modify it as-is, and rebuild it... but very few games have uniform coloring like that.
It might be simple, it might not be, but I thought I'd reach out for help - as well as share my progress so you know it definitely IS possible to do some crude coloration. I think it works a lot better than forced grayscale.
Some stuff I'd like to see, but a bit more heavy lifting:
- More than just two color modes. Three if not four settings - so you can have a Super Game Boy palette mode*, Game Boy Color mode, original grayscale mode, and possibly the green-tinted mode too.
- *Games made after the SGB came out usually have actual SGB color palettes. The super super super awesome thing would be if we could somehow get the emulator to load these colors, like it will with GBC colors. Games like Pokémon Red and Blue have full color support via the SGB, and when using any computer emulators, you can simply put them in SGB mode and voila... full colors! They also look much nicer than the GBC colors, as those are static and do not change based on the gameplay as SGB does.
- Basically, like I mentioned in the above bullet, Super Game Boy color support.
And by the way, if you need an extracted VC title to look at, I can provide one if you PM me... but you can totally do it yourself using Decrypt9 and any VC game you own. All GB and GBC games use the same emulator and set of files as I said.
Thanks for reading! I'm looking forward to some more knowledgable code hackers being able to help.
Edit: totally random side question... how come when you modify a file in romFS and recompile in 3DS Builder, it takes much longer to load? I can compile the extracted VC contents (unmodified) in 3DS Builder, load it up via the Gateway and it takes maybe 1-2 seconds of showing the 3DS boot logo before it starts.
When I change the config it takes 10, sometimes up to 20 or even 30 seconds of showing the Nintendo 3DS logo before it finally starts.
Last edited by drfsupercenter,