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

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by drfsupercenter, Mar 26, 2016.

  1. drfsupercenter
    OP

    drfsupercenter Flash Cart Aficionado

    Member
    1,900
    236
    Mar 26, 2008
    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:
    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:

    [​IMG]

    [​IMG]

    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:
    [​IMG]

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

    [​IMG]


    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:

    • 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, Mar 26, 2016