Checksum

The game has an internal checksum routine:

_LABEL_614F_Checksum:
  nop ; for patching?
  push af
  push bc
  push de
  push hl
    ld a, (_RAM_FFFF_)
    push af
      ld b, $1F           ; Start at page $1f
      xor a               ; zero
--:   ld d, a
      ld a, b
      ld (_RAM_FFFF_), a
      ld a, d
      ld hl, $8000        ; Read data from mapped page
      .repeat 16
-:    add a, (hl)         ; Sum 16 bytes
      inc hl
      .endr
      bit 6, h            ; Check for reaching $c000
      jr z, -             ; Loop over 16KB
      djnz --             ; Loop over all pages except the first one?
      ld hl, $000F        ; Checksum value is here
      cp (hl)
      jr nz, _RedScreen
    pop af
    ld (_RAM_FFFF_), a
  pop hl
  pop de
  pop bc
  pop af
  ret

It sums all the 8-bit bytes from offset $4000 to $7ffff - so the first 16KB is not checked. The expected sum is stored at offset $0000f. The first byte of the checksum routine is a "nop", seemingly for ease of patching to remove the check by writing a "ret" opcode.




Return to top
0.106s