User Tools

Site Tools


return_of_samus:technical_information:modding_ejrtq

Introduction

EJRTQ is a mod that converts Metroid 2 to full color, taking advantage of the Game Boy Color features not present in the original Game Boy. While not designed for moddability, most of EJRTQ’s color features can be modded fairly easily (others not so much).

Memory Map

Address Description
5:7F34 byte[20] Status Bar Tile Palettes
10:4000 word[8][2][4] Standard Palette

Color Hardware

The Game Boy Color contains a number of enhancements over the basic Game Boy, as described below. However, EJRTQ does not exploit the full feature set of the GBC, and descriptions below of features not available through modding are italicized.

The original GB could display 4 shades of “gray”. Each tile is a 2-bit bitmap with 4 logical “colors”, mapped to the shades of gray by one background palette and two sprite palettes. All background tiles use the background palette, while each sprite selects one of the two sprite palettes.

The GBC is capable of displaying a range of 32,768 colors (3 5-bit channels), of which 56 can be onscreen at any one time. These are arranged in 16 palettes: 8 background palettes that select 4 colors each and 8 sprite palettes that select 3 colors each (plus transparent). Each background tile and sprite has, again, 2-bit color depth, but uses one of these color palettes and obsoletes the original grayscale GB background and sprite palettes.

The GB contains enough tile memory for 384 8×8 tiles, of which 128 are unique to sprites, 128 are unique to backgrounds, and 128 are shared by both. The GBC doubles this, allowing a total of 768 tiles, allocated in the same proportions. Tile background memory is also doubled in size, though this doubles the amount of data for each tile in the background, rather than increasing the size of the background itself. This additional data contains the palette number to use as well as horizontal and vertical flip flags, removing the need for multiple tiles to be used for the same tile graphic that is simply mirrored one or both ways. It also contains a per-tile priority flag, as opposed to the global background priority flag found in the original GB.

The GBC draws sprites in a different order than the GB. In the GB, left-most sprites are drawn on top of more rightward sprites, with sprites with lower indices in the sprite table being drawn on top when sprites share an X coordinate. In GBC lower-ordered sprites are always drawn on top, allowing for explicit prioritization by the game.

Basic Method

EJRTQ assigns palettes to tiles at the tile level by means of a palette map table. For each tile graphic there is a corresponding entry in the palette map which supplies the palette number for that tile, regardless of where it appears on screen or whether it is in the background or a sprite (though it is possible the same palette number could result in different coloring for the tile in background vs. sprite, as background and sprite palettes are potentially different).

The palette index value for a given tile is located exactly $20 banks above the graphic data in the ROM. For example, take background tile $39 for tileset 7:6D30 (file offset $1ED30). The graphic data would located at 7:($6D30 + $39 * $10) = 7:70C0. The palette index byte would then be located at 27:70C0 ($9F0C0).

This palette map approach means that EJRTQ does not change the format of map data or metatile definitions, nor the ordering of tiles for the original tilesets. However it isn’t as powerful as other approaches.

Palettes

EJRTQ for the most part uses a single global set of palettes that is loaded at startup. The format of this data is:

+0: LSB of background palette 0 color 0
+1: MSB of background palette 0 color 0
+2: LSB of sprite palette 0 color 0
+3: MSB of sprite palette 0 color 0
+4: LSB of background palette 0 color 1
...

Each color entry (MSB:LSB) is structured -bbbbbgg gggrrrrr, with each channel ranging from 0 (none) to $1f (maximum).

Palette Alterations

While the palettes can be used freely, certain indices have special hard-coded uses. Namely, sprite palette 3 is used for frozen enemies and most flashing sprites, and sprite palette 1 is used as the alternate flashing palette for sprites whose normal palette is 3 (energy tanks, missile packs, and a handful of enemies).

Screen fading is done in a generic way, and does not require any particular concern for modders.

Periodic title screen flashing is performed by setting color 0 of all background palettes to $8FFF (white).

The Last Boss

License

Most art of EJRTQ is copyright Jeneric Stuff LLC per EJRT v1.2

Code and art not present in EJRT v1.2 is copyright Justin Olbrantz (Quantam)

Both are made available under Creative Commons Attribution-ShareAlike.

return_of_samus/technical_information/modding_ejrtq.txt · Last modified: 2019/02/27 03:47 by quantam