ROM Hack Editing GB(C) Emulator with Colors (read info)

drfsupercenter

Flash Cart Aficionado
OP
Member
Joined
Mar 26, 2008
Messages
1,909
Trophies
1
XP
1,163
Country
United States
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 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:

tv0dycE.jpg


KAjOFvs.jpg


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:
Tetris_SGB_Palette_Title.png


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!)

7225xr6.png



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.
What do you guys think?

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,

AleronIves

Well-Known Member
Member
Joined
Nov 17, 2016
Messages
460
Trophies
0
Age
36
Location
California
XP
2,244
Country
United States
True, but Nintendo's emulators are pretty barebones compared to homebrew ones. Nintendo gave priority to making all VC titles equal in terms of features, so games with SGB and GBC palettes remain greyscale. Since your post is five years old, I guess 3DS devs don't want to reinvent the wheel when it comes to supporting extra palettes.

BTW regarding Kirby's Dream Collection, the other games are also VC titles, and you can extract and rebuild the ROMs with vcromclaim. I've played through Kirby's Adventure, Kirby Super Star, and Kirby's Dream Land 3 on my 3DS thanks to KDC. :)
 

drfsupercenter

Flash Cart Aficionado
OP
Member
Joined
Mar 26, 2008
Messages
1,909
Trophies
1
XP
1,163
Country
United States
True, but Nintendo's emulators are pretty barebones compared to homebrew ones. Nintendo gave priority to making all VC titles equal in terms of features, so games with SGB and GBC palettes remain greyscale. Since your post is five years old, I guess 3DS devs don't want to reinvent the wheel when it comes to supporting extra palettes.

GBC palettes show up fine, it's only the ones with SGB that don't. Games like Pokémon Yellow (outside of Japan) have the GBC palettes and are in full color on the VC. Starting at 1:12 in this video you can see them playing the original "Medarot" game from 1997, but the emulator has it in full color. I checked in an emulator and it is indeed the Super Gameboy colors that are being shown. The 3DS compilation of those games has it in greyscale, because of course it does.

Interesting thing, I just discovered the Japanese compilation of Medabots game has an emulator that uses SGB colors.

BTW regarding Kirby's Dream Collection, the other games are also VC titles, and you can extract and rebuild the ROMs with vcromclaim. I've played through Kirby's Adventure, Kirby Super Star, and Kirby's Dream Land 3 on my 3DS thanks to KDC. :)

Aren't the Game Boy games available as 3DS VC as well? I'm pretty sure I bought at least the original Kirby's Dream Land on my 3DS.
 

AleronIves

Well-Known Member
Member
Joined
Nov 17, 2016
Messages
460
Trophies
0
Age
36
Location
California
XP
2,244
Country
United States
Games like Pokémon Yellow (outside of Japan) have the GBC palettes and are in full color on the VC.
Pokemon Yellow is kind of a special case. Red and Blue have colour when played on SGB but not GBC. Pokemon Yellow was reworked so the SGB colours are usable by the GBC, so 3DS VC would most likely be running Yellow in the GBC emulator. Since R/B require SGB to access the colour graphics, 3DS VC shows them greyscale in the regular DMG emulator. I don't think any 3DS VC is able to use SGB palettes, even though the SGB information is still present in the VC ROM files.

Aren't the Game Boy games available as 3DS VC as well?
Sure, but I already own KDL1/2 carts and GB cart dumpers, so I don't need to buy the VC titles. The SNES Kirby titles are sadly not on the eShop, because Nintendo doesn't support any SA-1 SNES titles on 3DS. Thankfully, homebrew SNES emulators are able to run SA-1 games on N3DS at full speed, so you can still play the SNES games from Kirby's Dream Collection on a modded 3DS.
 

lone_wolf323

Well-Known Member
Member
Joined
May 27, 2011
Messages
5,485
Trophies
2
XP
4,929
Country
Canada
Pokemon Yellow is kind of a special case. Red and Blue have colour when played on SGB but not GBC. Pokemon Yellow was reworked so the SGB colours are usable by the GBC, so 3DS VC would most likely be running Yellow in the GBC emulator. Since R/B require SGB to access the colour graphics, 3DS VC shows them greyscale in the regular DMG emulator. I don't think any 3DS VC is able to use SGB palettes, even though the SGB information is still present in the VC ROM files.


Sure, but I already own KDL1/2 carts and GB cart dumpers, so I don't need to buy the VC titles. The SNES Kirby titles are sadly not on the eShop, because Nintendo doesn't support any SA-1 SNES titles on 3DS. Thankfully, homebrew SNES emulators are able to run SA-1 games on N3DS at full speed, so you can still play the SNES games from Kirby's Dream Collection on a modded 3DS.
Kirby dream course was about the only snes release nintendo did https://www.nintendo.com/games/detail/kirbys-dream-course-3ds/

** I do realize this one i dont think needed the SA-1 chip to run. The rest of them never got a eshop release
 
Last edited by lone_wolf323,

drfsupercenter

Flash Cart Aficionado
OP
Member
Joined
Mar 26, 2008
Messages
1,909
Trophies
1
XP
1,163
Country
United States
Pokemon Yellow is kind of a special case. Red and Blue have colour when played on SGB but not GBC. Pokemon Yellow was reworked so the SGB colours are usable by the GBC, so 3DS VC would most likely be running Yellow in the GBC emulator. Since R/B require SGB to access the colour graphics, 3DS VC shows them greyscale in the regular DMG emulator. I don't think any 3DS VC is able to use SGB palettes, even though the SGB information is still present in the VC ROM files.

All of the VC releases used a 100% unmodified ROM that matches the retail cartridge. It's quite odd actually, they applied a ton of patches to the games to make the wireless trading work, but the ROM files themselves are the same as what we've had for years, all the custom stuff is done via patches. Even the Jynx censorship in Yellow is done in a patch and not editing the ROM.

So yes, the emulator used in Game Boy VC does both GB and GBC, it's the same exact emulator used in both, I mentioned this a bit in my original post from 2016. All it's doing is checking 0x143 and if it's 0x80 or 0xC0 it disables the palette-switcher and uses GBC mode. If it's 0x00 (like Pokémon Red and Blue), it starts up in greyscale mode and lets you switch to the ugly green mode.

As far as Yellow and being a hack of SGB... I just came across this thread at ProjectPokémon and the OP mentions something similar. Whether the story is true or not (of them coming up with a hacky method to convert SGB palettes because it would be poorly received in the US), the fact is that yes, international Yellow version has both SGB palettes *and* GBC palettes, and they are basically the same thing. GBC is just brighter because of the lack of a backlight.

I do think there's a viable solution in modifying the actual ROM files and putting colors in there, but for games that predate the SGB (like, Tetris and all the older ones... Mario Land 1 and 2, etc) it's a bit overkill to change the ROM when you can simply edit the colors in the .ini file. Just need to figure out how to do the different layers
 

AleronIves

Well-Known Member
Member
Joined
Nov 17, 2016
Messages
460
Trophies
0
Age
36
Location
California
XP
2,244
Country
United States
All of the VC releases used a 100% unmodified ROM that matches the retail cartridge. It's quite odd actually, they applied a ton of patches to the games to make the wireless trading work, but the ROM files themselves are the same as what we've had for years, all the custom stuff is done via patches.
It's not odd at all. Changing a ROM is a huge pain, so using patches is the preferred way to avoid having to rebuild the ROM. Most commercial emulators work this way today, AFAIK.

As far as Yellow and being a hack of SGB... I just came across this thread at ProjectPokémon and the OP mentions something similar.
It doesn't matter if it's a "hack" or not. Game Freak added GBC palettes to Yellow that look the same as SGB mode, but Red/Blue are SGB only, and Nintendo's DMG emulator does not support SGB features. Judging by his codebase, making the SGB palettes readable by GBC required tons of new code. He managed to backport the feature to Red and Blue, but it wasn't easy at all.

Kirby dream course was about the only snes release nintendo did
** I do realize this one i dont think needed the SA-1 chip to run. The rest of them never got a eshop release
Yes, the golf game doesn't use SA-1, so Nintendo put it on 3DS. The SA-1 Kirby games only came out on the Wii U's VC. It's just sad, because N3DS is more than fast enough to emulate SA-1 games, but Nintendo didn't bother to write a good enough emulator to do it on 3DS, so we have to rely on homebrew, just like we do for SGB support.
 
Last edited by AleronIves,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    OctoAori20 @ OctoAori20: Nice nice-