data/claims/pokered-save.yamlPokémon Red and Blue's battery save (pret/pokered)
Game: Pokémon Red and Blue.
Pokémon Red and Blue keep one copy of the game in battery-backed cartridge RAM (the player's name, the main data, the map's sprites, the party, the current PC box, and one byte for tile animations), followed by a check byte that is the complement of the 8-bit sum of all those bytes. pokered-save/checksum
About: Pokémon Red and Blue Password and battery save
Value
{
"copies": 1,
"check": "NOT (sum of the bytes mod 256)"
}ram/sram.asm#L12-L24SECTION "Save Data", SRAM
…
sGameData::
sPlayerName:: ds NAME_LENGTH
sMainData:: ds wMainDataEnd - wMainDataStart
sSpriteData:: ds wSpriteDataEnd - wSpriteDataStart
sPartyData:: ds wPartyDataEnd - wPartyDataStart
sCurBoxData:: ds wBoxDataEnd - wBoxDataStart
sTileAnimations:: db
sGameDataEnd::
sMainDataCheckSum:: dbpokered: disassembly of Pokémon Red and Blue · engine/menus/save.asm#L290-L310SaveGameData::
…
CalcCheckSum:
;Check Sum (result[1 byte] is complemented)
ld d, 0
.loop
ld a, [hli]
add d
ld d, a
dec bc
ld a, b
or c
…pokered: disassembly of Pokémon Red and Blue · engine/menus/save.asm#L237-L240ld hl, sGameData
ld bc, sGameDataEnd - sGameData
call CalcCheckSum
ld [sMainDataCheckSum], aChecked by claude, 2026-10-22 — read the save data section, SaveMainData's end, and CalcCheckSum at the pinned commitEach of the three save routines (main data, current box, party and Pokédex) recomputes the same check byte after its copy. The other PC boxes, in two further RAM banks, get one check byte each from CalcIndividualBoxCheckSums, which this claim doesn't cover.
Cited by: Password and battery save
When Pokémon Red and Blue load, they recompute the check byte for each of the three parts they copy (the main data twice before giving up), and on a mismatch print "The file data is destroyed!", wait 100 frames, and set the save status to 1, which the main menu treats as no save file; the saved bytes are not erased. pokered-save/reject
About: Pokémon Red and Blue Password and battery save
Codepokered: disassembly of Pokémon Red and Blue ·engine/menus/save.asm#L1-L57TryLoadSaveFile:
…
call LoadMainData
jr c, .badsum
call LoadCurrentBoxData
jr c, .badsum
call LoadPartyAndDexData
jr c, .badsum
ld a, $2 ; good checksum
…
ld hl, FileDataDestroyedText
call PrintText
…pokered: disassembly of Pokémon Red and Blue · data/text/text_3.asm#L1-L3_FileDataDestroyedText::
text "The file data is"
line "destroyed!"pokered: disassembly of Pokémon Red and Blue · engine/menus/main_menu.asm#L32-L34ld a, [wSaveFileStatus]
cp 1
jr z, .noSaveFileChecked by claude, 2026-10-22 — read TryLoadSaveFile, LoadMainData, and the main menu's save check at the pinned commitThe main menu runs TryLoadSaveFile only if CheckForPlayerNameInSRAM finds a name. The second try at the main data's sum recomputes the same bytes, so it can only differ if the RAM reads differently the second time.
Cited by: Password and battery save