Old Game tech

Old Game tech

Golden Sun (2001)

Golden Sun Cover
Golden Sun Cover
Golden Sun Battle
Golden Sun Battle
Golden sun save screen
Golden sun save screen
Golden Sun save screen
Golden Sun save screen

How much to transfer

You could copy over your characters and items from Golden Sun to The Lost Age with a password. There are 3 tiers:

Tier Length What moves
Bronze 16 chars Levels, Djinn, event flags, utility Psynergy items
Silver 61 chars Bronze data + character stats
Gold 260 chars Silver data + inventories and coins

How to:

  1. Encode bytes as 6-bit values, most-significant bit first, using ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyz!?#&$%+=.
  2. After each 9 values, add a check value: the sum of those nine % 64. This catches off by one errors.
  3. Offset each value by its position modulo 64, then map the result through the alphabet. The final byte is an XOR key applied to all earlier bytes before conversion; decoding reverses both.
  4. Verify the crc16 stored before the XOR step.

The per group checks locate typos, and the CRC validates the payload.

Codec details: Sol Cipher Make your own password

Byte codec

ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789abcdefghijkmnpqrstuvwxyz!?#&$%+="
SIZES = {16: 11, 61: 41, 260: 175}  # password chars -> bytes including CRC

def crc16(data):
    crc = 0xFFFF
    for byte in data:
        crc ^= byte << 8
        for _ in range(8):
            crc = (((crc << 1) - 0x1021) if crc & 0x8000 else (crc << 1)) & 0xFFFF
    return (~crc) & 0xFFFF

def encode(payload):
    crc = crc16(payload)
    raw = bytearray(payload + crc.to_bytes(2, "big"))
    key = raw[-1]
    raw[:-1] = bytes(b ^ key for b in raw[:-1])

    bits = "".join(f"{b:08b}" for b in raw)
    values = [int(bits[i:i + 6].ljust(6, "0"), 2) for i in range(0, len(bits), 6)]
    checked = []
    for i in range(0, len(values), 9):
        group = values[i:i + 9]
        checked.extend(group)
        if len(group) == 9:
            checked.append(sum(group) & 63)
    return "".join(ALPHABET[(v + i) & 63] for i, v in enumerate(checked))

def decode(password):
    chars = [ALPHABET.index(c) for c in password if not c.isspace()]
    byte_count = SIZES[len(chars)]
    values = [(v - i) & 63 for i, v in enumerate(chars)]
    data6 = []
    for i in range(0, len(values), 10):
        group = values[i:i + 10]
        body = group[:9]
        if len(group) == 10 and group[9] != (sum(body) & 63):
            raise ValueError(f"bad group {i // 10 + 1}")
        data6.extend(body)

    bits = "".join(f"{v:06b}" for v in data6)[:byte_count * 8]
    raw = bytearray(int(bits[i:i + 8], 2) for i in range(0, len(bits), 8))
    key = raw[-1]
    raw[:-1] = bytes(b ^ key for b in raw[:-1])
    payload, stored_crc = raw[:-2], int.from_bytes(raw[-2:], "big")
    if crc16(payload) != stored_crc:
        raise ValueError("bad CRC")
    return bytes(payload)

Pokemon Gold/Silver (2000)

Pokemon gold
Pokemon gold
English Pokémon Gold clock setup screen: “What time is it?”
English Pokémon Gold clock setup screen: “What time is it?”

(Setting the time at the start of the game)

Pokémon Gold and Silver clock prompts with the same scene at night and in daylight
Pokémon Gold and Silver clock prompts with the same scene at night and in daylight

The clock in the cartridge

The Game Boy itself had no clock, so Pokémon Gold and Silver came with a clock. It kept running while the handheld was off even. Also it skewed quite a lot time wise since it wasn’t synced with NTP.

Some Pokémon appeared at particular times, events depended on the day, and friendship evolutions could differ between day and night. Also your mom annoyed you at certain times and wasted your money.

Inside a Pokémon Silver cartridge, showing the MBC3 chip and CR2025 battery
Inside a Pokémon Silver cartridge, showing the MBC3 chip and CR2025 battery

The MBC3 controller provides the clock with a coin cell to keep the cartridge’s clock and battery-backed save memory alive. However these only lasted about 5-10 years or so, after which the game would lose its disk storage, and the time would stock working until the battery was replaced.

Pokemon stadium (1999)

Drowzee kick
Drowzee kick
Back of the Nintendo 64 Transfer Pak, showing the Game Boy cartridge slot
Back of the Nintendo 64 Transfer Pak, showing the Game Boy cartridge slot

The Transfer Pak plugged into the N64 controller and held a Game Boy cartridge.

Pick a mode

Pokemon stadium
Pokemon stadium

Pokemon Stadium

Emulation

Pokémon Stadium 2 Game Boy Tower screen
Pokémon Stadium 2 Game Boy Tower screen

The Game Boy Tower was an emulator inside Pokémon Stadium, so the mips n64 could emulate 8080 sharp gbc games.

Bringing the GBC to Rust

There are three levels of writing your own GBC games:

The author of rust-gb has a fork of cranelift, where they wanted to use cranelift:

cranelift-z80

Why not make my own? (really difficult)

Building my own

Project: sangoku

Audio

The Game boy has 4 channels, so you can roughly play 4 notes at a time

All the rest: TBD