Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- hChecksumPrint EQU $ffe9
- IF 0
- ld a, [wJumptableIndex]
- push af
- callw _Bootstrap
- pop af
- ld [wJumptableIndex], a
- ret
- ENDC
- _Bootstrap:
- ld hl, wBoxNames
- ld a, [hli]
- ld b, a
- callw DecodeCharPairPointer
- ld h, d
- ld l, e ; hl = bootstrap dest or execute src
- ld a, b
- and "-"
- cp "-"
- jr nz, .notDirectExecute
- jp hl
- .notDirectExecute
- bit 2, b
- jr z, .bootstrap
- ld a, b
- and $3
- call OpenSRAM
- ld a, [hli]
- ld b, a
- ld a, [hli]
- ld c, a
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- push de ; execute dest
- call CopyBytes
- call jp_de + 1 ; skip push de as de is already pushed
- jr .closeSRAM
- .bootstrap
- push bc ; save flags for later
- push de ; save dest for later
- bit 3, b
- ld de, wOverworldMap + $55 ; mail buffer dest
- ld hl, wBoxNames + 9
- callw nz, DecodeCharPairPointer
- push de ; save mail buffer dest for later
- .getBootstrapCharsLoop
- push de
- callba $4, _ComposeMailMessage
- pop hl
- push de
- ld bc, 0
- .checksumMsgLoop
- callw CharPairDecode
- add c
- ld c, a
- jr nc, .noCarry
- inc b
- .noCarry
- ld a, [hl]
- cp "@"
- jr nz, .checksumMsgLoop
- ld hl, hChecksumPrint + 1 ; 34
- ld a, c
- ld [hld], a
- ld [hl], b
- ld d, h
- ld e, l
- coord hl, 2, 0
- lb bc, 2, 5
- call PrintNum
- call ButtonSound
- pop de
- dec de
- ld a, [de]
- inc de
- cp "!"
- jr nz, .getBootstrapCharsLoop
- .bootstrapFinished
- pop hl ; mail buffer
- pop de ; dest
- pop af ; save a byte here as b goes into a
- and $3 ; bank
- call OpenSRAM
- callw CharPairDecode
- ld [de], a
- inc de
- callw CharPairDecode
- ld [de], a
- inc de
- push de ; save count dest for later
- inc de
- inc de
- ld bc, 0 ; 3
- .bootstrapCopyLoop
- callw CharPairDecode ; 6
- ld [de], a ; 7
- inc de ; 8
- inc bc
- ld a, [hli] ; 14
- cp $4e
- jr nz, .notNewline
- ld a, [hli]
- .notNewline
- cp "!" ; 16
- jr nz, .bootstrapCopyLoop ; 18
- pop hl ; 19
- ld a, b
- ld [hli], a
- ld [hl], c
- .closeSRAM
- jp CloseSRAM
- DecodeCharPairPointer:
- callw CharPairDecode
- ld d, a
- callw CharPairDecode
- ld e, a
- ret
- CharPairDecode:
- push bc
- callw ReadAndFilterChar
- add a
- add a
- add a
- add a
- ld b, a
- callw ReadAndFilterChar
- and $f
- or b
- pop bc
- ret
- ReadAndFilterChar:
- ld a, [hl]
- cp $4e
- jr nz, .notNewline
- inc hl
- .notNewline
- ld a, [wBoxNames]
- bit 4, a
- ld a, [hli]
- ret z
- add a, 10
- ret
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement