Skip to content

x.1sav.rtc.tc8521

Owner: these specifications, under a reserved name · Applies to: the header of a save or state, or one of its parts · Status: normative schema, optional to carry

The TAMA5 cartridge, Game de Hakken!! Tamagotchi: Osutchi to Mesutchi, keeps its clock in a Toshiba TC8521. The chip has the registers of the Ricoh RP5C01. This key carries what the chip holds and the moment a producer took it. x.1sav.rtc carries the reading.

The representation belongs to no one emulator, so the name sits in the x tree, under x.1sav.rtc.

; ============================================================================
; x.1sav.rtc.tc8521 - the Toshiba TC8521 in a TAMA5 Game Boy cartridge
;
; An extension key for the Universal Saves Format, defined by these
; specifications under a name reserved in the Vendor Names registry because
; the chip's registers belong to no one emulator.
;
; The root here is the value carried under the key, not a bundle. A bundle
; validates against the format's own schema whatever this holds, since an
; extension value is `any` there; this file is what makes the shape checkable.
; ============================================================================
rtc-tc8521 = {
0 => [4*4 block], ; blocks - 0 time, 1 alarm, 2 and 3 RAM
1 => nybble / null, ; mode - register D: block select, alarm and timer enable
? 2 => #6.1(int), ; taken_at - the producer's clock when it took them
}
; Registers 0 to C of one block. A register here or in key 1 is null where
; the producer's source does not keep it, since emulators keep anything from
; the time alone to every block.
block = [13*13 (nybble / null)]
nybble = 0..15

Key 0 is the chip’s four blocks, each 13 registers of four bits, in index order:

  • Block 0 is the time, in BCD. Registers 0 to 5 are the seconds, minutes and hours, each ones then tens. In 12-hour mode, bit 1 of register 5 is PM and bit 0 alone holds the tens of hours. Register 6 is the weekday. Registers 7 to C are the day, month and year, each ones then tens.
  • Block 1 is the alarm and the settings. Registers 2 to 8 are the alarm, laid out as block 0’s minutes to day. Register A is 1 in 24-hour mode and 0 in 12-hour mode. Register B counts years since a leap year, 0 to 3. Registers 0, 1, 9 and C read zero.
  • Blocks 2 and 3 are RAM.

Key 1 is the mode register, D. Bits 0 and 1 select the block a game sees, bit 2 enables the alarm, and bit 3 is set while the clock runs. The test and reset registers, E and F, are write-only, and the key does not carry them.

Emulators keep different amounts of this chip. A register, in a block or in key 1, is null where the producer’s source does not keep it. mGBA keeps every block, while ares keeps block 0 without the weekday, the two settings, and nothing else.

Key 2 is the anchor: the producer’s clock at the moment it took the registers. It is the moment the producer advances the clock from when the save is next loaded. A producer that keeps one SHOULD carry it.

A consumer rebuilding the chip needs a value for each null register. It SHOULD use these:

  • Key 1, the mode: 8. The clock runs, block 0 is selected, and the alarm is off.
  • Block 1, register A: 1, for 24-hour mode, as MAME starts the chip.
  • Block 1, register B: block 0’s year modulo 4, as MAME sets it, or 0 when the year is null too.
  • Any other register: 0, where MAME starts the alarm and the RAM. That includes the weekday. The chip counts it from whatever the game set, so the date does not give it.

The TC8521 is a dating clock. x.1sav.rtc reads block 0 as though it were UTC, as it does for every dating clock.

  • The year is two digits with no century, so a producer supplies one.
  • With block 1’s register A at 0 the clock runs in 12-hour mode. Bit 1 of block 0’s register 5 then says the hour is after noon, and a producer resolves the hour from it.
  • A producer MUST omit x.1sav.rtc when a register the date or time needs is null, as that key requires of any reading a producer cannot compute. Those are block 0’s registers and block 1’s register A.

Wherever x.1sav.rtc goes, and nowhere else: the header of a save or a state, or one of its parts. A producer carrying this key SHOULD carry x.1sav.rtc on the same map. The two describe one clock, and a consumer that wants only the time then reads it without knowing the chip. They may disagree without either being wrong.

Only for the TAMA5 cartridge, the one game on that board. Other Game Boy clocks take the other keys x.1sav.rtc lists.