ref: 0d6efda9bb3aa99cc9d28b9b9e7edaae121b7d75
parent: 6d7043c0c65161ad8ee97fa66b94beba86761d25
parent: 84a9b3907b9db08ee38e873554d8a6b4ac1b72b4
author: Bryan Bishop <[email protected]>
date: Mon Sep 9 15:51:29 EDT 2013
Merge pull request #198 from yenatch/split-predefs-specials-stds decouple home/ from engine/
--- a/battle/effect_commands.asm
+++ b/battle/effect_commands.asm
@@ -9542,212 +9542,13 @@
; 37588
-BattleCommand54: ; 37588
-; curse
+INCLUDE "battle/effects/curse.asm"
- ld de, BattleMonType1
- ld bc, PlayerStatLevels
- ld a, [hBattleTurn]
- and a
- jr z, .go
- ld de, EnemyMonType1
- ld bc, EnemyStatLevels
+INCLUDE "battle/effects/protect.asm"
-.go
+INCLUDE "battle/effects/endure.asm"
-; Curse is different for Ghost-types.
-
- ld a, [de]
- cp GHOST
- jr z, .ghost
- inc de
- ld a, [de]
- cp GHOST
- jr z, .ghost
-
-
-; If no stats can be increased, don't.
-
-; Attack
- ld a, [bc]
- cp 13 ; max
- jr c, .raise
-
-; Defense
- inc bc
- ld a, [bc]
- cp 13 ; max
- jr nc, .cantraise
-
-.raise
-
-; Raise Attack and Defense, and lower Speed.
-
- ld a, $1
- ld [$c689], a
- call Function0x37e01
- ld a, $2
- call Function0x36532
- call SwitchTurn
- call BattleCommand8d
- call ResetMiss
- call SwitchTurn
- call BattleCommand70
- call BattleCommand8c
- call ResetMiss
- call BattleCommand71
- jp BattleCommand8c
-
-
-.ghost
-
-; Cut HP in half and put a curse on the opponent.
-
- call CheckHiddenOpponent
- jr nz, .failed
-
- call CheckSubstituteOpp
- jr nz, .failed
-
- ld a, BATTLE_VARS_SUBSTATUS1_OPP
- call GetBattleVarPair
- bit 1, [hl]
- jr nz, .failed
-
- set 1, [hl]
- call Function0x37e01
- ld hl, GetHalfMaxHP
- call CallBankF
- ld hl, Function3cc3f
- call CallBankF
- call UpdateUserInParty
- ld hl, PutACurseText
- jp StdBattleTextBox
-
-.failed
- call Function0x37e77
- jp PrintButItFailed
-
-
-.cantraise
-
-; Can't raise either stat.
-
- ld b, $8 ; ABILITY
- call GetStatName
- call Function0x37e77
- ld hl, WontRiseAnymoreText
- jp StdBattleTextBox
-; 37618
-
-
-BattleCommand55: ; 37618
-; protect
-
- call Function0x3762c
- ret c
- ld a, BATTLE_VARS_SUBSTATUS1
- call GetBattleVarPair
- set 2, [hl]
- call Function0x37e01
- ld hl, ProtectedItselfText
- jp StdBattleTextBox
-; 3762c
-
-
-Function0x3762c: ; 3762c
- ld de, $c679
- ld a, [hBattleTurn]
- and a
- jr z, .asm_37637
- ld de, $c681
-
-.asm_37637
- call Function0x36abf
- jr nz, .asm_37665
-
- ld a, $3
- call CleanGetBattleVarPair
- bit 4, a
- jr nz, .asm_37665
-
- ld b, $ff
- ld a, [de]
- ld c, a
-.asm_37649
- ld a, c
- and a
- jr z, .asm_37656
-
- dec c
- srl b
- ld a, b
- and a
- jr nz, .asm_37649
-
- jr .asm_37665
-
-.asm_37656
- call BattleRandom
- and a
- jr z, .asm_37656
-
- dec a
- cp b
- jr nc, .asm_37665
-
- ld a, [de]
- inc a
- ld [de], a
- and a
- ret
-
-.asm_37665
- xor a
- ld [de], a
- call Function0x37e77
- call PrintButItFailed
- scf
- ret
-; 3766f
-
-
-BattleCommand5a: ; 3766f
-; endure
-
- call Function0x3762c
- ret c
-
- ld a, BATTLE_VARS_SUBSTATUS1
- call GetBattleVarPair
- set SUBSTATUS_ENDURE, [hl]
- call Function0x37e01
- ld hl, BracedItselfText
- jp StdBattleTextBox
-; 37683
-
-
-BattleCommand56: ; 37683
-; spikes
-
- ld hl, EnemyScreens
- ld a, [hBattleTurn]
- and a
- jr z, .asm_3768e
- ld hl, PlayerScreens
-
-.asm_3768e
- bit 0, [hl]
- jr nz, .failed
-
- set 0, [hl]
- call Function0x37e01
- ld hl, SpikesText
- jp StdBattleTextBox
-
-.failed
- jp Function0x37354
-; 376a0
+INCLUDE "battle/effects/spikes.asm"
BattleCommand57: ; 376a0
--- /dev/null
+++ b/battle/effects/curse.asm
@@ -1,0 +1,98 @@
+BattleCommand54: ; 37588
+; curse
+
+ ld de, BattleMonType1
+ ld bc, PlayerStatLevels
+ ld a, [hBattleTurn]
+ and a
+ jr z, .go
+ ld de, EnemyMonType1
+ ld bc, EnemyStatLevels
+
+.go
+
+; Curse is different for Ghost-types.
+
+ ld a, [de]
+ cp GHOST
+ jr z, .ghost
+ inc de
+ ld a, [de]
+ cp GHOST
+ jr z, .ghost
+
+
+; If no stats can be increased, don't.
+
+; Attack
+ ld a, [bc]
+ cp 13 ; max
+ jr c, .raise
+
+; Defense
+ inc bc
+ ld a, [bc]
+ cp 13 ; max
+ jr nc, .cantraise
+
+.raise
+
+; Raise Attack and Defense, and lower Speed.
+
+ ld a, $1
+ ld [$c689], a
+ call Function0x37e01
+ ld a, $2
+ call Function0x36532
+ call SwitchTurn
+ call BattleCommand8d
+ call ResetMiss
+ call SwitchTurn
+ call BattleCommand70
+ call BattleCommand8c
+ call ResetMiss
+ call BattleCommand71
+ jp BattleCommand8c
+
+
+.ghost
+
+; Cut HP in half and put a curse on the opponent.
+
+ call CheckHiddenOpponent
+ jr nz, .failed
+
+ call CheckSubstituteOpp
+ jr nz, .failed
+
+ ld a, BATTLE_VARS_SUBSTATUS1_OPP
+ call GetBattleVarPair
+ bit 1, [hl]
+ jr nz, .failed
+
+ set 1, [hl]
+ call Function0x37e01
+ ld hl, GetHalfMaxHP
+ call CallBankF
+ ld hl, Function3cc3f
+ call CallBankF
+ call UpdateUserInParty
+ ld hl, PutACurseText
+ jp StdBattleTextBox
+
+.failed
+ call Function0x37e77
+ jp PrintButItFailed
+
+
+.cantraise
+
+; Can't raise either stat.
+
+ ld b, $8 ; ABILITY
+ call GetStatName
+ call Function0x37e77
+ ld hl, WontRiseAnymoreText
+ jp StdBattleTextBox
+; 37618
+
--- /dev/null
+++ b/battle/effects/endure.asm
@@ -1,0 +1,18 @@
+BattleCommand5a: ; 3766f
+; endure
+
+; Endure shares code with Protect. See protect.asm.
+
+ call ProtectChance
+ ret c
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarPair
+ set SUBSTATUS_ENDURE, [hl]
+
+ call Function0x37e01
+
+ ld hl, BracedItselfText
+ jp StdBattleTextBox
+; 37683
+
--- /dev/null
+++ b/battle/effects/protect.asm
@@ -1,0 +1,81 @@
+BattleCommand55: ; 37618
+; protect
+ call ProtectChance
+ ret c
+
+ ld a, BATTLE_VARS_SUBSTATUS1
+ call GetBattleVarPair
+ set SUBSTATUS_PROTECT, [hl]
+
+ call Function0x37e01
+
+ ld hl, ProtectedItselfText
+ jp StdBattleTextBox
+; 3762c
+
+
+ProtectChance: ; 3762c
+
+ ld de, PlayerProtectCount
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_37637
+ ld de, EnemyProtectCount
+.asm_37637
+
+ call Function0x36abf
+ jr nz, .failed
+
+; Can't have a substitute.
+
+ ld a, BATTLE_VARS_SUBSTATUS4
+ call CleanGetBattleVarPair
+ bit SUBSTATUS_SUBSTITUTE, a
+ jr nz, .failed
+
+; Halve the chance of a successful Protect for each consecutive use.
+
+ ld b, $ff
+ ld a, [de]
+ ld c, a
+.loop
+ ld a, c
+ and a
+ jr z, .done
+ dec c
+
+ srl b
+ ld a, b
+ and a
+ jr nz, .loop
+ jr .failed
+.done
+
+.rand
+ call BattleRandom
+ and a
+ jr z, .rand
+
+ dec a
+ cp b
+ jr nc, .failed
+
+; Another consecutive Protect use.
+
+ ld a, [de]
+ inc a
+ ld [de], a
+
+ and a
+ ret
+
+
+.failed
+ xor a
+ ld [de], a
+ call Function0x37e77
+ call PrintButItFailed
+ scf
+ ret
+; 3766f
+
--- /dev/null
+++ b/battle/effects/spikes.asm
@@ -1,0 +1,28 @@
+BattleCommand56: ; 37683
+; spikes
+
+ ld hl, EnemyScreens
+ ld a, [hBattleTurn]
+ and a
+ jr z, .asm_3768e
+ ld hl, PlayerScreens
+.asm_3768e
+
+; Fails if spikes are already down!
+
+ bit SCREENS_SPIKES, [hl]
+ jr nz, .failed
+
+; Nothing else stops it from working.
+
+ set SCREENS_SPIKES, [hl]
+
+ call Function0x37e01
+
+ ld hl, SpikesText
+ jp StdBattleTextBox
+
+.failed
+ jp Function0x37354
+; 376a0
+
--- a/constants.asm
+++ b/constants.asm
@@ -170,8 +170,8 @@
D_PAD EQU %00100000
NO_INPUT EQU %00000000
-BUTTON_A EQU %00000001
-BUTTON_B EQU %00000010
+A_BUTTON EQU %00000001
+B_BUTTON EQU %00000010
SELECT EQU %00000100
START EQU %00001000
D_RIGHT EQU %00010000
--- a/engine/copy.asm
+++ /dev/null
@@ -1,431 +1,0 @@
-; Functions to copy data from ROM.
-
-
-Functiondc9: ; dc9
- ld a, [rLCDC]
- bit 7, a
- jp z, Copy2bpp
-
- ld a, [hROMBank]
- push af
- ld a, BANK(Function104284)
- rst Bankswitch
- call Function104284
- pop af
- rst Bankswitch
-
- ret
-; ddc
-
-Functionddc: ; ddc
- ld a, [rLCDC]
- bit 7, a
- jp z, Copy1bpp
-
- ld a, [hROMBank]
- push af
- ld a, BANK(Function1042b2)
- rst Bankswitch
- call Function1042b2
- pop af
- rst Bankswitch
-
- ret
-; def
-
-Functiondef: ; def
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
- call FarCopyBytesDouble
- pop af
- rst Bankswitch
- ret
-; dfd
-
-Functiondfd: ; dfd
- dec c
- ld a, [hBGMapMode]
- push af
- xor a
- ld [hBGMapMode], a
- ld a, [hROMBank]
- push af
- ld a, b
- rst Bankswitch
-
-.asm_e09
- ld a, d
- ld [rHDMA1], a
- ld a, e
- and $f0
- ld [rHDMA2], a
- ld a, h
- and $1f
- ld [rHDMA3], a
- ld a, l
- and $f0
- ld [rHDMA4], a
- ld a, c
- cp $8
- jr c, .asm_e3c
- sub $8
- ld c, a
- ld a, $f
- ld [hDMATransfer], a
- call DelayFrame
- ld a, l
- add $0
- ld l, a
- ld a, h
- adc $1
- ld h, a
- ld a, e
- add $0
- ld e, a
- ld a, d
- adc $1
- ld d, a
- jr .asm_e09
-
-.asm_e3c
- ld a, c
- and $7f
- ld [hDMATransfer], a
- call DelayFrame
- pop af
- rst Bankswitch
-
- pop af
- ld [hBGMapMode], a
- ret
-; e4a
-
-
-
-Functione4a: ; e4a
- ld a, $5
- ld hl, $4135
- rst FarCall
- ret
-; e51
-
-
-
-Functione51: ; e51
- ld a, $3e
- ld hl, $7449
- rst FarCall
- ret
-; e58
-
-Functione58: ; e58
- ld a, $3e
- ld hl, $74be
- rst FarCall
- ret
-; e5f
-
-
-
-Functione5f: ; e5f
- ld a, $3e
- ld hl, $748a
- rst FarCall
- ld a, $3e
- ld hl, $74b0
- rst FarCall
- ret
-; e6c
-
-Functione6c: ; e6c
- ld a, $3e
- ld hl, $74b0
- rst FarCall
- ret
-; e73
-
-Functione73: ; e73
- push de
- ld a, $0
- call GetSRAMBank
- push bc
- ld de, $a000
- ld a, b
- call FarDecompress
- pop bc
- pop hl
- ld de, $a000
- call Request2bpp
- call CloseSRAM
- ret
-; e8d
-
-
-
-FarCopyBytes: ; e8d
-; copy bc bytes from a:hl to de
-
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
- call CopyBytes
-
- pop af
- rst Bankswitch
- ret
-; 0xe9b
-
-
-FarCopyBytesDouble: ; e9b
-; Copy bc bytes from a:hl to bc*2 bytes at de,
-; doubling each byte in the process.
-
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
-; switcheroo, de <> hl
- ld a, h
- ld h, d
- ld d, a
- ld a, l
- ld l, e
- ld e, a
-
- inc b
- inc c
- jr .dec
-
-.loop
- ld a, [de]
- inc de
- ld [hli], a
- ld [hli], a
-.dec
- dec c
- jr nz, .loop
- dec b
- jr nz, .loop
-
- pop af
- rst Bankswitch
- ret
-; 0xeba
-
-
-Request2bpp: ; eba
- ld a, [hBGMapMode]
- push af
- xor a
- ld [hBGMapMode], a
-
- ld a, [hROMBank]
- push af
- ld a, b
- rst Bankswitch
-
- ld a, [$ffd3]
- push af
-
- ld a, $8
- ld [$ffd3], a
- ld a, [InLinkBattle]
- cp $4
- jr nz, .asm_edc
- ld a, [$ffe9]
- and a
- jr nz, .asm_edc
- ld a, $6
- ld [$ffd3], a
-
-.asm_edc
- ld a, e
- ld [Requested2bppSource], a
- ld a, d
- ld [Requested2bppSource + 1], a
- ld a, l
- ld [Requested2bppDest], a
- ld a, h
- ld [Requested2bppDest + 1], a
-
-.asm_eec
- ld a, c
- ld hl, $ffd3
- cp [hl]
- jr nc, .asm_f08
-
- ld [Requested2bpp], a
-.wait
- call DelayFrame
- ld a, [Requested2bpp]
- and a
- jr nz, .wait
-
- pop af
- ld [$ffd3], a
-
- pop af
- rst Bankswitch
-
- pop af
- ld [hBGMapMode], a
- ret
-
-.asm_f08
- ld a, [$ffd3]
- ld [Requested2bpp], a
-.asm_f0d
- call DelayFrame
- ld a, [Requested2bpp]
- and a
- jr nz, .asm_f0d
- ld a, c
- ld hl, $ffd3
- sub [hl]
- ld c, a
- jr .asm_eec
-; f1e
-
-
-Request1bpp: ; f1e
- ld a, [hBGMapMode]
- push af
- xor a
- ld [hBGMapMode], a
-
- ld a, [hROMBank]
- push af
- ld a, b
- rst Bankswitch
-
- ld a, [$ffd3]
- push af
-
- ld a, $8
- ld [$ffd3], a
- ld a, [InLinkBattle]
- cp $4
- jr nz, .asm_f40
- ld a, [$ffe9]
- and a
- jr nz, .asm_f40
- ld a, $6
- ld [$ffd3], a
-
-.asm_f40
- ld a, e
- ld [Requested1bppSource], a
- ld a, d
- ld [Requested1bppSource + 1], a
- ld a, l
- ld [Requested1bppDest], a
- ld a, h
- ld [Requested1bppDest + 1], a
-.asm_f50
- ld a, c
- ld hl, $ffd3
- cp [hl]
- jr nc, .asm_f6c
-
- ld [Requested1bpp], a
-.wait
- call DelayFrame
- ld a, [Requested1bpp]
- and a
- jr nz, .wait
-
- pop af
- ld [$ffd3], a
-
- pop af
- rst Bankswitch
-
- pop af
- ld [hBGMapMode], a
- ret
-
-.asm_f6c
- ld a, [$ffd3]
- ld [Requested1bpp], a
-.asm_f71
- call DelayFrame
- ld a, [Requested1bpp]
- and a
- jr nz, .asm_f71
- ld a, c
- ld hl, $ffd3
- sub [hl]
- ld c, a
- jr .asm_f50
-; f82
-
-
-Get2bpp: ; f82
- ld a, [rLCDC]
- bit 7, a
- jp nz, Request2bpp
-
-Copy2bpp: ; f89
-; copy c 2bpp tiles from b:de to hl
-
- push hl
- ld h, d
- ld l, e
- pop de
-
-; bank
- ld a, b
-
-; bc = c * $10
- push af
- swap c
- ld a, $f
- and c
- ld b, a
- ld a, $f0
- and c
- ld c, a
- pop af
-
- jp FarCopyBytes
-; f9d
-
-
-Get1bpp: ; f9d
- ld a, [rLCDC]
- bit 7, a
- jp nz, Request1bpp
-
-Copy1bpp: ; fa4
-; copy c 1bpp tiles from b:de to hl
-
- push de
- ld d, h
- ld e, l
-
-; bank
- ld a, b
-
-; bc = c * $10 / 2
- push af
- ld h, 0
- ld l, c
- add hl, hl
- add hl, hl
- add hl, hl
- ld b, h
- ld c, l
- pop af
-
- pop hl
- jp FarCopyBytesDouble
-; fb6
-
--- a/engine/decompress.asm
+++ /dev/null
@@ -1,367 +1,0 @@
-FarDecompress: ; b40
-; Decompress graphics data at a:hl to de
-
-; put a away for a sec
- ld [$c2c4], a
-; save bank
- ld a, [hROMBank]
- push af
-; bankswitch
- ld a, [$c2c4]
- rst Bankswitch
-
-; what we came here for
- call Decompress
-
-; restore bank
- pop af
- rst Bankswitch
- ret
-; b50
-
-
-Decompress: ; b50
-; Pokemon Crystal uses an lz variant for compression.
-
-; This is mainly used for graphics, but the intro's
-; tilemaps also use this compression.
-
-; This function decompresses lz-compressed data at hl to de.
-
-
-; Basic rundown:
-
-; A typical control command consists of:
-; -the command (bits 5-7)
-; -the count (bits 0-4)
-; -and any additional params
-
-; $ff is used as a terminator.
-
-
-; Commands:
-
-; 0: literal
-; literal data for some number of bytes
-; 1: iterate
-; one byte repeated for some number of bytes
-; 2: alternate
-; two bytes alternated for some number of bytes
-; 3: zero (whitespace)
-; 0x00 repeated for some number of bytes
-
-; Repeater control commands have a signed parameter used to determine the start point.
-; Wraparound is simulated:
-; Positive values are added to the start address of the decompressed data
-; and negative values are subtracted from the current position.
-
-; 4: repeat
-; repeat some number of bytes from decompressed data
-; 5: flipped
-; repeat some number of flipped bytes from decompressed data
-; ex: $ad = %10101101 -> %10110101 = $b5
-; 6: reverse
-; repeat some number of bytes in reverse from decompressed data
-
-; If the value in the count needs to be larger than 5 bits,
-; control code 7 can be used to expand the count to 10 bits.
-
-; A new control command is read in bits 2-4.
-; The new 10-bit count is split:
-; bits 0-1 contain the top 2 bits
-; another byte is added containing the latter 8
-
-; So, the structure of the control command becomes:
-; 111xxxyy yyyyyyyy
-; | | | |
-; | | our new count
-; | the control command for this count
-; 7 (this command)
-
-; For more information, refer to the code below and in extras/gfx.py .
-
-; save starting output address
- ld a, e
- ld [$c2c2], a
- ld a, d
- ld [$c2c3], a
-
-.loop
-; get next byte
- ld a, [hl]
-; done?
- cp $ff ; end
- ret z
-
-; get control code
- and %11100000
-
-; 10-bit param?
- cp $e0 ; LZ_HI
- jr nz, .normal
-
-
-; 10-bit param:
-
-; get next 3 bits (%00011100)
- ld a, [hl]
- add a
- add a ; << 3
- add a
-
-; this is our new control code
- and %11100000
- push af
-
-; get param hi
- ld a, [hli]
- and %00000011
- ld b, a
-
-; get param lo
- ld a, [hli]
- ld c, a
-
-; read at least 1 byte
- inc bc
- jr .readers
-
-
-.normal
-; push control code
- push af
-; get param
- ld a, [hli]
- and %00011111
- ld c, a
- ld b, $0
-; read at least 1 byte
- inc c
-
-.readers
-; let's get started
-
-; inc loop counts since we bail as soon as they hit 0
- inc b
- inc c
-
-; get control code
- pop af
-; command type
- bit 7, a ; 80, a0, c0
- jr nz, .repeatertype
-
-; literals
- cp $20 ; LZ_ITER
- jr z, .iter
- cp $40 ; LZ_ALT
- jr z, .alt
- cp $60 ; LZ_ZERO
- jr z, .zero
- ; else $00
-
-; 00 ; LZ_LIT
-; literal data for bc bytes
-.loop1
-; done?
- dec c
- jr nz, .next1
- dec b
- jp z, .loop
-
-.next1
- ld a, [hli]
- ld [de], a
- inc de
- jr .loop1
-
-
-; 20 ; LZ_ITER
-; write byte for bc bytes
-.iter
- ld a, [hli]
-
-.iterloop
- dec c
- jr nz, .iternext
- dec b
- jp z, .loop
-
-.iternext
- ld [de], a
- inc de
- jr .iterloop
-
-
-; 40 ; LZ_ALT
-; alternate two bytes for bc bytes
-
-; next pair
-.alt
-; done?
- dec c
- jr nz, .alt0
- dec b
- jp z, .altclose0
-
-; alternate for bc
-.alt0
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .alt1
-; done?
- dec b
- jp z, .altclose1
-.alt1
- ld a, [hld]
- ld [de], a
- inc de
- jr .alt
-
-; skip past the bytes we were alternating
-.altclose0
- inc hl
-.altclose1
- inc hl
- jr .loop
-
-
-; 60 ; LZ_ZERO
-; write 00 for bc bytes
-.zero
- xor a
-
-.zeroloop
- dec c
- jr nz, .zeronext
- dec b
- jp z, .loop
-
-.zeronext
- ld [de], a
- inc de
- jr .zeroloop
-
-
-; repeats
-; 80, a0, c0
-; repeat decompressed data from output
-.repeatertype
- push hl
- push af
-; get next byte
- ld a, [hli]
-; absolute?
- bit 7, a
- jr z, .absolute
-
-; relative
-; a = -a
- and %01111111 ; forget the bit we just looked at
- cpl
-; add de (current output address)
- add e
- ld l, a
- ld a, $ff ; -1
- adc d
- ld h, a
- jr .repeaters
-
-.absolute
-; get next byte (lo)
- ld l, [hl]
-; last byte (hi)
- ld h, a
-; add starting output address
- ld a, [$c2c2]
- add l
- ld l, a
- ld a, [$c2c3]
- adc h
- ld h, a
-
-.repeaters
- pop af
- cp $80 ; LZ_REPEAT
- jr z, .repeat
- cp $a0 ; LZ_FLIP
- jr z, .flip
- cp $c0 ; LZ_REVERSE
- jr z, .reverse
-
-; e0 -> 80
-
-; 80 ; LZ_REPEAT
-; repeat some decompressed data
-.repeat
-; done?
- dec c
- jr nz, .repeatnext
- dec b
- jr z, .cleanup
-
-.repeatnext
- ld a, [hli]
- ld [de], a
- inc de
- jr .repeat
-
-
-; a0 ; LZ_FLIP
-; repeat some decompressed data w/ flipped bit order
-.flip
- dec c
- jr nz, .flipnext
- dec b
- jp z, .cleanup
-
-.flipnext
- ld a, [hli]
- push bc
- ld bc, $0008
-
-.fliploop
- rra
- rl b
- dec c
- jr nz, .fliploop
- ld a, b
- pop bc
- ld [de], a
- inc de
- jr .flip
-
-
-; c0 ; LZ_REVERSE
-; repeat some decompressed data in reverse
-.reverse
- dec c
- jr nz, .reversenext
-
- dec b
- jp z, .cleanup
-
-.reversenext
- ld a, [hld]
- ld [de], a
- inc de
- jr .reverse
-
-
-.cleanup
-; get type of repeat we just used
- pop hl
-; was it relative or absolute?
- bit 7, [hl]
- jr nz, .next
-
-; skip two bytes for absolute
- inc hl
-; skip one byte for relative
-.next
- inc hl
- jp .loop
-; c2f
-
--- a/engine/delay.asm
+++ /dev/null
@@ -1,23 +1,0 @@
-DelayFrame: ; 45a
-; Wait for one frame
- ld a, 1
- ld [VBlankOccurred], a
-
-; Wait for the next VBlank, halting to conserve battery
-.halt
- halt ; rgbasm adds a nop after this instruction by default
- ld a, [VBlankOccurred]
- and a
- jr nz, .halt
- ret
-; 468
-
-
-DelayFrames: ; 468
-; Wait c frames
- call DelayFrame
- dec c
- jr nz, DelayFrames
- ret
-; 46f
-
--- a/engine/fade.asm
+++ /dev/null
@@ -1,134 +1,0 @@
-; Functions to fade the screen in and out.
-
-
-Function48c: ; 48c
- ld a, [TimeOfDayPal]
- ld b, a
- ld hl, IncGradGBPalTable_11
- ld a, l
- sub b
- ld l, a
- jr nc, .asm_499
- dec h
-
-.asm_499
- ld a, [hli]
- ld [rBGP], a
- ld a, [hli]
- ld [rOBP0], a
- ld a, [hli]
- ld [rOBP1], a
- ret
-; 4a3
-
-
-Function4a3: ; 4a3
- ld a, [hCGB]
- and a
- jr z, .asm_4af
- ld hl, IncGradGBPalTable_00
- ld b, 4
- jr FadeOut
-
-.asm_4af
- ld hl, IncGradGBPalTable_08
- ld b, 4
- jr FadeOut
-; 4b6
-
-Function4b6: ; 4b6
- ld a, [hCGB]
- and a
- jr z, .asm_4c2
- ld hl, IncGradGBPalTable_05
- ld b, 3
- jr FadeOut
-
-.asm_4c2
- ld hl, IncGradGBPalTable_13
- ld b, 3
-; 4c7
-
-FadeOut: ; 4c7
- push de
- ld a, [hli]
- call DmgToCgbBGPals
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- call DmgToCgbObjPals
- ld c, 8
- call DelayFrames
- pop de
- dec b
- jr nz, FadeOut
- ret
-; 4dd
-
-Function4dd: ; 4dd
- ld a, [hCGB]
- and a
- jr z, .asm_4e9
- ld hl, IncGradGBPalTable_04 - 1
- ld b, 4
- jr FadeIn
-
-.asm_4e9
- ld hl, IncGradGBPalTable_12 - 1
- ld b, 4
- jr FadeIn
-; 4f0
-
-Function4f0: ; 4f0
- ld a, [hCGB]
- and a
- jr z, .asm_4fc
- ld hl, IncGradGBPalTable_07 - 1
- ld b, 3
- jr FadeIn
-
-.asm_4fc
- ld hl, IncGradGBPalTable_15 - 1
- ld b, 3
- ; fallthrough
-; 501
-
-FadeIn: ; 501
- push de
- ld a, [hld]
- ld d, a
- ld a, [hld]
- ld e, a
- call DmgToCgbObjPals
- ld a, [hld]
- call DmgToCgbBGPals
- ld c, 8
- call DelayFrames
- pop de
- dec b
- jr nz, FadeIn
- ret
-; 517
-
-
-; 517
-IncGradGBPalTable_00: db %11111111, %11111111, %11111111
-IncGradGBPalTable_01: db %11111110, %11111110, %11111110
-IncGradGBPalTable_02: db %11111001, %11111001, %11111001
-IncGradGBPalTable_03: db %11100100, %11100100, %11100100
-IncGradGBPalTable_04: db %11100100, %11100100, %11100100
-IncGradGBPalTable_05: db %10010000, %10010000, %10010000
-IncGradGBPalTable_06: db %01000000, %01000000, %01000000
-IncGradGBPalTable_07: db %00000000, %00000000, %00000000
-; bgp obp1 obp2
-IncGradGBPalTable_08: db %11111111, %11111111, %11111111
-IncGradGBPalTable_09: db %11111110, %11111110, %11111000
-IncGradGBPalTable_10: db %11111001, %11100100, %11100100
-IncGradGBPalTable_11: db %11100100, %11010000, %11100000
-IncGradGBPalTable_12: db %11100100, %11010000, %11100000
-IncGradGBPalTable_13: db %10010000, %10000000, %10010000
-IncGradGBPalTable_14: db %01000000, %01000000, %01000000
-IncGradGBPalTable_15: db %00000000, %00000000, %00000000
-; 547
-
--- a/engine/farcall.asm
+++ /dev/null
@@ -1,55 +1,0 @@
-FarCall_de: ; 2d54
-; Call a:de.
-; Preserves other registers.
-
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
- call .de
- jr ReturnFarCall
-
-.de
- push de
- ret
-; 2d63
-
-
-FarCall_hl: ; 2d63
-; Call a:hl.
-; Preserves other registers.
-
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
- call Function2d82
-; 2d6e
-
-ReturnFarCall: ; 2d6e
-; We want to retain the contents of f.
-; To do this, we can pop to bc instead of af.
-
- ld a, b
- ld [$cfb9], a
- ld a, c
- ld [$cfba], a
-
-; Restore the working bank.
- pop bc
- ld a, b
- rst Bankswitch
-
- ld a, [$cfb9]
- ld b, a
- ld a, [$cfba]
- ld c, a
- ret
-; 2d82
-
-Function2d82: ; 2d82
- jp [hl]
-; 2d83
-
--- /dev/null
+++ b/engine/fruit_trees.asm
@@ -1,0 +1,165 @@
+FruitTreeScript: ; 44000
+ 3callasm BANK(GetCurTreeFruit), GetCurTreeFruit
+ loadfont
+ copybytetovar CurFruit
+ itemtotext $0, $0
+ 2writetext FruitBearingTreeText
+ keeptextopen
+ 3callasm BANK(TryResetFruitTrees), TryResetFruitTrees
+ 3callasm BANK(CheckFruitTree), CheckFruitTree
+ iffalse .fruit
+ 2writetext NothingHereText
+ closetext
+ 2jump .end
+
+.fruit
+ 2writetext HeyItsFruitText
+ copybytetovar CurFruit
+ giveitem $ff, 1
+ iffalse .packisfull
+ keeptextopen
+ 2writetext ObtainedFruitText
+ 3callasm BANK(PickedFruitTree), PickedFruitTree
+ specialsound
+ itemnotify
+ 2jump .end
+
+.packisfull
+ keeptextopen
+ 2writetext FruitPackIsFullText
+ closetext
+
+.end
+ loadmovesprites
+ end
+; 44041
+
+GetCurTreeFruit: ; 44041
+ ld a, [CurFruitTree]
+ dec a
+ call GetFruitTreeItem
+ ld [CurFruit], a
+ ret
+; 4404c
+
+TryResetFruitTrees: ; 4404c
+ ld hl, $dc1e
+ bit 4, [hl]
+ ret nz
+ jp ResetFruitTrees
+; 44055
+
+CheckFruitTree: ; 44055
+ ld b, 2
+ call GetFruitTreeFlag
+ ld a, c
+ ld [ScriptVar], a
+ ret
+; 4405f
+
+PickedFruitTree: ; 4405f
+ ld a, $41
+ ld hl, $609b
+ rst FarCall ; empty function
+
+ ld b, 1
+ jp GetFruitTreeFlag
+; 4406a
+
+ResetFruitTrees: ; 4406a
+ xor a
+ ld hl, FruitTreeFlags
+ ld [hli], a
+ ld [hli], a
+ ld [hli], a
+ ld [hl], a
+ ld hl, $dc1e
+ set 4, [hl]
+ ret
+; 44078
+
+GetFruitTreeFlag: ; 44078
+ push hl
+ push de
+ ld a, [CurFruitTree]
+ dec a
+ ld e, a
+ ld d, 0
+ ld hl, FruitTreeFlags
+ call FlagAction
+ pop de
+ pop hl
+ ret
+; 4408a
+
+GetFruitTreeItem: ; 4408a
+ push hl
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, FruitTreeItems
+ add hl, de
+ ld a, [hl]
+ pop de
+ pop hl
+ ret
+; 44097
+
+FruitTreeItems: ; 44097
+ db BERRY
+ db BERRY
+ db BERRY
+ db BERRY
+ db PSNCUREBERRY
+ db PSNCUREBERRY
+ db BITTER_BERRY
+ db BITTER_BERRY
+ db PRZCUREBERRY
+ db PRZCUREBERRY
+ db MYSTERYBERRY
+ db MYSTERYBERRY
+ db ICE_BERRY
+ db ICE_BERRY
+ db MINT_BERRY
+ db BURNT_BERRY
+ db RED_APRICORN
+ db BLU_APRICORN
+ db BLK_APRICORN
+ db WHT_APRICORN
+ db PNK_APRICORN
+ db GRN_APRICORN
+ db YLW_APRICORN
+ db BERRY
+ db PSNCUREBERRY
+ db BITTER_BERRY
+ db PRZCUREBERRY
+ db ICE_BERRY
+ db MINT_BERRY
+ db BURNT_BERRY
+; 440b5
+
+FruitBearingTreeText: ; 440b5
+ text_jump _FruitBearingTreeText, BANK(_FruitBearingTreeText)
+ db "@"
+; 440ba
+
+HeyItsFruitText: ; 440ba
+ text_jump _HeyItsFruitText, BANK(_HeyItsFruitText)
+ db "@"
+; 440bf
+
+ObtainedFruitText: ; 440bf
+ text_jump _ObtainedFruitText, BANK(_ObtainedFruitText)
+ db "@"
+; 440c4
+
+FruitPackIsFullText: ; 440c4
+ text_jump _FruitPackIsFullText, BANK(_FruitPackIsFullText)
+ db "@"
+; 440c9
+
+NothingHereText: ; 440c9
+ text_jump _NothingHereText, BANK(_NothingHereText)
+ db "@"
+; 440ce
+
--- a/engine/game_time.asm
+++ /dev/null
@@ -1,132 +1,0 @@
-ResetGameTime: ; 208a
- xor a
- ld [GameTimeCap], a
- ld [GameTimeHours], a
- ld [GameTimeHours + 1], a
- ld [GameTimeMinutes], a
- ld [GameTimeSeconds], a
- ld [GameTimeFrames], a
- ret
-; 209e
-
-
-GameTimer: ; 209e
-
- nop
-
- ld a, [rSVBK]
- push af
- ld a, 1
- ld [rSVBK], a
-
- call UpdateGameTimer
-
- pop af
- ld [rSVBK], a
- ret
-; 20ad
-
-
-UpdateGameTimer: ; 20ad
-; Increment the game timer by one frame.
-; The game timer is capped at 999:59:59.00.
-
-
-; Don't update if game logic is paused.
- ld a, [$c2cd]
- and a
- ret nz
-
-; Is the timer paused?
- ld hl, GameTimerPause
- bit 0, [hl]
- ret z
-
-; Is the timer already capped?
- ld hl, GameTimeCap
- bit 0, [hl]
- ret nz
-
-
-; +1 frame
- ld hl, GameTimeFrames
- ld a, [hl]
- inc a
-
- cp 60 ; frames/second
- jr nc, .second
-
- ld [hl], a
- ret
-
-
-.second
- xor a
- ld [hl], a
-
-; +1 second
- ld hl, GameTimeSeconds
- ld a, [hl]
- inc a
-
- cp 60 ; seconds/minute
- jr nc, .minute
-
- ld [hl], a
- ret
-
-
-.minute
- xor a
- ld [hl], a
-
-; +1 minute
- ld hl, GameTimeMinutes
- ld a, [hl]
- inc a
-
- cp 60 ; minutes/hour
- jr nc, .hour
-
- ld [hl], a
- ret
-
-
-.hour
- xor a
- ld [hl], a
-
-; +1 hour
- ld a, [GameTimeHours]
- ld h, a
- ld a, [GameTimeHours + 1]
- ld l, a
- inc hl
-
-
-; Cap the timer after 1000 hours.
- ld a, h
- cp 1000 / $100
- jr c, .ok
-
- ld a, l
- cp 1000 % $100
- jr c, .ok
-
- ld hl, GameTimeCap
- set 0, [hl]
-
- ld a, 59 ; 999:59:59.00
- ld [GameTimeMinutes], a
- ld [GameTimeSeconds], a
- ret
-
-
-.ok
- ld a, h
- ld [GameTimeHours], a
- ld a, l
- ld [GameTimeHours + 1], a
- ret
-; 210f
-
--- a/engine/init.asm
+++ /dev/null
@@ -1,225 +1,0 @@
-Reset: ; 150
- di
- call CleanSoundRestart
- xor a
- ld [$ffde], a
- call ClearPalettes
- xor a
- ld [rIF], a
- ld a, 1 ; VBlank int
- ld [rIE], a
- ei
-
- ld hl, $cfbe
- set 7, [hl]
-
- ld c, 32
- call DelayFrames
-
- jr Init
-; 16e
-
-
-_Start: ; 16e
- cp $11
- jr z, .asm_175
- xor a
- jr .asm_177
-
-.asm_175
- ld a, $1
-
-.asm_177
- ld [hCGB], a
- ld a, $1
- ld [$ffea], a
-; 17d
-
-
-Init: ; 17d
-
- di
-
- xor a
- ld [rIF], a
- ld [rIE], a
- ld [rRP], a
- ld [rSCX], a
- ld [rSCY], a
- ld [rSB], a
- ld [rSC], a
- ld [rWX], a
- ld [rWY], a
- ld [rBGP], a
- ld [rOBP0], a
- ld [rOBP1], a
- ld [rTMA], a
- ld [rTAC], a
- ld [$d000], a
-
- ld a, %100 ; Start timer at 4096Hz
- ld [rTAC], a
-
-.wait
- ld a, [rLY]
- cp 145
- jr nz, .wait
-
- xor a
- ld [rLCDC], a
-
-; Clear WRAM bank 0
- ld hl, $c000
- ld bc, $d000 - $c000
-.asm_1b1
- ld [hl], 0
- inc hl
- dec bc
- ld a, b
- or c
- jr nz, .asm_1b1
-
- ld sp, Stack
-
-; Clear HRAM
- ld a, [hCGB]
- push af
- ld a, [$ffea]
- push af
- xor a
- ld hl, $ff80
- ld bc, $ffff - $ff80
- call ByteFill
- pop af
- ld [$ffea], a
- pop af
- ld [hCGB], a
-
- call ClearWRAM
- ld a, 1
- ld [rSVBK], a
- call ClearVRAM
- call ClearSprites
- call Function270
-
-
- ld a, BANK(LoadPushOAM)
- rst Bankswitch
-
- call LoadPushOAM
-
- xor a
- ld [$ffde], a
- ld [hSCX], a
- ld [hSCY], a
- ld [rJOYP], a
-
- ld a, $8 ; HBlank int enable
- ld [rSTAT], a
-
- ld a, $90
- ld [hWY], a
- ld [rWY], a
-
- ld a, 7
- ld [hWX], a
- ld [rWX], a
-
- ld a, %11100011
- ; LCD on
- ; Win tilemap 1
- ; Win on
- ; BG/Win tiledata 0
- ; BG Tilemap 0
- ; OBJ 8x8
- ; OBJ on
- ; BG on
- ld [rLCDC], a
-
- ld a, $ff
- ld [$ffcb], a
-
- callba Function9890
-
- ld a, $9c
- ld [$ffd7], a
-
- xor a
- ld [hBGMapAddress], a
-
- callba StartClock
-
- xor a
- ld [MBC3LatchClock], a
- ld [MBC3SRamEnable], a
-
- ld a, [hCGB]
- and a
- jr z, .asm_22b
- call Function2ff7
-.asm_22b
-
- xor a
- ld [rIF], a
- ld a, %1111 ; VBlank, LCDStat, Timer, Serial interrupts
- ld [rIE], a
- ei
-
- call DelayFrame
-
- ld a, $30
- call Predef
-
- call CleanSoundRestart
- xor a
- ld [CurMusic], a
- jp GameInit
-; 245
-
-
-ClearVRAM: ; 245
-; Wipe VRAM banks 0 and 1
-
- ld a, 1
- ld [rVBK], a
- call .clear
-
- xor a
- ld [rVBK], a
-.clear
- ld hl, VTiles0
- ld bc, $2000
- xor a
- call ByteFill
- ret
-; 25a
-
-ClearWRAM: ; 25a
-; Wipe swappable WRAM banks (1-7)
-
- ld a, 1
-.asm_25c
- push af
- ld [rSVBK], a
- xor a
- ld hl, $d000
- ld bc, $1000
- call ByteFill
- pop af
- inc a
- cp 8
- jr nc, .asm_25c
- ret
-; 270
-
-Function270: ; 270
- ld a, $0
- call GetSRAMBank
- ld hl, $a000
- ld bc, $0020
- xor a
- call ByteFill
- call CloseSRAM
- ret
-; 283
-
--- a/engine/joypad.asm
+++ /dev/null
@@ -1,491 +1,0 @@
-JoypadInt: ; 92e
-; Replaced by Joypad, called from VBlank instead of the useless
-; joypad interrupt.
-
-; This is a placeholder in case the interrupt is somehow enabled.
- reti
-; 92f
-
-ClearJoypadPublic: ; 92f
- xor a
-; Pressed this frame (delta)
- ld [hJoyPressed], a
-; Currently pressed
- ld [hJoyDown], a
- ret
-; 935
-
-Joypad: ; 935
-; Read the joypad register and translate it to something more
-; workable for use in-game. There are 8 buttons, so we can use
-; one byte to contain all player input.
-
-; Updates:
-
-; hJoypadReleased: released this frame (delta)
-; hJoypadPressed: pressed this frame (delta)
-; hJoypadDown: currently pressed
-; hJoypadSum: pressed so far
-
-; Any of these three bits can be used to disable input.
- ld a, [$cfbe]
- and %11010000
- ret nz
-
-; If we're saving, input is disabled.
- ld a, [$c2cd]
- and a
- ret nz
-
-; We can only get four inputs at a time.
-; We take d-pad first for no particular reason.
- ld a, D_PAD
- ld [rJOYP], a
-; Read twice to give the request time to take.
- ld a, [rJOYP]
- ld a, [rJOYP]
-
-; The Joypad register output is in the lo nybble (inversed).
-; We make the hi nybble of our new container d-pad input.
- cpl
- and $f
- swap a
-
-; We'll keep this in b for now.
- ld b, a
-
-; Buttons make 8 total inputs (A, B, Select, Start).
-; We can fit this into one byte.
- ld a, BUTTONS
- ld [rJOYP], a
-; Wait for input to stabilize.
- ld a, [rJOYP]
- ld a, [rJOYP]
- ld a, [rJOYP]
- ld a, [rJOYP]
- ld a, [rJOYP]
- ld a, [rJOYP]
-; Buttons take the lo nybble.
- cpl
- and $f
- or b
- ld b, a
-
-; Reset the joypad register since we're done with it.
- ld a, $30
- ld [rJOYP], a
-
-; To get the delta we xor the last frame's input with the new one.
- ld a, [hJoypadDown] ; last frame
- ld e, a
- xor b
- ld d, a
-; Released this frame:
- and e
- ld [hJoypadReleased], a
-; Pressed this frame:
- ld a, d
- and b
- ld [hJoypadPressed], a
-
-; Add any new presses to the list of collective presses:
- ld c, a
- ld a, [hJoypadSum]
- or c
- ld [hJoypadSum], a
-
-; Currently pressed:
- ld a, b
- ld [hJoypadDown], a
-
-; Now that we have the input, we can do stuff with it.
-
-; For example, soft reset:
- and BUTTON_A | BUTTON_B | SELECT | START
- cp BUTTON_A | BUTTON_B | SELECT | START
- jp z, Reset
-
- ret
-; 984
-
-
-GetJoypadPublic: ; 984
-; Update mirror joypad input from hJoypadDown (real input)
-
-; hJoyReleased: released this frame (delta)
-; hJoyPressed: pressed this frame (delta)
-; hJoyDown: currently pressed
-
-; bit 0 A
-; 1 B
-; 2 SELECT
-; 3 START
-; 4 RIGHT
-; 5 LEFT
-; 6 UP
-; 7 DOWN
-
- push af
- push hl
- push de
- push bc
-
-; The player input can be automated using an input stream.
-; See more below.
- ld a, [InputType]
- cp a, AUTO_INPUT
- jr z, .auto
-
-; To get deltas, take this and last frame's input.
- ld a, [hJoypadDown] ; real input
- ld b, a
- ld a, [hJoyDown] ; last frame mirror
- ld e, a
-
-; Released this frame:
- xor b
- ld d, a
- and e
- ld [hJoyReleased], a
-
-; Pressed this frame:
- ld a, d
- and b
- ld [hJoyPressed], a
-
-; It looks like the collective presses got commented out here.
- ld c, a
-
-; Currently pressed:
- ld a, b
- ld [hJoyDown], a ; frame input
-
-.quit
- pop bc
- pop de
- pop hl
- pop af
- ret
-
-.auto
-; Use a predetermined input stream (used in the catching tutorial).
-
-; Stream format: [input][duration]
-; A value of $ff will immediately end the stream.
-
-; Read from the input stream.
- ld a, [hROMBank]
- push af
- ld a, [AutoInputBank]
- rst Bankswitch
-
- ld hl, AutoInputAddress
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
-; We only update when the input duration has expired.
- ld a, [AutoInputLength]
- and a
- jr z, .updateauto
-
-; Until then, don't change anything.
- dec a
- ld [AutoInputLength], a
- pop af
- rst Bankswitch
- jr .quit
-
-
-.updateauto
-; An input of $ff will end the stream.
- ld a, [hli]
- cp a, $ff
- jr z, .stopauto
- ld b, a
-
-; A duration of $ff will end the stream indefinitely.
- ld a, [hli]
- ld [AutoInputLength], a
- cp a, $ff
- jr nz, .next
-
-; The current input is overwritten.
- dec hl
- dec hl
- ld b, NO_INPUT
- jr .finishauto
-
-.next
-; On to the next input...
- ld a, l
- ld [AutoInputAddress], a
- ld a, h
- ld [AutoInputAddress+1], a
- jr .finishauto
-
-.stopauto
- call StopAutoInput
- ld b, NO_INPUT
-
-.finishauto
- pop af
- rst Bankswitch
- ld a, b
- ld [hJoyPressed], a ; pressed
- ld [hJoyDown], a ; input
- jr .quit
-; 9ee
-
-
-StartAutoInput: ; 9ee
-; Start reading automated input stream at a:hl.
-
- ld [AutoInputBank], a
- ld a, l
- ld [AutoInputAddress], a
- ld a, h
- ld [AutoInputAddress+1], a
-; Start reading the stream immediately.
- xor a
- ld [AutoInputLength], a
-; Reset input mirrors.
- xor a
- ld [hJoyPressed], a ; pressed this frame
- ld [hJoyReleased], a ; released this frame
- ld [hJoyDown], a ; currently pressed
-
- ld a, AUTO_INPUT
- ld [InputType], a
- ret
-; a0a
-
-
-StopAutoInput: ; a0a
-; Clear variables related to automated input.
- xor a
- ld [AutoInputBank], a
- ld [AutoInputAddress], a
- ld [AutoInputAddress+1], a
- ld [AutoInputLength], a
-; Back to normal input.
- ld [InputType], a
- ret
-; a1b
-
-
-Functiona1b: ; a1b
-
- call DelayFrame
-
- push bc
- call Functiona57
- pop bc
-
- ld a, [hJoyDown]
- cp D_UP | SELECT | BUTTON_B
- jr z, .asm_a34
-
- ld a, [$ffa9]
- and START | BUTTON_A
- jr nz, .asm_a34
-
- dec c
- jr nz, Functiona1b
-
- and a
- ret
-
-.asm_a34
- scf
- ret
-; a36
-
-
-Functiona36: ; a36
- call DelayFrame
- call GetJoypadPublic
- ld a, [hJoyPressed]
- and BUTTON_A | BUTTON_B
- ret nz
- call RTC
- jr Functiona36
-; a46
-
-Functiona46: ; a46
- ld a, [hOAMUpdate]
- push af
- ld a, 1
- ld [hOAMUpdate], a
- call WaitBGMap
- call Functiona36
- pop af
- ld [hOAMUpdate], a
- ret
-; a57
-
-Functiona57: ; a57
- call GetJoypadPublic
- ld a, [$ffaa]
- and a
- ld a, [hJoyPressed]
- jr z, .asm_a63
- ld a, [hJoyDown]
-.asm_a63
- ld [$ffa9], a
- ld a, [hJoyPressed]
- and a
- jr z, .asm_a70
- ld a, 15
- ld [TextDelayFrames], a
- ret
-
-.asm_a70
- ld a, [TextDelayFrames]
- and a
- jr z, .asm_a7a
- xor a
- ld [$ffa9], a
- ret
-
-.asm_a7a
- ld a, 5
- ld [TextDelayFrames], a
- ret
-; a80
-
-Functiona80: ; a80
- ld a, [$ffaf]
- push af
- ld a, [$ffb0]
- push af
- xor a
- ld [$ffaf], a
- ld a, $6
- ld [$ffb0], a
-.asm_a8d
- push hl
- ld hl, $c606
- call Functionb06
- pop hl
- call Functiona57
- ld a, [$ffa9]
- and $3
- jr z, .asm_a8d
- pop af
- ld [$ffb0], a
- pop af
- ld [$ffaf], a
- ret
-; aa5
-
-Functionaa5: ; aa5
- call Functiona57
- ld a, [$ffa9]
- and BUTTON_A | BUTTON_B
- jr z, Functionaa5
- ret
-; aaf
-
-Functionaaf: ; aaf
- ld a, [InLinkBattle]
- and a
- jr nz, .asm_ac1
- call Functionac6
- push de
- ld de, SFX_READ_TEXT_2
- call StartSFX
- pop de
- ret
-
-.asm_ac1
- ld c, 65
- jp DelayFrames
-; ac6
-
-Functionac6: ; ac6
- ld a, [hOAMUpdate]
- push af
- ld a, $1
- ld [hOAMUpdate], a
- ld a, [InputType]
- or a
- jr z, .asm_ad9
- callba Function1de28a
-.asm_ad9
- call Functionaf5
- call Functiona57
- ld a, [hJoyPressed]
- and $3
- jr nz, .asm_af1
- call RTC
- ld a, $1
- ld [hBGMapMode], a
- call DelayFrame
- jr .asm_ad9
-
-.asm_af1
- pop af
- ld [hOAMUpdate], a
- ret
-; af5
-
-Functionaf5: ; af5
- ld a, [$ff9b]
- and $10
- jr z, .asm_aff
- ld a, $ee
- jr .asm_b02
-
-.asm_aff
- ld a, [$c605]
-
-.asm_b02
- ld [$c606], a
- ret
-; b06
-
-Functionb06: ; b06
- push bc
- ld a, [hl]
- ld b, a
- ld a, $ee
- cp b
- pop bc
- jr nz, .asm_b27
- ld a, [$ffaf]
- dec a
- ld [$ffaf], a
- ret nz
- ld a, [$ffb0]
- dec a
- ld [$ffb0], a
- ret nz
- ld a, $7a
- ld [hl], a
- ld a, $ff
- ld [$ffaf], a
- ld a, $6
- ld [$ffb0], a
- ret
-
-.asm_b27
- ld a, [$ffaf]
- and a
- ret z
- dec a
- ld [$ffaf], a
- ret nz
- dec a
- ld [$ffaf], a
- ld a, [$ffb0]
- dec a
- ld [$ffb0], a
- ret nz
- ld a, $6
- ld [$ffb0], a
- ld a, $ee
- ld [hl], a
- ret
-; b40
-
--- a/engine/lcd.asm
+++ /dev/null
@@ -1,81 +1,0 @@
-; LCD handling
-
-
-Function547: ; 547
- ld a, [hLCDStatCustom]
- cp rSCX & $ff
- ret nz
- ld c, a
- ld a, [LYOverrides]
- ld [$ff00+c], a
- ret
-; 552
-
-
-LCD: ; 552
- push af
- ld a, [hLCDStatCustom]
- and a
- jr z, .done
-
-; At this point it's assumed we're in WRAM bank 5!
- push bc
- ld a, [rLY]
- ld c, a
- ld b, LYOverrides >> 8
- ld a, [bc]
- ld b, a
- ld a, [hLCDStatCustom]
- ld c, a
- ld a, b
- ld [$ff00+c], a
- pop bc
-
-.done
- pop af
- reti
-; 568
-
-
-DisableLCD: ; 568
-; Turn the LCD off
-
-; Don't need to do anything if the LCD is already off
- ld a, [rLCDC]
- bit 7, a ; lcd enable
- ret z
-
- xor a
- ld [rIF], a
- ld a, [rIE]
- ld b, a
-
-; Disable VBlank
- res 0, a ; vblank
- ld [rIE], a
-
-.wait
-; Wait until VBlank would normally happen
- ld a, [rLY]
- cp 145
- jr nz, .wait
-
- ld a, [rLCDC]
- and %01111111 ; lcd enable off
- ld [rLCDC], a
-
- xor a
- ld [rIF], a
- ld a, b
- ld [rIE], a
- ret
-; 58a
-
-
-EnableLCD: ; 58a
- ld a, [rLCDC]
- set 7, a ; lcd enable
- ld [rLCDC], a
- ret
-; 591
-
--- a/engine/map_objects.asm
+++ /dev/null
@@ -1,683 +1,0 @@
-; Functions handling map objects.
-
-
-GetSpritePalette: ; 17ff
- push hl
- push de
- push bc
- ld c, a
- callba _GetSpritePalette
- ld a, c
- pop bc
- pop de
- pop hl
- ret
-; 180e
-
-
-Function180e: ; 180e
- push hl
- push bc
- ld hl, $d156
- ld c, $1f
- ld b, a
- ld a, [hConnectionStripLength]
- cp $0
- jr z, .asm_182b
- ld a, b
-.asm_181d
- cp [hl]
- jr z, .asm_1830
- inc hl
- inc hl
- dec c
- jr nz, .asm_181d
- ld a, [$d155]
- scf
- jr .asm_1833
-
-.asm_182b
- ld a, [$d155]
- jr .asm_1833
-
-.asm_1830
- inc hl
- xor a
- ld a, [hl]
-
-.asm_1833
- pop bc
- pop hl
- ret
-; 1836
-
-Function1836: ; 1836
- push de
- push hl
-
- ld b, a
- ld a, [hROMBank]
- push af
- ld a, BANK(Function142a7)
- rst Bankswitch
-
- ld a, b
- call Function142a7
- ld c, a
-
- pop de
- ld a, d
- rst Bankswitch
-
- pop hl
- pop de
- ret
-; 184a
-
-
-
-Function184a: ; 184a
- ld a, [StandingTile]
- call GetTileCollision
- ld b, a
- ret
-; 1852
-
-Function1852: ; 1852
- ld a, [StandingTile]
- call GetTileCollision
- sub 1
- ret z
- and a
- ret
-; 185d
-
-
-GetTileCollision: ; 185d
-; Get the collision type of tile a.
-
- push de
- push hl
-
- ld hl, TileCollisionTable
- ld e, a
- ld d, 0
- add hl, de
-
- ld a, [hROMBank]
- push af
- ld a, BANK(TileCollisionTable)
- rst Bankswitch
- ld e, [hl]
- pop af
- rst Bankswitch
-
- ld a, e
- and $f ; lo nybble only
-
- pop hl
- pop de
- ret
-; 1875
-
-
-Function1875: ; 1875
- ld d, a
- and $f0
- cp $10
- jr z, .asm_1882
- cp $20
- jr z, .asm_1888
- scf
- ret
-
-.asm_1882
- ld a, d
- and 7
- ret z
- scf
- ret
-
-.asm_1888
- ld a, d
- and 7
- ret z
- scf
- ret
-; 188e
-
-Function188e: ; 188e
- cp $14
- ret z
- cp $1c
- ret
-; 1894
-
-CheckCutTreeTile: ; 1894
- cp $12
- ret z
- cp $1a
- ret
-; 189a
-
-CheckHeadbuttTreeTile: ; 189a
- cp $15
- ret z
- cp $1d
- ret
-; 18a0
-
-CheckCounterTile: ; 18a0
- cp $90
- ret z
- cp $98
- ret
-; 18a6
-
-CheckPitTile: ; 18a6
- cp $60
- ret z
- cp $68
- ret
-; 18ac
-
-CheckIceTile: ; 18ac
- cp $23
- ret z
- cp $2b
- ret z
- scf
- ret
-; 18b4
-
-CheckWhirlpoolTile: ; 18b4
- nop
- cp $24
- ret z
- cp $2c
- ret z
- scf
- ret
-; 18bd
-
-CheckWaterfallTile: ; 18bd
- cp $33
- ret z
- cp $3b
- ret
-; 18c3
-
-CheckStandingOnEntrance: ; 18c3
- ld a, [StandingTile]
- cp $71 ; door
- ret z
- cp $79
- ret z
- cp $7a ; stairs
- ret z
- cp $7b ; cave
- ret
-; 18d2
-
-
-GetMapObject: ; 18d2
-; Return the location of map object a in bc.
- ld hl, MapObjects
- ld bc, $10
- call AddNTimes
- ld b, h
- ld c, l
- ret
-; 18de
-
-
-Function18de: ; 18de
- ld [hConnectionStripLength], a
- call GetMapObject
- ld hl, $0000
- add hl, bc
- ld a, [hl]
- cp $ff
- jr z, .asm_18f3
- ld [hConnectedMapWidth], a
- call Function1ae5
- and a
- ret
-
-.asm_18f3
- scf
- ret
-; 18f5
-
-Function18f5: ; 18f5
- ld hl, $0006
- add hl, bc
- ld a, [hl]
- cp $ff
- jr nz, .asm_1921
- ld hl, $0007
- add hl, bc
- ld a, [hl]
- cp $ff
- jr z, .asm_191c
- ld hl, .data_191e
- ld a, [TimeOfDay]
- add l
- ld l, a
- jr nc, .asm_1912
- inc h
-
-.asm_1912
- ld a, [hl]
- ld hl, $0007
- add hl, bc
- and [hl]
- jr nz, .asm_191c
- scf
- ret
-
-.asm_191c
- and a
- ret
-
-.data_191e
- db $1
- db $2
- db $4
-
-.asm_1921
- ld hl, $0006
- add hl, bc
- ld d, [hl]
- ld hl, $0007
- add hl, bc
- ld e, [hl]
- ld hl, hHours
- ld a, d
- cp e
- jr z, .asm_1949
- jr c, .asm_193f
- ld a, [hl]
- cp d
- jr nc, .asm_1949
- cp e
- jr c, .asm_1949
- jr z, .asm_1949
- jr .asm_194b
-
-.asm_193f
- ld a, e
- cp [hl]
- jr c, .asm_194b
- ld a, [hl]
- cp d
- jr nc, .asm_1949
- jr .asm_194b
-
-.asm_1949
- and a
- ret
-
-.asm_194b
- scf
- ret
-; 194d
-
-Function194d: ; 194d
- ld [hConnectionStripLength], a
- call GetMapObject
- call $40e7
- ret
-; 1956
-
-
-
-Function1956: ; 1956
- ld [hConnectionStripLength], a
- call Function271e
- ld a, [hConnectionStripLength]
- call GetMapObject
- ld a, $2
- ld hl, $40e7
- rst FarCall
- ret
-; 1967
-
-Function1967: ; 1967
- ld [hConnectionStripLength], a
- call GetMapObject
- ld hl, $0000
- add hl, bc
- ld a, [hl]
- cp $ff
- ret z
- ld [hl], $ff
- push af
- call Function1985
- pop af
- call Function1ae5
- callba Function4357
- ret
-; 1985
-
-Function1985: ; 1985
- ld hl, $d4cd
- cp [hl]
- jr z, .asm_1990
- ld hl, $d4ce
- cp [hl]
- ret nz
-
-.asm_1990
- callba Function581f
- ld a, $ff
- ld [$d4cd], a
- ld [$d4ce], a
- ret
-; 199f
-
-Function199f: ; 199f
- call Function1967
- call Function2712
- ret
-; 19a6
-
-Function19a6: ; 19a6
- push hl
- call GetMapObject
- ld d, b
- ld e, c
- ld a, $ff
- ld [de], a
- inc de
- pop hl
- ld bc, $000f
- call CopyBytes
- ret
-; 19b8
-
-Function19b8: ; 19b8
- call GetMapObject
- ld hl, $0000
- add hl, bc
- ld a, [hl]
- push af
- ld [hl], $ff
- inc hl
- ld bc, $000f
- xor a
- call ByteFill
- pop af
- cp $ff
- ret z
- cp $d
- ret nc
- ld b, a
- ld a, [$d4cd]
- cp b
- jr nz, .asm_19de
- ld a, $ff
- ld [$d4cd], a
-
-.asm_19de
- ld a, b
- call Function1ae5
- callba Function4357
- ret
-; 19e9
-
-
-
-Function19e9: ; 19e9
- ld [$c2e2], a
- ld a, [hROMBank]
- ld [$c2e3], a
- ld a, l
- ld [$c2e4], a
- ld a, h
- ld [$c2e5], a
- ld a, [$c2e2]
- call Function18de
- ret c
- ld hl, $0003
- add hl, bc
- ld [hl], $14
- ld hl, $0009
- add hl, bc
- ld [hl], $0
- ld hl, VramState
- set 7, [hl]
- and a
- ret
-; 1a13
-
-
-
-Function1a13: ; 1a13
- push bc
- push de
- ld hl, $d4d6
- ld de, $0028
- ld c, $d
-.asm_1a1d
- ld a, [hl]
- and a
- jr z, .asm_1a28
- add hl, de
- dec c
- jr nz, .asm_1a1d
- xor a
- jr .asm_1a2c
-
-.asm_1a28
- ld a, $d
- sub c
- scf
-
-.asm_1a2c
- pop de
- pop bc
- ret
-; 1a2f
-
-
-
-Function1a2f: ; 1a2f
- ld hl, $0003
- add hl, bc
- ld a, [hl]
- cp $25
- jr c, .asm_1a39
- xor a
-
-.asm_1a39
- ld hl, Data4273
- ld e, a
- ld d, 0
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- ld a, [hl]
- ret
-; 1a47
-
-Function1a47: ; 1a47
- push bc
- push de
- ld e, a
- ld d, 0
- ld hl, Data4273 + 1
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- ld a, BANK(Data4273)
- call GetFarByte
- add a
- add a
- and $c
- pop de
- pop bc
- ret
-; 1a61
-
-
-Function1a61: ; 1a61
- ld l, a
- ld a, [hROMBank]
- push af
- ld a, BANK(Data4273)
- rst Bankswitch
- ld a, l
- push bc
-
- call Function1a71
-
- pop bc
- pop af
- rst Bankswitch
-
- ret
-; 1a71
-
-Function1a71: ; 1a71
- ld hl, $0003
- add hl, de
- ld [hl], a
- push de
- ld e, a
- ld d, 0
- ld hl, Data4273 + 1
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- ld b, h
- ld c, l
- pop de
- ld a, [bc]
- inc bc
- rlca
- rlca
- and $c
- ld hl, $0008
- add hl, de
- ld [hl], a
- ld a, [bc]
- inc bc
- ld hl, $000b
- add hl, de
- ld [hl], a
- ld a, [bc]
- inc bc
- ld hl, $0004
- add hl, de
- ld [hl], a
- ld a, [bc]
- inc bc
- ld hl, $0005
- add hl, de
- ld [hl], a
- ld a, [bc]
- inc bc
- ld hl, $0006
- add hl, de
- ld [hl], a
- ret
-; 1aae
-
-Function1aae: ; 1aae
- ld a, [hROMBank]
- push af
- ld a, [hli]
- rst Bankswitch
-
- ld a, [hli]
- ld d, [hl]
- ld hl, $001b
- add hl, bc
- add [hl]
- ld e, a
- ld a, d
- adc $0
- ld d, a
- inc [hl]
- ld a, [de]
- ld h, a
- pop af
- rst Bankswitch
-
- ld a, h
- ret
-; 1ac6
-
-Function1ac6: ; 1ac6
- ld hl, VramState
- set 0, [hl]
- ret
-; 1acc
-
-Function1acc: ; 1acc
- ld hl, VramState
- res 0, [hl]
- ret
-; 1ad2
-
-
-Function1ad2: ; 1ad2
- ld a, [VramState]
- bit 0, a
- ret z
- callba Function55e0
- callba Function5920
- ret
-; 1ae5
-
-
-Function1ae5: ; 1ae5
- ld bc, $0028
- ld hl, $d4d6
- call AddNTimes
- ld b, h
- ld c, l
- ret
-; 1af1
-
-Function1af1: ; 1af1
- ld hl, $0000
- add hl, bc
- ld a, [hl]
- and a
- ret
-; 1af8
-
-Function1af8: ; 1af8
- push af
- ld hl, $0008
- add hl, bc
- ld a, [hl]
- and $f3
- ld e, a
- pop af
- and $c
- or e
- ld [hl], a
- ret
-; 1b07
-
-
-GetSpriteDirection: ; 1b07
- ld hl, $0008
- add hl, bc
- ld a, [hl]
- and $c
- ret
-; 1b0f
-
--- a/engine/menu.asm
+++ /dev/null
@@ -1,603 +1,0 @@
-; Functions used in displaying and handling menus.
-
-
-LoadMenuDataHeader: ; 0x1d35
- call Function1d3c
- call Function1c00
- ret
-
-Function1d3c: ; 0x1d3c
- ld de, $cf81
- ld bc, $0010
- call CopyBytes
- ld a, [hROMBank]
- ld [$cf8a], a
- ret
-; 0x1d4b
-
-Function1d4b: ; 1d4b
- ld [$cf88], a
- ret
-; 1d4f
-
-
-Function1d4f: ; 1d4f
- push hl
- call Function1d58
- pop hl
- jp PrintText
-; 1d57
-
-Function1d57: ; 1d57
- ret
-; 1d58
-
-Function1d58: ; 1d58
- ld hl, MenuDataHeader_0x1d5f
- call LoadMenuDataHeader
- ret
-; 1d5f
-
-MenuDataHeader_0x1d5f: ; 1d5f
- db $40 ; tile backup
- db 12, 0 ; start coords
- db 17, 19 ; end coords
- dw VTiles0
- db 0 ; default option
-; 1d67
-
-Function1d67: ; 1d67
- call Function1d4f
- call Function1c17
- ret
-; 1d6e
-
-Function1d6e: ; 1d6e
- ld hl, MenuDataHeader_0x1d75
- call LoadMenuDataHeader
- ret
-; 1d75
-
-MenuDataHeader_0x1d75: ; 1d75
- db $40 ; tile backup
- db 0, 0 ; start coords
- db 17, 19 ; end coords
- dw $0000
- db 1 ; default option
-; 1d7d
-
-Function1d7d: ; 1d7d
- call Function1c07
- ret
-; 1d81
-
-Function1d81: ; 0x1d81
- xor a
- ld [hBGMapMode], a
- call Function1cbb
- call Function1ad2
- call Function1c89
- call Function321c
- call Function1c66
- ld a, [$cf91]
- bit 7, a
- jr z, .asm_1da7 ; 0x1d98 $d
- call Function1c10
- call Function1bc9
- call Function1ff8
- bit 1, a
- jr z, .asm_1da9 ; 0x1da5 $2
-.asm_1da7
- scf
- ret
-.asm_1da9
- and a
- ret
-; 0x1dab
-
-Function1dab: ; 1dab
- call LoadMenuDataHeader
- call Function1d81
- call Function1c17
- ld a, [$cfa9]
- ret
-; 1db8
-
-Function1db8: ; 0x1db8
- push hl
- push bc
- push af
- ld hl, $cf86
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- inc hl
- pop af
- call GetNthString
- ld d, h
- ld e, l
- call CopyName1
- pop bc
- pop hl
- ret
-; 0x1dcf
-
-
-Function1dcf: ; 1dcf
- ld bc, $0e07
-
-Function1dd2: ; 1dd2
- jr Function1dd9
-
-Function1dd4: ; 1dd4
- call LoadMenuDataHeader
- jr Function1dfe
-
-Function1dd9: ; 1dd9
- push bc
- ld hl, MenuDataHeader_0x1e1d
- call Function1d3c
- pop bc
- ld a, b
- cp $e
- jr nz, .asm_1de9
- ld a, $e
- ld b, a
-
-.asm_1de9
- ld a, b
- ld [$cf83], a
- add $5
- ld [$cf85], a
- ld a, c
- ld [$cf82], a
- add $4
- ld [$cf84], a
- call Function1c00
-
-Function1dfe: ; 1dfe
- call Function1d81
- push af
- ld c, $f
- call DelayFrames
- call Function1c17
- pop af
- jr c, .asm_1e16
- ld a, [$cfa9]
- cp $2
- jr z, .asm_1e16
- and a
- ret
-
-.asm_1e16
- ld a, $2
- ld [$cfa9], a
- scf
- ret
-; 1e1d
-
-MenuDataHeader_0x1e1d: ; 1e1d
- db $40 ; tile backup
- db 5, 10 ; start coords
- db 9, 15 ; end coords
- dw MenuData2_0x1e25
- db 1 ; default option
-; 1e25
-
-MenuData2_0x1e25: ; 1e25
- db $c0 ; flags
- db 2
- db "YES@"
- db "NO@"
-; 1e2e
-
-Function1e2e: ; 1e2e
- call Function1e35
- call Function1c00
- ret
-; 1e35
-
-Function1e35: ; 1e35
- push de
- call Function1d3c
- pop de
- ld a, [$cf83]
- ld h, a
- ld a, [$cf85]
- sub h
- ld h, a
- ld a, d
- ld [$cf83], a
- add h
- ld [$cf85], a
- ld a, [$cf82]
- ld l, a
- ld a, [$cf84]
- sub l
- ld l, a
- ld a, e
- ld [$cf82], a
- add l
- ld [$cf84], a
- ret
-; 1e5d
-
-Function1e5d: ; 1e5d
- call MenuFunc_1e7f
- call MenuWriteText
- call Function1eff
- call Function1f23
- call Function1bdd
- call Function1ff8
- ret
-; 1e70
-
-SetUpMenu: ; 1e70
- call MenuFunc_1e7f ; ???
- call MenuWriteText
- call Function1eff ; set up selection pointer
- ld hl, $cfa5
- set 7, [hl]
- ret
-
-MenuFunc_1e7f: ; 0x1e7f
- call Function1c66
- call Function1ebd
- call Function1ea6
- call Function1cbb
- ret
-
-MenuWriteText: ; 0x1e8c
- xor a
- ld [hBGMapMode], a
- call Function1ebd ; sort out the text
- call Function1eda ; actually write it
- call Function2e31
- ld a, [hOAMUpdate]
- push af
- ld a, $1
- ld [hOAMUpdate], a
- call Function321c
- pop af
- ld [hOAMUpdate], a
- ret
-; 0x1ea6
-
-Function1ea6: ; 1ea6
- ld a, [$cf83]
- ld c, a
- ld a, [$cf85]
- sub c
- ld c, a
- ld a, [$cf92]
- add a
- inc a
- ld b, a
- ld a, [$cf82]
- add b
- ld [$cf84], a
- ret
-; 1ebd
-
-Function1ebd: ; 1ebd
- ld hl, $cf93
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [$cf76]
- and a
- jr z, .asm_1ed3
- ld b, a
- ld c, $ff
-.asm_1ecc
- ld a, [hli]
- cp c
- jr nz, .asm_1ecc
- dec b
- jr nz, .asm_1ecc
-
-.asm_1ed3
- ld d, h
- ld e, l
- ld a, [hl]
- ld [$cf92], a
- ret
-; 1eda
-
-Function1eda: ; 1eda
- call Function1cfd
- ld bc, $002a
- add hl, bc
-.asm_1ee1
- inc de
- ld a, [de]
- cp $ff
- ret z
- ld [MenuSelection], a
- push de
- push hl
- ld d, h
- ld e, l
- ld hl, $cf95
- call Function1efb
- pop hl
- ld de, $0028
- add hl, de
- pop de
- jr .asm_1ee1
-; 1efb
-
-Function1efb: ; 1efb
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 1eff
-
-Function1eff: ; 1eff
- call Function1c10
- ld hl, $cfa8
- ld a, [$cf91]
- bit 3, a
- jr z, .asm_1f0e
- set 3, [hl]
-
-.asm_1f0e
- ld a, [$cf91]
- bit 2, a
- jr z, .asm_1f19
- set 5, [hl]
- set 4, [hl]
-
-.asm_1f19
- ret
-; 1f1a
-
-
-Function1f1a: ; 1f1a
- call Function1bd3
- ld hl, $cfa8
- and [hl]
- jr Function1f2a
-; 1f23
-
-Function1f23: ; 1f23
- xor a
- ld [$cf73], a
- call Function1bc9
-; 1f2a
-
-Function1f2a: ; 1f2a
- bit 0, a
- jr nz, .asm_1f52
- bit 1, a
- jr nz, .asm_1f6d
- bit 3, a
- jr nz, .asm_1f6d
- bit 4, a
- jr nz, .asm_1f44
- bit 5, a
- jr nz, .asm_1f4b
- xor a
- ld [$cf73], a
- jr .asm_1f57
-
-.asm_1f44
- ld a, $10
- ld [$cf73], a
- jr .asm_1f57
-
-.asm_1f4b
- ld a, $20
- ld [$cf73], a
- jr .asm_1f57
-
-.asm_1f52
- ld a, $1
- ld [$cf73], a
-
-.asm_1f57
- call Function1ebd
- ld a, [$cfa9]
- ld l, a
- ld h, $0
- add hl, de
- ld a, [hl]
- ld [MenuSelection], a
- ld a, [$cfa9]
- ld [$cf88], a
- and a
- ret
-
-.asm_1f6d
- ld a, $2
- ld [$cf73], a
- ld a, $ff
- ld [MenuSelection], a
- scf
- ret
-; 1f79
-
-Function1f79: ; 1f79
- push de
- ld hl, $cf97
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [MenuSelection]
- call GetNthString
- ld d, h
- ld e, l
- pop hl
- call PlaceString
- ret
-; 1f8d
-
-Function1f8d: ; 1f8d
- push de
- ld a, [MenuSelection]
- call Function1fb1
- inc hl
- inc hl
- ld a, [hli]
- ld d, [hl]
- ld e, a
- pop hl
- call PlaceString
- ret
-; 1f9e
-
-Function1f9e: ; 1f9e
- call Function1fb1
- inc hl
- inc hl
- ld a, [hli]
- ld d, [hl]
- ld e, a
- ret
-; 1fa7
-
-Function1fa7: ; 1fa7
- ld a, [MenuSelection]
- call Function1fb1
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp [hl]
-; 1fb1
-
-Function1fb1: ; 1fb1
- ld e, a
- ld d, $0
- ld hl, $cf97
- ld a, [hli]
- ld h, [hl]
- ld l, a
- add hl, de
- add hl, de
- add hl, de
- add hl, de
- ret
-; 1fbf
-
-Function1fbf: ; 1fbf
- ld hl, $cf71
- call Function1ff0
- ld hl, $cf81
- call Function1ff0
- ld hl, $cf91
- call Function1ff0
- ld hl, $cfa1
- call Function1ff0
- ld a, [rSVBK]
- push af
- ld a, $7
- ld [rSVBK], a
- xor a
- ld hl, $dfff
- ld [hld], a
- ld [hld], a
- ld a, l
- ld [$cf71], a
- ld a, h
- ld [$cf72], a
- pop af
- ld [rSVBK], a
- ret
-; 1ff0
-
-Function1ff0: ; 1ff0
- ld bc, $0010
- xor a
- call ByteFill
- ret
-; 1ff8
-
-Function1ff8: ; 1ff8
- push af
- and $3
- jr z, .asm_2007
- ld hl, $cf81
- bit 3, [hl]
- jr nz, .asm_2007
- call PlayClickSFX
-
-.asm_2007
- pop af
- ret
-; 2009
-
-
-PlayClickSFX: ; 2009
- push de
- ld de, SFX_READ_TEXT_2
- call StartSFX
- pop de
- ret
-; 0x2012
-
-Function2012: ; 2012
- call Function1d4f
- call Functiona46
- call Function1c07
- ret
-; 201c
-
-Function201c: ; 201c
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
- call PlaceString
- pop af
- rst Bankswitch
-
- ret
-; 202a
-
-Function202a: ; 202a
- ld a, [hROMBank]
- ld [$cf94], a
- ld a, $9
- ld hl, $400e
- rst FarCall
- ld a, [$cf88]
- ret
-; 2039
-
-Function2039: ; 2039
- ld a, [hROMBank]
- ld [$cf94], a
- ld a, $9
- ld hl, $4022
- rst FarCall
- ld a, [$cf88]
- ret
-; 2048
-
-Function2048: ; 2048
- ld a, [hROMBank]
- ld [$cf94], a
- ld a, $9
- ld hl, $403c
- rst FarCall
- ld a, [$cf88]
- ret
-; 2057
-
-Function2057: ; 2057
- ld a, [hROMBank]
- push af
- ld a, $21
- rst Bankswitch
-
- call $42db
- pop af
- rst Bankswitch
-
- ret
-; 2063
-
--- a/engine/palettes.asm
+++ /dev/null
@@ -1,347 +1,0 @@
-; Functions dealing with palettes.
-
-
-UpdatePalsIfCGB: ; c2f
-; update bgp data from BGPals
-; update obp data from OBPals
-; return carry if successful
-
-; check cgb
- ld a, [hCGB]
- and a
- ret z
-
-
-UpdateCGBPals: ; c33
-; return carry if successful
-; any pals to update?
- ld a, [hCGBPalUpdate]
- and a
- ret z
-
-
-ForceUpdateCGBPals: ; c37
-
- ld a, [rSVBK]
- push af
- ld a, 5 ; BANK(BGPals)
- ld [rSVBK], a
-
- ld hl, BGPals ; 5:d080
-
-; copy 8 pals to bgpd
- ld a, %10000000 ; auto increment, index 0
- ld [rBGPI], a
- ld c, rBGPD % $100
- ld b, 4 ; NUM_PALS / 2
-.bgp
- rept $10
- ld a, [hli]
- ld [$ff00+c], a
- endr
-
- dec b
- jr nz, .bgp
-
-; hl is now 5:d0c0 OBPals
-
-; copy 8 pals to obpd
- ld a, %10000000 ; auto increment, index 0
- ld [rOBPI], a
- ld c, rOBPD - rJOYP
- ld b, 4 ; NUM_PALS / 2
-.obp
- rept $10
- ld a, [hli]
- ld [$ff00+c], a
- endr
-
- dec b
- jr nz, .obp
-
- pop af
- ld [rSVBK], a
-
-; clear pal update queue
- xor a
- ld [hCGBPalUpdate], a
-
- scf
- ret
-; c9f
-
-
-DmgToCgbBGPals: ; c9f
-; exists to forego reinserting cgb-converted image data
-
-; input: a -> bgp
-
- ld [rBGP], a
- push af
-
- ld a, [hCGB]
- and a
- jr z, .end
-
- push hl
- push de
- push bc
- ld a, [rSVBK]
- push af
-
- ld a, 5
- ld [rSVBK], a
-
-; copy & reorder bg pal buffer
- ld hl, BGPals ; to
- ld de, Unkn1Pals ; from
-; order
- ld a, [rBGP]
- ld b, a
-; all pals
- ld c, 8
- call CopyPals
-; request pal update
- ld a, 1
- ld [hCGBPalUpdate], a
-
- pop af
- ld [rSVBK], a
- pop bc
- pop de
- pop hl
-.end
- pop af
- ret
-; ccb
-
-
-DmgToCgbObjPals: ; ccb
-; exists to forego reinserting cgb-converted image data
-
-; input: d -> obp1
-; e -> obp2
-
- ld a, e
- ld [rOBP0], a
- ld a, d
- ld [rOBP1], a
-
- ld a, [hCGB]
- and a
- ret z
-
- push hl
- push de
- push bc
- ld a, [rSVBK]
- push af
-
- ld a, 5
- ld [rSVBK], a
-
-; copy & reorder obj pal buffer
- ld hl, OBPals ; to
- ld de, Unkn2Pals ; from
-; order
- ld a, [rOBP0]
- ld b, a
-; all pals
- ld c, 8
- call CopyPals
-; request pal update
- ld a, 1
- ld [hCGBPalUpdate], a
-
- pop af
- ld [rSVBK], a
- pop bc
- pop de
- pop hl
- ret
-; cf8
-
-
-Functioncf8: ; cf8
- ld [rOBP0], a
- push af
- ld a, [hCGB]
- and a
- jr z, .asm_d22
- push hl
- push de
- push bc
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, $d0c0
- ld de, MartPointer
- ld a, [rOBP0]
- ld b, a
- ld c, $1
- call CopyPals
- ld a, $1
- ld [hCGBPalUpdate], a
- pop af
- ld [rSVBK], a
- pop bc
- pop de
- pop hl
-
-.asm_d22
- pop af
- ret
-; d24
-
-Functiond24: ; d24
- ld [rOBP1], a
- push af
- ld a, [hCGB]
- and a
- jr z, .asm_d4e
- push hl
- push de
- push bc
- ld a, [rSVBK]
- push af
- ld a, $5
- ld [rSVBK], a
- ld hl, $d0c8
- ld de, $d048
- ld a, [rOBP1]
- ld b, a
- ld c, $1
- call CopyPals
- ld a, $1
- ld [hCGBPalUpdate], a
- pop af
- ld [rSVBK], a
- pop bc
- pop de
- pop hl
-
-.asm_d4e
- pop af
- ret
-; d50
-
-
-
-CopyPals: ; d50
-; copy c palettes in order b from de to hl
-
- push bc
- ld c, 4 ; NUM_PAL_COLORS
-.loop
- push de
- push hl
-
-; get pal color
- ld a, b
- and %11 ; color
-; 2 bytes per color
- add a
- ld l, a
- ld h, 0
- add hl, de
- ld e, [hl]
- inc hl
- ld d, [hl]
-
-; dest
- pop hl
-; write color
- ld [hl], e
- inc hl
- ld [hl], d
- inc hl
-; next pal color
- srl b
- srl b
-; source
- pop de
-; done pal?
- dec c
- jr nz, .loop
-
-; de += 8 (next pal)
- ld a, 8 ; NUM_PAL_COLORS * 2 ; bytes per pal
- add e
- jr nc, .ok
- inc d
-.ok
- ld e, a
-
-; how many more pals?
- pop bc
- dec c
- jr nz, CopyPals
- ret
-; d79
-
-
-Functiond79: ; d79
- ld a, [hCGB]
- and a
- ret z
- ld a, 1
- ld [rVBK], a
- ld hl, VTiles0
- ld bc, $2000
- xor a
- call ByteFill
- ld a, 0
- ld [rVBK], a
- ret
-; d90
-
-
-Functiond90: ; d90
- ret
-; d91
-
-
-Functiond91: ; d91
- ld a, [hCGB]
- and a
- ret z
- ld a, [rSVBK]
- push af
- ld a, 5 ; BANK(BGPals)
- ld [rSVBK], a
- ld hl, BGPals
- ld bc, $40 + $10
- xor a
- call ByteFill
- pop af
- ld [rSVBK], a
- ld a, 1
- ld [hCGBPalUpdate], a
- call DelayFrame
- ret
-; db1
-
-
-Functiondb1: ; db1
- ld a, [hROMBank]
- push af
- ld a, BANK(Function4c000)
- rst Bankswitch
- call Function4c000
- pop af
- rst Bankswitch
- ret
-; dbd
-
-Functiondbd: ; dbd
- ld a, [hROMBank]
- push af
- ld a, BANK(Function4c03f)
- rst Bankswitch
- call Function4c03f
- pop af
- rst Bankswitch
- ret
-; dc9
-
--- a/engine/rtc.asm
+++ /dev/null
@@ -1,25 +1,0 @@
-RTC: ; 46f
-; update time and time-sensitive palettes
-
-; rtc enabled?
- ld a, [$c2ce]
- cp 0
- ret z
-
- call UpdateTime
-
-; obj update on?
- ld a, [VramState]
- bit 0, a ; obj update
- ret z
-
-TimeOfDayPals: ; 47e
- callab _TimeOfDayPals
- ret
-; 485
-
-UpdateTimePals: ; 485
- callab _UpdateTimePals
- ret
-; 48c
-
--- a/engine/scripting.asm
+++ b/engine/scripting.asm
@@ -539,7 +539,7 @@
ld a, [de]
ld [$d10c], a
ld hl, $d892
- call Function2f66
+ call ReceiveItem
ld a, $1
jr c, .asm_96fb0 ; 0x96fad $1
xor a
@@ -2320,7 +2320,7 @@
call GetScriptByte
ld [$d10c], a
ld hl, $d892
- call Function2f66
+ call ReceiveItem
jr nc, .asm_977eb ; 0x977e3 $6
ld a, $1
ld [$c2dd], a
@@ -2346,7 +2346,7 @@
ld a, $ff
ld [$d107], a
ld hl, $d892
- call Function2f53
+ call TossItem
ret nc
ld a, $1
ld [$c2dd], a
@@ -2363,7 +2363,7 @@
call GetScriptByte
ld [$d106], a
ld hl, $d892
- call PickUpItem
+ call CheckItem
ret nc
ld a, $1
ld [$c2dd], a
--- a/engine/serial.asm
+++ /dev/null
@@ -1,408 +1,0 @@
-Serial: ; 6ef
-; The serial interrupt.
-
- push af
- push bc
- push de
- push hl
-
- ld a, [$ffc9]
- and a
- jr nz, .asm_71c
-
- ld a, [$c2d4]
- bit 0, a
- jr nz, .asm_721
-
- ld a, [$ffcb]
- inc a
- jr z, .asm_726
-
- ld a, [rSB]
- ld [hSerialReceive], a
-
- ld a, [hSerialSend]
- ld [rSB], a
-
- ld a, [$ffcb]
- cp $2
- jr z, .asm_752
-
- ld a, 0 << rSC_ON
- ld [rSC], a
- ld a, 1 << rSC_ON
- ld [rSC], a
- jr .asm_752
-
-.asm_71c
- call Function3e80
- jr .asm_75a
-
-.asm_721
- call Function2057
- jr .asm_75a
-
-.asm_726
- ld a, [rSB]
- cp $1
- jr z, .asm_730
- cp $2
- jr nz, .asm_752
-
-.asm_730
- ld [hSerialReceive], a
- ld [$ffcb], a
- cp $2
- jr z, .asm_74f
-
- xor a
- ld [rSB], a
- ld a, $3
- ld [rDIV], a
-
-.asm_73f
- ld a, [rDIV]
- bit 7, a
- jr nz, .asm_73f
-
- ld a, 0 << rSC_ON
- ld [rSC], a
- ld a, 1 << rSC_ON
- ld [rSC], a
- jr .asm_752
-
-.asm_74f
- xor a
- ld [rSB], a
-
-.asm_752
- ld a, $1
- ld [$ffca], a
- ld a, $fe
- ld [hSerialSend], a
-
-.asm_75a
- pop hl
- pop de
- pop bc
- pop af
- reti
-; 75f
-
-Function75f: ; 75f
- ld a, $1
- ld [$ffcc], a
-.asm_763
- ld a, [hl]
- ld [hSerialSend], a
- call Function78a
- push bc
- ld b, a
- inc hl
- ld a, $30
-.asm_76e
- dec a
- jr nz, .asm_76e
- ld a, [$ffcc]
- and a
- ld a, b
- pop bc
- jr z, .asm_782
- dec hl
- cp $fd
- jr nz, .asm_763
- xor a
- ld [$ffcc], a
- jr .asm_763
-
-.asm_782
- ld [de], a
- inc de
- dec bc
- ld a, b
- or c
- jr nz, .asm_763
- ret
-; 78a
-
-Function78a: ; 78a
- xor a
- ld [$ffca], a
- ld a, [$ffcb]
- cp $2
- jr nz, .asm_79b
- ld a, $1
- ld [rSC], a
- ld a, $81
- ld [rSC], a
-
-.asm_79b
- ld a, [$ffca]
- and a
- jr nz, .asm_7e5
- ld a, [$ffcb]
- cp $1
- jr nz, .asm_7c0
- call Function82b
- jr z, .asm_7c0
- call .asm_825
- push hl
- ld hl, $cf5c
- inc [hl]
- jr nz, .asm_7b7
- dec hl
- inc [hl]
-
-.asm_7b7
- pop hl
- call Function82b
- jr nz, .asm_79b
- jp Function833
-
-.asm_7c0
- ld a, [rIE]
- and $f
- cp $8
- jr nz, .asm_79b
- ld a, [$cf5d]
- dec a
- ld [$cf5d], a
- jr nz, .asm_79b
- ld a, [$cf5e]
- dec a
- ld [$cf5e], a
- jr nz, .asm_79b
- ld a, [$ffcb]
- cp $1
- jr z, .asm_7e5
- ld a, $ff
-.asm_7e2
- dec a
- jr nz, .asm_7e2
-
-.asm_7e5
- xor a
- ld [$ffca], a
- ld a, [rIE]
- and $f
- sub $8
- jr nz, .asm_7f8
- ld [$cf5d], a
- ld a, $50
- ld [$cf5e], a
-
-.asm_7f8
- ld a, [hSerialReceive]
- cp $fe
- ret nz
- call Function82b
- jr z, .asm_813
- push hl
- ld hl, $cf5c
- ld a, [hl]
- dec a
- ld [hld], a
- inc a
- jr nz, .asm_80d
- dec [hl]
-
-.asm_80d
- pop hl
- call Function82b
- jr z, Function833
-
-.asm_813
- ld a, [rIE]
- and $f
- cp $8
- ld a, $fe
- ret z
- ld a, [hl]
- ld [hSerialSend], a
- call DelayFrame
- jp Function78a
-
-.asm_825
- ld a, $f
-.asm_827
- dec a
- jr nz, .asm_827
- ret
-; 82b
-
-Function82b: ; 82b
- push hl
- ld hl, $cf5b
- ld a, [hli]
- or [hl]
- pop hl
- ret
-; 833
-
-Function833: ; 833
- dec a
- ld [$cf5b], a
- ld [$cf5c], a
- ret
-; 83b
-
-Function83b: ; 83b
- ld hl, $cf56
- ld de, $cf51
- ld c, $2
- ld a, $1
- ld [$ffcc], a
-.asm_847
- call DelayFrame
- ld a, [hl]
- ld [hSerialSend], a
- call Function78a
- ld b, a
- inc hl
- ld a, [$ffcc]
- and a
- ld a, $0
- ld [$ffcc], a
- jr nz, .asm_847
- ld a, b
- ld [de], a
- inc de
- dec c
- jr nz, .asm_847
- ret
-; 862
-
-Function862: ; 862
- call Function309d
- callab Function4000
- call Function87d
- jp Function30b4
-; 871
-
-
-Function871: ; 871
- call Function309d
- callab Function4000
- jp Function87d
-; 87d
-
-
-
-Function87d: ; 87d
- ld a, $ff
- ld [$cf52], a
-.asm_882
- call Function8c1
- call DelayFrame
- call Function82b
- jr z, .asm_89e
- push hl
- ld hl, $cf5c
- dec [hl]
- jr nz, .asm_89d
- dec hl
- dec [hl]
- jr nz, .asm_89d
- pop hl
- xor a
- jp Function833
-
-.asm_89d
- pop hl
-
-.asm_89e
- ld a, [$cf52]
- inc a
- jr z, .asm_882
- ld b, $a
-.asm_8a6
- call DelayFrame
- call Function8c1
- dec b
- jr nz, .asm_8a6
- ld b, $a
-.asm_8b1
- call DelayFrame
- call Function908
- dec b
- jr nz, .asm_8b1
- ld a, [$cf52]
- ld [$cf51], a
- ret
-; 8c1
-
-Function8c1: ; 8c1
- push bc
- ld b, $60
- ld a, [InLinkBattle]
- cp $1
- jr z, .asm_8d7
- ld b, $60
- jr c, .asm_8d7
- cp $2
- ld b, $70
- jr z, .asm_8d7
- ld b, $80
-
-.asm_8d7
- call Function8f3
- ld a, [$cf56]
- add b
- ld [hSerialSend], a
- ld a, [$ffcb]
- cp $2
- jr nz, .asm_8ee
- ld a, $1
- ld [rSC], a
- ld a, $81
- ld [rSC], a
-
-.asm_8ee
- call Function8f3
- pop bc
- ret
-; 8f3
-
-Function8f3: ; 8f3
- ld a, [hSerialReceive]
- ld [$cf51], a
- and $f0
- cp b
- ret nz
- xor a
- ld [hSerialReceive], a
- ld a, [$cf51]
- and $f
- ld [$cf52], a
- ret
-; 908
-
-Function908: ; 908
- xor a
- ld [hSerialSend], a
- ld a, [$ffcb]
- cp $2
- ret nz
- ld a, $1
- ld [rSC], a
- ld a, $81
- ld [rSC], a
- ret
-; 919
-
-Function919: ; 919
- ld a, [InLinkBattle]
- and a
- ret nz
- ld a, $2
- ld [rSB], a
- xor a
- ld [hSerialReceive], a
- ld a, $0
- ld [rSC], a
- ld a, $80
- ld [rSC], a
- ret
-; 92e
-
-
--- a/engine/sine.asm
+++ /dev/null
@@ -1,22 +1,0 @@
-Cosine: ; 1b0f
-; Return d * cos(a) in hl
- add $10 ; 90 degrees
-
-Sine: ; 1b11
-; Return d * sin(a) in hl
-; a is a signed 6-bit value.
-
- ld e, a
-
- ld a, [hROMBank]
- push af
- ld a, BANK(_Sine)
- rst Bankswitch
-
- call _Sine
-
- pop af
- rst Bankswitch
- ret
-; 1b1e
-
--- /dev/null
+++ b/engine/std_scripts.asm
@@ -1,0 +1,2619 @@
+StdScripts: ; bc000
+ dbw BANK(PokeCenterNurseScript), PokeCenterNurseScript
+ dbw BANK(UnknownScript_0xbc162), UnknownScript_0xbc162
+ dbw BANK(UnknownScript_0xbc166), UnknownScript_0xbc166
+ dbw BANK(UnknownScript_0xbc16a), UnknownScript_0xbc16a
+ dbw BANK(UnknownScript_0xbc16e), UnknownScript_0xbc16e
+ dbw BANK(UnknownScript_0xbc172), UnknownScript_0xbc172
+ dbw BANK(UnknownScript_0xbc176), UnknownScript_0xbc176
+ dbw BANK(UnknownScript_0xbc17a), UnknownScript_0xbc17a
+ dbw BANK(UnknownScript_0xbc185), UnknownScript_0xbc185
+ dbw BANK(UnknownScript_0xbc189), UnknownScript_0xbc189
+ dbw BANK(UnknownScript_0xbc191), UnknownScript_0xbc191
+ dbw BANK(UnknownScript_0xbc195), UnknownScript_0xbc195
+ dbw BANK(UnknownScript_0xbc19d), UnknownScript_0xbc19d
+ dbw BANK(UnknownScript_0xbc1a5), UnknownScript_0xbc1a5
+ dbw BANK(UnknownScript_0xbc1b8), UnknownScript_0xbc1b8
+ dbw BANK(UnknownScript_0xbc1bc), UnknownScript_0xbc1bc
+ dbw BANK(UnknownScript_0xbc1c0), UnknownScript_0xbc1c0
+ dbw BANK(UnknownScript_0xbc1c4), UnknownScript_0xbc1c4
+ dbw BANK(UnknownScript_0xbc23e), UnknownScript_0xbc23e
+ dbw BANK(UnknownScript_0xbc242), UnknownScript_0xbc242
+ dbw BANK(UnknownScript_0xbc1af), UnknownScript_0xbc1af
+ dbw BANK(UnknownScript_0xbc1c8), UnknownScript_0xbc1c8
+ dbw BANK(UnknownScript_0xbc25c), UnknownScript_0xbc25c
+ dbw BANK(UnknownScript_0xbc274), UnknownScript_0xbc274
+ dbw BANK(UnknownScript_0xbc3db), UnknownScript_0xbc3db
+ dbw BANK(UnknownScript_0xbc574), UnknownScript_0xbc574
+ dbw BANK(UnknownScript_0xbc62d), UnknownScript_0xbc62d
+ dbw BANK(UnknownScript_0xbc6e6), UnknownScript_0xbc6e6
+ dbw BANK(UnknownScript_0xbc6f0), UnknownScript_0xbc6f0
+ dbw BANK(UnknownScript_0xbc7ce), UnknownScript_0xbc7ce
+ dbw BANK(UnknownScript_0xbc8ac), UnknownScript_0xbc8ac
+ dbw BANK(UnknownScript_0xbc98a), UnknownScript_0xbc98a
+ dbw BANK(UnknownScript_0xbca47), UnknownScript_0xbca47
+ dbw BANK(UnknownScript_0xbca8f), UnknownScript_0xbca8f
+ dbw BANK(UnknownScript_0xbcb0a), UnknownScript_0xbcb0a
+ dbw BANK(UnknownScript_0xbcb35), UnknownScript_0xbcb35
+ dbw BANK(UnknownScript_0xbcb7f), UnknownScript_0xbcb7f
+ dbw BANK(UnknownScript_0xbcbc9), UnknownScript_0xbcbc9
+ dbw BANK(UnknownScript_0xbcbd3), UnknownScript_0xbcbd3
+ dbw BANK(UnknownScript_0xbcc2d), UnknownScript_0xbcc2d
+ dbw BANK(UnknownScript_0xbcc87), UnknownScript_0xbcc87
+ dbw BANK(UnknownScript_0xbcce1), UnknownScript_0xbcce1
+ dbw BANK(UnknownScript_0xbcd30), UnknownScript_0xbcd30
+ dbw BANK(UnknownScript_0xbcd5a), UnknownScript_0xbcd5a
+ dbw BANK(UnknownScript_0xbcd93), UnknownScript_0xbcd93
+ dbw BANK(UnknownScript_0xbcda0), UnknownScript_0xbcda0
+ dbw BANK(UnknownScript_0xbcdaa), UnknownScript_0xbcdaa
+ dbw BANK(UnknownScript_0xbcdb9), UnknownScript_0xbcdb9
+ dbw BANK(UnknownScript_0xbcdc3), UnknownScript_0xbcdc3
+ dbw BANK(UnknownScript_0xbc1a9), UnknownScript_0xbc1a9
+ dbw BANK(UnknownScript_0xbcdcd), UnknownScript_0xbcdcd
+ dbw BANK(UnknownScript_0xbce7f), UnknownScript_0xbce7f
+; bc09c
+
+PokeCenterNurseScript: ; bc09c
+; Talking to a nurse in a Pokemon Center
+
+ loadfont
+; The nurse has different text for:
+; Morn
+ checktime $1
+ iftrue .morn
+; Day
+ checktime $2
+ iftrue .day
+; Nite
+ checktime $4
+ iftrue .nite
+; If somehow it's not a time of day at all, we skip the introduction
+ 2jump .heal
+
+.morn
+; Different text if we're in the com center
+ checkbit1 $032a
+ iftrue .morn_comcenter
+; Good morning! Welcome to ...
+ 3writetext BANK(UnknownText_0x1b0000), UnknownText_0x1b0000
+ keeptextopen
+ 2jump .heal
+.morn_comcenter
+; Good morning! This is the ...
+ 3writetext BANK(UnknownText_0x1b008a), UnknownText_0x1b008a
+ keeptextopen
+ 2jump .heal
+
+.day
+; Different text if we're in the com center
+ checkbit1 $032a
+ iftrue .day_comcenter
+; Hello! Welcome to ...
+ 3writetext BANK(UnknownText_0x1b002b), UnknownText_0x1b002b
+ keeptextopen
+ 2jump .heal
+.day_comcenter
+; Hello! This is the ...
+ 3writetext BANK(UnknownText_0x1b00d6), UnknownText_0x1b00d6
+ keeptextopen
+ 2jump .heal
+
+.nite
+; Different text if we're in the com center
+ checkbit1 $032a
+ iftrue .nite_comcenter
+; Good evening! You're out late. ...
+ 3writetext BANK(UnknownText_0x1b004f), UnknownText_0x1b004f
+ keeptextopen
+ 2jump .heal
+.nite_comcenter
+; Good to see you working so late. ...
+ 3writetext BANK(UnknownText_0x1b011b), UnknownText_0x1b011b
+ keeptextopen
+ 2jump .heal
+
+.heal
+; If we come back, don't welcome us to the com center again
+ clearbit1 $032a
+; Ask if you want to heal
+ 3writetext BANK(UnknownText_0x1b017a), UnknownText_0x1b017a
+ yesorno
+ iffalse .end
+; Go ahead and heal
+ 3writetext BANK(UnknownText_0x1b01bd), UnknownText_0x1b01bd
+ pause 20
+ special $009d
+; Turn to the machine
+ spriteface $fe, $2
+ pause 10
+ special $001b
+ playmusic $0000
+ writebyte $0
+ special $003e
+ pause 30
+ special $003d
+ spriteface $fe, $0
+ pause 10
+; Has Elm already phoned you about Pokerus?
+ checkphonecall
+ iftrue .done
+; Has Pokerus already been found in the Pokecenter?
+ checkbit2 $000d
+ iftrue .done
+; Check for Pokerus
+ special $004e ; SPECIAL_CHECKPOKERUS
+ iftrue .pokerus
+.done
+; Thank you for waiting. ...
+ 3writetext BANK(UnknownText_0x1b01d7), UnknownText_0x1b01d7
+ pause 20
+.end
+; We hope to see you again.
+ 3writetext BANK(UnknownText_0x1b020b), UnknownText_0x1b020b
+; Curtsy
+ spriteface $fe, $1
+ pause 10
+ spriteface $fe, $0
+ pause 10
+; And we're out
+ closetext
+ loadmovesprites
+ end
+
+.pokerus
+; Different text for com center (excludes 'in a Pokemon Center')
+; Since flag $32a is cleared when healing,
+; this text is never actually seen
+ checkbit1 $032a
+ iftrue .pokerus_comcenter
+; Your Pokemon appear to be infected ...
+ 3writetext BANK(UnknownText_0x1b0241), UnknownText_0x1b0241
+ closetext
+ loadmovesprites
+ 2jump .endpokerus
+.pokerus_comcenter
+; Your Pokemon appear to be infected ...
+ 3writetext BANK(UnknownText_0x1b02d6), UnknownText_0x1b02d6
+ closetext
+ loadmovesprites
+.endpokerus
+; Don't tell us about Pokerus again
+ setbit2 $000d
+; Trigger Elm's Pokerus phone call
+ specialphonecall $0001
+ end
+; bc162
+
+UnknownScript_0xbc162: ; 0xbc162
+ 3jumptext $6c, $435a
+; 0xbc166
+
+UnknownScript_0xbc166: ; 0xbc166
+ 3jumptext $6c, $4378
+; 0xbc16a
+
+UnknownScript_0xbc16a: ; 0xbc16a
+ 3jumptext $6c, $43a3
+; 0xbc16e
+
+UnknownScript_0xbc16e: ; 0xbc16e
+ 3jumptext $6c, $43d9
+; 0xbc172
+
+UnknownScript_0xbc172: ; 0xbc172
+ 3jumptext $6c, $4448
+; 0xbc176
+
+UnknownScript_0xbc176: ; 0xbc176
+ 3jumptext $6c, $4472
+; 0xbc17a
+
+UnknownScript_0xbc17a: ; 0xbc17a
+ loadfont
+ 3writetext $6c, $448d
+ closetext
+ special $0026
+ loadmovesprites
+ end
+; 0xbc185
+
+UnknownScript_0xbc185: ; 0xbc185
+ 3jumptext $6c, $44a0
+; 0xbc189
+
+UnknownScript_0xbc189: ; 0xbc189
+ loadfont
+ 3writetext $6c, $44be
+ closetext
+ loadmovesprites
+ end
+; 0xbc191
+
+UnknownScript_0xbc191: ; 0xbc191
+ 3jumptext $6c, $44c9
+; 0xbc195
+
+UnknownScript_0xbc195: ; 0xbc195
+ loadfont
+ writebyte $0
+ special $0028
+ loadmovesprites
+ end
+; 0xbc19d
+
+UnknownScript_0xbc19d: ; 0xbc19d
+ loadfont
+ writebyte $4
+ special $0028
+ loadmovesprites
+ end
+; 0xbc1a5
+
+UnknownScript_0xbc1a5: ; 0xbc1a5
+ 3jumptext $6c, $4526
+; 0xbc1a9
+
+UnknownScript_0xbc1a9: ; 0xbc1a9
+ loadfont
+ special $001c
+ loadmovesprites
+ end
+; 0xbc1af
+
+UnknownScript_0xbc1af: ; 0xbc1af
+ playsound $0008
+ pause 15
+ playsound $0027
+ end
+; 0xbc1b8
+
+UnknownScript_0xbc1b8: ; 0xbc1b8
+ 3jump BANK(UnknownScript_0xcd4b), UnknownScript_0xcd4b
+; 0xbc1bc
+
+UnknownScript_0xbc1bc: ; 0xbc1bc
+ 3jump BANK(UnknownScript_0xcf5d), UnknownScript_0xcf5d
+; 0xbc1c0
+
+UnknownScript_0xbc1c0: ; 0xbc1c0
+ 3jumptext $6c, $457f
+; 0xbc1c4
+
+UnknownScript_0xbc1c4: ; 0xbc1c4
+ 3jumptext $6c, $459c
+; 0xbc1c8
+
+UnknownScript_0xbc1c8: ; 0xbc1c8
+ checkcode $b
+ if_equal $1, UnknownScript_0xbc1e7
+ if_equal $2, UnknownScript_0xbc1ec
+ if_equal $3, UnknownScript_0xbc1f1
+ if_equal $4, UnknownScript_0xbc1f6
+ if_equal $5, UnknownScript_0xbc1fb
+ if_equal $6, UnknownScript_0xbc200
+ stringtotext UnknownRawText_0xbc205, $0
+ end
+; 0xbc1e7
+
+UnknownScript_0xbc1e7: ; 0xbc1e7
+ stringtotext UnknownRawText_0xbc20c, $0
+ end
+; 0xbc1ec
+
+UnknownScript_0xbc1ec: ; 0xbc1ec
+ stringtotext UnknownRawText_0xbc213, $0
+ end
+; 0xbc1f1
+
+UnknownScript_0xbc1f1: ; 0xbc1f1
+ stringtotext UnknownRawText_0xbc21b, $0
+ end
+; 0xbc1f6
+
+UnknownScript_0xbc1f6: ; 0xbc1f6
+ stringtotext UnknownRawText_0xbc225, $0
+ end
+; 0xbc1fb
+
+UnknownScript_0xbc1fb: ; 0xbc1fb
+ stringtotext UnknownRawText_0xbc22e, $0
+ end
+; 0xbc200
+
+UnknownScript_0xbc200: ; 0xbc200
+ stringtotext UnknownRawText_0xbc235, $0
+ end
+; 0xbc205
+
+UnknownRawText_0xbc205: ; bc205
+ db "SUNDAY@"
+; bc20c
+
+UnknownRawText_0xbc20c: ; bc20c
+ db "MONDAY@"
+; bc213
+
+UnknownRawText_0xbc213: ; bc213
+ db "TUESDAY@"
+; bc21b
+
+UnknownRawText_0xbc21b: ; bc21b
+ db "WEDNESDAY@"
+; bc225
+
+UnknownRawText_0xbc225: ; bc225
+ db "THURSDAY@"
+; bc22e
+
+UnknownRawText_0xbc22e: ; bc22e
+ db "FRIDAY@"
+; bc235
+
+UnknownRawText_0xbc235: ; bc235
+ db "SATURDAY@"
+; bc23e
+
+UnknownScript_0xbc23e: ; 0xbc23e
+ clearbit1 $06cd
+ end
+; 0xbc242
+
+UnknownScript_0xbc242: ; 0xbc242
+ setbit2 $0013
+ setbit1 $06cf
+ setbit1 $06d1
+ clearbit1 $06ce
+ clearbit1 $0025
+ setbit1 $0756
+ specialphonecall $0004
+ domaptrigger GROUP_MAHOGANY_TOWN, MAP_MAHOGANY_TOWN, $1
+ end
+; 0xbc25c
+
+UnknownScript_0xbc25c: ; 0xbc25c
+ special $0034
+ 2call UnknownScript_0xbc380
+ setbit1 $0747
+ clearbit1 $0748
+ setbit1 $02d2
+ warp GROUP_ROUTE_36_NATIONAL_PARK_GATE, MAP_ROUTE_36_NATIONAL_PARK_GATE, $0, $4
+ applymovement $0, MovementData_0xbcea1
+
+UnknownScript_0xbc274: ; bc274
+ clearbit2 $0011
+ clearbit1 $02d2
+ clearbit1 $0313
+ clearbit1 $0314
+ clearbit1 $0315
+ clearbit1 $0316
+ loadfont
+ 3writetext $6c, $45bf
+ closetext
+ special $0014
+ RAM2MEM $0
+ if_equal $1, UnknownScript_0xbc31e
+ if_equal $2, UnknownScript_0xbc332
+ if_equal $3, UnknownScript_0xbc343
+ 3writetext $6c, $4681
+ keeptextopen
+ waitbutton
+ verbosegiveitem BERRY, 1
+ iffalse UnknownScript_0xbc375
+ 3writetext $6c, $46b7
+ keeptextopen
+ 2jump $42b6
+; 0xbc2b1
+
+UnknownScript_0xbc2b1: ; 0xbc2b1
+ 3writetext $6c, $465b
+ keeptextopen
+ checkbit1 $0308
+ iffalse $42c4
+ 3writetext $6c, $46d9
+ closetext
+ special $0017
+ special $0015
+ if_equal $0, $42d4
+ if_equal $2, $42d4
+ 3writetext $6c, $470d
+ closetext
+ loadmovesprites
+ dotrigger $0
+ domaptrigger GROUP_ROUTE_35_NATIONAL_PARK_GATE, MAP_ROUTE_35_NATIONAL_PARK_GATE, $0
+ setbit1 $0716
+ setbit1 $0717
+ setbit1 $0718
+ setbit1 $0719
+ setbit1 $071a
+ setbit1 $071b
+ setbit1 $071c
+ setbit1 $071d
+ setbit1 $071e
+ setbit1 $071f
+ setbit1 $0720
+ setbit1 $0721
+ setbit1 $0722
+ setbit1 $0723
+ setbit1 $0724
+ setbit1 $0725
+ setbit1 $0726
+ setbit1 $0727
+ setbit1 $0728
+ setbit1 $0729
+ setbit2 $0051
+ special $003c
+ end
+; 0xbc31e
+
+UnknownScript_0xbc31e: ; 0xbc31e
+ setbit1 $0000
+ itemtotext SUN_STONE, $1
+ 3writetext $6c, $4621
+ closetext
+ verbosegiveitem SUN_STONE, 1
+ iffalse UnknownScript_0xbc354
+ 2jump UnknownScript_0xbc2b1
+; 0xbc332
+
+UnknownScript_0xbc332: ; 0xbc332
+ itemtotext EVERSTONE, $1
+ 3writetext $6c, $4621
+ closetext
+ verbosegiveitem EVERSTONE, 1
+ iffalse UnknownScript_0xbc35f
+ 2jump UnknownScript_0xbc2b1
+; 0xbc343
+
+UnknownScript_0xbc343: ; 0xbc343
+ itemtotext GOLD_BERRY, $1
+ 3writetext $6c, $4621
+ closetext
+ verbosegiveitem GOLD_BERRY, 1
+ iffalse UnknownScript_0xbc36a
+ 2jump UnknownScript_0xbc2b1
+; 0xbc354
+
+UnknownScript_0xbc354: ; 0xbc354
+ 3writetext $6c, $48cc
+ keeptextopen
+ setbit1 $0313
+ 2jump UnknownScript_0xbc2b1
+; 0xbc35f
+
+UnknownScript_0xbc35f: ; 0xbc35f
+ 3writetext $6c, $48cc
+ keeptextopen
+ setbit1 $0314
+ 2jump UnknownScript_0xbc2b1
+; 0xbc36a
+
+UnknownScript_0xbc36a: ; 0xbc36a
+ 3writetext $6c, $48cc
+ keeptextopen
+ setbit1 $0315
+ 2jump UnknownScript_0xbc2b1
+; 0xbc375
+
+UnknownScript_0xbc375: ; 0xbc375
+ 3writetext $6c, $48cc
+ keeptextopen
+ setbit1 $0316
+ 2jump $42a9
+; 0xbc380
+
+UnknownScript_0xbc380: ; 0xbc380
+ checkbit1 $0716
+ iftrue .skip1
+ clearbit1 $0720
+.skip1
+ checkbit1 $0717
+ iftrue .skip2
+ clearbit1 $0721
+.skip2
+ checkbit1 $0718
+ iftrue .skip3
+ clearbit1 $0722
+.skip3
+ checkbit1 $0719
+ iftrue .skip4
+ clearbit1 $0723
+.skip4
+ checkbit1 $071a
+ iftrue .skip5
+ clearbit1 $0724
+.skip5
+ checkbit1 $071b
+ iftrue .skip6
+ clearbit1 $0725
+.skip6
+ checkbit1 $071c
+ iftrue .skip7
+ clearbit1 $0726
+.skip7
+ checkbit1 $071d
+ iftrue .skip8
+ clearbit1 $0727
+.skip8
+ checkbit1 $071e
+ iftrue .skip9
+ clearbit1 $0728
+.skip9
+ checkbit1 $071f
+ iftrue .skip10
+ clearbit1 $0729
+.skip10
+ end
+; 0xbc3db
+
+UnknownScript_0xbc3db: ; 0xbc3db
+ setbit1 $06cb
+ setbit1 $06ce
+ setbit1 $06cd
+ setbit1 $06d0
+ setbit1 $06f3
+ setbit1 $06e9
+ setbit1 $06f4
+ setbit1 $06d5
+ setbit1 $06de
+ setbit1 $06dd
+ setbit1 $06df
+ setbit1 $06c0
+ setbit1 $06e4
+ setbit1 $0025
+ setbit1 $06be
+ setbit1 $06bf
+ setbit1 $06c1
+ setbit1 $06f9
+ setbit1 $06fd
+ setbit1 $06ff
+ setbit1 $0700
+ setbit1 $0702
+ setbit1 $0703
+ setbit1 $0704
+ setbit1 $070d
+ setbit1 $070e
+ setbit1 $070f
+ setbit1 $0710
+ setbit1 $0715
+ setbit1 $0716
+ setbit1 $0717
+ setbit1 $0718
+ setbit1 $0719
+ setbit1 $071a
+ setbit1 $071b
+ setbit1 $071c
+ setbit1 $071d
+ setbit1 $071e
+ setbit1 $071f
+ setbit1 $0720
+ setbit1 $0721
+ setbit1 $0722
+ setbit1 $0723
+ setbit1 $0724
+ setbit1 $0725
+ setbit1 $0726
+ setbit1 $0727
+ setbit1 $0728
+ setbit1 $0729
+ setbit1 $072c
+ setbit1 $072f
+ setbit1 $072d
+ setbit1 $0735
+ setbit1 $0736
+ setbit1 $073c
+ setbit1 $073d
+ setbit1 $0741
+ setbit1 $0742
+ setbit1 $0743
+ setbit1 $0744
+ setbit1 $02a4
+ setbit1 $02af
+ setbit1 $0749
+ setbit1 $06d3
+ setbit1 $074d
+ setbit1 $0712
+ setbit1 $0713
+ setbit1 $0711
+ setbit1 $06d4
+ setbit1 $0304
+ setbit1 $0307
+ setbit1 $06d8
+ setbit1 $06c3
+ setbit1 $06c2
+ setbit1 $06c6
+ setbit1 $075f
+ setbit1 $0731
+ setbit1 $074a
+ setbit1 $0762
+ setbit1 $0738
+ setbit1 $073a
+ setbit1 $073b
+ setbit1 $0733
+ setbit1 $073f
+ setbit1 $078d
+ setbit1 $0766
+ setbit1 $0768
+ setbit1 $0769
+ setbit1 $076a
+ setbit1 $078e
+ setbit1 $078f
+ setbit1 $0790
+ setbit1 $0791
+ setbit1 $0793
+ setbit1 $07a4
+ setbit1 $07a4
+ setbit1 $07a5
+ setbit1 $06ec
+ setbit1 $06ed
+ setbit1 $06f0
+ setbit1 $07a9
+ setbit1 $07aa
+ setbit1 $06c8
+ setbit1 $07ac
+ setbit1 $07ad
+ setbit1 $07b5
+ setbit1 $07b6
+ setbit1 $07c5
+ setbit1 $07b7
+ setbit1 $07b0
+ setbit1 $07af
+ setbit1 $07ae
+ setbit1 $07cf
+ setbit2 $000e
+ setbit2 $0017
+ variablesprite $4, $52
+ variablesprite $5, $4
+ variablesprite $6, $35
+ variablesprite $7, $a
+ variablesprite $8, $a
+ variablesprite $9, $a
+ variablesprite $a, $a
+ variablesprite $b, $28
+ variablesprite $c, $28
+ setbit1 $00fb
+ setbit1 $076d
+ setbit1 $076c
+ setbit1 $076e
+ setbit1 $076f
+ setbit1 $0773
+ setbit1 $0776
+ setbit1 $0777
+ setbit1 $0779
+ setbit1 $0772
+ setbit1 $077b
+ setbit1 $0036
+ return
+; 0xbc574
+
+UnknownScript_0xbc574: ; 0xbc574
+ special $005d
+ checkcode $17
+ if_equal $5, UnknownScript_0xbc5c9
+ if_equal $7, UnknownScript_0xbc5ce
+ if_equal $b, UnknownScript_0xbc5d3
+ if_equal $d, UnknownScript_0xbc5d8
+ if_equal $f, UnknownScript_0xbc5dd
+ if_equal $10, UnknownScript_0xbc5e2
+ if_equal $11, UnknownScript_0xbc5e7
+ if_equal $13, UnknownScript_0xbc5ec
+ if_equal $14, UnknownScript_0xbc5f1
+ if_equal $16, UnknownScript_0xbc5f6
+ if_equal $17, UnknownScript_0xbc5fb
+ if_equal $18, UnknownScript_0xbc600
+ if_equal $1b, UnknownScript_0xbc605
+ if_equal $1c, UnknownScript_0xbc60a
+ if_equal $1d, UnknownScript_0xbc60f
+ if_equal $1e, UnknownScript_0xbc614
+ if_equal $20, UnknownScript_0xbc619
+ if_equal $21, UnknownScript_0xbc61e
+ if_equal $22, UnknownScript_0xbc623
+ if_equal $23, UnknownScript_0xbc628
+
+UnknownScript_0xbc5c9: ; bc5c9
+ 3writetext $6c, $49fe
+ end
+; 0xbc5ce
+
+UnknownScript_0xbc5ce: ; 0xbc5ce
+ 3writetext $6c, $4d9f
+ end
+; 0xbc5d3
+
+UnknownScript_0xbc5d3: ; 0xbc5d3
+ 3writetext $6c, $502e
+ end
+; 0xbc5d8
+
+UnknownScript_0xbc5d8: ; 0xbc5d8
+ 3writetext $6c, $542d
+ end
+; 0xbc5dd
+
+UnknownScript_0xbc5dd: ; 0xbc5dd
+ 3writetext $6c, $5800
+ end
+; 0xbc5e2
+
+UnknownScript_0xbc5e2: ; 0xbc5e2
+ 3writetext $6c, $5a71
+ end
+; 0xbc5e7
+
+UnknownScript_0xbc5e7: ; 0xbc5e7
+ 3writetext $6c, $5cd5
+ end
+; 0xbc5ec
+
+UnknownScript_0xbc5ec: ; 0xbc5ec
+ 3writetext $29, $4000
+ end
+; 0xbc5f1
+
+UnknownScript_0xbc5f1: ; 0xbc5f1
+ 3writetext $29, $41c0
+ end
+; 0xbc5f6
+
+UnknownScript_0xbc5f6: ; 0xbc5f6
+ 3writetext $29, $4642
+ end
+; 0xbc5fb
+
+UnknownScript_0xbc5fb: ; 0xbc5fb
+ 3writetext $29, $4829
+ end
+; 0xbc600
+
+UnknownScript_0xbc600: ; 0xbc600
+ 3writetext $29, $4a31
+ end
+; 0xbc605
+
+UnknownScript_0xbc605: ; 0xbc605
+ 3writetext $29, $4ed4
+ end
+; 0xbc60a
+
+UnknownScript_0xbc60a: ; 0xbc60a
+ 3writetext $29, $50d5
+ end
+; 0xbc60f
+
+UnknownScript_0xbc60f: ; 0xbc60f
+ 3writetext $29, $52e2
+ end
+; 0xbc614
+
+UnknownScript_0xbc614: ; 0xbc614
+ 3writetext $29, $5545
+ end
+; 0xbc619
+
+UnknownScript_0xbc619: ; 0xbc619
+ 3writetext $29, $5937
+ end
+; 0xbc61e
+
+UnknownScript_0xbc61e: ; 0xbc61e
+ 3writetext $29, $5bc4
+ end
+; 0xbc623
+
+UnknownScript_0xbc623: ; 0xbc623
+ 3writetext $29, $5dc6
+ end
+; 0xbc628
+
+UnknownScript_0xbc628: ; 0xbc628
+ 3writetext $29, $600c
+ end
+; 0xbc62d
+
+UnknownScript_0xbc62d: ; 0xbc62d
+ special $005d
+ checkcode $17
+ if_equal $5, UnknownScript_0xbc682
+ if_equal $7, UnknownScript_0xbc687
+ if_equal $b, UnknownScript_0xbc68c
+ if_equal $d, UnknownScript_0xbc691
+ if_equal $f, UnknownScript_0xbc696
+ if_equal $10, UnknownScript_0xbc69b
+ if_equal $11, UnknownScript_0xbc6a0
+ if_equal $13, UnknownScript_0xbc6a5
+ if_equal $14, UnknownScript_0xbc6aa
+ if_equal $16, UnknownScript_0xbc6af
+ if_equal $17, UnknownScript_0xbc6b4
+ if_equal $18, UnknownScript_0xbc6b9
+ if_equal $1b, UnknownScript_0xbc6be
+ if_equal $1c, UnknownScript_0xbc6c3
+ if_equal $1d, UnknownScript_0xbc6c8
+ if_equal $1e, UnknownScript_0xbc6cd
+ if_equal $20, UnknownScript_0xbc6d2
+ if_equal $21, UnknownScript_0xbc6d7
+ if_equal $22, UnknownScript_0xbc6dc
+ if_equal $23, UnknownScript_0xbc6e1
+
+UnknownScript_0xbc682: ; bc682
+ 3writetext $6c, $4a82
+ end
+; 0xbc687
+
+UnknownScript_0xbc687: ; 0xbc687
+ 3writetext $6c, $4e2c
+ end
+; 0xbc68c
+
+UnknownScript_0xbc68c: ; 0xbc68c
+ 3writetext $6c, $50d3
+ end
+; 0xbc691
+
+UnknownScript_0xbc691: ; 0xbc691
+ 3writetext $6c, $54e4
+ end
+; 0xbc696
+
+UnknownScript_0xbc696: ; 0xbc696
+ 3writetext $6c, $587b
+ end
+; 0xbc69b
+
+UnknownScript_0xbc69b: ; 0xbc69b
+ 3writetext $6c, $5b1d
+ end
+; 0xbc6a0
+
+UnknownScript_0xbc6a0: ; 0xbc6a0
+ 3writetext $6c, $5d85
+ end
+; 0xbc6a5
+
+UnknownScript_0xbc6a5: ; 0xbc6a5
+ 3writetext $29, $40a9
+ end
+; 0xbc6aa
+
+UnknownScript_0xbc6aa: ; 0xbc6aa
+ 3writetext $29, $426a
+ end
+; 0xbc6af
+
+UnknownScript_0xbc6af: ; 0xbc6af
+ 3writetext $29, $470b
+ end
+; 0xbc6b4
+
+UnknownScript_0xbc6b4: ; 0xbc6b4
+ 3writetext $29, $48fc
+ end
+; 0xbc6b9
+
+UnknownScript_0xbc6b9: ; 0xbc6b9
+ 3writetext $29, $4b03
+ end
+; 0xbc6be
+
+UnknownScript_0xbc6be: ; 0xbc6be
+ 3writetext $29, $4fc8
+ end
+; 0xbc6c3
+
+UnknownScript_0xbc6c3: ; 0xbc6c3
+ 3writetext $29, $5175
+ end
+; 0xbc6c8
+
+UnknownScript_0xbc6c8: ; 0xbc6c8
+ 3writetext $29, $5383
+ end
+; 0xbc6cd
+
+UnknownScript_0xbc6cd: ; 0xbc6cd
+ 3writetext $29, $5621
+ end
+; 0xbc6d2
+
+UnknownScript_0xbc6d2: ; 0xbc6d2
+ 3writetext $29, $59bc
+ end
+; 0xbc6d7
+
+UnknownScript_0xbc6d7: ; 0xbc6d7
+ 3writetext $29, $5c4b
+ end
+; 0xbc6dc
+
+UnknownScript_0xbc6dc: ; 0xbc6dc
+ 3writetext $29, $5e63
+ end
+; 0xbc6e1
+
+UnknownScript_0xbc6e1: ; 0xbc6e1
+ 3writetext $29, $6076
+ end
+; 0xbc6e6
+
+UnknownScript_0xbc6e6: ; 0xbc6e6
+ 3writetext $6c, $49c4
+ playsound $0093
+ waitbutton
+ keeptextopen
+ end
+; 0xbc6f0
+
+UnknownScript_0xbc6f0: ; 0xbc6f0
+ checkcode $17
+ if_equal $5, $4742
+ if_equal $7, UnknownScript_0xbc749
+ if_equal $b, UnknownScript_0xbc750
+ if_equal $d, UnknownScript_0xbc757
+ if_equal $f, UnknownScript_0xbc75e
+ if_equal $10, UnknownScript_0xbc765
+ if_equal $11, UnknownScript_0xbc76c
+ if_equal $13, UnknownScript_0xbc773
+ if_equal $14, UnknownScript_0xbc77a
+ if_equal $16, UnknownScript_0xbc781
+ if_equal $17, UnknownScript_0xbc788
+ if_equal $18, UnknownScript_0xbc78f
+ if_equal $1b, UnknownScript_0xbc796
+ if_equal $1c, UnknownScript_0xbc79d
+ if_equal $1d, UnknownScript_0xbc7a4
+ if_equal $1e, UnknownScript_0xbc7ab
+ if_equal $20, UnknownScript_0xbc7b2
+ if_equal $21, UnknownScript_0xbc7b9
+ if_equal $22, UnknownScript_0xbc7c0
+ if_equal $23, UnknownScript_0xbc7c7
+ 3writetext $6c, $4adb
+ closetext
+ loadmovesprites
+ end
+; 0xbc749
+
+UnknownScript_0xbc749: ; 0xbc749
+ 3writetext $6c, $4e89
+ closetext
+ loadmovesprites
+ end
+; 0xbc750
+
+UnknownScript_0xbc750: ; 0xbc750
+ 3writetext $6c, $5136
+ closetext
+ loadmovesprites
+ end
+; 0xbc757
+
+UnknownScript_0xbc757: ; 0xbc757
+ 3writetext $6c, $5553
+ closetext
+ loadmovesprites
+ end
+; 0xbc75e
+
+UnknownScript_0xbc75e: ; 0xbc75e
+ 3writetext $6c, $58d7
+ closetext
+ loadmovesprites
+ end
+; 0xbc765
+
+UnknownScript_0xbc765: ; 0xbc765
+ 3writetext $6c, $5b8e
+ closetext
+ loadmovesprites
+ end
+; 0xbc76c
+
+UnknownScript_0xbc76c: ; 0xbc76c
+ 3writetext $6c, $5db9
+ closetext
+ loadmovesprites
+ end
+; 0xbc773
+
+UnknownScript_0xbc773: ; 0xbc773
+ 3writetext $29, $40f8
+ closetext
+ loadmovesprites
+ end
+; 0xbc77a
+
+UnknownScript_0xbc77a: ; 0xbc77a
+ 3writetext $29, $42ab
+ closetext
+ loadmovesprites
+ end
+; 0xbc781
+
+UnknownScript_0xbc781: ; 0xbc781
+ 3writetext $29, $4730
+ closetext
+ loadmovesprites
+ end
+; 0xbc788
+
+UnknownScript_0xbc788: ; 0xbc788
+ 3writetext $29, $494d
+ closetext
+ loadmovesprites
+ end
+; 0xbc78f
+
+UnknownScript_0xbc78f: ; 0xbc78f
+ 3writetext $29, $4b47
+ closetext
+ loadmovesprites
+ end
+; 0xbc796
+
+UnknownScript_0xbc796: ; 0xbc796
+ 3writetext $29, $502e
+ closetext
+ loadmovesprites
+ end
+; 0xbc79d
+
+UnknownScript_0xbc79d: ; 0xbc79d
+ 3writetext $29, $51ac
+ closetext
+ loadmovesprites
+ end
+; 0xbc7a4
+
+UnknownScript_0xbc7a4: ; 0xbc7a4
+ 3writetext $29, $53de
+ closetext
+ loadmovesprites
+ end
+; 0xbc7ab
+
+UnknownScript_0xbc7ab: ; 0xbc7ab
+ 3writetext $29, $5666
+ closetext
+ loadmovesprites
+ end
+; 0xbc7b2
+
+UnknownScript_0xbc7b2: ; 0xbc7b2
+ 3writetext $29, $5a28
+ closetext
+ loadmovesprites
+ end
+; 0xbc7b9
+
+UnknownScript_0xbc7b9: ; 0xbc7b9
+ 3writetext $29, $5c8e
+ closetext
+ loadmovesprites
+ end
+; 0xbc7c0
+
+UnknownScript_0xbc7c0: ; 0xbc7c0
+ 3writetext $29, $5ea8
+ closetext
+ loadmovesprites
+ end
+; 0xbc7c7
+
+UnknownScript_0xbc7c7: ; 0xbc7c7
+ 3writetext $29, $60b5
+ closetext
+ loadmovesprites
+ end
+; 0xbc7ce
+
+UnknownScript_0xbc7ce: ; 0xbc7ce
+ checkcode $17
+ if_equal $5, $4820
+ if_equal $7, UnknownScript_0xbc827
+ if_equal $b, UnknownScript_0xbc82e
+ if_equal $d, UnknownScript_0xbc835
+ if_equal $f, UnknownScript_0xbc83c
+ if_equal $10, UnknownScript_0xbc843
+ if_equal $11, UnknownScript_0xbc84a
+ if_equal $13, UnknownScript_0xbc851
+ if_equal $14, UnknownScript_0xbc858
+ if_equal $16, UnknownScript_0xbc85f
+ if_equal $17, UnknownScript_0xbc866
+ if_equal $18, UnknownScript_0xbc86d
+ if_equal $1b, UnknownScript_0xbc874
+ if_equal $1c, UnknownScript_0xbc87b
+ if_equal $1d, UnknownScript_0xbc882
+ if_equal $1e, UnknownScript_0xbc889
+ if_equal $20, UnknownScript_0xbc890
+ if_equal $21, UnknownScript_0xbc897
+ if_equal $22, UnknownScript_0xbc89e
+ if_equal $23, UnknownScript_0xbc8a5
+ 3writetext $6c, $4afd
+ closetext
+ loadmovesprites
+ end
+; 0xbc827
+
+UnknownScript_0xbc827: ; 0xbc827
+ 3writetext $6c, $4ea2
+ closetext
+ loadmovesprites
+ end
+; 0xbc82e
+
+UnknownScript_0xbc82e: ; 0xbc82e
+ 3writetext $6c, $517b
+ closetext
+ loadmovesprites
+ end
+; 0xbc835
+
+UnknownScript_0xbc835: ; 0xbc835
+ 3writetext $6c, $5584
+ closetext
+ loadmovesprites
+ end
+; 0xbc83c
+
+UnknownScript_0xbc83c: ; 0xbc83c
+ 3writetext $6c, $5908
+ closetext
+ loadmovesprites
+ end
+; 0xbc843
+
+UnknownScript_0xbc843: ; 0xbc843
+ 3writetext $6c, $5bd2
+ closetext
+ loadmovesprites
+ end
+; 0xbc84a
+
+UnknownScript_0xbc84a: ; 0xbc84a
+ 3writetext $6c, $5df4
+ closetext
+ loadmovesprites
+ end
+; 0xbc851
+
+UnknownScript_0xbc851: ; 0xbc851
+ 3writetext $29, $4126
+ closetext
+ loadmovesprites
+ end
+; 0xbc858
+
+UnknownScript_0xbc858: ; 0xbc858
+ 3writetext $29, $42f2
+ closetext
+ loadmovesprites
+ end
+; 0xbc85f
+
+UnknownScript_0xbc85f: ; 0xbc85f
+ 3writetext $29, $4794
+ closetext
+ loadmovesprites
+ end
+; 0xbc866
+
+UnknownScript_0xbc866: ; 0xbc866
+ 3writetext $29, $498a
+ closetext
+ loadmovesprites
+ end
+; 0xbc86d
+
+UnknownScript_0xbc86d: ; 0xbc86d
+ 3writetext $29, $4b87
+ closetext
+ loadmovesprites
+ end
+; 0xbc874
+
+UnknownScript_0xbc874: ; 0xbc874
+ 3writetext $29, $505f
+ closetext
+ loadmovesprites
+ end
+; 0xbc87b
+
+UnknownScript_0xbc87b: ; 0xbc87b
+ 3writetext $29, $51ee
+ closetext
+ loadmovesprites
+ end
+; 0xbc882
+
+UnknownScript_0xbc882: ; 0xbc882
+ 3writetext $29, $5412
+ closetext
+ loadmovesprites
+ end
+; 0xbc889
+
+UnknownScript_0xbc889: ; 0xbc889
+ 3writetext $29, $56b6
+ closetext
+ loadmovesprites
+ end
+; 0xbc890
+
+UnknownScript_0xbc890: ; 0xbc890
+ 3writetext $29, $5a5a
+ closetext
+ loadmovesprites
+ end
+; 0xbc897
+
+UnknownScript_0xbc897: ; 0xbc897
+ 3writetext $29, $5cc5
+ closetext
+ loadmovesprites
+ end
+; 0xbc89e
+
+UnknownScript_0xbc89e: ; 0xbc89e
+ 3writetext $29, $5ed6
+ closetext
+ loadmovesprites
+ end
+; 0xbc8a5
+
+UnknownScript_0xbc8a5: ; 0xbc8a5
+ 3writetext $29, $60e2
+ closetext
+ loadmovesprites
+ end
+; 0xbc8ac
+
+UnknownScript_0xbc8ac: ; 0xbc8ac
+ checkcode $17
+ if_equal $5, $48fe
+ if_equal $7, UnknownScript_0xbc905
+ if_equal $b, UnknownScript_0xbc90c
+ if_equal $d, UnknownScript_0xbc913
+ if_equal $f, UnknownScript_0xbc91a
+ if_equal $10, UnknownScript_0xbc921
+ if_equal $11, UnknownScript_0xbc928
+ if_equal $13, UnknownScript_0xbc92f
+ if_equal $14, UnknownScript_0xbc936
+ if_equal $16, UnknownScript_0xbc93d
+ if_equal $17, UnknownScript_0xbc944
+ if_equal $18, UnknownScript_0xbc94b
+ if_equal $1b, UnknownScript_0xbc952
+ if_equal $1c, UnknownScript_0xbc959
+ if_equal $1d, UnknownScript_0xbc960
+ if_equal $1e, UnknownScript_0xbc967
+ if_equal $20, UnknownScript_0xbc96e
+ if_equal $21, UnknownScript_0xbc975
+ if_equal $22, UnknownScript_0xbc97c
+ if_equal $23, UnknownScript_0xbc983
+ 3writetext $6c, $4b42
+ closetext
+ loadmovesprites
+ end
+; 0xbc905
+
+UnknownScript_0xbc905: ; 0xbc905
+ 3writetext $6c, $4ebc
+ closetext
+ loadmovesprites
+ end
+; 0xbc90c
+
+UnknownScript_0xbc90c: ; 0xbc90c
+ 3writetext $6c, $51c4
+ closetext
+ loadmovesprites
+ end
+; 0xbc913
+
+UnknownScript_0xbc913: ; 0xbc913
+ 3writetext $6c, $55b6
+ closetext
+ loadmovesprites
+ end
+; 0xbc91a
+
+UnknownScript_0xbc91a: ; 0xbc91a
+ 3writetext $6c, $5936
+ closetext
+ loadmovesprites
+ end
+; 0xbc921
+
+UnknownScript_0xbc921: ; 0xbc921
+ 3writetext $6c, $5c06
+ closetext
+ loadmovesprites
+ end
+; 0xbc928
+
+UnknownScript_0xbc928: ; 0xbc928
+ 3writetext $6c, $5e50
+ closetext
+ loadmovesprites
+ end
+; 0xbc92f
+
+UnknownScript_0xbc92f: ; 0xbc92f
+ 3writetext $29, $4158
+ closetext
+ loadmovesprites
+ end
+; 0xbc936
+
+UnknownScript_0xbc936: ; 0xbc936
+ 3writetext $29, $434a
+ closetext
+ loadmovesprites
+ end
+; 0xbc93d
+
+UnknownScript_0xbc93d: ; 0xbc93d
+ 3writetext $29, $47eb
+ closetext
+ loadmovesprites
+ end
+; 0xbc944
+
+UnknownScript_0xbc944: ; 0xbc944
+ 3writetext $29, $49bd
+ closetext
+ loadmovesprites
+ end
+; 0xbc94b
+
+UnknownScript_0xbc94b: ; 0xbc94b
+ 3writetext $29, $4bcd
+ closetext
+ loadmovesprites
+ end
+; 0xbc952
+
+UnknownScript_0xbc952: ; 0xbc952
+ 3writetext $29, $508c
+ closetext
+ loadmovesprites
+ end
+; 0xbc959
+
+UnknownScript_0xbc959: ; 0xbc959
+ 3writetext $29, $5216
+ closetext
+ loadmovesprites
+ end
+; 0xbc960
+
+UnknownScript_0xbc960: ; 0xbc960
+ 3writetext $29, $5446
+ closetext
+ loadmovesprites
+ end
+; 0xbc967
+
+UnknownScript_0xbc967: ; 0xbc967
+ 3writetext $29, $56e2
+ closetext
+ loadmovesprites
+ end
+; 0xbc96e
+
+UnknownScript_0xbc96e: ; 0xbc96e
+ 3writetext $29, $5aa6
+ closetext
+ loadmovesprites
+ end
+; 0xbc975
+
+UnknownScript_0xbc975: ; 0xbc975
+ 3writetext $29, $5cfa
+ closetext
+ loadmovesprites
+ end
+; 0xbc97c
+
+UnknownScript_0xbc97c: ; 0xbc97c
+ 3writetext $29, $5f06
+ closetext
+ loadmovesprites
+ end
+; 0xbc983
+
+UnknownScript_0xbc983: ; 0xbc983
+ 3writetext $29, $6144
+ closetext
+ loadmovesprites
+ end
+; 0xbc98a
+
+UnknownScript_0xbc98a: ; 0xbc98a
+ checkcode $17
+ if_equal $5, $49d0
+ if_equal $7, UnknownScript_0xbc9d7
+ if_equal $b, UnknownScript_0xbc9de
+ if_equal $d, UnknownScript_0xbc9e5
+ if_equal $f, UnknownScript_0xbc9ec
+ if_equal $10, UnknownScript_0xbc9f3
+ if_equal $11, UnknownScript_0xbc9fa
+ if_equal $13, UnknownScript_0xbca01
+ if_equal $14, UnknownScript_0xbca08
+ if_equal $17, UnknownScript_0xbca0f
+ if_equal $18, UnknownScript_0xbca16
+ if_equal $1b, UnknownScript_0xbca1d
+ if_equal $1d, UnknownScript_0xbca24
+ if_equal $1e, UnknownScript_0xbca2b
+ if_equal $20, UnknownScript_0xbca32
+ if_equal $21, UnknownScript_0xbca39
+ if_equal $23, UnknownScript_0xbca40
+ 3writetext $6c, $4b75
+ closetext
+ loadmovesprites
+ end
+; 0xbc9d7
+
+UnknownScript_0xbc9d7: ; 0xbc9d7
+ 3writetext $6c, $4edc
+ closetext
+ loadmovesprites
+ end
+; 0xbc9de
+
+UnknownScript_0xbc9de: ; 0xbc9de
+ 3writetext $6c, $51fe
+ closetext
+ loadmovesprites
+ end
+; 0xbc9e5
+
+UnknownScript_0xbc9e5: ; 0xbc9e5
+ 3writetext $6c, $55d5
+ closetext
+ loadmovesprites
+ end
+; 0xbc9ec
+
+UnknownScript_0xbc9ec: ; 0xbc9ec
+ 3writetext $6c, $5954
+ closetext
+ loadmovesprites
+ end
+; 0xbc9f3
+
+UnknownScript_0xbc9f3: ; 0xbc9f3
+ 3writetext $6c, $5c32
+ closetext
+ loadmovesprites
+ end
+; 0xbc9fa
+
+UnknownScript_0xbc9fa: ; 0xbc9fa
+ 3writetext $6c, $5e98
+ closetext
+ loadmovesprites
+ end
+; 0xbca01
+
+UnknownScript_0xbca01: ; 0xbca01
+ 3writetext $29, $418d
+ closetext
+ loadmovesprites
+ end
+; 0xbca08
+
+UnknownScript_0xbca08: ; 0xbca08
+ 3writetext $29, $4382
+ closetext
+ loadmovesprites
+ end
+; 0xbca0f
+
+UnknownScript_0xbca0f: ; 0xbca0f
+ 3writetext $29, $49fc
+ closetext
+ loadmovesprites
+ end
+; 0xbca16
+
+UnknownScript_0xbca16: ; 0xbca16
+ 3writetext $29, $4bec
+ closetext
+ loadmovesprites
+ end
+; 0xbca1d
+
+UnknownScript_0xbca1d: ; 0xbca1d
+ 3writetext $29, $50b1
+ closetext
+ loadmovesprites
+ end
+; 0xbca24
+
+UnknownScript_0xbca24: ; 0xbca24
+ 3writetext $29, $548c
+ closetext
+ loadmovesprites
+ end
+; 0xbca2b
+
+UnknownScript_0xbca2b: ; 0xbca2b
+ 3writetext $29, $571e
+ closetext
+ loadmovesprites
+ end
+; 0xbca32
+
+UnknownScript_0xbca32: ; 0xbca32
+ 3writetext $29, $5ada
+ closetext
+ loadmovesprites
+ end
+; 0xbca39
+
+UnknownScript_0xbca39: ; 0xbca39
+ 3writetext $29, $5d1d
+ closetext
+ loadmovesprites
+ end
+; 0xbca40
+
+UnknownScript_0xbca40: ; 0xbca40
+ 3writetext $29, $6175
+ closetext
+ loadmovesprites
+ end
+; 0xbca47
+
+UnknownScript_0xbca47: ; 0xbca47
+ checkcode $17
+ if_equal $d, $4a65
+ if_equal $10, UnknownScript_0xbca6b
+ if_equal $18, UnknownScript_0xbca71
+ if_equal $1c, UnknownScript_0xbca77
+ if_equal $1d, UnknownScript_0xbca7d
+ if_equal $21, UnknownScript_0xbca83
+ if_equal $22, UnknownScript_0xbca89
+ 3writetext $6c, $5607
+ keeptextopen
+ end
+; 0xbca6b
+
+UnknownScript_0xbca6b: ; 0xbca6b
+ 3writetext $6c, $5c57
+ keeptextopen
+ end
+; 0xbca71
+
+UnknownScript_0xbca71: ; 0xbca71
+ 3writetext $29, $4c24
+ keeptextopen
+ end
+; 0xbca77
+
+UnknownScript_0xbca77: ; 0xbca77
+ 3writetext $29, $523a
+ keeptextopen
+ end
+; 0xbca7d
+
+UnknownScript_0xbca7d: ; 0xbca7d
+ 3writetext $29, $54e3
+ keeptextopen
+ end
+; 0xbca83
+
+UnknownScript_0xbca83: ; 0xbca83
+ 3writetext $29, $5d4d
+ keeptextopen
+ end
+; 0xbca89
+
+UnknownScript_0xbca89: ; 0xbca89
+ 3writetext $29, $5f37
+ keeptextopen
+ end
+; 0xbca8f
+
+UnknownScript_0xbca8f: ; 0xbca8f
+ checkcode $17
+ if_equal $7, $4abd
+ if_equal $d, UnknownScript_0xbcac4
+ if_equal $f, UnknownScript_0xbcacb
+ if_equal $10, UnknownScript_0xbcad2
+ if_equal $18, UnknownScript_0xbcad9
+ if_equal $1c, UnknownScript_0xbcae0
+ if_equal $1d, UnknownScript_0xbcae7
+ if_equal $20, UnknownScript_0xbcaee
+ if_equal $21, UnknownScript_0xbcaf5
+ if_equal $22, UnknownScript_0xbcafc
+ if_equal $23, UnknownScript_0xbcb03
+ 3writetext $6c, $4eff
+ closetext
+ loadmovesprites
+ end
+; 0xbcac4
+
+UnknownScript_0xbcac4: ; 0xbcac4
+ 3writetext $6c, $564d
+ closetext
+ loadmovesprites
+ end
+; 0xbcacb
+
+UnknownScript_0xbcacb: ; 0xbcacb
+ 3writetext $6c, $5978
+ closetext
+ loadmovesprites
+ end
+; 0xbcad2
+
+UnknownScript_0xbcad2: ; 0xbcad2
+ 3writetext $6c, $5c91
+ closetext
+ loadmovesprites
+ end
+; 0xbcad9
+
+UnknownScript_0xbcad9: ; 0xbcad9
+ 3writetext $29, $4c47
+ closetext
+ loadmovesprites
+ end
+; 0xbcae0
+
+UnknownScript_0xbcae0: ; 0xbcae0
+ 3writetext $29, $52a0
+ closetext
+ loadmovesprites
+ end
+; 0xbcae7
+
+UnknownScript_0xbcae7: ; 0xbcae7
+ 3writetext $29, $5513
+ closetext
+ loadmovesprites
+ end
+; 0xbcaee
+
+UnknownScript_0xbcaee: ; 0xbcaee
+ 3writetext $29, $5aff
+ closetext
+ loadmovesprites
+ end
+; 0xbcaf5
+
+UnknownScript_0xbcaf5: ; 0xbcaf5
+ 3writetext $29, $5d9a
+ closetext
+ loadmovesprites
+ end
+; 0xbcafc
+
+UnknownScript_0xbcafc: ; 0xbcafc
+ 3writetext $29, $5faa
+ closetext
+ loadmovesprites
+ end
+; 0xbcb03
+
+UnknownScript_0xbcb03: ; 0xbcb03
+ 3writetext $29, $61c9
+ closetext
+ loadmovesprites
+ end
+; 0xbcb0a
+
+UnknownScript_0xbcb0a: ; 0xbcb0a
+ loadfont
+ checkcode $17
+ if_equal $7, $4b1d
+ if_equal $f, UnknownScript_0xbcb23
+ if_equal $20, UnknownScript_0xbcb29
+ if_equal $23, UnknownScript_0xbcb2f
+ 3writetext $6c, $4f2f
+ keeptextopen
+ end
+; 0xbcb23
+
+UnknownScript_0xbcb23: ; 0xbcb23
+ 3writetext $6c, $59be
+ keeptextopen
+ end
+; 0xbcb29
+
+UnknownScript_0xbcb29: ; 0xbcb29
+ 3writetext $29, $5b3f
+ keeptextopen
+ end
+; 0xbcb2f
+
+UnknownScript_0xbcb2f: ; 0xbcb2f
+ 3writetext $29, $6200
+ keeptextopen
+ end
+; 0xbcb35
+
+UnknownScript_0xbcb35: ; 0xbcb35
+ checkcode $17
+ if_equal $6, $4b57
+ if_equal $c, UnknownScript_0xbcb5c
+ if_equal $e, UnknownScript_0xbcb61
+ if_equal $12, UnknownScript_0xbcb66
+ if_equal $15, UnknownScript_0xbcb6b
+ if_equal $1a, UnknownScript_0xbcb70
+ if_equal $1f, UnknownScript_0xbcb75
+ if_equal $24, UnknownScript_0xbcb7a
+ 3writetext $6c, $4bb6
+ end
+; 0xbcb5c
+
+UnknownScript_0xbcb5c: ; 0xbcb5c
+ 3writetext $6c, $5239
+ end
+; 0xbcb61
+
+UnknownScript_0xbcb61: ; 0xbcb61
+ 3writetext $6c, $5690
+ end
+; 0xbcb66
+
+UnknownScript_0xbcb66: ; 0xbcb66
+ 3writetext $6c, $5ebe
+ end
+; 0xbcb6b
+
+UnknownScript_0xbcb6b: ; 0xbcb6b
+ 3writetext $29, $4405
+ end
+; 0xbcb70
+
+UnknownScript_0xbcb70: ; 0xbcb70
+ 3writetext $29, $4c8c
+ end
+; 0xbcb75
+
+UnknownScript_0xbcb75: ; 0xbcb75
+ 3writetext $29, $574a
+ end
+; 0xbcb7a
+
+UnknownScript_0xbcb7a: ; 0xbcb7a
+ 3writetext $29, $6295
+ end
+; 0xbcb7f
+
+UnknownScript_0xbcb7f: ; 0xbcb7f
+ checkcode $17
+ if_equal $6, $4ba1
+ if_equal $c, UnknownScript_0xbcba6
+ if_equal $e, UnknownScript_0xbcbab
+ if_equal $12, UnknownScript_0xbcbb0
+ if_equal $15, UnknownScript_0xbcbb5
+ if_equal $1a, UnknownScript_0xbcbba
+ if_equal $1f, UnknownScript_0xbcbbf
+ if_equal $24, UnknownScript_0xbcbc4
+ 3writetext $6c, $4c37
+ end
+; 0xbcba6
+
+UnknownScript_0xbcba6: ; 0xbcba6
+ 3writetext $6c, $5314
+ end
+; 0xbcbab
+
+UnknownScript_0xbcbab: ; 0xbcbab
+ 3writetext $6c, $5710
+ end
+; 0xbcbb0
+
+UnknownScript_0xbcbb0: ; 0xbcbb0
+ 3writetext $6c, $5f4e
+ end
+; 0xbcbb5
+
+UnknownScript_0xbcbb5: ; 0xbcbb5
+ 3writetext $29, $44db
+ end
+; 0xbcbba
+
+UnknownScript_0xbcbba: ; 0xbcbba
+ 3writetext $29, $4d36
+ end
+; 0xbcbbf
+
+UnknownScript_0xbcbbf: ; 0xbcbbf
+ 3writetext $29, $57e3
+ end
+; 0xbcbc4
+
+UnknownScript_0xbcbc4: ; 0xbcbc4
+ 3writetext $29, $6316
+ end
+; 0xbcbc9
+
+UnknownScript_0xbcbc9: ; 0xbcbc9
+ 3writetext $6c, $49e1
+ playsound $0093
+ waitbutton
+ keeptextopen
+ end
+; 0xbcbd3
+
+UnknownScript_0xbcbd3: ; 0xbcbd3
+ checkcode $17
+ if_equal $6, $4bf5
+ if_equal $c, UnknownScript_0xbcbfc
+ if_equal $e, UnknownScript_0xbcc03
+ if_equal $12, UnknownScript_0xbcc0a
+ if_equal $15, UnknownScript_0xbcc11
+ if_equal $1a, UnknownScript_0xbcc18
+ if_equal $1f, UnknownScript_0xbcc1f
+ if_equal $24, UnknownScript_0xbcc26
+ 3writetext $6c, $4c9b
+ closetext
+ loadmovesprites
+ end
+; 0xbcbfc
+
+UnknownScript_0xbcbfc: ; 0xbcbfc
+ 3writetext $6c, $5392
+ closetext
+ loadmovesprites
+ end
+; 0xbcc03
+
+UnknownScript_0xbcc03: ; 0xbcc03
+ 3writetext $6c, $5755
+ closetext
+ loadmovesprites
+ end
+; 0xbcc0a
+
+UnknownScript_0xbcc0a: ; 0xbcc0a
+ 3writetext $6c, $5faa
+ closetext
+ loadmovesprites
+ end
+; 0xbcc11
+
+UnknownScript_0xbcc11: ; 0xbcc11
+ 3writetext $29, $451d
+ closetext
+ loadmovesprites
+ end
+; 0xbcc18
+
+UnknownScript_0xbcc18: ; 0xbcc18
+ 3writetext $29, $4d72
+ closetext
+ loadmovesprites
+ end
+; 0xbcc1f
+
+UnknownScript_0xbcc1f: ; 0xbcc1f
+ 3writetext $29, $5820
+ closetext
+ loadmovesprites
+ end
+; 0xbcc26
+
+UnknownScript_0xbcc26: ; 0xbcc26
+ 3writetext $29, $6359
+ closetext
+ loadmovesprites
+ end
+; 0xbcc2d
+
+UnknownScript_0xbcc2d: ; 0xbcc2d
+ checkcode $17
+ if_equal $6, $4c4f
+ if_equal $c, UnknownScript_0xbcc56
+ if_equal $e, UnknownScript_0xbcc5d
+ if_equal $12, UnknownScript_0xbcc64
+ if_equal $15, UnknownScript_0xbcc6b
+ if_equal $1a, UnknownScript_0xbcc72
+ if_equal $1f, UnknownScript_0xbcc79
+ if_equal $24, UnknownScript_0xbcc80
+ 3writetext $6c, $4ce0
+ closetext
+ loadmovesprites
+ end
+; 0xbcc56
+
+UnknownScript_0xbcc56: ; 0xbcc56
+ 3writetext $6c, $53af
+ closetext
+ loadmovesprites
+ end
+; 0xbcc5d
+
+UnknownScript_0xbcc5d: ; 0xbcc5d
+ 3writetext $6c, $578a
+ closetext
+ loadmovesprites
+ end
+; 0xbcc64
+
+UnknownScript_0xbcc64: ; 0xbcc64
+ 3writetext $6c, $5fdd
+ closetext
+ loadmovesprites
+ end
+; 0xbcc6b
+
+UnknownScript_0xbcc6b: ; 0xbcc6b
+ 3writetext $29, $4542
+ closetext
+ loadmovesprites
+ end
+; 0xbcc72
+
+UnknownScript_0xbcc72: ; 0xbcc72
+ 3writetext $29, $4dcd
+ closetext
+ loadmovesprites
+ end
+; 0xbcc79
+
+UnknownScript_0xbcc79: ; 0xbcc79
+ 3writetext $29, $5842
+ closetext
+ loadmovesprites
+ end
+; 0xbcc80
+
+UnknownScript_0xbcc80: ; 0xbcc80
+ 3writetext $29, $638c
+ closetext
+ loadmovesprites
+ end
+; 0xbcc87
+
+UnknownScript_0xbcc87: ; 0xbcc87
+ checkcode $17
+ if_equal $6, $4ca9
+ if_equal $c, UnknownScript_0xbccb0
+ if_equal $e, UnknownScript_0xbccb7
+ if_equal $12, UnknownScript_0xbccbe
+ if_equal $15, UnknownScript_0xbccc5
+ if_equal $1a, UnknownScript_0xbcccc
+ if_equal $1f, UnknownScript_0xbccd3
+ if_equal $24, UnknownScript_0xbccda
+ 3writetext $6c, $4d0b
+ closetext
+ loadmovesprites
+ end
+; 0xbccb0
+
+UnknownScript_0xbccb0: ; 0xbccb0
+ 3writetext $6c, $53e4
+ closetext
+ loadmovesprites
+ end
+; 0xbccb7
+
+UnknownScript_0xbccb7: ; 0xbccb7
+ 3writetext $6c, $57ba
+ closetext
+ loadmovesprites
+ end
+; 0xbccbe
+
+UnknownScript_0xbccbe: ; 0xbccbe
+ 3writetext $6c, $5ffa
+ closetext
+ loadmovesprites
+ end
+; 0xbccc5
+
+UnknownScript_0xbccc5: ; 0xbccc5
+ 3writetext $29, $4573
+ closetext
+ loadmovesprites
+ end
+; 0xbcccc
+
+UnknownScript_0xbcccc: ; 0xbcccc
+ 3writetext $29, $4e01
+ closetext
+ loadmovesprites
+ end
+; 0xbccd3
+
+UnknownScript_0xbccd3: ; 0xbccd3
+ 3writetext $29, $5881
+ closetext
+ loadmovesprites
+ end
+; 0xbccda
+
+UnknownScript_0xbccda: ; 0xbccda
+ 3writetext $29, $63cc
+ closetext
+ loadmovesprites
+ end
+; 0xbcce1
+
+UnknownScript_0xbcce1: ; 0xbcce1
+ checkcode $17
+ if_equal $c, $4cff
+ if_equal $e, UnknownScript_0xbcd06
+ if_equal $12, UnknownScript_0xbcd0d
+ if_equal $15, UnknownScript_0xbcd14
+ if_equal $1a, UnknownScript_0xbcd1b
+ if_equal $1f, UnknownScript_0xbcd22
+ if_equal $24, UnknownScript_0xbcd29
+ 3writetext $6c, $5409
+ closetext
+ loadmovesprites
+ end
+; 0xbcd06
+
+UnknownScript_0xbcd06: ; 0xbcd06
+ 3writetext $6c, $57de
+ closetext
+ loadmovesprites
+ end
+; 0xbcd0d
+
+UnknownScript_0xbcd0d: ; 0xbcd0d
+ 3writetext $6c, $601f
+ closetext
+ loadmovesprites
+ end
+; 0xbcd14
+
+UnknownScript_0xbcd14: ; 0xbcd14
+ 3writetext $29, $4595
+ closetext
+ loadmovesprites
+ end
+; 0xbcd1b
+
+UnknownScript_0xbcd1b: ; 0xbcd1b
+ 3writetext $29, $4e21
+ closetext
+ loadmovesprites
+ end
+; 0xbcd22
+
+UnknownScript_0xbcd22: ; 0xbcd22
+ 3writetext $29, $58a3
+ closetext
+ loadmovesprites
+ end
+; 0xbcd29
+
+UnknownScript_0xbcd29: ; 0xbcd29
+ 3writetext $29, $63f1
+ closetext
+ loadmovesprites
+ end
+; 0xbcd30
+
+UnknownScript_0xbcd30: ; 0xbcd30
+ checkcode $17
+ if_equal $6, $4d42
+ if_equal $15, UnknownScript_0xbcd48
+ if_equal $1a, UnknownScript_0xbcd4e
+ if_equal $1f, UnknownScript_0xbcd54
+ 3writetext $6c, $4d2c
+ keeptextopen
+ end
+; 0xbcd48
+
+UnknownScript_0xbcd48: ; 0xbcd48
+ 3writetext $29, $45c9
+ keeptextopen
+ end
+; 0xbcd4e
+
+UnknownScript_0xbcd4e: ; 0xbcd4e
+ 3writetext $29, $4e4c
+ keeptextopen
+ end
+; 0xbcd54
+
+UnknownScript_0xbcd54: ; 0xbcd54
+ 3writetext $29, $58d5
+ keeptextopen
+ end
+; 0xbcd5a
+
+UnknownScript_0xbcd5a: ; 0xbcd5a
+ checkcode $17
+ if_equal $6, $4d70
+ if_equal $15, UnknownScript_0xbcd77
+ if_equal $1a, UnknownScript_0xbcd7e
+ if_equal $1f, UnknownScript_0xbcd85
+ if_equal $24, UnknownScript_0xbcd8c
+ 3writetext $6c, $4d69
+ closetext
+ loadmovesprites
+ end
+; 0xbcd77
+
+UnknownScript_0xbcd77: ; 0xbcd77
+ 3writetext $29, $4603
+ closetext
+ loadmovesprites
+ end
+; 0xbcd7e
+
+UnknownScript_0xbcd7e: ; 0xbcd7e
+ 3writetext $29, $4e8f
+ closetext
+ loadmovesprites
+ end
+; 0xbcd85
+
+UnknownScript_0xbcd85: ; 0xbcd85
+ 3writetext $29, $5914
+ closetext
+ loadmovesprites
+ end
+; 0xbcd8c
+
+UnknownScript_0xbcd8c: ; 0xbcd8c
+ 3writetext $29, $6411
+ closetext
+ loadmovesprites
+ end
+; 0xbcd93
+
+UnknownScript_0xbcd93: ; 0xbcd93
+ checkcode $17
+ if_equal $24, $4d99
+ loadfont
+ 3writetext $29, $6454
+ keeptextopen
+ end
+; 0xbcda0
+
+UnknownScript_0xbcda0: ; 0xbcda0
+ mapnametotext $0
+ loadfont
+ 3writetext $6c, $474e
+ closetext
+ loadmovesprites
+ end
+; 0xbcdaa
+
+UnknownScript_0xbcdaa: ; 0xbcdaa
+ mapnametotext $0
+ loadfont
+ 3writetext $6c, $474e
+ keeptextopen
+ 3writetext $6c, $475c
+ closetext
+ loadmovesprites
+ end
+; 0xbcdb9
+
+UnknownScript_0xbcdb9: ; 0xbcdb9
+ waitbutton
+ 3writetext $6c, $4648
+ playsound $0001
+ waitbutton
+ end
+; 0xbcdc3
+
+UnknownScript_0xbcdc3: ; 0xbcdc3
+ waitbutton
+ 3writetext $6c, $4648
+ playsound $0096
+ waitbutton
+ end
+; 0xbcdcd
+
+UnknownScript_0xbcdcd: ; 0xbcdcd
+ faceplayer
+ loadfont
+ 3writetext $6c, $477f
+ keeptextopen
+ checkitem COIN_CASE
+ iftrue UnknownScript_0xbcde0
+ 3writetext $6c, $479c
+ closetext
+ loadmovesprites
+ end
+; 0xbcde0
+
+UnknownScript_0xbcde0: ; 0xbcde0
+ 3writetext $6c, $47e3
+ special $0050
+ loadmenudata MenuDataHeader_0xbce54
+ interpretmenu2
+ writebackup
+ if_equal $1, UnknownScript_0xbcdf7
+ if_equal $2, UnknownScript_0xbce1b
+ 2jump UnknownScript_0xbce4d
+; 0xbcdf7
+
+UnknownScript_0xbcdf7: ; 0xbcdf7
+ checkcoins 9949
+ if_equal $0, UnknownScript_0xbce46
+ checkmoney $0, 1000
+ if_equal $2, UnknownScript_0xbce3f
+ givecoins 50
+ takemoney $0, 1000
+ waitbutton
+ playsound $0022
+ 3writetext $6c, $4830
+ closetext
+ 2jump $4de4
+; 0xbce1b
+
+UnknownScript_0xbce1b: ; 0xbce1b
+ checkcoins 9499
+ if_equal $0, UnknownScript_0xbce46
+ checkmoney $0, 10000
+ if_equal $2, UnknownScript_0xbce3f
+ givecoins 500
+ takemoney $0, 10000
+ waitbutton
+ playsound $0022
+ 3writetext $6c, $484f
+ closetext
+ 2jump $4de4
+; 0xbce3f
+
+UnknownScript_0xbce3f: ; 0xbce3f
+ 3writetext $6c, $486f
+ closetext
+ loadmovesprites
+ end
+; 0xbce46
+
+UnknownScript_0xbce46: ; 0xbce46
+ 3writetext $6c, $488c
+ closetext
+ loadmovesprites
+ end
+; 0xbce4d
+
+UnknownScript_0xbce4d: ; 0xbce4d
+ 3writetext $6c, $48ad
+ closetext
+ loadmovesprites
+ end
+; 0xbce54
+
+
+MenuDataHeader_0xbce54: ; 0xbce54
+ db $40 ; flags
+ db 04, 00 ; start coords
+ db 11, 15 ; end coords
+ dw MenuData2_0xbce5c
+ db 1 ; default option
+; 0xbce5c
+
+MenuData2_0xbce5c: ; 0xbce5c
+ db $80 ; flags
+ db 3 ; items
+ db " 50 : ¥1000@"
+ db "500 : ¥10000@"
+ db "CANCEL@"
+; 0xbce7f
+
+
+UnknownScript_0xbce7f: ; 0xbce7f
+ faceplayer
+ loadfont
+ special $0059
+ if_greater_than $32, UnknownScript_0xbce9a
+ if_greater_than $96, UnknownScript_0xbce93
+ 3writetext $6c, $492a
+ closetext
+ loadmovesprites
+ end
+; 0xbce93
+
+UnknownScript_0xbce93: ; 0xbce93
+ 3writetext $6c, $4954
+ closetext
+ loadmovesprites
+ end
+; 0xbce9a
+
+UnknownScript_0xbce9a: ; 0xbce9a
+ 3writetext $6c, $4989
+ closetext
+ loadmovesprites
+ end
+; 0xbcea1
+
+MovementData_0xbcea1: ; bcea1
+ step_right
+ step_down
+ turn_head_up
+ step_end
+; bcea5
+
+UnusedPhoneScript: ; 0xbcea5
+ 3writetext BANK(UnusedPhoneText), UnusedPhoneText
+ end
+
+MomPhoneScript: ; 0xbceaa
+ checkbit1 $0040
+ iftrue .bcec5
+ checkbit1 $0041 ; if dude talked to you, then you left home without talking to mom
+ iftrue MomPhoneLectureScript
+ checkbit1 $001f
+ iftrue MomPhoneNoGymQuestScript
+ checkbit1 $001a
+ iftrue MomPhoneNoPokedexScript
+ 2jump MomPhoneNoPokemonScript
+
+.bcec5 ; 0xbcec5
+ checkbit1 $0007
+ iftrue MomPhoneHangUpScript
+ 3writetext BANK(MomPhoneGreetingText), MomPhoneGreetingText
+ keeptextopen
+ mapnametotext $0
+ checkcode $f
+ if_equal $1, UnknownScript_0xbcee7
+ if_equal $2, $4f27
+ 2jump UnknownScript_0xbcf2f
+
+UnknownScript_0xbcedf: ; 0xbcedf
+ 3writetext $6d, $4021
+ keeptextopen
+ 2jump UnknownScript_0xbcf37
+
+UnknownScript_0xbcee7: ; 0xbcee7
+ checkcode $c
+ if_equal GROUP_NEW_BARK_TOWN, .newbark
+ if_equal GROUP_CHERRYGROVE_CITY, .cherrygrove
+ if_equal GROUP_VIOLET_CITY, .violet
+ if_equal GROUP_AZALEA_TOWN, .azalea
+ if_equal GROUP_GOLDENROD_CITY, .goldenrod
+ 3writetext BANK(MomPhoneGenericAreaText), MomPhoneGenericAreaText
+ keeptextopen
+ 2jump UnknownScript_0xbcf37
+
+.newbark ; 0xbcf05
+ 3writetext BANK(MomPhoneNewBarkText), MomPhoneNewBarkText
+ keeptextopen
+ 2jump UnknownScript_0xbcf37
+
+.cherrygrove ; 0xbcf0d
+ 3writetext BANK(MomPhoneCherrygroveText), MomPhoneCherrygroveText
+ keeptextopen
+ 2jump UnknownScript_0xbcf37
+
+.violet ; 0xbcf15
+ displaylocation $7 ; sprout tower
+ 3call $3, UnknownScript_0xbcedf
+.azalea ; 0xbcf1b
+ displaylocation $d ; slowpoke well
+ 3call $3, UnknownScript_0xbcedf
+.goldenrod ; 0xbcf21
+ displaylocation $11 ; radio tower
+ 3call $3, UnknownScript_0xbcedf
+ 3writetext $6d, $411c
+ keeptextopen
+ 2jump UnknownScript_0xbcf37
+
+UnknownScript_0xbcf2f: ; 0xbcf2f
+ 3writetext $6d, $4150
+ keeptextopen
+ 2jump UnknownScript_0xbcf37
+
+UnknownScript_0xbcf37: ; 0xbcf37
+ checkbit2 $0008
+ iffalse UnknownScript_0xbcf49
+ checkmoney $1, 0
+ if_equal $0, UnknownScript_0xbcf55
+ 2jump UnknownScript_0xbcf63
+
+UnknownScript_0xbcf49: ; 0xbcf49
+ checkmoney $1, 0
+ if_equal $0, UnknownScript_0xbcf79
+ 2jump UnknownScript_0xbcf6e
+
+UnknownScript_0xbcf55: ; 0xbcf55
+ readmoney $1, $0
+ 3writetext $6d, $41a7
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ 2jump MomPhoneWontSaveMoneyScript
+
+UnknownScript_0xbcf63: ; 0xbcf63
+ 3writetext $6d, $41ea
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ 2jump MomPhoneWontSaveMoneyScript
+
+UnknownScript_0xbcf6e: ; 0xbcf6e
+ 3writetext $6d, $420d
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ 2jump MomPhoneWontSaveMoneyScript
+
+UnknownScript_0xbcf79: ; 0xbcf79
+ readmoney $1, $0
+ 3writetext $6d, $4249
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ 2jump MomPhoneWontSaveMoneyScript
+
+MomPhoneSaveMoneyScript: ; 0xbcf87
+ setbit2 $0008
+ 3writetext $6d, $4289
+ keeptextopen
+ 2jump MomPhoneHangUpScript
+
+MomPhoneWontSaveMoneyScript: ; 0xbcf92
+ clearbit2 $0008
+ 3writetext BANK(MomPhoneWontSaveMoneyText), MomPhoneWontSaveMoneyText
+ keeptextopen
+ 2jump MomPhoneHangUpScript
+
+MomPhoneHangUpScript: ; 0xbcf9d
+ 3writetext BANK(MomPhoneHangUpText), MomPhoneHangUpText
+ end
+
+MomPhoneNoPokemonScript: ; 0xbcfa2
+ 3writetext BANK(MomPhoneNoPokemonText), MomPhoneNoPokemonText
+ end
+
+MomPhoneNoPokedexScript: ; 0xbcfa7
+ 3writetext BANK(MomPhoneNoPokedexText), MomPhoneNoPokedexText
+ end
+
+MomPhoneNoGymQuestScript: ; 0xbcfac
+ 3writetext BANK(MomPhoneNoGymQuestText), MomPhoneNoGymQuestText
+ end
+
+MomPhoneLectureScript: ; 0xbcfb1
+ setbit1 $0040
+ setbit2 $0009
+ specialphonecall $0000
+ 3writetext BANK(MomPhoneLectureText), MomPhoneLectureText
+ yesorno
+ iftrue MomPhoneSaveMoneyScript
+ 2jump MomPhoneWontSaveMoneyScript
+
+BillPhoneScript1: ; 0xbcfc5
+ checktime $2
+ iftrue .daygreet
+ checktime $4
+ iftrue .nitegreet
+ 3writetext BANK(BillPhoneMornGreetingText), BillPhoneMornGreetingText
+ keeptextopen
+ 2jump .main
+
+.daygreet ; 0xbcfd7
+ 3writetext BANK(BillPhoneDayGreetingText), BillPhoneDayGreetingText
+ keeptextopen
+ 2jump .main
+
+.nitegreet ; 0xbcfdf
+ 3writetext BANK(BillPhoneNiteGreetingText), BillPhoneNiteGreetingText
+ keeptextopen
+ 2jump .main
+
+.main ; 0xbcfe7
+ 3writetext BANK(BillPhoneGeneriText), BillPhoneGeneriText
+ keeptextopen
+ checkcode $10
+ RAM2MEM $0
+ if_equal $0, .full
+ if_greater_than $6, .nearlyfull
+ 3writetext BANK(BillPhoneNotFullText), BillPhoneNotFullText
+ end
+
+.nearlyfull ; 0xbcffd
+ 3writetext BANK(BillPhoneNearlyFullText), BillPhoneNearlyFullText
+ end
+
+.full ; 0xbd002
+ 3writetext BANK(BillPhoneFullText), BillPhoneFullText
+ end
+
+BillPhoneScript2: ; 0xbd007
+ 3writetext BANK(BillPhoneNewlyFullText), BillPhoneNewlyFullText
+ closetext
+ end
+
+ElmPhoneScript1: ; 0xbd00d
+ checkcode $14
+ if_equal $1, .pokerus
+ checkbit1 $0055
+ iftrue .discovery
+ checkbit1 $002d
+ iffalse .next
+ checkbit1 $0054
+ iftrue .egghatched
+.next
+ checkbit1 $002d
+ iftrue .eggunhatched
+ checkbit1 $0701
+ iftrue .assistant
+ checkbit1 $001f
+ iftrue .checkingegg
+ checkbit1 $0043
+ iftrue .stolen
+ checkbit1 $001e
+ iftrue .sawmrpokemon
+ 3writetext BANK(ElmPhoneStartText), ElmPhoneStartText
+ end
+
+.sawmrpokemon ; 0xbd048
+ 3writetext BANK(ElmPhoneSawMrPokemonText), ElmPhoneSawMrPokemonText
+ end
+
+.stolen ; 0xbd04d
+ 3writetext BANK(ElmPhonePokemonStolenText), ElmPhonePokemonStolenText
+ end
+
+.checkingegg ; 0xbd052
+ 3writetext BANK(ElmPhoneCheckingEggText), ElmPhoneCheckingEggText
+ end
+
+.assistant ; 0xbd057
+ 3writetext BANK(ElmPhoneAssistantText), ElmPhoneAssistantText
+ end
+
+.eggunhatched ; 0xbd05c
+ 3writetext BANK(ElmPhoneEggUnhatchedText), ElmPhoneEggUnhatchedText
+ end
+
+.egghatched ; 0xbd061
+ 3writetext BANK(ElmPhoneEggHatchedText), ElmPhoneEggHatchedText
+ setbit1 $0077
+ end
+
+.discovery ; 0xbd069
+ random $2
+ if_equal $0, .nextdiscovery
+ 3writetext BANK(ElmPhoneDiscovery1Text), ElmPhoneDiscovery1Text
+ end
+
+.nextdiscovery ; 0xbd074
+ 3writetext BANK(ElmPhoneDiscovery2Text), ElmPhoneDiscovery2Text
+ end
+
+.pokerus ; 0xbd079
+ 3writetext BANK(ElmPhonePokerusText), ElmPhonePokerusText
+ specialphonecall $0000
+ end
+
+ElmPhoneScript2: ; 0xbd081
+ checkcode $14
+ if_equal $2, .disaster
+ if_equal $3, .assistant
+ if_equal $4, .rocket
+ if_equal $5, .gift
+ if_equal $8, .gift
+ 3writetext BANK(ElmPhonePokerusText), ElmPhonePokerusText
+ specialphonecall $0000
+ end
+
+.disaster ; 0xbd09f
+ 3writetext BANK(ElmPhoneDisasterText), ElmPhoneDisasterText
+ specialphonecall $0000
+ setbit1 $0043
+ end
+
+.assistant ; 0xbd0aa
+ 3writetext BANK(ElmPhoneEggAssistantText), ElmPhoneEggAssistantText
+ specialphonecall $0000
+ clearbit1 $0700
+ setbit1 $0701
+ end
+
+.rocket ; 0xbd0b8
+ 3writetext BANK(ElmPhoneRocketText), ElmPhoneRocketText
+ specialphonecall $0000
+ end
+
+.gift ; 0xbd0c0
+ 3writetext BANK(ElmPhoneGiftText), ElmPhoneGiftText
+ specialphonecall $0000
+ end
+
+.unused ; 0xbd0c8
+ 3writetext BANK(ElmPhoneUnusedText), ElmPhoneUnusedText
+ specialphonecall $0000
+ end
+; bd0d0
+
--- a/engine/text.asm
+++ /dev/null
@@ -1,1230 +1,0 @@
-ClearBox: ; fb6
-; Fill a c*b box at hl with blank tiles.
-
- ld a, " "
-.y
- push bc
- push hl
-.x
- ld [hli], a
- dec c
- jr nz, .x
- pop hl
- ld bc, 20 ; screen width
- add hl, bc
- pop bc
- dec b
- jr nz, .y
- ret
-; fc8
-
-
-ClearTileMap: ; fc8
-; Fill TileMap with blank tiles.
-
- ld hl, TileMap
- ld a, " "
- ld bc, 360 ; screen dimensions 20*18
- call ByteFill
-
-; We aren't done if the LCD is on.
- ld a, [rLCDC]
- bit 7, a
- ret z
- jp WaitBGMap
-; fdb
-
-
-Functionfdb: ; fdb
- ld a, $7
- ld hl, AttrMap
- ld bc, $0168
- call ByteFill
- jr ClearTileMap
-; fe8
-
-
-
-TextBox: ; fe8
-; Draw a text box width c height b at hl
-; Dimensions do not include the border.
- push bc
- push hl
- call TextBoxBorder
- pop hl
- pop bc
- jr TextBoxPalette
-; ff1
-
-
-TextBoxBorder: ; ff1
-
-; Top
- push hl
- ld a, "┌"
- ld [hli], a
- inc a ; "─"
- call NPlaceChar
- inc a ; "┐"
- ld [hl], a
-
-; Middle
- pop hl
- ld de, 20 ; screen width
- add hl, de
-.PlaceRow
- push hl
- ld a, "│"
- ld [hli], a
- ld a, " "
- call NPlaceChar
- ld [hl], "│"
- pop hl
- ld de, 20 ; screen width
- add hl, de
- dec b
- jr nz, .PlaceRow
-
-; Bottom
- ld a, "└"
- ld [hli], a
- ld a, "─"
- call NPlaceChar
- ld [hl], "┘"
-
- ret
-; 101e
-
-
-NPlaceChar: ; 101e
-; Place char a c times
- ld d,c
-.loop
- ld [hli],a
- dec d
- jr nz, .loop
- ret
-; 1024
-
-
-TextBoxPalette: ; 1024
-; Fill text box width c height b at hl with pal 7
- ld de, AttrMap - TileMap
- add hl, de
- inc b
- inc b
- inc c
- inc c
- ld a, 7 ; pal
-.gotoy
- push bc
- push hl
-.gotox
- ld [hli], a
- dec c
- jr nz, .gotox
- pop hl
- ld de, 20 ; screen width
- add hl, de
- pop bc
- dec b
- jr nz, .gotoy
- ret
-; 103e
-
-
-SpeechTextBox: ; 103e
-; Standard textbox.
- hlcoord 0, 12
- ld b, 4 ; height
- ld c, 18 ; screen width - 2 (border)
- jp TextBox
-; 1048
-
-UnknownText_0x1048: ; 1048
- db $0, "ゲームフりーク!", $57
-; 1052
-
-Function1052: ; 1052
- ld hl, .text_1056
- ret
-.text_1056
- db "@"
-; 1057
-
-
-PrintText: ; 1057
- call Function106c
-Function105a: ; 105a
- push hl
- hlcoord 1, 14
- ld bc, 18 + 3<<8
- call ClearBox
- pop hl
-
-PrintTextBoxText: ; 1065
- bccoord 1, 14
- call Function13e5
- ret
-; 106c
-
-
-Function106c: ; 106c
- push hl
- call SpeechTextBox
- call Function1ad2
- call Function321c
- pop hl
- ret
-; 1078
-
-
-
-PlaceString: ; 1078
- push hl
-
-PlaceNextChar: ; 1079
- ld a, [de]
- cp "@"
- jr nz, CheckDict
- ld b, h
- ld c, l
- pop hl
- ret
- pop de
-
-NextChar: ; 1083
- inc de
- jp PlaceNextChar
-
-CheckDict: ; 1087
- cp $15
- jp z, Function117b
- cp $4f
- jp z, Char4F
- cp $4e
- jp z, Function12a7
- cp $16
- jp z, Function12b9
- and a
- jp z, Function1383
- cp $4c
- jp z, $1337
- cp $4b
- jp z, Char4B
- cp $51 ; Player name
- jp z, Function12f2
- cp $49
- jp z, Function1186
- cp $52 ; Mother name
- jp z, Function118d
- cp $53
- jp z, Function1194
- cp $35
- jp z, Function11e8
- cp $36
- jp z, Function11ef
- cp $37
- jp z, Function11f6
- cp $38
- jp z, Function119b
- cp $39
- jp z, Function11a2
- cp $54
- jp z, Function11c5
- cp $5b
- jp z, Function11b7
- cp $5e
- jp z, Function11be
- cp $5c
- jp z, Function11b0
- cp $5d
- jp z, Function11a9
- cp $23
- jp z, Function11cc
- cp $22
- jp z, Function12b0
- cp $55
- jp z, Char55
- cp $56
- jp z, Function11d3
- cp $57
- jp z, $137c
- cp $58
- jp z, Function135a
- cp $4a
- jp z, Function11da
- cp $24
- jp z, Function11e1
- cp $25
- jp z, NextChar
- cp $1f
- jr nz, .asm_1122
- ld a, $7f
-.asm_1122
- cp $5f
- jp z, Char5F
- cp $59
- jp z, Function11fd
- cp $5a
- jp z, Char5D
- cp $3f
- jp z, $121b
- cp $14
- jp z, $1252
- cp $e4
- jr z, .asm_1174 ; 0x113d $35
- cp $e5
- jr z, .asm_1174 ; 0x1141 $31
- jr .asm_114c ; 0x1143 $7
- ld b, a
- call Function13c6
- jp NextChar
-.asm_114c
- cp $60
- jr nc, .asm_1174 ; 0x114e $24
- cp $40
- jr nc, .asm_1165 ; 0x1152 $11
- cp $20
- jr nc, .asm_115c ; 0x1156 $4
- add $80
- jr .asm_115e ; 0x115a $2
-.asm_115c
- add $90
-.asm_115e
- ld b, $e5
- call Function13c6
- jr .asm_1174 ; 0x1163 $f
-.asm_1165
- cp $44
- jr nc, .asm_116d ; 0x1167 $4
- add $59
- jr .asm_116f ; 0x116b $2
-.asm_116d
- add $86
-.asm_116f
- ld b, $e4
- call Function13c6
-.asm_1174
- ld [hli], a
- call PrintLetterDelay
- jp NextChar
-; 0x117b
-
-
-Function117b: ; 117b
- ld c, l
- ld b, h
- ld a, $5f
- ld hl, $7036
- rst FarCall
- jp PlaceNextChar
-; 1186
-
-Function1186: ; 1186
- push de
- ld de, MomsName
- jp $126a
-; 118d
-
-Function118d: ; 118d
- push de
- ld de, PlayerName
- jp $126a
-; 1194
-
-Function1194: ; 1194
- push de
- ld de, RivalName
- jp $126a
-; 119b
-
-Function119b: ; 119b
- push de
- ld de, RedsName
- jp $126a
-; 11a2
-
-Function11a2: ; 11a2
- push de
- ld de, GreensName
- jp $126a
-; 11a9
-
-Function11a9: ; 11a9
- push de
- ld de, Char5DText
- jp $126a
-; 11b0
-
-Function11b0: ; 11b0
- push de
- ld de, Char5CText
- jp $126a
-; 11b7
-
-Function11b7: ; 11b7
- push de
- ld de, Char5BText
- jp $126a
-; 11be
-
-Function11be: ; 11be
- push de
- ld de, Char5EText
- jp $126a
-; 11c5
-
-Function11c5: ; 11c5
- push de
- ld de, Char54Text
- jp $126a
-; 11cc
-
-Function11cc: ; 11cc
- push de
- ld de, Char23Text
- jp $126a
-; 11d3
-
-Function11d3: ; 11d3
- push de
- ld de, $1292
- jp $126a
-; 11da
-
-Function11da: ; 11da
- push de
- ld de, Char4AText
- jp $126a
-; 11e1
-
-Function11e1: ; 11e1
- push de
- ld de, Char24Text
- jp $126a
-; 11e8
-
-Function11e8: ; 11e8
- push de
- ld de, Char37Text
- jp $126a
-; 11ef
-
-Function11ef: ; 11ef
- push de
- ld de, Char37Text
- jp $126a
-; 11f6
-
-Function11f6: ; 11f6
- push de
- ld de, Char37Text
- jp $126a
-; 11fd
-
-
-Function11fd: ; 11fd
- ld a, [hBattleTurn]
- xor $1
- jr Function1205
-; 1203
-
-Char5D: ; 1203
- ld a, [hBattleTurn]
-; 1205
-
-Function1205: ; 1205
- push de
- and a
- jr nz, .asm_120e ; 0x1207 $5
- ld de, BattleMonNick
- jr .asm_126a ; 0x120c $5c
-.asm_120e
- ld de, Char5AText ; Enemy
- call PlaceString
- ld h, b
- ld l, c
- ld de, EnemyMonNick
- jr .asm_126a ; 0x1219 $4f
- push de
- ld a, [InLinkBattle]
- and a
- jr nz, .linkbattle
- ld a, [TrainerClass]
- cp $9
- jr z, .asm_1248 ; 0x1227 $1f
- cp $2a
- jr z, .asm_1248 ; 0x122b $1b
- ld de, $c656
- call PlaceString
- ld h, b
- ld l, c
- ld de, String12a2
- call PlaceString
- push bc
- ld hl, $5939
- ld a, $e
- rst FarCall
- pop hl
- ld de, StringBuffer1
- jr .asm_126a ; 0x1246 $22
-.asm_1248
- ld de, RivalName
- jr .asm_126a ; 0x124b $1d
-.linkbattle
- ld de, $c656
- jr .asm_126a ; 0x1250 $18
- push de
- ld de, PlayerName
- call PlaceString
- ld h, b
- ld l, c
- ld a, [PlayerGender]
- bit 0, a
- ld de, String12a5
- jr z, .asm_126a ; 0x1263 $5
- ld de, String12a6
- jr .asm_126a ; 0x1268 $0
-.asm_126a
- call PlaceString
- ld h, b
- ld l, c
- pop de
- jp NextChar
-; 0x1273
-
-Char5CText: ; 1273
- db "TM@"
-Char5DText: ; 1276
- db "TRAINER@"
-Char5BText: ; 127e
- db "PC@"
-Char5EText: ; 1281
- db "ROCKET@"
-Char54Text: ; 1288
- db "POKé@"
-Char23Text: ; 128d
- db "こうげき@"
-Char56Text:; 1292
- db "……@"
-Char5AText: ; 1295
- db "Enemy @"
-Char4AText: ; 129c
- db $e1, $e2, "@" ; PK MN
-Char24Text: ; 129f
- db $70, $71, "@" ; PO KE
-String12a2: ; 12a2
- db " @"
-Char35Text:
-Char36Text:
-Char37Text: ; 12a4
- db "@"
-String12a5: ; 12a5
- db "@"
-String12a6: ; 12a6
- db "@"
-; 12a7
-
-Function12a7: ; 12a7
- pop hl
- ld bc, $0028
- add hl, bc
- push hl
- jp NextChar
-; 12b0
-
-Function12b0: ; 12b0
- pop hl
- ld bc, $0014
- add hl, bc
- push hl
- jp NextChar
-; 12b9
-
-Function12b9: ; 12b9
- pop hl
- push de
- ld bc, $3b60
- add hl, bc
- ld de, $ffec
- ld c, $1
-.asm_12c4
- ld a, h
- and a
- jr nz, .asm_12cd
- ld a, l
- cp $14
- jr c, .asm_12d1
-
-.asm_12cd
- add hl, de
- inc c
- jr .asm_12c4
-
-.asm_12d1
- ld hl, TileMap
- ld de, $0014
- ld a, c
-.asm_12d8
- and a
- jr z, .asm_12df
- add hl, de
- dec a
- jr .asm_12d8
-
-.asm_12df
- pop de
- inc de
- ld a, [de]
- ld c, a
- ld b, $0
- add hl, bc
- push hl
- jp NextChar
-; 12ea
-
-
-Char4F: ; 12ea
- pop hl
- hlcoord 1, 16
- push hl
- jp NextChar
-; 0x12f2
-
-Function12f2: ; 12f2
- push de
- ld a, [InLinkBattle]
- cp $3
- jr z, .asm_1301
- cp $4
- jr z, .asm_1301
- call Function13c7
-
-.asm_1301
- call Function13b6
- call Functionaaf
- ld hl, $c5b9
- ld bc, $0312
- call ClearBox
- call Function13cd
- ld c, $14
- call DelayFrames
- ld hl, $c5b9
- pop de
- jp NextChar
-; 131f
-
-
-Char4B: ; 131f
- ld a, [InLinkBattle]
- or a
- jr nz, .asm_1328
- call Function13c7
-
-.asm_1328
- call Function13b6
-
- push de
- call Functionaaf
- pop de
-
- ld a, [InLinkBattle]
- or a
- call z, Function13cd
-
- push de
- call Function138c
- call Function138c
- hlcoord 1, 16
- pop de
- jp NextChar
-; 1345
-
-
-Char55: ; 1345
- push de
- ld de, Text_1354
- ld b, h
- ld c, l
- call PlaceString
- ld h, b
- ld l, c
- pop de
- jp NextChar
-; 1354
-
-Text_1354: ; 1354
- db $4b, "@"
-; 1356
-
-
-Char5F: ; 1356
-; ends a Pokédex entry
- ld [hl], "."
- pop hl
- ret
-; 135a
-
-Function135a: ; 135a
- ld a, [InLinkBattle]
- cp $3
- jr z, .asm_1368
- cp $4
- jr z, .asm_1368
- call Function13c7
-
-.asm_1368
- call Function13b6
- call Functionaaf
- ld a, [InLinkBattle]
- cp $3
- jr z, .asm_137c
- cp $4
- jr z, .asm_137c
- call Function13cd
-
-.asm_137c
- pop hl
- ld de, .string_1382
- dec de
- ret
-
-.string_1382
- db "@"
-; 1383
-
-Function1383: ; 1383
- ld a, $e6
- ld [hli], a
- call PrintLetterDelay
- jp NextChar
-; 138c
-
-Function138c: ; 138c
- ld hl, $c5b9
- ld de, $c5a5
- ld a, $3
-.asm_1394
- push af
- ld c, $12
-.asm_1397
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_1397
- inc de
- inc de
- inc hl
- inc hl
- pop af
- dec a
- jr nz, .asm_1394
- ld hl, $c5e1
- ld a, $7f
- ld bc, $0012
- call ByteFill
- ld c, $5
- call DelayFrames
- ret
-; 13b6
-
-Function13b6: ; 13b6
- push bc
- ld a, [hOAMUpdate]
- push af
- ld a, $1
- ld [hOAMUpdate], a
- call WaitBGMap
- pop af
- ld [hOAMUpdate], a
- pop bc
- ret
-; 13c6
-
-Function13c6: ; 13c6
- ret
-; 13c7
-
-Function13c7: ; 13c7
- ld a, $ee
- ld [$c606], a
- ret
-; 13cd
-
-Function13cd: ; 13cd
- ld a, [$c605]
- ld [$c606], a
- ret
-; 13d4
-
-Function13d4: ; 13d4
- ld b, a
- ld a, [hROMBank]
- push af
- ld a, b
- rst Bankswitch
-
- call PlaceString
- pop af
- rst Bankswitch
-
- ret
-; 13e0
-
-Function13e0: ; 13e0
- ld hl, $13e4
- ret
-
-.string_13e4
- db "@"
-; 13e5
-
-
-Function13e5: ; 13e5
- ld a, [$cfcf]
- push af
- set 1, a
- ld [$cfcf], a
- call Function13f6
- pop af
- ld [$cfcf], a
- ret
-; 13f6
-
-Function13f6: ; 13f6
-.asm_13f6
- ld a, [hli]
- cp "@"
- ret z
- call Function13ff
- jr .asm_13f6
-; 13ff
-
-Function13ff: ; 13ff
- push hl
- push bc
- ld c, a
- ld b, 0
- ld hl, TextCommands
- add hl, bc
- add hl, bc
- ld e, [hl]
- inc hl
- ld d, [hl]
- pop bc
- pop hl
-
-; jp de
- push de
- ret
-; 1410
-
-TextCommands: ; 1410
- dw Text_00
- dw Text_01
- dw Text_02
- dw Text_03
- dw Text_04
- dw Text_05
- dw Text_06
- dw Text_07
- dw Text_08
- dw Text_09
- dw Text_0A
- dw Text_PlaySound ; $0b
- dw Text_0C
- dw Text_0D
- dw Text_PlaySound ; $0e
- dw Text_PlaySound ; $0f
- dw Text_PlaySound ; $10
- dw Text_PlaySound ; $11
- dw Text_PlaySound ; $12
- dw Text_PlaySound ; $13
- dw Text_14
- dw Text_15
- dw Text_16
-; 143e
-
-Text_00: ; 143e
-; TX
-; write text until "@"
-; [$00]["...@"]
-
- ld d, h
- ld e, l
- ld h, b
- ld l, c
- call PlaceString
- ld h, d
- ld l, e
- inc hl
- ret
-; 1449
-
-Text_01: ; 1449
-; TX_RAM
-; write text from a ram address
-; little endian
-; [$01][addr]
-
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- push hl
- ld h, b
- ld l, c
- call PlaceString
- pop hl
- ret
-; 1455
-
-Text_16: ; 1455
-; TX_FAR
-; write text from a different bank
-; little endian
-; [$16][addr][bank]
-
- ld a, [hROMBank]
- push af
-
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
-
- ld [hROMBank], a
- ld [MBC3RomBank], a
-
- push hl
- ld h, d
- ld l, e
- call Function13f6
- pop hl
-
- pop af
- ld [hROMBank], a
- ld [MBC3RomBank], a
- ret
-; 1470
-
-Text_02: ; 1470
-; TX_NUM
-; write bcdnumber from address, typically ram
-; little endian
-; [$02][addr][flags]
-; flags: see PrintBCDNumber
-
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- push hl
- ld h, b
- ld l, c
- ld c, a
- call PrintBCDNumber
- ld b, h
- ld c, l
- pop hl
- ret
-; 1480
-
-Text_03: ; 1480
-; TX_MOVE
-; move to a new tile
-; little endian
-; [$03][tileaddr]
-
- ld a, [hli]
- ld [$d0e6], a
- ld c, a
- ld a, [hli]
- ld [$d0e7], a
- ld b, a
- ret
-; 148b
-
-Text_04: ; 148b
-; TX_BOX
-; draw a box
-; little endian
-; [$04][tileaddr][height][width]
-
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- ld b, a
- ld a, [hli]
- ld c, a
- push hl
- ld h, d
- ld l, e
- call TextBox
- pop hl
- ret
-; 149b
-
-Text_05: ; 149b
-; TX_LOW
-; write text at (1,16)
-; [$05]
-
- bccoord 1, 16
- ret
-; 149f
-
-Text_06:: ; 149f
-; TX_WAITBUTTON
-; wait for button press
-; show arrow
-; [06]
-
- ld a, [InLinkBattle]
- cp $3
- jp z, Text_0D
- cp $4
- jp z, Text_0D
- push hl
- call Function13c7
- push bc
- call Functionaaf
- pop bc
- call Function13cd
- pop hl
- ret
-; 14ba
-
-Text_07: ; 14ba
- push hl
- call Function13cd
- call Function138c
- call Function138c
- pop hl
- bccoord 1, 16
- ret
-; 14c9
-
-Text_08: ; 14c9
-; TX_ASM
-
-; rom only?
- bit 7, h
- jr nz, .asm_14ce
- jp [hl]
-
-.asm_14ce
- ld a, "@"
- ld [hl], a
- ret
-; 14d2
-
-Text_09: ; 14d2
- ld a, [hli]
- ld e, a
- ld a, [hli]
- ld d, a
- ld a, [hli]
- push hl
- ld h, b
- ld l, c
- ld b, a
- and $f
- ld c, a
- ld a, b
- and $f0
- swap a
- set 6, a
- ld b, a
- call PrintNum
- ld b, h
- ld c, l
- pop hl
- ret
-; 14ed
-
-Text_0A: ; 14ed
- push hl
- push bc
- call GetJoypadPublic
- ld a, [hJoyDown]
- and BUTTON_A | BUTTON_B
- jr nz, .asm_14fd
- ld c, 30
- call DelayFrames
-
-.asm_14fd
- pop bc
- pop hl
- ret
-; 1500
-
-Text_PlaySound:: ; 1500
-; chars:
-; $0b, $0e, $0f, $10, $11, $12, $13
-; see TextSFX
-
- push bc
- dec hl
- ld a, [hli]
- ld b, a
- push hl
- ld hl, TextSFX
-.asm_1508
- ld a, [hli]
- cp $ff
- jr z, .asm_151f
- cp b
- jr z, .asm_1514
- inc hl
- inc hl
- jr .asm_1508
-
-.asm_1514
- push de
- ld e, [hl]
- inc hl
- ld d, [hl]
- call StartSFX
- call WaitSFX
- pop de
-
-.asm_151f
- pop hl
- pop bc
- ret
-; 1522
-
-Function1522: ; 1522
- push de
- ld e, [hl]
- inc hl
- ld d, [hl]
- call Function37ce
- pop de
- pop hl
- pop bc
- ret
-; 152d
-
-TextSFX: ; 152d
- dbw $0b, SFX_DEX_FANFARE_50_79
- dbw $12, SFX_FANFARE
- dbw $0e, SFX_DEX_FANFARE_20_49
- dbw $0f, SFX_ITEM
- dbw $10, SFX_CAUGHT_MON
- dbw $11, SFX_DEX_FANFARE_80_109
- dbw $13, SFX_SLOT_MACHINE_START
- db $ff ; end
-; 1543
-
-Text_0C: ; 1543
- ld a, [hli]
- ld d, a
- push hl
- ld h, b
- ld l, c
-.asm_1548
- push de
- ld a, "…"
- ld [hli], a
- call GetJoypadPublic
- ld a, [hJoyDown]
- and BUTTON_A | BUTTON_B
- jr nz, .asm_155a
- ld c, 10
- call DelayFrames
-.asm_155a
- pop de
- dec d
- jr nz, .asm_1548
- ld b, h
- ld c, l
- pop hl
- ret
-; 1562
-
-Text_0D: ; 1562
-; wait for key down
-; display arrow
- push hl
- push bc
- call Functionaaf
- pop bc
- pop hl
- ret
-; 156a
-
-Text_14: ; 156a
-; TX_PREDEF
-; [$14][id]
-
- ld a, [hli]
- push hl
- ld e, a
- ld d, 0
- ld hl, $4000
- add hl, de
- add hl, de
- ld a, $9
- call GetFarHalfword
- ld d, h
- ld e, l
- ld h, b
- ld l, c
- call PlaceString
- pop hl
- ret
-; 1582
-
-Text_15: ; 1582
-; TX_DAY
-
- call GetWeekday
- push hl
- push bc
- ld c, a
- ld b, 0
- ld hl, .Days
- add hl, bc
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld d, h
- ld e, l
- pop hl
- call PlaceString
- ld h, b
- ld l, c
- ld de, .Day
- call PlaceString
- pop hl
- ret
-; 15a2
-
-.Days ; 15a2
- dw .Sun
- dw .Mon
- dw .Tues
- dw .Wednes
- dw .Thurs
- dw .Fri
- dw .Satur
-
-.Sun db "SUN@"
-.Mon db "MON@"
-.Tues db "TUES@"
-.Wednes db "WEDNES@"
-.Thurs db "THURS@"
-.Fri db "FRI@"
-.Satur db "SATUR@"
-.Day db "DAY@"
-; 15d8
-
--- a/engine/time.asm
+++ /dev/null
@@ -1,311 +1,0 @@
-; Functions relating to the timer interrupt and the real-time-clock.
-
-
-AskTimer: ; 591
- push af
- ld a, [$ffe9]
- and a
- jr z, .asm_59a
- call Timer
-
-.asm_59a
- pop af
- reti
-; 59c
-
-
-LatchClock: ; 59c
-; latch clock counter data
- ld a, 0
- ld [MBC3LatchClock], a
- ld a, 1
- ld [MBC3LatchClock], a
- ret
-; 5a7
-
-
-UpdateTime: ; 5a7
- call GetClock
- call FixDays
- call FixTime
- callba GetTimeOfDay
- ret
-; 5b7
-
-
-GetClock: ; 5b7
-; store clock data in hRTCDayHi-hRTCSeconds
-
-; enable clock r/w
- ld a, SRAM_ENABLE
- ld [MBC3SRamEnable], a
-
-; clock data is 'backwards' in hram
-
- call LatchClock
- ld hl, MBC3SRamBank
- ld de, MBC3RTC
-
- ld [hl], RTC_S
- ld a, [de]
- and $3f
- ld [hRTCSeconds], a
-
- ld [hl], RTC_M
- ld a, [de]
- and $3f
- ld [hRTCMinutes], a
-
- ld [hl], RTC_H
- ld a, [de]
- and $1f
- ld [hRTCHours], a
-
- ld [hl], RTC_DL
- ld a, [de]
- ld [hRTCDayLo], a
-
- ld [hl], RTC_DH
- ld a, [de]
- ld [hRTCDayHi], a
-
-; unlatch clock / disable clock r/w
- call CloseSRAM
- ret
-; 5e8
-
-
-FixDays: ; 5e8
-; fix day count
-; mod by 140
-
-; check if day count > 255 (bit 8 set)
- ld a, [hRTCDayHi] ; DH
- bit 0, a
- jr z, .daylo
-; reset dh (bit 8)
- res 0, a
- ld [hRTCDayHi], a ; DH
-
-; mod 140
-; mod twice since bit 8 (DH) was set
- ld a, [hRTCDayLo] ; DL
-.modh
- sub 140
- jr nc, .modh
-.modl
- sub 140
- jr nc, .modl
- add 140
-
-; update dl
- ld [hRTCDayLo], a ; DL
-
-; unknown output
- ld a, $40 ; %1000000
- jr .set
-
-.daylo
-; quit if fewer than 140 days have passed
- ld a, [hRTCDayLo] ; DL
- cp 140
- jr c, .quit
-
-; mod 140
-.mod
- sub 140
- jr nc, .mod
- add 140
-
-; update dl
- ld [hRTCDayLo], a ; DL
-
-; unknown output
- ld a, $20 ; %100000
-
-.set
-; update clock with modded day value
- push af
- call SetClock
- pop af
- scf
- ret
-
-.quit
- xor a
- ret
-; 61d
-
-
-FixTime: ; 61d
-; add ingame time (set at newgame) to current time
-; day hr min sec
-; store time in CurDay, hHours, hMinutes, hSeconds
-
-; second
- ld a, [hRTCSeconds] ; S
- ld c, a
- ld a, [StartSecond]
- add c
- sub 60
- jr nc, .updatesec
- add 60
-.updatesec
- ld [hSeconds], a
-
-; minute
- ccf ; carry is set, so turn it off
- ld a, [hRTCMinutes] ; M
- ld c, a
- ld a, [StartMinute]
- adc c
- sub 60
- jr nc, .updatemin
- add 60
-.updatemin
- ld [hMinutes], a
-
-; hour
- ccf ; carry is set, so turn it off
- ld a, [hRTCHours] ; H
- ld c, a
- ld a, [StartHour]
- adc c
- sub 24
- jr nc, .updatehr
- add 24
-.updatehr
- ld [hHours], a
-
-; day
- ccf ; carry is set, so turn it off
- ld a, [hRTCDayLo] ; DL
- ld c, a
- ld a, [StartDay]
- adc c
- ld [CurDay], a
- ret
-; 658
-
-Function658: ; 658
- xor a
- ld [StringBuffer2], a
- ld a, $0
- ld [$d089], a
- jr .asm_677
-
- call UpdateTime
- ld a, [hHours]
- ld [$d087], a
- ld a, [hMinutes]
- ld [$d088], a
- ld a, [hSeconds]
- ld [$d089], a
- jr .asm_677
-
-.asm_677
- ld a, $5
- ld hl, $40ed
- rst FarCall
- ret
-; 67e
-
-
-
-Function67e: ; 67e
- call Function685
- call SetClock
- ret
-; 685
-
-Function685: ; 685
- xor a
- ld [hRTCSeconds], a
- ld [hRTCMinutes], a
- ld [hRTCHours], a
- ld [hRTCDayLo], a
- ld [hRTCDayHi], a
- ret
-; 691
-
-
-SetClock: ; 691
-; set clock data from hram
-
-; enable clock r/w
- ld a, SRAM_ENABLE
- ld [MBC3SRamEnable], a
-
-; set clock data
-; stored 'backwards' in hram
-
- call LatchClock
- ld hl, MBC3SRamBank
- ld de, MBC3RTC
-
-; seems to be a halt check that got partially commented out
-; this block is totally pointless
- ld [hl], RTC_DH
- ld a, [de]
- bit 6, a ; halt
- ld [de], a
-
-; seconds
- ld [hl], RTC_S
- ld a, [hRTCSeconds]
- ld [de], a
-; minutes
- ld [hl], RTC_M
- ld a, [hRTCMinutes]
- ld [de], a
-; hours
- ld [hl], RTC_H
- ld a, [hRTCHours]
- ld [de], a
-; day lo
- ld [hl], RTC_DL
- ld a, [hRTCDayLo]
- ld [de], a
-; day hi
- ld [hl], RTC_DH
- ld a, [hRTCDayHi]
- res 6, a ; make sure timer is active
- ld [de], a
-
-; cleanup
- call CloseSRAM ; unlatch clock, disable clock r/w
- ret
-; 6c4
-
-
-Function6c4: ; 6c4
- xor a
- push af
- ld a, $0
- call GetSRAMBank
- pop af
- ld [$ac60], a
- call CloseSRAM
- ret
-; 6d3
-
-Function6d3: ; 6d3
- ld hl, $ac60
- push af
- ld a, $0
- call GetSRAMBank
- pop af
- or [hl]
- ld [hl], a
- call CloseSRAM
- ret
-; 6e3
-
-Function6e3: ; 6e3
- ld a, $0
- call GetSRAMBank
- ld a, [$ac60]
- call CloseSRAM
- ret
-; 6ef
-
--- a/engine/vblank.asm
+++ /dev/null
@@ -1,541 +1,0 @@
-; VBlank is the interrupt responsible for updating VRAM.
-
-; In Pokemon Crystal, VBlank has been hijacked to act as the
-; main loop. After time-sensitive graphics operations have been
-; performed, joypad input and sound functions are executed.
-
-; This prevents the display and audio output from lagging.
-
-
-VBlank: ; 283
- push af
- push bc
- push de
- push hl
-
-; get vblank type
- ld a, [$ff9e]
- and $7
-
-; get fn pointer
- ld e, a
- ld d, $0
- ld hl, .VBlanks
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
-; down to business
- call _hl_
-
-; since this is called once per frame
- call GameTimer
-
- pop hl
- pop de
- pop bc
- pop af
- reti
-; 2a1
-
-.VBlanks ; 2a1
- dw VBlank0 ; 0
- dw VBlank1 ; 1
- dw VBlank2 ; 2
- dw VBlank3 ; 3
- dw VBlank4 ; 4
- dw VBlank5 ; 5
- dw VBlank6 ; 6
- dw VBlank0 ; 7
-; 2b1
-
-
-VBlank0: ; 2b1
-; normal operation
-
-; rng
-; scx, scy, wy, wx
-; bg map buffer
-; palettes
-; dma transfer
-; bg map
-; tiles
-; oam
-; joypad
-; sound
-
-; inc frame counter
- ld hl, $ff9b
- inc [hl]
-
-; advance rng
- ld a, [rDIV]
- ld b, a
- ld a, [hRandomAdd]
- adc b
- ld [hRandomAdd], a
-
- ld a, [rDIV]
- ld b, a
- ld a, [hRandomSub]
- sbc b
- ld [hRandomSub], a
-
-; save bank
- ld a, [hROMBank] ; current bank
- ld [$ff8a], a
-
-; scroll x
- ld a, [hSCX]
- ld [rSCX], a
-; scroll y
- ld a, [hSCY]
- ld [rSCY], a
-; window y
- ld a, [hWY]
- ld [rWY], a
-; window x + 7
- ld a, [hWX]
- ld [rWX], a
-
-; some time management is in order
-; only have time for one of these during vblank
-
-; bg map buffer has priority
- call UpdateBGMapBuffer
- jr c, .doneframeaction
-
-; then pals
- call UpdatePalsIfCGB
- jr c, .doneframeaction
-
-; dma transfer
- call DMATransfer
- jr c, .doneframeaction
-
-; bg map
- call UpdateBGMap
-
-; these have their own timing checks
- call Serve2bppRequest
- call Serve1bppRequest
- call AnimateTileset
-
-.doneframeaction
-; oam update off?
- ld a, [hOAMUpdate]
- and a
- jr nz, .vblankoccurred
-
-; update oam by dma transfer
- call hPushOAM
-; @PushOAM:
-; ld a, Sprites >> 8
-; ld [rDMA], a
-; ld a, $28
-; .loop
-; dec a
-; jr nz, .loop
-; ret
-
-
-; vblank-sensitive operations are done
-
-.vblankoccurred
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
-
-; dec OverworldDelay until 0
- ld a, [OverworldDelay]
- and a
- jr z, .textdelay
- dec a
- ld [OverworldDelay], a
-
-.textdelay
-; dec text delay counter until 0
- ld a, [TextDelayFrames]
- and a
- jr z, .joypad
- dec a
- ld [TextDelayFrames], a
-
-.joypad
- call Joypad
-
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
- ld a, [$ff8a]
- rst Bankswitch ; restore bank
-
-;
- ld a, [hSeconds]
- ld [$ffe3], a
-
- ret
-; 325
-
-
-VBlank2: ; 325
-; sound only
-
-; save bank
- ld a, [hROMBank]
- ld [$ff8a], a
-
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
-
-; restore bank
- ld a, [$ff8a]
- rst Bankswitch
-
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
- ret
-; 337
-
-
-VBlank1: ; 337
-; scx, scy
-; palettes
-; bg map
-; tiles
-; oam
-; sound / lcd stat
-
-; save bank
- ld a, [hROMBank]
- ld [$ff8a], a
-
-; scroll x
- ld a, [hSCX]
- ld [rSCX], a
-
-; scroll y
- ld a, [hSCY]
- ld [rSCY], a
-
-; time-sensitive fns
- call UpdatePals
- jr c, .vblankoccurred
-
-; these have their own timing checks
- call UpdateBGMap
- call Serve2bppRequest@VBlank
-; update oam by dma transfer
- call hPushOAM
-; @PushOAM:
-; ld a, Sprites >> 8
-; ld [rDMA], a
-; ld a, $28
-; .loop
-; dec a
-; jr nz, .loop
-; ret
-
-.vblankoccurred
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
-
-; get requested ints
- ld a, [rIF]
- ld b, a
-; discard requested ints
- xor a
- ld [rIF], a
-; enable lcd stat
- ld a, %10 ; lcd stat
- ld [rIE], a
-; rerequest serial int if applicable (still disabled)
-; request lcd stat
- ld a, b
- and %1000 ; serial
- or %10 ; lcd stat
- ld [rIF], a
-
- ei
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
-; restore bank
- ld a, [$ff8a]
- rst Bankswitch
- di
-
-; get requested ints
- ld a, [rIF]
- ld b, a
-; discard requested ints
- xor a
- ld [rIF], a
-; enable ints besides joypad
- ld a, %1111 ; serial timer lcdstat vblank
- ld [rIE], a
-; rerequest ints
- ld a, b
- ld [rIF], a
- ret
-; 37f
-
-
-UpdatePals: ; 37f
-; update pals for either dmg or cgb
-
-; check cgb
- ld a, [hCGB]
- and a
- jp nz, UpdateCGBPals
-
-; update gb pals
- ld a, [$cfc7]
- ld [rBGP], a
-
- ld a, [$cfc8]
- ld [rOBP0], a
-
- ld a, [$cfc9]
- ld [rOBP1], a
-
- and a
- ret
-; 396
-
-
-VBlank3: ; 396
-; scx, scy
-; palettes
-; bg map
-; tiles
-; oam
-; sound / lcd stat
-
-; save bank
- ld a, [hROMBank]
- ld [$ff8a], a
-
-; scroll x
- ld a, [hSCX]
- ld [rSCX], a
-; scroll y
- ld a, [hSCY]
- ld [rSCY], a
-
-; any pals to update?
- ld a, [hCGBPalUpdate]
- and a
- call nz, ForceUpdateCGBPals
- jr c, .vblankoccurred
-; else
- call UpdateBGMap
- call Serve2bppRequest@VBlank
-
-; update oam by dma transfer
- call hPushOAM
-; @PushOAM:
-; ld a, Sprites >> 8
-; ld [rDMA], a
-; ld a, $28
-; .loop
-; dec a
-; jr nz, .loop
-; ret
-
-.vblankoccurred
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
-
-; save int flag
- ld a, [rIF]
- push af
-; reset ints
- xor a
- ld [rIF], a
-; force lcdstat int during sound update
- ld a, %10 ; lcd stat
- ld [rIE], a
- ld [rIF], a
-
- ei
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
-; restore bank
- ld a, [$ff8a]
- rst Bankswitch
- di
-
-; request lcdstat
- ld a, [rIF]
- ld b, a
-; and any other ints
- pop af
- or b
- ld b, a
-; reset ints
- xor a
- ld [rIF], a
-; enable ints besides joypad
- ld a, %1111 ; serial timer lcdstat vblank
- ld [rIE], a
-; request ints
- ld a, b
- ld [rIF], a
- ret
-; 3df
-
-
-VBlank4: ; 3df
-; bg map
-; tiles
-; oam
-; joypad
-; serial
-; sound
-
-; save bank
- ld a, [hROMBank]
- ld [$ff8a], a
-
- call UpdateBGMap
- call Serve2bppRequest
-
-; update oam by dma transfer
- call hPushOAM
-; @PushOAM:
-; ld a, Sprites >> 8
-; ld [rDMA], a
-; ld a, $28
-; .loop
-; dec a
-; jr nz, .loop
-; ret
-
-; update joypad
- call Joypad
-
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
-
-; handshake
- call AskSerial
-
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
-; restore bank
- ld a, [$ff8a]
- rst Bankswitch
- ret
-; 400
-
-
-VBlank5: ; 400
-; scx
-; palettes
-; bg map
-; tiles
-; joypad
-;
-
-; save bank
- ld a, [hROMBank]
- ld [$ff8a], a
-
-; scroll x
- ld a, [hSCX]
- ld [rSCX], a
-
-; if we can update pals, skip this part
- call UpdatePalsIfCGB
- jr c, .vblankoccurred
-
- call UpdateBGMap
- call Serve2bppRequest
-
-.vblankoccurred
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
-
-; joypad
- call Joypad
-
-; discard requested ints
- xor a
- ld [rIF], a
-; enable lcd stat
- ld a, %10 ; lcd stat
- ld [rIE], a
-; request lcd stat
- ld [rIF], a
-
- ei
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
-; restore bank
- ld a, [$ff8a]
- rst Bankswitch
- di
-
-; discard requested ints
- xor a
- ld [rIF], a
-; enable ints besides joypad
- ld a, %1111 ; serial timer lcdstat vblank
- ld [rIE], a
- ret
-; 436
-
-
-VBlank6: ; 436
-; palettes
-; tiles
-; dma transfer
-; sound
-
-; save bank
- ld a, [hROMBank]
- ld [$ff8a], a
-
-; inc frame counter
- ld hl, $ff9b
- inc [hl]
-
- call UpdateCGBPals
- jr c, .vblankoccurred
-
- call Serve2bppRequest
- call Serve1bppRequest
- call DMATransfer
-
-.vblankoccurred
-; tell other fns vblank happened
- xor a
- ld [VBlankOccurred], a
-
-; update sound
- ld a, BANK(UpdateSound)
- rst Bankswitch ; bankswitch
- call UpdateSound
-; restore bank
- ld a, [$ff8a]
- rst Bankswitch
- ret
-; 45a
--- a/engine/video.asm
+++ /dev/null
@@ -1,487 +1,0 @@
-; Functions dealing with VRAM.
-
-DMATransfer: ; 15d8
-; Return carry if the transfer is completed.
-
- ld a, [hDMATransfer]
- and a
- ret z
-
-; Start transfer
- ld [rHDMA5], a
-
-; Execution is halted until the transfer is complete.
-
- xor a
- ld [hDMATransfer], a
- scf
- ret
-; 15e3
-
-
-UpdateBGMapBuffer: ; 15e3
-; Copy [$ffdc] 16x8 tiles from BGMapBuffer
-; to bg map addresses in BGMapBufferPtrs.
-
-; [$ffdc] must be even since this is done in pairs.
-
-; Return carry on success.
-
- ld a, [hBGMapUpdate]
- and a
- ret z
-
- ld a, [rVBK]
- push af
- ld [hSPBuffer], sp
-
- ld hl, BGMapBufferPtrs
- ld sp, hl
-
-; We can now pop the addresses of affected spots on the BG Map
-
- ld hl, BGMapPalBuffer
- ld de, BGMapBuffer
-
-
-.next
-; Copy a pair of 16x8 blocks (one 16x16 block)
-
-rept 2
-; Get our BG Map address
- pop bc
-
-; Palettes
- ld a, 1
- ld [rVBK], a
-
- ld a, [hli]
- ld [bc], a
- inc c
- ld a, [hli]
- ld [bc], a
- dec c
-
-; Tiles
- ld a, 0
- ld [rVBK], a
-
- ld a, [de]
- inc de
- ld [bc], a
- inc c
- ld a, [de]
- inc de
- ld [bc], a
-endr
-
-; We've done 2 16x8 blocks
- ld a, [$ffdc]
- dec a
- dec a
- ld [$ffdc], a
-
- jr nz, .next
-
-
- ld a, [hSPBuffer]
- ld l, a
- ld a, [hSPBuffer + 1]
- ld h, a
- ld sp, hl
-
- pop af
- ld [rVBK], a
-
- xor a
- ld [hBGMapUpdate], a
- scf
- ret
-; 163a
-
-
-WaitTop: ; 163a
-; Wait until the top third of the BG Map is being updated.
-
- ld a, [hBGMapMode]
- and a
- ret z
-
- ld a, [hBGMapThird]
- and a
- jr z, .done
-
- call DelayFrame
- jr WaitTop
-
-.done
- xor a
- ld [hBGMapMode], a
- ret
-; 164c
-
-
-UpdateBGMap: ; 164c
-; Update the BG Map, in thirds, from TileMap and AttrMap.
-
- ld a, [hBGMapMode]
- and a
- ret z
-
-; BG Map 0
- dec a ; 1
- jr z, .Tiles
- dec a ; 2
- jr z, .Attr
-
-; BG Map 1
- dec a
-
- ld a, [hBGMapAddress]
- ld l, a
- ld a, [hBGMapAddress + 1]
- ld h, a
- push hl
-
- xor a
- ld [hBGMapAddress], a
- ld a, VBGMap1 >> 8
- ld [hBGMapAddress + 1], a
-
- ld a, [hBGMapMode]
- push af
- cp 3
- call z, .Tiles
- pop af
- cp 4
- call z, .Attr
-
- pop hl
- ld a, l
- ld [hBGMapAddress], a
- ld a, h
- ld [hBGMapAddress + 1], a
- ret
-
-
-.Attr
- ld a, 1
- ld [rVBK], a
-
- ld hl, AttrMap
- call .update
-
- ld a, 0
- ld [rVBK], a
- ret
-
-
-.Tiles
- ld hl, TileMap
-
-
-.update
- ld [hSPBuffer], sp
-
-; Which third?
- ld a, [hBGMapThird]
- and a ; 0
- jr z, .top
- dec a ; 1
- jr z, .middle
- ; 2
-
-
-THIRD_HEIGHT EQU SCREEN_HEIGHT / 3
-
-
-.bottom
- ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH
- add hl, de
- ld sp, hl
-
- ld a, [hBGMapAddress + 1]
- ld h, a
- ld a, [hBGMapAddress]
- ld l, a
-
- ld de, 2 * THIRD_HEIGHT * BG_MAP_WIDTH
- add hl, de
-
-; Next time: top third
- xor a
- jr .start
-
-
-.middle
- ld de, THIRD_HEIGHT * SCREEN_WIDTH
- add hl, de
- ld sp, hl
-
- ld a, [hBGMapAddress + 1]
- ld h, a
- ld a, [hBGMapAddress]
- ld l, a
-
- ld de, THIRD_HEIGHT * BG_MAP_WIDTH
- add hl, de
-
-; Next time: bottom third
- ld a, 2
- jr .start
-
-
-.top
- ld sp, hl
-
- ld a, [hBGMapAddress + 1]
- ld h, a
- ld a, [hBGMapAddress]
- ld l, a
-
-; Next time: middle third
- ld a, 1
-
-
-.start
-; Which third to update next time
- ld [hBGMapThird], a
-
-; Rows of tiles in a third
- ld a, SCREEN_HEIGHT / 3
-
-; Discrepancy between TileMap and BGMap
- ld bc, BG_MAP_WIDTH - (SCREEN_WIDTH - 1)
-
-
-.row
-; Copy a row of 20 tiles
-rept SCREEN_WIDTH / 2 - 1
- pop de
- ld [hl], e
- inc l
- ld [hl], d
- inc l
-endr
- pop de
- ld [hl], e
- inc l
- ld [hl], d
-
- add hl, bc
- dec a
- jr nz, .row
-
-
- ld a, [hSPBuffer]
- ld l, a
- ld a, [hSPBuffer + 1]
- ld h, a
- ld sp, hl
- ret
-; 170a
-
-
-Serve1bppRequest: ; 170a
-; Only call during the first fifth of VBlank
-
- ld a, [Requested1bpp]
- and a
- ret z
-
-; Back out if we're too far into VBlank
- ld a, [rLY]
- cp 144
- ret c
- cp 146
- ret nc
-
-; Copy [Requested1bpp] 1bpp tiles from [Requested1bppSource] to [Requested1bppDest]
-
- ld [hSPBuffer], sp
-
-; Source
- ld hl, Requested1bppSource
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld sp, hl
-
-; Destination
- ld hl, Requested1bppDest
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
-; # tiles to copy
- ld a, [Requested1bpp]
- ld b, a
-
- xor a
- ld [Requested1bpp], a
-
-.next
-
-rept 3
- pop de
- ld [hl], e
- inc l
- ld [hl], e
- inc l
- ld [hl], d
- inc l
- ld [hl], d
- inc l
-endr
- pop de
- ld [hl], e
- inc l
- ld [hl], e
- inc l
- ld [hl], d
- inc l
- ld [hl], d
-
- inc hl
- dec b
- jr nz, .next
-
-
- ld a, l
- ld [Requested1bppDest], a
- ld a, h
- ld [Requested1bppDest + 1], a
-
- ld [Requested1bppSource], sp
-
- ld a, [hSPBuffer]
- ld l, a
- ld a, [hSPBuffer + 1]
- ld h, a
- ld sp, hl
- ret
-; 1769
-
-
-Serve2bppRequest: ; 1769
-; Only call during the first fifth of VBlank
-
- ld a, [Requested2bpp]
- and a
- ret z
-
-; Back out if we're too far into VBlank
- ld a, [rLY]
- cp 144
- ret c
- cp 146
- ret nc
- jr _Serve2bppRequest
-
-
-Serve2bppRequest@VBlank: ; 1778
-
- ld a, [Requested2bpp]
- and a
- ret z
-
-_Serve2bppRequest: ; 177d
-; Copy [Requested2bpp] 2bpp tiles from [Requested2bppSource] to [Requested2bppDest]
-
- ld [hSPBuffer], sp
-
-; Source
- ld hl, Requested2bppSource
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld sp, hl
-
-; Destination
- ld hl, Requested2bppDest
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
-; # tiles to copy
- ld a, [Requested2bpp]
- ld b, a
-
- xor a
- ld [Requested2bpp], a
-
-.next
-
-rept 7
- pop de
- ld [hl], e
- inc l
- ld [hl], d
- inc l
-endr
- pop de
- ld [hl], e
- inc l
- ld [hl], d
-
- inc hl
- dec b
- jr nz, .next
-
-
- ld a, l
- ld [Requested2bppDest], a
- ld a, h
- ld [Requested2bppDest + 1], a
-
- ld [Requested2bppSource], sp
-
- ld a, [hSPBuffer]
- ld l, a
- ld a, [hSPBuffer + 1]
- ld h, a
- ld sp, hl
- ret
-; 17d3
-
-
-AnimateTileset: ; 17d3
-; Only call during the first fifth of VBlank
-
- ld a, [$ffde]
- and a
- ret z
-
-; Back out if we're too far into VBlank
- ld a, [rLY]
- cp 144
- ret c
- cp 151
- ret nc
-
- ld a, [hROMBank]
- push af
- ld a, BANK(_AnimateTileset)
- rst Bankswitch
-
- ld a, [rSVBK]
- push af
- ld a, 1
- ld [rSVBK], a
-
- ld a, [rVBK]
- push af
- ld a, 0
- ld [rVBK], a
-
- call _AnimateTileset
-
- pop af
- ld [rVBK], a
- pop af
- ld [rSVBK], a
- pop af
- rst Bankswitch
- ret
-; 17ff
-
--- /dev/null
+++ b/event/name_rater.asm
@@ -1,0 +1,236 @@
+NameRater: ; fb6ed
+ ld hl, UnknownText_0xfb80f
+ call PrintText
+ call Function1dcf
+ jp c, .asm_fb77e
+ ld hl, UnknownText_0xfb814
+ call PrintText
+ callba Function50000
+ jr c, .asm_fb77e
+ ld a, [CurPartySpecies]
+ cp EGG
+ jr z, .asm_fb783
+ call GetCurNick
+ call Functionfb78a
+ jr c, .asm_fb779
+ ld hl, UnknownText_0xfb819
+ call PrintText
+ call Function1dcf
+ jr c, .asm_fb77e
+ ld hl, UnknownText_0xfb81e
+ call PrintText
+ xor a
+ ld [MonType], a
+ ld a, [CurPartySpecies]
+ ld [$d265], a
+ ld [CurSpecies], a
+ call GetBaseData
+ ld b, 0
+ ld de, StringBuffer2
+ callba Function116b7
+ call Functionfb7be
+ ld hl, UnknownText_0xfb837
+ jr c, .asm_fb76c
+ call Functionfb7d3
+ ld hl, UnknownText_0xfb837
+ jr c, .asm_fb76c
+ ld hl, PartyMon1Nickname
+ ld bc, $000b
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld e, l
+ ld d, h
+ ld hl, StringBuffer2
+ ld bc, $000b
+ call CopyBytes
+ ld hl, UnknownText_0xfb823
+
+.asm_fb76c
+ push hl
+ call GetCurNick
+ ld hl, UnknownText_0xfb83c
+ call PrintText
+ pop hl
+ jr .asm_fb786
+
+.asm_fb779
+ ld hl, UnknownText_0xfb82d
+ jr .asm_fb786
+
+.asm_fb77e
+ ld hl, UnknownText_0xfb828
+ jr .asm_fb786
+
+.asm_fb783
+ ld hl, UnknownText_0xfb832
+
+.asm_fb786
+ call PrintText
+ ret
+; fb78a
+
+Functionfb78a: ; fb78a
+ ld hl, PartyMon1OT
+ ld bc, $000b
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld de, PlayerName
+ ld c, $b
+ call .asm_fb7b1
+ jr c, .asm_fb7bc
+ ld hl, PartyMon1ID
+ ld bc, PartyMon2 - PartyMon1
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld de, PlayerID
+ ld c, $2
+.asm_fb7b1
+ ld a, [de]
+ cp [hl]
+ jr nz, .asm_fb7bc
+ inc hl
+ inc de
+ dec c
+ jr nz, .asm_fb7b1
+ and a
+ ret
+
+.asm_fb7bc
+ scf
+ ret
+; fb7be
+
+Functionfb7be: ; fb7be
+ ld hl, StringBuffer2
+ ld c, 10
+.asm_fb7c3
+ ld a, [hli]
+ cp "@"
+ jr z, .asm_fb7cf
+ cp " "
+ jr nz, .asm_fb7d1
+ dec c
+ jr nz, .asm_fb7c3
+
+.asm_fb7cf
+ scf
+ ret
+
+.asm_fb7d1
+ and a
+ ret
+; fb7d3
+
+Functionfb7d3: ; fb7d3
+ ld hl, PartyMon1Nickname
+ ld bc, $000b
+ ld a, [CurPartyMon]
+ call AddNTimes
+ push hl
+ call Functionfb802
+ ld b, c
+ ld hl, StringBuffer2
+ call Functionfb802
+ pop hl
+ ld a, c
+ cp b
+ jr nz, .asm_fb7fe
+ ld de, StringBuffer2
+.asm_fb7f2
+ ld a, [de]
+ cp "@"
+ jr z, .asm_fb800
+ cp [hl]
+ jr nz, .asm_fb7fe
+ inc hl
+ inc de
+ jr .asm_fb7f2
+
+.asm_fb7fe
+ and a
+ ret
+
+.asm_fb800
+ scf
+ ret
+; fb802
+
+Functionfb802: ; fb802
+ ld c, 0
+.asm_fb804
+ ld a, [hli]
+ cp "@"
+ ret z
+ inc c
+ ld a, c
+ cp 10
+ jr nz, .asm_fb804
+ ret
+; fb80f
+
+UnknownText_0xfb80f: ; 0xfb80f
+ ; Hello, hello! I'm the NAME RATER.
+ ; I rate the names of #MON.
+ ; Would you like me to rate names?
+ text_jump UnknownText_0x1c0043, BANK(UnknownText_0x1c0043)
+ db "@"
+; 0xfb814
+
+UnknownText_0xfb814: ; 0xfb814
+ ; Which #MON's nickname should I rate for you?
+ text_jump UnknownText_0x1c00a0, BANK(UnknownText_0x1c00a0)
+ db "@"
+; 0xfb819
+
+UnknownText_0xfb819: ; 0xfb819
+ ; Hm… @ … That's a fairly decent name.
+ ; But, how about a slightly better nickname?
+ ; Want me to give it a better name?
+ text_jump UnknownText_0x1c00cd, BANK(UnknownText_0x1c00cd)
+ db "@"
+; 0xfb81e
+
+UnknownText_0xfb81e: ; 0xfb81e
+ ; All right. What name should we give it, then?
+ text_jump UnknownText_0x1c0142, BANK(UnknownText_0x1c0142)
+ db "@"
+; 0xfb823
+
+UnknownText_0xfb823: ; 0xfb823
+ ; That's a better name than before! Well done!
+ text_jump UnknownText_0x1c0171, BANK(UnknownText_0x1c0171)
+ db "@"
+; 0xfb828
+
+UnknownText_0xfb828: ; 0xfb828
+ ; OK, then. Come again sometime.
+ text_jump UnknownText_0x1c019e, BANK(UnknownText_0x1c019e)
+ db "@"
+; 0xfb82d
+
+UnknownText_0xfb82d: ; 0xfb82d
+ ; Hm… @ ? What a great name! It's perfect.
+ ; Treat @ with loving care.
+ text_jump UnknownText_0x1c01be, BANK(UnknownText_0x1c01be)
+ db "@"
+; 0xfb832
+
+UnknownText_0xfb832: ; 0xfb832
+ ; Whoa… That's just an EGG.
+ text_jump UnknownText_0x1c0208, BANK(UnknownText_0x1c0208)
+ db "@"
+; 0xfb837
+
+UnknownText_0xfb837: ; 0xfb837
+ ; It might look the same as before,
+ ; but this new name is much better! Well done!
+ text_jump UnknownText_0x1c0222, BANK(UnknownText_0x1c0222)
+ db "@"
+; 0xfb83c
+
+UnknownText_0xfb83c: ; 0xfb83c
+ ; All right. This #MON is now named @ .
+ text_jump UnknownText_0x1c0272, BANK(UnknownText_0x1c0272)
+ db "@"
+; 0xfb841
+
--- /dev/null
+++ b/home/copy.asm
@@ -1,0 +1,431 @@
+; Functions to copy data from ROM.
+
+
+Functiondc9: ; dc9
+ ld a, [rLCDC]
+ bit 7, a
+ jp z, Copy2bpp
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(Function104284)
+ rst Bankswitch
+ call Function104284
+ pop af
+ rst Bankswitch
+
+ ret
+; ddc
+
+Functionddc: ; ddc
+ ld a, [rLCDC]
+ bit 7, a
+ jp z, Copy1bpp
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(Function1042b2)
+ rst Bankswitch
+ call Function1042b2
+ pop af
+ rst Bankswitch
+
+ ret
+; def
+
+Functiondef: ; def
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+ call FarCopyBytesDouble
+ pop af
+ rst Bankswitch
+ ret
+; dfd
+
+Functiondfd: ; dfd
+ dec c
+ ld a, [hBGMapMode]
+ push af
+ xor a
+ ld [hBGMapMode], a
+ ld a, [hROMBank]
+ push af
+ ld a, b
+ rst Bankswitch
+
+.asm_e09
+ ld a, d
+ ld [rHDMA1], a
+ ld a, e
+ and $f0
+ ld [rHDMA2], a
+ ld a, h
+ and $1f
+ ld [rHDMA3], a
+ ld a, l
+ and $f0
+ ld [rHDMA4], a
+ ld a, c
+ cp $8
+ jr c, .asm_e3c
+ sub $8
+ ld c, a
+ ld a, $f
+ ld [hDMATransfer], a
+ call DelayFrame
+ ld a, l
+ add $0
+ ld l, a
+ ld a, h
+ adc $1
+ ld h, a
+ ld a, e
+ add $0
+ ld e, a
+ ld a, d
+ adc $1
+ ld d, a
+ jr .asm_e09
+
+.asm_e3c
+ ld a, c
+ and $7f
+ ld [hDMATransfer], a
+ call DelayFrame
+ pop af
+ rst Bankswitch
+
+ pop af
+ ld [hBGMapMode], a
+ ret
+; e4a
+
+
+
+Functione4a: ; e4a
+ ld a, $5
+ ld hl, $4135
+ rst FarCall
+ ret
+; e51
+
+
+
+Functione51: ; e51
+ ld a, $3e
+ ld hl, $7449
+ rst FarCall
+ ret
+; e58
+
+Functione58: ; e58
+ ld a, $3e
+ ld hl, $74be
+ rst FarCall
+ ret
+; e5f
+
+
+
+Functione5f: ; e5f
+ ld a, $3e
+ ld hl, $748a
+ rst FarCall
+ ld a, $3e
+ ld hl, $74b0
+ rst FarCall
+ ret
+; e6c
+
+Functione6c: ; e6c
+ ld a, $3e
+ ld hl, $74b0
+ rst FarCall
+ ret
+; e73
+
+Functione73: ; e73
+ push de
+ ld a, $0
+ call GetSRAMBank
+ push bc
+ ld de, $a000
+ ld a, b
+ call FarDecompress
+ pop bc
+ pop hl
+ ld de, $a000
+ call Request2bpp
+ call CloseSRAM
+ ret
+; e8d
+
+
+
+FarCopyBytes: ; e8d
+; copy bc bytes from a:hl to de
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+ call CopyBytes
+
+ pop af
+ rst Bankswitch
+ ret
+; 0xe9b
+
+
+FarCopyBytesDouble: ; e9b
+; Copy bc bytes from a:hl to bc*2 bytes at de,
+; doubling each byte in the process.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+; switcheroo, de <> hl
+ ld a, h
+ ld h, d
+ ld d, a
+ ld a, l
+ ld l, e
+ ld e, a
+
+ inc b
+ inc c
+ jr .dec
+
+.loop
+ ld a, [de]
+ inc de
+ ld [hli], a
+ ld [hli], a
+.dec
+ dec c
+ jr nz, .loop
+ dec b
+ jr nz, .loop
+
+ pop af
+ rst Bankswitch
+ ret
+; 0xeba
+
+
+Request2bpp: ; eba
+ ld a, [hBGMapMode]
+ push af
+ xor a
+ ld [hBGMapMode], a
+
+ ld a, [hROMBank]
+ push af
+ ld a, b
+ rst Bankswitch
+
+ ld a, [$ffd3]
+ push af
+
+ ld a, $8
+ ld [$ffd3], a
+ ld a, [InLinkBattle]
+ cp $4
+ jr nz, .asm_edc
+ ld a, [$ffe9]
+ and a
+ jr nz, .asm_edc
+ ld a, $6
+ ld [$ffd3], a
+
+.asm_edc
+ ld a, e
+ ld [Requested2bppSource], a
+ ld a, d
+ ld [Requested2bppSource + 1], a
+ ld a, l
+ ld [Requested2bppDest], a
+ ld a, h
+ ld [Requested2bppDest + 1], a
+
+.asm_eec
+ ld a, c
+ ld hl, $ffd3
+ cp [hl]
+ jr nc, .asm_f08
+
+ ld [Requested2bpp], a
+.wait
+ call DelayFrame
+ ld a, [Requested2bpp]
+ and a
+ jr nz, .wait
+
+ pop af
+ ld [$ffd3], a
+
+ pop af
+ rst Bankswitch
+
+ pop af
+ ld [hBGMapMode], a
+ ret
+
+.asm_f08
+ ld a, [$ffd3]
+ ld [Requested2bpp], a
+.asm_f0d
+ call DelayFrame
+ ld a, [Requested2bpp]
+ and a
+ jr nz, .asm_f0d
+ ld a, c
+ ld hl, $ffd3
+ sub [hl]
+ ld c, a
+ jr .asm_eec
+; f1e
+
+
+Request1bpp: ; f1e
+ ld a, [hBGMapMode]
+ push af
+ xor a
+ ld [hBGMapMode], a
+
+ ld a, [hROMBank]
+ push af
+ ld a, b
+ rst Bankswitch
+
+ ld a, [$ffd3]
+ push af
+
+ ld a, $8
+ ld [$ffd3], a
+ ld a, [InLinkBattle]
+ cp $4
+ jr nz, .asm_f40
+ ld a, [$ffe9]
+ and a
+ jr nz, .asm_f40
+ ld a, $6
+ ld [$ffd3], a
+
+.asm_f40
+ ld a, e
+ ld [Requested1bppSource], a
+ ld a, d
+ ld [Requested1bppSource + 1], a
+ ld a, l
+ ld [Requested1bppDest], a
+ ld a, h
+ ld [Requested1bppDest + 1], a
+.asm_f50
+ ld a, c
+ ld hl, $ffd3
+ cp [hl]
+ jr nc, .asm_f6c
+
+ ld [Requested1bpp], a
+.wait
+ call DelayFrame
+ ld a, [Requested1bpp]
+ and a
+ jr nz, .wait
+
+ pop af
+ ld [$ffd3], a
+
+ pop af
+ rst Bankswitch
+
+ pop af
+ ld [hBGMapMode], a
+ ret
+
+.asm_f6c
+ ld a, [$ffd3]
+ ld [Requested1bpp], a
+.asm_f71
+ call DelayFrame
+ ld a, [Requested1bpp]
+ and a
+ jr nz, .asm_f71
+ ld a, c
+ ld hl, $ffd3
+ sub [hl]
+ ld c, a
+ jr .asm_f50
+; f82
+
+
+Get2bpp: ; f82
+ ld a, [rLCDC]
+ bit 7, a
+ jp nz, Request2bpp
+
+Copy2bpp: ; f89
+; copy c 2bpp tiles from b:de to hl
+
+ push hl
+ ld h, d
+ ld l, e
+ pop de
+
+; bank
+ ld a, b
+
+; bc = c * $10
+ push af
+ swap c
+ ld a, $f
+ and c
+ ld b, a
+ ld a, $f0
+ and c
+ ld c, a
+ pop af
+
+ jp FarCopyBytes
+; f9d
+
+
+Get1bpp: ; f9d
+ ld a, [rLCDC]
+ bit 7, a
+ jp nz, Request1bpp
+
+Copy1bpp: ; fa4
+; copy c 1bpp tiles from b:de to hl
+
+ push de
+ ld d, h
+ ld e, l
+
+; bank
+ ld a, b
+
+; bc = c * $10 / 2
+ push af
+ ld h, 0
+ ld l, c
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld b, h
+ ld c, l
+ pop af
+
+ pop hl
+ jp FarCopyBytesDouble
+; fb6
+
--- /dev/null
+++ b/home/copy2.asm
@@ -1,0 +1,134 @@
+CopyBytes: ; 0x3026
+; copy bc bytes from hl to de
+ inc b ; we bail the moment b hits 0, so include the last run
+ inc c ; same thing; include last byte
+ jr .HandleLoop
+.CopyByte
+ ld a, [hli]
+ ld [de], a
+ inc de
+.HandleLoop
+ dec c
+ jr nz, .CopyByte
+ dec b
+ jr nz, .CopyByte
+ ret
+
+SwapBytes: ; 0x3034
+; swap bc bytes between hl and de
+.Loop
+ ; stash [hl] away on the stack
+ ld a, [hl]
+ push af
+
+ ; copy a byte from [de] to [hl]
+ ld a, [de]
+ ld [hli], a
+
+ ; retrieve the previous value of [hl]; put it in [de]
+ pop af
+ ld [de], a
+ inc de
+
+ ; handle loop stuff
+ dec bc
+ ld a, b
+ or c
+ jr nz, .Loop
+ ret
+
+ByteFill: ; 0x3041
+; fill bc bytes with the value of a, starting at hl
+ inc b ; we bail the moment b hits 0, so include the last run
+ inc c ; same thing; include last byte
+ jr .HandleLoop
+.PutByte
+ ld [hli], a
+.HandleLoop
+ dec c
+ jr nz, .PutByte
+ dec b
+ jr nz, .PutByte
+ ret
+
+GetFarByte: ; 0x304d
+; retrieve a single byte from a:hl, and return it in a.
+ ; bankswitch to new bank
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+ ; get byte from new bank
+ ld a, [hl]
+ ld [hBuffer], a
+
+ ; bankswitch to previous bank
+ pop af
+ rst Bankswitch
+
+ ; return retrieved value in a
+ ld a, [hBuffer]
+ ret
+
+GetFarHalfword: ; 0x305d
+; retrieve a halfword from a:hl, and return it in hl.
+ ; bankswitch to new bank
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+ ; get halfword from new bank, put it in hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ; bankswitch to previous bank and return
+ pop af
+ rst Bankswitch
+ ret
+; 0x306b
+
+FarCopyWRAM: ; 306b
+ ld [hBuffer], a
+ ld a, [rSVBK]
+ push af
+ ld a, [hBuffer]
+ ld [rSVBK], a
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ ret
+; 307b
+
+GetFarWRAMByte: ; 307b
+ ld [hBuffer], a
+ ld a, [rSVBK]
+ push af
+ ld a, [hBuffer]
+ ld [rSVBK], a
+ ld a, [hl]
+ ld [hBuffer], a
+ pop af
+ ld [rSVBK], a
+ ld a, [hBuffer]
+ ret
+; 308d
+
+GetFarWRAMWord: ; 308d
+ ld [hBuffer], a
+ ld a, [rSVBK]
+ push af
+ ld a, [hBuffer]
+ ld [rSVBK], a
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop af
+ ld [rSVBK], a
+ ret
+; 309d
+
--- /dev/null
+++ b/home/decompress.asm
@@ -1,0 +1,367 @@
+FarDecompress: ; b40
+; Decompress graphics data at a:hl to de
+
+; put a away for a sec
+ ld [$c2c4], a
+; save bank
+ ld a, [hROMBank]
+ push af
+; bankswitch
+ ld a, [$c2c4]
+ rst Bankswitch
+
+; what we came here for
+ call Decompress
+
+; restore bank
+ pop af
+ rst Bankswitch
+ ret
+; b50
+
+
+Decompress: ; b50
+; Pokemon Crystal uses an lz variant for compression.
+
+; This is mainly used for graphics, but the intro's
+; tilemaps also use this compression.
+
+; This function decompresses lz-compressed data at hl to de.
+
+
+; Basic rundown:
+
+; A typical control command consists of:
+; -the command (bits 5-7)
+; -the count (bits 0-4)
+; -and any additional params
+
+; $ff is used as a terminator.
+
+
+; Commands:
+
+; 0: literal
+; literal data for some number of bytes
+; 1: iterate
+; one byte repeated for some number of bytes
+; 2: alternate
+; two bytes alternated for some number of bytes
+; 3: zero (whitespace)
+; 0x00 repeated for some number of bytes
+
+; Repeater control commands have a signed parameter used to determine the start point.
+; Wraparound is simulated:
+; Positive values are added to the start address of the decompressed data
+; and negative values are subtracted from the current position.
+
+; 4: repeat
+; repeat some number of bytes from decompressed data
+; 5: flipped
+; repeat some number of flipped bytes from decompressed data
+; ex: $ad = %10101101 -> %10110101 = $b5
+; 6: reverse
+; repeat some number of bytes in reverse from decompressed data
+
+; If the value in the count needs to be larger than 5 bits,
+; control code 7 can be used to expand the count to 10 bits.
+
+; A new control command is read in bits 2-4.
+; The new 10-bit count is split:
+; bits 0-1 contain the top 2 bits
+; another byte is added containing the latter 8
+
+; So, the structure of the control command becomes:
+; 111xxxyy yyyyyyyy
+; | | | |
+; | | our new count
+; | the control command for this count
+; 7 (this command)
+
+; For more information, refer to the code below and in extras/gfx.py .
+
+; save starting output address
+ ld a, e
+ ld [$c2c2], a
+ ld a, d
+ ld [$c2c3], a
+
+.loop
+; get next byte
+ ld a, [hl]
+; done?
+ cp $ff ; end
+ ret z
+
+; get control code
+ and %11100000
+
+; 10-bit param?
+ cp $e0 ; LZ_HI
+ jr nz, .normal
+
+
+; 10-bit param:
+
+; get next 3 bits (%00011100)
+ ld a, [hl]
+ add a
+ add a ; << 3
+ add a
+
+; this is our new control code
+ and %11100000
+ push af
+
+; get param hi
+ ld a, [hli]
+ and %00000011
+ ld b, a
+
+; get param lo
+ ld a, [hli]
+ ld c, a
+
+; read at least 1 byte
+ inc bc
+ jr .readers
+
+
+.normal
+; push control code
+ push af
+; get param
+ ld a, [hli]
+ and %00011111
+ ld c, a
+ ld b, $0
+; read at least 1 byte
+ inc c
+
+.readers
+; let's get started
+
+; inc loop counts since we bail as soon as they hit 0
+ inc b
+ inc c
+
+; get control code
+ pop af
+; command type
+ bit 7, a ; 80, a0, c0
+ jr nz, .repeatertype
+
+; literals
+ cp $20 ; LZ_ITER
+ jr z, .iter
+ cp $40 ; LZ_ALT
+ jr z, .alt
+ cp $60 ; LZ_ZERO
+ jr z, .zero
+ ; else $00
+
+; 00 ; LZ_LIT
+; literal data for bc bytes
+.loop1
+; done?
+ dec c
+ jr nz, .next1
+ dec b
+ jp z, .loop
+
+.next1
+ ld a, [hli]
+ ld [de], a
+ inc de
+ jr .loop1
+
+
+; 20 ; LZ_ITER
+; write byte for bc bytes
+.iter
+ ld a, [hli]
+
+.iterloop
+ dec c
+ jr nz, .iternext
+ dec b
+ jp z, .loop
+
+.iternext
+ ld [de], a
+ inc de
+ jr .iterloop
+
+
+; 40 ; LZ_ALT
+; alternate two bytes for bc bytes
+
+; next pair
+.alt
+; done?
+ dec c
+ jr nz, .alt0
+ dec b
+ jp z, .altclose0
+
+; alternate for bc
+.alt0
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .alt1
+; done?
+ dec b
+ jp z, .altclose1
+.alt1
+ ld a, [hld]
+ ld [de], a
+ inc de
+ jr .alt
+
+; skip past the bytes we were alternating
+.altclose0
+ inc hl
+.altclose1
+ inc hl
+ jr .loop
+
+
+; 60 ; LZ_ZERO
+; write 00 for bc bytes
+.zero
+ xor a
+
+.zeroloop
+ dec c
+ jr nz, .zeronext
+ dec b
+ jp z, .loop
+
+.zeronext
+ ld [de], a
+ inc de
+ jr .zeroloop
+
+
+; repeats
+; 80, a0, c0
+; repeat decompressed data from output
+.repeatertype
+ push hl
+ push af
+; get next byte
+ ld a, [hli]
+; absolute?
+ bit 7, a
+ jr z, .absolute
+
+; relative
+; a = -a
+ and %01111111 ; forget the bit we just looked at
+ cpl
+; add de (current output address)
+ add e
+ ld l, a
+ ld a, $ff ; -1
+ adc d
+ ld h, a
+ jr .repeaters
+
+.absolute
+; get next byte (lo)
+ ld l, [hl]
+; last byte (hi)
+ ld h, a
+; add starting output address
+ ld a, [$c2c2]
+ add l
+ ld l, a
+ ld a, [$c2c3]
+ adc h
+ ld h, a
+
+.repeaters
+ pop af
+ cp $80 ; LZ_REPEAT
+ jr z, .repeat
+ cp $a0 ; LZ_FLIP
+ jr z, .flip
+ cp $c0 ; LZ_REVERSE
+ jr z, .reverse
+
+; e0 -> 80
+
+; 80 ; LZ_REPEAT
+; repeat some decompressed data
+.repeat
+; done?
+ dec c
+ jr nz, .repeatnext
+ dec b
+ jr z, .cleanup
+
+.repeatnext
+ ld a, [hli]
+ ld [de], a
+ inc de
+ jr .repeat
+
+
+; a0 ; LZ_FLIP
+; repeat some decompressed data w/ flipped bit order
+.flip
+ dec c
+ jr nz, .flipnext
+ dec b
+ jp z, .cleanup
+
+.flipnext
+ ld a, [hli]
+ push bc
+ ld bc, $0008
+
+.fliploop
+ rra
+ rl b
+ dec c
+ jr nz, .fliploop
+ ld a, b
+ pop bc
+ ld [de], a
+ inc de
+ jr .flip
+
+
+; c0 ; LZ_REVERSE
+; repeat some decompressed data in reverse
+.reverse
+ dec c
+ jr nz, .reversenext
+
+ dec b
+ jp z, .cleanup
+
+.reversenext
+ ld a, [hld]
+ ld [de], a
+ inc de
+ jr .reverse
+
+
+.cleanup
+; get type of repeat we just used
+ pop hl
+; was it relative or absolute?
+ bit 7, [hl]
+ jr nz, .next
+
+; skip two bytes for absolute
+ inc hl
+; skip one byte for relative
+.next
+ inc hl
+ jp .loop
+; c2f
+
--- /dev/null
+++ b/home/delay.asm
@@ -1,0 +1,23 @@
+DelayFrame: ; 45a
+; Wait for one frame
+ ld a, 1
+ ld [VBlankOccurred], a
+
+; Wait for the next VBlank, halting to conserve battery
+.halt
+ halt ; rgbasm adds a nop after this instruction by default
+ ld a, [VBlankOccurred]
+ and a
+ jr nz, .halt
+ ret
+; 468
+
+
+DelayFrames: ; 468
+; Wait c frames
+ call DelayFrame
+ dec c
+ jr nz, DelayFrames
+ ret
+; 46f
+
--- /dev/null
+++ b/home/double_speed.asm
@@ -1,0 +1,31 @@
+; The CGB hardware introduces Double Speed Mode.
+; While active, the clock speed is doubled.
+
+; The hardware can switch between normal speed
+; and double speed at any time, but LCD output
+; collapses during the switch.
+
+DoubleSpeed: ; 2fef
+ ld hl, rKEY1
+ bit 7, [hl]
+ jr z, SwitchSpeed
+ ret
+; 2ff7
+
+NormalSpeed: ; 2ff7
+ ld hl, rKEY1
+ bit 7, [hl]
+ ret z
+; 2ffd
+
+SwitchSpeed: ; 2ffd
+ set 0, [hl]
+ xor a
+ ld [rIF], a
+ ld [rIE], a
+ ld a, $30
+ ld [rJOYP], a
+ stop ; rgbasm adds a nop after this instruction by default
+ ret
+; 300b
+
--- /dev/null
+++ b/home/fade.asm
@@ -1,0 +1,134 @@
+; Functions to fade the screen in and out.
+
+
+Function48c: ; 48c
+ ld a, [TimeOfDayPal]
+ ld b, a
+ ld hl, IncGradGBPalTable_11
+ ld a, l
+ sub b
+ ld l, a
+ jr nc, .asm_499
+ dec h
+
+.asm_499
+ ld a, [hli]
+ ld [rBGP], a
+ ld a, [hli]
+ ld [rOBP0], a
+ ld a, [hli]
+ ld [rOBP1], a
+ ret
+; 4a3
+
+
+Function4a3: ; 4a3
+ ld a, [hCGB]
+ and a
+ jr z, .asm_4af
+ ld hl, IncGradGBPalTable_00
+ ld b, 4
+ jr FadeOut
+
+.asm_4af
+ ld hl, IncGradGBPalTable_08
+ ld b, 4
+ jr FadeOut
+; 4b6
+
+Function4b6: ; 4b6
+ ld a, [hCGB]
+ and a
+ jr z, .asm_4c2
+ ld hl, IncGradGBPalTable_05
+ ld b, 3
+ jr FadeOut
+
+.asm_4c2
+ ld hl, IncGradGBPalTable_13
+ ld b, 3
+; 4c7
+
+FadeOut: ; 4c7
+ push de
+ ld a, [hli]
+ call DmgToCgbBGPals
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ call DmgToCgbObjPals
+ ld c, 8
+ call DelayFrames
+ pop de
+ dec b
+ jr nz, FadeOut
+ ret
+; 4dd
+
+Function4dd: ; 4dd
+ ld a, [hCGB]
+ and a
+ jr z, .asm_4e9
+ ld hl, IncGradGBPalTable_04 - 1
+ ld b, 4
+ jr FadeIn
+
+.asm_4e9
+ ld hl, IncGradGBPalTable_12 - 1
+ ld b, 4
+ jr FadeIn
+; 4f0
+
+Function4f0: ; 4f0
+ ld a, [hCGB]
+ and a
+ jr z, .asm_4fc
+ ld hl, IncGradGBPalTable_07 - 1
+ ld b, 3
+ jr FadeIn
+
+.asm_4fc
+ ld hl, IncGradGBPalTable_15 - 1
+ ld b, 3
+ ; fallthrough
+; 501
+
+FadeIn: ; 501
+ push de
+ ld a, [hld]
+ ld d, a
+ ld a, [hld]
+ ld e, a
+ call DmgToCgbObjPals
+ ld a, [hld]
+ call DmgToCgbBGPals
+ ld c, 8
+ call DelayFrames
+ pop de
+ dec b
+ jr nz, FadeIn
+ ret
+; 517
+
+
+; 517
+IncGradGBPalTable_00: db %11111111, %11111111, %11111111
+IncGradGBPalTable_01: db %11111110, %11111110, %11111110
+IncGradGBPalTable_02: db %11111001, %11111001, %11111001
+IncGradGBPalTable_03: db %11100100, %11100100, %11100100
+IncGradGBPalTable_04: db %11100100, %11100100, %11100100
+IncGradGBPalTable_05: db %10010000, %10010000, %10010000
+IncGradGBPalTable_06: db %01000000, %01000000, %01000000
+IncGradGBPalTable_07: db %00000000, %00000000, %00000000
+; bgp obp1 obp2
+IncGradGBPalTable_08: db %11111111, %11111111, %11111111
+IncGradGBPalTable_09: db %11111110, %11111110, %11111000
+IncGradGBPalTable_10: db %11111001, %11100100, %11100100
+IncGradGBPalTable_11: db %11100100, %11010000, %11100000
+IncGradGBPalTable_12: db %11100100, %11010000, %11100000
+IncGradGBPalTable_13: db %10010000, %10000000, %10010000
+IncGradGBPalTable_14: db %01000000, %01000000, %01000000
+IncGradGBPalTable_15: db %00000000, %00000000, %00000000
+; 547
+
--- /dev/null
+++ b/home/farcall.asm
@@ -1,0 +1,55 @@
+FarCall_de: ; 2d54
+; Call a:de.
+; Preserves other registers.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+ call .de
+ jr ReturnFarCall
+
+.de
+ push de
+ ret
+; 2d63
+
+
+FarCall_hl: ; 2d63
+; Call a:hl.
+; Preserves other registers.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+ call Function2d82
+; 2d6e
+
+ReturnFarCall: ; 2d6e
+; We want to retain the contents of f.
+; To do this, we can pop to bc instead of af.
+
+ ld a, b
+ ld [$cfb9], a
+ ld a, c
+ ld [$cfba], a
+
+; Restore the working bank.
+ pop bc
+ ld a, b
+ rst Bankswitch
+
+ ld a, [$cfb9]
+ ld b, a
+ ld a, [$cfba]
+ ld c, a
+ ret
+; 2d82
+
+Function2d82: ; 2d82
+ jp [hl]
+; 2d83
+
--- /dev/null
+++ b/home/flag.asm
@@ -1,0 +1,113 @@
+Function2e50: ; 2e50
+ xor a
+ ld hl, EventFlags
+ ld [hli], a
+ ret
+; 2e56
+
+Function2e56: ; 2e56
+ xor a
+ ld hl, BikeFlags
+ ld [hli], a
+ ld [hl], a
+ ret
+; 2e5d
+
+Function2e5d: ; 2e5d
+ ld a, [$d19a]
+ cp $2
+ jr z, .asm_2e69
+ cp $1
+ jr z, .asm_2e69
+ ret
+
+.asm_2e69
+ ld hl, StatusFlags
+ res 2, [hl]
+ ret
+; 2e6f
+
+
+EventFlagAction: ; 0x2e6f
+ ld hl, EventFlags
+ call FlagAction
+ ret
+
+FlagAction: ; 0x2e76
+; Perform action b on bit de in flag array hl.
+
+; inputs:
+; b: function
+; 0 clear bit
+; 1 set bit
+; 2 check bit
+; de: bit number
+; hl: index within bit table
+
+ ; get index within the byte
+ ld a, e
+ and 7
+
+ ; shift de right by three bits (get the index within memory)
+ srl d
+ rr e
+ srl d
+ rr e
+ srl d
+ rr e
+ add hl, de
+
+ ; implement a decoder
+ ld c, 1
+ rrca
+ jr nc, .one
+ rlc c
+.one
+ rrca
+ jr nc, .two
+ rlc c
+ rlc c
+.two
+ rrca
+ jr nc, .three
+ swap c
+.three
+
+ ; check b's value: 0, 1, 2
+ ld a, b
+ cp 1
+ jr c, .clearbit ; 0
+ jr z, .setbit ; 1
+
+ ; check bit
+ ld a, [hl]
+ and c
+ ld c, a
+ ret
+
+.setbit
+ ; set bit
+ ld a, [hl]
+ or c
+ ld [hl], a
+ ret
+
+.clearbit
+ ; clear bit
+ ld a, c
+ cpl
+ and [hl]
+ ld [hl], a
+ ret
+; 0x2ead
+
+
+Function2ead: ; 2ead
+ ld de, ENGINE_POKEDEX
+ ld b, CHECK_FLAG
+ callba EngineFlagAction
+ ld a, c
+ and a
+ ret
+; 2ebb
+
--- /dev/null
+++ b/home/game_time.asm
@@ -1,0 +1,132 @@
+ResetGameTime: ; 208a
+ xor a
+ ld [GameTimeCap], a
+ ld [GameTimeHours], a
+ ld [GameTimeHours + 1], a
+ ld [GameTimeMinutes], a
+ ld [GameTimeSeconds], a
+ ld [GameTimeFrames], a
+ ret
+; 209e
+
+
+GameTimer: ; 209e
+
+ nop
+
+ ld a, [rSVBK]
+ push af
+ ld a, 1
+ ld [rSVBK], a
+
+ call UpdateGameTimer
+
+ pop af
+ ld [rSVBK], a
+ ret
+; 20ad
+
+
+UpdateGameTimer: ; 20ad
+; Increment the game timer by one frame.
+; The game timer is capped at 999:59:59.00.
+
+
+; Don't update if game logic is paused.
+ ld a, [$c2cd]
+ and a
+ ret nz
+
+; Is the timer paused?
+ ld hl, GameTimerPause
+ bit 0, [hl]
+ ret z
+
+; Is the timer already capped?
+ ld hl, GameTimeCap
+ bit 0, [hl]
+ ret nz
+
+
+; +1 frame
+ ld hl, GameTimeFrames
+ ld a, [hl]
+ inc a
+
+ cp 60 ; frames/second
+ jr nc, .second
+
+ ld [hl], a
+ ret
+
+
+.second
+ xor a
+ ld [hl], a
+
+; +1 second
+ ld hl, GameTimeSeconds
+ ld a, [hl]
+ inc a
+
+ cp 60 ; seconds/minute
+ jr nc, .minute
+
+ ld [hl], a
+ ret
+
+
+.minute
+ xor a
+ ld [hl], a
+
+; +1 minute
+ ld hl, GameTimeMinutes
+ ld a, [hl]
+ inc a
+
+ cp 60 ; minutes/hour
+ jr nc, .hour
+
+ ld [hl], a
+ ret
+
+
+.hour
+ xor a
+ ld [hl], a
+
+; +1 hour
+ ld a, [GameTimeHours]
+ ld h, a
+ ld a, [GameTimeHours + 1]
+ ld l, a
+ inc hl
+
+
+; Cap the timer after 1000 hours.
+ ld a, h
+ cp 1000 / $100
+ jr c, .ok
+
+ ld a, l
+ cp 1000 % $100
+ jr c, .ok
+
+ ld hl, GameTimeCap
+ set 0, [hl]
+
+ ld a, 59 ; 999:59:59.00
+ ld [GameTimeMinutes], a
+ ld [GameTimeSeconds], a
+ ret
+
+
+.ok
+ ld a, h
+ ld [GameTimeHours], a
+ ld a, l
+ ld [GameTimeHours + 1], a
+ ret
+; 210f
+
--- /dev/null
+++ b/home/handshake.asm
@@ -1,0 +1,38 @@
+AskSerial: ; 2063
+; send out a handshake while serial int is off
+ ld a, [$c2d4]
+ bit 0, a
+ ret z
+
+ ld a, [$c2d5]
+ and a
+ ret nz
+
+; once every 6 frames
+ ld hl, $ca8a
+ inc [hl]
+ ld a, [hl]
+ cp 6
+ ret c
+
+ xor a
+ ld [hl], a
+
+ ld a, $c
+ ld [$c2d5], a
+
+; handshake
+ ld a, $88
+ ld [rSB], a
+
+; switch to internal clock
+ ld a, %00000001
+ ld [rSC], a
+
+; start transfer
+ ld a, %10000001
+ ld [rSC], a
+
+ ret
+; 208a
+
--- /dev/null
+++ b/home/init.asm
@@ -1,0 +1,225 @@
+Reset: ; 150
+ di
+ call CleanSoundRestart
+ xor a
+ ld [$ffde], a
+ call ClearPalettes
+ xor a
+ ld [rIF], a
+ ld a, 1 ; VBlank int
+ ld [rIE], a
+ ei
+
+ ld hl, $cfbe
+ set 7, [hl]
+
+ ld c, 32
+ call DelayFrames
+
+ jr Init
+; 16e
+
+
+_Start: ; 16e
+ cp $11
+ jr z, .asm_175
+ xor a
+ jr .asm_177
+
+.asm_175
+ ld a, $1
+
+.asm_177
+ ld [hCGB], a
+ ld a, $1
+ ld [$ffea], a
+; 17d
+
+
+Init: ; 17d
+
+ di
+
+ xor a
+ ld [rIF], a
+ ld [rIE], a
+ ld [rRP], a
+ ld [rSCX], a
+ ld [rSCY], a
+ ld [rSB], a
+ ld [rSC], a
+ ld [rWX], a
+ ld [rWY], a
+ ld [rBGP], a
+ ld [rOBP0], a
+ ld [rOBP1], a
+ ld [rTMA], a
+ ld [rTAC], a
+ ld [$d000], a
+
+ ld a, %100 ; Start timer at 4096Hz
+ ld [rTAC], a
+
+.wait
+ ld a, [rLY]
+ cp 145
+ jr nz, .wait
+
+ xor a
+ ld [rLCDC], a
+
+; Clear WRAM bank 0
+ ld hl, $c000
+ ld bc, $d000 - $c000
+.asm_1b1
+ ld [hl], 0
+ inc hl
+ dec bc
+ ld a, b
+ or c
+ jr nz, .asm_1b1
+
+ ld sp, Stack
+
+; Clear HRAM
+ ld a, [hCGB]
+ push af
+ ld a, [$ffea]
+ push af
+ xor a
+ ld hl, $ff80
+ ld bc, $ffff - $ff80
+ call ByteFill
+ pop af
+ ld [$ffea], a
+ pop af
+ ld [hCGB], a
+
+ call ClearWRAM
+ ld a, 1
+ ld [rSVBK], a
+ call ClearVRAM
+ call ClearSprites
+ call Function270
+
+
+ ld a, BANK(LoadPushOAM)
+ rst Bankswitch
+
+ call LoadPushOAM
+
+ xor a
+ ld [$ffde], a
+ ld [hSCX], a
+ ld [hSCY], a
+ ld [rJOYP], a
+
+ ld a, $8 ; HBlank int enable
+ ld [rSTAT], a
+
+ ld a, $90
+ ld [hWY], a
+ ld [rWY], a
+
+ ld a, 7
+ ld [hWX], a
+ ld [rWX], a
+
+ ld a, %11100011
+ ; LCD on
+ ; Win tilemap 1
+ ; Win on
+ ; BG/Win tiledata 0
+ ; BG Tilemap 0
+ ; OBJ 8x8
+ ; OBJ on
+ ; BG on
+ ld [rLCDC], a
+
+ ld a, $ff
+ ld [$ffcb], a
+
+ callba Function9890
+
+ ld a, $9c
+ ld [$ffd7], a
+
+ xor a
+ ld [hBGMapAddress], a
+
+ callba StartClock
+
+ xor a
+ ld [MBC3LatchClock], a
+ ld [MBC3SRamEnable], a
+
+ ld a, [hCGB]
+ and a
+ jr z, .asm_22b
+ call NormalSpeed
+.asm_22b
+
+ xor a
+ ld [rIF], a
+ ld a, %1111 ; VBlank, LCDStat, Timer, Serial interrupts
+ ld [rIE], a
+ ei
+
+ call DelayFrame
+
+ ld a, $30
+ call Predef
+
+ call CleanSoundRestart
+ xor a
+ ld [CurMusic], a
+ jp GameInit
+; 245
+
+
+ClearVRAM: ; 245
+; Wipe VRAM banks 0 and 1
+
+ ld a, 1
+ ld [rVBK], a
+ call .clear
+
+ xor a
+ ld [rVBK], a
+.clear
+ ld hl, VTiles0
+ ld bc, $2000
+ xor a
+ call ByteFill
+ ret
+; 25a
+
+ClearWRAM: ; 25a
+; Wipe swappable WRAM banks (1-7)
+
+ ld a, 1
+.asm_25c
+ push af
+ ld [rSVBK], a
+ xor a
+ ld hl, $d000
+ ld bc, $1000
+ call ByteFill
+ pop af
+ inc a
+ cp 8
+ jr nc, .asm_25c
+ ret
+; 270
+
+Function270: ; 270
+ ld a, $0
+ call GetSRAMBank
+ ld hl, $a000
+ ld bc, $0020
+ xor a
+ call ByteFill
+ call CloseSRAM
+ ret
+; 283
+
--- /dev/null
+++ b/home/item.asm
@@ -1,0 +1,76 @@
+DoItemEffect: ; 2f3f
+ callba _DoItemEffect
+ ret
+; 2f46
+
+CheckTossableItem: ; 2f46
+ push hl
+ push de
+ push bc
+ callba _CheckTossableItem
+ pop bc
+ pop de
+ pop hl
+ ret
+; 2f53
+
+TossItem: ; 2f53
+ push hl
+ push de
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_TossItem)
+ rst Bankswitch
+
+ call _TossItem
+
+ pop bc
+ ld a, b
+ rst Bankswitch
+ pop bc
+ pop de
+ pop hl
+ ret
+; 2f66
+
+ReceiveItem: ; 2f66
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_ReceiveItem)
+ rst Bankswitch
+ push hl
+ push de
+
+ call _ReceiveItem
+
+ pop de
+ pop hl
+ pop bc
+ ld a, b
+ rst Bankswitch
+ pop bc
+ ret
+; 2f79
+
+CheckItem: ; 2f79
+ push hl
+ push de
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_CheckItem)
+ rst Bankswitch
+
+ call _CheckItem
+
+ pop bc
+ ld a, b
+ rst Bankswitch
+ pop bc
+ pop de
+ pop hl
+ ret
+; 2f8c
+
--- /dev/null
+++ b/home/joypad.asm
@@ -1,0 +1,491 @@
+JoypadInt: ; 92e
+; Replaced by Joypad, called from VBlank instead of the useless
+; joypad interrupt.
+
+; This is a placeholder in case the interrupt is somehow enabled.
+ reti
+; 92f
+
+ClearJoypadPublic: ; 92f
+ xor a
+; Pressed this frame (delta)
+ ld [hJoyPressed], a
+; Currently pressed
+ ld [hJoyDown], a
+ ret
+; 935
+
+Joypad: ; 935
+; Read the joypad register and translate it to something more
+; workable for use in-game. There are 8 buttons, so we can use
+; one byte to contain all player input.
+
+; Updates:
+
+; hJoypadReleased: released this frame (delta)
+; hJoypadPressed: pressed this frame (delta)
+; hJoypadDown: currently pressed
+; hJoypadSum: pressed so far
+
+; Any of these three bits can be used to disable input.
+ ld a, [$cfbe]
+ and %11010000
+ ret nz
+
+; If we're saving, input is disabled.
+ ld a, [$c2cd]
+ and a
+ ret nz
+
+; We can only get four inputs at a time.
+; We take d-pad first for no particular reason.
+ ld a, D_PAD
+ ld [rJOYP], a
+; Read twice to give the request time to take.
+ ld a, [rJOYP]
+ ld a, [rJOYP]
+
+; The Joypad register output is in the lo nybble (inversed).
+; We make the hi nybble of our new container d-pad input.
+ cpl
+ and $f
+ swap a
+
+; We'll keep this in b for now.
+ ld b, a
+
+; Buttons make 8 total inputs (A, B, Select, Start).
+; We can fit this into one byte.
+ ld a, BUTTONS
+ ld [rJOYP], a
+; Wait for input to stabilize.
+ ld a, [rJOYP]
+ ld a, [rJOYP]
+ ld a, [rJOYP]
+ ld a, [rJOYP]
+ ld a, [rJOYP]
+ ld a, [rJOYP]
+; Buttons take the lo nybble.
+ cpl
+ and $f
+ or b
+ ld b, a
+
+; Reset the joypad register since we're done with it.
+ ld a, $30
+ ld [rJOYP], a
+
+; To get the delta we xor the last frame's input with the new one.
+ ld a, [hJoypadDown] ; last frame
+ ld e, a
+ xor b
+ ld d, a
+; Released this frame:
+ and e
+ ld [hJoypadReleased], a
+; Pressed this frame:
+ ld a, d
+ and b
+ ld [hJoypadPressed], a
+
+; Add any new presses to the list of collective presses:
+ ld c, a
+ ld a, [hJoypadSum]
+ or c
+ ld [hJoypadSum], a
+
+; Currently pressed:
+ ld a, b
+ ld [hJoypadDown], a
+
+; Now that we have the input, we can do stuff with it.
+
+; For example, soft reset:
+ and A_BUTTON | B_BUTTON | SELECT | START
+ cp A_BUTTON | B_BUTTON | SELECT | START
+ jp z, Reset
+
+ ret
+; 984
+
+
+GetJoypadPublic: ; 984
+; Update mirror joypad input from hJoypadDown (real input)
+
+; hJoyReleased: released this frame (delta)
+; hJoyPressed: pressed this frame (delta)
+; hJoyDown: currently pressed
+
+; bit 0 A
+; 1 B
+; 2 SELECT
+; 3 START
+; 4 RIGHT
+; 5 LEFT
+; 6 UP
+; 7 DOWN
+
+ push af
+ push hl
+ push de
+ push bc
+
+; The player input can be automated using an input stream.
+; See more below.
+ ld a, [InputType]
+ cp a, AUTO_INPUT
+ jr z, .auto
+
+; To get deltas, take this and last frame's input.
+ ld a, [hJoypadDown] ; real input
+ ld b, a
+ ld a, [hJoyDown] ; last frame mirror
+ ld e, a
+
+; Released this frame:
+ xor b
+ ld d, a
+ and e
+ ld [hJoyReleased], a
+
+; Pressed this frame:
+ ld a, d
+ and b
+ ld [hJoyPressed], a
+
+; It looks like the collective presses got commented out here.
+ ld c, a
+
+; Currently pressed:
+ ld a, b
+ ld [hJoyDown], a ; frame input
+
+.quit
+ pop bc
+ pop de
+ pop hl
+ pop af
+ ret
+
+.auto
+; Use a predetermined input stream (used in the catching tutorial).
+
+; Stream format: [input][duration]
+; A value of $ff will immediately end the stream.
+
+; Read from the input stream.
+ ld a, [hROMBank]
+ push af
+ ld a, [AutoInputBank]
+ rst Bankswitch
+
+ ld hl, AutoInputAddress
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+; We only update when the input duration has expired.
+ ld a, [AutoInputLength]
+ and a
+ jr z, .updateauto
+
+; Until then, don't change anything.
+ dec a
+ ld [AutoInputLength], a
+ pop af
+ rst Bankswitch
+ jr .quit
+
+
+.updateauto
+; An input of $ff will end the stream.
+ ld a, [hli]
+ cp a, $ff
+ jr z, .stopauto
+ ld b, a
+
+; A duration of $ff will end the stream indefinitely.
+ ld a, [hli]
+ ld [AutoInputLength], a
+ cp a, $ff
+ jr nz, .next
+
+; The current input is overwritten.
+ dec hl
+ dec hl
+ ld b, NO_INPUT
+ jr .finishauto
+
+.next
+; On to the next input...
+ ld a, l
+ ld [AutoInputAddress], a
+ ld a, h
+ ld [AutoInputAddress+1], a
+ jr .finishauto
+
+.stopauto
+ call StopAutoInput
+ ld b, NO_INPUT
+
+.finishauto
+ pop af
+ rst Bankswitch
+ ld a, b
+ ld [hJoyPressed], a ; pressed
+ ld [hJoyDown], a ; input
+ jr .quit
+; 9ee
+
+
+StartAutoInput: ; 9ee
+; Start reading automated input stream at a:hl.
+
+ ld [AutoInputBank], a
+ ld a, l
+ ld [AutoInputAddress], a
+ ld a, h
+ ld [AutoInputAddress+1], a
+; Start reading the stream immediately.
+ xor a
+ ld [AutoInputLength], a
+; Reset input mirrors.
+ xor a
+ ld [hJoyPressed], a ; pressed this frame
+ ld [hJoyReleased], a ; released this frame
+ ld [hJoyDown], a ; currently pressed
+
+ ld a, AUTO_INPUT
+ ld [InputType], a
+ ret
+; a0a
+
+
+StopAutoInput: ; a0a
+; Clear variables related to automated input.
+ xor a
+ ld [AutoInputBank], a
+ ld [AutoInputAddress], a
+ ld [AutoInputAddress+1], a
+ ld [AutoInputLength], a
+; Back to normal input.
+ ld [InputType], a
+ ret
+; a1b
+
+
+Functiona1b: ; a1b
+
+ call DelayFrame
+
+ push bc
+ call Functiona57
+ pop bc
+
+ ld a, [hJoyDown]
+ cp D_UP | SELECT | B_BUTTON
+ jr z, .asm_a34
+
+ ld a, [$ffa9]
+ and START | A_BUTTON
+ jr nz, .asm_a34
+
+ dec c
+ jr nz, Functiona1b
+
+ and a
+ ret
+
+.asm_a34
+ scf
+ ret
+; a36
+
+
+Functiona36: ; a36
+ call DelayFrame
+ call GetJoypadPublic
+ ld a, [hJoyPressed]
+ and A_BUTTON | B_BUTTON
+ ret nz
+ call RTC
+ jr Functiona36
+; a46
+
+Functiona46: ; a46
+ ld a, [hOAMUpdate]
+ push af
+ ld a, 1
+ ld [hOAMUpdate], a
+ call WaitBGMap
+ call Functiona36
+ pop af
+ ld [hOAMUpdate], a
+ ret
+; a57
+
+Functiona57: ; a57
+ call GetJoypadPublic
+ ld a, [$ffaa]
+ and a
+ ld a, [hJoyPressed]
+ jr z, .asm_a63
+ ld a, [hJoyDown]
+.asm_a63
+ ld [$ffa9], a
+ ld a, [hJoyPressed]
+ and a
+ jr z, .asm_a70
+ ld a, 15
+ ld [TextDelayFrames], a
+ ret
+
+.asm_a70
+ ld a, [TextDelayFrames]
+ and a
+ jr z, .asm_a7a
+ xor a
+ ld [$ffa9], a
+ ret
+
+.asm_a7a
+ ld a, 5
+ ld [TextDelayFrames], a
+ ret
+; a80
+
+Functiona80: ; a80
+ ld a, [$ffaf]
+ push af
+ ld a, [$ffb0]
+ push af
+ xor a
+ ld [$ffaf], a
+ ld a, $6
+ ld [$ffb0], a
+.asm_a8d
+ push hl
+ ld hl, $c606
+ call Functionb06
+ pop hl
+ call Functiona57
+ ld a, [$ffa9]
+ and $3
+ jr z, .asm_a8d
+ pop af
+ ld [$ffb0], a
+ pop af
+ ld [$ffaf], a
+ ret
+; aa5
+
+Functionaa5: ; aa5
+ call Functiona57
+ ld a, [$ffa9]
+ and A_BUTTON | B_BUTTON
+ jr z, Functionaa5
+ ret
+; aaf
+
+Functionaaf: ; aaf
+ ld a, [InLinkBattle]
+ and a
+ jr nz, .asm_ac1
+ call Functionac6
+ push de
+ ld de, SFX_READ_TEXT_2
+ call StartSFX
+ pop de
+ ret
+
+.asm_ac1
+ ld c, 65
+ jp DelayFrames
+; ac6
+
+Functionac6: ; ac6
+ ld a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ld [hOAMUpdate], a
+ ld a, [InputType]
+ or a
+ jr z, .asm_ad9
+ callba Function1de28a
+.asm_ad9
+ call Functionaf5
+ call Functiona57
+ ld a, [hJoyPressed]
+ and $3
+ jr nz, .asm_af1
+ call RTC
+ ld a, $1
+ ld [hBGMapMode], a
+ call DelayFrame
+ jr .asm_ad9
+
+.asm_af1
+ pop af
+ ld [hOAMUpdate], a
+ ret
+; af5
+
+Functionaf5: ; af5
+ ld a, [$ff9b]
+ and $10
+ jr z, .asm_aff
+ ld a, $ee
+ jr .asm_b02
+
+.asm_aff
+ ld a, [$c605]
+
+.asm_b02
+ ld [$c606], a
+ ret
+; b06
+
+Functionb06: ; b06
+ push bc
+ ld a, [hl]
+ ld b, a
+ ld a, $ee
+ cp b
+ pop bc
+ jr nz, .asm_b27
+ ld a, [$ffaf]
+ dec a
+ ld [$ffaf], a
+ ret nz
+ ld a, [$ffb0]
+ dec a
+ ld [$ffb0], a
+ ret nz
+ ld a, $7a
+ ld [hl], a
+ ld a, $ff
+ ld [$ffaf], a
+ ld a, $6
+ ld [$ffb0], a
+ ret
+
+.asm_b27
+ ld a, [$ffaf]
+ and a
+ ret z
+ dec a
+ ld [$ffaf], a
+ ret nz
+ dec a
+ ld [$ffaf], a
+ ld a, [$ffb0]
+ dec a
+ ld [$ffb0], a
+ ret nz
+ ld a, $6
+ ld [$ffb0], a
+ ld a, $ee
+ ld [hl], a
+ ret
+; b40
+
--- /dev/null
+++ b/home/lcd.asm
@@ -1,0 +1,81 @@
+; LCD handling
+
+
+Function547: ; 547
+ ld a, [hLCDStatCustom]
+ cp rSCX & $ff
+ ret nz
+ ld c, a
+ ld a, [LYOverrides]
+ ld [$ff00+c], a
+ ret
+; 552
+
+
+LCD: ; 552
+ push af
+ ld a, [hLCDStatCustom]
+ and a
+ jr z, .done
+
+; At this point it's assumed we're in WRAM bank 5!
+ push bc
+ ld a, [rLY]
+ ld c, a
+ ld b, LYOverrides >> 8
+ ld a, [bc]
+ ld b, a
+ ld a, [hLCDStatCustom]
+ ld c, a
+ ld a, b
+ ld [$ff00+c], a
+ pop bc
+
+.done
+ pop af
+ reti
+; 568
+
+
+DisableLCD: ; 568
+; Turn the LCD off
+
+; Don't need to do anything if the LCD is already off
+ ld a, [rLCDC]
+ bit 7, a ; lcd enable
+ ret z
+
+ xor a
+ ld [rIF], a
+ ld a, [rIE]
+ ld b, a
+
+; Disable VBlank
+ res 0, a ; vblank
+ ld [rIE], a
+
+.wait
+; Wait until VBlank would normally happen
+ ld a, [rLY]
+ cp 145
+ jr nz, .wait
+
+ ld a, [rLCDC]
+ and %01111111 ; lcd enable off
+ ld [rLCDC], a
+
+ xor a
+ ld [rIF], a
+ ld a, b
+ ld [rIE], a
+ ret
+; 58a
+
+
+EnableLCD: ; 58a
+ ld a, [rLCDC]
+ set 7, a ; lcd enable
+ ld [rLCDC], a
+ ret
+; 591
+
--- /dev/null
+++ b/home/map.asm
@@ -1,0 +1,2369 @@
+; Functions dealing with rendering and interacting with maps.
+
+Function210f: ; 210f
+ ld hl, $c7e8
+ ld bc, $0018
+ ld a, $0
+ call ByteFill
+ ret
+; 211b
+
+Function211b: ; 211b
+ push hl
+ ld hl, $dbf7
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ or h
+ ld a, [hl]
+ jr nz, .asm_2128
+ ld a, $ff
+
+.asm_2128
+ pop hl
+ ret
+; 212a
+
+Function212a: ; 212a
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ xor a
+ ld [$dbf7], a
+ ld [$dbf8], a
+ call Function2147
+ ret c
+ ld a, e
+ ld [$dbf7], a
+ ld a, d
+ ld [$dbf8], a
+ xor a
+ ret
+; 2147
+
+Function2147: ; 2147
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, $13
+ rst Bankswitch
+
+ ld hl, $501e
+.asm_2151
+ push hl
+ ld a, [hli]
+ cp $ff
+ jr z, .asm_2167
+ cp b
+ jr nz, .asm_2160
+ ld a, [hli]
+ cp c
+ jr nz, .asm_2160
+ jr .asm_216a
+
+.asm_2160
+ pop hl
+ ld de, $0004
+ add hl, de
+ jr .asm_2151
+
+.asm_2167
+ scf
+ jr .asm_216d
+
+.asm_216a
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+
+.asm_216d
+ pop hl
+ pop bc
+ ld a, b
+ rst Bankswitch
+
+ pop bc
+ ret
+; 2173
+
+Function2173: ; 2173
+ call Function217a
+ call Functiondb1
+ ret
+; 217a
+
+Function217a: ; 217a
+ ld a, [hROMBank]
+ push af
+ ld a, [TilesetBlocksBank]
+ rst Bankswitch
+
+ call Function2198
+ ld a, $60
+ ld hl, TileMap
+ ld bc, $0168
+ call ByteFill
+ ld a, $13
+ rst Bankswitch
+
+ call $515b
+ pop af
+ rst Bankswitch
+
+ ret
+; 2198
+
+Function2198: ; 2198
+ ld a, [$d194]
+ ld e, a
+ ld a, [$d195]
+ ld d, a
+ ld hl, EnemyMoveAnimation
+ ld b, $5
+
+.asm_21a5
+ push de
+ push hl
+ ld c, $6
+
+.asm_21a9
+ push de
+ push hl
+ ld a, [de]
+ and a
+ jr nz, .asm_21b2
+ ld a, [$d19d]
+
+.asm_21b2
+ ld e, l
+ ld d, h
+ add a
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld a, [TilesetBlocksAddress]
+ add l
+ ld l, a
+ ld a, [TilesetBlocksAddress + 1]
+ adc h
+ ld h, a
+
+rept 3
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+
+ ld a, e
+ add 20
+ ld e, a
+ jr nc, .next\@
+ inc d
+.next\@
+endr
+
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+
+ pop hl
+ ld de, $0004
+ add hl, de
+ pop de
+ inc de
+ dec c
+ jp nz, .asm_21a9
+ pop hl
+ ld de, $0060
+ add hl, de
+ pop de
+ ld a, [$d19f]
+ add $6
+ add e
+ ld e, a
+ jr nc, .asm_2225
+ inc d
+
+.asm_2225
+ dec b
+ jp nz, .asm_21a5
+ ret
+; 222a
+
+Function222a: ; 222a
+ ld a, $fa
+ ld [$ff9f], a
+ callba Function15363
+ xor a
+ ld [$ff9f], a
+ ret
+; 2238
+
+Function2238: ; 2238
+ call Function2252
+ ret nc
+ push bc
+ callba Function149af
+ pop bc
+ ret nc
+ call Function22a7
+ scf
+ ret
+; 224a
+
+
+
+Function224a: ; 224a
+ call Function2252
+ ret nc
+ call Function22a7
+ ret
+; 2252
+
+Function2252: ; 2252
+ callba Function1499a
+ ret nc
+
+ ld a, [hROMBank]
+ push af
+
+ call Function2c52
+ call Function2266
+
+ pop de
+ ld a, d
+ rst Bankswitch
+ ret
+; 2266
+
+Function2266: ; 2266
+ ld a, [MapY]
+ sub $4
+ ld e, a
+ ld a, [MapX]
+ sub $4
+ ld d, a
+ ld a, [$dbfb]
+ and a
+ ret z
+ ld c, a
+ ld hl, $dbfc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+.asm_227e
+ push hl
+ ld a, [hli]
+ cp e
+ jr nz, .asm_2289
+ ld a, [hli]
+ cp d
+ jr nz, .asm_2289
+ jr .asm_2296
+
+.asm_2289
+ pop hl
+ ld a, $5
+ add l
+ ld l, a
+ jr nc, .asm_2291
+ inc h
+
+.asm_2291
+ dec c
+ jr nz, .asm_227e
+ xor a
+ ret
+
+.asm_2296
+ pop hl
+ call Function22a3
+ ret nc
+ ld a, [$dbfb]
+ inc a
+ sub c
+ ld c, a
+ scf
+ ret
+; 22a3
+
+Function22a3: ; 22a3
+ inc hl
+ inc hl
+ scf
+ ret
+; 22a7
+
+Function22a7: ; 22a7
+ ld a, [hROMBank]
+ push af
+
+ call Function2c52
+ call Function22b4
+
+ pop af
+ rst Bankswitch
+ scf
+ ret
+; 22b4
+
+Function22b4: ; 22b4
+ push bc
+ ld hl, $dbfc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, c
+ dec a
+ ld bc, $0005
+ call AddNTimes
+ ld bc, $0002
+ add hl, bc
+ ld a, [hli]
+ cp $ff
+ jr nz, .asm_22d0
+ ld hl, $dcac
+ ld a, [hli]
+
+.asm_22d0
+ pop bc
+ ld [$d146], a
+ ld a, [hli]
+ ld [$d147], a
+ ld a, [hli]
+ ld [$d148], a
+ ld a, c
+ ld [$d149], a
+ ld a, [MapGroup]
+ ld [$d14a], a
+ ld a, [MapNumber]
+ ld [$d14b], a
+ scf
+ ret
+; 22ee
+
+
+
+CheckOutdoorMap: ; 22ee
+ cp ROUTE
+ ret z
+ cp TOWN
+ ret
+; 22f4
+
+CheckIndoorMap: ; 22f4
+ cp INDOOR
+ ret z
+ cp CAVE
+ ret z
+ cp DUNGEON
+ ret z
+ cp GATE
+ ret
+; 2300
+
+Function2300: ; 2300
+ cp INDOOR
+ ret z
+ cp GATE
+ ret z
+ cp $5
+ ret
+; 2309
+
+
+Function2309: ; 2309
+ call Function2326
+ call Function2c52
+ call Function234f
+ xor a
+ call Function2336
+ ret
+; 2317
+
+Function2317: ; 2317
+ call Function2326
+ call Function2c52
+ call Function234f
+ ld a, $1
+ call Function2336
+ ret
+; 2326
+
+Function2326: ; 2326
+ call Function2c3d
+ call Function2c1c
+ call GetSecondaryMapHeaderPointer
+ call Function235c
+ call Function2368
+ ret
+; 2336
+
+Function2336: ; 2336
+ push af
+ ld hl, $d1a6
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ inc hl
+ inc hl
+ call Function23da
+ call Function23f1
+ call Function2408
+ pop af
+ and a
+ ret nz
+ call Function241f
+ ret
+; 234f
+
+Function234f: ; 234f
+ ld hl, $d1a4
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call Function23ac
+ call Function23c3
+ ret
+; 235c
+
+Function235c: ; 235c
+ ld de, $d19d
+ ld c, $c
+.asm_2361
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_2361
+ ret
+; 2368
+
+Function2368: ; 2368
+ ld a, $ff
+ ld [NorthConnectedMapGroup], a
+ ld [SouthConnectedMapGroup], a
+ ld [WestConnectedMapGroup], a
+ ld [EastConnectedMapGroup], a
+
+ ld a, [$d1a8]
+ ld b, a
+
+ bit 3, b
+ jr z, .asm_2384
+ ld de, NorthMapConnection
+ call GetMapConnection
+
+.asm_2384
+ bit 2, b
+ jr z, .asm_238e
+ ld de, SouthMapConnection
+ call GetMapConnection
+
+.asm_238e
+ bit 1, b
+ jr z, .asm_2398
+ ld de, WestMapConnection
+ call GetMapConnection
+
+.asm_2398
+ bit 0, b
+ jr z, .asm_23a2
+ ld de, EastMapConnection
+ call GetMapConnection
+
+.asm_23a2
+ ret
+; 23a3
+
+
+GetMapConnection: ; 23a3
+; Load map connection struct at hl into de.
+ ld c, SouthMapConnection - NorthMapConnection
+.loop
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop
+ ret
+; 23ac
+
+
+Function23ac: ; 23ac
+ ld a, [hli]
+ ld c, a
+ ld [$dc07], a
+ ld a, l
+ ld [$dc08], a
+ ld a, h
+ ld [$dc09], a
+ ld a, c
+ and a
+ ret z
+ ld bc, $0004
+ call AddNTimes
+ ret
+; 23c3
+
+Function23c3: ; 23c3
+ ld a, [hli]
+ ld c, a
+ ld [$dc0a], a
+ ld a, l
+ ld [$dc0b], a
+ ld a, h
+ ld [$dc0c], a
+ ld a, c
+ and a
+ ret z
+ ld bc, $0003
+ call AddNTimes
+ ret
+; 23da
+
+Function23da: ; 23da
+ ld a, [hli]
+ ld c, a
+ ld [$dbfb], a
+ ld a, l
+ ld [$dbfc], a
+ ld a, h
+ ld [$dbfd], a
+ ld a, c
+ and a
+ ret z
+ ld bc, $0005
+ call AddNTimes
+ ret
+; 23f1
+
+Function23f1: ; 23f1
+ ld a, [hli]
+ ld c, a
+ ld [$dbfe], a
+ ld a, l
+ ld [$dbff], a
+ ld a, h
+ ld [$dc00], a
+ ld a, c
+ and a
+ ret z
+ ld bc, $0008
+ call AddNTimes
+ ret
+; 2408
+
+Function2408: ; 2408
+ ld a, [hli]
+ ld c, a
+ ld [$dc01], a
+ ld a, l
+ ld [$dc02], a
+ ld a, h
+ ld [$dc03], a
+ ld a, c
+ and a
+ ret z
+ ld bc, $0005
+ call AddNTimes
+ ret
+; 241f
+
+Function241f: ; 241f
+ push hl
+ call Function2471
+ pop de
+ ld hl, $d72e
+ ld a, [de]
+ inc de
+ ld [$dc04], a
+ ld a, e
+ ld [$dc05], a
+ ld a, d
+ ld [$dc06], a
+ ld a, [$dc04]
+ call Function2457
+ ld a, [$dc04]
+ ld c, a
+ ld a, $10
+ sub c
+ jr z, .asm_2454
+ ld bc, $0001
+ add hl, bc
+ ld bc, $0010
+.asm_244a
+ ld [hl], $0
+ inc hl
+ ld [hl], $ff
+ dec hl
+ add hl, bc
+ dec a
+ jr nz, .asm_244a
+
+.asm_2454
+ ld h, d
+ ld l, e
+ ret
+; 2457
+
+Function2457: ; 2457
+ and a
+ ret z
+ ld c, a
+.asm_245a
+ push bc
+ push hl
+ ld a, $ff
+ ld [hli], a
+ ld b, $d
+.asm_2461
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec b
+ jr nz, .asm_2461
+ pop hl
+ ld bc, $0010
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .asm_245a
+ ret
+; 2471
+
+Function2471: ; 2471
+ ld hl, $d4fe
+ ld bc, $01e0
+ xor a
+ call ByteFill
+ ld hl, $d4fe
+ ld de, $0028
+ ld c, $c
+ xor a
+.asm_2484
+ ld [hl], a
+ add hl, de
+ dec c
+ jr nz, .asm_2484
+ ret
+; 248a
+
+Function248a: ; 248a
+ call GetMapEventBank
+ rst Bankswitch
+
+ ld hl, $d1a6
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ inc hl
+ inc hl
+ inc hl
+ ld a, [WarpNumber]
+ dec a
+ ld c, a
+ ld b, $0
+ ld a, $5
+ call AddNTimes
+ ld a, [hli]
+ ld [YCoord], a
+ ld a, [hli]
+ ld [XCoord], a
+ ld a, [hli]
+ cp $ff
+ jr nz, .asm_24b3
+ call Function24ba
+
+.asm_24b3
+ ld a, $41
+ ld hl, $486d
+ rst FarCall
+ ret
+; 24ba
+
+Function24ba: ; 24ba
+ ld a, [$d149]
+ ld [$dcac], a
+ ld a, [$d14a]
+ ld [BackupMapGroup], a
+ ld a, [$d14b]
+ ld [BackupMapNumber], a
+ ret
+; 24cd
+
+Function24cd: ; 24cd
+ ld hl, OverworldMap
+ ld bc, $0514
+ ld a, $0
+ call ByteFill
+ call Function24e4
+ call FillMapConnections
+ ld a, $1
+ call Function263b
+ ret
+; 24e4
+
+
+
+Function24e4: ; 24e4
+ ld a, [hROMBank]
+ push af
+ ld hl, OverworldMap
+ ld a, [$d19f]
+ ld [hConnectedMapWidth], a
+ add $6
+ ld [hConnectionStripLength], a
+ ld c, a
+ ld b, $0
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld c, $3
+ add hl, bc
+ ld a, [$d1a0]
+ rst Bankswitch
+
+ ld a, [$d1a1]
+ ld e, a
+ ld a, [$d1a2]
+ ld d, a
+ ld a, [$d19e]
+ ld b, a
+.asm_250c
+ push hl
+ ld a, [hConnectedMapWidth]
+ ld c, a
+.asm_2510
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .asm_2510
+ pop hl
+ ld a, [hConnectionStripLength]
+ add l
+ ld l, a
+ jr nc, .asm_251e
+ inc h
+
+.asm_251e
+ dec b
+ jr nz, .asm_250c
+ pop af
+ rst Bankswitch
+
+ ret
+; 2524
+
+
+
+FillMapConnections: ; 2524
+
+; North
+ ld a, [NorthConnectedMapGroup]
+ cp $ff
+ jr z, .South
+ ld b, a
+ ld a, [NorthConnectedMapNumber]
+ ld c, a
+ call GetAnyMapBlockdataBank
+
+ ld a, [NorthConnectionStripPointer]
+ ld l, a
+ ld a, [NorthConnectionStripPointer + 1]
+ ld h, a
+ ld a, [NorthConnectionStripLocation]
+ ld e, a
+ ld a, [NorthConnectionStripLocation + 1]
+ ld d, a
+ ld a, [NorthConnectionStripLength]
+ ld [hConnectionStripLength], a
+ ld a, [NorthConnectedMapWidth]
+ ld [hConnectedMapWidth], a
+ call FillNorthConnectionStrip
+
+.South
+ ld a, [SouthConnectedMapGroup]
+ cp $ff
+ jr z, .West
+ ld b, a
+ ld a, [SouthConnectedMapNumber]
+ ld c, a
+ call GetAnyMapBlockdataBank
+
+ ld a, [SouthConnectionStripPointer]
+ ld l, a
+ ld a, [SouthConnectionStripPointer + 1]
+ ld h, a
+ ld a, [SouthConnectionStripLocation]
+ ld e, a
+ ld a, [SouthConnectionStripLocation + 1]
+ ld d, a
+ ld a, [SouthConnectionStripLength]
+ ld [hConnectionStripLength], a
+ ld a, [SouthConnectedMapWidth]
+ ld [hConnectedMapWidth], a
+ call FillSouthConnectionStrip
+
+.West
+ ld a, [WestConnectedMapGroup]
+ cp $ff
+ jr z, .East
+ ld b, a
+ ld a, [WestConnectedMapNumber]
+ ld c, a
+ call GetAnyMapBlockdataBank
+
+ ld a, [WestConnectionStripPointer]
+ ld l, a
+ ld a, [WestConnectionStripPointer + 1]
+ ld h, a
+ ld a, [WestConnectionStripLocation]
+ ld e, a
+ ld a, [WestConnectionStripLocation + 1]
+ ld d, a
+ ld a, [WestConnectionStripLength]
+ ld b, a
+ ld a, [WestConnectedMapWidth]
+ ld [hConnectionStripLength], a
+ call FillWestConnectionStrip
+
+.East
+ ld a, [EastConnectedMapGroup]
+ cp $ff
+ jr z, .Done
+ ld b, a
+ ld a, [EastConnectedMapNumber]
+ ld c, a
+ call GetAnyMapBlockdataBank
+
+ ld a, [EastConnectionStripPointer]
+ ld l, a
+ ld a, [EastConnectionStripPointer + 1]
+ ld h, a
+ ld a, [EastConnectionStripLocation]
+ ld e, a
+ ld a, [EastConnectionStripLocation + 1]
+ ld d, a
+ ld a, [EastConnectionStripLength]
+ ld b, a
+ ld a, [EastConnectedMapWidth]
+ ld [hConnectionStripLength], a
+ call FillEastConnectionStrip
+
+.Done
+ ret
+; 25d3
+
+
+FillNorthConnectionStrip:
+FillSouthConnectionStrip: ; 25d3
+
+ ld c, 3
+.y
+ push de
+
+ push hl
+ ld a, [hConnectionStripLength]
+ ld b, a
+.x
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .x
+ pop hl
+
+ ld a, [hConnectedMapWidth]
+ ld e, a
+ ld d, 0
+ add hl, de
+ pop de
+
+ ld a, [$d19f]
+ add 6
+ add e
+ ld e, a
+ jr nc, .asm_25f2
+ inc d
+.asm_25f2
+ dec c
+ jr nz, .y
+ ret
+; 25f6
+
+
+FillWestConnectionStrip:
+FillEastConnectionStrip: ; 25f6
+
+.asm_25f6
+ ld a, [$d19f]
+ add 6
+ ld [hConnectedMapWidth], a
+
+ push de
+
+ push hl
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hli]
+ ld [de], a
+ inc de
+ pop hl
+
+ ld a, [hConnectionStripLength]
+ ld e, a
+ ld d, 0
+ add hl, de
+ pop de
+
+ ld a, [hConnectedMapWidth]
+ add e
+ ld e, a
+ jr nc, .asm_2617
+ inc d
+.asm_2617
+ dec b
+ jr nz, .asm_25f6
+ ret
+; 261b
+
+Function261b: ; 261b
+ ld [$d432], a
+ ret
+; 261f
+
+
+CallScript: ; 261f
+; Call a script at a:hl.
+
+ ld [ScriptBank], a
+ ld a, l
+ ld [ScriptPos], a
+ ld a, h
+ ld [ScriptPos + 1], a
+
+ ld a, $ff
+ ld [ScriptRunning], a
+
+ scf
+ ret
+; 2631
+
+Function2631: ; 2631
+ ld a, [ScriptRunning]
+ and a
+ ret nz
+ call GetMapEventBank
+ jr CallScript
+; 263b
+
+Function263b: ; 263b
+ ld b, a
+ ld a, [hROMBank]
+ push af
+ call Function2c52
+ call Function2653
+ jr nc, .done
+
+ call GetMapEventBank
+ ld b, a
+ ld d, h
+ ld e, l
+ call Function2674
+
+.done
+ pop af
+ rst Bankswitch
+ ret
+; 2653
+
+Function2653: ; 2653
+ ld a, [$dc0a]
+ ld c, a
+ and a
+ ret z
+ ld hl, $dc0b
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ or h
+ ret z
+ ld de, $0003
+.asm_2664
+ ld a, [hl]
+ cp b
+ jr z, .asm_266e
+ add hl, de
+ dec c
+ jr nz, .asm_2664
+ xor a
+ ret
+
+.asm_266e
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ scf
+ ret
+; 2674
+
+Function2674: ; 2674
+ callba Unknown_0x974f3
+ ld a, [ScriptMode]
+ push af
+ ld hl, ScriptFlags
+ ld a, [hl]
+ push af
+ set 1, [hl]
+ callba Function96c56
+ callba ScriptEvents
+ pop af
+ ld [ScriptFlags], a
+ pop af
+ ld [ScriptMode], a
+ ret
+; 269a
+
+Function269a: ; 269a
+ ld a, [hROMBank]
+ push af
+ ld a, b
+ rst Bankswitch
+
+ push hl
+ call SpeechTextBox
+ call Function2e31
+ ld a, 1
+ ld [hOAMUpdate], a
+ call Function321c
+ pop hl
+ call PrintTextBoxText
+ xor a
+ ld [hOAMUpdate], a
+ pop af
+ rst Bankswitch
+
+ ret
+; 26b7
+
+Function26b7: ; 26b7
+; Call a:de.
+
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+ call .de
+
+ pop af
+ rst Bankswitch
+ ret
+
+.de
+ push de
+ ret
+; 26c7
+
+Function26c7: ; 26c7
+ ld a, [hROMBank]
+ push af
+ ld a, b
+ rst Bankswitch
+
+ ld a, c
+ call Function19e9
+
+ pop hl
+ ld a, h
+ rst Bankswitch
+ ret
+; 26d4
+
+
+GetScriptByte: ; 0x26d4
+; Return byte at ScriptBank:ScriptPos in a.
+
+ push hl
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, [ScriptBank]
+ rst Bankswitch
+
+ ld hl, ScriptPos
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+
+ ld a, [bc]
+
+ inc bc
+ ld [hl], b
+ dec hl
+ ld [hl], c
+
+ ld b, a
+ pop af
+ rst Bankswitch
+ ld a, b
+ pop bc
+ pop hl
+ ret
+; 0x26ef
+
+
+ObjectEvent: ; 0x26ef
+ jumptextfaceplayer ObjectEventText
+; 0x26f2
+
+ObjectEventText:
+ TX_FAR _ObjectEventText
+ db "@"
+; 0x26f7
+
+
+BGEvent: ; 26f7
+ jumptext BGEventText
+; 26fa
+
+BGEventText: ; 26fa
+ text_jump UnknownText_0x1c46fc, BANK(UnknownText_0x1c46fc)
+ db "@"
+; 26ff
+
+
+CoordinatesEvent: ; 26ff
+ jumptext CoordinatesEventText
+; 2702
+
+CoordinatesEventText: ; 2702
+ text_jump UnknownText_0x1c4706, BANK(UnknownText_0x1c4706)
+ db "@"
+; 2707
+
+
+Function2707: ; 2707
+ ld a, [hConnectionStripLength]
+ ld e, a
+ ld d, $0
+ ld hl, $d81e
+ add hl, de
+ ld a, [hl]
+ ret
+; 2712
+
+Function2712: ; 2712
+ ld a, [hConnectionStripLength]
+ ld e, a
+ ld d, $0
+ ld hl, $d81e
+ add hl, de
+ ld [hl], $ff
+ ret
+; 271e
+
+Function271e: ; 271e
+ ld a, [hConnectionStripLength]
+ ld e, a
+ ld d, $0
+ ld hl, $d81e
+ add hl, de
+ ld [hl], $0
+ ret
+; 272a
+
+
+Function272a: ; 272a
+ ld hl, TileMap
+ ld de, BGMapBuffer
+ call Function27b7
+ ld c, $28
+ call Functiondbd
+ ld a, [$d152]
+ ld e, a
+ ld a, [$d153]
+ ld d, a
+ call Function27d3
+ ld a, $1
+ ld [hBGMapUpdate], a
+ ret
+; 2748
+
+Function2748: ; 2748
+ ld hl, $c5e0
+ ld de, BGMapBuffer
+ call Function27b7
+ ld c, $28
+ call Functiondbd
+ ld a, [$d152]
+ ld l, a
+ ld a, [$d153]
+ ld h, a
+ ld bc, $0200
+ add hl, bc
+ ld a, h
+ and $3
+ or $98
+ ld e, l
+ ld d, a
+ call Function27d3
+ ld a, $1
+ ld [hBGMapUpdate], a
+ ret
+; 2771
+
+Function2771: ; 2771
+ ld hl, TileMap
+ ld de, BGMapBuffer
+ call Function27c0
+ ld c, $24
+ call Functiondbd
+ ld a, [$d152]
+ ld e, a
+ ld a, [$d153]
+ ld d, a
+ call Function27f8
+ ld a, $1
+ ld [hBGMapUpdate], a
+ ret
+; 278f
+
+Function278f: ; 278f
+ ld hl, $c4b2
+ ld de, BGMapBuffer
+ call Function27c0
+ ld c, $24
+ call Functiondbd
+ ld a, [$d152]
+ ld e, a
+ and $e0
+ ld b, a
+ ld a, e
+ add $12
+ and $1f
+ or b
+ ld e, a
+ ld a, [$d153]
+ ld d, a
+ call Function27f8
+ ld a, $1
+ ld [hBGMapUpdate], a
+ ret
+; 27b7
+
+Function27b7: ; 27b7
+ ld c, $28
+.asm_27b9
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_27b9
+ ret
+; 27c0
+
+Function27c0: ; 27c0
+ ld c, $12
+.asm_27c2
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, [hl]
+ ld [de], a
+ inc de
+ ld a, $13
+ add l
+ ld l, a
+ jr nc, .asm_27cf
+ inc h
+
+.asm_27cf
+ dec c
+ jr nz, .asm_27c2
+ ret
+; 27d3
+
+Function27d3: ; 27d3
+ ld hl, BGMapBufferPtrs
+ push de
+ call .asm_27df
+ pop de
+ ld a, $20
+ add e
+ ld e, a
+
+.asm_27df
+ ld c, $a
+.asm_27e1
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ ld a, e
+ inc a
+ inc a
+ and $1f
+ ld b, a
+ ld a, e
+ and $e0
+ or b
+ ld e, a
+ dec c
+ jr nz, .asm_27e1
+ ld a, $14
+ ld [$ffdc], a
+ ret
+; 27f8
+
+Function27f8: ; 27f8
+ ld hl, BGMapBufferPtrs
+ ld c, $12
+.asm_27fd
+ ld a, e
+ ld [hli], a
+ ld a, d
+ ld [hli], a
+ ld a, $20
+ add e
+ ld e, a
+ jr nc, .asm_280e
+ inc d
+ ld a, d
+ and $3
+ or $98
+ ld d, a
+
+.asm_280e
+ dec c
+ jr nz, .asm_27fd
+ ld a, $12
+ ld [$ffdc], a
+ ret
+; 2816
+
+Function2816: ; 2816
+ ld hl, BGMapBuffer
+ ld bc, $0078
+ xor a
+ call ByteFill
+ ret
+; 2821
+
+Function2821: ; 2821
+ ld hl, TilesetAddress
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [TilesetBank]
+ ld e, a
+ ld a, [rSVBK]
+ push af
+ ld a, $6
+ ld [rSVBK], a
+ ld a, e
+ ld de, $d000
+ call FarDecompress
+ ld hl, $d000
+ ld de, VTiles2
+ ld bc, $0600
+ call CopyBytes
+ ld a, [rVBK]
+ push af
+ ld a, $1
+ ld [rVBK], a
+ ld hl, $d600
+ ld de, VTiles2
+ ld bc, $0600
+ call CopyBytes
+ pop af
+ ld [rVBK], a
+ pop af
+ ld [rSVBK], a
+ ld a, [$d199]
+ cp $1
+ jr z, .asm_286f
+ cp $2
+ jr z, .asm_286f
+ cp $4
+ jr z, .asm_286f
+ jr .asm_2875
+
+.asm_286f
+ ld a, $7
+ ld hl, $4000
+ rst FarCall
+
+.asm_2875
+ xor a
+ ld [hTileAnimFrame], a
+ ret
+; 2879
+
+Function2879: ; 2879
+ ld hl, $d194
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, $dcb9
+ ld c, $5
+ ld b, $6
+.asm_2886
+ push bc
+ push hl
+.asm_2888
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .asm_2888
+ pop hl
+ ld a, [$d19f]
+ add $6
+ ld c, a
+ ld b, $0
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .asm_2886
+ ret
+; 289d
+
+Function289d: ; 289d
+ ld hl, $d194
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, $dcb9
+ ld a, [$d19f]
+ add $6
+ ld [hConnectionStripLength], a
+ ld a, [$d151]
+ and a
+ jr z, .asm_28cb
+ cp $1
+ jr z, .asm_28c0
+ cp $2
+ jr z, .asm_28d4
+ cp $3
+ jr z, .asm_28da
+ ret
+
+.asm_28c0
+ ld de, $dcbf
+ ld a, [hConnectionStripLength]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ jr .asm_28ce
+
+.asm_28cb
+ ld de, $dcb9
+
+.asm_28ce
+ ld b, $6
+ ld c, $4
+ jr .asm_28f7
+
+.asm_28d4
+ ld de, $dcba
+ inc hl
+ jr .asm_28dd
+
+.asm_28da
+ ld de, $dcb9
+
+.asm_28dd
+ ld b, $5
+ ld c, $5
+ jr .asm_28f7
+
+ ld hl, $d194
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [$d19f]
+ add $6
+ ld [hConnectionStripLength], a
+ ld de, $dcb9
+ ld b, $6
+ ld c, $5
+
+.asm_28f7
+ push bc
+ push hl
+ push de
+.asm_28fa
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec b
+ jr nz, .asm_28fa
+ pop de
+ ld a, e
+ add $6
+ ld e, a
+ jr nc, .asm_2908
+ inc d
+
+.asm_2908
+ pop hl
+ ld a, [hConnectionStripLength]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ pop bc
+ dec c
+ jr nz, .asm_28f7
+ ret
+; 2914
+
+Function2914: ; 2914
+ xor a
+ ld [TilePermissions], a
+ call Function296c
+ call Function294d
+ ld a, [MapX]
+ ld d, a
+ ld a, [MapY]
+ ld e, a
+ call Function2a3c
+ ld [StandingTile], a
+ call Function29ff
+ ret nz
+ ld a, [StandingTile]
+ and 7
+ ld hl, .data_2945
+ add l
+ ld l, a
+ ld a, 0
+ adc h
+ ld h, a
+ ld a, [hl]
+ ld hl, TilePermissions
+ or [hl]
+ ld [hl], a
+ ret
+; 2945
+
+.data_2945 ; 2945
+ db 1, 2, 4, 8, 9, 10, 5, 6
+; 294d
+
+Function294d: ; 294d
+ ld a, [MapX]
+ ld d, a
+ ld a, [MapY]
+ ld e, a
+ push de
+ inc e
+ call Function2a3c
+ ld [TileDown], a
+ call Function298b
+ pop de
+ dec e
+ call Function2a3c
+ ld [TileUp], a
+ call Function29a8
+ ret
+; 296c
+
+Function296c: ; 296c
+ ld a, [MapX]
+ ld d, a
+ ld a, [MapY]
+ ld e, a
+ push de
+ dec d
+ call Function2a3c
+ ld [TileLeft], a
+ call Function29e2
+ pop de
+ inc d
+ call Function2a3c
+ ld [TileRight], a
+ call Function29c5
+ ret
+; 298b
+
+Function298b: ; 298b
+ call Function29ff
+ ret nz
+ ld a, [TileDown]
+ and $7
+ cp $2
+ jr z, .asm_299f
+ cp $6
+ jr z, .asm_299f
+ cp $7
+ ret nz
+
+.asm_299f
+ ld a, [TilePermissions]
+ or $8
+ ld [TilePermissions], a
+ ret
+; 29a8
+
+Function29a8: ; 29a8
+ call Function29ff
+ ret nz
+ ld a, [TileUp]
+ and $7
+ cp $3
+ jr z, .asm_29bc
+ cp $4
+ jr z, .asm_29bc
+ cp $5
+ ret nz
+
+.asm_29bc
+ ld a, [TilePermissions]
+ or $4
+ ld [TilePermissions], a
+ ret
+; 29c5
+
+Function29c5: ; 29c5
+ call Function29ff
+ ret nz
+ ld a, [TileRight]
+ and $7
+ cp $1
+ jr z, .asm_29d9
+ cp $5
+ jr z, .asm_29d9
+ cp $7
+ ret nz
+
+.asm_29d9
+ ld a, [TilePermissions]
+ or $1
+ ld [TilePermissions], a
+ ret
+; 29e2
+
+Function29e2: ; 29e2
+ call Function29ff
+ ret nz
+ ld a, [TileLeft]
+ and $7
+ cp $0
+ jr z, .asm_29f6
+ cp $4
+ jr z, .asm_29f6
+ cp $6
+ ret nz
+
+.asm_29f6
+ ld a, [TilePermissions]
+ or $2
+ ld [TilePermissions], a
+ ret
+; 29ff
+
+Function29ff: ; 29ff
+ and $f0
+ cp $b0
+ ret z
+ cp $c0
+ ret
+; 2a07
+
+
+GetFacingTileCoord: ; 2a07
+; Return map coordinates in (d, e) and tile id in a
+; of the tile the player is facing.
+
+ ld a, [PlayerDirection]
+ and %1100
+ srl a
+ srl a
+ ld l, a
+ ld h, 0
+ add hl, hl
+ add hl, hl
+ ld de, .Directions
+ add hl, de
+
+ ld d, [hl]
+ inc hl
+ ld e, [hl]
+ inc hl
+
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+ ld a, [MapX]
+ add d
+ ld d, a
+ ld a, [MapY]
+ add e
+ ld e, a
+ ld a, [hl]
+ ret
+
+.Directions
+ ; x, y
+ db 0, 1
+ dw TileDown
+ db 0, -1
+ dw TileUp
+ db -1, 0
+ dw TileLeft
+ db 1, 0
+ dw TileRight
+; 2a3c
+
+
+Function2a3c: ; 2a3c
+ call Function2a66
+ ld a, [hl]
+ and a
+ jr z, .asm_2a63
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld a, [TilesetCollisionAddress]
+ ld c, a
+ ld a, [$d1e1]
+ ld b, a
+ add hl, bc
+ rr d
+ jr nc, .asm_2a56
+ inc hl
+
+.asm_2a56
+ rr e
+ jr nc, .asm_2a5c
+ inc hl
+ inc hl
+
+.asm_2a5c
+ ld a, [TilesetCollisionBank]
+ call GetFarByte
+ ret
+
+.asm_2a63
+ ld a, $ff
+ ret
+; 2a66
+
+Function2a66: ; 2a66
+ ld a, [$d19f]
+ add $6
+ ld c, a
+ ld b, $0
+ ld hl, $c801
+ add hl, bc
+ ld a, e
+ srl a
+ jr z, .asm_2a84
+ and a
+.asm_2a78
+ srl a
+ jr nc, .asm_2a7d
+ add hl, bc
+
+.asm_2a7d
+ sla c
+ rl b
+ and a
+ jr nz, .asm_2a78
+
+.asm_2a84
+ ld c, d
+ srl c
+ ld b, $0
+ add hl, bc
+ ret
+; 2a8b
+
+
+CheckFacingSign: ; 2a8b
+ call GetFacingTileCoord
+ ld b, a
+ ld a, d
+ sub 4
+ ld d, a
+ ld a, e
+ sub 4
+ ld e, a
+ ld a, [$dc01]
+ and a
+ ret z
+ ld c, a
+ ld a, [hROMBank]
+ push af
+ call Function2c52
+ call Function2aaa
+ pop hl
+ ld a, h
+ rst Bankswitch
+ ret
+; 2aaa
+
+Function2aaa: ; 2aaa
+ ld hl, $dc02
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+.asm_2ab0
+ push hl
+ ld a, [hli]
+ cp e
+ jr nz, .asm_2abb
+ ld a, [hli]
+ cp d
+ jr nz, .asm_2abb
+ jr .asm_2ac8
+
+.asm_2abb
+ pop hl
+ ld a, 5
+ add l
+ ld l, a
+ jr nc, .asm_2ac3
+ inc h
+
+.asm_2ac3
+ dec c
+ jr nz, .asm_2ab0
+ xor a
+ ret
+
+.asm_2ac8
+ pop hl
+ ld de, EngineBuffer1
+ ld bc, 5
+ call CopyBytes
+ scf
+ ret
+; 2ad4
+
+Function2ad4: ; 2ad4
+ ld a, [$dbfe]
+ and a
+ ret z
+ ld c, a
+ ld a, [hROMBank]
+ push af
+ call Function2c52
+ call Function2ae7
+ pop hl
+ ld a, h
+ rst Bankswitch
+ ret
+; 2ae7
+
+Function2ae7: ; 2ae7
+ ld hl, $dbff
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ call Function211b
+ ld b, a
+ ld a, [MapX]
+ sub $4
+ ld d, a
+ ld a, [MapY]
+ sub $4
+ ld e, a
+.asm_2afd
+ push hl
+ ld a, [hli]
+ cp b
+ jr z, .asm_2b06
+ cp $ff
+ jr nz, .asm_2b10
+
+.asm_2b06
+ ld a, [hli]
+ cp e
+ jr nz, .asm_2b10
+ ld a, [hli]
+ cp d
+ jr nz, .asm_2b10
+ jr .asm_2b1d
+
+.asm_2b10
+ pop hl
+ ld a, $8
+ add l
+ ld l, a
+ jr nc, .asm_2b18
+ inc h
+
+.asm_2b18
+ dec c
+ jr nz, .asm_2afd
+ xor a
+ ret
+
+.asm_2b1d
+ pop hl
+ ld de, EngineBuffer1
+ ld bc, $0008
+ call CopyBytes
+ scf
+ ret
+; 2b29
+
+
+FadeToMenu: ; 2b29
+ xor a
+ ld [hBGMapMode], a
+ call Function1d6e
+ ld a, $23
+ ld hl, $4084
+ rst FarCall
+ call ClearSprites
+ call Function2ed3
+ ret
+; 2b3c
+
+
+Function2b3c: ; 2b3c
+ call WhiteBGMap
+ call Function2bae
+ call Function1ad2
+ call Function1d7d
+ call Functiond90
+ jr Function2b5c
+; 2b4d
+
+Function2b4d: ; 2b4d
+ call WhiteBGMap
+ call Function1d7d
+ call Function2bae
+ call Function1ad2
+ call Functiond90
+; 2b5c
+
+Function2b5c: ; 2b5c
+ ld b, $9
+ call GetSGBLayout
+ ld a, $12
+ ld hl, $5409
+ rst FarCall
+ call Function3200
+ ld a, $23
+ ld hl, $4079
+ rst FarCall
+ call Function2ee4
+ ret
+; 2b74
+
+
+Function2b74: ; 0x2b74
+ push af
+ ld a, $1
+ ld [$c2ce], a
+ call WhiteBGMap
+ call ClearSprites
+ call Function2bae
+ ld hl, $c590 ; tile 0, 12
+ ld bc, $0412
+ call TextBox
+ ld hl, VramState
+ set 0, [hl]
+ call Function1ad2
+ call Function3200
+ ld b, $9
+ call GetSGBLayout
+ callba Function49409
+ call UpdateTimePals
+ call DelayFrame
+ ld a, $1
+ ld [$ffde], a
+ pop af
+ ret
+; 0x2bae
+
+Function2bae: ; 2bae
+ call DisableLCD
+ call ClearSprites
+ ld a, $5
+ ld hl, $4168
+ rst FarCall
+ call Functione51
+ call Functione5f
+ ld a, [hROMBank]
+ push af
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call Function2c24
+ ld a, $23
+ ld hl, $4001
+ rst FarCall
+ call Function2173
+ call Function2821
+ ld a, $9
+ call Function3cb4
+ pop af
+ rst Bankswitch
+
+ call EnableLCD
+ ret
+; 2be5
+
+
+GetMapHeaderPointer: ; 2be5
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+; 2bed
+
+GetAnyMapHeaderPointer: ; 0x2bed
+; Prior to calling this function, you must have switched banks so that
+; MapGroupPointers is visible.
+
+; inputs:
+; b = map group, c = map number
+; XXX de = ???
+
+; outputs:
+; hl points to the map header
+ push bc ; save map number for later
+
+ ; get pointer to map group
+ dec b
+ ld c, b
+ ld b, $0
+ ld hl, MapGroupPointers
+ add hl, bc
+ add hl, bc
+
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ pop bc ; restore map number
+
+ ; find the cth map header
+ dec c
+ ld b, $0
+ ld a, OlivineGym_MapHeader - OlivinePokeCenter1F_MapHeader
+ call AddNTimes
+ ret
+; 0x2c04
+
+GetMapHeaderMember: ; 0x2c04
+; Extract data from the current map's header.
+
+; inputs:
+; de = offset of desired data within the mapheader
+
+; outputs:
+; bc = data from the current map's header
+; (e.g., de = $0003 would return a pointer to the secondary map header)
+
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ ; fallthrough
+
+GetAnyMapHeaderMember: ; 0x2c0c
+ ; bankswitch
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(MapGroupPointers)
+ rst Bankswitch
+
+ call GetAnyMapHeaderPointer
+ add hl, de
+ ld c, [hl]
+ inc hl
+ ld b, [hl]
+
+ ; bankswitch back
+ pop af
+ rst Bankswitch
+ ret
+; 0x2c1c
+
+
+Function2c1c: ; 2c1c
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+; 2c24
+
+Function2c24: ; 2c24
+ call Function2c31
+ rst Bankswitch
+ ret
+; 2c29
+
+
+Function2c29: ; 2c29
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+; 2c31
+
+Function2c31: ; 2c31
+ push hl
+ push de
+ ld de, $0000
+ call GetAnyMapHeaderMember
+ ld a, c
+ pop de
+ pop hl
+ ret
+; 2c3d
+
+Function2c3d: ; 2c3d
+ ld a, [hROMBank]
+ push af
+ ld a, $25
+ rst Bankswitch
+ call GetMapHeaderPointer
+ ld de, $d198
+ ld bc, $0005
+ call CopyBytes
+ pop af
+ rst Bankswitch
+ ret
+; 2c52
+
+Function2c52: ; 2c52
+ ld a, [MapEventBank]
+ rst Bankswitch
+ ret
+; 2c57
+
+
+GetMapEventBank: ; 2c57
+ ld a, [MapEventBank]
+ ret
+; 2c5b
+
+GetAnyMapBlockdataBank: ; 2c5b
+; Return the blockdata bank for group b map c.
+ push hl
+ push de
+ push bc
+
+ push bc
+ ld de, 3 ; second map header pointer
+ call GetAnyMapHeaderMember
+ ld l, c
+ ld h, b
+ pop bc
+
+ push hl
+ ld de, 0 ; second map header bank
+ call GetAnyMapHeaderMember
+ pop hl
+
+ ld de, 3 ; blockdata bank
+ add hl, de
+ ld a, c
+ call GetFarByte
+ rst Bankswitch
+
+ pop bc
+ pop de
+ pop hl
+ ret
+; 2c7d
+
+GetSecondaryMapHeaderPointer: ; 0x2c7d
+; returns the current map's secondary map header pointer in hl.
+ push bc
+ push de
+ ld de, $0003 ; secondary map header pointer (offset within header)
+ call GetMapHeaderMember
+ ld l, c
+ ld h, b
+ pop de
+ pop bc
+ ret
+; 2c8a
+
+GetMapPermission: ; 2c8a
+ push hl
+ push de
+ push bc
+ ld de, 2
+ call GetMapHeaderMember
+ ld a, c
+ pop bc
+ pop de
+ pop hl
+ ret
+; 2c98
+
+Function2c98: ; 2c98
+ ret
+; 2c99
+
+Function2c99: ; 2c99
+ push hl
+ push de
+ push bc
+ ld de, $0002
+ call GetAnyMapHeaderMember
+ ld a, c
+ pop bc
+ pop de
+ pop hl
+ ret
+; 2ca7
+
+Function2ca7: ; 2ca7
+ ld de, $0001
+ call GetAnyMapHeaderMember
+ ld a, c
+ ret
+; 2caf
+
+GetWorldMapLocation: ; 0x2caf
+; given a map group/id in bc, return its location on the Pokégear map.
+ push hl
+ push de
+ push bc
+ ld de, 5
+ call GetAnyMapHeaderMember
+ ld a, c
+ pop bc
+ pop de
+ pop hl
+ ret
+; 0x2cbd
+
+Function2cbd: ; 2cbd
+ push hl
+ push bc
+ ld de, $0006
+ call GetMapHeaderMember
+ ld a, c
+ cp $64
+ jr z, .asm_2cee
+ bit 7, c
+ jr nz, .asm_2cda
+ ld a, $22
+ ld hl, $7342
+ rst FarCall
+ ld e, c
+ ld d, $0
+.asm_2cd7
+ pop bc
+ pop hl
+ ret
+
+.asm_2cda
+ ld a, [StatusFlags2]
+ bit 0, a
+ jr z, .asm_2ce6
+ ld de, $0056
+ jr .asm_2cd7
+
+.asm_2ce6
+ ld a, c
+ and $7f
+ ld e, a
+ ld d, $0
+ jr .asm_2cd7
+
+.asm_2cee
+ ld a, [StatusFlags2]
+ bit 7, a
+ jr z, .asm_2cfa
+ ld de, $0048
+ jr .asm_2cd7
+
+.asm_2cfa
+ ld de, $0026
+ jr .asm_2cd7
+; 2cff
+
+Function2cff: ; 2cff
+ call Function2d0d
+ and $f
+ ret
+; 2d05
+
+Function2d05: ; 2d05
+ call Function2d0d
+ and $f0
+ swap a
+ ret
+; 2d0d
+
+Function2d0d: ; 2d0d
+ push hl
+ push bc
+ ld de, $0007
+ call GetMapHeaderMember
+ ld a, c
+ pop bc
+ pop hl
+ ret
+; 2d19
+
+Function2d19: ; 2d19
+ push de
+ push hl
+ push bc
+ ld de, $0008
+ call GetMapHeaderMember
+ ld a, c
+ pop bc
+ pop hl
+ pop de
+ ret
+; 2d27
+
+Function2d27: ; 2d27
+ push hl
+ push bc
+ ld hl, $5596
+ ld bc, $000f
+ ld a, [$d199]
+ call AddNTimes
+ ld de, TilesetBank
+ ld bc, $000f
+ ld a, $13
+ call FarCopyBytes
+ pop bc
+ pop hl
+ ret
+; 2d43
+
--- /dev/null
+++ b/home/map_objects.asm
@@ -1,0 +1,683 @@
+; Functions handling map objects.
+
+
+GetSpritePalette: ; 17ff
+ push hl
+ push de
+ push bc
+ ld c, a
+ callba _GetSpritePalette
+ ld a, c
+ pop bc
+ pop de
+ pop hl
+ ret
+; 180e
+
+
+Function180e: ; 180e
+ push hl
+ push bc
+ ld hl, $d156
+ ld c, $1f
+ ld b, a
+ ld a, [hConnectionStripLength]
+ cp $0
+ jr z, .asm_182b
+ ld a, b
+.asm_181d
+ cp [hl]
+ jr z, .asm_1830
+ inc hl
+ inc hl
+ dec c
+ jr nz, .asm_181d
+ ld a, [$d155]
+ scf
+ jr .asm_1833
+
+.asm_182b
+ ld a, [$d155]
+ jr .asm_1833
+
+.asm_1830
+ inc hl
+ xor a
+ ld a, [hl]
+
+.asm_1833
+ pop bc
+ pop hl
+ ret
+; 1836
+
+Function1836: ; 1836
+ push de
+ push hl
+
+ ld b, a
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(Function142a7)
+ rst Bankswitch
+
+ ld a, b
+ call Function142a7
+ ld c, a
+
+ pop de
+ ld a, d
+ rst Bankswitch
+
+ pop hl
+ pop de
+ ret
+; 184a
+
+
+
+Function184a: ; 184a
+ ld a, [StandingTile]
+ call GetTileCollision
+ ld b, a
+ ret
+; 1852
+
+Function1852: ; 1852
+ ld a, [StandingTile]
+ call GetTileCollision
+ sub 1
+ ret z
+ and a
+ ret
+; 185d
+
+
+GetTileCollision: ; 185d
+; Get the collision type of tile a.
+
+ push de
+ push hl
+
+ ld hl, TileCollisionTable
+ ld e, a
+ ld d, 0
+ add hl, de
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(TileCollisionTable)
+ rst Bankswitch
+ ld e, [hl]
+ pop af
+ rst Bankswitch
+
+ ld a, e
+ and $f ; lo nybble only
+
+ pop hl
+ pop de
+ ret
+; 1875
+
+
+Function1875: ; 1875
+ ld d, a
+ and $f0
+ cp $10
+ jr z, .asm_1882
+ cp $20
+ jr z, .asm_1888
+ scf
+ ret
+
+.asm_1882
+ ld a, d
+ and 7
+ ret z
+ scf
+ ret
+
+.asm_1888
+ ld a, d
+ and 7
+ ret z
+ scf
+ ret
+; 188e
+
+Function188e: ; 188e
+ cp $14
+ ret z
+ cp $1c
+ ret
+; 1894
+
+CheckCutTreeTile: ; 1894
+ cp $12
+ ret z
+ cp $1a
+ ret
+; 189a
+
+CheckHeadbuttTreeTile: ; 189a
+ cp $15
+ ret z
+ cp $1d
+ ret
+; 18a0
+
+CheckCounterTile: ; 18a0
+ cp $90
+ ret z
+ cp $98
+ ret
+; 18a6
+
+CheckPitTile: ; 18a6
+ cp $60
+ ret z
+ cp $68
+ ret
+; 18ac
+
+CheckIceTile: ; 18ac
+ cp $23
+ ret z
+ cp $2b
+ ret z
+ scf
+ ret
+; 18b4
+
+CheckWhirlpoolTile: ; 18b4
+ nop
+ cp $24
+ ret z
+ cp $2c
+ ret z
+ scf
+ ret
+; 18bd
+
+CheckWaterfallTile: ; 18bd
+ cp $33
+ ret z
+ cp $3b
+ ret
+; 18c3
+
+CheckStandingOnEntrance: ; 18c3
+ ld a, [StandingTile]
+ cp $71 ; door
+ ret z
+ cp $79
+ ret z
+ cp $7a ; stairs
+ ret z
+ cp $7b ; cave
+ ret
+; 18d2
+
+
+GetMapObject: ; 18d2
+; Return the location of map object a in bc.
+ ld hl, MapObjects
+ ld bc, $10
+ call AddNTimes
+ ld b, h
+ ld c, l
+ ret
+; 18de
+
+
+Function18de: ; 18de
+ ld [hConnectionStripLength], a
+ call GetMapObject
+ ld hl, $0000
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ jr z, .asm_18f3
+ ld [hConnectedMapWidth], a
+ call Function1ae5
+ and a
+ ret
+
+.asm_18f3
+ scf
+ ret
+; 18f5
+
+Function18f5: ; 18f5
+ ld hl, $0006
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ jr nz, .asm_1921
+ ld hl, $0007
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ jr z, .asm_191c
+ ld hl, .data_191e
+ ld a, [TimeOfDay]
+ add l
+ ld l, a
+ jr nc, .asm_1912
+ inc h
+
+.asm_1912
+ ld a, [hl]
+ ld hl, $0007
+ add hl, bc
+ and [hl]
+ jr nz, .asm_191c
+ scf
+ ret
+
+.asm_191c
+ and a
+ ret
+
+.data_191e
+ db $1
+ db $2
+ db $4
+
+.asm_1921
+ ld hl, $0006
+ add hl, bc
+ ld d, [hl]
+ ld hl, $0007
+ add hl, bc
+ ld e, [hl]
+ ld hl, hHours
+ ld a, d
+ cp e
+ jr z, .asm_1949
+ jr c, .asm_193f
+ ld a, [hl]
+ cp d
+ jr nc, .asm_1949
+ cp e
+ jr c, .asm_1949
+ jr z, .asm_1949
+ jr .asm_194b
+
+.asm_193f
+ ld a, e
+ cp [hl]
+ jr c, .asm_194b
+ ld a, [hl]
+ cp d
+ jr nc, .asm_1949
+ jr .asm_194b
+
+.asm_1949
+ and a
+ ret
+
+.asm_194b
+ scf
+ ret
+; 194d
+
+Function194d: ; 194d
+ ld [hConnectionStripLength], a
+ call GetMapObject
+ call $40e7
+ ret
+; 1956
+
+
+
+Function1956: ; 1956
+ ld [hConnectionStripLength], a
+ call Function271e
+ ld a, [hConnectionStripLength]
+ call GetMapObject
+ ld a, $2
+ ld hl, $40e7
+ rst FarCall
+ ret
+; 1967
+
+Function1967: ; 1967
+ ld [hConnectionStripLength], a
+ call GetMapObject
+ ld hl, $0000
+ add hl, bc
+ ld a, [hl]
+ cp $ff
+ ret z
+ ld [hl], $ff
+ push af
+ call Function1985
+ pop af
+ call Function1ae5
+ callba Function4357
+ ret
+; 1985
+
+Function1985: ; 1985
+ ld hl, $d4cd
+ cp [hl]
+ jr z, .asm_1990
+ ld hl, $d4ce
+ cp [hl]
+ ret nz
+
+.asm_1990
+ callba Function581f
+ ld a, $ff
+ ld [$d4cd], a
+ ld [$d4ce], a
+ ret
+; 199f
+
+Function199f: ; 199f
+ call Function1967
+ call Function2712
+ ret
+; 19a6
+
+Function19a6: ; 19a6
+ push hl
+ call GetMapObject
+ ld d, b
+ ld e, c
+ ld a, $ff
+ ld [de], a
+ inc de
+ pop hl
+ ld bc, $000f
+ call CopyBytes
+ ret
+; 19b8
+
+Function19b8: ; 19b8
+ call GetMapObject
+ ld hl, $0000
+ add hl, bc
+ ld a, [hl]
+ push af
+ ld [hl], $ff
+ inc hl
+ ld bc, $000f
+ xor a
+ call ByteFill
+ pop af
+ cp $ff
+ ret z
+ cp $d
+ ret nc
+ ld b, a
+ ld a, [$d4cd]
+ cp b
+ jr nz, .asm_19de
+ ld a, $ff
+ ld [$d4cd], a
+
+.asm_19de
+ ld a, b
+ call Function1ae5
+ callba Function4357
+ ret
+; 19e9
+
+
+
+Function19e9: ; 19e9
+ ld [$c2e2], a
+ ld a, [hROMBank]
+ ld [$c2e3], a
+ ld a, l
+ ld [$c2e4], a
+ ld a, h
+ ld [$c2e5], a
+ ld a, [$c2e2]
+ call Function18de
+ ret c
+ ld hl, $0003
+ add hl, bc
+ ld [hl], $14
+ ld hl, $0009
+ add hl, bc
+ ld [hl], $0
+ ld hl, VramState
+ set 7, [hl]
+ and a
+ ret
+; 1a13
+
+
+
+Function1a13: ; 1a13
+ push bc
+ push de
+ ld hl, $d4d6
+ ld de, $0028
+ ld c, $d
+.asm_1a1d
+ ld a, [hl]
+ and a
+ jr z, .asm_1a28
+ add hl, de
+ dec c
+ jr nz, .asm_1a1d
+ xor a
+ jr .asm_1a2c
+
+.asm_1a28
+ ld a, $d
+ sub c
+ scf
+
+.asm_1a2c
+ pop de
+ pop bc
+ ret
+; 1a2f
+
+
+
+Function1a2f: ; 1a2f
+ ld hl, $0003
+ add hl, bc
+ ld a, [hl]
+ cp $25
+ jr c, .asm_1a39
+ xor a
+
+.asm_1a39
+ ld hl, Data4273
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, [hl]
+ ret
+; 1a47
+
+Function1a47: ; 1a47
+ push bc
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, Data4273 + 1
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ ld a, BANK(Data4273)
+ call GetFarByte
+ add a
+ add a
+ and $c
+ pop de
+ pop bc
+ ret
+; 1a61
+
+
+Function1a61: ; 1a61
+ ld l, a
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(Data4273)
+ rst Bankswitch
+ ld a, l
+ push bc
+
+ call Function1a71
+
+ pop bc
+ pop af
+ rst Bankswitch
+
+ ret
+; 1a71
+
+Function1a71: ; 1a71
+ ld hl, $0003
+ add hl, de
+ ld [hl], a
+ push de
+ ld e, a
+ ld d, 0
+ ld hl, Data4273 + 1
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ ld b, h
+ ld c, l
+ pop de
+ ld a, [bc]
+ inc bc
+ rlca
+ rlca
+ and $c
+ ld hl, $0008
+ add hl, de
+ ld [hl], a
+ ld a, [bc]
+ inc bc
+ ld hl, $000b
+ add hl, de
+ ld [hl], a
+ ld a, [bc]
+ inc bc
+ ld hl, $0004
+ add hl, de
+ ld [hl], a
+ ld a, [bc]
+ inc bc
+ ld hl, $0005
+ add hl, de
+ ld [hl], a
+ ld a, [bc]
+ inc bc
+ ld hl, $0006
+ add hl, de
+ ld [hl], a
+ ret
+; 1aae
+
+Function1aae: ; 1aae
+ ld a, [hROMBank]
+ push af
+ ld a, [hli]
+ rst Bankswitch
+
+ ld a, [hli]
+ ld d, [hl]
+ ld hl, $001b
+ add hl, bc
+ add [hl]
+ ld e, a
+ ld a, d
+ adc $0
+ ld d, a
+ inc [hl]
+ ld a, [de]
+ ld h, a
+ pop af
+ rst Bankswitch
+
+ ld a, h
+ ret
+; 1ac6
+
+Function1ac6: ; 1ac6
+ ld hl, VramState
+ set 0, [hl]
+ ret
+; 1acc
+
+Function1acc: ; 1acc
+ ld hl, VramState
+ res 0, [hl]
+ ret
+; 1ad2
+
+
+Function1ad2: ; 1ad2
+ ld a, [VramState]
+ bit 0, a
+ ret z
+ callba Function55e0
+ callba Function5920
+ ret
+; 1ae5
+
+
+Function1ae5: ; 1ae5
+ ld bc, $0028
+ ld hl, $d4d6
+ call AddNTimes
+ ld b, h
+ ld c, l
+ ret
+; 1af1
+
+Function1af1: ; 1af1
+ ld hl, $0000
+ add hl, bc
+ ld a, [hl]
+ and a
+ ret
+; 1af8
+
+Function1af8: ; 1af8
+ push af
+ ld hl, $0008
+ add hl, bc
+ ld a, [hl]
+ and $f3
+ ld e, a
+ pop af
+ and $c
+ or e
+ ld [hl], a
+ ret
+; 1b07
+
+
+GetSpriteDirection: ; 1b07
+ ld hl, $0008
+ add hl, bc
+ ld a, [hl]
+ and $c
+ ret
+; 1b0f
+
--- /dev/null
+++ b/home/math.asm
@@ -1,0 +1,76 @@
+SimpleMultiply: ; 3105
+; Return a * c.
+ and a
+ ret z
+
+ push bc
+ ld b, a
+ xor a
+.loop
+ add c
+ dec b
+ jr nz, .loop
+ pop bc
+ ret
+; 3110
+
+
+SimpleDivide: ; 3110
+; Divide a by c. Return quotient b and remainder a.
+ ld b, 0
+.loop
+ inc b
+ sub c
+ jr nc, .loop
+ dec b
+ add c
+ ret
+; 3119
+
+
+Multiply: ; 3119
+; Multiply hMultiplicand (3 bytes) by hMultiplier. Result in hProduct.
+; All values are big endian.
+ push hl
+ push bc
+
+ callab _Multiply
+
+ pop bc
+ pop hl
+ ret
+; 3124
+
+
+Divide: ; 3124
+; Divide hDividend length b (max 4 bytes) by hDivisor. Result in hQuotient.
+; All values are big endian.
+ push hl
+ push de
+ push bc
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_Divide)
+ rst Bankswitch
+
+ call _Divide
+
+ pop af
+ rst Bankswitch
+ pop bc
+ pop de
+ pop hl
+ ret
+; 3136
+
+
+SubtractSigned: ; 3136
+; Return a - b, sign in carry.
+ sub b
+ ret nc
+ cpl
+ add 1
+ scf
+ ret
+; 313d
+
--- /dev/null
+++ b/home/menu.asm
@@ -1,0 +1,603 @@
+; Functions used in displaying and handling menus.
+
+
+LoadMenuDataHeader: ; 0x1d35
+ call Function1d3c
+ call Function1c00
+ ret
+
+Function1d3c: ; 0x1d3c
+ ld de, $cf81
+ ld bc, $0010
+ call CopyBytes
+ ld a, [hROMBank]
+ ld [$cf8a], a
+ ret
+; 0x1d4b
+
+Function1d4b: ; 1d4b
+ ld [$cf88], a
+ ret
+; 1d4f
+
+
+Function1d4f: ; 1d4f
+ push hl
+ call Function1d58
+ pop hl
+ jp PrintText
+; 1d57
+
+Function1d57: ; 1d57
+ ret
+; 1d58
+
+Function1d58: ; 1d58
+ ld hl, MenuDataHeader_0x1d5f
+ call LoadMenuDataHeader
+ ret
+; 1d5f
+
+MenuDataHeader_0x1d5f: ; 1d5f
+ db $40 ; tile backup
+ db 12, 0 ; start coords
+ db 17, 19 ; end coords
+ dw VTiles0
+ db 0 ; default option
+; 1d67
+
+Function1d67: ; 1d67
+ call Function1d4f
+ call Function1c17
+ ret
+; 1d6e
+
+Function1d6e: ; 1d6e
+ ld hl, MenuDataHeader_0x1d75
+ call LoadMenuDataHeader
+ ret
+; 1d75
+
+MenuDataHeader_0x1d75: ; 1d75
+ db $40 ; tile backup
+ db 0, 0 ; start coords
+ db 17, 19 ; end coords
+ dw $0000
+ db 1 ; default option
+; 1d7d
+
+Function1d7d: ; 1d7d
+ call Function1c07
+ ret
+; 1d81
+
+Function1d81: ; 0x1d81
+ xor a
+ ld [hBGMapMode], a
+ call Function1cbb
+ call Function1ad2
+ call Function1c89
+ call Function321c
+ call Function1c66
+ ld a, [$cf91]
+ bit 7, a
+ jr z, .asm_1da7 ; 0x1d98 $d
+ call Function1c10
+ call Function1bc9
+ call Function1ff8
+ bit 1, a
+ jr z, .asm_1da9 ; 0x1da5 $2
+.asm_1da7
+ scf
+ ret
+.asm_1da9
+ and a
+ ret
+; 0x1dab
+
+Function1dab: ; 1dab
+ call LoadMenuDataHeader
+ call Function1d81
+ call Function1c17
+ ld a, [$cfa9]
+ ret
+; 1db8
+
+Function1db8: ; 0x1db8
+ push hl
+ push bc
+ push af
+ ld hl, $cf86
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ inc hl
+ inc hl
+ pop af
+ call GetNthString
+ ld d, h
+ ld e, l
+ call CopyName1
+ pop bc
+ pop hl
+ ret
+; 0x1dcf
+
+
+Function1dcf: ; 1dcf
+ ld bc, $0e07
+
+Function1dd2: ; 1dd2
+ jr Function1dd9
+
+Function1dd4: ; 1dd4
+ call LoadMenuDataHeader
+ jr Function1dfe
+
+Function1dd9: ; 1dd9
+ push bc
+ ld hl, MenuDataHeader_0x1e1d
+ call Function1d3c
+ pop bc
+ ld a, b
+ cp $e
+ jr nz, .asm_1de9
+ ld a, $e
+ ld b, a
+
+.asm_1de9
+ ld a, b
+ ld [$cf83], a
+ add $5
+ ld [$cf85], a
+ ld a, c
+ ld [$cf82], a
+ add $4
+ ld [$cf84], a
+ call Function1c00
+
+Function1dfe: ; 1dfe
+ call Function1d81
+ push af
+ ld c, $f
+ call DelayFrames
+ call Function1c17
+ pop af
+ jr c, .asm_1e16
+ ld a, [$cfa9]
+ cp $2
+ jr z, .asm_1e16
+ and a
+ ret
+
+.asm_1e16
+ ld a, $2
+ ld [$cfa9], a
+ scf
+ ret
+; 1e1d
+
+MenuDataHeader_0x1e1d: ; 1e1d
+ db $40 ; tile backup
+ db 5, 10 ; start coords
+ db 9, 15 ; end coords
+ dw MenuData2_0x1e25
+ db 1 ; default option
+; 1e25
+
+MenuData2_0x1e25: ; 1e25
+ db $c0 ; flags
+ db 2
+ db "YES@"
+ db "NO@"
+; 1e2e
+
+Function1e2e: ; 1e2e
+ call Function1e35
+ call Function1c00
+ ret
+; 1e35
+
+Function1e35: ; 1e35
+ push de
+ call Function1d3c
+ pop de
+ ld a, [$cf83]
+ ld h, a
+ ld a, [$cf85]
+ sub h
+ ld h, a
+ ld a, d
+ ld [$cf83], a
+ add h
+ ld [$cf85], a
+ ld a, [$cf82]
+ ld l, a
+ ld a, [$cf84]
+ sub l
+ ld l, a
+ ld a, e
+ ld [$cf82], a
+ add l
+ ld [$cf84], a
+ ret
+; 1e5d
+
+Function1e5d: ; 1e5d
+ call MenuFunc_1e7f
+ call MenuWriteText
+ call Function1eff
+ call Function1f23
+ call Function1bdd
+ call Function1ff8
+ ret
+; 1e70
+
+SetUpMenu: ; 1e70
+ call MenuFunc_1e7f ; ???
+ call MenuWriteText
+ call Function1eff ; set up selection pointer
+ ld hl, $cfa5
+ set 7, [hl]
+ ret
+
+MenuFunc_1e7f: ; 0x1e7f
+ call Function1c66
+ call Function1ebd
+ call Function1ea6
+ call Function1cbb
+ ret
+
+MenuWriteText: ; 0x1e8c
+ xor a
+ ld [hBGMapMode], a
+ call Function1ebd ; sort out the text
+ call Function1eda ; actually write it
+ call Function2e31
+ ld a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ld [hOAMUpdate], a
+ call Function321c
+ pop af
+ ld [hOAMUpdate], a
+ ret
+; 0x1ea6
+
+Function1ea6: ; 1ea6
+ ld a, [$cf83]
+ ld c, a
+ ld a, [$cf85]
+ sub c
+ ld c, a
+ ld a, [$cf92]
+ add a
+ inc a
+ ld b, a
+ ld a, [$cf82]
+ add b
+ ld [$cf84], a
+ ret
+; 1ebd
+
+Function1ebd: ; 1ebd
+ ld hl, $cf93
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [$cf76]
+ and a
+ jr z, .asm_1ed3
+ ld b, a
+ ld c, $ff
+.asm_1ecc
+ ld a, [hli]
+ cp c
+ jr nz, .asm_1ecc
+ dec b
+ jr nz, .asm_1ecc
+
+.asm_1ed3
+ ld d, h
+ ld e, l
+ ld a, [hl]
+ ld [$cf92], a
+ ret
+; 1eda
+
+Function1eda: ; 1eda
+ call Function1cfd
+ ld bc, $002a
+ add hl, bc
+.asm_1ee1
+ inc de
+ ld a, [de]
+ cp $ff
+ ret z
+ ld [MenuSelection], a
+ push de
+ push hl
+ ld d, h
+ ld e, l
+ ld hl, $cf95
+ call Function1efb
+ pop hl
+ ld de, $0028
+ add hl, de
+ pop de
+ jr .asm_1ee1
+; 1efb
+
+Function1efb: ; 1efb
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 1eff
+
+Function1eff: ; 1eff
+ call Function1c10
+ ld hl, $cfa8
+ ld a, [$cf91]
+ bit 3, a
+ jr z, .asm_1f0e
+ set 3, [hl]
+
+.asm_1f0e
+ ld a, [$cf91]
+ bit 2, a
+ jr z, .asm_1f19
+ set 5, [hl]
+ set 4, [hl]
+
+.asm_1f19
+ ret
+; 1f1a
+
+
+Function1f1a: ; 1f1a
+ call Function1bd3
+ ld hl, $cfa8
+ and [hl]
+ jr Function1f2a
+; 1f23
+
+Function1f23: ; 1f23
+ xor a
+ ld [$cf73], a
+ call Function1bc9
+; 1f2a
+
+Function1f2a: ; 1f2a
+ bit 0, a
+ jr nz, .asm_1f52
+ bit 1, a
+ jr nz, .asm_1f6d
+ bit 3, a
+ jr nz, .asm_1f6d
+ bit 4, a
+ jr nz, .asm_1f44
+ bit 5, a
+ jr nz, .asm_1f4b
+ xor a
+ ld [$cf73], a
+ jr .asm_1f57
+
+.asm_1f44
+ ld a, $10
+ ld [$cf73], a
+ jr .asm_1f57
+
+.asm_1f4b
+ ld a, $20
+ ld [$cf73], a
+ jr .asm_1f57
+
+.asm_1f52
+ ld a, $1
+ ld [$cf73], a
+
+.asm_1f57
+ call Function1ebd
+ ld a, [$cfa9]
+ ld l, a
+ ld h, $0
+ add hl, de
+ ld a, [hl]
+ ld [MenuSelection], a
+ ld a, [$cfa9]
+ ld [$cf88], a
+ and a
+ ret
+
+.asm_1f6d
+ ld a, $2
+ ld [$cf73], a
+ ld a, $ff
+ ld [MenuSelection], a
+ scf
+ ret
+; 1f79
+
+Function1f79: ; 1f79
+ push de
+ ld hl, $cf97
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [MenuSelection]
+ call GetNthString
+ ld d, h
+ ld e, l
+ pop hl
+ call PlaceString
+ ret
+; 1f8d
+
+Function1f8d: ; 1f8d
+ push de
+ ld a, [MenuSelection]
+ call Function1fb1
+ inc hl
+ inc hl
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ pop hl
+ call PlaceString
+ ret
+; 1f9e
+
+Function1f9e: ; 1f9e
+ call Function1fb1
+ inc hl
+ inc hl
+ ld a, [hli]
+ ld d, [hl]
+ ld e, a
+ ret
+; 1fa7
+
+Function1fa7: ; 1fa7
+ ld a, [MenuSelection]
+ call Function1fb1
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 1fb1
+
+Function1fb1: ; 1fb1
+ ld e, a
+ ld d, $0
+ ld hl, $cf97
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ add hl, de
+ add hl, de
+ add hl, de
+ add hl, de
+ ret
+; 1fbf
+
+Function1fbf: ; 1fbf
+ ld hl, $cf71
+ call Function1ff0
+ ld hl, $cf81
+ call Function1ff0
+ ld hl, $cf91
+ call Function1ff0
+ ld hl, $cfa1
+ call Function1ff0
+ ld a, [rSVBK]
+ push af
+ ld a, $7
+ ld [rSVBK], a
+ xor a
+ ld hl, $dfff
+ ld [hld], a
+ ld [hld], a
+ ld a, l
+ ld [$cf71], a
+ ld a, h
+ ld [$cf72], a
+ pop af
+ ld [rSVBK], a
+ ret
+; 1ff0
+
+Function1ff0: ; 1ff0
+ ld bc, $0010
+ xor a
+ call ByteFill
+ ret
+; 1ff8
+
+Function1ff8: ; 1ff8
+ push af
+ and $3
+ jr z, .asm_2007
+ ld hl, $cf81
+ bit 3, [hl]
+ jr nz, .asm_2007
+ call PlayClickSFX
+
+.asm_2007
+ pop af
+ ret
+; 2009
+
+
+PlayClickSFX: ; 2009
+ push de
+ ld de, SFX_READ_TEXT_2
+ call StartSFX
+ pop de
+ ret
+; 0x2012
+
+Function2012: ; 2012
+ call Function1d4f
+ call Functiona46
+ call Function1c07
+ ret
+; 201c
+
+Function201c: ; 201c
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+ call PlaceString
+ pop af
+ rst Bankswitch
+
+ ret
+; 202a
+
+Function202a: ; 202a
+ ld a, [hROMBank]
+ ld [$cf94], a
+ ld a, $9
+ ld hl, $400e
+ rst FarCall
+ ld a, [$cf88]
+ ret
+; 2039
+
+Function2039: ; 2039
+ ld a, [hROMBank]
+ ld [$cf94], a
+ ld a, $9
+ ld hl, $4022
+ rst FarCall
+ ld a, [$cf88]
+ ret
+; 2048
+
+Function2048: ; 2048
+ ld a, [hROMBank]
+ ld [$cf94], a
+ ld a, $9
+ ld hl, $403c
+ rst FarCall
+ ld a, [$cf88]
+ ret
+; 2057
+
+Function2057: ; 2057
+ ld a, [hROMBank]
+ push af
+ ld a, $21
+ rst Bankswitch
+
+ call $42db
+ pop af
+ rst Bankswitch
+
+ ret
+; 2063
+
--- /dev/null
+++ b/home/palettes.asm
@@ -1,0 +1,347 @@
+; Functions dealing with palettes.
+
+
+UpdatePalsIfCGB: ; c2f
+; update bgp data from BGPals
+; update obp data from OBPals
+; return carry if successful
+
+; check cgb
+ ld a, [hCGB]
+ and a
+ ret z
+
+
+UpdateCGBPals: ; c33
+; return carry if successful
+; any pals to update?
+ ld a, [hCGBPalUpdate]
+ and a
+ ret z
+
+
+ForceUpdateCGBPals: ; c37
+
+ ld a, [rSVBK]
+ push af
+ ld a, 5 ; BANK(BGPals)
+ ld [rSVBK], a
+
+ ld hl, BGPals ; 5:d080
+
+; copy 8 pals to bgpd
+ ld a, %10000000 ; auto increment, index 0
+ ld [rBGPI], a
+ ld c, rBGPD % $100
+ ld b, 4 ; NUM_PALS / 2
+.bgp
+ rept $10
+ ld a, [hli]
+ ld [$ff00+c], a
+ endr
+
+ dec b
+ jr nz, .bgp
+
+; hl is now 5:d0c0 OBPals
+
+; copy 8 pals to obpd
+ ld a, %10000000 ; auto increment, index 0
+ ld [rOBPI], a
+ ld c, rOBPD - rJOYP
+ ld b, 4 ; NUM_PALS / 2
+.obp
+ rept $10
+ ld a, [hli]
+ ld [$ff00+c], a
+ endr
+
+ dec b
+ jr nz, .obp
+
+ pop af
+ ld [rSVBK], a
+
+; clear pal update queue
+ xor a
+ ld [hCGBPalUpdate], a
+
+ scf
+ ret
+; c9f
+
+
+DmgToCgbBGPals: ; c9f
+; exists to forego reinserting cgb-converted image data
+
+; input: a -> bgp
+
+ ld [rBGP], a
+ push af
+
+ ld a, [hCGB]
+ and a
+ jr z, .end
+
+ push hl
+ push de
+ push bc
+ ld a, [rSVBK]
+ push af
+
+ ld a, 5
+ ld [rSVBK], a
+
+; copy & reorder bg pal buffer
+ ld hl, BGPals ; to
+ ld de, Unkn1Pals ; from
+; order
+ ld a, [rBGP]
+ ld b, a
+; all pals
+ ld c, 8
+ call CopyPals
+; request pal update
+ ld a, 1
+ ld [hCGBPalUpdate], a
+
+ pop af
+ ld [rSVBK], a
+ pop bc
+ pop de
+ pop hl
+.end
+ pop af
+ ret
+; ccb
+
+
+DmgToCgbObjPals: ; ccb
+; exists to forego reinserting cgb-converted image data
+
+; input: d -> obp1
+; e -> obp2
+
+ ld a, e
+ ld [rOBP0], a
+ ld a, d
+ ld [rOBP1], a
+
+ ld a, [hCGB]
+ and a
+ ret z
+
+ push hl
+ push de
+ push bc
+ ld a, [rSVBK]
+ push af
+
+ ld a, 5
+ ld [rSVBK], a
+
+; copy & reorder obj pal buffer
+ ld hl, OBPals ; to
+ ld de, Unkn2Pals ; from
+; order
+ ld a, [rOBP0]
+ ld b, a
+; all pals
+ ld c, 8
+ call CopyPals
+; request pal update
+ ld a, 1
+ ld [hCGBPalUpdate], a
+
+ pop af
+ ld [rSVBK], a
+ pop bc
+ pop de
+ pop hl
+ ret
+; cf8
+
+
+Functioncf8: ; cf8
+ ld [rOBP0], a
+ push af
+ ld a, [hCGB]
+ and a
+ jr z, .asm_d22
+ push hl
+ push de
+ push bc
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, $d0c0
+ ld de, MartPointer
+ ld a, [rOBP0]
+ ld b, a
+ ld c, $1
+ call CopyPals
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ pop af
+ ld [rSVBK], a
+ pop bc
+ pop de
+ pop hl
+
+.asm_d22
+ pop af
+ ret
+; d24
+
+Functiond24: ; d24
+ ld [rOBP1], a
+ push af
+ ld a, [hCGB]
+ and a
+ jr z, .asm_d4e
+ push hl
+ push de
+ push bc
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, $d0c8
+ ld de, $d048
+ ld a, [rOBP1]
+ ld b, a
+ ld c, $1
+ call CopyPals
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ pop af
+ ld [rSVBK], a
+ pop bc
+ pop de
+ pop hl
+
+.asm_d4e
+ pop af
+ ret
+; d50
+
+
+
+CopyPals: ; d50
+; copy c palettes in order b from de to hl
+
+ push bc
+ ld c, 4 ; NUM_PAL_COLORS
+.loop
+ push de
+ push hl
+
+; get pal color
+ ld a, b
+ and %11 ; color
+; 2 bytes per color
+ add a
+ ld l, a
+ ld h, 0
+ add hl, de
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+
+; dest
+ pop hl
+; write color
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ inc hl
+; next pal color
+ srl b
+ srl b
+; source
+ pop de
+; done pal?
+ dec c
+ jr nz, .loop
+
+; de += 8 (next pal)
+ ld a, 8 ; NUM_PAL_COLORS * 2 ; bytes per pal
+ add e
+ jr nc, .ok
+ inc d
+.ok
+ ld e, a
+
+; how many more pals?
+ pop bc
+ dec c
+ jr nz, CopyPals
+ ret
+; d79
+
+
+Functiond79: ; d79
+ ld a, [hCGB]
+ and a
+ ret z
+ ld a, 1
+ ld [rVBK], a
+ ld hl, VTiles0
+ ld bc, $2000
+ xor a
+ call ByteFill
+ ld a, 0
+ ld [rVBK], a
+ ret
+; d90
+
+
+Functiond90: ; d90
+ ret
+; d91
+
+
+Functiond91: ; d91
+ ld a, [hCGB]
+ and a
+ ret z
+ ld a, [rSVBK]
+ push af
+ ld a, 5 ; BANK(BGPals)
+ ld [rSVBK], a
+ ld hl, BGPals
+ ld bc, $40 + $10
+ xor a
+ call ByteFill
+ pop af
+ ld [rSVBK], a
+ ld a, 1
+ ld [hCGBPalUpdate], a
+ call DelayFrame
+ ret
+; db1
+
+
+Functiondb1: ; db1
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(Function4c000)
+ rst Bankswitch
+ call Function4c000
+ pop af
+ rst Bankswitch
+ ret
+; dbd
+
+Functiondbd: ; dbd
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(Function4c03f)
+ rst Bankswitch
+ call Function4c03f
+ pop af
+ rst Bankswitch
+ ret
+; dc9
+
--- /dev/null
+++ b/home/predef.asm
@@ -1,0 +1,54 @@
+Predef: ; 2d83
+; Call predefined function a.
+; Preserves bc, de, hl and f.
+
+ ld [PredefID], a
+ ld a, [hROMBank]
+ push af
+
+ ld a, BANK(GetPredefPointer)
+ rst Bankswitch
+ call GetPredefPointer ; stores hl in PredefTemp
+
+; Switch to the new function's bank
+ rst Bankswitch
+
+; Instead of directly calling stuff,
+; push it to the stack in reverse.
+
+ ld hl, .Return
+ push hl
+
+; Call the Predef function
+ ld a, [PredefAddress]
+ ld h, a
+ ld a, [PredefAddress + 1]
+ ld l, a
+ push hl
+
+; Get hl back
+ ld a, [PredefTemp]
+ ld h, a
+ ld a, [PredefTemp + 1]
+ ld l, a
+ ret
+
+.Return
+; Clean up after the Predef call
+
+ ld a, h
+ ld [PredefTemp], a
+ ld a, l
+ ld [PredefTemp+1], a
+
+ pop hl
+ ld a, h
+ rst Bankswitch
+
+ ld a, [PredefTemp]
+ ld h, a
+ ld a, [PredefTemp + 1]
+ ld l, a
+ ret
+; 2dba
+
--- /dev/null
+++ b/home/random.asm
@@ -1,0 +1,76 @@
+Random: ; 2f8c
+; A simple hardware-based random number generator (RNG).
+
+; Two random numbers are generated by adding and subtracting
+; the divider to the respective values every time it's called.
+
+; The divider is a register that increments at a rate of 16384Hz.
+; For comparison, the Game Boy operates at a clock speed of 4.2MHz.
+
+; Additionally, an equivalent function is executed in VBlank.
+
+; This leaves a with the value in hRandomSub.
+
+ push bc
+
+ ld a, [rDIV]
+ ld b, a
+ ld a, [hRandomAdd]
+ adc b
+ ld [hRandomAdd], a
+
+ ld a, [rDIV]
+ ld b, a
+ ld a, [hRandomSub]
+ sbc b
+ ld [hRandomSub], a
+
+ pop bc
+ ret
+; 2f9f
+
+BattleRandom: ; 2f9f
+; _BattleRandom lives in another bank.
+
+; It handles all RNG calls in the battle engine, allowing
+; link battles to remain in sync using a shared PRNG.
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_BattleRandom)
+ rst Bankswitch
+
+ call _BattleRandom
+
+ ld [$cfb6], a
+ pop af
+ rst Bankswitch
+ ld a, [$cfb6]
+ ret
+; 2fb1
+
+
+Function2fb1: ; 2fb1
+ push bc
+ ld c, a
+ xor a
+ sub c
+.asm_2fb5
+ sub c
+ jr nc, .asm_2fb5
+ add c
+ ld b, a
+ push bc
+.asm_2fbb
+ call Random
+ ld a, [hRandomAdd]
+ ld c, a
+ add b
+ jr c, .asm_2fbb
+ ld a, c
+ pop bc
+ call SimpleDivide
+ pop bc
+ ret
+; 2fcb
+
--- /dev/null
+++ b/home/rtc.asm
@@ -1,0 +1,25 @@
+RTC: ; 46f
+; update time and time-sensitive palettes
+
+; rtc enabled?
+ ld a, [$c2ce]
+ cp 0
+ ret z
+
+ call UpdateTime
+
+; obj update on?
+ ld a, [VramState]
+ bit 0, a ; obj update
+ ret z
+
+TimeOfDayPals: ; 47e
+ callab _TimeOfDayPals
+ ret
+; 485
+
+UpdateTimePals: ; 485
+ callab _UpdateTimePals
+ ret
+; 48c
+
--- /dev/null
+++ b/home/serial.asm
@@ -1,0 +1,408 @@
+Serial: ; 6ef
+; The serial interrupt.
+
+ push af
+ push bc
+ push de
+ push hl
+
+ ld a, [$ffc9]
+ and a
+ jr nz, .asm_71c
+
+ ld a, [$c2d4]
+ bit 0, a
+ jr nz, .asm_721
+
+ ld a, [$ffcb]
+ inc a
+ jr z, .asm_726
+
+ ld a, [rSB]
+ ld [hSerialReceive], a
+
+ ld a, [hSerialSend]
+ ld [rSB], a
+
+ ld a, [$ffcb]
+ cp $2
+ jr z, .asm_752
+
+ ld a, 0 << rSC_ON
+ ld [rSC], a
+ ld a, 1 << rSC_ON
+ ld [rSC], a
+ jr .asm_752
+
+.asm_71c
+ call Function3e80
+ jr .asm_75a
+
+.asm_721
+ call Function2057
+ jr .asm_75a
+
+.asm_726
+ ld a, [rSB]
+ cp $1
+ jr z, .asm_730
+ cp $2
+ jr nz, .asm_752
+
+.asm_730
+ ld [hSerialReceive], a
+ ld [$ffcb], a
+ cp $2
+ jr z, .asm_74f
+
+ xor a
+ ld [rSB], a
+ ld a, $3
+ ld [rDIV], a
+
+.asm_73f
+ ld a, [rDIV]
+ bit 7, a
+ jr nz, .asm_73f
+
+ ld a, 0 << rSC_ON
+ ld [rSC], a
+ ld a, 1 << rSC_ON
+ ld [rSC], a
+ jr .asm_752
+
+.asm_74f
+ xor a
+ ld [rSB], a
+
+.asm_752
+ ld a, $1
+ ld [$ffca], a
+ ld a, $fe
+ ld [hSerialSend], a
+
+.asm_75a
+ pop hl
+ pop de
+ pop bc
+ pop af
+ reti
+; 75f
+
+Function75f: ; 75f
+ ld a, $1
+ ld [$ffcc], a
+.asm_763
+ ld a, [hl]
+ ld [hSerialSend], a
+ call Function78a
+ push bc
+ ld b, a
+ inc hl
+ ld a, $30
+.asm_76e
+ dec a
+ jr nz, .asm_76e
+ ld a, [$ffcc]
+ and a
+ ld a, b
+ pop bc
+ jr z, .asm_782
+ dec hl
+ cp $fd
+ jr nz, .asm_763
+ xor a
+ ld [$ffcc], a
+ jr .asm_763
+
+.asm_782
+ ld [de], a
+ inc de
+ dec bc
+ ld a, b
+ or c
+ jr nz, .asm_763
+ ret
+; 78a
+
+Function78a: ; 78a
+ xor a
+ ld [$ffca], a
+ ld a, [$ffcb]
+ cp $2
+ jr nz, .asm_79b
+ ld a, $1
+ ld [rSC], a
+ ld a, $81
+ ld [rSC], a
+
+.asm_79b
+ ld a, [$ffca]
+ and a
+ jr nz, .asm_7e5
+ ld a, [$ffcb]
+ cp $1
+ jr nz, .asm_7c0
+ call Function82b
+ jr z, .asm_7c0
+ call .asm_825
+ push hl
+ ld hl, $cf5c
+ inc [hl]
+ jr nz, .asm_7b7
+ dec hl
+ inc [hl]
+
+.asm_7b7
+ pop hl
+ call Function82b
+ jr nz, .asm_79b
+ jp Function833
+
+.asm_7c0
+ ld a, [rIE]
+ and $f
+ cp $8
+ jr nz, .asm_79b
+ ld a, [$cf5d]
+ dec a
+ ld [$cf5d], a
+ jr nz, .asm_79b
+ ld a, [$cf5e]
+ dec a
+ ld [$cf5e], a
+ jr nz, .asm_79b
+ ld a, [$ffcb]
+ cp $1
+ jr z, .asm_7e5
+ ld a, $ff
+.asm_7e2
+ dec a
+ jr nz, .asm_7e2
+
+.asm_7e5
+ xor a
+ ld [$ffca], a
+ ld a, [rIE]
+ and $f
+ sub $8
+ jr nz, .asm_7f8
+ ld [$cf5d], a
+ ld a, $50
+ ld [$cf5e], a
+
+.asm_7f8
+ ld a, [hSerialReceive]
+ cp $fe
+ ret nz
+ call Function82b
+ jr z, .asm_813
+ push hl
+ ld hl, $cf5c
+ ld a, [hl]
+ dec a
+ ld [hld], a
+ inc a
+ jr nz, .asm_80d
+ dec [hl]
+
+.asm_80d
+ pop hl
+ call Function82b
+ jr z, Function833
+
+.asm_813
+ ld a, [rIE]
+ and $f
+ cp $8
+ ld a, $fe
+ ret z
+ ld a, [hl]
+ ld [hSerialSend], a
+ call DelayFrame
+ jp Function78a
+
+.asm_825
+ ld a, $f
+.asm_827
+ dec a
+ jr nz, .asm_827
+ ret
+; 82b
+
+Function82b: ; 82b
+ push hl
+ ld hl, $cf5b
+ ld a, [hli]
+ or [hl]
+ pop hl
+ ret
+; 833
+
+Function833: ; 833
+ dec a
+ ld [$cf5b], a
+ ld [$cf5c], a
+ ret
+; 83b
+
+Function83b: ; 83b
+ ld hl, $cf56
+ ld de, $cf51
+ ld c, $2
+ ld a, $1
+ ld [$ffcc], a
+.asm_847
+ call DelayFrame
+ ld a, [hl]
+ ld [hSerialSend], a
+ call Function78a
+ ld b, a
+ inc hl
+ ld a, [$ffcc]
+ and a
+ ld a, $0
+ ld [$ffcc], a
+ jr nz, .asm_847
+ ld a, b
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_847
+ ret
+; 862
+
+Function862: ; 862
+ call Function309d
+ callab Function4000
+ call Function87d
+ jp Function30b4
+; 871
+
+
+Function871: ; 871
+ call Function309d
+ callab Function4000
+ jp Function87d
+; 87d
+
+
+
+Function87d: ; 87d
+ ld a, $ff
+ ld [$cf52], a
+.asm_882
+ call Function8c1
+ call DelayFrame
+ call Function82b
+ jr z, .asm_89e
+ push hl
+ ld hl, $cf5c
+ dec [hl]
+ jr nz, .asm_89d
+ dec hl
+ dec [hl]
+ jr nz, .asm_89d
+ pop hl
+ xor a
+ jp Function833
+
+.asm_89d
+ pop hl
+
+.asm_89e
+ ld a, [$cf52]
+ inc a
+ jr z, .asm_882
+ ld b, $a
+.asm_8a6
+ call DelayFrame
+ call Function8c1
+ dec b
+ jr nz, .asm_8a6
+ ld b, $a
+.asm_8b1
+ call DelayFrame
+ call Function908
+ dec b
+ jr nz, .asm_8b1
+ ld a, [$cf52]
+ ld [$cf51], a
+ ret
+; 8c1
+
+Function8c1: ; 8c1
+ push bc
+ ld b, $60
+ ld a, [InLinkBattle]
+ cp $1
+ jr z, .asm_8d7
+ ld b, $60
+ jr c, .asm_8d7
+ cp $2
+ ld b, $70
+ jr z, .asm_8d7
+ ld b, $80
+
+.asm_8d7
+ call Function8f3
+ ld a, [$cf56]
+ add b
+ ld [hSerialSend], a
+ ld a, [$ffcb]
+ cp $2
+ jr nz, .asm_8ee
+ ld a, $1
+ ld [rSC], a
+ ld a, $81
+ ld [rSC], a
+
+.asm_8ee
+ call Function8f3
+ pop bc
+ ret
+; 8f3
+
+Function8f3: ; 8f3
+ ld a, [hSerialReceive]
+ ld [$cf51], a
+ and $f0
+ cp b
+ ret nz
+ xor a
+ ld [hSerialReceive], a
+ ld a, [$cf51]
+ and $f
+ ld [$cf52], a
+ ret
+; 908
+
+Function908: ; 908
+ xor a
+ ld [hSerialSend], a
+ ld a, [$ffcb]
+ cp $2
+ ret nz
+ ld a, $1
+ ld [rSC], a
+ ld a, $81
+ ld [rSC], a
+ ret
+; 919
+
+Function919: ; 919
+ ld a, [InLinkBattle]
+ and a
+ ret nz
+ ld a, $2
+ ld [rSB], a
+ xor a
+ ld [hSerialReceive], a
+ ld a, $0
+ ld [rSC], a
+ ld a, $80
+ ld [rSC], a
+ ret
+; 92e
+
+
--- /dev/null
+++ b/home/sine.asm
@@ -1,0 +1,22 @@
+Cosine: ; 1b0f
+; Return d * cos(a) in hl
+ add $10 ; 90 degrees
+
+Sine: ; 1b11
+; Return d * sin(a) in hl
+; a is a signed 6-bit value.
+
+ ld e, a
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_Sine)
+ rst Bankswitch
+
+ call _Sine
+
+ pop af
+ rst Bankswitch
+ ret
+; 1b1e
+
--- /dev/null
+++ b/home/sram.asm
@@ -1,0 +1,34 @@
+GetSRAMBank: ; 2fcb
+; load sram bank a
+; if invalid bank, sram is disabled
+ cp NUM_SRAM_BANKS
+ jr c, OpenSRAM
+ jr CloseSRAM
+; 2fd1
+
+OpenSRAM: ; 2fd1
+; switch to sram bank a
+ push af
+; latch clock data
+ ld a, 1
+ ld [MBC3LatchClock], a
+; enable sram/clock write
+ ld a, SRAM_ENABLE
+ ld [MBC3SRamEnable], a
+; select sram bank
+ pop af
+ ld [MBC3SRamBank], a
+ ret
+; 2fe1
+
+CloseSRAM: ; 2fe1
+ push af
+ ld a, SRAM_DISABLE
+; reset clock latch for next time
+ ld [MBC3LatchClock], a
+; disable sram/clock write
+ ld [MBC3SRamEnable], a
+ pop af
+ ret
+; 2fec
+
--- /dev/null
+++ b/home/string.asm
@@ -1,0 +1,39 @@
+InitString: ; 2ef6
+; Init a string of length c.
+ push hl
+ jr _InitString
+; 2ef9
+
+InitName: ; 2ef9
+; Intended for names, so this function is limited to ten characters.
+ push hl
+ ld c, 10
+; 2efc
+
+_InitString: ; 2efc
+; if the string pointed to by hl is empty (defined as "zero or more spaces
+; followed by a null"), then initialize it to the string pointed to by de.
+ push bc
+.loop
+ ld a, [hli]
+ cp "@"
+ jr z, .blank
+ cp " "
+ jr nz, .notblank
+ dec c
+ jr nz, .loop
+.blank
+ pop bc
+ ld l, e
+ ld h, d
+ pop de
+ ld b, 0
+ inc c
+ call CopyBytes
+ ret
+.notblank
+ pop bc
+ pop hl
+ ret
+; 2f17
+
--- /dev/null
+++ b/home/text.asm
@@ -1,0 +1,1230 @@
+ClearBox: ; fb6
+; Fill a c*b box at hl with blank tiles.
+
+ ld a, " "
+.y
+ push bc
+ push hl
+.x
+ ld [hli], a
+ dec c
+ jr nz, .x
+ pop hl
+ ld bc, 20 ; screen width
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .y
+ ret
+; fc8
+
+
+ClearTileMap: ; fc8
+; Fill TileMap with blank tiles.
+
+ ld hl, TileMap
+ ld a, " "
+ ld bc, 360 ; screen dimensions 20*18
+ call ByteFill
+
+; We aren't done if the LCD is on.
+ ld a, [rLCDC]
+ bit 7, a
+ ret z
+ jp WaitBGMap
+; fdb
+
+
+Functionfdb: ; fdb
+ ld a, $7
+ ld hl, AttrMap
+ ld bc, $0168
+ call ByteFill
+ jr ClearTileMap
+; fe8
+
+
+
+TextBox: ; fe8
+; Draw a text box width c height b at hl
+; Dimensions do not include the border.
+ push bc
+ push hl
+ call TextBoxBorder
+ pop hl
+ pop bc
+ jr TextBoxPalette
+; ff1
+
+
+TextBoxBorder: ; ff1
+
+; Top
+ push hl
+ ld a, "┌"
+ ld [hli], a
+ inc a ; "─"
+ call NPlaceChar
+ inc a ; "┐"
+ ld [hl], a
+
+; Middle
+ pop hl
+ ld de, 20 ; screen width
+ add hl, de
+.PlaceRow
+ push hl
+ ld a, "│"
+ ld [hli], a
+ ld a, " "
+ call NPlaceChar
+ ld [hl], "│"
+ pop hl
+ ld de, 20 ; screen width
+ add hl, de
+ dec b
+ jr nz, .PlaceRow
+
+; Bottom
+ ld a, "└"
+ ld [hli], a
+ ld a, "─"
+ call NPlaceChar
+ ld [hl], "┘"
+
+ ret
+; 101e
+
+
+NPlaceChar: ; 101e
+; Place char a c times
+ ld d,c
+.loop
+ ld [hli],a
+ dec d
+ jr nz, .loop
+ ret
+; 1024
+
+
+TextBoxPalette: ; 1024
+; Fill text box width c height b at hl with pal 7
+ ld de, AttrMap - TileMap
+ add hl, de
+ inc b
+ inc b
+ inc c
+ inc c
+ ld a, 7 ; pal
+.gotoy
+ push bc
+ push hl
+.gotox
+ ld [hli], a
+ dec c
+ jr nz, .gotox
+ pop hl
+ ld de, 20 ; screen width
+ add hl, de
+ pop bc
+ dec b
+ jr nz, .gotoy
+ ret
+; 103e
+
+
+SpeechTextBox: ; 103e
+; Standard textbox.
+ hlcoord 0, 12
+ ld b, 4 ; height
+ ld c, 18 ; screen width - 2 (border)
+ jp TextBox
+; 1048
+
+UnknownText_0x1048: ; 1048
+ db $0, "ゲームフりーク!", $57
+; 1052
+
+Function1052: ; 1052
+ ld hl, .text_1056
+ ret
+.text_1056
+ db "@"
+; 1057
+
+
+PrintText: ; 1057
+ call Function106c
+Function105a: ; 105a
+ push hl
+ hlcoord 1, 14
+ ld bc, 18 + 3<<8
+ call ClearBox
+ pop hl
+
+PrintTextBoxText: ; 1065
+ bccoord 1, 14
+ call Function13e5
+ ret
+; 106c
+
+
+Function106c: ; 106c
+ push hl
+ call SpeechTextBox
+ call Function1ad2
+ call Function321c
+ pop hl
+ ret
+; 1078
+
+
+
+PlaceString: ; 1078
+ push hl
+
+PlaceNextChar: ; 1079
+ ld a, [de]
+ cp "@"
+ jr nz, CheckDict
+ ld b, h
+ ld c, l
+ pop hl
+ ret
+ pop de
+
+NextChar: ; 1083
+ inc de
+ jp PlaceNextChar
+
+CheckDict: ; 1087
+ cp $15
+ jp z, Function117b
+ cp $4f
+ jp z, Char4F
+ cp $4e
+ jp z, Function12a7
+ cp $16
+ jp z, Function12b9
+ and a
+ jp z, Function1383
+ cp $4c
+ jp z, $1337
+ cp $4b
+ jp z, Char4B
+ cp $51 ; Player name
+ jp z, Function12f2
+ cp $49
+ jp z, Function1186
+ cp $52 ; Mother name
+ jp z, Function118d
+ cp $53
+ jp z, Function1194
+ cp $35
+ jp z, Function11e8
+ cp $36
+ jp z, Function11ef
+ cp $37
+ jp z, Function11f6
+ cp $38
+ jp z, Function119b
+ cp $39
+ jp z, Function11a2
+ cp $54
+ jp z, Function11c5
+ cp $5b
+ jp z, Function11b7
+ cp $5e
+ jp z, Function11be
+ cp $5c
+ jp z, Function11b0
+ cp $5d
+ jp z, Function11a9
+ cp $23
+ jp z, Function11cc
+ cp $22
+ jp z, Function12b0
+ cp $55
+ jp z, Char55
+ cp $56
+ jp z, Function11d3
+ cp $57
+ jp z, $137c
+ cp $58
+ jp z, Function135a
+ cp $4a
+ jp z, Function11da
+ cp $24
+ jp z, Function11e1
+ cp $25
+ jp z, NextChar
+ cp $1f
+ jr nz, .asm_1122
+ ld a, $7f
+.asm_1122
+ cp $5f
+ jp z, Char5F
+ cp $59
+ jp z, Function11fd
+ cp $5a
+ jp z, Char5D
+ cp $3f
+ jp z, $121b
+ cp $14
+ jp z, $1252
+ cp $e4
+ jr z, .asm_1174 ; 0x113d $35
+ cp $e5
+ jr z, .asm_1174 ; 0x1141 $31
+ jr .asm_114c ; 0x1143 $7
+ ld b, a
+ call Function13c6
+ jp NextChar
+.asm_114c
+ cp $60
+ jr nc, .asm_1174 ; 0x114e $24
+ cp $40
+ jr nc, .asm_1165 ; 0x1152 $11
+ cp $20
+ jr nc, .asm_115c ; 0x1156 $4
+ add $80
+ jr .asm_115e ; 0x115a $2
+.asm_115c
+ add $90
+.asm_115e
+ ld b, $e5
+ call Function13c6
+ jr .asm_1174 ; 0x1163 $f
+.asm_1165
+ cp $44
+ jr nc, .asm_116d ; 0x1167 $4
+ add $59
+ jr .asm_116f ; 0x116b $2
+.asm_116d
+ add $86
+.asm_116f
+ ld b, $e4
+ call Function13c6
+.asm_1174
+ ld [hli], a
+ call PrintLetterDelay
+ jp NextChar
+; 0x117b
+
+
+Function117b: ; 117b
+ ld c, l
+ ld b, h
+ ld a, $5f
+ ld hl, $7036
+ rst FarCall
+ jp PlaceNextChar
+; 1186
+
+Function1186: ; 1186
+ push de
+ ld de, MomsName
+ jp $126a
+; 118d
+
+Function118d: ; 118d
+ push de
+ ld de, PlayerName
+ jp $126a
+; 1194
+
+Function1194: ; 1194
+ push de
+ ld de, RivalName
+ jp $126a
+; 119b
+
+Function119b: ; 119b
+ push de
+ ld de, RedsName
+ jp $126a
+; 11a2
+
+Function11a2: ; 11a2
+ push de
+ ld de, GreensName
+ jp $126a
+; 11a9
+
+Function11a9: ; 11a9
+ push de
+ ld de, Char5DText
+ jp $126a
+; 11b0
+
+Function11b0: ; 11b0
+ push de
+ ld de, Char5CText
+ jp $126a
+; 11b7
+
+Function11b7: ; 11b7
+ push de
+ ld de, Char5BText
+ jp $126a
+; 11be
+
+Function11be: ; 11be
+ push de
+ ld de, Char5EText
+ jp $126a
+; 11c5
+
+Function11c5: ; 11c5
+ push de
+ ld de, Char54Text
+ jp $126a
+; 11cc
+
+Function11cc: ; 11cc
+ push de
+ ld de, Char23Text
+ jp $126a
+; 11d3
+
+Function11d3: ; 11d3
+ push de
+ ld de, $1292
+ jp $126a
+; 11da
+
+Function11da: ; 11da
+ push de
+ ld de, Char4AText
+ jp $126a
+; 11e1
+
+Function11e1: ; 11e1
+ push de
+ ld de, Char24Text
+ jp $126a
+; 11e8
+
+Function11e8: ; 11e8
+ push de
+ ld de, Char37Text
+ jp $126a
+; 11ef
+
+Function11ef: ; 11ef
+ push de
+ ld de, Char37Text
+ jp $126a
+; 11f6
+
+Function11f6: ; 11f6
+ push de
+ ld de, Char37Text
+ jp $126a
+; 11fd
+
+
+Function11fd: ; 11fd
+ ld a, [hBattleTurn]
+ xor $1
+ jr Function1205
+; 1203
+
+Char5D: ; 1203
+ ld a, [hBattleTurn]
+; 1205
+
+Function1205: ; 1205
+ push de
+ and a
+ jr nz, .asm_120e ; 0x1207 $5
+ ld de, BattleMonNick
+ jr .asm_126a ; 0x120c $5c
+.asm_120e
+ ld de, Char5AText ; Enemy
+ call PlaceString
+ ld h, b
+ ld l, c
+ ld de, EnemyMonNick
+ jr .asm_126a ; 0x1219 $4f
+ push de
+ ld a, [InLinkBattle]
+ and a
+ jr nz, .linkbattle
+ ld a, [TrainerClass]
+ cp $9
+ jr z, .asm_1248 ; 0x1227 $1f
+ cp $2a
+ jr z, .asm_1248 ; 0x122b $1b
+ ld de, $c656
+ call PlaceString
+ ld h, b
+ ld l, c
+ ld de, String12a2
+ call PlaceString
+ push bc
+ ld hl, $5939
+ ld a, $e
+ rst FarCall
+ pop hl
+ ld de, StringBuffer1
+ jr .asm_126a ; 0x1246 $22
+.asm_1248
+ ld de, RivalName
+ jr .asm_126a ; 0x124b $1d
+.linkbattle
+ ld de, $c656
+ jr .asm_126a ; 0x1250 $18
+ push de
+ ld de, PlayerName
+ call PlaceString
+ ld h, b
+ ld l, c
+ ld a, [PlayerGender]
+ bit 0, a
+ ld de, String12a5
+ jr z, .asm_126a ; 0x1263 $5
+ ld de, String12a6
+ jr .asm_126a ; 0x1268 $0
+.asm_126a
+ call PlaceString
+ ld h, b
+ ld l, c
+ pop de
+ jp NextChar
+; 0x1273
+
+Char5CText: ; 1273
+ db "TM@"
+Char5DText: ; 1276
+ db "TRAINER@"
+Char5BText: ; 127e
+ db "PC@"
+Char5EText: ; 1281
+ db "ROCKET@"
+Char54Text: ; 1288
+ db "POKé@"
+Char23Text: ; 128d
+ db "こうげき@"
+Char56Text:; 1292
+ db "……@"
+Char5AText: ; 1295
+ db "Enemy @"
+Char4AText: ; 129c
+ db $e1, $e2, "@" ; PK MN
+Char24Text: ; 129f
+ db $70, $71, "@" ; PO KE
+String12a2: ; 12a2
+ db " @"
+Char35Text:
+Char36Text:
+Char37Text: ; 12a4
+ db "@"
+String12a5: ; 12a5
+ db "@"
+String12a6: ; 12a6
+ db "@"
+; 12a7
+
+Function12a7: ; 12a7
+ pop hl
+ ld bc, $0028
+ add hl, bc
+ push hl
+ jp NextChar
+; 12b0
+
+Function12b0: ; 12b0
+ pop hl
+ ld bc, $0014
+ add hl, bc
+ push hl
+ jp NextChar
+; 12b9
+
+Function12b9: ; 12b9
+ pop hl
+ push de
+ ld bc, $3b60
+ add hl, bc
+ ld de, $ffec
+ ld c, $1
+.asm_12c4
+ ld a, h
+ and a
+ jr nz, .asm_12cd
+ ld a, l
+ cp $14
+ jr c, .asm_12d1
+
+.asm_12cd
+ add hl, de
+ inc c
+ jr .asm_12c4
+
+.asm_12d1
+ ld hl, TileMap
+ ld de, $0014
+ ld a, c
+.asm_12d8
+ and a
+ jr z, .asm_12df
+ add hl, de
+ dec a
+ jr .asm_12d8
+
+.asm_12df
+ pop de
+ inc de
+ ld a, [de]
+ ld c, a
+ ld b, $0
+ add hl, bc
+ push hl
+ jp NextChar
+; 12ea
+
+
+Char4F: ; 12ea
+ pop hl
+ hlcoord 1, 16
+ push hl
+ jp NextChar
+; 0x12f2
+
+Function12f2: ; 12f2
+ push de
+ ld a, [InLinkBattle]
+ cp $3
+ jr z, .asm_1301
+ cp $4
+ jr z, .asm_1301
+ call Function13c7
+
+.asm_1301
+ call Function13b6
+ call Functionaaf
+ ld hl, $c5b9
+ ld bc, $0312
+ call ClearBox
+ call Function13cd
+ ld c, $14
+ call DelayFrames
+ ld hl, $c5b9
+ pop de
+ jp NextChar
+; 131f
+
+
+Char4B: ; 131f
+ ld a, [InLinkBattle]
+ or a
+ jr nz, .asm_1328
+ call Function13c7
+
+.asm_1328
+ call Function13b6
+
+ push de
+ call Functionaaf
+ pop de
+
+ ld a, [InLinkBattle]
+ or a
+ call z, Function13cd
+
+ push de
+ call Function138c
+ call Function138c
+ hlcoord 1, 16
+ pop de
+ jp NextChar
+; 1345
+
+
+Char55: ; 1345
+ push de
+ ld de, Text_1354
+ ld b, h
+ ld c, l
+ call PlaceString
+ ld h, b
+ ld l, c
+ pop de
+ jp NextChar
+; 1354
+
+Text_1354: ; 1354
+ db $4b, "@"
+; 1356
+
+
+Char5F: ; 1356
+; ends a Pokédex entry
+ ld [hl], "."
+ pop hl
+ ret
+; 135a
+
+Function135a: ; 135a
+ ld a, [InLinkBattle]
+ cp $3
+ jr z, .asm_1368
+ cp $4
+ jr z, .asm_1368
+ call Function13c7
+
+.asm_1368
+ call Function13b6
+ call Functionaaf
+ ld a, [InLinkBattle]
+ cp $3
+ jr z, .asm_137c
+ cp $4
+ jr z, .asm_137c
+ call Function13cd
+
+.asm_137c
+ pop hl
+ ld de, .string_1382
+ dec de
+ ret
+
+.string_1382
+ db "@"
+; 1383
+
+Function1383: ; 1383
+ ld a, $e6
+ ld [hli], a
+ call PrintLetterDelay
+ jp NextChar
+; 138c
+
+Function138c: ; 138c
+ ld hl, $c5b9
+ ld de, $c5a5
+ ld a, $3
+.asm_1394
+ push af
+ ld c, $12
+.asm_1397
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .asm_1397
+ inc de
+ inc de
+ inc hl
+ inc hl
+ pop af
+ dec a
+ jr nz, .asm_1394
+ ld hl, $c5e1
+ ld a, $7f
+ ld bc, $0012
+ call ByteFill
+ ld c, $5
+ call DelayFrames
+ ret
+; 13b6
+
+Function13b6: ; 13b6
+ push bc
+ ld a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ld [hOAMUpdate], a
+ call WaitBGMap
+ pop af
+ ld [hOAMUpdate], a
+ pop bc
+ ret
+; 13c6
+
+Function13c6: ; 13c6
+ ret
+; 13c7
+
+Function13c7: ; 13c7
+ ld a, $ee
+ ld [$c606], a
+ ret
+; 13cd
+
+Function13cd: ; 13cd
+ ld a, [$c605]
+ ld [$c606], a
+ ret
+; 13d4
+
+Function13d4: ; 13d4
+ ld b, a
+ ld a, [hROMBank]
+ push af
+ ld a, b
+ rst Bankswitch
+
+ call PlaceString
+ pop af
+ rst Bankswitch
+
+ ret
+; 13e0
+
+Function13e0: ; 13e0
+ ld hl, $13e4
+ ret
+
+.string_13e4
+ db "@"
+; 13e5
+
+
+Function13e5: ; 13e5
+ ld a, [$cfcf]
+ push af
+ set 1, a
+ ld [$cfcf], a
+ call Function13f6
+ pop af
+ ld [$cfcf], a
+ ret
+; 13f6
+
+Function13f6: ; 13f6
+.asm_13f6
+ ld a, [hli]
+ cp "@"
+ ret z
+ call Function13ff
+ jr .asm_13f6
+; 13ff
+
+Function13ff: ; 13ff
+ push hl
+ push bc
+ ld c, a
+ ld b, 0
+ ld hl, TextCommands
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ pop bc
+ pop hl
+
+; jp de
+ push de
+ ret
+; 1410
+
+TextCommands: ; 1410
+ dw Text_00
+ dw Text_01
+ dw Text_02
+ dw Text_03
+ dw Text_04
+ dw Text_05
+ dw Text_06
+ dw Text_07
+ dw Text_08
+ dw Text_09
+ dw Text_0A
+ dw Text_PlaySound ; $0b
+ dw Text_0C
+ dw Text_0D
+ dw Text_PlaySound ; $0e
+ dw Text_PlaySound ; $0f
+ dw Text_PlaySound ; $10
+ dw Text_PlaySound ; $11
+ dw Text_PlaySound ; $12
+ dw Text_PlaySound ; $13
+ dw Text_14
+ dw Text_15
+ dw Text_16
+; 143e
+
+Text_00: ; 143e
+; TX
+; write text until "@"
+; [$00]["...@"]
+
+ ld d, h
+ ld e, l
+ ld h, b
+ ld l, c
+ call PlaceString
+ ld h, d
+ ld l, e
+ inc hl
+ ret
+; 1449
+
+Text_01: ; 1449
+; TX_RAM
+; write text from a ram address
+; little endian
+; [$01][addr]
+
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ push hl
+ ld h, b
+ ld l, c
+ call PlaceString
+ pop hl
+ ret
+; 1455
+
+Text_16: ; 1455
+; TX_FAR
+; write text from a different bank
+; little endian
+; [$16][addr][bank]
+
+ ld a, [hROMBank]
+ push af
+
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+
+ push hl
+ ld h, d
+ ld l, e
+ call Function13f6
+ pop hl
+
+ pop af
+ ld [hROMBank], a
+ ld [MBC3RomBank], a
+ ret
+; 1470
+
+Text_02: ; 1470
+; TX_NUM
+; write bcdnumber from address, typically ram
+; little endian
+; [$02][addr][flags]
+; flags: see PrintBCDNumber
+
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ push hl
+ ld h, b
+ ld l, c
+ ld c, a
+ call PrintBCDNumber
+ ld b, h
+ ld c, l
+ pop hl
+ ret
+; 1480
+
+Text_03: ; 1480
+; TX_MOVE
+; move to a new tile
+; little endian
+; [$03][tileaddr]
+
+ ld a, [hli]
+ ld [$d0e6], a
+ ld c, a
+ ld a, [hli]
+ ld [$d0e7], a
+ ld b, a
+ ret
+; 148b
+
+Text_04: ; 148b
+; TX_BOX
+; draw a box
+; little endian
+; [$04][tileaddr][height][width]
+
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ ld b, a
+ ld a, [hli]
+ ld c, a
+ push hl
+ ld h, d
+ ld l, e
+ call TextBox
+ pop hl
+ ret
+; 149b
+
+Text_05: ; 149b
+; TX_LOW
+; write text at (1,16)
+; [$05]
+
+ bccoord 1, 16
+ ret
+; 149f
+
+Text_06:: ; 149f
+; TX_WAITBUTTON
+; wait for button press
+; show arrow
+; [06]
+
+ ld a, [InLinkBattle]
+ cp $3
+ jp z, Text_0D
+ cp $4
+ jp z, Text_0D
+ push hl
+ call Function13c7
+ push bc
+ call Functionaaf
+ pop bc
+ call Function13cd
+ pop hl
+ ret
+; 14ba
+
+Text_07: ; 14ba
+ push hl
+ call Function13cd
+ call Function138c
+ call Function138c
+ pop hl
+ bccoord 1, 16
+ ret
+; 14c9
+
+Text_08: ; 14c9
+; TX_ASM
+
+; rom only?
+ bit 7, h
+ jr nz, .asm_14ce
+ jp [hl]
+
+.asm_14ce
+ ld a, "@"
+ ld [hl], a
+ ret
+; 14d2
+
+Text_09: ; 14d2
+ ld a, [hli]
+ ld e, a
+ ld a, [hli]
+ ld d, a
+ ld a, [hli]
+ push hl
+ ld h, b
+ ld l, c
+ ld b, a
+ and $f
+ ld c, a
+ ld a, b
+ and $f0
+ swap a
+ set 6, a
+ ld b, a
+ call PrintNum
+ ld b, h
+ ld c, l
+ pop hl
+ ret
+; 14ed
+
+Text_0A: ; 14ed
+ push hl
+ push bc
+ call GetJoypadPublic
+ ld a, [hJoyDown]
+ and A_BUTTON | B_BUTTON
+ jr nz, .asm_14fd
+ ld c, 30
+ call DelayFrames
+
+.asm_14fd
+ pop bc
+ pop hl
+ ret
+; 1500
+
+Text_PlaySound:: ; 1500
+; chars:
+; $0b, $0e, $0f, $10, $11, $12, $13
+; see TextSFX
+
+ push bc
+ dec hl
+ ld a, [hli]
+ ld b, a
+ push hl
+ ld hl, TextSFX
+.asm_1508
+ ld a, [hli]
+ cp $ff
+ jr z, .asm_151f
+ cp b
+ jr z, .asm_1514
+ inc hl
+ inc hl
+ jr .asm_1508
+
+.asm_1514
+ push de
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ call StartSFX
+ call WaitSFX
+ pop de
+
+.asm_151f
+ pop hl
+ pop bc
+ ret
+; 1522
+
+Function1522: ; 1522
+ push de
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ call Function37ce
+ pop de
+ pop hl
+ pop bc
+ ret
+; 152d
+
+TextSFX: ; 152d
+ dbw $0b, SFX_DEX_FANFARE_50_79
+ dbw $12, SFX_FANFARE
+ dbw $0e, SFX_DEX_FANFARE_20_49
+ dbw $0f, SFX_ITEM
+ dbw $10, SFX_CAUGHT_MON
+ dbw $11, SFX_DEX_FANFARE_80_109
+ dbw $13, SFX_SLOT_MACHINE_START
+ db $ff ; end
+; 1543
+
+Text_0C: ; 1543
+ ld a, [hli]
+ ld d, a
+ push hl
+ ld h, b
+ ld l, c
+.asm_1548
+ push de
+ ld a, "…"
+ ld [hli], a
+ call GetJoypadPublic
+ ld a, [hJoyDown]
+ and A_BUTTON | B_BUTTON
+ jr nz, .asm_155a
+ ld c, 10
+ call DelayFrames
+.asm_155a
+ pop de
+ dec d
+ jr nz, .asm_1548
+ ld b, h
+ ld c, l
+ pop hl
+ ret
+; 1562
+
+Text_0D: ; 1562
+; wait for key down
+; display arrow
+ push hl
+ push bc
+ call Functionaaf
+ pop bc
+ pop hl
+ ret
+; 156a
+
+Text_14: ; 156a
+; TX_PREDEF
+; [$14][id]
+
+ ld a, [hli]
+ push hl
+ ld e, a
+ ld d, 0
+ ld hl, $4000
+ add hl, de
+ add hl, de
+ ld a, $9
+ call GetFarHalfword
+ ld d, h
+ ld e, l
+ ld h, b
+ ld l, c
+ call PlaceString
+ pop hl
+ ret
+; 1582
+
+Text_15: ; 1582
+; TX_DAY
+
+ call GetWeekday
+ push hl
+ push bc
+ ld c, a
+ ld b, 0
+ ld hl, .Days
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld d, h
+ ld e, l
+ pop hl
+ call PlaceString
+ ld h, b
+ ld l, c
+ ld de, .Day
+ call PlaceString
+ pop hl
+ ret
+; 15a2
+
+.Days ; 15a2
+ dw .Sun
+ dw .Mon
+ dw .Tues
+ dw .Wednes
+ dw .Thurs
+ dw .Fri
+ dw .Satur
+
+.Sun db "SUN@"
+.Mon db "MON@"
+.Tues db "TUES@"
+.Wednes db "WEDNES@"
+.Thurs db "THURS@"
+.Fri db "FRI@"
+.Satur db "SATUR@"
+.Day db "DAY@"
+; 15d8
+
--- /dev/null
+++ b/home/time.asm
@@ -1,0 +1,311 @@
+; Functions relating to the timer interrupt and the real-time-clock.
+
+
+AskTimer: ; 591
+ push af
+ ld a, [$ffe9]
+ and a
+ jr z, .asm_59a
+ call Timer
+
+.asm_59a
+ pop af
+ reti
+; 59c
+
+
+LatchClock: ; 59c
+; latch clock counter data
+ ld a, 0
+ ld [MBC3LatchClock], a
+ ld a, 1
+ ld [MBC3LatchClock], a
+ ret
+; 5a7
+
+
+UpdateTime: ; 5a7
+ call GetClock
+ call FixDays
+ call FixTime
+ callba GetTimeOfDay
+ ret
+; 5b7
+
+
+GetClock: ; 5b7
+; store clock data in hRTCDayHi-hRTCSeconds
+
+; enable clock r/w
+ ld a, SRAM_ENABLE
+ ld [MBC3SRamEnable], a
+
+; clock data is 'backwards' in hram
+
+ call LatchClock
+ ld hl, MBC3SRamBank
+ ld de, MBC3RTC
+
+ ld [hl], RTC_S
+ ld a, [de]
+ and $3f
+ ld [hRTCSeconds], a
+
+ ld [hl], RTC_M
+ ld a, [de]
+ and $3f
+ ld [hRTCMinutes], a
+
+ ld [hl], RTC_H
+ ld a, [de]
+ and $1f
+ ld [hRTCHours], a
+
+ ld [hl], RTC_DL
+ ld a, [de]
+ ld [hRTCDayLo], a
+
+ ld [hl], RTC_DH
+ ld a, [de]
+ ld [hRTCDayHi], a
+
+; unlatch clock / disable clock r/w
+ call CloseSRAM
+ ret
+; 5e8
+
+
+FixDays: ; 5e8
+; fix day count
+; mod by 140
+
+; check if day count > 255 (bit 8 set)
+ ld a, [hRTCDayHi] ; DH
+ bit 0, a
+ jr z, .daylo
+; reset dh (bit 8)
+ res 0, a
+ ld [hRTCDayHi], a ; DH
+
+; mod 140
+; mod twice since bit 8 (DH) was set
+ ld a, [hRTCDayLo] ; DL
+.modh
+ sub 140
+ jr nc, .modh
+.modl
+ sub 140
+ jr nc, .modl
+ add 140
+
+; update dl
+ ld [hRTCDayLo], a ; DL
+
+; unknown output
+ ld a, $40 ; %1000000
+ jr .set
+
+.daylo
+; quit if fewer than 140 days have passed
+ ld a, [hRTCDayLo] ; DL
+ cp 140
+ jr c, .quit
+
+; mod 140
+.mod
+ sub 140
+ jr nc, .mod
+ add 140
+
+; update dl
+ ld [hRTCDayLo], a ; DL
+
+; unknown output
+ ld a, $20 ; %100000
+
+.set
+; update clock with modded day value
+ push af
+ call SetClock
+ pop af
+ scf
+ ret
+
+.quit
+ xor a
+ ret
+; 61d
+
+
+FixTime: ; 61d
+; add ingame time (set at newgame) to current time
+; day hr min sec
+; store time in CurDay, hHours, hMinutes, hSeconds
+
+; second
+ ld a, [hRTCSeconds] ; S
+ ld c, a
+ ld a, [StartSecond]
+ add c
+ sub 60
+ jr nc, .updatesec
+ add 60
+.updatesec
+ ld [hSeconds], a
+
+; minute
+ ccf ; carry is set, so turn it off
+ ld a, [hRTCMinutes] ; M
+ ld c, a
+ ld a, [StartMinute]
+ adc c
+ sub 60
+ jr nc, .updatemin
+ add 60
+.updatemin
+ ld [hMinutes], a
+
+; hour
+ ccf ; carry is set, so turn it off
+ ld a, [hRTCHours] ; H
+ ld c, a
+ ld a, [StartHour]
+ adc c
+ sub 24
+ jr nc, .updatehr
+ add 24
+.updatehr
+ ld [hHours], a
+
+; day
+ ccf ; carry is set, so turn it off
+ ld a, [hRTCDayLo] ; DL
+ ld c, a
+ ld a, [StartDay]
+ adc c
+ ld [CurDay], a
+ ret
+; 658
+
+Function658: ; 658
+ xor a
+ ld [StringBuffer2], a
+ ld a, $0
+ ld [$d089], a
+ jr .asm_677
+
+ call UpdateTime
+ ld a, [hHours]
+ ld [$d087], a
+ ld a, [hMinutes]
+ ld [$d088], a
+ ld a, [hSeconds]
+ ld [$d089], a
+ jr .asm_677
+
+.asm_677
+ ld a, $5
+ ld hl, $40ed
+ rst FarCall
+ ret
+; 67e
+
+
+
+Function67e: ; 67e
+ call Function685
+ call SetClock
+ ret
+; 685
+
+Function685: ; 685
+ xor a
+ ld [hRTCSeconds], a
+ ld [hRTCMinutes], a
+ ld [hRTCHours], a
+ ld [hRTCDayLo], a
+ ld [hRTCDayHi], a
+ ret
+; 691
+
+
+SetClock: ; 691
+; set clock data from hram
+
+; enable clock r/w
+ ld a, SRAM_ENABLE
+ ld [MBC3SRamEnable], a
+
+; set clock data
+; stored 'backwards' in hram
+
+ call LatchClock
+ ld hl, MBC3SRamBank
+ ld de, MBC3RTC
+
+; seems to be a halt check that got partially commented out
+; this block is totally pointless
+ ld [hl], RTC_DH
+ ld a, [de]
+ bit 6, a ; halt
+ ld [de], a
+
+; seconds
+ ld [hl], RTC_S
+ ld a, [hRTCSeconds]
+ ld [de], a
+; minutes
+ ld [hl], RTC_M
+ ld a, [hRTCMinutes]
+ ld [de], a
+; hours
+ ld [hl], RTC_H
+ ld a, [hRTCHours]
+ ld [de], a
+; day lo
+ ld [hl], RTC_DL
+ ld a, [hRTCDayLo]
+ ld [de], a
+; day hi
+ ld [hl], RTC_DH
+ ld a, [hRTCDayHi]
+ res 6, a ; make sure timer is active
+ ld [de], a
+
+; cleanup
+ call CloseSRAM ; unlatch clock, disable clock r/w
+ ret
+; 6c4
+
+
+Function6c4: ; 6c4
+ xor a
+ push af
+ ld a, $0
+ call GetSRAMBank
+ pop af
+ ld [$ac60], a
+ call CloseSRAM
+ ret
+; 6d3
+
+Function6d3: ; 6d3
+ ld hl, $ac60
+ push af
+ ld a, $0
+ call GetSRAMBank
+ pop af
+ or [hl]
+ ld [hl], a
+ call CloseSRAM
+ ret
+; 6e3
+
+Function6e3: ; 6e3
+ ld a, $0
+ call GetSRAMBank
+ ld a, [$ac60]
+ call CloseSRAM
+ ret
+; 6ef
+
--- /dev/null
+++ b/home/vblank.asm
@@ -1,0 +1,541 @@
+; VBlank is the interrupt responsible for updating VRAM.
+
+; In Pokemon Crystal, VBlank has been hijacked to act as the
+; main loop. After time-sensitive graphics operations have been
+; performed, joypad input and sound functions are executed.
+
+; This prevents the display and audio output from lagging.
+
+
+VBlank: ; 283
+ push af
+ push bc
+ push de
+ push hl
+
+; get vblank type
+ ld a, [$ff9e]
+ and $7
+
+; get fn pointer
+ ld e, a
+ ld d, $0
+ ld hl, .VBlanks
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+; down to business
+ call _hl_
+
+; since this is called once per frame
+ call GameTimer
+
+ pop hl
+ pop de
+ pop bc
+ pop af
+ reti
+; 2a1
+
+.VBlanks ; 2a1
+ dw VBlank0 ; 0
+ dw VBlank1 ; 1
+ dw VBlank2 ; 2
+ dw VBlank3 ; 3
+ dw VBlank4 ; 4
+ dw VBlank5 ; 5
+ dw VBlank6 ; 6
+ dw VBlank0 ; 7
+; 2b1
+
+
+VBlank0: ; 2b1
+; normal operation
+
+; rng
+; scx, scy, wy, wx
+; bg map buffer
+; palettes
+; dma transfer
+; bg map
+; tiles
+; oam
+; joypad
+; sound
+
+; inc frame counter
+ ld hl, $ff9b
+ inc [hl]
+
+; advance rng
+ ld a, [rDIV]
+ ld b, a
+ ld a, [hRandomAdd]
+ adc b
+ ld [hRandomAdd], a
+
+ ld a, [rDIV]
+ ld b, a
+ ld a, [hRandomSub]
+ sbc b
+ ld [hRandomSub], a
+
+; save bank
+ ld a, [hROMBank] ; current bank
+ ld [$ff8a], a
+
+; scroll x
+ ld a, [hSCX]
+ ld [rSCX], a
+; scroll y
+ ld a, [hSCY]
+ ld [rSCY], a
+; window y
+ ld a, [hWY]
+ ld [rWY], a
+; window x + 7
+ ld a, [hWX]
+ ld [rWX], a
+
+; some time management is in order
+; only have time for one of these during vblank
+
+; bg map buffer has priority
+ call UpdateBGMapBuffer
+ jr c, .doneframeaction
+
+; then pals
+ call UpdatePalsIfCGB
+ jr c, .doneframeaction
+
+; dma transfer
+ call DMATransfer
+ jr c, .doneframeaction
+
+; bg map
+ call UpdateBGMap
+
+; these have their own timing checks
+ call Serve2bppRequest
+ call Serve1bppRequest
+ call AnimateTileset
+
+.doneframeaction
+; oam update off?
+ ld a, [hOAMUpdate]
+ and a
+ jr nz, .vblankoccurred
+
+; update oam by dma transfer
+ call hPushOAM
+; @PushOAM:
+; ld a, Sprites >> 8
+; ld [rDMA], a
+; ld a, $28
+; .loop
+; dec a
+; jr nz, .loop
+; ret
+
+
+; vblank-sensitive operations are done
+
+.vblankoccurred
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+
+; dec OverworldDelay until 0
+ ld a, [OverworldDelay]
+ and a
+ jr z, .textdelay
+ dec a
+ ld [OverworldDelay], a
+
+.textdelay
+; dec text delay counter until 0
+ ld a, [TextDelayFrames]
+ and a
+ jr z, .joypad
+ dec a
+ ld [TextDelayFrames], a
+
+.joypad
+ call Joypad
+
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+ ld a, [$ff8a]
+ rst Bankswitch ; restore bank
+
+;
+ ld a, [hSeconds]
+ ld [$ffe3], a
+
+ ret
+; 325
+
+
+VBlank2: ; 325
+; sound only
+
+; save bank
+ ld a, [hROMBank]
+ ld [$ff8a], a
+
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+
+; restore bank
+ ld a, [$ff8a]
+ rst Bankswitch
+
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+ ret
+; 337
+
+
+VBlank1: ; 337
+; scx, scy
+; palettes
+; bg map
+; tiles
+; oam
+; sound / lcd stat
+
+; save bank
+ ld a, [hROMBank]
+ ld [$ff8a], a
+
+; scroll x
+ ld a, [hSCX]
+ ld [rSCX], a
+
+; scroll y
+ ld a, [hSCY]
+ ld [rSCY], a
+
+; time-sensitive fns
+ call UpdatePals
+ jr c, .vblankoccurred
+
+; these have their own timing checks
+ call UpdateBGMap
+ call Serve2bppRequest@VBlank
+; update oam by dma transfer
+ call hPushOAM
+; @PushOAM:
+; ld a, Sprites >> 8
+; ld [rDMA], a
+; ld a, $28
+; .loop
+; dec a
+; jr nz, .loop
+; ret
+
+.vblankoccurred
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+
+; get requested ints
+ ld a, [rIF]
+ ld b, a
+; discard requested ints
+ xor a
+ ld [rIF], a
+; enable lcd stat
+ ld a, %10 ; lcd stat
+ ld [rIE], a
+; rerequest serial int if applicable (still disabled)
+; request lcd stat
+ ld a, b
+ and %1000 ; serial
+ or %10 ; lcd stat
+ ld [rIF], a
+
+ ei
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+; restore bank
+ ld a, [$ff8a]
+ rst Bankswitch
+ di
+
+; get requested ints
+ ld a, [rIF]
+ ld b, a
+; discard requested ints
+ xor a
+ ld [rIF], a
+; enable ints besides joypad
+ ld a, %1111 ; serial timer lcdstat vblank
+ ld [rIE], a
+; rerequest ints
+ ld a, b
+ ld [rIF], a
+ ret
+; 37f
+
+
+UpdatePals: ; 37f
+; update pals for either dmg or cgb
+
+; check cgb
+ ld a, [hCGB]
+ and a
+ jp nz, UpdateCGBPals
+
+; update gb pals
+ ld a, [$cfc7]
+ ld [rBGP], a
+
+ ld a, [$cfc8]
+ ld [rOBP0], a
+
+ ld a, [$cfc9]
+ ld [rOBP1], a
+
+ and a
+ ret
+; 396
+
+
+VBlank3: ; 396
+; scx, scy
+; palettes
+; bg map
+; tiles
+; oam
+; sound / lcd stat
+
+; save bank
+ ld a, [hROMBank]
+ ld [$ff8a], a
+
+; scroll x
+ ld a, [hSCX]
+ ld [rSCX], a
+; scroll y
+ ld a, [hSCY]
+ ld [rSCY], a
+
+; any pals to update?
+ ld a, [hCGBPalUpdate]
+ and a
+ call nz, ForceUpdateCGBPals
+ jr c, .vblankoccurred
+; else
+ call UpdateBGMap
+ call Serve2bppRequest@VBlank
+
+; update oam by dma transfer
+ call hPushOAM
+; @PushOAM:
+; ld a, Sprites >> 8
+; ld [rDMA], a
+; ld a, $28
+; .loop
+; dec a
+; jr nz, .loop
+; ret
+
+.vblankoccurred
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+
+; save int flag
+ ld a, [rIF]
+ push af
+; reset ints
+ xor a
+ ld [rIF], a
+; force lcdstat int during sound update
+ ld a, %10 ; lcd stat
+ ld [rIE], a
+ ld [rIF], a
+
+ ei
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+; restore bank
+ ld a, [$ff8a]
+ rst Bankswitch
+ di
+
+; request lcdstat
+ ld a, [rIF]
+ ld b, a
+; and any other ints
+ pop af
+ or b
+ ld b, a
+; reset ints
+ xor a
+ ld [rIF], a
+; enable ints besides joypad
+ ld a, %1111 ; serial timer lcdstat vblank
+ ld [rIE], a
+; request ints
+ ld a, b
+ ld [rIF], a
+ ret
+; 3df
+
+
+VBlank4: ; 3df
+; bg map
+; tiles
+; oam
+; joypad
+; serial
+; sound
+
+; save bank
+ ld a, [hROMBank]
+ ld [$ff8a], a
+
+ call UpdateBGMap
+ call Serve2bppRequest
+
+; update oam by dma transfer
+ call hPushOAM
+; @PushOAM:
+; ld a, Sprites >> 8
+; ld [rDMA], a
+; ld a, $28
+; .loop
+; dec a
+; jr nz, .loop
+; ret
+
+; update joypad
+ call Joypad
+
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+
+; handshake
+ call AskSerial
+
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+; restore bank
+ ld a, [$ff8a]
+ rst Bankswitch
+ ret
+; 400
+
+
+VBlank5: ; 400
+; scx
+; palettes
+; bg map
+; tiles
+; joypad
+;
+
+; save bank
+ ld a, [hROMBank]
+ ld [$ff8a], a
+
+; scroll x
+ ld a, [hSCX]
+ ld [rSCX], a
+
+; if we can update pals, skip this part
+ call UpdatePalsIfCGB
+ jr c, .vblankoccurred
+
+ call UpdateBGMap
+ call Serve2bppRequest
+
+.vblankoccurred
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+
+; joypad
+ call Joypad
+
+; discard requested ints
+ xor a
+ ld [rIF], a
+; enable lcd stat
+ ld a, %10 ; lcd stat
+ ld [rIE], a
+; request lcd stat
+ ld [rIF], a
+
+ ei
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+; restore bank
+ ld a, [$ff8a]
+ rst Bankswitch
+ di
+
+; discard requested ints
+ xor a
+ ld [rIF], a
+; enable ints besides joypad
+ ld a, %1111 ; serial timer lcdstat vblank
+ ld [rIE], a
+ ret
+; 436
+
+
+VBlank6: ; 436
+; palettes
+; tiles
+; dma transfer
+; sound
+
+; save bank
+ ld a, [hROMBank]
+ ld [$ff8a], a
+
+; inc frame counter
+ ld hl, $ff9b
+ inc [hl]
+
+ call UpdateCGBPals
+ jr c, .vblankoccurred
+
+ call Serve2bppRequest
+ call Serve1bppRequest
+ call DMATransfer
+
+.vblankoccurred
+; tell other fns vblank happened
+ xor a
+ ld [VBlankOccurred], a
+
+; update sound
+ ld a, BANK(UpdateSound)
+ rst Bankswitch ; bankswitch
+ call UpdateSound
+; restore bank
+ ld a, [$ff8a]
+ rst Bankswitch
+ ret
+; 45a
--- /dev/null
+++ b/home/video.asm
@@ -1,0 +1,487 @@
+; Functions dealing with VRAM.
+
+DMATransfer: ; 15d8
+; Return carry if the transfer is completed.
+
+ ld a, [hDMATransfer]
+ and a
+ ret z
+
+; Start transfer
+ ld [rHDMA5], a
+
+; Execution is halted until the transfer is complete.
+
+ xor a
+ ld [hDMATransfer], a
+ scf
+ ret
+; 15e3
+
+
+UpdateBGMapBuffer: ; 15e3
+; Copy [$ffdc] 16x8 tiles from BGMapBuffer
+; to bg map addresses in BGMapBufferPtrs.
+
+; [$ffdc] must be even since this is done in pairs.
+
+; Return carry on success.
+
+ ld a, [hBGMapUpdate]
+ and a
+ ret z
+
+ ld a, [rVBK]
+ push af
+ ld [hSPBuffer], sp
+
+ ld hl, BGMapBufferPtrs
+ ld sp, hl
+
+; We can now pop the addresses of affected spots on the BG Map
+
+ ld hl, BGMapPalBuffer
+ ld de, BGMapBuffer
+
+
+.next
+; Copy a pair of 16x8 blocks (one 16x16 block)
+
+rept 2
+; Get our BG Map address
+ pop bc
+
+; Palettes
+ ld a, 1
+ ld [rVBK], a
+
+ ld a, [hli]
+ ld [bc], a
+ inc c
+ ld a, [hli]
+ ld [bc], a
+ dec c
+
+; Tiles
+ ld a, 0
+ ld [rVBK], a
+
+ ld a, [de]
+ inc de
+ ld [bc], a
+ inc c
+ ld a, [de]
+ inc de
+ ld [bc], a
+endr
+
+; We've done 2 16x8 blocks
+ ld a, [$ffdc]
+ dec a
+ dec a
+ ld [$ffdc], a
+
+ jr nz, .next
+
+
+ ld a, [hSPBuffer]
+ ld l, a
+ ld a, [hSPBuffer + 1]
+ ld h, a
+ ld sp, hl
+
+ pop af
+ ld [rVBK], a
+
+ xor a
+ ld [hBGMapUpdate], a
+ scf
+ ret
+; 163a
+
+
+WaitTop: ; 163a
+; Wait until the top third of the BG Map is being updated.
+
+ ld a, [hBGMapMode]
+ and a
+ ret z
+
+ ld a, [hBGMapThird]
+ and a
+ jr z, .done
+
+ call DelayFrame
+ jr WaitTop
+
+.done
+ xor a
+ ld [hBGMapMode], a
+ ret
+; 164c
+
+
+UpdateBGMap: ; 164c
+; Update the BG Map, in thirds, from TileMap and AttrMap.
+
+ ld a, [hBGMapMode]
+ and a
+ ret z
+
+; BG Map 0
+ dec a ; 1
+ jr z, .Tiles
+ dec a ; 2
+ jr z, .Attr
+
+; BG Map 1
+ dec a
+
+ ld a, [hBGMapAddress]
+ ld l, a
+ ld a, [hBGMapAddress + 1]
+ ld h, a
+ push hl
+
+ xor a
+ ld [hBGMapAddress], a
+ ld a, VBGMap1 >> 8
+ ld [hBGMapAddress + 1], a
+
+ ld a, [hBGMapMode]
+ push af
+ cp 3
+ call z, .Tiles
+ pop af
+ cp 4
+ call z, .Attr
+
+ pop hl
+ ld a, l
+ ld [hBGMapAddress], a
+ ld a, h
+ ld [hBGMapAddress + 1], a
+ ret
+
+
+.Attr
+ ld a, 1
+ ld [rVBK], a
+
+ ld hl, AttrMap
+ call .update
+
+ ld a, 0
+ ld [rVBK], a
+ ret
+
+
+.Tiles
+ ld hl, TileMap
+
+
+.update
+ ld [hSPBuffer], sp
+
+; Which third?
+ ld a, [hBGMapThird]
+ and a ; 0
+ jr z, .top
+ dec a ; 1
+ jr z, .middle
+ ; 2
+
+
+THIRD_HEIGHT EQU SCREEN_HEIGHT / 3
+
+
+.bottom
+ ld de, 2 * THIRD_HEIGHT * SCREEN_WIDTH
+ add hl, de
+ ld sp, hl
+
+ ld a, [hBGMapAddress + 1]
+ ld h, a
+ ld a, [hBGMapAddress]
+ ld l, a
+
+ ld de, 2 * THIRD_HEIGHT * BG_MAP_WIDTH
+ add hl, de
+
+; Next time: top third
+ xor a
+ jr .start
+
+
+.middle
+ ld de, THIRD_HEIGHT * SCREEN_WIDTH
+ add hl, de
+ ld sp, hl
+
+ ld a, [hBGMapAddress + 1]
+ ld h, a
+ ld a, [hBGMapAddress]
+ ld l, a
+
+ ld de, THIRD_HEIGHT * BG_MAP_WIDTH
+ add hl, de
+
+; Next time: bottom third
+ ld a, 2
+ jr .start
+
+
+.top
+ ld sp, hl
+
+ ld a, [hBGMapAddress + 1]
+ ld h, a
+ ld a, [hBGMapAddress]
+ ld l, a
+
+; Next time: middle third
+ ld a, 1
+
+
+.start
+; Which third to update next time
+ ld [hBGMapThird], a
+
+; Rows of tiles in a third
+ ld a, SCREEN_HEIGHT / 3
+
+; Discrepancy between TileMap and BGMap
+ ld bc, BG_MAP_WIDTH - (SCREEN_WIDTH - 1)
+
+
+.row
+; Copy a row of 20 tiles
+rept SCREEN_WIDTH / 2 - 1
+ pop de
+ ld [hl], e
+ inc l
+ ld [hl], d
+ inc l
+endr
+ pop de
+ ld [hl], e
+ inc l
+ ld [hl], d
+
+ add hl, bc
+ dec a
+ jr nz, .row
+
+
+ ld a, [hSPBuffer]
+ ld l, a
+ ld a, [hSPBuffer + 1]
+ ld h, a
+ ld sp, hl
+ ret
+; 170a
+
+
+Serve1bppRequest: ; 170a
+; Only call during the first fifth of VBlank
+
+ ld a, [Requested1bpp]
+ and a
+ ret z
+
+; Back out if we're too far into VBlank
+ ld a, [rLY]
+ cp 144
+ ret c
+ cp 146
+ ret nc
+
+; Copy [Requested1bpp] 1bpp tiles from [Requested1bppSource] to [Requested1bppDest]
+
+ ld [hSPBuffer], sp
+
+; Source
+ ld hl, Requested1bppSource
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld sp, hl
+
+; Destination
+ ld hl, Requested1bppDest
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+; # tiles to copy
+ ld a, [Requested1bpp]
+ ld b, a
+
+ xor a
+ ld [Requested1bpp], a
+
+.next
+
+rept 3
+ pop de
+ ld [hl], e
+ inc l
+ ld [hl], e
+ inc l
+ ld [hl], d
+ inc l
+ ld [hl], d
+ inc l
+endr
+ pop de
+ ld [hl], e
+ inc l
+ ld [hl], e
+ inc l
+ ld [hl], d
+ inc l
+ ld [hl], d
+
+ inc hl
+ dec b
+ jr nz, .next
+
+
+ ld a, l
+ ld [Requested1bppDest], a
+ ld a, h
+ ld [Requested1bppDest + 1], a
+
+ ld [Requested1bppSource], sp
+
+ ld a, [hSPBuffer]
+ ld l, a
+ ld a, [hSPBuffer + 1]
+ ld h, a
+ ld sp, hl
+ ret
+; 1769
+
+
+Serve2bppRequest: ; 1769
+; Only call during the first fifth of VBlank
+
+ ld a, [Requested2bpp]
+ and a
+ ret z
+
+; Back out if we're too far into VBlank
+ ld a, [rLY]
+ cp 144
+ ret c
+ cp 146
+ ret nc
+ jr _Serve2bppRequest
+
+
+Serve2bppRequest@VBlank: ; 1778
+
+ ld a, [Requested2bpp]
+ and a
+ ret z
+
+_Serve2bppRequest: ; 177d
+; Copy [Requested2bpp] 2bpp tiles from [Requested2bppSource] to [Requested2bppDest]
+
+ ld [hSPBuffer], sp
+
+; Source
+ ld hl, Requested2bppSource
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld sp, hl
+
+; Destination
+ ld hl, Requested2bppDest
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+
+; # tiles to copy
+ ld a, [Requested2bpp]
+ ld b, a
+
+ xor a
+ ld [Requested2bpp], a
+
+.next
+
+rept 7
+ pop de
+ ld [hl], e
+ inc l
+ ld [hl], d
+ inc l
+endr
+ pop de
+ ld [hl], e
+ inc l
+ ld [hl], d
+
+ inc hl
+ dec b
+ jr nz, .next
+
+
+ ld a, l
+ ld [Requested2bppDest], a
+ ld a, h
+ ld [Requested2bppDest + 1], a
+
+ ld [Requested2bppSource], sp
+
+ ld a, [hSPBuffer]
+ ld l, a
+ ld a, [hSPBuffer + 1]
+ ld h, a
+ ld sp, hl
+ ret
+; 17d3
+
+
+AnimateTileset: ; 17d3
+; Only call during the first fifth of VBlank
+
+ ld a, [$ffde]
+ and a
+ ret z
+
+; Back out if we're too far into VBlank
+ ld a, [rLY]
+ cp 144
+ ret c
+ cp 151
+ ret nc
+
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(_AnimateTileset)
+ rst Bankswitch
+
+ ld a, [rSVBK]
+ push af
+ ld a, 1
+ ld [rSVBK], a
+
+ ld a, [rVBK]
+ push af
+ ld a, 0
+ ld [rVBK], a
+
+ call _AnimateTileset
+
+ pop af
+ ld [rVBK], a
+ pop af
+ ld [rSVBK], a
+ pop af
+ rst Bankswitch
+ ret
+; 17ff
+
--- a/main.asm
+++ b/main.asm
@@ -14,22 +14,22 @@
SECTION "start",ROM0[$150]
-INCLUDE "engine/init.asm"
-INCLUDE "engine/vblank.asm"
-INCLUDE "engine/delay.asm"
-INCLUDE "engine/rtc.asm"
-INCLUDE "engine/fade.asm"
-INCLUDE "engine/lcd.asm"
-INCLUDE "engine/time.asm"
-INCLUDE "engine/serial.asm"
-INCLUDE "engine/joypad.asm"
-INCLUDE "engine/decompress.asm"
-INCLUDE "engine/palettes.asm"
-INCLUDE "engine/copy.asm"
-INCLUDE "engine/text.asm"
-INCLUDE "engine/video.asm"
-INCLUDE "engine/map_objects.asm"
-INCLUDE "engine/sine.asm"
+INCLUDE "home/init.asm"
+INCLUDE "home/vblank.asm"
+INCLUDE "home/delay.asm"
+INCLUDE "home/rtc.asm"
+INCLUDE "home/fade.asm"
+INCLUDE "home/lcd.asm"
+INCLUDE "home/time.asm"
+INCLUDE "home/serial.asm"
+INCLUDE "home/joypad.asm"
+INCLUDE "home/decompress.asm"
+INCLUDE "home/palettes.asm"
+INCLUDE "home/copy.asm"
+INCLUDE "home/text.asm"
+INCLUDE "home/video.asm"
+INCLUDE "home/map_objects.asm"
+INCLUDE "home/sine.asm"
Function1b1e: ; 1b1e
ld [$d003], a
@@ -473,2419 +473,15 @@
; 1d35
-INCLUDE "engine/menu.asm"
+INCLUDE "home/menu.asm"
+INCLUDE "home/handshake.asm"
+INCLUDE "home/game_time.asm"
+INCLUDE "home/map.asm"
-AskSerial: ; 2063
-; send out a handshake while serial int is off
- ld a, [$c2d4]
- bit 0, a
- ret z
-
- ld a, [$c2d5]
- and a
- ret nz
-
-; once every 6 frames
- ld hl, $ca8a
- inc [hl]
- ld a, [hl]
- cp 6
- ret c
-
- xor a
- ld [hl], a
-
- ld a, $c
- ld [$c2d5], a
-
-; handshake
- ld a, $88
- ld [rSB], a
-
-; switch to internal clock
- ld a, %00000001
- ld [rSC], a
-
-; start transfer
- ld a, %10000001
- ld [rSC], a
-
- ret
-; 208a
-
-
-INCLUDE "engine/game_time.asm"
-
-
-Function210f: ; 210f
- ld hl, $c7e8
- ld bc, $0018
- ld a, $0
- call ByteFill
- ret
-; 211b
-
-Function211b: ; 211b
- push hl
- ld hl, $dbf7
- ld a, [hli]
- ld h, [hl]
- ld l, a
- or h
- ld a, [hl]
- jr nz, .asm_2128
- ld a, $ff
-
-.asm_2128
- pop hl
- ret
-; 212a
-
-Function212a: ; 212a
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- xor a
- ld [$dbf7], a
- ld [$dbf8], a
- call Function2147
- ret c
- ld a, e
- ld [$dbf7], a
- ld a, d
- ld [$dbf8], a
- xor a
- ret
-; 2147
-
-Function2147: ; 2147
- push bc
- ld a, [hROMBank]
- push af
- ld a, $13
- rst Bankswitch
-
- ld hl, $501e
-.asm_2151
- push hl
- ld a, [hli]
- cp $ff
- jr z, .asm_2167
- cp b
- jr nz, .asm_2160
- ld a, [hli]
- cp c
- jr nz, .asm_2160
- jr .asm_216a
-
-.asm_2160
- pop hl
- ld de, $0004
- add hl, de
- jr .asm_2151
-
-.asm_2167
- scf
- jr .asm_216d
-
-.asm_216a
- ld e, [hl]
- inc hl
- ld d, [hl]
-
-.asm_216d
- pop hl
- pop bc
- ld a, b
- rst Bankswitch
-
- pop bc
- ret
-; 2173
-
-Function2173: ; 2173
- call Function217a
- call Functiondb1
- ret
-; 217a
-
-Function217a: ; 217a
- ld a, [hROMBank]
- push af
- ld a, [TilesetBlocksBank]
- rst Bankswitch
-
- call Function2198
- ld a, $60
- ld hl, TileMap
- ld bc, $0168
- call ByteFill
- ld a, $13
- rst Bankswitch
-
- call $515b
- pop af
- rst Bankswitch
-
- ret
-; 2198
-
-Function2198: ; 2198
- ld a, [$d194]
- ld e, a
- ld a, [$d195]
- ld d, a
- ld hl, EnemyMoveAnimation
- ld b, $5
-
-.asm_21a5
- push de
- push hl
- ld c, $6
-
-.asm_21a9
- push de
- push hl
- ld a, [de]
- and a
- jr nz, .asm_21b2
- ld a, [$d19d]
-
-.asm_21b2
- ld e, l
- ld d, h
- add a
- ld l, a
- ld h, $0
- add hl, hl
- add hl, hl
- add hl, hl
- ld a, [TilesetBlocksAddress]
- add l
- ld l, a
- ld a, [TilesetBlocksAddress + 1]
- adc h
- ld h, a
-
-rept 3
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
-
- ld a, e
- add 20
- ld e, a
- jr nc, .next\@
- inc d
-.next\@
-endr
-
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
-
- pop hl
- ld de, $0004
- add hl, de
- pop de
- inc de
- dec c
- jp nz, .asm_21a9
- pop hl
- ld de, $0060
- add hl, de
- pop de
- ld a, [$d19f]
- add $6
- add e
- ld e, a
- jr nc, .asm_2225
- inc d
-
-.asm_2225
- dec b
- jp nz, .asm_21a5
- ret
-; 222a
-
-Function222a: ; 222a
- ld a, $fa
- ld [$ff9f], a
- callba Function15363
- xor a
- ld [$ff9f], a
- ret
-; 2238
-
-Function2238: ; 2238
- call Function2252
- ret nc
- push bc
- callba Function149af
- pop bc
- ret nc
- call Function22a7
- scf
- ret
-; 224a
-
-
-
-Function224a: ; 224a
- call Function2252
- ret nc
- call Function22a7
- ret
-; 2252
-
-Function2252: ; 2252
- callba Function1499a
- ret nc
-
- ld a, [hROMBank]
- push af
-
- call Function2c52
- call Function2266
-
- pop de
- ld a, d
- rst Bankswitch
- ret
-; 2266
-
-Function2266: ; 2266
- ld a, [MapY]
- sub $4
- ld e, a
- ld a, [MapX]
- sub $4
- ld d, a
- ld a, [$dbfb]
- and a
- ret z
- ld c, a
- ld hl, $dbfc
- ld a, [hli]
- ld h, [hl]
- ld l, a
-.asm_227e
- push hl
- ld a, [hli]
- cp e
- jr nz, .asm_2289
- ld a, [hli]
- cp d
- jr nz, .asm_2289
- jr .asm_2296
-
-.asm_2289
- pop hl
- ld a, $5
- add l
- ld l, a
- jr nc, .asm_2291
- inc h
-
-.asm_2291
- dec c
- jr nz, .asm_227e
- xor a
- ret
-
-.asm_2296
- pop hl
- call Function22a3
- ret nc
- ld a, [$dbfb]
- inc a
- sub c
- ld c, a
- scf
- ret
-; 22a3
-
-Function22a3: ; 22a3
- inc hl
- inc hl
- scf
- ret
-; 22a7
-
-Function22a7: ; 22a7
- ld a, [hROMBank]
- push af
-
- call Function2c52
- call Function22b4
-
- pop af
- rst Bankswitch
- scf
- ret
-; 22b4
-
-Function22b4: ; 22b4
- push bc
- ld hl, $dbfc
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, c
- dec a
- ld bc, $0005
- call AddNTimes
- ld bc, $0002
- add hl, bc
- ld a, [hli]
- cp $ff
- jr nz, .asm_22d0
- ld hl, $dcac
- ld a, [hli]
-
-.asm_22d0
- pop bc
- ld [$d146], a
- ld a, [hli]
- ld [$d147], a
- ld a, [hli]
- ld [$d148], a
- ld a, c
- ld [$d149], a
- ld a, [MapGroup]
- ld [$d14a], a
- ld a, [MapNumber]
- ld [$d14b], a
- scf
- ret
-; 22ee
-
-
-
-CheckOutdoorMap: ; 22ee
- cp ROUTE
- ret z
- cp TOWN
- ret
-; 22f4
-
-CheckIndoorMap: ; 22f4
- cp INDOOR
- ret z
- cp CAVE
- ret z
- cp DUNGEON
- ret z
- cp GATE
- ret
-; 2300
-
-Function2300: ; 2300
- cp INDOOR
- ret z
- cp GATE
- ret z
- cp $5
- ret
-; 2309
-
-
-Function2309: ; 2309
- call Function2326
- call Function2c52
- call Function234f
- xor a
- call Function2336
- ret
-; 2317
-
-Function2317: ; 2317
- call Function2326
- call Function2c52
- call Function234f
- ld a, $1
- call Function2336
- ret
-; 2326
-
-Function2326: ; 2326
- call Function2c3d
- call Function2c1c
- call GetSecondaryMapHeaderPointer
- call Function235c
- call Function2368
- ret
-; 2336
-
-Function2336: ; 2336
- push af
- ld hl, $d1a6
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- inc hl
- call Function23da
- call Function23f1
- call Function2408
- pop af
- and a
- ret nz
- call Function241f
- ret
-; 234f
-
-Function234f: ; 234f
- ld hl, $d1a4
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call Function23ac
- call Function23c3
- ret
-; 235c
-
-Function235c: ; 235c
- ld de, $d19d
- ld c, $c
-.asm_2361
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_2361
- ret
-; 2368
-
-Function2368: ; 2368
- ld a, $ff
- ld [NorthConnectedMapGroup], a
- ld [SouthConnectedMapGroup], a
- ld [WestConnectedMapGroup], a
- ld [EastConnectedMapGroup], a
-
- ld a, [$d1a8]
- ld b, a
-
- bit 3, b
- jr z, .asm_2384
- ld de, NorthMapConnection
- call GetMapConnection
-
-.asm_2384
- bit 2, b
- jr z, .asm_238e
- ld de, SouthMapConnection
- call GetMapConnection
-
-.asm_238e
- bit 1, b
- jr z, .asm_2398
- ld de, WestMapConnection
- call GetMapConnection
-
-.asm_2398
- bit 0, b
- jr z, .asm_23a2
- ld de, EastMapConnection
- call GetMapConnection
-
-.asm_23a2
- ret
-; 23a3
-
-
-GetMapConnection: ; 23a3
-; Load map connection struct at hl into de.
- ld c, SouthMapConnection - NorthMapConnection
-.loop
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .loop
- ret
-; 23ac
-
-
-Function23ac: ; 23ac
- ld a, [hli]
- ld c, a
- ld [$dc07], a
- ld a, l
- ld [$dc08], a
- ld a, h
- ld [$dc09], a
- ld a, c
- and a
- ret z
- ld bc, $0004
- call AddNTimes
- ret
-; 23c3
-
-Function23c3: ; 23c3
- ld a, [hli]
- ld c, a
- ld [$dc0a], a
- ld a, l
- ld [$dc0b], a
- ld a, h
- ld [$dc0c], a
- ld a, c
- and a
- ret z
- ld bc, $0003
- call AddNTimes
- ret
-; 23da
-
-Function23da: ; 23da
- ld a, [hli]
- ld c, a
- ld [$dbfb], a
- ld a, l
- ld [$dbfc], a
- ld a, h
- ld [$dbfd], a
- ld a, c
- and a
- ret z
- ld bc, $0005
- call AddNTimes
- ret
-; 23f1
-
-Function23f1: ; 23f1
- ld a, [hli]
- ld c, a
- ld [$dbfe], a
- ld a, l
- ld [$dbff], a
- ld a, h
- ld [$dc00], a
- ld a, c
- and a
- ret z
- ld bc, $0008
- call AddNTimes
- ret
-; 2408
-
-Function2408: ; 2408
- ld a, [hli]
- ld c, a
- ld [$dc01], a
- ld a, l
- ld [$dc02], a
- ld a, h
- ld [$dc03], a
- ld a, c
- and a
- ret z
- ld bc, $0005
- call AddNTimes
- ret
-; 241f
-
-Function241f: ; 241f
- push hl
- call Function2471
- pop de
- ld hl, $d72e
- ld a, [de]
- inc de
- ld [$dc04], a
- ld a, e
- ld [$dc05], a
- ld a, d
- ld [$dc06], a
- ld a, [$dc04]
- call Function2457
- ld a, [$dc04]
- ld c, a
- ld a, $10
- sub c
- jr z, .asm_2454
- ld bc, $0001
- add hl, bc
- ld bc, $0010
-.asm_244a
- ld [hl], $0
- inc hl
- ld [hl], $ff
- dec hl
- add hl, bc
- dec a
- jr nz, .asm_244a
-
-.asm_2454
- ld h, d
- ld l, e
- ret
-; 2457
-
-Function2457: ; 2457
- and a
- ret z
- ld c, a
-.asm_245a
- push bc
- push hl
- ld a, $ff
- ld [hli], a
- ld b, $d
-.asm_2461
- ld a, [de]
- inc de
- ld [hli], a
- dec b
- jr nz, .asm_2461
- pop hl
- ld bc, $0010
- add hl, bc
- pop bc
- dec c
- jr nz, .asm_245a
- ret
-; 2471
-
-Function2471: ; 2471
- ld hl, $d4fe
- ld bc, $01e0
- xor a
- call ByteFill
- ld hl, $d4fe
- ld de, $0028
- ld c, $c
- xor a
-.asm_2484
- ld [hl], a
- add hl, de
- dec c
- jr nz, .asm_2484
- ret
-; 248a
-
-Function248a: ; 248a
- call GetMapEventBank
- rst Bankswitch
-
- ld hl, $d1a6
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- inc hl
- inc hl
- ld a, [WarpNumber]
- dec a
- ld c, a
- ld b, $0
- ld a, $5
- call AddNTimes
- ld a, [hli]
- ld [YCoord], a
- ld a, [hli]
- ld [XCoord], a
- ld a, [hli]
- cp $ff
- jr nz, .asm_24b3
- call Function24ba
-
-.asm_24b3
- ld a, $41
- ld hl, $486d
- rst FarCall
- ret
-; 24ba
-
-Function24ba: ; 24ba
- ld a, [$d149]
- ld [$dcac], a
- ld a, [$d14a]
- ld [BackupMapGroup], a
- ld a, [$d14b]
- ld [BackupMapNumber], a
- ret
-; 24cd
-
-Function24cd: ; 24cd
- ld hl, OverworldMap
- ld bc, $0514
- ld a, $0
- call ByteFill
- call Function24e4
- call FillMapConnections
- ld a, $1
- call Function263b
- ret
-; 24e4
-
-
-
-Function24e4: ; 24e4
- ld a, [hROMBank]
- push af
- ld hl, OverworldMap
- ld a, [$d19f]
- ld [hConnectedMapWidth], a
- add $6
- ld [hConnectionStripLength], a
- ld c, a
- ld b, $0
- add hl, bc
- add hl, bc
- add hl, bc
- ld c, $3
- add hl, bc
- ld a, [$d1a0]
- rst Bankswitch
-
- ld a, [$d1a1]
- ld e, a
- ld a, [$d1a2]
- ld d, a
- ld a, [$d19e]
- ld b, a
-.asm_250c
- push hl
- ld a, [hConnectedMapWidth]
- ld c, a
-.asm_2510
- ld a, [de]
- inc de
- ld [hli], a
- dec c
- jr nz, .asm_2510
- pop hl
- ld a, [hConnectionStripLength]
- add l
- ld l, a
- jr nc, .asm_251e
- inc h
-
-.asm_251e
- dec b
- jr nz, .asm_250c
- pop af
- rst Bankswitch
-
- ret
-; 2524
-
-
-
-FillMapConnections: ; 2524
-
-; North
- ld a, [NorthConnectedMapGroup]
- cp $ff
- jr z, .South
- ld b, a
- ld a, [NorthConnectedMapNumber]
- ld c, a
- call GetAnyMapBlockdataBank
-
- ld a, [NorthConnectionStripPointer]
- ld l, a
- ld a, [NorthConnectionStripPointer + 1]
- ld h, a
- ld a, [NorthConnectionStripLocation]
- ld e, a
- ld a, [NorthConnectionStripLocation + 1]
- ld d, a
- ld a, [NorthConnectionStripLength]
- ld [hConnectionStripLength], a
- ld a, [NorthConnectedMapWidth]
- ld [hConnectedMapWidth], a
- call FillNorthConnectionStrip
-
-.South
- ld a, [SouthConnectedMapGroup]
- cp $ff
- jr z, .West
- ld b, a
- ld a, [SouthConnectedMapNumber]
- ld c, a
- call GetAnyMapBlockdataBank
-
- ld a, [SouthConnectionStripPointer]
- ld l, a
- ld a, [SouthConnectionStripPointer + 1]
- ld h, a
- ld a, [SouthConnectionStripLocation]
- ld e, a
- ld a, [SouthConnectionStripLocation + 1]
- ld d, a
- ld a, [SouthConnectionStripLength]
- ld [hConnectionStripLength], a
- ld a, [SouthConnectedMapWidth]
- ld [hConnectedMapWidth], a
- call FillSouthConnectionStrip
-
-.West
- ld a, [WestConnectedMapGroup]
- cp $ff
- jr z, .East
- ld b, a
- ld a, [WestConnectedMapNumber]
- ld c, a
- call GetAnyMapBlockdataBank
-
- ld a, [WestConnectionStripPointer]
- ld l, a
- ld a, [WestConnectionStripPointer + 1]
- ld h, a
- ld a, [WestConnectionStripLocation]
- ld e, a
- ld a, [WestConnectionStripLocation + 1]
- ld d, a
- ld a, [WestConnectionStripLength]
- ld b, a
- ld a, [WestConnectedMapWidth]
- ld [hConnectionStripLength], a
- call FillWestConnectionStrip
-
-.East
- ld a, [EastConnectedMapGroup]
- cp $ff
- jr z, .Done
- ld b, a
- ld a, [EastConnectedMapNumber]
- ld c, a
- call GetAnyMapBlockdataBank
-
- ld a, [EastConnectionStripPointer]
- ld l, a
- ld a, [EastConnectionStripPointer + 1]
- ld h, a
- ld a, [EastConnectionStripLocation]
- ld e, a
- ld a, [EastConnectionStripLocation + 1]
- ld d, a
- ld a, [EastConnectionStripLength]
- ld b, a
- ld a, [EastConnectedMapWidth]
- ld [hConnectionStripLength], a
- call FillEastConnectionStrip
-
-.Done
- ret
-; 25d3
-
-
-FillNorthConnectionStrip:
-FillSouthConnectionStrip: ; 25d3
-
- ld c, 3
-.y
- push de
-
- push hl
- ld a, [hConnectionStripLength]
- ld b, a
-.x
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .x
- pop hl
-
- ld a, [hConnectedMapWidth]
- ld e, a
- ld d, 0
- add hl, de
- pop de
-
- ld a, [$d19f]
- add 6
- add e
- ld e, a
- jr nc, .asm_25f2
- inc d
-.asm_25f2
- dec c
- jr nz, .y
- ret
-; 25f6
-
-
-FillWestConnectionStrip:
-FillEastConnectionStrip: ; 25f6
-
-.asm_25f6
- ld a, [$d19f]
- add 6
- ld [hConnectedMapWidth], a
-
- push de
-
- push hl
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hli]
- ld [de], a
- inc de
- pop hl
-
- ld a, [hConnectionStripLength]
- ld e, a
- ld d, 0
- add hl, de
- pop de
-
- ld a, [hConnectedMapWidth]
- add e
- ld e, a
- jr nc, .asm_2617
- inc d
-.asm_2617
- dec b
- jr nz, .asm_25f6
- ret
-; 261b
-
-Function261b: ; 261b
- ld [$d432], a
- ret
-; 261f
-
-
-CallScript: ; 261f
-; Call a script at a:hl.
-
- ld [ScriptBank], a
- ld a, l
- ld [ScriptPos], a
- ld a, h
- ld [ScriptPos + 1], a
-
- ld a, $ff
- ld [ScriptRunning], a
-
- scf
- ret
-; 2631
-
-Function2631: ; 2631
- ld a, [ScriptRunning]
- and a
- ret nz
- call GetMapEventBank
- jr CallScript
-; 263b
-
-Function263b: ; 263b
- ld b, a
- ld a, [hROMBank]
- push af
- call Function2c52
- call Function2653
- jr nc, .done
-
- call GetMapEventBank
- ld b, a
- ld d, h
- ld e, l
- call Function2674
-
-.done
- pop af
- rst Bankswitch
- ret
-; 2653
-
-Function2653: ; 2653
- ld a, [$dc0a]
- ld c, a
- and a
- ret z
- ld hl, $dc0b
- ld a, [hli]
- ld h, [hl]
- ld l, a
- or h
- ret z
- ld de, $0003
-.asm_2664
- ld a, [hl]
- cp b
- jr z, .asm_266e
- add hl, de
- dec c
- jr nz, .asm_2664
- xor a
- ret
-
-.asm_266e
- inc hl
- ld a, [hli]
- ld h, [hl]
- ld l, a
- scf
- ret
-; 2674
-
-Function2674: ; 2674
- callba Unknown_0x974f3
- ld a, [ScriptMode]
- push af
- ld hl, ScriptFlags
- ld a, [hl]
- push af
- set 1, [hl]
- callba Function96c56
- callba ScriptEvents
- pop af
- ld [ScriptFlags], a
- pop af
- ld [ScriptMode], a
- ret
-; 269a
-
-Function269a: ; 269a
- ld a, [hROMBank]
- push af
- ld a, b
- rst Bankswitch
-
- push hl
- call SpeechTextBox
- call Function2e31
- ld a, 1
- ld [hOAMUpdate], a
- call Function321c
- pop hl
- call PrintTextBoxText
- xor a
- ld [hOAMUpdate], a
- pop af
- rst Bankswitch
-
- ret
-; 26b7
-
-Function26b7: ; 26b7
-; Call a:de.
-
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
- call .de
-
- pop af
- rst Bankswitch
- ret
-
-.de
- push de
- ret
-; 26c7
-
-Function26c7: ; 26c7
- ld a, [hROMBank]
- push af
- ld a, b
- rst Bankswitch
-
- ld a, c
- call Function19e9
-
- pop hl
- ld a, h
- rst Bankswitch
- ret
-; 26d4
-
-
-GetScriptByte: ; 0x26d4
-; Return byte at ScriptBank:ScriptPos in a.
-
- push hl
- push bc
- ld a, [hROMBank]
- push af
- ld a, [ScriptBank]
- rst Bankswitch
-
- ld hl, ScriptPos
- ld c, [hl]
- inc hl
- ld b, [hl]
-
- ld a, [bc]
-
- inc bc
- ld [hl], b
- dec hl
- ld [hl], c
-
- ld b, a
- pop af
- rst Bankswitch
- ld a, b
- pop bc
- pop hl
- ret
-; 0x26ef
-
-
-ObjectEvent: ; 0x26ef
- jumptextfaceplayer ObjectEventText
-; 0x26f2
-
-ObjectEventText:
- TX_FAR _ObjectEventText
- db "@"
-; 0x26f7
-
-
-BGEvent: ; 26f7
- jumptext BGEventText
-; 26fa
-
-BGEventText: ; 26fa
- text_jump UnknownText_0x1c46fc, BANK(UnknownText_0x1c46fc)
- db "@"
-; 26ff
-
-
-CoordinatesEvent: ; 26ff
- jumptext CoordinatesEventText
-; 2702
-
-CoordinatesEventText: ; 2702
- text_jump UnknownText_0x1c4706, BANK(UnknownText_0x1c4706)
- db "@"
-; 2707
-
-
-Function2707: ; 2707
- ld a, [hConnectionStripLength]
- ld e, a
- ld d, $0
- ld hl, $d81e
- add hl, de
- ld a, [hl]
- ret
-; 2712
-
-Function2712: ; 2712
- ld a, [hConnectionStripLength]
- ld e, a
- ld d, $0
- ld hl, $d81e
- add hl, de
- ld [hl], $ff
- ret
-; 271e
-
-Function271e: ; 271e
- ld a, [hConnectionStripLength]
- ld e, a
- ld d, $0
- ld hl, $d81e
- add hl, de
- ld [hl], $0
- ret
-; 272a
-
-
-Function272a: ; 272a
- ld hl, TileMap
- ld de, BGMapBuffer
- call Function27b7
- ld c, $28
- call Functiondbd
- ld a, [$d152]
- ld e, a
- ld a, [$d153]
- ld d, a
- call Function27d3
- ld a, $1
- ld [hBGMapUpdate], a
- ret
-; 2748
-
-Function2748: ; 2748
- ld hl, $c5e0
- ld de, BGMapBuffer
- call Function27b7
- ld c, $28
- call Functiondbd
- ld a, [$d152]
- ld l, a
- ld a, [$d153]
- ld h, a
- ld bc, $0200
- add hl, bc
- ld a, h
- and $3
- or $98
- ld e, l
- ld d, a
- call Function27d3
- ld a, $1
- ld [hBGMapUpdate], a
- ret
-; 2771
-
-Function2771: ; 2771
- ld hl, TileMap
- ld de, BGMapBuffer
- call Function27c0
- ld c, $24
- call Functiondbd
- ld a, [$d152]
- ld e, a
- ld a, [$d153]
- ld d, a
- call Function27f8
- ld a, $1
- ld [hBGMapUpdate], a
- ret
-; 278f
-
-Function278f: ; 278f
- ld hl, $c4b2
- ld de, BGMapBuffer
- call Function27c0
- ld c, $24
- call Functiondbd
- ld a, [$d152]
- ld e, a
- and $e0
- ld b, a
- ld a, e
- add $12
- and $1f
- or b
- ld e, a
- ld a, [$d153]
- ld d, a
- call Function27f8
- ld a, $1
- ld [hBGMapUpdate], a
- ret
-; 27b7
-
-Function27b7: ; 27b7
- ld c, $28
-.asm_27b9
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .asm_27b9
- ret
-; 27c0
-
-Function27c0: ; 27c0
- ld c, $12
-.asm_27c2
- ld a, [hli]
- ld [de], a
- inc de
- ld a, [hl]
- ld [de], a
- inc de
- ld a, $13
- add l
- ld l, a
- jr nc, .asm_27cf
- inc h
-
-.asm_27cf
- dec c
- jr nz, .asm_27c2
- ret
-; 27d3
-
-Function27d3: ; 27d3
- ld hl, BGMapBufferPtrs
- push de
- call .asm_27df
- pop de
- ld a, $20
- add e
- ld e, a
-
-.asm_27df
- ld c, $a
-.asm_27e1
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- ld a, e
- inc a
- inc a
- and $1f
- ld b, a
- ld a, e
- and $e0
- or b
- ld e, a
- dec c
- jr nz, .asm_27e1
- ld a, $14
- ld [$ffdc], a
- ret
-; 27f8
-
-Function27f8: ; 27f8
- ld hl, BGMapBufferPtrs
- ld c, $12
-.asm_27fd
- ld a, e
- ld [hli], a
- ld a, d
- ld [hli], a
- ld a, $20
- add e
- ld e, a
- jr nc, .asm_280e
- inc d
- ld a, d
- and $3
- or $98
- ld d, a
-
-.asm_280e
- dec c
- jr nz, .asm_27fd
- ld a, $12
- ld [$ffdc], a
- ret
-; 2816
-
-Function2816: ; 2816
- ld hl, BGMapBuffer
- ld bc, $0078
- xor a
- call ByteFill
- ret
-; 2821
-
-Function2821: ; 2821
- ld hl, TilesetAddress
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [TilesetBank]
- ld e, a
- ld a, [rSVBK]
- push af
- ld a, $6
- ld [rSVBK], a
- ld a, e
- ld de, $d000
- call FarDecompress
- ld hl, $d000
- ld de, VTiles2
- ld bc, $0600
- call CopyBytes
- ld a, [rVBK]
- push af
- ld a, $1
- ld [rVBK], a
- ld hl, $d600
- ld de, VTiles2
- ld bc, $0600
- call CopyBytes
- pop af
- ld [rVBK], a
- pop af
- ld [rSVBK], a
- ld a, [$d199]
- cp $1
- jr z, .asm_286f
- cp $2
- jr z, .asm_286f
- cp $4
- jr z, .asm_286f
- jr .asm_2875
-
-.asm_286f
- ld a, $7
- ld hl, $4000
- rst FarCall
-
-.asm_2875
- xor a
- ld [hTileAnimFrame], a
- ret
-; 2879
-
-Function2879: ; 2879
- ld hl, $d194
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, $dcb9
- ld c, $5
- ld b, $6
-.asm_2886
- push bc
- push hl
-.asm_2888
- ld a, [hli]
- ld [de], a
- inc de
- dec b
- jr nz, .asm_2888
- pop hl
- ld a, [$d19f]
- add $6
- ld c, a
- ld b, $0
- add hl, bc
- pop bc
- dec c
- jr nz, .asm_2886
- ret
-; 289d
-
-Function289d: ; 289d
- ld hl, $d194
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, $dcb9
- ld a, [$d19f]
- add $6
- ld [hConnectionStripLength], a
- ld a, [$d151]
- and a
- jr z, .asm_28cb
- cp $1
- jr z, .asm_28c0
- cp $2
- jr z, .asm_28d4
- cp $3
- jr z, .asm_28da
- ret
-
-.asm_28c0
- ld de, $dcbf
- ld a, [hConnectionStripLength]
- ld c, a
- ld b, $0
- add hl, bc
- jr .asm_28ce
-
-.asm_28cb
- ld de, $dcb9
-
-.asm_28ce
- ld b, $6
- ld c, $4
- jr .asm_28f7
-
-.asm_28d4
- ld de, $dcba
- inc hl
- jr .asm_28dd
-
-.asm_28da
- ld de, $dcb9
-
-.asm_28dd
- ld b, $5
- ld c, $5
- jr .asm_28f7
-
- ld hl, $d194
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [$d19f]
- add $6
- ld [hConnectionStripLength], a
- ld de, $dcb9
- ld b, $6
- ld c, $5
-
-.asm_28f7
- push bc
- push hl
- push de
-.asm_28fa
- ld a, [de]
- inc de
- ld [hli], a
- dec b
- jr nz, .asm_28fa
- pop de
- ld a, e
- add $6
- ld e, a
- jr nc, .asm_2908
- inc d
-
-.asm_2908
- pop hl
- ld a, [hConnectionStripLength]
- ld c, a
- ld b, $0
- add hl, bc
- pop bc
- dec c
- jr nz, .asm_28f7
- ret
-; 2914
-
-Function2914: ; 2914
- xor a
- ld [TilePermissions], a
- call Function296c
- call Function294d
- ld a, [MapX]
- ld d, a
- ld a, [MapY]
- ld e, a
- call Function2a3c
- ld [StandingTile], a
- call Function29ff
- ret nz
- ld a, [StandingTile]
- and 7
- ld hl, .data_2945
- add l
- ld l, a
- ld a, 0
- adc h
- ld h, a
- ld a, [hl]
- ld hl, TilePermissions
- or [hl]
- ld [hl], a
- ret
-; 2945
-
-.data_2945 ; 2945
- db 1, 2, 4, 8, 9, 10, 5, 6
-; 294d
-
-Function294d: ; 294d
- ld a, [MapX]
- ld d, a
- ld a, [MapY]
- ld e, a
- push de
- inc e
- call Function2a3c
- ld [TileDown], a
- call Function298b
- pop de
- dec e
- call Function2a3c
- ld [TileUp], a
- call Function29a8
- ret
-; 296c
-
-Function296c: ; 296c
- ld a, [MapX]
- ld d, a
- ld a, [MapY]
- ld e, a
- push de
- dec d
- call Function2a3c
- ld [TileLeft], a
- call Function29e2
- pop de
- inc d
- call Function2a3c
- ld [TileRight], a
- call Function29c5
- ret
-; 298b
-
-Function298b: ; 298b
- call Function29ff
- ret nz
- ld a, [TileDown]
- and $7
- cp $2
- jr z, .asm_299f
- cp $6
- jr z, .asm_299f
- cp $7
- ret nz
-
-.asm_299f
- ld a, [TilePermissions]
- or $8
- ld [TilePermissions], a
- ret
-; 29a8
-
-Function29a8: ; 29a8
- call Function29ff
- ret nz
- ld a, [TileUp]
- and $7
- cp $3
- jr z, .asm_29bc
- cp $4
- jr z, .asm_29bc
- cp $5
- ret nz
-
-.asm_29bc
- ld a, [TilePermissions]
- or $4
- ld [TilePermissions], a
- ret
-; 29c5
-
-Function29c5: ; 29c5
- call Function29ff
- ret nz
- ld a, [TileRight]
- and $7
- cp $1
- jr z, .asm_29d9
- cp $5
- jr z, .asm_29d9
- cp $7
- ret nz
-
-.asm_29d9
- ld a, [TilePermissions]
- or $1
- ld [TilePermissions], a
- ret
-; 29e2
-
-Function29e2: ; 29e2
- call Function29ff
- ret nz
- ld a, [TileLeft]
- and $7
- cp $0
- jr z, .asm_29f6
- cp $4
- jr z, .asm_29f6
- cp $6
- ret nz
-
-.asm_29f6
- ld a, [TilePermissions]
- or $2
- ld [TilePermissions], a
- ret
-; 29ff
-
-Function29ff: ; 29ff
- and $f0
- cp $b0
- ret z
- cp $c0
- ret
-; 2a07
-
-
-GetFacingTileCoord: ; 2a07
-; Return map coordinates in (d, e) and tile id in a
-; of the tile the player is facing.
-
- ld a, [PlayerDirection]
- and %1100
- srl a
- srl a
- ld l, a
- ld h, 0
- add hl, hl
- add hl, hl
- ld de, .Directions
- add hl, de
-
- ld d, [hl]
- inc hl
- ld e, [hl]
- inc hl
-
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
- ld a, [MapX]
- add d
- ld d, a
- ld a, [MapY]
- add e
- ld e, a
- ld a, [hl]
- ret
-
-.Directions
- ; x, y
- db 0, 1
- dw TileDown
- db 0, -1
- dw TileUp
- db -1, 0
- dw TileLeft
- db 1, 0
- dw TileRight
-; 2a3c
-
-
-Function2a3c: ; 2a3c
- call Function2a66
- ld a, [hl]
- and a
- jr z, .asm_2a63
- ld l, a
- ld h, $0
- add hl, hl
- add hl, hl
- ld a, [TilesetCollisionAddress]
- ld c, a
- ld a, [$d1e1]
- ld b, a
- add hl, bc
- rr d
- jr nc, .asm_2a56
- inc hl
-
-.asm_2a56
- rr e
- jr nc, .asm_2a5c
- inc hl
- inc hl
-
-.asm_2a5c
- ld a, [TilesetCollisionBank]
- call GetFarByte
- ret
-
-.asm_2a63
- ld a, $ff
- ret
-; 2a66
-
-Function2a66: ; 2a66
- ld a, [$d19f]
- add $6
- ld c, a
- ld b, $0
- ld hl, $c801
- add hl, bc
- ld a, e
- srl a
- jr z, .asm_2a84
- and a
-.asm_2a78
- srl a
- jr nc, .asm_2a7d
- add hl, bc
-
-.asm_2a7d
- sla c
- rl b
- and a
- jr nz, .asm_2a78
-
-.asm_2a84
- ld c, d
- srl c
- ld b, $0
- add hl, bc
- ret
-; 2a8b
-
-
-CheckFacingSign: ; 2a8b
- call GetFacingTileCoord
- ld b, a
- ld a, d
- sub 4
- ld d, a
- ld a, e
- sub 4
- ld e, a
- ld a, [$dc01]
- and a
- ret z
- ld c, a
- ld a, [hROMBank]
- push af
- call Function2c52
- call Function2aaa
- pop hl
- ld a, h
- rst Bankswitch
- ret
-; 2aaa
-
-Function2aaa: ; 2aaa
- ld hl, $dc02
- ld a, [hli]
- ld h, [hl]
- ld l, a
-.asm_2ab0
- push hl
- ld a, [hli]
- cp e
- jr nz, .asm_2abb
- ld a, [hli]
- cp d
- jr nz, .asm_2abb
- jr .asm_2ac8
-
-.asm_2abb
- pop hl
- ld a, 5
- add l
- ld l, a
- jr nc, .asm_2ac3
- inc h
-
-.asm_2ac3
- dec c
- jr nz, .asm_2ab0
- xor a
- ret
-
-.asm_2ac8
- pop hl
- ld de, EngineBuffer1
- ld bc, 5
- call CopyBytes
- scf
- ret
-; 2ad4
-
-Function2ad4: ; 2ad4
- ld a, [$dbfe]
- and a
- ret z
- ld c, a
- ld a, [hROMBank]
- push af
- call Function2c52
- call Function2ae7
- pop hl
- ld a, h
- rst Bankswitch
- ret
-; 2ae7
-
-Function2ae7: ; 2ae7
- ld hl, $dbff
- ld a, [hli]
- ld h, [hl]
- ld l, a
- call Function211b
- ld b, a
- ld a, [MapX]
- sub $4
- ld d, a
- ld a, [MapY]
- sub $4
- ld e, a
-.asm_2afd
- push hl
- ld a, [hli]
- cp b
- jr z, .asm_2b06
- cp $ff
- jr nz, .asm_2b10
-
-.asm_2b06
- ld a, [hli]
- cp e
- jr nz, .asm_2b10
- ld a, [hli]
- cp d
- jr nz, .asm_2b10
- jr .asm_2b1d
-
-.asm_2b10
- pop hl
- ld a, $8
- add l
- ld l, a
- jr nc, .asm_2b18
- inc h
-
-.asm_2b18
- dec c
- jr nz, .asm_2afd
- xor a
- ret
-
-.asm_2b1d
- pop hl
- ld de, EngineBuffer1
- ld bc, $0008
- call CopyBytes
- scf
- ret
-; 2b29
-
-
-FadeToMenu: ; 2b29
- xor a
- ld [hBGMapMode], a
- call Function1d6e
- ld a, $23
- ld hl, $4084
- rst FarCall
- call ClearSprites
- call Function2ed3
- ret
-; 2b3c
-
-
-Function2b3c: ; 2b3c
- call WhiteBGMap
- call Function2bae
- call Function1ad2
- call Function1d7d
- call Functiond90
- jr Function2b5c
-; 2b4d
-
-Function2b4d: ; 2b4d
- call WhiteBGMap
- call Function1d7d
- call Function2bae
- call Function1ad2
- call Functiond90
-; 2b5c
-
-Function2b5c: ; 2b5c
- ld b, $9
- call GetSGBLayout
- ld a, $12
- ld hl, $5409
- rst FarCall
- call Function3200
- ld a, $23
- ld hl, $4079
- rst FarCall
- call Function2ee4
- ret
-; 2b74
-
-
-Function2b74: ; 0x2b74
- push af
- ld a, $1
- ld [$c2ce], a
- call WhiteBGMap
- call ClearSprites
- call Function2bae
- ld hl, $c590 ; tile 0, 12
- ld bc, $0412
- call TextBox
- ld hl, VramState
- set 0, [hl]
- call Function1ad2
- call Function3200
- ld b, $9
- call GetSGBLayout
- callba Function49409
- call UpdateTimePals
- call DelayFrame
- ld a, $1
- ld [$ffde], a
- pop af
- ret
-; 0x2bae
-
-Function2bae: ; 2bae
- call DisableLCD
- call ClearSprites
- ld a, $5
- ld hl, $4168
- rst FarCall
- call Functione51
- call Functione5f
- ld a, [hROMBank]
- push af
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- call Function2c24
- ld a, $23
- ld hl, $4001
- rst FarCall
- call Function2173
- call Function2821
- ld a, $9
- call Function3cb4
- pop af
- rst Bankswitch
-
- call EnableLCD
- ret
-; 2be5
-
-
-GetMapHeaderPointer: ; 2be5
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
-; 2bed
-
-GetAnyMapHeaderPointer: ; 0x2bed
-; Prior to calling this function, you must have switched banks so that
-; MapGroupPointers is visible.
-
-; inputs:
-; b = map group, c = map number
-; XXX de = ???
-
-; outputs:
-; hl points to the map header
- push bc ; save map number for later
-
- ; get pointer to map group
- dec b
- ld c, b
- ld b, $0
- ld hl, MapGroupPointers
- add hl, bc
- add hl, bc
-
- ld a, [hli]
- ld h, [hl]
- ld l, a
- pop bc ; restore map number
-
- ; find the cth map header
- dec c
- ld b, $0
- ld a, OlivineGym_MapHeader - OlivinePokeCenter1F_MapHeader
- call AddNTimes
- ret
-; 0x2c04
-
-GetMapHeaderMember: ; 0x2c04
-; Extract data from the current map's header.
-
-; inputs:
-; de = offset of desired data within the mapheader
-
-; outputs:
-; bc = data from the current map's header
-; (e.g., de = $0003 would return a pointer to the secondary map header)
-
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- ; fallthrough
-
-GetAnyMapHeaderMember: ; 0x2c0c
- ; bankswitch
- ld a, [hROMBank]
- push af
- ld a, BANK(MapGroupPointers)
- rst Bankswitch
-
- call GetAnyMapHeaderPointer
- add hl, de
- ld c, [hl]
- inc hl
- ld b, [hl]
-
- ; bankswitch back
- pop af
- rst Bankswitch
- ret
-; 0x2c1c
-
-
-Function2c1c: ; 2c1c
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
-; 2c24
-
-Function2c24: ; 2c24
- call Function2c31
- rst Bankswitch
- ret
-; 2c29
-
-
-Function2c29: ; 2c29
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
-; 2c31
-
-Function2c31: ; 2c31
- push hl
- push de
- ld de, $0000
- call GetAnyMapHeaderMember
- ld a, c
- pop de
- pop hl
- ret
-; 2c3d
-
-Function2c3d: ; 2c3d
- ld a, [hROMBank]
- push af
- ld a, $25
- rst Bankswitch
- call GetMapHeaderPointer
- ld de, $d198
- ld bc, $0005
- call CopyBytes
- pop af
- rst Bankswitch
- ret
-; 2c52
-
-Function2c52: ; 2c52
- ld a, [MapEventBank]
- rst Bankswitch
- ret
-; 2c57
-
-
-GetMapEventBank: ; 2c57
- ld a, [MapEventBank]
- ret
-; 2c5b
-
-GetAnyMapBlockdataBank: ; 2c5b
-; Return the blockdata bank for group b map c.
- push hl
- push de
- push bc
-
- push bc
- ld de, 3 ; second map header pointer
- call GetAnyMapHeaderMember
- ld l, c
- ld h, b
- pop bc
-
- push hl
- ld de, 0 ; second map header bank
- call GetAnyMapHeaderMember
- pop hl
-
- ld de, 3 ; blockdata bank
- add hl, de
- ld a, c
- call GetFarByte
- rst Bankswitch
-
- pop bc
- pop de
- pop hl
- ret
-; 2c7d
-
-GetSecondaryMapHeaderPointer: ; 0x2c7d
-; returns the current map's secondary map header pointer in hl.
- push bc
- push de
- ld de, $0003 ; secondary map header pointer (offset within header)
- call GetMapHeaderMember
- ld l, c
- ld h, b
- pop de
- pop bc
- ret
-; 2c8a
-
-GetMapPermission: ; 2c8a
- push hl
- push de
- push bc
- ld de, 2
- call GetMapHeaderMember
- ld a, c
- pop bc
- pop de
- pop hl
- ret
-; 2c98
-
-Function2c98: ; 2c98
- ret
-; 2c99
-
-Function2c99: ; 2c99
- push hl
- push de
- push bc
- ld de, $0002
- call GetAnyMapHeaderMember
- ld a, c
- pop bc
- pop de
- pop hl
- ret
-; 2ca7
-
-Function2ca7: ; 2ca7
- ld de, $0001
- call GetAnyMapHeaderMember
- ld a, c
- ret
-; 2caf
-
-GetWorldMapLocation: ; 0x2caf
-; given a map group/id in bc, return its location on the Pokégear map.
- push hl
- push de
- push bc
- ld de, 5
- call GetAnyMapHeaderMember
- ld a, c
- pop bc
- pop de
- pop hl
- ret
-; 0x2cbd
-
-Function2cbd: ; 2cbd
- push hl
- push bc
- ld de, $0006
- call GetMapHeaderMember
- ld a, c
- cp $64
- jr z, .asm_2cee
- bit 7, c
- jr nz, .asm_2cda
- ld a, $22
- ld hl, $7342
- rst FarCall
- ld e, c
- ld d, $0
-.asm_2cd7
- pop bc
- pop hl
- ret
-
-.asm_2cda
- ld a, [StatusFlags2]
- bit 0, a
- jr z, .asm_2ce6
- ld de, $0056
- jr .asm_2cd7
-
-.asm_2ce6
- ld a, c
- and $7f
- ld e, a
- ld d, $0
- jr .asm_2cd7
-
-.asm_2cee
- ld a, [StatusFlags2]
- bit 7, a
- jr z, .asm_2cfa
- ld de, $0048
- jr .asm_2cd7
-
-.asm_2cfa
- ld de, $0026
- jr .asm_2cd7
-; 2cff
-
-Function2cff: ; 2cff
- call Function2d0d
- and $f
- ret
-; 2d05
-
-Function2d05: ; 2d05
- call Function2d0d
- and $f0
- swap a
- ret
-; 2d0d
-
-Function2d0d: ; 2d0d
- push hl
- push bc
- ld de, $0007
- call GetMapHeaderMember
- ld a, c
- pop bc
- pop hl
- ret
-; 2d19
-
-Function2d19: ; 2d19
- push de
- push hl
- push bc
- ld de, $0008
- call GetMapHeaderMember
- ld a, c
- pop bc
- pop hl
- pop de
- ret
-; 2d27
-
-Function2d27: ; 2d27
- push hl
- push bc
- ld hl, $5596
- ld bc, $000f
- ld a, [$d199]
- call AddNTimes
- ld de, TilesetBank
- ld bc, $000f
- ld a, $13
- call FarCopyBytes
- pop bc
- pop hl
- ret
-; 2d43
-
-Function2d43: ; 2d43
+Function2d43: ; 2d43
+; Inexplicably empty.
+; Seen in PredefPointers.
nop
nop
nop
@@ -2906,64 +502,10 @@
; 2d54
-INCLUDE "engine/farcall.asm"
+INCLUDE "home/farcall.asm"
+INCLUDE "home/predef.asm"
-Predef: ; 2d83
-; Call predefined function a.
-; Preserves bc, de, hl and f.
-
- ld [PredefID], a
- ld a, [hROMBank]
- push af
-
- ld a, BANK(GetPredefPointer)
- rst Bankswitch
- call GetPredefPointer ; stores hl in PredefTemp
-
-; Switch to the new function's bank
- rst Bankswitch
-
-; Instead of directly calling stuff,
-; push it to the stack in reverse.
-
- ld hl, .Return
- push hl
-
-; Call the Predef function
- ld a, [PredefAddress]
- ld h, a
- ld a, [PredefAddress + 1]
- ld l, a
- push hl
-
-; Get hl back
- ld a, [PredefTemp]
- ld h, a
- ld a, [PredefTemp + 1]
- ld l, a
- ret
-
-.Return
-; Clean up after the Predef call
-
- ld a, h
- ld [PredefTemp], a
- ld a, l
- ld [PredefTemp+1], a
-
- pop hl
- ld a, h
- rst Bankswitch
-
- ld a, [PredefTemp]
- ld h, a
- ld a, [PredefTemp + 1]
- ld l, a
- ret
-; 2dba
-
-
ResetWindow: ; 2dba
call Function1fbf
@@ -3071,125 +613,16 @@
ret
; 2e50
-Function2e50: ; 2e50
- xor a
- ld hl, EventFlags
- ld [hli], a
- ret
-; 2e56
-Function2e56: ; 2e56
- xor a
- ld hl, BikeFlags
- ld [hli], a
- ld [hl], a
- ret
-; 2e5d
+INCLUDE "home/flag.asm"
-Function2e5d: ; 2e5d
- ld a, [$d19a]
- cp $2
- jr z, .asm_2e69
- cp $1
- jr z, .asm_2e69
- ret
-.asm_2e69
- ld hl, StatusFlags
- res 2, [hl]
- ret
-; 2e6f
-
-
-EventFlagAction: ; 0x2e6f
- ld hl, EventFlags
- call FlagAction
- ret
-
-FlagAction: ; 0x2e76
-; Perform a function on a bit in memory.
-
-; inputs:
-; b: function
-; 0 clear bit
-; 1 set bit
-; 2 check bit
-; de: bit number
-; hl: index within bit table
-
- ; get index within the byte
- ld a, e
- and $7
-
- ; shift de right by three bits (get the index within memory)
- srl d
- rr e
- srl d
- rr e
- srl d
- rr e
- add hl, de
-
- ; implement a decoder
- ld c, $1
- rrca
- jr nc, .one
- rlc c
-.one
- rrca
- jr nc, .two
- rlc c
- rlc c
-.two
- rrca
- jr nc, .three
- swap c
-.three
-
- ; check b's value: 0, 1, 2
- ld a, b
- cp 1
- jr c, .clearbit ; 0
- jr z, .setbit ; 1
-
- ; check bit
- ld a, [hl]
- and c
- ld c, a
- ret
-
-.setbit
- ; set bit
- ld a, [hl]
- or c
- ld [hl], a
- ret
-
-.clearbit
- ; clear bit
- ld a, c
- cpl
- and [hl]
- ld [hl], a
- ret
-; 0x2ead
-
-
-Function2ead: ; 2ead
- ld de, ENGINE_POKEDEX
- ld b, CHECK_FLAG
- callba EngineFlagAction
- ld a, c
- and a
- ret
-; 2ebb
-
-Function2ebb: ; 2ebb
+Function2ebb: ; 2ebb
ld a, [$c2cc]
bit 1, a
ret z
ld a, [hJoyDown]
- bit 1, a
+ bit A_BUTTON, a
ret
; 2ec6
@@ -3205,7 +638,6 @@
ret
; 2ecb
-
Function2ecb: ; 2ecb
push hl
ld hl, $c2cc
@@ -3239,55 +671,24 @@
; 2ef6
-InitString: ; 2ef6
-; Init a string of length c.
- push hl
- jr _InitString
-; 2ef9
+INCLUDE "home/string.asm"
-InitName: ; 2ef9
-; Intended for names, so this function is limited to ten characters.
- push hl
- ld c, 10
-; 2efc
-_InitString: ; 2efc
-; if the string pointed to by hl is empty (defined as "zero or more spaces
-; followed by a null"), then initialize it to the string pointed to by de.
- push bc
-.loop
- ld a, [hli]
- cp "@"
- jr z, .blank
- cp " "
- jr nz, .notblank
- dec c
- jr nz, .loop
-.blank
- pop bc
- ld l, e
- ld h, d
- pop de
- ld b, $0
- inc c
- call CopyBytes
- ret
-.notblank
- pop bc
- pop hl
- ret
-; 2f17
+IsInJohto: ; 2f17
+; Return 0 if the player is in Johto, and 1 in Kanto.
-Function2f17: ; 2f17
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
- cp $5f
- jr z, .asm_2f39
- cp $0
- jr nz, .asm_2f35
+
+ cp $5f ; SS Aqua
+ jr z, .Johto
+
+ cp $0 ; Poke Center 2F
+ jr nz, .CheckRegion
+
ld a, [BackupMapGroup]
ld b, a
ld a, [BackupMapNumber]
@@ -3294,16 +695,16 @@
ld c, a
call GetWorldMapLocation
-.asm_2f35
- cp $2f
- jr nc, .asm_2f3b
+.CheckRegion
+ cp $2f ; Pallet Town
+ jr nc, .Kanto
-.asm_2f39
+.Johto
xor a
ret
-.asm_2f3b
- ld a, $1
+.Kanto
+ ld a, 1
ret
; 2f3e
@@ -3312,195 +713,12 @@
ret
; 2f3f
-DoItemEffect: ; 2f3f
- callba _DoItemEffect
- ret
-; 2f46
-CheckTossableItem: ; 2f46
- push hl
- push de
- push bc
- callba _CheckTossableItem
- pop bc
- pop de
- pop hl
- ret
-; 2f53
+INCLUDE "home/item.asm"
+INCLUDE "home/random.asm"
+INCLUDE "home/sram.asm"
-Function2f53: ; 2f53
- push hl
- push de
- push bc
- ld a, [hROMBank]
- push af
- ld a, $3
- rst Bankswitch
- call $520d
- pop bc
- ld a, b
- rst Bankswitch
-
- pop bc
- pop de
- pop hl
- ret
-; 2f66
-
-Function2f66: ; 2f66
- push bc
- ld a, [hROMBank]
- push af
- ld a, $3
- rst Bankswitch
-
- push hl
- push de
- call $51d5
- pop de
- pop hl
- pop bc
- ld a, b
- rst Bankswitch
-
- pop bc
- ret
-; 2f79
-
-PickUpItem: ; 2f79
- push hl
- push de
- push bc
- ld a, [hROMBank]
- push af
- ld a, BANK(_PickUpItem)
- rst Bankswitch
-
- call _PickUpItem
-
- pop bc
- ld a, b
- rst Bankswitch
- pop bc
- pop de
- pop hl
- ret
-; 2f8c
-
-
-Random: ; 2f8c
-; A simple hardware-based random number generator (RNG).
-
-; Two random numbers are generated by adding and subtracting
-; the divider to the respective values every time it's called.
-
-; The divider is a register that increments at a rate of 16384Hz.
-; For comparison, the Game Boy operates at a clock speed of 4.2MHz.
-
-; Additionally, an equivalent function is executed in VBlank.
-
-; This leaves a with the value in hRandomSub.
-
- push bc
-
- ld a, [rDIV]
- ld b, a
- ld a, [hRandomAdd]
- adc b
- ld [hRandomAdd], a
-
- ld a, [rDIV]
- ld b, a
- ld a, [hRandomSub]
- sbc b
- ld [hRandomSub], a
-
- pop bc
- ret
-; 2f9f
-
-BattleRandom: ; 2f9f
-; _BattleRandom lives in another bank.
-
-; It handles all RNG calls in the battle engine, allowing
-; link battles to remain in sync using a shared PRNG.
-
- ld a, [hROMBank]
- push af
- ld a, BANK(_BattleRandom)
- rst Bankswitch
-
- call _BattleRandom
-
- ld [$cfb6], a
- pop af
- rst Bankswitch
- ld a, [$cfb6]
- ret
-; 2fb1
-
-
-Function2fb1: ; 2fb1
- push bc
- ld c, a
- xor a
- sub c
-.asm_2fb5
- sub c
- jr nc, .asm_2fb5
- add c
- ld b, a
- push bc
-.asm_2fbb
- call Random
- ld a, [hRandomAdd]
- ld c, a
- add b
- jr c, .asm_2fbb
- ld a, c
- pop bc
- call SimpleDivide
- pop bc
- ret
-; 2fcb
-
-GetSRAMBank: ; 2fcb
-; load sram bank a
-; if invalid bank, sram is disabled
- cp NUM_SRAM_BANKS
- jr c, OpenSRAM
- jr CloseSRAM
-; 2fd1
-
-OpenSRAM: ; 2fd1
-; switch to sram bank a
- push af
-; latch clock data
- ld a, 1
- ld [MBC3LatchClock], a
-; enable sram/clock write
- ld a, SRAM_ENABLE
- ld [MBC3SRamEnable], a
-; select sram bank
- pop af
- ld [MBC3SRamBank], a
- ret
-; 2fe1
-
-CloseSRAM: ; 2fe1
-; preserve a
- push af
- ld a, SRAM_DISABLE
-; reset clock latch for next time
- ld [MBC3LatchClock], a
-; disable sram/clock write
- ld [MBC3SRamEnable], a
- pop af
- ret
-; 2fec
-
-
; Register aliases
_hl_: ; 2fec
@@ -3513,31 +731,9 @@
; 2fef
-Function2fef: ; 2fef
- ld hl, rKEY1
- bit 7, [hl]
- jr z, Function2ffd
- ret
-; 2ff7
+INCLUDE "home/double_speed.asm"
-Function2ff7: ; 2ff7
- ld hl, rKEY1
- bit 7, [hl]
- ret z
-; 2ffd
-Function2ffd: ; 2ffd
- set 0, [hl]
- xor a
- ld [rIF], a
- ld [rIE], a
- ld a, $30
- ld [rJOYP], a
- stop ; rgbasm adds a nop after this instruction by default
- ret
-; 300b
-
-
ClearSprites: ; 300b
ld hl, Sprites
ld b, TileMap - Sprites
@@ -3563,140 +759,10 @@
ret
; 3026
-CopyBytes: ; 0x3026
-; copy bc bytes from hl to de
- inc b ; we bail the moment b hits 0, so include the last run
- inc c ; same thing; include last byte
- jr .HandleLoop
-.CopyByte
- ld a, [hli]
- ld [de], a
- inc de
-.HandleLoop
- dec c
- jr nz, .CopyByte
- dec b
- jr nz, .CopyByte
- ret
-SwapBytes: ; 0x3034
-; swap bc bytes between hl and de
-.Loop
- ; stash [hl] away on the stack
- ld a, [hl]
- push af
+INCLUDE "home/copy2.asm"
- ; copy a byte from [de] to [hl]
- ld a, [de]
- ld [hli], a
- ; retrieve the previous value of [hl]; put it in [de]
- pop af
- ld [de], a
-
- ; handle loop stuff
- inc de
- dec bc
- ld a, b
- or c
- jr nz, .Loop
- ret
-
-ByteFill: ; 0x3041
-; fill bc bytes with the value of a, starting at hl
- inc b ; we bail the moment b hits 0, so include the last run
- inc c ; same thing; include last byte
- jr .HandleLoop
-.PutByte
- ld [hli], a
-.HandleLoop
- dec c
- jr nz, .PutByte
- dec b
- jr nz, .PutByte
- ret
-
-GetFarByte: ; 0x304d
-; retrieve a single byte from a:hl, and return it in a.
- ; bankswitch to new bank
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
- ; get byte from new bank
- ld a, [hl]
- ld [hBuffer], a
-
- ; bankswitch to previous bank
- pop af
- rst Bankswitch
-
- ; return retrieved value in a
- ld a, [hBuffer]
- ret
-
-GetFarHalfword: ; 0x305d
-; retrieve a halfword from a:hl, and return it in hl.
- ; bankswitch to new bank
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
- ; get halfword from new bank, put it in hl
- ld a, [hli]
- ld h, [hl]
- ld l, a
-
- ; bankswitch to previous bank and return
- pop af
- rst Bankswitch
- ret
-; 0x306b
-
-Function306b: ; 306b
- ld [hBuffer], a
- ld a, [rSVBK]
- push af
- ld a, [hBuffer]
- ld [rSVBK], a
- call CopyBytes
- pop af
- ld [rSVBK], a
- ret
-; 307b
-
-Function307b: ; 307b
- ld [hBuffer], a
- ld a, [rSVBK]
- push af
- ld a, [hBuffer]
- ld [rSVBK], a
- ld a, [hl]
- ld [hBuffer], a
- pop af
- ld [rSVBK], a
- ld a, [hBuffer]
- ret
-; 308d
-
-Function308d: ; 308d
- ld [hBuffer], a
- ld a, [rSVBK]
- push af
- ld a, [hBuffer]
- ld [rSVBK], a
- ld a, [hli]
- ld h, [hl]
- ld l, a
- pop af
- ld [rSVBK], a
- ret
-; 309d
-
Function309d: ; 309d
ld a, [rSVBK]
push af
@@ -3795,83 +861,9 @@
; 0x3105
-SimpleMultiply: ; 3105
-; Return a * c.
- and a
- ret z
+INCLUDE "home/math.asm"
- push bc
- ld b, a
- xor a
-.loop
- add c
- dec b
- jr nz, .loop
- pop bc
- ret
-; 3110
-
-SimpleDivide: ; 3110
-; Divide a by c. Return quotient b and remainder a.
- ld b, 0
-.loop
- inc b
- sub c
- jr nc, .loop
- dec b
- add c
- ret
-; 3119
-
-
-Multiply: ; 3119
-; Multiply hMultiplicand (3 bytes) by hMultiplier. Result in hProduct.
-; All values are big endian.
- push hl
- push bc
-
- callab _Multiply
-
- pop bc
- pop hl
- ret
-; 3124
-
-
-Divide: ; 3124
-; Divide hDividend length b (max 4 bytes) by hDivisor. Result in hQuotient.
-; All values are big endian.
- push hl
- push de
- push bc
- ld a, [hROMBank]
- push af
- ld a, BANK(_Divide)
- rst Bankswitch
-
- call _Divide
-
- pop af
- rst Bankswitch
- pop bc
- pop de
- pop hl
- ret
-; 3136
-
-
-SubtractSigned: ; 3136
-; Return a - b, sign in carry.
- sub b
- ret nc
- cpl
- add 1
- scf
- ret
-; 313d
-
-
PrintLetterDelay: ; 313d
; wait some frames before printing the next letter
; the text speed setting in Options is actually a frame count
@@ -3958,6 +950,7 @@
ret
; 318c
+
CopyDataUntil: ; 318c
; Copies [hl, bc) to [de, bc - hl).
; In other words, the source data is from hl up to but not including bc,
@@ -3974,12 +967,15 @@
ret
; 0x3198
+
PrintNum: ; 3198
ld a, [hROMBank]
push af
ld a, BANK(_PrintNum)
rst Bankswitch
+
call _PrintNum
+
pop af
rst Bankswitch
ret
@@ -3989,18 +985,18 @@
Function31a4: ; 31a4
ld a, [hROMBank]
push af
- ld a, $41
+ ld a, BANK(Function1061ef)
rst Bankswitch
- call $61ef
+ call Function1061ef
+
pop af
rst Bankswitch
-
ret
; 31b0
-Function31b0: ; 31b0
+FarPrintText: ; 31b0
ld [hBuffer], a
ld a, [hROMBank]
push af
@@ -4008,13 +1004,14 @@
rst Bankswitch
call PrintText
+
pop af
rst Bankswitch
-
ret
; 31be
-Function31be: ; 31be
+
+CallPointerAt: ; 31be
ld a, [hROMBank]
push af
ld a, [hli]
@@ -4032,10 +1029,13 @@
ret
; 31cd
+
Function31cd: ; 31cd
+; Push pointer hl in the current bank to $d0e8.
ld a, [hROMBank]
Function31cf: ; 31cf
+; Push pointer a:hl to $d0e8.
ld [$d0e8], a
ld a, l
ld [$d0e9], a
@@ -4099,15 +1099,15 @@
ld a, [hCGB]
and a
jr z, .asm_320e
- ld a, $2
+ ld a, 2
ld [hBGMapMode], a
- ld c, $4
+ ld c, 4
call DelayFrames
.asm_320e
- ld a, $1
+ ld a, 1
ld [hBGMapMode], a
- ld c, $4
+ ld c, 4
call DelayFrames
ret
; 0x3218
@@ -4124,9 +1124,11 @@
ld a, [hCGB]
and a
jr z, .asm_322e
+
ld a, [$c2ce]
cp 0
jr z, .asm_322e
+
ld a, 1
ld [hBGMapMode], a
jr Function323d
@@ -4275,20 +1277,21 @@
ret
.cgb
-; Save WRAM bank
ld a, [rSVBK]
push af
-; WRAM bank 5
+
ld a, 5
ld [rSVBK], a
+
; Fill BGPals and OBPals with $ffff (white)
ld hl, BGPals
- ld bc, $0080
+ ld bc, $80
ld a, $ff
call ByteFill
-; Restore WRAM bank
+
pop af
ld [rSVBK], a
+
; Request palette update
ld a, 1
ld [hCGBPalUpdate], a
@@ -4295,6 +1298,7 @@
ret
; 333e
+
ClearSGB: ; 333e
ld b, $ff
GetSGBLayout: ; 3340
@@ -4368,9 +1372,9 @@
GetWeekday: ; 3376
ld a, [CurDay]
-.loop
+.mod
sub 7
- jr nc, .loop
+ jr nc, .mod
add 7
ret
; 3380
@@ -4379,39 +1383,38 @@
SetSeenAndCaughtMon: ; 3380
push af
ld c, a
- ld hl, PokedexSeen
- ld b, 1
- call GetWramFlag
+ ld hl, PokedexCaught
+ ld b, SET_FLAG
+ call PokedexFlagAction
pop af
; fallthrough
; 338b
-SetCaughtMon: ; 338b
+SetSeenMon: ; 338b
ld c, a
- ld hl, PokedexCaught
- ld b, 1
- jr GetWramFlag
+ ld hl, PokedexSeen
+ ld b, SET_FLAG
+ jr PokedexFlagAction
; 3393
-CheckSeenMon: ; 3393
+CheckCaughtMon: ; 3393
ld c, a
- ld hl, PokedexSeen
- ld b, 2
- jr GetWramFlag
+ ld hl, PokedexCaught
+ ld b, CHECK_FLAG
+ jr PokedexFlagAction
; 339b
-CheckCaughtMon: ; 339b
+CheckSeenMon: ; 339b
ld c, a
- ld hl, PokedexCaught
- ld b, 2
+ ld hl, PokedexSeen
+ ld b, CHECK_FLAG
; fallthrough
; 33a1
-GetWramFlag: ; 33a1
+PokedexFlagAction: ; 33a1
ld d, 0
ld a, PREDEF_FLAG
call Predef
-
ld a, c
and a
ret
@@ -5185,7 +2188,7 @@
ld h, [hl]
ld l, a
call GetMapEventBank
- call Function31b0
+ call FarPrintText
call WaitBGMap
call Functiona80
ret
@@ -11608,7 +8611,7 @@
bit 0, a
ret z
push hl
- ld hl, PokedexSeen
+ ld hl, PokedexCaught
ld b, $20
call CountSetBits
pop hl
@@ -14985,7 +11988,7 @@
dwb Function6508, BANK(Function6508)
dwb Function747a, BANK(Function747a)
dwb Functionc658, BANK(Functionc658)
- dwb Function4d7c1, BANK(Function4d7c1)
+ dwb FlagPredef, BANK(FlagPredef)
dwb Functionc699, BANK(Functionc699)
dwb FillPP, BANK(FillPP)
dwb Functiond88c, BANK(Functiond88c)
@@ -14999,7 +12002,7 @@
dwb CanLearnTMHMMove, BANK(CanLearnTMHMMove)
dwb GetTMHMMove, BANK(GetTMHMMove)
dwb Function28eef, BANK(Function28eef)
- dwb $4b3e, $0b ; PrintMoveDescription, BANK(PrintMoveDescription)
+ dwb PrintMoveDesc, BANK(PrintMoveDesc)
dwb Function3df48, BANK(Function3df48) ; UpdatePlayerHUD
dwb FillBox, BANK(FillBox)
dwb Function3d873, BANK(Function3d873)
@@ -15060,41 +12063,9 @@
; 864c
-Function864c: ; 864c
-; LoadSGBLayout
- call Function8d55
- jp nz, Function8d59
- ld a, b
- cp $ff
- jr nz, .asm_865a
- ld a, [SGBPredef]
+INCLUDE "predef/sgb.asm"
-.asm_865a
- cp $fc
- jp z, Function8ade
- ld l, a
- ld h, 0
- add hl, hl
- ld de, $466f
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, Function8a60
- push de
- jp [hl]
-; 866f
-INCBIN "baserom.gbc", $866f, $8a60 - $866f
-
-Function8a60: ; 8a60
- push de
- call Function9809
- pop hl
- jp Function9809
-; 8a68
-
-
CheckShininess: ; 8a68
; Check if a mon is shiny by DVs at bc.
; Return carry if shiny.
@@ -15137,7 +12108,7 @@
CheckContestMon: ; 8a88
; Check a mon's DVs at hl in the bug catching contest.
-; Return shiny if its DVs are good enough to place in the contest.
+; Return carry if its DVs are good enough to place in the contest.
; Attack
ld a, [hl]
@@ -15233,18 +12204,18 @@
; 8b07
Function8b07: ; 8b07
- call Function8d55
+ call CheckCGB
ret z
ld hl, $4b2f
ld de, $d000
ld bc, $0008
ld a, $5
- call Function306b
+ call FarCopyWRAM
ld hl, $4b37
ld de, MartPointer
ld bc, $0008
ld a, $5
- call Function306b
+ call FarCopyWRAM
call Function96a4
ld a, $1
ld [hCGBPalUpdate], a
@@ -15279,7 +12250,7 @@
add hl, bc
ld bc, $0004
ld a, $5
- call Function306b
+ call FarCopyWRAM
ld a, $1
ld [hCGBPalUpdate], a
ret
@@ -15314,7 +12285,7 @@
add hl, hl
ld de, $4d05
add hl, de
- call Function8d55
+ call CheckCGB
jr nz, .asm_8cf0
push hl
ld hl, $5ce6
@@ -15342,7 +12313,7 @@
ld de, $d000
ld bc, $0008
ld a, $5
- call Function306b
+ call FarCopyWRAM
call Function96a4
call Function9699
call Function96b3
@@ -15352,233 +12323,12 @@
INCBIN "baserom.gbc", $8d05, $8d55 - $8d05
-Function8d55: ; 8d55
- ld a, [hCGB]
- and a
- ret
-; 8d59
+INCLUDE "predef/cgb.asm"
-Function8d59: ; 8d59
- ld a, b
- cp $ff
- jr nz, .asm_8d61
- ld a, [SGBPredef]
-.asm_8d61
- cp $fc
- jp z, Function96f3
- call Function9673
- ld l, a
- ld h, $0
- add hl, hl
- ld de, $4d7a
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, Function8d79
- push de
- jp [hl]
-; 8d79
+INCBIN "baserom.gbc", $95e0, $9610 - $95e0
-Function8d79: ; 8d79
- ret
-; 8d7a
-INCBIN "baserom.gbc", $8d7a, $8db8 - $8d7a
-
-Function8db8: ; 8db8
- ld hl, $5c67
- ld de, $d000
- ld c, $4
- call $5615
- ld hl, $5c67
- ld de, $d020
- ld c, $4
- call $5615
- ld hl, $5c67
- ld de, MartPointer
- ld c, $2
- call $5615
- jr .asm_8e23
-
- ld de, $d000
- call Function9729
- push hl
- call Function9643
- call Function973a
- push hl
- call Function9643
- ld a, [EnemyHPPal]
- ld l, a
- ld h, $0
- add hl, hl
- add hl, hl
- ld bc, $68be
- add hl, bc
- call Function9643
- ld a, [PlayerHPPal]
- ld l, a
- ld h, $0
- add hl, hl
- add hl, hl
- ld bc, $68be
- add hl, bc
- call Function9643
- ld hl, $68ca
- call Function9643
- ld de, MartPointer
- pop hl
- call Function9643
- pop hl
- call Function9643
- ld a, $1
- ld [SGBPredef], a
- call Function96a4
-
-.asm_8e23
- call Function8e85
- ld hl, AttrMap
- ld bc, $0168
- ld a, $2
- call ByteFill
- ld hl, $ce29
- ld bc, $080a
- ld a, $0
- call Function9663
- ld hl, $cde3
- ld bc, $070a
- ld a, $1
- call Function9663
- ld hl, AttrMap
- ld bc, $040a
- ld a, $2
- call Function9663
- ld hl, $ce6f
- ld bc, $050a
- ld a, $3
- call Function9663
- ld hl, $cebf
- ld bc, $0109
- ld a, $4
- call Function9663
- ld hl, $cec9
- ld bc, $0078
- ld a, $7
- call ByteFill
- ld hl, $579c
- ld de, $d050
- ld bc, $0030
- ld a, $5
- call Function306b
- call Function96b3
- ret
-; 8e85
-
-
-Function8e85: ; 8e85
- ld a, $40
- ld hl, $4dc0
- rst FarCall
- ld hl, $7311
- jr nc, .asm_8e93
- ld hl, $7309
-
-.asm_8e93
- ld de, $d038
- ld bc, $0008
- ld a, $5
- call Function306b
- ret
-; 8e9f
-
-Function8e9f: ; 8e9f
- callba Function100dc0
- ld hl, $7311
- jr nc, .asm_8ead
- ld hl, $7309
-
-.asm_8ead
- ld de, $d000
- ld bc, $0008
- ld a, $5
- call Function306b
- ret
-; 8eb9
-
-Function8eb9: ; 8eb9
- ld a, [PlayerGender]
- bit 0, a
- jr z, .asm_8ec5
- ld hl, $7759
- jr .asm_8ec8
-
-.asm_8ec5
- ld hl, $7729
-
-.asm_8ec8
- ld de, $d000
- ld bc, $0030
- ld a, $5
- call Function306b
- call Function96a4
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; 8edb
-
-Function8edb: ; 8edb
- ld de, $d000
- ld a, [$cda1]
- ld l, a
- ld h, $0
- add hl, hl
- add hl, hl
- ld bc, $68be
- add hl, bc
- call Function9643
- ld a, [CurPartySpecies]
- ld bc, TempMonDVs
- call Function974b
- call Function9643
- ld hl, $68ca
- call Function9643
- ld hl, $4f52
- ld de, $d018
- ld bc, $0018
- ld a, $5
- call Function306b
- call Function9699
- ld hl, AttrMap
- ld bc, $0814
- ld a, $1
- call Function9663
- ld hl, $cf23
- ld bc, $000a
- ld a, $2
- call ByteFill
- ld hl, $ce4a
- ld bc, $0202
- ld a, $3
- call Function9663
- ld hl, $ce4c
- ld bc, $0202
- ld a, $4
- call Function9663
- ld hl, $ce4e
- ld bc, $0202
- ld a, $5
- call Function9663
- call Function96b3
- call Function96a4
- ld a, $1
- ld [hCGBPalUpdate], a
- ret
-; 8f52
-
-INCBIN "baserom.gbc", $8f52, $9610 - $8f52
-
-
Function9610: ; 9610
ld de, $d000
ld c, $4
@@ -15716,7 +12466,7 @@
ld de, $d080
ld bc, $0080
ld a, $5
- call Function306b
+ call FarCopyWRAM
ret
; 96b3
@@ -15798,7 +12548,7 @@
ld de, MartPointer
ld bc, $0010
ld a, $5
- call Function306b
+ call FarCopyWRAM
ret
; 9729
@@ -15845,6 +12595,8 @@
and a
jp nz, Function97f9
ld a, [TrainerClass]
+
+Function976b: ; 976b
ld l, a
ld h, $0
add hl, hl
@@ -15854,8 +12606,13 @@
ret
; 9775
-INCBIN "baserom.gbc", $9775, $97ee - $9775
+Function9775: ; 9775
+ call Function97ee
+ ret
+; 9779
+INCBIN "baserom.gbc", $9779, $97ee - $9779
+
Function97ee: ; 97ee
ld l, a
ld h, $0
@@ -15936,7 +12693,7 @@
; 9853
Function9853: ; 9853
- call Function8d55
+ call CheckCGB
ret nz
di
ld a, [$cfbe]
@@ -15969,7 +12726,7 @@
Function9890: ; 9890
- call Function8d55
+ call CheckCGB
ret z
ld a, $1
ld [rVBK], a
@@ -16272,8 +13029,107 @@
TrainerPalettes:
INCLUDE "gfx/trainers/palette_pointers.asm"
-INCBIN "baserom.gbc", $b1de, $b319 - $b1de
+Functionb1de: ; b1de
+ callba Function494ac
+ jr c, .asm_b230
+ ld a, [$d19a]
+ and $7
+ ld e, a
+ ld d, $0
+ ld hl, $7279
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [TimeOfDayPal]
+ and $3
+ add a
+ add a
+ add a
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld e, l
+ ld d, h
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Unkn1Pals
+ ld b, $8
+.asm_b210
+ ld a, [de]
+ push de
+ push hl
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld de, MornPal
+ add hl, de
+ ld e, l
+ ld d, h
+ pop hl
+ ld c, $8
+.asm_b222
+ ld a, [de]
+ inc de
+ ld [hli], a
+ dec c
+ jr nz, .asm_b222
+ pop de
+ inc de
+ dec b
+ jr nz, .asm_b210
+ pop af
+ ld [rSVBK], a
+.asm_b230
+ ld a, [TimeOfDayPal]
+ and $3
+ ld bc, $0040
+ ld hl, $7469
+ call AddNTimes
+ ld de, Unkn2Pals
+ ld bc, $0040
+ ld a, $5
+ call FarCopyWRAM
+ ld a, [$d19a]
+ cp $1
+ jr z, .asm_b253
+ cp $2
+ ret nz
+
+.asm_b253
+ ld a, [MapGroup]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld de, $7569
+ add hl, de
+ ld a, [TimeOfDayPal]
+ and $3
+ cp $2
+ jr c, .asm_b26d
+ inc hl
+ inc hl
+ inc hl
+ inc hl
+
+.asm_b26d
+ ld de, $d032
+ ld bc, $0004
+ ld a, $5
+ call FarCopyWRAM
+ ret
+; b279
+
+INCBIN "baserom.gbc", $b279, $b319 - $b279
+
MornPal: ; 0xb319
INCBIN "tilesets/morn.pal"
; 0xb359
@@ -16386,7 +13242,7 @@
dbw BANK(Function1ad2), Function1ad2
dbw BANK(Functione4a), Functione4a
dbw BANK(Functionc230), Functionc230
- dbw BANK(Functionc252), Functionc252
+ dbw BANK(SpecialSeenMon), SpecialSeenMon
dbw BANK(WaitSFX),WaitSFX
dbw BANK(Function3cdf), Function3cdf
dbw BANK(Function3d47), Function3d47
@@ -16415,7 +13271,7 @@
dbw BANK(Functionc422), Functionc422
dbw BANK(Function4d9d3), Function4d9d3
dbw BANK(Function88018), Function88018
- dbw BANK(Functionc2b9), Functionc2b9
+ dbw BANK(SpecialNameRater), SpecialNameRater
dbw BANK(Functionc2da), Functionc2da
dbw BANK(Function718d), Function718d
dbw BANK(Function71ac), Function71ac
@@ -16496,10 +13352,10 @@
dbw BANK(Function4a927), Function4a927
dbw BANK(Function90a54), Function90a54
dbw BANK(Function90a88), Function90a88
- dbw BANK(Functionc224), Functionc224
+ dbw BANK(SpecialNone), SpecialNone
; c224
-Functionc224: ; c224
+SpecialNone: ; c224
ret
; c225
@@ -16513,7 +13369,7 @@
Functionc230: ; c230
ld a, [ScriptVar]
dec a
- call CheckSeenMon
+ call CheckCaughtMon
ret nz
ld a, [ScriptVar]
dec a
@@ -16526,10 +13382,10 @@
ret
; c252
-Functionc252: ; c252
+SpecialSeenMon: ; c252
ld a, [ScriptVar]
dec a
- call SetCaughtMon
+ call SetSeenMon
ret
; c25a
@@ -16586,8 +13442,8 @@
DefaultRivalName: ; 0xc2b2
db "SILVER@"
-Functionc2b9: ; c2b9
- callba Functionfb6ed
+SpecialNameRater: ; c2b9
+ callba NameRater
ret
; c2c0
@@ -16643,7 +13499,7 @@
ld a, $1
ld [$d10c], a
ld hl, NumItems
- call Function2f66
+ call ReceiveItem
jr nc, .asm_c33d
xor a
ld [$abe2], a
@@ -16743,7 +13599,7 @@
ld a, $36
ld [CurItem], a
ld hl, NumItems
- call PickUpItem
+ call CheckItem
jr nc, .asm_c3c9
and a
ret
@@ -18776,7 +15632,7 @@
; 0xd1d5
-Functiond1d5: ; d1d5
+_ReceiveItem: ; d1d5
call Functiond27b
jp nz, Functiond29c
push hl
@@ -18823,7 +15679,7 @@
; d20d
-Functiond20d: ; d20d
+_TossItem: ; d20d
call Functiond27b
jr nz, .asm_d241
push hl
@@ -18871,7 +15727,7 @@
jp Functiond2ff
; d244
-_PickUpItem: ; d244
+_CheckItem: ; d244
call Functiond27b
jr nz, .asm_d278
push hl
@@ -18929,7 +15785,7 @@
; d283
Functiond283: ; d283
- ld c, $14
+ ld c, 20
ld a, e
cp TMsHMsEnd % $100
jr nz, .asm_d28e
@@ -18938,7 +15794,7 @@
ret z
.asm_d28e
- ld c, $32
+ ld c, 50
ld a, e
cp BallsEnd % $100
jr nz, .asm_d299
@@ -20014,7 +16870,7 @@
ld [$d265], a
dec a
push de
- call CheckSeenMon
+ call CheckCaughtMon
ld a, [$d265]
dec a
call SetSeenAndCaughtMon
@@ -20920,10 +17776,10 @@
ld a, [CurPartySpecies]
dec a
push af
- call CheckSeenMon
+ call CheckCaughtMon
pop af
push bc
- call CheckCaughtMon
+ call CheckSeenMon
push bc
call Functiond88c
pop bc
@@ -20934,7 +17790,7 @@
dec a
ld c, a
ld d, $0
- ld hl, PokedexSeen
+ ld hl, PokedexCaught
ld b, $0
ld a, $3
call Predef
@@ -20948,7 +17804,7 @@
dec a
ld c, a
ld d, $0
- ld hl, PokedexCaught
+ ld hl, PokedexSeen
ld b, $0
ld a, $3
call Predef
@@ -21974,7 +18830,7 @@
ld hl, NumItems
ld a, $1
ld [$d10c], a
- jp Function2f53
+ jp TossItem
; f7a0
Functionf7a0: ; f7a0
@@ -23606,7 +20462,7 @@
ld de, CurMart
ld bc, $0008
ld a, $5
- call Function306b
+ call FarCopyWRAM
ld a, $1
ld [hCGBPalUpdate], a
ret
@@ -23902,9 +20758,9 @@
call .PrintMenuAccount
call Function1f1a
ld a, [$cf73]
- cp BUTTON_B
+ cp B_BUTTON
jr z, .b
- cp BUTTON_A
+ cp A_BUTTON
jr z, .a
jr .loop
.a
@@ -24801,7 +21657,7 @@
ld a, $1
ld [$d10c], a
ld hl, NumItems
- jp Function2f66
+ jp ReceiveItem
; 12cea
INCBIN "baserom.gbc", $12cea, $12cf5 - $12cea
@@ -29539,7 +26395,7 @@
ld a, [$d107]
ld [Buffer2], a
ld hl, NumItems
- call Function2f66
+ call ReceiveItem
jr nc, .PackFull
ld a, [Buffer1]
ld [$d10c], a
@@ -29546,7 +26402,7 @@
ld a, [Buffer2]
ld [$d107], a
ld hl, PCItems
- call Function2f53
+ call TossItem
ld a, $3b
call Predef
ld hl, .WithdrewText
@@ -29720,7 +26576,7 @@
ld a, [$d107]
ld [Buffer2], a
ld hl, PCItems
- call Function2f66
+ call ReceiveItem
jr nc, .asm_15965
ld a, [Buffer1]
ld [$d10c], a
@@ -29727,7 +26583,7 @@
ld a, [Buffer2]
ld [$d107], a
ld hl, NumItems
- call Function2f53
+ call TossItem
ld a, $3b
call Predef
ld hl, .DepositText
@@ -30295,7 +27151,7 @@
call Function1600b
jr c, .asm_15d79
ld hl, NumItems
- call Function2f66
+ call ReceiveItem
jr nc, .asm_15d6f
ld a, [$d107]
ld e, a
@@ -30513,7 +27369,7 @@
call Function15fd7
ld a, [$d107]
ld hl, NumItems
- call Function2f53
+ call TossItem
ld a, $3b
call Predef
ld hl, $c5b9
@@ -31482,11 +28338,11 @@
call Functiona57
ld a, [hJoyPressed]
- and BUTTON_B
+ and B_BUTTON
jr nz, .asm_16c95
ld a, [hJoyPressed]
- and BUTTON_A
+ and A_BUTTON
jr nz, .asm_16c82
call Function16ca0
@@ -33464,7 +30320,7 @@
ld d, h
ld e, l
ld hl, $cf98
- jp Function31be
+ jp CallPointerAt
; 2486e
Function2486e: ; 2486e
@@ -33472,7 +30328,7 @@
ld d, h
ld e, l
ld hl, $cf98
- call Function31be
+ call CallPointerAt
pop hl
ld a, [$cf93]
and a
@@ -33483,7 +30339,7 @@
ld d, h
ld e, l
ld hl, $cf9b
- call Function31be
+ call CallPointerAt
.asm_2488a
ret
@@ -33536,7 +30392,7 @@
dec a
call Function248d5
ld hl, $cf9e
- call Function31be
+ call CallPointerAt
ret
; 248d5
@@ -33802,7 +30658,7 @@
push hl
ld [CurItem], a
ld hl, NumItems
- call PickUpItem
+ call CheckItem
pop hl
jr nc, .asm_24c89
ld a, [hl]
@@ -34573,13 +31429,13 @@
Rate: ; 0x26616
; calculate Seen/Owned
- ld hl, PokedexCaught
- ld b, EndPokedexCaught - PokedexCaught
- call CountSetBits
- ld [DefaultFlypoint], a
ld hl, PokedexSeen
ld b, EndPokedexSeen - PokedexSeen
call CountSetBits
+ ld [DefaultFlypoint], a
+ ld hl, PokedexCaught
+ ld b, EndPokedexCaught - PokedexCaught
+ call CountSetBits
ld [$d003], a
; print appropriate rating
@@ -38565,7 +35421,7 @@
jr .asm_2a27a
.asm_2a235
- call Function2f17
+ call IsInJohto
and a
ret z
ld h, d
@@ -38978,7 +35834,7 @@
push bc
dec c
ld a, c
- call CheckCaughtMon
+ call CheckSeenMon
pop bc
jr nz, .asm_2a514
ld de, StringBuffer1
@@ -39470,7 +36326,7 @@
ret nz
ld a, [TempEnemyMonSpecies]
dec a
- call CheckSeenMon
+ call CheckCaughtMon
ret z
ld hl, $c4b5
ld [hl], $5d
@@ -39844,7 +36700,7 @@
INCBIN "baserom.gbc", $2c867, $2cb3e - $2c867
-PrintMoveDescription: ; 2cb3e
+PrintMoveDesc: ; 2cb3e
push hl
ld hl, MoveDescriptions
ld a, [CurSpecies]
@@ -47690,7 +44546,7 @@
dec a
ld c, a
ld b, 1 ; set
- ld hl, PokedexCaught
+ ld hl, PokedexSeen
ld a, PREDEF_FLAG
call Predef
@@ -50982,7 +47838,7 @@
push hl
ld a, [$d265]
dec a
- call CheckCaughtMon
+ call CheckSeenMon
pop hl
pop de
ret
@@ -51896,173 +48752,9 @@
SECTION "bank11",ROMX,BANK[$11]
-FruitTreeScript: ; 44000
- 3callasm BANK(GetCurTreeFruit), GetCurTreeFruit
- loadfont
- copybytetovar CurFruit
- itemtotext $0, $0
- 2writetext FruitBearingTreeText
- keeptextopen
- 3callasm BANK(TryResetFruitTrees), TryResetFruitTrees
- 3callasm BANK(CheckFruitTree), CheckFruitTree
- iffalse .fruit
- 2writetext NothingHereText
- closetext
- 2jump .end
+INCLUDE "engine/fruit_trees.asm"
-.fruit
- 2writetext HeyItsFruitText
- copybytetovar CurFruit
- giveitem $ff, 1
- iffalse .packisfull
- keeptextopen
- 2writetext ObtainedFruitText
- 3callasm BANK(PickedFruitTree), PickedFruitTree
- specialsound
- itemnotify
- 2jump .end
-.packisfull
- keeptextopen
- 2writetext FruitPackIsFullText
- closetext
-
-.end
- loadmovesprites
- end
-; 44041
-
-GetCurTreeFruit: ; 44041
- ld a, [CurFruitTree]
- dec a
- call GetFruitTreeItem
- ld [CurFruit], a
- ret
-; 4404c
-
-TryResetFruitTrees: ; 4404c
- ld hl, $dc1e
- bit 4, [hl]
- ret nz
- jp ResetFruitTrees
-; 44055
-
-CheckFruitTree: ; 44055
- ld b, 2
- call GetFruitTreeFlag
- ld a, c
- ld [ScriptVar], a
- ret
-; 4405f
-
-PickedFruitTree: ; 4405f
- ld a, $41
- ld hl, $609b
- rst FarCall ; empty function
-
- ld b, 1
- jp GetFruitTreeFlag
-; 4406a
-
-ResetFruitTrees: ; 4406a
- xor a
- ld hl, FruitTreeFlags
- ld [hli], a
- ld [hli], a
- ld [hli], a
- ld [hl], a
- ld hl, $dc1e
- set 4, [hl]
- ret
-; 44078
-
-GetFruitTreeFlag: ; 44078
- push hl
- push de
- ld a, [CurFruitTree]
- dec a
- ld e, a
- ld d, 0
- ld hl, FruitTreeFlags
- call FlagAction
- pop de
- pop hl
- ret
-; 4408a
-
-GetFruitTreeItem: ; 4408a
- push hl
- push de
- ld e, a
- ld d, 0
- ld hl, FruitTreeItems
- add hl, de
- ld a, [hl]
- pop de
- pop hl
- ret
-; 44097
-
-FruitTreeItems: ; 44097
- db BERRY
- db BERRY
- db BERRY
- db BERRY
- db PSNCUREBERRY
- db PSNCUREBERRY
- db BITTER_BERRY
- db BITTER_BERRY
- db PRZCUREBERRY
- db PRZCUREBERRY
- db MYSTERYBERRY
- db MYSTERYBERRY
- db ICE_BERRY
- db ICE_BERRY
- db MINT_BERRY
- db BURNT_BERRY
- db RED_APRICORN
- db BLU_APRICORN
- db BLK_APRICORN
- db WHT_APRICORN
- db PNK_APRICORN
- db GRN_APRICORN
- db YLW_APRICORN
- db BERRY
- db PSNCUREBERRY
- db BITTER_BERRY
- db PRZCUREBERRY
- db ICE_BERRY
- db MINT_BERRY
- db BURNT_BERRY
-; 440b5
-
-FruitBearingTreeText: ; 440b5
- text_jump _FruitBearingTreeText, BANK(_FruitBearingTreeText)
- db "@"
-; 440ba
-
-HeyItsFruitText: ; 440ba
- text_jump _HeyItsFruitText, BANK(_HeyItsFruitText)
- db "@"
-; 440bf
-
-ObtainedFruitText: ; 440bf
- text_jump _ObtainedFruitText, BANK(_ObtainedFruitText)
- db "@"
-; 440c4
-
-FruitPackIsFullText: ; 440c4
- text_jump _FruitPackIsFullText, BANK(_FruitPackIsFullText)
- db "@"
-; 440c9
-
-NothingHereText: ; 440c9
- text_jump _NothingHereText, BANK(_NothingHereText)
- db "@"
-; 440ce
-
-
-
AIChooseMove: ; 440ce
; Score each move in EnemyMonMoves starting from Buffer1. Lower is better.
; Pick the move with the lowest score.
@@ -52358,7 +49050,7 @@
call PrintNum
ld a, [$d265]
dec a
- call CheckSeenMon
+ call CheckCaughtMon
pop hl
pop bc
ret z
@@ -52835,7 +49527,7 @@
ld a, $1
ld [$d10c], a
ld hl, NumItems
- call Function2f66
+ call ReceiveItem
jr c, .asm_4489e
ld hl, .PackFullText
jp Function1d67
@@ -53127,7 +49819,7 @@
pop de
ld a, $b
ld hl, $48ce
- call Function31b0
+ call FarPrintText
jr .asm_49300
.asm_492e5
@@ -53182,12 +49874,148 @@
ld de, $d038
ld bc, $0008
ld a, $5
- call Function306b
+ call FarCopyWRAM
ret
; 49418
-INCBIN "baserom.gbc", $49418, $49797 - $49418
+INCBIN "baserom.gbc", $49418, $494ac - $49418
+Function494ac: ; 494ac
+ ld a, [$d199]
+ cp $15
+ jr z, .asm_494c9
+ cp $16
+ jr z, .asm_494ce
+ cp $1d
+ jr z, .asm_494d3
+ cp $5
+ jr z, .asm_494e1
+ cp $1b
+ jr z, .asm_494e6
+ cp $d
+ jr z, .asm_494eb
+ jr .asm_494f0
+
+.asm_494c9
+ call Function494f2
+ scf
+ ret
+
+.asm_494ce
+ call Function49541
+ scf
+ ret
+
+.asm_494d3
+ ld a, [$d19a]
+ and $7
+ cp $3
+ jr z, .asm_494f0
+ call Function49590
+ scf
+ ret
+
+.asm_494e1
+ call Function495df
+ scf
+ ret
+
+.asm_494e6
+ call Function4962e
+ scf
+ ret
+
+.asm_494eb
+ call Function496c5
+ scf
+ ret
+
+.asm_494f0
+ and a
+ ret
+; 494f2
+
+Function494f2: ; 494f2
+ ld a, $5
+ ld de, Unkn1Pals
+ ld hl, $5501
+ ld bc, $0040
+ call FarCopyWRAM
+ ret
+; 49501
+
+INCBIN "baserom.gbc", $49501, $49541 - $49501
+
+Function49541: ; 49541
+ ld a, $5
+ ld de, Unkn1Pals
+ ld hl, $5550
+ ld bc, $0040
+ call FarCopyWRAM
+ ret
+; 49550
+
+INCBIN "baserom.gbc", $49550, $49590 - $49550
+
+Function49590: ; 49590
+ ld a, $5
+ ld de, Unkn1Pals
+ ld hl, $559f
+ ld bc, $0040
+ call FarCopyWRAM
+ ret
+; 4959f
+
+INCBIN "baserom.gbc", $4959f, $495df - $4959f
+
+Function495df: ; 495df
+ ld a, $5
+ ld de, Unkn1Pals
+ ld hl, $55ee
+ ld bc, $0040
+ call FarCopyWRAM
+ ret
+; 495ee
+
+INCBIN "baserom.gbc", $495ee, $4962e - $495ee
+
+Function4962e: ; 4962e
+ ld a, $5
+ ld de, Unkn1Pals
+ ld hl, $563d
+ ld bc, $0040
+ call FarCopyWRAM
+ ret
+; 4963d
+
+INCBIN "baserom.gbc", $4963d, $496c5 - $4963d
+
+Function496c5: ; 496c5
+ ld a, $5
+ ld de, Unkn1Pals
+ ld hl, $567d
+ ld bc, $0040
+ call FarCopyWRAM
+ ld a, $5
+ ld de, $d020
+ ld hl, $56fe
+ ld bc, $0008
+ call FarCopyWRAM
+ ld a, $5
+ ld de, $d018
+ ld hl, $56ad
+ ld bc, $0008
+ call FarCopyWRAM
+ ld a, $5
+ ld de, $d030
+ ld hl, $56bd
+ ld bc, $0008
+ call FarCopyWRAM
+ ret
+; 496fe
+
+INCBIN "baserom.gbc", $496fe, $49797 - $496fe
+
Function49797: ; 49797
ld hl, AttrMap
ld bc, $1002
@@ -53245,7 +50073,7 @@
ld de, $d010
ld bc, $0030
ld a, $5
- call Function306b
+ call FarCopyWRAM
callba Function96a4
ret
; 49826
@@ -54249,12 +51077,12 @@
ld a, [ScriptVar]
ld [CurItem], a
ld hl, PCItems
- call PickUpItem
+ call CheckItem
jr c, .asm_4a948
ld a, [ScriptVar]
ld [CurItem], a
ld hl, NumItems
- call PickUpItem
+ call CheckItem
jr c, .asm_4a948
xor a
ld [ScriptVar], a
@@ -55796,57 +52624,73 @@
Tilesets:
INCLUDE "tilesets/tileset_headers.asm"
-Function4d7c1: ; 4d7c1
+
+FlagPredef: ; 4d7c1
+; Perform action b on flag c in flag array hl.
+; If checking a flag, check flag array d:hl unless d is 0.
+
+; For longer flag arrays, see FlagAction.
+
push hl
push bc
+
+; Divide by 8 to get the byte we want.
push bc
srl c
srl c
srl c
- ld b, $0
+ ld b, 0
add hl, bc
pop bc
+
+; Which bit we want from the byte
ld a, c
- and $7
+ and 7
ld c, a
- ld a, $1
- jr z, .asm_4d7da
-.asm_4d7d6
+
+; Shift left until we can mask the bit
+ ld a, 1
+ jr z, .shifted
+.shift
add a
dec c
- jr nz, .asm_4d7d6
-
-.asm_4d7da
+ jr nz, .shift
+.shifted
ld c, a
+
+; What are we doing to this flag?
dec b
- jr z, .asm_4d7e7
+ jr z, .set ; 1
dec b
- jr z, .asm_4d7ec
+ jr z, .check ; 2
+
+.reset
ld a, c
cpl
and [hl]
ld [hl], a
- jr .asm_4d7f9
+ jr .done
-.asm_4d7e7
+.set
ld a, [hl]
or c
ld [hl], a
- jr .asm_4d7f9
+ jr .done
-.asm_4d7ec
+.check
ld a, d
- cp $0
- jr nz, .asm_4d7f5
+ cp 0
+ jr nz, .farcheck
+
ld a, [hl]
and c
- jr .asm_4d7f9
+ jr .done
-.asm_4d7f5
+.farcheck
call GetFarByte
and c
-.asm_4d7f9
+.done
pop bc
pop hl
ld c, a
@@ -57294,7 +54138,7 @@
ld de, $cd53
ld bc, $000c
ld a, $5
- call Function306b
+ call FarCopyWRAM
ld a, [rSVBK]
push af
ld a, $1
@@ -57316,7 +54160,7 @@
Function4ea44: ; 4ea44
ld a, $0
ld hl, InLinkBattle
- call Function307b
+ call GetFarWRAMByte
cp $4
jr z, .asm_4ea59
ld a, [Options]
@@ -57343,7 +54187,7 @@
.asm_4ea72
ld a, $5
ld hl, $dc00
- call Function307b
+ call GetFarWRAMByte
bit 0, a
jr z, .asm_4ea80
and a
@@ -59140,165 +55984,126 @@
; 5090d
-PrintMonTypes: ; 5090d
- push hl
- call GetBaseData
- pop hl
- push hl
- ld a, [BaseType1]
- call .asm_50928
- ld a, [BaseType1]
- ld b, a
- ld a, [BaseType2]
- cp b
- pop hl
- jr z, .asm_5092b
- ld bc, 20
- add hl, bc
+INCLUDE "text/types.asm"
-.asm_50928
- ld b, a
- jr PrintType
-.asm_5092b
- ld a, " "
- ld bc, 20 - 3
+Function50a28: ; 50a28
+ ld hl, Strings50a42
+ ld a, [TrainerClass]
+ dec a
+ ld c, a
+ ld b, 0
add hl, bc
- ld [hl], a
- inc bc
add hl, bc
- ld bc, 5
- jp ByteFill
-; 5093a
-
-PrintMoveType: ; 5093a
-; Print the type of move b at hl.
-
- push hl
- ld a, b
- dec a
- ld bc, Move2 - Move1
- ld hl, Moves
- call AddNTimes
- ld de, StringBuffer1
- ld a, BANK(Moves)
- call FarCopyBytes
- ld a, [StringBuffer1 + PlayerMoveType - PlayerMoveStruct]
- pop hl
-
- ld b, a
-; 50953
-
-PrintType: ; 50953
-; Print type b at hl.
- ld a, b
-
- push hl
- add a
- ld hl, TypeNames
- ld e, a
- ld d, 0
- add hl, de
ld a, [hli]
- ld e, a
- ld d, [hl]
- pop hl
-
- jp PlaceString
-; 50964
-
-
-GetTypeName: ; 50964
-; Copy the name of type $d265 to StringBuffer1.
- ld a, [$d265]
- ld hl, TypeNames
- ld e, a
- ld d, 0
- add hl, de
- add hl, de
- ld a, [hli]
ld h, [hl]
ld l, a
ld de, StringBuffer1
- ld bc, $000d
- jp CopyBytes
-; 5097b
+.copy
+ ld a, [hli]
+ ld [de], a
+ inc de
+ cp "@"
+ jr nz, .copy
+ ret
+; 50a42
+Strings50a42: ; 50a42
+; Untranslated trainer class names from Red.
-TypeNames: ; 5097b
- dw Normal
- dw Fighting
- dw Flying
- dw Poison
- dw Ground
- dw Rock
- dw Bird
- dw Bug
- dw Ghost
- dw Steel
- dw Normal
- dw Normal
- dw Normal
- dw Normal
- dw Normal
- dw Normal
- dw Normal
- dw Normal
- dw Normal
- dw UnknownType
- dw Fire
- dw Water
- dw Grass
- dw Electric
- dw Psychic
- dw Ice
- dw Dragon
- dw Dark
+ dw .Youngster
+ dw .BugCatcher
+ dw .Lass
+ dw OTName
+ dw .JrTrainerM
+ dw .JrTrainerF
+ dw .Pokemaniac
+ dw .SuperNerd
+ dw OTName
+ dw OTName
+ dw .Burglar
+ dw .Engineer
+ dw .Jack
+ dw OTName
+ dw .Swimmer
+ dw OTName
+ dw OTName
+ dw .Beauty
+ dw OTName
+ dw .Rocker
+ dw .Juggler
+ dw OTName
+ dw OTName
+ dw .Blackbelt
+ dw OTName
+ dw .ProfOak
+ dw .Chief
+ dw .Scientist
+ dw OTName
+ dw .Rocket
+ dw .CooltrainerM
+ dw .CooltrainerF
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
+ dw OTName
-Normal:
- db "NORMAL@"
-Fighting:
- db "FIGHTING@"
-Flying:
- db "FLYING@"
-Poison:
- db "POISON@"
-UnknownType:
- db "???@"
-Fire:
- db "FIRE@"
-Water:
- db "WATER@"
-Grass:
- db "GRASS@"
-Electric:
- db "ELECTRIC@"
-Psychic:
- db "PSYCHIC@"
-Ice:
- db "ICE@"
-Ground:
- db "GROUND@"
-Rock:
- db "ROCK@"
-Bird:
- db "BIRD@"
-Bug:
- db "BUG@"
-Ghost:
- db "GHOST@"
-Steel:
- db "STEEL@"
-Dragon:
- db "DRAGON@"
-Dark:
- db "DARK@"
-; 50a28
+.Youngster
+ db "たんパン@"
+.BugCatcher
+ db "むしとり@"
+.Lass
+ db "ミニスカ@"
+.JrTrainerM
+ db "ボーイ@"
+.JrTrainerF
+ db "ガール@"
+.Pokemaniac
+ db "マニア@"
+.SuperNerd
+ db "りかけい@"
+.Burglar
+ db "どろぼう@"
+.Engineer
+ db "ォヤジ@"
+.Jack
+ db "ジャック@"
+.Swimmer
+ db "かいパン@"
+.Beauty
+ db "おねえさん@"
+.Rocker
+ db "グループ@"
+.Juggler
+ db "ジャグラー@"
+.Blackbelt
+ db "からて@"
+.ProfOak
+ db "ォーキド@"
+.Chief
+ db "チーフ@"
+.Scientist
+ db "けんきゅういん@"
+.Rocket
+ db "だんいん@"
+.CooltrainerM
+ db "エりート♂@"
+.CooltrainerF
+ db "エりート♀@"
+; 50b0a
-INCBIN "baserom.gbc", $50a28, $50b0a - $50a28
-
-
DrawPlayerHP: ; 50b0a
ld a, $1
jr DrawHP
@@ -60147,7 +56952,7 @@
push hl
ld a, $1
ld hl, BasePicSize
- call Function307b
+ call GetFarWRAMByte
pop hl
and $f
ld de, $d990
@@ -61361,7 +58166,7 @@
ld hl, .data_802e8
add hl, de
ld a, [CurInput]
- and BUTTON_A | BUTTON_B | SELECT | START
+ and A_BUTTON | B_BUTTON | SELECT | START
or [hl]
ld [CurInput], a
ret
@@ -63329,7 +60134,7 @@
ld hl, NumItems
ld a, b
ld [$d10c], a
- call Function2f53
+ call TossItem
pop bc
ld a, c
sub b
@@ -65169,7 +61974,7 @@
ld a, WATER_STONE
ld [CurItem], a
ld hl, NumItems
- call PickUpItem
+ call CheckItem
jr c, .asm_8ae24
ld a, [PartyCount]
@@ -65489,7 +62294,7 @@
ld a, $1
ld [$d10c], a
ld hl, NumItems
- call Function2f66
+ call ReceiveItem
pop hl
jr nc, .asm_8b04c
ld a, [hl]
@@ -70802,7 +67607,7 @@
CheckAPressOW: ; 96999
ld a, [hJoyPressed]
- and BUTTON_A
+ and A_BUTTON
ret z
call TryObjectEvent
ret c
@@ -72429,33 +69234,39 @@
INCBIN "baserom.gbc", $b81ea, $b8219 - $b81ea
Functionb8219: ; b8219
-; deals strictly with rockmon encounter
+; get a RockMon encounter
+
xor a
ld [$d22e], a
ld [CurPartyLevel], a
- ld hl, WildRockMonMapTable
+
+ ld hl, RockMonMaps
call GetTreeMonEncounterTable
jr nc, .quit
- call LoadWildTreeMonData
+
+ call LoadTreeMonData
jr nc, .quit
- ld a, $0a
+
+ ld a, 10
call Function2fb1
- cp a, $04
+ cp 4
jr nc, .quit
- call $441f
+
+ call Functionb841f
jr nc, .quit
+
ret
+
.quit
xor a
ret
; b823e
-db $05 ; ????
+ db $05 ; ????
GetTreeMonEncounterTable: ; b823f
-; reads a map-sensitive encounter table
-; compares current map with maps in the table
-; if there is a match, encounter table # is loaded into a
+; Return carry and table id in a
+; if MapGroup and MapNumber are in table hl
ld a, [MapNumber]
ld e, a
ld a, [MapGroup]
@@ -72462,7 +69273,7 @@
ld d, a
.loop
ld a, [hli]
- cp a, $ff
+ cp $ff
jr z, .quit
cp d
jr nz, .skip2
@@ -72486,55 +69297,60 @@
INCBIN "baserom.gbc", $B825E, $b82c5 - $b825e
-WildRockMonMapTable: ; b82c5
- db GROUP_CIANWOOD_CITY, MAP_CIANWOOD_CITY, $07
- db GROUP_ROUTE_40, MAP_ROUTE_40, $07
- db GROUP_DARK_CAVE_VIOLET_ENTRANCE, MAP_DARK_CAVE_VIOLET_ENTRANCE, $07
- db GROUP_SLOWPOKE_WELL_B1F, MAP_SLOWPOKE_WELL_B1F, $07
+RockMonMaps: ; b82c5
+ db GROUP_CIANWOOD_CITY, MAP_CIANWOOD_CITY, 7
+ db GROUP_ROUTE_40, MAP_ROUTE_40, 7
+ db GROUP_DARK_CAVE_VIOLET_ENTRANCE, MAP_DARK_CAVE_VIOLET_ENTRANCE, 7
+ db GROUP_SLOWPOKE_WELL_B1F, MAP_SLOWPOKE_WELL_B1F, 7
db $ff ; end
; b82d2
-LoadWildTreeMonData: ; b82d2
-; input: a = table number
-; returns wildtreemontable pointer in hl
-; sets carry if successful
- cp a, $08 ; which table?
- jr nc, .quit ; only 8 tables
+LoadTreeMonData: ; b82d2
+; Return TreeMon pointer a in hl
+; Return carry on success
+
+; only 7 tables
+ cp 8
+ jr nc, .quit
+
and a
- jr z, .quit ; 0 is invalid
+ jr z, .quit
+
ld e, a
- ld d, $00
- ld hl, WildTreeMonPointerTable
+ ld d, 0
+ ld hl, TreeMonPointers
add hl, de
add hl, de
- ld a, [hli] ; store pointer in hl
+
+ ld a, [hli]
ld h, [hl]
ld l, a
+
scf
ret
+
.quit
xor a
ret
; b82e8
-WildTreeMonPointerTable: ; b82e8
+TreeMonPointers: ; b82e8
; seems to point to "normal" tree encounter data
-; as such only odd-numbered tables are used
-; rockmon is 13th
- dw WildTreeMonTable1 ; filler
- dw WildTreeMonTable1 ; 1
- dw WildTreeMonTable3 ; 2
- dw WildTreeMonTable5 ; 3
- dw WildTreeMonTable7 ; 4
- dw WildTreeMonTable9 ; 5
- dw WildTreeMonTable11 ; 6
- dw WildRockMonTable ; 7
- dw WildTreeMonTable1 ; 8
+; so only odd-numbered tables are used
+ dw TreeMons1 ; filler
+ dw TreeMons1 ; 1
+ dw TreeMons3 ; 2
+ dw TreeMons5 ; 3
+ dw TreeMons7 ; 4
+ dw TreeMons9 ; 5
+ dw TreeMons11 ; 6
+ dw RockMons ; 7
+ dw TreeMons1 ; filler
; b82fa
; structure: % species level
-WildTreeMonTable1: ; b82fa
+TreeMons1: ; b82fa
db 50, SPEAROW, 10
db 15, SPEAROW, 10
db 15, SPEAROW, 10
@@ -72544,7 +69360,7 @@
db $ff ; end
; b830d
-WildTreeMonTable2 ; b830d
+TreeMons2 ; b830d
; unused
db 50, SPEAROW, 10
db 15, HERACROSS, 10
@@ -72555,7 +69371,7 @@
db $ff ; end
; b8320
-WildTreeMonTable3: ; b8320
+TreeMons3: ; b8320
db 50, SPEAROW, 10
db 15, EKANS, 10
db 15, SPEAROW, 10
@@ -72565,7 +69381,7 @@
db $ff ; end
; b8333
-WildTreeMonTable4: ; b8333
+TreeMons4: ; b8333
; unused
db 50, SPEAROW, 10
db 15, HERACROSS, 10
@@ -72576,7 +69392,7 @@
db $ff ; end
; b8346
-WildTreeMonTable5: ; b8346
+TreeMons5: ; b8346
db 50, HOOTHOOT, 10
db 15, SPINARAK, 10
db 15, LEDYBA, 10
@@ -72586,7 +69402,7 @@
db $ff ; end
; b8359
-WildTreeMonTable6: ; b8359
+TreeMons6: ; b8359
; unused
db 50, HOOTHOOT, 10
db 15, PINECO, 10
@@ -72597,7 +69413,7 @@
db $ff ; end
; b836c
-WildTreeMonTable7: ; b836c
+TreeMons7: ; b836c
db 50, HOOTHOOT, 10
db 15, EKANS, 10
db 15, HOOTHOOT, 10
@@ -72607,7 +69423,7 @@
db $ff ; end
; b837f
-WildTreeMonTable8: ; b837f
+TreeMons8: ; b837f
; unused
db 50, HOOTHOOT, 10
db 15, PINECO, 10
@@ -72618,7 +69434,7 @@
db $ff ; end
; b8392
-WildTreeMonTable9: ; b8392
+TreeMons9: ; b8392
db 50, HOOTHOOT, 10
db 15, VENONAT, 10
db 15, HOOTHOOT, 10
@@ -72628,7 +69444,7 @@
db $ff ; end
; b83a5
-WildTreeMonTable10: ; b83a5
+TreeMons10: ; b83a5
; unused
db 50, HOOTHOOT, 10
db 15, PINECO, 10
@@ -72639,7 +69455,7 @@
db $ff ; end
; b83b8
-WildTreeMonTable11: ; b83b8
+TreeMons11: ; b83b8
db 50, HOOTHOOT, 10
db 15, PINECO, 10
db 15, PINECO, 10
@@ -72649,7 +69465,7 @@
db $ff ; end
; b83cb
-WildTreeMonTable12; b83cb
+TreeMons12; b83cb
; unused
db 50, HOOTHOOT, 10
db 15, CATERPIE, 10
@@ -72660,14 +69476,47 @@
db $ff ; end
; b83de
-WildRockMonTable: ; b83de
+RockMons: ; b83de
db 90, KRABBY, 15
db 10, SHUCKLE, 15
db $ff ; end
; b83e5
-INCBIN "baserom.gbc", $b83e5, $b8f8f - $b83e5
+INCBIN "baserom.gbc", $b83e5, $b841f - $b83e5
+Functionb841f: ; b841f
+; Read a TreeMons table.
+
+ ld a, 100
+ call Function2fb1
+.asm_b8424
+ sub [hl]
+ jr c, .asm_b842c
+ inc hl
+ inc hl
+ inc hl
+ jr .asm_b8424
+
+.asm_b842c
+ ld a, [hli]
+ cp $ff
+ jr z, .asm_b843b
+ ld a, [hli]
+ ld [$d22e], a
+ ld a, [hl]
+ ld [CurPartyLevel], a
+ scf
+ ret
+
+.asm_b843b
+ xor a
+ ld [$d22e], a
+ ld [CurPartyLevel], a
+ ret
+; b8443
+
+INCBIN "baserom.gbc", $b8443, $b8f8f - $b8443
+
Functionb8f8f: ; b8f8f
ld a, c
swap a
@@ -72850,2594 +69699,8 @@
SECTION "bank2F",ROMX,BANK[$2F]
-StdScripts: ; bc000
- dbw BANK(PokeCenterNurseScript), PokeCenterNurseScript
- dbw BANK(UnknownScript_0xbc162), UnknownScript_0xbc162
- dbw BANK(UnknownScript_0xbc166), UnknownScript_0xbc166
- dbw BANK(UnknownScript_0xbc16a), UnknownScript_0xbc16a
- dbw BANK(UnknownScript_0xbc16e), UnknownScript_0xbc16e
- dbw BANK(UnknownScript_0xbc172), UnknownScript_0xbc172
- dbw BANK(UnknownScript_0xbc176), UnknownScript_0xbc176
- dbw BANK(UnknownScript_0xbc17a), UnknownScript_0xbc17a
- dbw BANK(UnknownScript_0xbc185), UnknownScript_0xbc185
- dbw BANK(UnknownScript_0xbc189), UnknownScript_0xbc189
- dbw BANK(UnknownScript_0xbc191), UnknownScript_0xbc191
- dbw BANK(UnknownScript_0xbc195), UnknownScript_0xbc195
- dbw BANK(UnknownScript_0xbc19d), UnknownScript_0xbc19d
- dbw BANK(UnknownScript_0xbc1a5), UnknownScript_0xbc1a5
- dbw BANK(UnknownScript_0xbc1b8), UnknownScript_0xbc1b8
- dbw BANK(UnknownScript_0xbc1bc), UnknownScript_0xbc1bc
- dbw BANK(UnknownScript_0xbc1c0), UnknownScript_0xbc1c0
- dbw BANK(UnknownScript_0xbc1c4), UnknownScript_0xbc1c4
- dbw BANK(UnknownScript_0xbc23e), UnknownScript_0xbc23e
- dbw BANK(UnknownScript_0xbc242), UnknownScript_0xbc242
- dbw BANK(UnknownScript_0xbc1af), UnknownScript_0xbc1af
- dbw BANK(UnknownScript_0xbc1c8), UnknownScript_0xbc1c8
- dbw BANK(UnknownScript_0xbc25c), UnknownScript_0xbc25c
- dbw BANK(UnknownScript_0xbc274), UnknownScript_0xbc274
- dbw BANK(UnknownScript_0xbc3db), UnknownScript_0xbc3db
- dbw BANK(UnknownScript_0xbc574), UnknownScript_0xbc574
- dbw BANK(UnknownScript_0xbc62d), UnknownScript_0xbc62d
- dbw BANK(UnknownScript_0xbc6e6), UnknownScript_0xbc6e6
- dbw BANK(UnknownScript_0xbc6f0), UnknownScript_0xbc6f0
- dbw BANK(UnknownScript_0xbc7ce), UnknownScript_0xbc7ce
- dbw BANK(UnknownScript_0xbc8ac), UnknownScript_0xbc8ac
- dbw BANK(UnknownScript_0xbc98a), UnknownScript_0xbc98a
- dbw BANK(UnknownScript_0xbca47), UnknownScript_0xbca47
- dbw BANK(UnknownScript_0xbca8f), UnknownScript_0xbca8f
- dbw BANK(UnknownScript_0xbcb0a), UnknownScript_0xbcb0a
- dbw BANK(UnknownScript_0xbcb35), UnknownScript_0xbcb35
- dbw BANK(UnknownScript_0xbcb7f), UnknownScript_0xbcb7f
- dbw BANK(UnknownScript_0xbcbc9), UnknownScript_0xbcbc9
- dbw BANK(UnknownScript_0xbcbd3), UnknownScript_0xbcbd3
- dbw BANK(UnknownScript_0xbcc2d), UnknownScript_0xbcc2d
- dbw BANK(UnknownScript_0xbcc87), UnknownScript_0xbcc87
- dbw BANK(UnknownScript_0xbcce1), UnknownScript_0xbcce1
- dbw BANK(UnknownScript_0xbcd30), UnknownScript_0xbcd30
- dbw BANK(UnknownScript_0xbcd5a), UnknownScript_0xbcd5a
- dbw BANK(UnknownScript_0xbcd93), UnknownScript_0xbcd93
- dbw BANK(UnknownScript_0xbcda0), UnknownScript_0xbcda0
- dbw BANK(UnknownScript_0xbcdaa), UnknownScript_0xbcdaa
- dbw BANK(UnknownScript_0xbcdb9), UnknownScript_0xbcdb9
- dbw BANK(UnknownScript_0xbcdc3), UnknownScript_0xbcdc3
- dbw BANK(UnknownScript_0xbc1a9), UnknownScript_0xbc1a9
- dbw BANK(UnknownScript_0xbcdcd), UnknownScript_0xbcdcd
- dbw BANK(UnknownScript_0xbce7f), UnknownScript_0xbce7f
-; bc09c
+INCLUDE "engine/std_scripts.asm"
-PokeCenterNurseScript: ; bc09c
-; Talking to a nurse in a Pokemon Center
-
- loadfont
-; The nurse has different text for:
-; Morn
- checktime $1
- iftrue .morn
-; Day
- checktime $2
- iftrue .day
-; Nite
- checktime $4
- iftrue .nite
-; If somehow it's not a time of day at all, we skip the introduction
- 2jump .heal
-
-.morn
-; Different text if we're in the com center
- checkbit1 $032a
- iftrue .morn_comcenter
-; Good morning! Welcome to ...
- 3writetext BANK(UnknownText_0x1b0000), UnknownText_0x1b0000
- keeptextopen
- 2jump .heal
-.morn_comcenter
-; Good morning! This is the ...
- 3writetext BANK(UnknownText_0x1b008a), UnknownText_0x1b008a
- keeptextopen
- 2jump .heal
-
-.day
-; Different text if we're in the com center
- checkbit1 $032a
- iftrue .day_comcenter
-; Hello! Welcome to ...
- 3writetext BANK(UnknownText_0x1b002b), UnknownText_0x1b002b
- keeptextopen
- 2jump .heal
-.day_comcenter
-; Hello! This is the ...
- 3writetext BANK(UnknownText_0x1b00d6), UnknownText_0x1b00d6
- keeptextopen
- 2jump .heal
-
-.nite
-; Different text if we're in the com center
- checkbit1 $032a
- iftrue .nite_comcenter
-; Good evening! You're out late. ...
- 3writetext BANK(UnknownText_0x1b004f), UnknownText_0x1b004f
- keeptextopen
- 2jump .heal
-.nite_comcenter
-; Good to see you working so late. ...
- 3writetext BANK(UnknownText_0x1b011b), UnknownText_0x1b011b
- keeptextopen
- 2jump .heal
-
-.heal
-; If we come back, don't welcome us to the com center again
- clearbit1 $032a
-; Ask if you want to heal
- 3writetext BANK(UnknownText_0x1b017a), UnknownText_0x1b017a
- yesorno
- iffalse .end
-; Go ahead and heal
- 3writetext BANK(UnknownText_0x1b01bd), UnknownText_0x1b01bd
- pause 20
- special $009d
-; Turn to the machine
- spriteface $fe, $2
- pause 10
- special $001b
- playmusic $0000
- writebyte $0
- special $003e
- pause 30
- special $003d
- spriteface $fe, $0
- pause 10
-; Has Elm already phoned you about Pokerus?
- checkphonecall
- iftrue .done
-; Has Pokerus already been found in the Pokecenter?
- checkbit2 $000d
- iftrue .done
-; Check for Pokerus
- special $004e ; SPECIAL_CHECKPOKERUS
- iftrue .pokerus
-.done
-; Thank you for waiting. ...
- 3writetext BANK(UnknownText_0x1b01d7), UnknownText_0x1b01d7
- pause 20
-.end
-; We hope to see you again.
- 3writetext BANK(UnknownText_0x1b020b), UnknownText_0x1b020b
-; Curtsy
- spriteface $fe, $1
- pause 10
- spriteface $fe, $0
- pause 10
-; And we're out
- closetext
- loadmovesprites
- end
-
-.pokerus
-; Different text for com center (excludes 'in a Pokemon Center')
-; Since flag $32a is cleared when healing,
-; this text is never actually seen
- checkbit1 $032a
- iftrue .pokerus_comcenter
-; Your Pokemon appear to be infected ...
- 3writetext BANK(UnknownText_0x1b0241), UnknownText_0x1b0241
- closetext
- loadmovesprites
- 2jump .endpokerus
-.pokerus_comcenter
-; Your Pokemon appear to be infected ...
- 3writetext BANK(UnknownText_0x1b02d6), UnknownText_0x1b02d6
- closetext
- loadmovesprites
-.endpokerus
-; Don't tell us about Pokerus again
- setbit2 $000d
-; Trigger Elm's Pokerus phone call
- specialphonecall $0001
- end
-; bc162
-
-UnknownScript_0xbc162: ; 0xbc162
- 3jumptext $6c, $435a
-; 0xbc166
-
-UnknownScript_0xbc166: ; 0xbc166
- 3jumptext $6c, $4378
-; 0xbc16a
-
-UnknownScript_0xbc16a: ; 0xbc16a
- 3jumptext $6c, $43a3
-; 0xbc16e
-
-UnknownScript_0xbc16e: ; 0xbc16e
- 3jumptext $6c, $43d9
-; 0xbc172
-
-UnknownScript_0xbc172: ; 0xbc172
- 3jumptext $6c, $4448
-; 0xbc176
-
-UnknownScript_0xbc176: ; 0xbc176
- 3jumptext $6c, $4472
-; 0xbc17a
-
-UnknownScript_0xbc17a: ; 0xbc17a
- loadfont
- 3writetext $6c, $448d
- closetext
- special $0026
- loadmovesprites
- end
-; 0xbc185
-
-UnknownScript_0xbc185: ; 0xbc185
- 3jumptext $6c, $44a0
-; 0xbc189
-
-UnknownScript_0xbc189: ; 0xbc189
- loadfont
- 3writetext $6c, $44be
- closetext
- loadmovesprites
- end
-; 0xbc191
-
-UnknownScript_0xbc191: ; 0xbc191
- 3jumptext $6c, $44c9
-; 0xbc195
-
-UnknownScript_0xbc195: ; 0xbc195
- loadfont
- writebyte $0
- special $0028
- loadmovesprites
- end
-; 0xbc19d
-
-UnknownScript_0xbc19d: ; 0xbc19d
- loadfont
- writebyte $4
- special $0028
- loadmovesprites
- end
-; 0xbc1a5
-
-UnknownScript_0xbc1a5: ; 0xbc1a5
- 3jumptext $6c, $4526
-; 0xbc1a9
-
-UnknownScript_0xbc1a9: ; 0xbc1a9
- loadfont
- special $001c
- loadmovesprites
- end
-; 0xbc1af
-
-UnknownScript_0xbc1af: ; 0xbc1af
- playsound $0008
- pause 15
- playsound $0027
- end
-; 0xbc1b8
-
-UnknownScript_0xbc1b8: ; 0xbc1b8
- 3jump BANK(UnknownScript_0xcd4b), UnknownScript_0xcd4b
-; 0xbc1bc
-
-UnknownScript_0xbc1bc: ; 0xbc1bc
- 3jump BANK(UnknownScript_0xcf5d), UnknownScript_0xcf5d
-; 0xbc1c0
-
-UnknownScript_0xbc1c0: ; 0xbc1c0
- 3jumptext $6c, $457f
-; 0xbc1c4
-
-UnknownScript_0xbc1c4: ; 0xbc1c4
- 3jumptext $6c, $459c
-; 0xbc1c8
-
-UnknownScript_0xbc1c8: ; 0xbc1c8
- checkcode $b
- if_equal $1, UnknownScript_0xbc1e7
- if_equal $2, UnknownScript_0xbc1ec
- if_equal $3, UnknownScript_0xbc1f1
- if_equal $4, UnknownScript_0xbc1f6
- if_equal $5, UnknownScript_0xbc1fb
- if_equal $6, UnknownScript_0xbc200
- stringtotext UnknownRawText_0xbc205, $0
- end
-; 0xbc1e7
-
-UnknownScript_0xbc1e7: ; 0xbc1e7
- stringtotext UnknownRawText_0xbc20c, $0
- end
-; 0xbc1ec
-
-UnknownScript_0xbc1ec: ; 0xbc1ec
- stringtotext UnknownRawText_0xbc213, $0
- end
-; 0xbc1f1
-
-UnknownScript_0xbc1f1: ; 0xbc1f1
- stringtotext UnknownRawText_0xbc21b, $0
- end
-; 0xbc1f6
-
-UnknownScript_0xbc1f6: ; 0xbc1f6
- stringtotext UnknownRawText_0xbc225, $0
- end
-; 0xbc1fb
-
-UnknownScript_0xbc1fb: ; 0xbc1fb
- stringtotext UnknownRawText_0xbc22e, $0
- end
-; 0xbc200
-
-UnknownScript_0xbc200: ; 0xbc200
- stringtotext UnknownRawText_0xbc235, $0
- end
-; 0xbc205
-
-UnknownRawText_0xbc205: ; bc205
- db "SUNDAY@"
-; bc20c
-
-UnknownRawText_0xbc20c: ; bc20c
- db "MONDAY@"
-; bc213
-
-UnknownRawText_0xbc213: ; bc213
- db "TUESDAY@"
-; bc21b
-
-UnknownRawText_0xbc21b: ; bc21b
- db "WEDNESDAY@"
-; bc225
-
-UnknownRawText_0xbc225: ; bc225
- db "THURSDAY@"
-; bc22e
-
-UnknownRawText_0xbc22e: ; bc22e
- db "FRIDAY@"
-; bc235
-
-UnknownRawText_0xbc235: ; bc235
- db "SATURDAY@"
-; bc23e
-
-UnknownScript_0xbc23e: ; 0xbc23e
- clearbit1 $06cd
- end
-; 0xbc242
-
-UnknownScript_0xbc242: ; 0xbc242
- setbit2 $0013
- setbit1 $06cf
- setbit1 $06d1
- clearbit1 $06ce
- clearbit1 $0025
- setbit1 $0756
- specialphonecall $0004
- domaptrigger GROUP_MAHOGANY_TOWN, MAP_MAHOGANY_TOWN, $1
- end
-; 0xbc25c
-
-UnknownScript_0xbc25c: ; 0xbc25c
- special $0034
- 2call UnknownScript_0xbc380
- setbit1 $0747
- clearbit1 $0748
- setbit1 $02d2
- warp GROUP_ROUTE_36_NATIONAL_PARK_GATE, MAP_ROUTE_36_NATIONAL_PARK_GATE, $0, $4
- applymovement $0, MovementData_0xbcea1
-
-UnknownScript_0xbc274: ; bc274
- clearbit2 $0011
- clearbit1 $02d2
- clearbit1 $0313
- clearbit1 $0314
- clearbit1 $0315
- clearbit1 $0316
- loadfont
- 3writetext $6c, $45bf
- closetext
- special $0014
- RAM2MEM $0
- if_equal $1, UnknownScript_0xbc31e
- if_equal $2, UnknownScript_0xbc332
- if_equal $3, UnknownScript_0xbc343
- 3writetext $6c, $4681
- keeptextopen
- waitbutton
- verbosegiveitem BERRY, 1
- iffalse UnknownScript_0xbc375
- 3writetext $6c, $46b7
- keeptextopen
- 2jump $42b6
-; 0xbc2b1
-
-UnknownScript_0xbc2b1: ; 0xbc2b1
- 3writetext $6c, $465b
- keeptextopen
- checkbit1 $0308
- iffalse $42c4
- 3writetext $6c, $46d9
- closetext
- special $0017
- special $0015
- if_equal $0, $42d4
- if_equal $2, $42d4
- 3writetext $6c, $470d
- closetext
- loadmovesprites
- dotrigger $0
- domaptrigger GROUP_ROUTE_35_NATIONAL_PARK_GATE, MAP_ROUTE_35_NATIONAL_PARK_GATE, $0
- setbit1 $0716
- setbit1 $0717
- setbit1 $0718
- setbit1 $0719
- setbit1 $071a
- setbit1 $071b
- setbit1 $071c
- setbit1 $071d
- setbit1 $071e
- setbit1 $071f
- setbit1 $0720
- setbit1 $0721
- setbit1 $0722
- setbit1 $0723
- setbit1 $0724
- setbit1 $0725
- setbit1 $0726
- setbit1 $0727
- setbit1 $0728
- setbit1 $0729
- setbit2 $0051
- special $003c
- end
-; 0xbc31e
-
-UnknownScript_0xbc31e: ; 0xbc31e
- setbit1 $0000
- itemtotext SUN_STONE, $1
- 3writetext $6c, $4621
- closetext
- verbosegiveitem SUN_STONE, 1
- iffalse UnknownScript_0xbc354
- 2jump UnknownScript_0xbc2b1
-; 0xbc332
-
-UnknownScript_0xbc332: ; 0xbc332
- itemtotext EVERSTONE, $1
- 3writetext $6c, $4621
- closetext
- verbosegiveitem EVERSTONE, 1
- iffalse UnknownScript_0xbc35f
- 2jump UnknownScript_0xbc2b1
-; 0xbc343
-
-UnknownScript_0xbc343: ; 0xbc343
- itemtotext GOLD_BERRY, $1
- 3writetext $6c, $4621
- closetext
- verbosegiveitem GOLD_BERRY, 1
- iffalse UnknownScript_0xbc36a
- 2jump UnknownScript_0xbc2b1
-; 0xbc354
-
-UnknownScript_0xbc354: ; 0xbc354
- 3writetext $6c, $48cc
- keeptextopen
- setbit1 $0313
- 2jump UnknownScript_0xbc2b1
-; 0xbc35f
-
-UnknownScript_0xbc35f: ; 0xbc35f
- 3writetext $6c, $48cc
- keeptextopen
- setbit1 $0314
- 2jump UnknownScript_0xbc2b1
-; 0xbc36a
-
-UnknownScript_0xbc36a: ; 0xbc36a
- 3writetext $6c, $48cc
- keeptextopen
- setbit1 $0315
- 2jump UnknownScript_0xbc2b1
-; 0xbc375
-
-UnknownScript_0xbc375: ; 0xbc375
- 3writetext $6c, $48cc
- keeptextopen
- setbit1 $0316
- 2jump $42a9
-; 0xbc380
-
-UnknownScript_0xbc380: ; 0xbc380
- checkbit1 $0716
- iftrue $4389
- clearbit1 $0720
- checkbit1 $0717
- iftrue $4392
- clearbit1 $0721
- checkbit1 $0718
- iftrue $439b
- clearbit1 $0722
- checkbit1 $0719
- iftrue $43a4
- clearbit1 $0723
- checkbit1 $071a
- iftrue $43ad
- clearbit1 $0724
- checkbit1 $071b
- iftrue $43b6
- clearbit1 $0725
- checkbit1 $071c
- iftrue $43bf
- clearbit1 $0726
- checkbit1 $071d
- iftrue $43c8
- clearbit1 $0727
- checkbit1 $071e
- iftrue $43d1
- clearbit1 $0728
- checkbit1 $071f
- iftrue $43da
- clearbit1 $0729
- end
-; 0xbc3db
-
-UnknownScript_0xbc3db: ; 0xbc3db
- setbit1 $06cb
- setbit1 $06ce
- setbit1 $06cd
- setbit1 $06d0
- setbit1 $06f3
- setbit1 $06e9
- setbit1 $06f4
- setbit1 $06d5
- setbit1 $06de
- setbit1 $06dd
- setbit1 $06df
- setbit1 $06c0
- setbit1 $06e4
- setbit1 $0025
- setbit1 $06be
- setbit1 $06bf
- setbit1 $06c1
- setbit1 $06f9
- setbit1 $06fd
- setbit1 $06ff
- setbit1 $0700
- setbit1 $0702
- setbit1 $0703
- setbit1 $0704
- setbit1 $070d
- setbit1 $070e
- setbit1 $070f
- setbit1 $0710
- setbit1 $0715
- setbit1 $0716
- setbit1 $0717
- setbit1 $0718
- setbit1 $0719
- setbit1 $071a
- setbit1 $071b
- setbit1 $071c
- setbit1 $071d
- setbit1 $071e
- setbit1 $071f
- setbit1 $0720
- setbit1 $0721
- setbit1 $0722
- setbit1 $0723
- setbit1 $0724
- setbit1 $0725
- setbit1 $0726
- setbit1 $0727
- setbit1 $0728
- setbit1 $0729
- setbit1 $072c
- setbit1 $072f
- setbit1 $072d
- setbit1 $0735
- setbit1 $0736
- setbit1 $073c
- setbit1 $073d
- setbit1 $0741
- setbit1 $0742
- setbit1 $0743
- setbit1 $0744
- setbit1 $02a4
- setbit1 $02af
- setbit1 $0749
- setbit1 $06d3
- setbit1 $074d
- setbit1 $0712
- setbit1 $0713
- setbit1 $0711
- setbit1 $06d4
- setbit1 $0304
- setbit1 $0307
- setbit1 $06d8
- setbit1 $06c3
- setbit1 $06c2
- setbit1 $06c6
- setbit1 $075f
- setbit1 $0731
- setbit1 $074a
- setbit1 $0762
- setbit1 $0738
- setbit1 $073a
- setbit1 $073b
- setbit1 $0733
- setbit1 $073f
- setbit1 $078d
- setbit1 $0766
- setbit1 $0768
- setbit1 $0769
- setbit1 $076a
- setbit1 $078e
- setbit1 $078f
- setbit1 $0790
- setbit1 $0791
- setbit1 $0793
- setbit1 $07a4
- setbit1 $07a4
- setbit1 $07a5
- setbit1 $06ec
- setbit1 $06ed
- setbit1 $06f0
- setbit1 $07a9
- setbit1 $07aa
- setbit1 $06c8
- setbit1 $07ac
- setbit1 $07ad
- setbit1 $07b5
- setbit1 $07b6
- setbit1 $07c5
- setbit1 $07b7
- setbit1 $07b0
- setbit1 $07af
- setbit1 $07ae
- setbit1 $07cf
- setbit2 $000e
- setbit2 $0017
- variablesprite $4, $52
- variablesprite $5, $4
- variablesprite $6, $35
- variablesprite $7, $a
- variablesprite $8, $a
- variablesprite $9, $a
- variablesprite $a, $a
- variablesprite $b, $28
- variablesprite $c, $28
- setbit1 $00fb
- setbit1 $076d
- setbit1 $076c
- setbit1 $076e
- setbit1 $076f
- setbit1 $0773
- setbit1 $0776
- setbit1 $0777
- setbit1 $0779
- setbit1 $0772
- setbit1 $077b
- setbit1 $0036
- return
-; 0xbc574
-
-UnknownScript_0xbc574: ; 0xbc574
- special $005d
- checkcode $17
- if_equal $5, $45c9
- if_equal $7, UnknownScript_0xbc5ce
- if_equal $b, UnknownScript_0xbc5d3
- if_equal $d, UnknownScript_0xbc5d8
- if_equal $f, UnknownScript_0xbc5dd
- if_equal $10, UnknownScript_0xbc5e2
- if_equal $11, UnknownScript_0xbc5e7
- if_equal $13, UnknownScript_0xbc5ec
- if_equal $14, UnknownScript_0xbc5f1
- if_equal $16, UnknownScript_0xbc5f6
- if_equal $17, UnknownScript_0xbc5fb
- if_equal $18, UnknownScript_0xbc600
- if_equal $1b, UnknownScript_0xbc605
- if_equal $1c, UnknownScript_0xbc60a
- if_equal $1d, UnknownScript_0xbc60f
- if_equal $1e, UnknownScript_0xbc614
- if_equal $20, UnknownScript_0xbc619
- if_equal $21, UnknownScript_0xbc61e
- if_equal $22, UnknownScript_0xbc623
- if_equal $23, UnknownScript_0xbc628
- 3writetext $6c, $49fe
- end
-; 0xbc5ce
-
-UnknownScript_0xbc5ce: ; 0xbc5ce
- 3writetext $6c, $4d9f
- end
-; 0xbc5d3
-
-UnknownScript_0xbc5d3: ; 0xbc5d3
- 3writetext $6c, $502e
- end
-; 0xbc5d8
-
-UnknownScript_0xbc5d8: ; 0xbc5d8
- 3writetext $6c, $542d
- end
-; 0xbc5dd
-
-UnknownScript_0xbc5dd: ; 0xbc5dd
- 3writetext $6c, $5800
- end
-; 0xbc5e2
-
-UnknownScript_0xbc5e2: ; 0xbc5e2
- 3writetext $6c, $5a71
- end
-; 0xbc5e7
-
-UnknownScript_0xbc5e7: ; 0xbc5e7
- 3writetext $6c, $5cd5
- end
-; 0xbc5ec
-
-UnknownScript_0xbc5ec: ; 0xbc5ec
- 3writetext $29, $4000
- end
-; 0xbc5f1
-
-UnknownScript_0xbc5f1: ; 0xbc5f1
- 3writetext $29, $41c0
- end
-; 0xbc5f6
-
-UnknownScript_0xbc5f6: ; 0xbc5f6
- 3writetext $29, $4642
- end
-; 0xbc5fb
-
-UnknownScript_0xbc5fb: ; 0xbc5fb
- 3writetext $29, $4829
- end
-; 0xbc600
-
-UnknownScript_0xbc600: ; 0xbc600
- 3writetext $29, $4a31
- end
-; 0xbc605
-
-UnknownScript_0xbc605: ; 0xbc605
- 3writetext $29, $4ed4
- end
-; 0xbc60a
-
-UnknownScript_0xbc60a: ; 0xbc60a
- 3writetext $29, $50d5
- end
-; 0xbc60f
-
-UnknownScript_0xbc60f: ; 0xbc60f
- 3writetext $29, $52e2
- end
-; 0xbc614
-
-UnknownScript_0xbc614: ; 0xbc614
- 3writetext $29, $5545
- end
-; 0xbc619
-
-UnknownScript_0xbc619: ; 0xbc619
- 3writetext $29, $5937
- end
-; 0xbc61e
-
-UnknownScript_0xbc61e: ; 0xbc61e
- 3writetext $29, $5bc4
- end
-; 0xbc623
-
-UnknownScript_0xbc623: ; 0xbc623
- 3writetext $29, $5dc6
- end
-; 0xbc628
-
-UnknownScript_0xbc628: ; 0xbc628
- 3writetext $29, $600c
- end
-; 0xbc62d
-
-UnknownScript_0xbc62d: ; 0xbc62d
- special $005d
- checkcode $17
- if_equal $5, $4682
- if_equal $7, UnknownScript_0xbc687
- if_equal $b, UnknownScript_0xbc68c
- if_equal $d, UnknownScript_0xbc691
- if_equal $f, UnknownScript_0xbc696
- if_equal $10, UnknownScript_0xbc69b
- if_equal $11, UnknownScript_0xbc6a0
- if_equal $13, UnknownScript_0xbc6a5
- if_equal $14, UnknownScript_0xbc6aa
- if_equal $16, UnknownScript_0xbc6af
- if_equal $17, UnknownScript_0xbc6b4
- if_equal $18, UnknownScript_0xbc6b9
- if_equal $1b, UnknownScript_0xbc6be
- if_equal $1c, UnknownScript_0xbc6c3
- if_equal $1d, UnknownScript_0xbc6c8
- if_equal $1e, UnknownScript_0xbc6cd
- if_equal $20, UnknownScript_0xbc6d2
- if_equal $21, UnknownScript_0xbc6d7
- if_equal $22, UnknownScript_0xbc6dc
- if_equal $23, UnknownScript_0xbc6e1
- 3writetext $6c, $4a82
- end
-; 0xbc687
-
-UnknownScript_0xbc687: ; 0xbc687
- 3writetext $6c, $4e2c
- end
-; 0xbc68c
-
-UnknownScript_0xbc68c: ; 0xbc68c
- 3writetext $6c, $50d3
- end
-; 0xbc691
-
-UnknownScript_0xbc691: ; 0xbc691
- 3writetext $6c, $54e4
- end
-; 0xbc696
-
-UnknownScript_0xbc696: ; 0xbc696
- 3writetext $6c, $587b
- end
-; 0xbc69b
-
-UnknownScript_0xbc69b: ; 0xbc69b
- 3writetext $6c, $5b1d
- end
-; 0xbc6a0
-
-UnknownScript_0xbc6a0: ; 0xbc6a0
- 3writetext $6c, $5d85
- end
-; 0xbc6a5
-
-UnknownScript_0xbc6a5: ; 0xbc6a5
- 3writetext $29, $40a9
- end
-; 0xbc6aa
-
-UnknownScript_0xbc6aa: ; 0xbc6aa
- 3writetext $29, $426a
- end
-; 0xbc6af
-
-UnknownScript_0xbc6af: ; 0xbc6af
- 3writetext $29, $470b
- end
-; 0xbc6b4
-
-UnknownScript_0xbc6b4: ; 0xbc6b4
- 3writetext $29, $48fc
- end
-; 0xbc6b9
-
-UnknownScript_0xbc6b9: ; 0xbc6b9
- 3writetext $29, $4b03
- end
-; 0xbc6be
-
-UnknownScript_0xbc6be: ; 0xbc6be
- 3writetext $29, $4fc8
- end
-; 0xbc6c3
-
-UnknownScript_0xbc6c3: ; 0xbc6c3
- 3writetext $29, $5175
- end
-; 0xbc6c8
-
-UnknownScript_0xbc6c8: ; 0xbc6c8
- 3writetext $29, $5383
- end
-; 0xbc6cd
-
-UnknownScript_0xbc6cd: ; 0xbc6cd
- 3writetext $29, $5621
- end
-; 0xbc6d2
-
-UnknownScript_0xbc6d2: ; 0xbc6d2
- 3writetext $29, $59bc
- end
-; 0xbc6d7
-
-UnknownScript_0xbc6d7: ; 0xbc6d7
- 3writetext $29, $5c4b
- end
-; 0xbc6dc
-
-UnknownScript_0xbc6dc: ; 0xbc6dc
- 3writetext $29, $5e63
- end
-; 0xbc6e1
-
-UnknownScript_0xbc6e1: ; 0xbc6e1
- 3writetext $29, $6076
- end
-; 0xbc6e6
-
-UnknownScript_0xbc6e6: ; 0xbc6e6
- 3writetext $6c, $49c4
- playsound $0093
- waitbutton
- keeptextopen
- end
-; 0xbc6f0
-
-UnknownScript_0xbc6f0: ; 0xbc6f0
- checkcode $17
- if_equal $5, $4742
- if_equal $7, UnknownScript_0xbc749
- if_equal $b, UnknownScript_0xbc750
- if_equal $d, UnknownScript_0xbc757
- if_equal $f, UnknownScript_0xbc75e
- if_equal $10, UnknownScript_0xbc765
- if_equal $11, UnknownScript_0xbc76c
- if_equal $13, UnknownScript_0xbc773
- if_equal $14, UnknownScript_0xbc77a
- if_equal $16, UnknownScript_0xbc781
- if_equal $17, UnknownScript_0xbc788
- if_equal $18, UnknownScript_0xbc78f
- if_equal $1b, UnknownScript_0xbc796
- if_equal $1c, UnknownScript_0xbc79d
- if_equal $1d, UnknownScript_0xbc7a4
- if_equal $1e, UnknownScript_0xbc7ab
- if_equal $20, UnknownScript_0xbc7b2
- if_equal $21, UnknownScript_0xbc7b9
- if_equal $22, UnknownScript_0xbc7c0
- if_equal $23, UnknownScript_0xbc7c7
- 3writetext $6c, $4adb
- closetext
- loadmovesprites
- end
-; 0xbc749
-
-UnknownScript_0xbc749: ; 0xbc749
- 3writetext $6c, $4e89
- closetext
- loadmovesprites
- end
-; 0xbc750
-
-UnknownScript_0xbc750: ; 0xbc750
- 3writetext $6c, $5136
- closetext
- loadmovesprites
- end
-; 0xbc757
-
-UnknownScript_0xbc757: ; 0xbc757
- 3writetext $6c, $5553
- closetext
- loadmovesprites
- end
-; 0xbc75e
-
-UnknownScript_0xbc75e: ; 0xbc75e
- 3writetext $6c, $58d7
- closetext
- loadmovesprites
- end
-; 0xbc765
-
-UnknownScript_0xbc765: ; 0xbc765
- 3writetext $6c, $5b8e
- closetext
- loadmovesprites
- end
-; 0xbc76c
-
-UnknownScript_0xbc76c: ; 0xbc76c
- 3writetext $6c, $5db9
- closetext
- loadmovesprites
- end
-; 0xbc773
-
-UnknownScript_0xbc773: ; 0xbc773
- 3writetext $29, $40f8
- closetext
- loadmovesprites
- end
-; 0xbc77a
-
-UnknownScript_0xbc77a: ; 0xbc77a
- 3writetext $29, $42ab
- closetext
- loadmovesprites
- end
-; 0xbc781
-
-UnknownScript_0xbc781: ; 0xbc781
- 3writetext $29, $4730
- closetext
- loadmovesprites
- end
-; 0xbc788
-
-UnknownScript_0xbc788: ; 0xbc788
- 3writetext $29, $494d
- closetext
- loadmovesprites
- end
-; 0xbc78f
-
-UnknownScript_0xbc78f: ; 0xbc78f
- 3writetext $29, $4b47
- closetext
- loadmovesprites
- end
-; 0xbc796
-
-UnknownScript_0xbc796: ; 0xbc796
- 3writetext $29, $502e
- closetext
- loadmovesprites
- end
-; 0xbc79d
-
-UnknownScript_0xbc79d: ; 0xbc79d
- 3writetext $29, $51ac
- closetext
- loadmovesprites
- end
-; 0xbc7a4
-
-UnknownScript_0xbc7a4: ; 0xbc7a4
- 3writetext $29, $53de
- closetext
- loadmovesprites
- end
-; 0xbc7ab
-
-UnknownScript_0xbc7ab: ; 0xbc7ab
- 3writetext $29, $5666
- closetext
- loadmovesprites
- end
-; 0xbc7b2
-
-UnknownScript_0xbc7b2: ; 0xbc7b2
- 3writetext $29, $5a28
- closetext
- loadmovesprites
- end
-; 0xbc7b9
-
-UnknownScript_0xbc7b9: ; 0xbc7b9
- 3writetext $29, $5c8e
- closetext
- loadmovesprites
- end
-; 0xbc7c0
-
-UnknownScript_0xbc7c0: ; 0xbc7c0
- 3writetext $29, $5ea8
- closetext
- loadmovesprites
- end
-; 0xbc7c7
-
-UnknownScript_0xbc7c7: ; 0xbc7c7
- 3writetext $29, $60b5
- closetext
- loadmovesprites
- end
-; 0xbc7ce
-
-UnknownScript_0xbc7ce: ; 0xbc7ce
- checkcode $17
- if_equal $5, $4820
- if_equal $7, UnknownScript_0xbc827
- if_equal $b, UnknownScript_0xbc82e
- if_equal $d, UnknownScript_0xbc835
- if_equal $f, UnknownScript_0xbc83c
- if_equal $10, UnknownScript_0xbc843
- if_equal $11, UnknownScript_0xbc84a
- if_equal $13, UnknownScript_0xbc851
- if_equal $14, UnknownScript_0xbc858
- if_equal $16, UnknownScript_0xbc85f
- if_equal $17, UnknownScript_0xbc866
- if_equal $18, UnknownScript_0xbc86d
- if_equal $1b, UnknownScript_0xbc874
- if_equal $1c, UnknownScript_0xbc87b
- if_equal $1d, UnknownScript_0xbc882
- if_equal $1e, UnknownScript_0xbc889
- if_equal $20, UnknownScript_0xbc890
- if_equal $21, UnknownScript_0xbc897
- if_equal $22, UnknownScript_0xbc89e
- if_equal $23, UnknownScript_0xbc8a5
- 3writetext $6c, $4afd
- closetext
- loadmovesprites
- end
-; 0xbc827
-
-UnknownScript_0xbc827: ; 0xbc827
- 3writetext $6c, $4ea2
- closetext
- loadmovesprites
- end
-; 0xbc82e
-
-UnknownScript_0xbc82e: ; 0xbc82e
- 3writetext $6c, $517b
- closetext
- loadmovesprites
- end
-; 0xbc835
-
-UnknownScript_0xbc835: ; 0xbc835
- 3writetext $6c, $5584
- closetext
- loadmovesprites
- end
-; 0xbc83c
-
-UnknownScript_0xbc83c: ; 0xbc83c
- 3writetext $6c, $5908
- closetext
- loadmovesprites
- end
-; 0xbc843
-
-UnknownScript_0xbc843: ; 0xbc843
- 3writetext $6c, $5bd2
- closetext
- loadmovesprites
- end
-; 0xbc84a
-
-UnknownScript_0xbc84a: ; 0xbc84a
- 3writetext $6c, $5df4
- closetext
- loadmovesprites
- end
-; 0xbc851
-
-UnknownScript_0xbc851: ; 0xbc851
- 3writetext $29, $4126
- closetext
- loadmovesprites
- end
-; 0xbc858
-
-UnknownScript_0xbc858: ; 0xbc858
- 3writetext $29, $42f2
- closetext
- loadmovesprites
- end
-; 0xbc85f
-
-UnknownScript_0xbc85f: ; 0xbc85f
- 3writetext $29, $4794
- closetext
- loadmovesprites
- end
-; 0xbc866
-
-UnknownScript_0xbc866: ; 0xbc866
- 3writetext $29, $498a
- closetext
- loadmovesprites
- end
-; 0xbc86d
-
-UnknownScript_0xbc86d: ; 0xbc86d
- 3writetext $29, $4b87
- closetext
- loadmovesprites
- end
-; 0xbc874
-
-UnknownScript_0xbc874: ; 0xbc874
- 3writetext $29, $505f
- closetext
- loadmovesprites
- end
-; 0xbc87b
-
-UnknownScript_0xbc87b: ; 0xbc87b
- 3writetext $29, $51ee
- closetext
- loadmovesprites
- end
-; 0xbc882
-
-UnknownScript_0xbc882: ; 0xbc882
- 3writetext $29, $5412
- closetext
- loadmovesprites
- end
-; 0xbc889
-
-UnknownScript_0xbc889: ; 0xbc889
- 3writetext $29, $56b6
- closetext
- loadmovesprites
- end
-; 0xbc890
-
-UnknownScript_0xbc890: ; 0xbc890
- 3writetext $29, $5a5a
- closetext
- loadmovesprites
- end
-; 0xbc897
-
-UnknownScript_0xbc897: ; 0xbc897
- 3writetext $29, $5cc5
- closetext
- loadmovesprites
- end
-; 0xbc89e
-
-UnknownScript_0xbc89e: ; 0xbc89e
- 3writetext $29, $5ed6
- closetext
- loadmovesprites
- end
-; 0xbc8a5
-
-UnknownScript_0xbc8a5: ; 0xbc8a5
- 3writetext $29, $60e2
- closetext
- loadmovesprites
- end
-; 0xbc8ac
-
-UnknownScript_0xbc8ac: ; 0xbc8ac
- checkcode $17
- if_equal $5, $48fe
- if_equal $7, UnknownScript_0xbc905
- if_equal $b, UnknownScript_0xbc90c
- if_equal $d, UnknownScript_0xbc913
- if_equal $f, UnknownScript_0xbc91a
- if_equal $10, UnknownScript_0xbc921
- if_equal $11, UnknownScript_0xbc928
- if_equal $13, UnknownScript_0xbc92f
- if_equal $14, UnknownScript_0xbc936
- if_equal $16, UnknownScript_0xbc93d
- if_equal $17, UnknownScript_0xbc944
- if_equal $18, UnknownScript_0xbc94b
- if_equal $1b, UnknownScript_0xbc952
- if_equal $1c, UnknownScript_0xbc959
- if_equal $1d, UnknownScript_0xbc960
- if_equal $1e, UnknownScript_0xbc967
- if_equal $20, UnknownScript_0xbc96e
- if_equal $21, UnknownScript_0xbc975
- if_equal $22, UnknownScript_0xbc97c
- if_equal $23, UnknownScript_0xbc983
- 3writetext $6c, $4b42
- closetext
- loadmovesprites
- end
-; 0xbc905
-
-UnknownScript_0xbc905: ; 0xbc905
- 3writetext $6c, $4ebc
- closetext
- loadmovesprites
- end
-; 0xbc90c
-
-UnknownScript_0xbc90c: ; 0xbc90c
- 3writetext $6c, $51c4
- closetext
- loadmovesprites
- end
-; 0xbc913
-
-UnknownScript_0xbc913: ; 0xbc913
- 3writetext $6c, $55b6
- closetext
- loadmovesprites
- end
-; 0xbc91a
-
-UnknownScript_0xbc91a: ; 0xbc91a
- 3writetext $6c, $5936
- closetext
- loadmovesprites
- end
-; 0xbc921
-
-UnknownScript_0xbc921: ; 0xbc921
- 3writetext $6c, $5c06
- closetext
- loadmovesprites
- end
-; 0xbc928
-
-UnknownScript_0xbc928: ; 0xbc928
- 3writetext $6c, $5e50
- closetext
- loadmovesprites
- end
-; 0xbc92f
-
-UnknownScript_0xbc92f: ; 0xbc92f
- 3writetext $29, $4158
- closetext
- loadmovesprites
- end
-; 0xbc936
-
-UnknownScript_0xbc936: ; 0xbc936
- 3writetext $29, $434a
- closetext
- loadmovesprites
- end
-; 0xbc93d
-
-UnknownScript_0xbc93d: ; 0xbc93d
- 3writetext $29, $47eb
- closetext
- loadmovesprites
- end
-; 0xbc944
-
-UnknownScript_0xbc944: ; 0xbc944
- 3writetext $29, $49bd
- closetext
- loadmovesprites
- end
-; 0xbc94b
-
-UnknownScript_0xbc94b: ; 0xbc94b
- 3writetext $29, $4bcd
- closetext
- loadmovesprites
- end
-; 0xbc952
-
-UnknownScript_0xbc952: ; 0xbc952
- 3writetext $29, $508c
- closetext
- loadmovesprites
- end
-; 0xbc959
-
-UnknownScript_0xbc959: ; 0xbc959
- 3writetext $29, $5216
- closetext
- loadmovesprites
- end
-; 0xbc960
-
-UnknownScript_0xbc960: ; 0xbc960
- 3writetext $29, $5446
- closetext
- loadmovesprites
- end
-; 0xbc967
-
-UnknownScript_0xbc967: ; 0xbc967
- 3writetext $29, $56e2
- closetext
- loadmovesprites
- end
-; 0xbc96e
-
-UnknownScript_0xbc96e: ; 0xbc96e
- 3writetext $29, $5aa6
- closetext
- loadmovesprites
- end
-; 0xbc975
-
-UnknownScript_0xbc975: ; 0xbc975
- 3writetext $29, $5cfa
- closetext
- loadmovesprites
- end
-; 0xbc97c
-
-UnknownScript_0xbc97c: ; 0xbc97c
- 3writetext $29, $5f06
- closetext
- loadmovesprites
- end
-; 0xbc983
-
-UnknownScript_0xbc983: ; 0xbc983
- 3writetext $29, $6144
- closetext
- loadmovesprites
- end
-; 0xbc98a
-
-UnknownScript_0xbc98a: ; 0xbc98a
- checkcode $17
- if_equal $5, $49d0
- if_equal $7, UnknownScript_0xbc9d7
- if_equal $b, UnknownScript_0xbc9de
- if_equal $d, UnknownScript_0xbc9e5
- if_equal $f, UnknownScript_0xbc9ec
- if_equal $10, UnknownScript_0xbc9f3
- if_equal $11, UnknownScript_0xbc9fa
- if_equal $13, UnknownScript_0xbca01
- if_equal $14, UnknownScript_0xbca08
- if_equal $17, UnknownScript_0xbca0f
- if_equal $18, UnknownScript_0xbca16
- if_equal $1b, UnknownScript_0xbca1d
- if_equal $1d, UnknownScript_0xbca24
- if_equal $1e, UnknownScript_0xbca2b
- if_equal $20, UnknownScript_0xbca32
- if_equal $21, UnknownScript_0xbca39
- if_equal $23, UnknownScript_0xbca40
- 3writetext $6c, $4b75
- closetext
- loadmovesprites
- end
-; 0xbc9d7
-
-UnknownScript_0xbc9d7: ; 0xbc9d7
- 3writetext $6c, $4edc
- closetext
- loadmovesprites
- end
-; 0xbc9de
-
-UnknownScript_0xbc9de: ; 0xbc9de
- 3writetext $6c, $51fe
- closetext
- loadmovesprites
- end
-; 0xbc9e5
-
-UnknownScript_0xbc9e5: ; 0xbc9e5
- 3writetext $6c, $55d5
- closetext
- loadmovesprites
- end
-; 0xbc9ec
-
-UnknownScript_0xbc9ec: ; 0xbc9ec
- 3writetext $6c, $5954
- closetext
- loadmovesprites
- end
-; 0xbc9f3
-
-UnknownScript_0xbc9f3: ; 0xbc9f3
- 3writetext $6c, $5c32
- closetext
- loadmovesprites
- end
-; 0xbc9fa
-
-UnknownScript_0xbc9fa: ; 0xbc9fa
- 3writetext $6c, $5e98
- closetext
- loadmovesprites
- end
-; 0xbca01
-
-UnknownScript_0xbca01: ; 0xbca01
- 3writetext $29, $418d
- closetext
- loadmovesprites
- end
-; 0xbca08
-
-UnknownScript_0xbca08: ; 0xbca08
- 3writetext $29, $4382
- closetext
- loadmovesprites
- end
-; 0xbca0f
-
-UnknownScript_0xbca0f: ; 0xbca0f
- 3writetext $29, $49fc
- closetext
- loadmovesprites
- end
-; 0xbca16
-
-UnknownScript_0xbca16: ; 0xbca16
- 3writetext $29, $4bec
- closetext
- loadmovesprites
- end
-; 0xbca1d
-
-UnknownScript_0xbca1d: ; 0xbca1d
- 3writetext $29, $50b1
- closetext
- loadmovesprites
- end
-; 0xbca24
-
-UnknownScript_0xbca24: ; 0xbca24
- 3writetext $29, $548c
- closetext
- loadmovesprites
- end
-; 0xbca2b
-
-UnknownScript_0xbca2b: ; 0xbca2b
- 3writetext $29, $571e
- closetext
- loadmovesprites
- end
-; 0xbca32
-
-UnknownScript_0xbca32: ; 0xbca32
- 3writetext $29, $5ada
- closetext
- loadmovesprites
- end
-; 0xbca39
-
-UnknownScript_0xbca39: ; 0xbca39
- 3writetext $29, $5d1d
- closetext
- loadmovesprites
- end
-; 0xbca40
-
-UnknownScript_0xbca40: ; 0xbca40
- 3writetext $29, $6175
- closetext
- loadmovesprites
- end
-; 0xbca47
-
-UnknownScript_0xbca47: ; 0xbca47
- checkcode $17
- if_equal $d, $4a65
- if_equal $10, UnknownScript_0xbca6b
- if_equal $18, UnknownScript_0xbca71
- if_equal $1c, UnknownScript_0xbca77
- if_equal $1d, UnknownScript_0xbca7d
- if_equal $21, UnknownScript_0xbca83
- if_equal $22, UnknownScript_0xbca89
- 3writetext $6c, $5607
- keeptextopen
- end
-; 0xbca6b
-
-UnknownScript_0xbca6b: ; 0xbca6b
- 3writetext $6c, $5c57
- keeptextopen
- end
-; 0xbca71
-
-UnknownScript_0xbca71: ; 0xbca71
- 3writetext $29, $4c24
- keeptextopen
- end
-; 0xbca77
-
-UnknownScript_0xbca77: ; 0xbca77
- 3writetext $29, $523a
- keeptextopen
- end
-; 0xbca7d
-
-UnknownScript_0xbca7d: ; 0xbca7d
- 3writetext $29, $54e3
- keeptextopen
- end
-; 0xbca83
-
-UnknownScript_0xbca83: ; 0xbca83
- 3writetext $29, $5d4d
- keeptextopen
- end
-; 0xbca89
-
-UnknownScript_0xbca89: ; 0xbca89
- 3writetext $29, $5f37
- keeptextopen
- end
-; 0xbca8f
-
-UnknownScript_0xbca8f: ; 0xbca8f
- checkcode $17
- if_equal $7, $4abd
- if_equal $d, UnknownScript_0xbcac4
- if_equal $f, UnknownScript_0xbcacb
- if_equal $10, UnknownScript_0xbcad2
- if_equal $18, UnknownScript_0xbcad9
- if_equal $1c, UnknownScript_0xbcae0
- if_equal $1d, UnknownScript_0xbcae7
- if_equal $20, UnknownScript_0xbcaee
- if_equal $21, UnknownScript_0xbcaf5
- if_equal $22, UnknownScript_0xbcafc
- if_equal $23, UnknownScript_0xbcb03
- 3writetext $6c, $4eff
- closetext
- loadmovesprites
- end
-; 0xbcac4
-
-UnknownScript_0xbcac4: ; 0xbcac4
- 3writetext $6c, $564d
- closetext
- loadmovesprites
- end
-; 0xbcacb
-
-UnknownScript_0xbcacb: ; 0xbcacb
- 3writetext $6c, $5978
- closetext
- loadmovesprites
- end
-; 0xbcad2
-
-UnknownScript_0xbcad2: ; 0xbcad2
- 3writetext $6c, $5c91
- closetext
- loadmovesprites
- end
-; 0xbcad9
-
-UnknownScript_0xbcad9: ; 0xbcad9
- 3writetext $29, $4c47
- closetext
- loadmovesprites
- end
-; 0xbcae0
-
-UnknownScript_0xbcae0: ; 0xbcae0
- 3writetext $29, $52a0
- closetext
- loadmovesprites
- end
-; 0xbcae7
-
-UnknownScript_0xbcae7: ; 0xbcae7
- 3writetext $29, $5513
- closetext
- loadmovesprites
- end
-; 0xbcaee
-
-UnknownScript_0xbcaee: ; 0xbcaee
- 3writetext $29, $5aff
- closetext
- loadmovesprites
- end
-; 0xbcaf5
-
-UnknownScript_0xbcaf5: ; 0xbcaf5
- 3writetext $29, $5d9a
- closetext
- loadmovesprites
- end
-; 0xbcafc
-
-UnknownScript_0xbcafc: ; 0xbcafc
- 3writetext $29, $5faa
- closetext
- loadmovesprites
- end
-; 0xbcb03
-
-UnknownScript_0xbcb03: ; 0xbcb03
- 3writetext $29, $61c9
- closetext
- loadmovesprites
- end
-; 0xbcb0a
-
-UnknownScript_0xbcb0a: ; 0xbcb0a
- loadfont
- checkcode $17
- if_equal $7, $4b1d
- if_equal $f, UnknownScript_0xbcb23
- if_equal $20, UnknownScript_0xbcb29
- if_equal $23, UnknownScript_0xbcb2f
- 3writetext $6c, $4f2f
- keeptextopen
- end
-; 0xbcb23
-
-UnknownScript_0xbcb23: ; 0xbcb23
- 3writetext $6c, $59be
- keeptextopen
- end
-; 0xbcb29
-
-UnknownScript_0xbcb29: ; 0xbcb29
- 3writetext $29, $5b3f
- keeptextopen
- end
-; 0xbcb2f
-
-UnknownScript_0xbcb2f: ; 0xbcb2f
- 3writetext $29, $6200
- keeptextopen
- end
-; 0xbcb35
-
-UnknownScript_0xbcb35: ; 0xbcb35
- checkcode $17
- if_equal $6, $4b57
- if_equal $c, UnknownScript_0xbcb5c
- if_equal $e, UnknownScript_0xbcb61
- if_equal $12, UnknownScript_0xbcb66
- if_equal $15, UnknownScript_0xbcb6b
- if_equal $1a, UnknownScript_0xbcb70
- if_equal $1f, UnknownScript_0xbcb75
- if_equal $24, UnknownScript_0xbcb7a
- 3writetext $6c, $4bb6
- end
-; 0xbcb5c
-
-UnknownScript_0xbcb5c: ; 0xbcb5c
- 3writetext $6c, $5239
- end
-; 0xbcb61
-
-UnknownScript_0xbcb61: ; 0xbcb61
- 3writetext $6c, $5690
- end
-; 0xbcb66
-
-UnknownScript_0xbcb66: ; 0xbcb66
- 3writetext $6c, $5ebe
- end
-; 0xbcb6b
-
-UnknownScript_0xbcb6b: ; 0xbcb6b
- 3writetext $29, $4405
- end
-; 0xbcb70
-
-UnknownScript_0xbcb70: ; 0xbcb70
- 3writetext $29, $4c8c
- end
-; 0xbcb75
-
-UnknownScript_0xbcb75: ; 0xbcb75
- 3writetext $29, $574a
- end
-; 0xbcb7a
-
-UnknownScript_0xbcb7a: ; 0xbcb7a
- 3writetext $29, $6295
- end
-; 0xbcb7f
-
-UnknownScript_0xbcb7f: ; 0xbcb7f
- checkcode $17
- if_equal $6, $4ba1
- if_equal $c, UnknownScript_0xbcba6
- if_equal $e, UnknownScript_0xbcbab
- if_equal $12, UnknownScript_0xbcbb0
- if_equal $15, UnknownScript_0xbcbb5
- if_equal $1a, UnknownScript_0xbcbba
- if_equal $1f, UnknownScript_0xbcbbf
- if_equal $24, UnknownScript_0xbcbc4
- 3writetext $6c, $4c37
- end
-; 0xbcba6
-
-UnknownScript_0xbcba6: ; 0xbcba6
- 3writetext $6c, $5314
- end
-; 0xbcbab
-
-UnknownScript_0xbcbab: ; 0xbcbab
- 3writetext $6c, $5710
- end
-; 0xbcbb0
-
-UnknownScript_0xbcbb0: ; 0xbcbb0
- 3writetext $6c, $5f4e
- end
-; 0xbcbb5
-
-UnknownScript_0xbcbb5: ; 0xbcbb5
- 3writetext $29, $44db
- end
-; 0xbcbba
-
-UnknownScript_0xbcbba: ; 0xbcbba
- 3writetext $29, $4d36
- end
-; 0xbcbbf
-
-UnknownScript_0xbcbbf: ; 0xbcbbf
- 3writetext $29, $57e3
- end
-; 0xbcbc4
-
-UnknownScript_0xbcbc4: ; 0xbcbc4
- 3writetext $29, $6316
- end
-; 0xbcbc9
-
-UnknownScript_0xbcbc9: ; 0xbcbc9
- 3writetext $6c, $49e1
- playsound $0093
- waitbutton
- keeptextopen
- end
-; 0xbcbd3
-
-UnknownScript_0xbcbd3: ; 0xbcbd3
- checkcode $17
- if_equal $6, $4bf5
- if_equal $c, UnknownScript_0xbcbfc
- if_equal $e, UnknownScript_0xbcc03
- if_equal $12, UnknownScript_0xbcc0a
- if_equal $15, UnknownScript_0xbcc11
- if_equal $1a, UnknownScript_0xbcc18
- if_equal $1f, UnknownScript_0xbcc1f
- if_equal $24, UnknownScript_0xbcc26
- 3writetext $6c, $4c9b
- closetext
- loadmovesprites
- end
-; 0xbcbfc
-
-UnknownScript_0xbcbfc: ; 0xbcbfc
- 3writetext $6c, $5392
- closetext
- loadmovesprites
- end
-; 0xbcc03
-
-UnknownScript_0xbcc03: ; 0xbcc03
- 3writetext $6c, $5755
- closetext
- loadmovesprites
- end
-; 0xbcc0a
-
-UnknownScript_0xbcc0a: ; 0xbcc0a
- 3writetext $6c, $5faa
- closetext
- loadmovesprites
- end
-; 0xbcc11
-
-UnknownScript_0xbcc11: ; 0xbcc11
- 3writetext $29, $451d
- closetext
- loadmovesprites
- end
-; 0xbcc18
-
-UnknownScript_0xbcc18: ; 0xbcc18
- 3writetext $29, $4d72
- closetext
- loadmovesprites
- end
-; 0xbcc1f
-
-UnknownScript_0xbcc1f: ; 0xbcc1f
- 3writetext $29, $5820
- closetext
- loadmovesprites
- end
-; 0xbcc26
-
-UnknownScript_0xbcc26: ; 0xbcc26
- 3writetext $29, $6359
- closetext
- loadmovesprites
- end
-; 0xbcc2d
-
-UnknownScript_0xbcc2d: ; 0xbcc2d
- checkcode $17
- if_equal $6, $4c4f
- if_equal $c, UnknownScript_0xbcc56
- if_equal $e, UnknownScript_0xbcc5d
- if_equal $12, UnknownScript_0xbcc64
- if_equal $15, UnknownScript_0xbcc6b
- if_equal $1a, UnknownScript_0xbcc72
- if_equal $1f, UnknownScript_0xbcc79
- if_equal $24, UnknownScript_0xbcc80
- 3writetext $6c, $4ce0
- closetext
- loadmovesprites
- end
-; 0xbcc56
-
-UnknownScript_0xbcc56: ; 0xbcc56
- 3writetext $6c, $53af
- closetext
- loadmovesprites
- end
-; 0xbcc5d
-
-UnknownScript_0xbcc5d: ; 0xbcc5d
- 3writetext $6c, $578a
- closetext
- loadmovesprites
- end
-; 0xbcc64
-
-UnknownScript_0xbcc64: ; 0xbcc64
- 3writetext $6c, $5fdd
- closetext
- loadmovesprites
- end
-; 0xbcc6b
-
-UnknownScript_0xbcc6b: ; 0xbcc6b
- 3writetext $29, $4542
- closetext
- loadmovesprites
- end
-; 0xbcc72
-
-UnknownScript_0xbcc72: ; 0xbcc72
- 3writetext $29, $4dcd
- closetext
- loadmovesprites
- end
-; 0xbcc79
-
-UnknownScript_0xbcc79: ; 0xbcc79
- 3writetext $29, $5842
- closetext
- loadmovesprites
- end
-; 0xbcc80
-
-UnknownScript_0xbcc80: ; 0xbcc80
- 3writetext $29, $638c
- closetext
- loadmovesprites
- end
-; 0xbcc87
-
-UnknownScript_0xbcc87: ; 0xbcc87
- checkcode $17
- if_equal $6, $4ca9
- if_equal $c, UnknownScript_0xbccb0
- if_equal $e, UnknownScript_0xbccb7
- if_equal $12, UnknownScript_0xbccbe
- if_equal $15, UnknownScript_0xbccc5
- if_equal $1a, UnknownScript_0xbcccc
- if_equal $1f, UnknownScript_0xbccd3
- if_equal $24, UnknownScript_0xbccda
- 3writetext $6c, $4d0b
- closetext
- loadmovesprites
- end
-; 0xbccb0
-
-UnknownScript_0xbccb0: ; 0xbccb0
- 3writetext $6c, $53e4
- closetext
- loadmovesprites
- end
-; 0xbccb7
-
-UnknownScript_0xbccb7: ; 0xbccb7
- 3writetext $6c, $57ba
- closetext
- loadmovesprites
- end
-; 0xbccbe
-
-UnknownScript_0xbccbe: ; 0xbccbe
- 3writetext $6c, $5ffa
- closetext
- loadmovesprites
- end
-; 0xbccc5
-
-UnknownScript_0xbccc5: ; 0xbccc5
- 3writetext $29, $4573
- closetext
- loadmovesprites
- end
-; 0xbcccc
-
-UnknownScript_0xbcccc: ; 0xbcccc
- 3writetext $29, $4e01
- closetext
- loadmovesprites
- end
-; 0xbccd3
-
-UnknownScript_0xbccd3: ; 0xbccd3
- 3writetext $29, $5881
- closetext
- loadmovesprites
- end
-; 0xbccda
-
-UnknownScript_0xbccda: ; 0xbccda
- 3writetext $29, $63cc
- closetext
- loadmovesprites
- end
-; 0xbcce1
-
-UnknownScript_0xbcce1: ; 0xbcce1
- checkcode $17
- if_equal $c, $4cff
- if_equal $e, UnknownScript_0xbcd06
- if_equal $12, UnknownScript_0xbcd0d
- if_equal $15, UnknownScript_0xbcd14
- if_equal $1a, UnknownScript_0xbcd1b
- if_equal $1f, UnknownScript_0xbcd22
- if_equal $24, UnknownScript_0xbcd29
- 3writetext $6c, $5409
- closetext
- loadmovesprites
- end
-; 0xbcd06
-
-UnknownScript_0xbcd06: ; 0xbcd06
- 3writetext $6c, $57de
- closetext
- loadmovesprites
- end
-; 0xbcd0d
-
-UnknownScript_0xbcd0d: ; 0xbcd0d
- 3writetext $6c, $601f
- closetext
- loadmovesprites
- end
-; 0xbcd14
-
-UnknownScript_0xbcd14: ; 0xbcd14
- 3writetext $29, $4595
- closetext
- loadmovesprites
- end
-; 0xbcd1b
-
-UnknownScript_0xbcd1b: ; 0xbcd1b
- 3writetext $29, $4e21
- closetext
- loadmovesprites
- end
-; 0xbcd22
-
-UnknownScript_0xbcd22: ; 0xbcd22
- 3writetext $29, $58a3
- closetext
- loadmovesprites
- end
-; 0xbcd29
-
-UnknownScript_0xbcd29: ; 0xbcd29
- 3writetext $29, $63f1
- closetext
- loadmovesprites
- end
-; 0xbcd30
-
-UnknownScript_0xbcd30: ; 0xbcd30
- checkcode $17
- if_equal $6, $4d42
- if_equal $15, UnknownScript_0xbcd48
- if_equal $1a, UnknownScript_0xbcd4e
- if_equal $1f, UnknownScript_0xbcd54
- 3writetext $6c, $4d2c
- keeptextopen
- end
-; 0xbcd48
-
-UnknownScript_0xbcd48: ; 0xbcd48
- 3writetext $29, $45c9
- keeptextopen
- end
-; 0xbcd4e
-
-UnknownScript_0xbcd4e: ; 0xbcd4e
- 3writetext $29, $4e4c
- keeptextopen
- end
-; 0xbcd54
-
-UnknownScript_0xbcd54: ; 0xbcd54
- 3writetext $29, $58d5
- keeptextopen
- end
-; 0xbcd5a
-
-UnknownScript_0xbcd5a: ; 0xbcd5a
- checkcode $17
- if_equal $6, $4d70
- if_equal $15, UnknownScript_0xbcd77
- if_equal $1a, UnknownScript_0xbcd7e
- if_equal $1f, UnknownScript_0xbcd85
- if_equal $24, UnknownScript_0xbcd8c
- 3writetext $6c, $4d69
- closetext
- loadmovesprites
- end
-; 0xbcd77
-
-UnknownScript_0xbcd77: ; 0xbcd77
- 3writetext $29, $4603
- closetext
- loadmovesprites
- end
-; 0xbcd7e
-
-UnknownScript_0xbcd7e: ; 0xbcd7e
- 3writetext $29, $4e8f
- closetext
- loadmovesprites
- end
-; 0xbcd85
-
-UnknownScript_0xbcd85: ; 0xbcd85
- 3writetext $29, $5914
- closetext
- loadmovesprites
- end
-; 0xbcd8c
-
-UnknownScript_0xbcd8c: ; 0xbcd8c
- 3writetext $29, $6411
- closetext
- loadmovesprites
- end
-; 0xbcd93
-
-UnknownScript_0xbcd93: ; 0xbcd93
- checkcode $17
- if_equal $24, $4d99
- loadfont
- 3writetext $29, $6454
- keeptextopen
- end
-; 0xbcda0
-
-UnknownScript_0xbcda0: ; 0xbcda0
- mapnametotext $0
- loadfont
- 3writetext $6c, $474e
- closetext
- loadmovesprites
- end
-; 0xbcdaa
-
-UnknownScript_0xbcdaa: ; 0xbcdaa
- mapnametotext $0
- loadfont
- 3writetext $6c, $474e
- keeptextopen
- 3writetext $6c, $475c
- closetext
- loadmovesprites
- end
-; 0xbcdb9
-
-UnknownScript_0xbcdb9: ; 0xbcdb9
- waitbutton
- 3writetext $6c, $4648
- playsound $0001
- waitbutton
- end
-; 0xbcdc3
-
-UnknownScript_0xbcdc3: ; 0xbcdc3
- waitbutton
- 3writetext $6c, $4648
- playsound $0096
- waitbutton
- end
-; 0xbcdcd
-
-UnknownScript_0xbcdcd: ; 0xbcdcd
- faceplayer
- loadfont
- 3writetext $6c, $477f
- keeptextopen
- checkitem COIN_CASE
- iftrue UnknownScript_0xbcde0
- 3writetext $6c, $479c
- closetext
- loadmovesprites
- end
-; 0xbcde0
-
-UnknownScript_0xbcde0: ; 0xbcde0
- 3writetext $6c, $47e3
- special $0050
- loadmenudata $4e54
- interpretmenu2
- writebackup
- if_equal $1, UnknownScript_0xbcdf7
- if_equal $2, UnknownScript_0xbce1b
- 2jump UnknownScript_0xbce4d
-; 0xbcdf7
-
-UnknownScript_0xbcdf7: ; 0xbcdf7
- checkcoins 9949
- if_equal $0, UnknownScript_0xbce46
- checkmoney $0, 1000
- if_equal $2, UnknownScript_0xbce3f
- givecoins 50
- takemoney $0, 1000
- waitbutton
- playsound $0022
- 3writetext $6c, $4830
- closetext
- 2jump $4de4
-; 0xbce1b
-
-UnknownScript_0xbce1b: ; 0xbce1b
- checkcoins 9499
- if_equal $0, UnknownScript_0xbce46
- checkmoney $0, 10000
- if_equal $2, UnknownScript_0xbce3f
- givecoins 500
- takemoney $0, 10000
- waitbutton
- playsound $0022
- 3writetext $6c, $484f
- closetext
- 2jump $4de4
-; 0xbce3f
-
-UnknownScript_0xbce3f: ; 0xbce3f
- 3writetext $6c, $486f
- closetext
- loadmovesprites
- end
-; 0xbce46
-
-UnknownScript_0xbce46: ; 0xbce46
- 3writetext $6c, $488c
- closetext
- loadmovesprites
- end
-; 0xbce4d
-
-UnknownScript_0xbce4d: ; 0xbce4d
- 3writetext $6c, $48ad
- closetext
- loadmovesprites
- end
-; 0xbce54
-
-INCBIN "baserom.gbc", $bce54, $bce7f - $bce54
-
-UnknownScript_0xbce7f: ; 0xbce7f
- faceplayer
- loadfont
- special $0059
- if_greater_than $32, UnknownScript_0xbce9a
- if_greater_than $96, UnknownScript_0xbce93
- 3writetext $6c, $492a
- closetext
- loadmovesprites
- end
-; 0xbce93
-
-UnknownScript_0xbce93: ; 0xbce93
- 3writetext $6c, $4954
- closetext
- loadmovesprites
- end
-; 0xbce9a
-
-UnknownScript_0xbce9a: ; 0xbce9a
- 3writetext $6c, $4989
- closetext
- loadmovesprites
- end
-; 0xbcea1
-
-MovementData_0xbcea1: ; bcea1
- step_right
- step_down
- turn_head_up
- step_end
-; bcea5
-
-UnusedPhoneScript: ; 0xbcea5
- 3writetext BANK(UnusedPhoneText), UnusedPhoneText
- end
-
-MomPhoneScript: ; 0xbceaa
- checkbit1 $0040
- iftrue .bcec5
- checkbit1 $0041 ; if dude talked to you, then you left home without talking to mom
- iftrue MomPhoneLectureScript
- checkbit1 $001f
- iftrue MomPhoneNoGymQuestScript
- checkbit1 $001a
- iftrue MomPhoneNoPokedexScript
- 2jump MomPhoneNoPokemonScript
-
-.bcec5 ; 0xbcec5
- checkbit1 $0007
- iftrue MomPhoneHangUpScript
- 3writetext BANK(MomPhoneGreetingText), MomPhoneGreetingText
- keeptextopen
- mapnametotext $0
- checkcode $f
- if_equal $1, UnknownScript_0xbcee7
- if_equal $2, $4f27
- 2jump UnknownScript_0xbcf2f
-
-UnknownScript_0xbcedf: ; 0xbcedf
- 3writetext $6d, $4021
- keeptextopen
- 2jump UnknownScript_0xbcf37
-
-UnknownScript_0xbcee7: ; 0xbcee7
- checkcode $c
- if_equal GROUP_NEW_BARK_TOWN, .newbark
- if_equal GROUP_CHERRYGROVE_CITY, .cherrygrove
- if_equal GROUP_VIOLET_CITY, .violet
- if_equal GROUP_AZALEA_TOWN, .azalea
- if_equal GROUP_GOLDENROD_CITY, .goldenrod
- 3writetext BANK(MomPhoneGenericAreaText), MomPhoneGenericAreaText
- keeptextopen
- 2jump UnknownScript_0xbcf37
-
-.newbark ; 0xbcf05
- 3writetext BANK(MomPhoneNewBarkText), MomPhoneNewBarkText
- keeptextopen
- 2jump UnknownScript_0xbcf37
-
-.cherrygrove ; 0xbcf0d
- 3writetext BANK(MomPhoneCherrygroveText), MomPhoneCherrygroveText
- keeptextopen
- 2jump UnknownScript_0xbcf37
-
-.violet ; 0xbcf15
- displaylocation $7 ; sprout tower
- 3call $3, UnknownScript_0xbcedf
-.azalea ; 0xbcf1b
- displaylocation $d ; slowpoke well
- 3call $3, UnknownScript_0xbcedf
-.goldenrod ; 0xbcf21
- displaylocation $11 ; radio tower
- 3call $3, UnknownScript_0xbcedf
- 3writetext $6d, $411c
- keeptextopen
- 2jump UnknownScript_0xbcf37
-
-UnknownScript_0xbcf2f: ; 0xbcf2f
- 3writetext $6d, $4150
- keeptextopen
- 2jump UnknownScript_0xbcf37
-
-UnknownScript_0xbcf37: ; 0xbcf37
- checkbit2 $0008
- iffalse UnknownScript_0xbcf49
- checkmoney $1, 0
- if_equal $0, UnknownScript_0xbcf55
- 2jump UnknownScript_0xbcf63
-
-UnknownScript_0xbcf49: ; 0xbcf49
- checkmoney $1, 0
- if_equal $0, UnknownScript_0xbcf79
- 2jump UnknownScript_0xbcf6e
-
-UnknownScript_0xbcf55: ; 0xbcf55
- readmoney $1, $0
- 3writetext $6d, $41a7
- yesorno
- iftrue MomPhoneSaveMoneyScript
- 2jump MomPhoneWontSaveMoneyScript
-
-UnknownScript_0xbcf63: ; 0xbcf63
- 3writetext $6d, $41ea
- yesorno
- iftrue MomPhoneSaveMoneyScript
- 2jump MomPhoneWontSaveMoneyScript
-
-UnknownScript_0xbcf6e: ; 0xbcf6e
- 3writetext $6d, $420d
- yesorno
- iftrue MomPhoneSaveMoneyScript
- 2jump MomPhoneWontSaveMoneyScript
-
-UnknownScript_0xbcf79: ; 0xbcf79
- readmoney $1, $0
- 3writetext $6d, $4249
- yesorno
- iftrue MomPhoneSaveMoneyScript
- 2jump MomPhoneWontSaveMoneyScript
-
-MomPhoneSaveMoneyScript: ; 0xbcf87
- setbit2 $0008
- 3writetext $6d, $4289
- keeptextopen
- 2jump MomPhoneHangUpScript
-
-MomPhoneWontSaveMoneyScript: ; 0xbcf92
- clearbit2 $0008
- 3writetext BANK(MomPhoneWontSaveMoneyText), MomPhoneWontSaveMoneyText
- keeptextopen
- 2jump MomPhoneHangUpScript
-
-MomPhoneHangUpScript: ; 0xbcf9d
- 3writetext BANK(MomPhoneHangUpText), MomPhoneHangUpText
- end
-
-MomPhoneNoPokemonScript: ; 0xbcfa2
- 3writetext BANK(MomPhoneNoPokemonText), MomPhoneNoPokemonText
- end
-
-MomPhoneNoPokedexScript: ; 0xbcfa7
- 3writetext BANK(MomPhoneNoPokedexText), MomPhoneNoPokedexText
- end
-
-MomPhoneNoGymQuestScript: ; 0xbcfac
- 3writetext BANK(MomPhoneNoGymQuestText), MomPhoneNoGymQuestText
- end
-
-MomPhoneLectureScript: ; 0xbcfb1
- setbit1 $0040
- setbit2 $0009
- specialphonecall $0000
- 3writetext BANK(MomPhoneLectureText), MomPhoneLectureText
- yesorno
- iftrue MomPhoneSaveMoneyScript
- 2jump MomPhoneWontSaveMoneyScript
-
-BillPhoneScript1: ; 0xbcfc5
- checktime $2
- iftrue .daygreet
- checktime $4
- iftrue .nitegreet
- 3writetext BANK(BillPhoneMornGreetingText), BillPhoneMornGreetingText
- keeptextopen
- 2jump .main
-
-.daygreet ; 0xbcfd7
- 3writetext BANK(BillPhoneDayGreetingText), BillPhoneDayGreetingText
- keeptextopen
- 2jump .main
-
-.nitegreet ; 0xbcfdf
- 3writetext BANK(BillPhoneNiteGreetingText), BillPhoneNiteGreetingText
- keeptextopen
- 2jump .main
-
-.main ; 0xbcfe7
- 3writetext BANK(BillPhoneGeneriText), BillPhoneGeneriText
- keeptextopen
- checkcode $10
- RAM2MEM $0
- if_equal $0, .full
- if_greater_than $6, .nearlyfull
- 3writetext BANK(BillPhoneNotFullText), BillPhoneNotFullText
- end
-
-.nearlyfull ; 0xbcffd
- 3writetext BANK(BillPhoneNearlyFullText), BillPhoneNearlyFullText
- end
-
-.full ; 0xbd002
- 3writetext BANK(BillPhoneFullText), BillPhoneFullText
- end
-
-BillPhoneScript2: ; 0xbd007
- 3writetext BANK(BillPhoneNewlyFullText), BillPhoneNewlyFullText
- closetext
- end
-
-ElmPhoneScript1: ; 0xbd00d
- checkcode $14
- if_equal $1, .pokerus
- checkbit1 $0055
- iftrue .discovery
- checkbit1 $002d
- iffalse .next
- checkbit1 $0054
- iftrue .egghatched
-.next
- checkbit1 $002d
- iftrue .eggunhatched
- checkbit1 $0701
- iftrue .assistant
- checkbit1 $001f
- iftrue .checkingegg
- checkbit1 $0043
- iftrue .stolen
- checkbit1 $001e
- iftrue .sawmrpokemon
- 3writetext BANK(ElmPhoneStartText), ElmPhoneStartText
- end
-
-.sawmrpokemon ; 0xbd048
- 3writetext BANK(ElmPhoneSawMrPokemonText), ElmPhoneSawMrPokemonText
- end
-
-.stolen ; 0xbd04d
- 3writetext BANK(ElmPhonePokemonStolenText), ElmPhonePokemonStolenText
- end
-
-.checkingegg ; 0xbd052
- 3writetext BANK(ElmPhoneCheckingEggText), ElmPhoneCheckingEggText
- end
-
-.assistant ; 0xbd057
- 3writetext BANK(ElmPhoneAssistantText), ElmPhoneAssistantText
- end
-
-.eggunhatched ; 0xbd05c
- 3writetext BANK(ElmPhoneEggUnhatchedText), ElmPhoneEggUnhatchedText
- end
-
-.egghatched ; 0xbd061
- 3writetext BANK(ElmPhoneEggHatchedText), ElmPhoneEggHatchedText
- setbit1 $0077
- end
-
-.discovery ; 0xbd069
- random $2
- if_equal $0, .nextdiscovery
- 3writetext BANK(ElmPhoneDiscovery1Text), ElmPhoneDiscovery1Text
- end
-
-.nextdiscovery ; 0xbd074
- 3writetext BANK(ElmPhoneDiscovery2Text), ElmPhoneDiscovery2Text
- end
-
-.pokerus ; 0xbd079
- 3writetext BANK(ElmPhonePokerusText), ElmPhonePokerusText
- specialphonecall $0000
- end
-
-ElmPhoneScript2: ; 0xbd081
- checkcode $14
- if_equal $2, .disaster
- if_equal $3, .assistant
- if_equal $4, .rocket
- if_equal $5, .gift
- if_equal $8, .gift
- 3writetext BANK(ElmPhonePokerusText), ElmPhonePokerusText
- specialphonecall $0000
- end
-
-.disaster ; 0xbd09f
- 3writetext BANK(ElmPhoneDisasterText), ElmPhoneDisasterText
- specialphonecall $0000
- setbit1 $0043
- end
-
-.assistant ; 0xbd0aa
- 3writetext BANK(ElmPhoneEggAssistantText), ElmPhoneEggAssistantText
- specialphonecall $0000
- clearbit1 $0700
- setbit1 $0701
- end
-
-.rocket ; 0xbd0b8
- 3writetext BANK(ElmPhoneRocketText), ElmPhoneRocketText
- specialphonecall $0000
- end
-
-.gift ; 0xbd0c0
- 3writetext BANK(ElmPhoneGiftText), ElmPhoneGiftText
- specialphonecall $0000
- end
-
-.unused ; 0xbd0c8
- 3writetext BANK(ElmPhoneUnusedText), ElmPhoneUnusedText
- specialphonecall $0000
- end
-
INCBIN "baserom.gbc", $bd0d0, $be699-$bd0d0
@@ -76663,11 +70926,11 @@
ld [$d16e], a
ld a, $1
ld hl, CurPartySpecies
- call Function307b
+ call GetFarWRAMByte
ld [$d16b], a
ld a, $1
ld hl, UnownLetter
- call Function307b
+ call GetFarWRAMByte
ld [$d16c], a
call Functiond065c
ld [$d16d], a
@@ -78644,7 +72907,7 @@
Options_Cancel: ; e4520
ld a, [hJoyPressed]
- and BUTTON_A
+ and A_BUTTON
jr nz, .asm_e4528
and a
ret
@@ -79617,178 +73880,10 @@
INCBIN "baserom.gbc", $fb656, $fb6ed - $fb656
-Functionfb6ed: ; fb6ed
- ld hl, $780f
- call PrintText
- call Function1dcf
- jp c, .asm_fb77e
- ld hl, $7814
- call PrintText
- callba Function50000
- jr c, .asm_fb77e
- ld a, [CurPartySpecies]
- cp $fd
- jr z, .asm_fb783
- call GetCurNick
- call Functionfb78a
- jr c, .asm_fb779
- ld hl, $7819
- call PrintText
- call Function1dcf
- jr c, .asm_fb77e
- ld hl, $781e
- call PrintText
- xor a
- ld [MonType], a
- ld a, [CurPartySpecies]
- ld [$d265], a
- ld [CurSpecies], a
- call GetBaseData
- ld b, $0
- ld de, StringBuffer2
- callba Function116b7
- call Functionfb7be
- ld hl, $7837
- jr c, .asm_fb76c
- call Functionfb7d3
- ld hl, $7837
- jr c, .asm_fb76c
- ld hl, PartyMon1Nickname
- ld bc, $000b
- ld a, [CurPartyMon]
- call AddNTimes
- ld e, l
- ld d, h
- ld hl, StringBuffer2
- ld bc, $000b
- call CopyBytes
- ld hl, $7823
-.asm_fb76c
- push hl
- call GetCurNick
- ld hl, $783c
- call PrintText
- pop hl
- jr .asm_fb786
+INCLUDE "event/name_rater.asm"
-.asm_fb779
- ld hl, $782d
- jr .asm_fb786
-.asm_fb77e
- ld hl, $7828
- jr .asm_fb786
-
-.asm_fb783
- ld hl, $7832
-
-.asm_fb786
- call PrintText
- ret
-; fb78a
-
-Functionfb78a: ; fb78a
- ld hl, PartyMon1OT
- ld bc, $000b
- ld a, [CurPartyMon]
- call AddNTimes
- ld de, PlayerName
- ld c, $b
- call .asm_fb7b1
- jr c, .asm_fb7bc
- ld hl, PartyMon1ID
- ld bc, $0030
- ld a, [CurPartyMon]
- call AddNTimes
- ld de, PlayerID
- ld c, $2
-.asm_fb7b1
- ld a, [de]
- cp [hl]
- jr nz, .asm_fb7bc
- inc hl
- inc de
- dec c
- jr nz, .asm_fb7b1
- and a
- ret
-
-.asm_fb7bc
- scf
- ret
-; fb7be
-
-Functionfb7be: ; fb7be
- ld hl, StringBuffer2
- ld c, $a
-.asm_fb7c3
- ld a, [hli]
- cp $50
- jr z, .asm_fb7cf
- cp $7f
- jr nz, .asm_fb7d1
- dec c
- jr nz, .asm_fb7c3
-
-.asm_fb7cf
- scf
- ret
-
-.asm_fb7d1
- and a
- ret
-; fb7d3
-
-Functionfb7d3: ; fb7d3
- ld hl, PartyMon1Nickname
- ld bc, $000b
- ld a, [CurPartyMon]
- call AddNTimes
- push hl
- call Functionfb802
- ld b, c
- ld hl, StringBuffer2
- call Functionfb802
- pop hl
- ld a, c
- cp b
- jr nz, .asm_fb7fe
- ld de, StringBuffer2
-.asm_fb7f2
- ld a, [de]
- cp $50
- jr z, .asm_fb800
- cp [hl]
- jr nz, .asm_fb7fe
- inc hl
- inc de
- jr .asm_fb7f2
-
-.asm_fb7fe
- and a
- ret
-
-.asm_fb800
- scf
- ret
-; fb802
-
-Functionfb802: ; fb802
- ld c, $0
-.asm_fb804
- ld a, [hli]
- cp $50
- ret z
- inc c
- ld a, c
- cp $a
- jr nz, .asm_fb804
- ret
-; fb80f
-
-INCBIN "baserom.gbc", $fb80f, $fb841 - $fb80f
-
Functionfb841: ; fb841
ld a, [ScriptVar]
call Function37f3
@@ -81805,7 +75900,7 @@
ld a, $1
ld [$d10c], a
ld hl, PCItems
- call Function2f66
+ call ReceiveItem
ret
; fd0eb
@@ -81926,7 +76021,7 @@
ld [$ffe9], a
xor a
ld [$ff9e], a
- call Function2ff7
+ call NormalSpeed
xor a
ld [rIF], a
ld a, [BGMapBuffer]
@@ -82368,7 +76463,7 @@
ld de, $d000
ld bc, $0054
ld a, $3
- call Function306b
+ call FarCopyWRAM
ret
; 1003ab
@@ -82380,7 +76475,7 @@
ld de, $d080
ld bc, $0054
ld a, $3
- call Function306b
+ call FarCopyWRAM
ret
; 1003c9
@@ -82389,7 +76484,7 @@
ld de, $ccb4
ld bc, $0054
ld a, $3
- call Function306b
+ call FarCopyWRAM
ret
; 1003d8
@@ -83033,7 +77128,7 @@
Function1009a5: ; 1009a5
ld bc, $0168
ld a, $3
- call Function306b
+ call FarCopyWRAM
ret
; 1009ae
@@ -84086,7 +78181,7 @@
ld de, EnemyMoveAnimation
ld bc, $0026
ld a, $5
- call Function306b
+ call FarCopyWRAM
ld de, EnemyMoveEffect
ret
; 10219f
@@ -87378,7 +81473,7 @@
di
ld a, [rIE]
ld [$cd32], a
- call Function2fef
+ call DoubleSpeed
xor a
ld [rIF], a
ld [$c300], a
@@ -87427,7 +81522,7 @@
ld [$ffc9], a
ld [$ffe9], a
ld [$ff9e], a
- call Function2ff7
+ call NormalSpeed
xor a
ld [rIF], a
ld a, [$cd32]
@@ -89008,7 +83103,7 @@
ld hl, rSVBK
ld e, $1
ld [hl], e
- call CheckCaughtMon
+ call CheckSeenMon
ld hl, rSVBK
ld e, $5
ld [hl], e
@@ -92985,7 +87080,7 @@
DudeAutoInput_A: ; 1de29f
db NO_INPUT, $50
- db BUTTON_A, $00
+ db A_BUTTON, $00
db NO_INPUT, $ff ; end
; 1de2a5
@@ -92993,7 +87088,7 @@
db NO_INPUT, $08
db D_RIGHT, $00
db NO_INPUT, $08
- db BUTTON_A, $00
+ db A_BUTTON, $00
db NO_INPUT, $ff ; end
; 1de2af
@@ -93007,7 +87102,7 @@
db NO_INPUT, $fe
db NO_INPUT, $fe
db NO_INPUT, $fe
- db BUTTON_A, $00
+ db A_BUTTON, $00
db NO_INPUT, $ff ; end
; 1de2c5
--- /dev/null
+++ b/predef/cgb.asm
@@ -1,0 +1,922 @@
+; Replaces the functionality of sgb.asm to work with CGB hardware.
+
+CheckCGB: ; 8d55
+ ld a, [hCGB]
+ and a
+ ret
+; 8d59
+
+Function8d59: ; 8d59
+ ld a, b
+ cp $ff
+ jr nz, .asm_8d61
+ ld a, [SGBPredef]
+
+.asm_8d61
+ cp $fc
+ jp z, Function96f3
+ call Function9673
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, Table8d7a
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, Function8d79
+ push de
+ jp [hl]
+; 8d79
+
+Function8d79: ; 8d79
+ ret
+; 8d7a
+
+Table8d7a: ; 8d7a
+ dw Function8db8
+ dw Function8ddb
+ dw Function8eb9
+ dw Function8edb
+ dw Function8f70
+ dw Function906e
+ dw Function90f8
+ dw Function9122
+ dw Function91ad
+ dw Function91c8
+ dw Function91d1
+ dw Function91e4
+ dw Function9228
+ dw Function9251
+ dw Function9373
+ dw Function93a6
+ dw Function93ba
+ dw Function9195
+ dw Function9499
+ dw Function94d0
+ dw Function93d3
+ dw Function9289
+ dw Function903e
+ dw Function8fca
+ dw Function925e
+ dw Function94fa
+ dw Function9529
+ dw Function9555
+ dw Function9578
+ dw Function9591
+ dw Function9542
+; 8db8
+
+Function8db8: ; 8db8
+ ld hl, $5c67
+ ld de, $d000
+ ld c, $4
+ call $5615
+ ld hl, $5c67
+ ld de, $d020
+ ld c, $4
+ call $5615
+ ld hl, $5c67
+ ld de, MartPointer
+ ld c, $2
+ call $5615
+ jr Function8e23
+
+Function8ddb: ; 8ddb
+ ld de, $d000
+ call Function9729
+ push hl
+ call Function9643
+ call Function973a
+ push hl
+ call Function9643
+ ld a, [EnemyHPPal]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld bc, $68be
+ add hl, bc
+ call Function9643
+ ld a, [PlayerHPPal]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld bc, $68be
+ add hl, bc
+ call Function9643
+ ld hl, $68ca
+ call Function9643
+ ld de, MartPointer
+ pop hl
+ call Function9643
+ pop hl
+ call Function9643
+ ld a, $1
+ ld [SGBPredef], a
+ call Function96a4
+
+Function8e23: ; 8e23
+ call Function8e85
+ ld hl, AttrMap
+ ld bc, $0168
+ ld a, $2
+ call ByteFill
+ ld hl, $ce29
+ ld bc, $080a
+ ld a, $0
+ call Function9663
+ ld hl, $cde3
+ ld bc, $070a
+ ld a, $1
+ call Function9663
+ ld hl, AttrMap
+ ld bc, $040a
+ ld a, $2
+ call Function9663
+ ld hl, $ce6f
+ ld bc, $050a
+ ld a, $3
+ call Function9663
+ ld hl, $cebf
+ ld bc, $0109
+ ld a, $4
+ call Function9663
+ ld hl, $cec9
+ ld bc, $0078
+ ld a, $7
+ call ByteFill
+ ld hl, $579c
+ ld de, $d050
+ ld bc, $0030
+ ld a, $5
+ call FarCopyWRAM
+ call Function96b3
+ ret
+; 8e85
+
+
+Function8e85: ; 8e85
+ ld a, $40
+ ld hl, $4dc0
+ rst FarCall
+ ld hl, $7311
+ jr nc, .asm_8e93
+ ld hl, $7309
+
+.asm_8e93
+ ld de, $d038
+ ld bc, $0008
+ ld a, $5
+ call FarCopyWRAM
+ ret
+; 8e9f
+
+Function8e9f: ; 8e9f
+ callba Function100dc0
+ ld hl, $7311
+ jr nc, .asm_8ead
+ ld hl, $7309
+
+.asm_8ead
+ ld de, $d000
+ ld bc, $0008
+ ld a, $5
+ call FarCopyWRAM
+ ret
+; 8eb9
+
+Function8eb9: ; 8eb9
+ ld a, [PlayerGender]
+ bit 0, a
+ jr z, .asm_8ec5
+ ld hl, $7759
+ jr .asm_8ec8
+
+.asm_8ec5
+ ld hl, $7729
+
+.asm_8ec8
+ ld de, $d000
+ ld bc, $0030
+ ld a, $5
+ call FarCopyWRAM
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 8edb
+
+Function8edb: ; 8edb
+ ld de, $d000
+ ld a, [$cda1]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld bc, $68be
+ add hl, bc
+ call Function9643
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function974b
+ call Function9643
+ ld hl, $68ca
+ call Function9643
+ ld hl, $4f52
+ ld de, $d018
+ ld bc, $0018
+ ld a, $5
+ call FarCopyWRAM
+ call Function9699
+ ld hl, AttrMap
+ ld bc, $0814
+ ld a, $1
+ call Function9663
+ ld hl, $cf23
+ ld bc, $000a
+ ld a, $2
+ call ByteFill
+ ld hl, $ce4a
+ ld bc, $0202
+ ld a, $3
+ call Function9663
+ ld hl, $ce4c
+ ld bc, $0202
+ ld a, $4
+ call Function9663
+ ld hl, $ce4e
+ ld bc, $0202
+ ld a, $5
+ call Function9663
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 8f52
+
+INCBIN "baserom.gbc", $8f52, $8f70 - $8f52
+
+Function8f70: ; 8f70
+ ld de, Unkn1Pals
+ ld a, $1d
+ call Function9625
+ call Function9630
+ ld a, [CurPartySpecies]
+ cp $ff
+ jr nz, .asm_8f8a
+ ld hl, $4fba
+ call Function9630
+ jr .asm_8f90
+
+.asm_8f8a
+ call Function9775
+ call Function9643
+
+.asm_8f90
+ call Function9699
+ ld hl, $cdee
+ ld bc, $0707
+ ld a, $1
+ call Function9663
+ call Function971a
+ ld hl, $4fc2
+ ld de, $d078
+ ld bc, $0008
+ ld a, $5
+ call FarCopyWRAM
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 8fba
+
+INCBIN "baserom.gbc", $8fba, $8fca - $8fba
+
+Function8fca: ; 8fca
+ ld de, Unkn1Pals
+ ld a, $1d
+ call Function9625
+ call Function9630
+ ld a, [CurPartySpecies]
+ cp $ff
+ jr nz, .asm_8fe4
+ ld hl, $5036
+ call Function9630
+ jr .asm_8fed
+
+.asm_8fe4
+ ld bc, TempMonDVs
+ call Function974b
+ call Function9643
+
+.asm_8fed
+ call Function9699
+ ld hl, $ce2a
+ ld bc, $0707
+ ld a, $1
+ call Function9663
+ call Function971a
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 9009
+
+INCBIN "baserom.gbc", $9009, $903e - $9009
+
+Function903e: ; 903e
+ ld de, Unkn1Pals
+ ld a, $1d
+ call Function9625
+ call Function9630
+ ld a, [CurPartySpecies]
+ call Function9775
+ call Function9643
+ call Function9699
+ ld hl, $ce44
+ ld bc, $0707
+ ld a, $1
+ call Function9663
+ call Function971a
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 906e
+
+Function906e: ; 906e
+ ld hl, $77a9
+ ld de, Unkn1Pals
+ ld bc, $0080
+ ld a, $5
+ call FarCopyWRAM
+ call Function9699
+ ld hl, $ce01
+ ld bc, $0a03
+ ld a, $2
+ call Function9663
+ ld hl, $ce12
+ ld bc, $0a03
+ ld a, $2
+ call Function9663
+ ld hl, $ce29
+ ld bc, $0603
+ ld a, $3
+ call Function9663
+ ld hl, $ce3a
+ ld bc, $0603
+ ld a, $3
+ call Function9663
+ ld hl, $ce51
+ ld bc, $0203
+ ld a, $4
+ call Function9663
+ ld hl, $ce62
+ ld bc, $0203
+ ld a, $4
+ call Function9663
+ ld hl, $ce05
+ ld bc, $020c
+ ld a, $1
+ call Function9663
+ ld hl, $ce04
+ ld bc, $0a01
+ ld a, $1
+ call Function9663
+ ld hl, $ce11
+ ld bc, $0a01
+ ld a, $1
+ call Function9663
+ ld hl, $cec9
+ ld bc, $0078
+ ld a, $7
+ call ByteFill
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 90f8
+
+Function90f8: ; 90f8
+ ld hl, $5ca7
+ call Function9610
+ call Function9699
+ ld de, Unkn2Pals
+ ld a, $3c
+ call Function9625
+ call Function9630
+ ld hl, $ce51
+ ld bc, $0c14
+ ld a, $1
+ call Function9663
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 9122
+
+Function9122: ; 9122
+ ld b, $0
+ ld hl, $512d
+ add hl, bc
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jp [hl]
+; 912d
+
+INCBIN "baserom.gbc", $912d, $9195 - $912d
+
+Function9195: ; 9195
+ ld hl, $7789
+ ld de, Unkn1Pals
+ ld bc, $0028
+ ld a, $5
+ call FarCopyWRAM
+ call Function96a4
+ call Function9699
+ call Function96b3
+ ret
+; 91ad
+
+Function91ad: ; 91ad
+ ld hl, $7641
+ ld de, Unkn1Pals
+ ld bc, $0080
+ ld a, $5
+ call FarCopyWRAM
+ ld hl, $5cb7
+ call Function9610
+ call Function9699
+ call Function96b3
+ ret
+; 91c8
+
+Function91c8: ; 91c8
+ call Functionb1de
+ ld a, $9
+ ld [SGBPredef], a
+ ret
+; 91d1
+
+Function91d1: ; 91d1
+ ld hl, $5c57
+ call Function9610
+ call Function8e9f
+ call Function8e85
+ call Function971a
+ call Function96b3
+ ret
+; 91e4
+
+Function91e4: ; 91e4
+ ld de, Unkn1Pals
+ ld a, c
+ and a
+ jr z, .asm_91f5
+ ld a, $1a
+ call Function9625
+ call Function9630
+ jr .asm_921a
+
+.asm_91f5
+ ld hl, PartyMon1DVs
+ ld bc, $0030
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld c, l
+ ld b, h
+ ld a, [PlayerHPPal]
+ call Function974b
+ call Function9643
+ ld hl, $579c
+ ld de, $d050
+ ld bc, $0030
+ ld a, $5
+ call FarCopyWRAM
+
+.asm_921a
+ call Function9699
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 9228
+
+Function9228: ; 9228
+ ld hl, $76f1
+ ld de, Unkn1Pals
+ ld bc, $0028
+ ld a, $5
+ call FarCopyWRAM
+ ld hl, $7719
+ ld de, Unkn2Pals
+ ld bc, $0010
+ ld a, $5
+ call FarCopyWRAM
+ ld a, $8
+ ld [SGBPredef], a
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 9251
+
+Function9251: ; 9251
+ ld hl, $5cb7
+ call Function9610
+ call Function9699
+ call Function96b3
+ ret
+; 925e
+
+Function925e: ; 925e
+ ld hl, $5bc7
+ call Function9610
+ ld de, Unkn2Pals
+ ld a, $4c
+ call Function9625
+ call Function9630
+ ld a, [rSVBK]
+ push af
+ ld a, $5
+ ld [rSVBK], a
+ ld hl, Unkn2Pals
+ ld a, $1f
+ ld [hli], a
+ ld a, $0
+ ld [hl], a
+ pop af
+ ld [rSVBK], a
+ call Function9699
+ call Function96b3
+ ret
+; 9289
+
+Function9289: ; 9289
+ ld de, Unkn1Pals
+ xor a
+ call Function976b
+ call Function9643
+ ld a, $1
+ call Function976b
+ call Function9643
+ ld a, $3
+ call Function976b
+ call Function9643
+ ld a, $2
+ call Function976b
+ call Function9643
+ ld a, $4
+ call Function976b
+ call Function9643
+ ld a, $7
+ call Function976b
+ call Function9643
+ ld a, $6
+ call Function976b
+ call Function9643
+ ld a, $5
+ call Function976b
+ call Function9643
+ ld a, $24
+ call Function9625
+ call Function9630
+ ld hl, AttrMap
+ ld bc, $0168
+ ld a, [PlayerGender]
+ and a
+ ld a, $1
+ jr z, .asm_92e3
+ ld a, $0
+
+.asm_92e3
+ call ByteFill
+ ld hl, $cdfb
+ ld bc, $0705
+ ld a, [PlayerGender]
+ and a
+ ld a, $0
+ jr z, .asm_92f6
+ ld a, $1
+
+.asm_92f6
+ call Function9663
+ ld hl, $cdff
+ ld [hl], $1
+ ld hl, $ceb7
+ ld bc, $0204
+ ld a, $1
+ call Function9663
+ ld hl, $cebb
+ ld bc, $0204
+ ld a, $2
+ call Function9663
+ ld hl, $cebf
+ ld bc, $0204
+ ld a, $3
+ call Function9663
+ ld hl, $cec3
+ ld bc, $0204
+ ld a, $4
+ call Function9663
+ ld hl, $cef3
+ ld bc, $0204
+ ld a, $5
+ call Function9663
+ ld hl, $cef7
+ ld bc, $0204
+ ld a, $6
+ call Function9663
+ ld hl, $cefb
+ ld bc, $0204
+ ld a, $7
+ call Function9663
+ ld a, [PlayerGender]
+ and a
+ push af
+ jr z, .asm_935d
+ ld hl, $ceff
+ ld bc, $0204
+ ld a, $1
+ call Function9663
+
+.asm_935d
+ pop af
+ ld c, $0
+ jr nz, .asm_9363
+ inc c
+
+.asm_9363
+ ld a, c
+ ld hl, $cdff
+ ld [hl], a
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 9373
+
+Function9373: ; 9373
+ ld de, Unkn1Pals
+ ld a, $10
+ call Function9625
+ call Function9630
+ ld a, [PlayerHPPal]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld bc, $68be
+ add hl, bc
+ call Function9643
+ call Function9699
+ ld hl, $cdf8
+ ld bc, $0209
+ ld a, $1
+ call Function9663
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 93a6
+
+Function93a6: ; 93a6
+ ld hl, $5c47
+ call Function9610
+ call Function9699
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 93ba
+
+Function93ba: ; 93ba
+ ld de, Unkn1Pals
+ ld a, $1d
+ call Function9625
+ call Function9630
+ call Function9699
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 93d3
+
+Function93d3: ; 93d3
+ ld a, [BattleType]
+ cp $3
+ jr z, .asm_93e6
+ ld a, [PlayerGender]
+ bit 0, a
+ jr z, .asm_93e6
+ ld hl, $5469
+ jr .asm_93e9
+
+.asm_93e6
+ ld hl, $5439
+
+.asm_93e9
+ ld de, Unkn1Pals
+ ld bc, $0040
+ ld a, $5
+ call FarCopyWRAM
+ call Function9699
+ ld hl, AttrMap
+ ld bc, $010a
+ ld a, $1
+ call Function9663
+ ld hl, $cde3
+ ld bc, $010a
+ ld a, $2
+ call Function9663
+ ld hl, $ce08
+ ld bc, $0901
+ ld a, $3
+ call Function9663
+ ld hl, $ce65
+ ld bc, $0305
+ ld a, $4
+ call Function9663
+ ld hl, $ce15
+ ld bc, $0305
+ ld a, $5
+ call Function9663
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 9439
+
+INCBIN "baserom.gbc", $9439, $9499 - $9439
+
+Function9499: ; 9499
+ call Function91c8
+ ld de, $0014
+ ld hl, AttrMap
+ ld a, [$cf82]
+.asm_94a5
+ and a
+ jr z, .asm_94ac
+ dec a
+ add hl, de
+ jr .asm_94a5
+
+.asm_94ac
+ ld a, [$cf83]
+ ld e, a
+ ld d, $0
+ add hl, de
+ ld a, [$cf82]
+ ld b, a
+ ld a, [$cf84]
+ inc a
+ sub b
+ ld b, a
+ ld a, [$cf83]
+ ld c, a
+ ld a, [$cf85]
+ sub c
+ inc a
+ ld c, a
+ ld a, $0
+ call Function9663
+ call Function96b3
+ ret
+; 94d0
+
+Function94d0: ; 94d0
+ ld hl, $5ba7
+ call Function9610
+ call Function9699
+ ld hl, $ce29
+ ld bc, $0a14
+ ld a, $2
+ call Function9663
+ ld hl, $ce51
+ ld bc, $0614
+ ld a, $1
+ call Function9663
+ call Function96b3
+ call Function96a4
+ ld a, $1
+ ld [hCGBPalUpdate], a
+ ret
+; 94fa
+
+Function94fa: ; 94fa
+ ld de, Unkn1Pals
+ ld a, $4e
+ call Function9625
+ call Function9630
+ ld hl, $5521
+ ld de, Unkn2Pals
+ call Function9630
+ ld hl, $5521
+ ld de, $d048
+ call Function9630
+ call Function9699
+ call Function96b3
+ call Function96a4
+ ret
+; 9521
+
+INCBIN "baserom.gbc", $9521, $9529 - $9521
+
+Function9529: ; 9529
+ ld de, Unkn1Pals
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function974b
+ call Function9643
+ call Function9699
+ call Function96b3
+ call Function96a4
+ ret
+; 9542
+
+Function9542: ; 9542
+ ld de, Unkn1Pals
+ ld a, [CurPartySpecies]
+ call Function9775
+ call Function9643
+ call Function9699
+ call Function96b3
+ ret
+; 9555
+
+Function9555: ; 9555
+ ld hl, $5cc7
+ call Function9610
+ ld hl, $7681
+ ld de, Unkn2Pals
+ ld bc, $0008
+ ld a, $5
+ call FarCopyWRAM
+ ld de, $d078
+ ld a, $1c
+ call Function9625
+ call Function9630
+ call Function9699
+ ret
+; 9578
+
+Function9578: ; 9578
+ ld de, Unkn1Pals
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function9764
+ call Function9643
+ call Function9699
+ call Function96b3
+ call Function96a4
+ ret
+; 9591
+
+Function9591: ; 9591
+ ld hl, $55e0
+ ld de, Unkn1Pals
+ ld bc, $0010
+ ld a, $5
+ call FarCopyWRAM
+ call Function96a4
+ call Function9699
+ ld hl, $ce68
+ ld bc, $080e
+ ld a, $1
+ call Function9663
+ ld hl, $ce3e
+ ld bc, $0112
+ ld a, $1
+ call Function9663
+ ld hl, $cf1a
+ ld bc, $0112
+ ld a, $1
+ call Function9663
+ ld hl, AttrMap
+ ld bc, $1102
+ ld a, $1
+ call Function9663
+ ld hl, $ce4f
+ ld bc, $0c01
+ ld a, $1
+ call Function9663
+ call Function96b3
+ ret
+; 95e0
+
--- /dev/null
+++ b/predef/sgb.asm
@@ -1,0 +1,591 @@
+Function864c: ; 864c
+; LoadSGBLayout
+ call CheckCGB
+ jp nz, Function8d59
+
+ ld a, b
+ cp $ff
+ jr nz, .asm_865a
+ ld a, [SGBPredef]
+
+.asm_865a
+ cp $fc
+ jp z, Function8ade
+ ld l, a
+ ld h, 0
+ add hl, hl
+ ld de, Table866f
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, Function8a60
+ push de
+ jp [hl]
+; 866f
+
+Table866f: ; 866f
+ dw Function86ad
+ dw Function86b4
+ dw Function875c
+ dw Function8763
+ dw Function87b2
+ dw Function8852
+ dw Function8859
+ dw Function8867
+ dw Function8860
+ dw Function88b1
+ dw Function87ab
+ dw Function88cd
+ dw Function8884
+ dw Function891a
+ dw Function873c
+ dw Function8897
+ dw Function882a
+ dw Function889e
+ dw Function8928
+ dw Function8890
+ dw Function884b
+ dw Function891a
+ dw Function8823
+ dw Function87e9
+ dw Function8921
+ dw Function89a6
+ dw Function89ad
+ dw Function89d9
+ dw Function89e0
+ dw Function8860
+ dw Function8969
+; 86ad
+
+Function86ad: ; 86ad
+ ld hl, $5c66
+ ld de, $5aa6
+ ret
+; 86b4
+
+Function86b4: ; 86b4
+ ld hl, $5aa6
+ call Function9809
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld a, [PlayerHPPal]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld de, $68be
+ add hl, de
+ ld a, [hli]
+ ld [$cdac], a
+ ld a, [hli]
+ ld [$cdad], a
+ ld a, [hli]
+ ld [$cdae], a
+ ld a, [hl]
+ ld [$cdaf], a
+ ld a, [EnemyHPPal]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld de, $68be
+ add hl, de
+ ld a, [hli]
+ ld [$cdb2], a
+ ld a, [hli]
+ ld [$cdb3], a
+ ld a, [hli]
+ ld [$cdb4], a
+ ld a, [hl]
+ ld [$cdb5], a
+ ld hl, $5cf6
+ ld de, $cdb9
+ ld bc, $0010
+ call CopyBytes
+ call Function9729
+ ld a, [hli]
+ ld [$cdbc], a
+ ld a, [hli]
+ ld [$cdbd], a
+ ld a, [hli]
+ ld [$cdbe], a
+ ld a, [hl]
+ ld [$cdbf], a
+ call Function973a
+ ld a, [hli]
+ ld [$cdc2], a
+ ld a, [hli]
+ ld [$cdc3], a
+ ld a, [hli]
+ ld [$cdc4], a
+ ld a, [hl]
+ ld [$cdc5], a
+ ld hl, $cda9
+ ld de, $cdb9
+ ld a, $1
+ ld [SGBPredef], a
+ ret
+; 873c
+
+Function873c: ; 873c
+ ld hl, $5bd6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld hl, $cdaa
+ ld [hl], $10
+ inc hl
+ inc hl
+ ld a, [PlayerHPPal]
+ add $2f
+ ld [hl], a
+ ld hl, $cda9
+ ld de, $5ad6
+ ret
+; 875c
+
+Function875c: ; 875c
+ ld hl, $5c76
+ ld de, $5a86
+ ret
+; 8763
+
+Function8763: ; 8763
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld a, [$cda1]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ ld de, $68be
+ add hl, de
+ ld a, [hli]
+ ld [$cdac], a
+ ld a, [hli]
+ ld [$cdad], a
+ ld a, [hli]
+ ld [$cdae], a
+ ld a, [hl]
+ ld [$cdaf], a
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function974b
+ ld a, [hli]
+ ld [$cdb2], a
+ ld a, [hli]
+ ld [$cdb3], a
+ ld a, [hli]
+ ld [$cdb4], a
+ ld a, [hl]
+ ld [$cdb5], a
+ ld hl, $cda9
+ ld de, $5ac6
+ ret
+; 87ab
+
+Function87ab: ; 87ab
+ ld hl, $5c56
+ ld de, $cdaa
+ ret
+; 87b2
+
+Function87b2: ; 87b2
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld hl, $cdac
+ ld [hl], $9f
+ inc hl
+ ld [hl], $2a
+ inc hl
+ ld [hl], $5a
+ inc hl
+ ld [hl], $19
+ ld a, [CurPartySpecies]
+ call Function9775
+ ld a, [hli]
+ ld [$cdb2], a
+ ld a, [hli]
+ ld [$cdb3], a
+ ld a, [hli]
+ ld [$cdb4], a
+ ld a, [hl]
+ ld [$cdb5], a
+ ld hl, $cda9
+ ld de, $5ae6
+ ret
+; 87e9
+
+Function87e9: ; 87e9
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld hl, $cdac
+ ld [hl], $9f
+ inc hl
+ ld [hl], $2a
+ inc hl
+ ld [hl], $5a
+ inc hl
+ ld [hl], $19
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function974b
+ ld a, [hli]
+ ld [$cdb2], a
+ ld a, [hli]
+ ld [$cdb3], a
+ ld a, [hli]
+ ld [$cdb4], a
+ ld a, [hl]
+ ld [$cdb5], a
+ ld hl, $cda9
+ ld de, $5ae6
+ ret
+; 8823
+
+Function8823: ; 8823
+ call Function87b2
+ ld de, $5af6
+ ret
+; 882a
+
+Function882a: ; 882a
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld hl, $cdac
+ ld [hl], $9f
+ inc hl
+ ld [hl], $2a
+ inc hl
+ ld [hl], $5a
+ inc hl
+ ld [hl], $19
+ ld hl, $cda9
+ ld de, $5a86
+ ret
+; 884b
+
+Function884b: ; 884b
+ ld hl, $5c36
+ ld de, $5a86
+ ret
+; 8852
+
+Function8852: ; 8852
+ ld hl, $5c96
+ ld de, $5b06
+ ret
+; 8859
+
+Function8859: ; 8859
+ ld hl, $5ca6
+ ld de, $5b76
+ ret
+; 8860
+
+Function8860: ; 8860
+ ld hl, $5cb6
+ ld de, $5a86
+ ret
+; 8867
+
+Function8867: ; 8867
+ ld b, $0
+ ld hl, $4878
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ add hl, bc
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ret
+; 8878
+
+INCBIN "baserom.gbc", $8878, $8884 - $8878
+
+Function8884: ; 8884
+ ld hl, $5b96
+ ld de, $5b56
+ ld a, $8
+ ld [SGBPredef], a
+ ret
+; 8890
+
+Function8890: ; 8890
+ ld hl, $5ba6
+ ld de, $5b86
+ ret
+; 8897
+
+Function8897: ; 8897
+ ld hl, $5c46
+ ld de, $5a86
+ ret
+; 889e
+
+Function889e: ; 889e
+ ld hl, $5a86
+ ld de, PlayerLightScreenCount
+ ld bc, $0010
+ call CopyBytes
+ ld hl, $5bb6
+ ld de, $5a86
+ ret
+; 88b1
+
+Function88b1: ; 88b1
+ ld hl, $5bd6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ call Function8a0c
+ ld hl, $cdaa
+ ld [hld], a
+ ld de, $5a86
+ ld a, $9
+ ld [SGBPredef], a
+ ret
+; 88cd
+
+Function88cd: ; 88cd
+ push bc
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ pop bc
+ ld a, c
+ and a
+ jr z, .asm_88ef
+ ld hl, $cdac
+ ld [hl], $e7
+ inc hl
+ ld [hl], $1c
+ inc hl
+ ld [hl], $62
+ inc hl
+ ld [hl], $c
+ jr .asm_8913
+
+.asm_88ef
+ ld hl, PartyMon1DVs
+ ld bc, $0030
+ ld a, [CurPartyMon]
+ call AddNTimes
+ ld c, l
+ ld b, h
+ ld a, [PlayerHPPal]
+ call Function974b
+ ld a, [hli]
+ ld [$cdac], a
+ ld a, [hli]
+ ld [$cdad], a
+ ld a, [hli]
+ ld [$cdae], a
+ ld a, [hl]
+ ld [$cdaf], a
+
+.asm_8913
+ ld hl, $cda9
+ ld de, $5a86
+ ret
+; 891a
+
+Function891a: ; 891a
+ ld hl, $5cb6
+ ld de, $5a86
+ ret
+; 8921
+
+Function8921: ; 8921
+ ld hl, $5bc6
+ ld de, $5a86
+ ret
+; 8928
+
+Function8928: ; 8928
+ ld hl, $5bd6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld hl, $5a86
+ ld de, $cdb9
+ ld bc, $0010
+ call CopyBytes
+ call Function8a0c
+ ld hl, $cdaa
+ ld [hl], a
+ ld hl, $cdac
+ ld [hl], $2e
+ ld hl, $cdbc
+ ld a, $5
+ ld [hli], a
+ ld a, [$cf83]
+ ld [hli], a
+ ld a, [$cf82]
+ ld [hli], a
+ ld a, [$cf85]
+ ld [hli], a
+ ld a, [$cf84]
+ ld [hl], a
+ ld hl, $cda9
+ ld de, $cdb9
+ ret
+; 8969
+
+Function8969: ; 8969
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld a, [CurPartySpecies]
+ ld l, a
+ ld h, $0
+ add hl, hl
+ add hl, hl
+ add hl, hl
+ ld de, $68ce
+ add hl, de
+ ld a, [$cf65]
+ and $3
+ sla a
+ sla a
+ ld c, a
+ ld b, $0
+ add hl, bc
+ ld a, [hli]
+ ld [$cdac], a
+ ld a, [hli]
+ ld [$cdad], a
+ ld a, [hli]
+ ld [$cdae], a
+ ld a, [hl]
+ ld [$cdaf], a
+ ld hl, $cda9
+ ld de, $5a86
+ ret
+; 89a6
+
+Function89a6: ; 89a6
+ ld hl, $5cd6
+ ld de, $5a86
+ ret
+; 89ad
+
+Function89ad: ; 89ad
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function974b
+ ld a, [hli]
+ ld [$cdac], a
+ ld a, [hli]
+ ld [$cdad], a
+ ld a, [hli]
+ ld [$cdae], a
+ ld a, [hl]
+ ld [$cdaf], a
+ ld hl, $cda9
+ ld de, $5a86
+ ret
+; 89d9
+
+Function89d9: ; 89d9
+ ld hl, $5cc6
+ ld de, $5a86
+ ret
+; 89e0
+
+Function89e0: ; 89e0
+ ld hl, $5ce6
+ ld de, $cda9
+ ld bc, $0010
+ call CopyBytes
+ ld a, [CurPartySpecies]
+ ld bc, TempMonDVs
+ call Function9764
+ ld a, [hli]
+ ld [$cdac], a
+ ld a, [hli]
+ ld [$cdad], a
+ ld a, [hli]
+ ld [$cdae], a
+ ld a, [hl]
+ ld [$cdaf], a
+ ld hl, $cda9
+ ld de, $5a86
+ ret
+; 8a0c
+
+Function8a0c: ; 8a0c
+ ld a, [TimeOfDayPal]
+ cp $2
+ jr c, .asm_8a16
+ ld a, $19
+ ret
+
+.asm_8a16
+ ld a, [$d19a]
+ cp $2
+ jr z, .asm_8a39
+ cp $4
+ jr z, .asm_8a3c
+ cp $7
+ jr z, .asm_8a3c
+ cp $5
+ jr z, .asm_8a3f
+ cp $6
+ jr z, .asm_8a42
+ ld a, [MapGroup]
+ ld e, a
+ ld d, $0
+ ld hl, $4a45
+ add hl, de
+ ld a, [hl]
+ ret
+
+.asm_8a39
+ ld a, $0
+ ret
+
+.asm_8a3c
+ ld a, $18
+ ret
+
+.asm_8a3f
+ ld a, $6
+ ret
+
+.asm_8a42
+ ld a, $3
+ ret
+; 8a45
+
+INCBIN "baserom.gbc", $8a45, $8a60 - $8a45
+
+Function8a60: ; 8a60
+ push de
+ call Function9809
+ pop hl
+ jp Function9809
+; 8a68
+
--- a/stats/odd_eggs.asm
+++ b/stats/odd_eggs.asm
@@ -45,7 +45,7 @@
ld a, $ff
ld [$d107], a
ld hl, NumItems
- call Function2f53
+ call TossItem
ld a, EGG
ld [$cd2a], a
ld a, $29
--- /dev/null
+++ b/text/types.asm
@@ -1,0 +1,162 @@
+PrintMonTypes: ; 5090d
+; Print both types of CurSpecies on the stats screen at hl.
+
+ push hl
+ call GetBaseData
+ pop hl
+
+ push hl
+ ld a, [BaseType1]
+ call .PrintType
+
+ ld a, [BaseType1]
+ ld b, a
+ ld a, [BaseType2]
+ cp b
+ pop hl
+ jr z, .HideSecondType
+
+; Next row
+ ld bc, 20
+ add hl, bc
+
+.PrintType
+ ld b, a
+ jr PrintType
+
+.HideSecondType
+; This doesn't actually do anything.
+ ld a, " "
+ ld bc, 20 - 3
+ add hl, bc
+ ld [hl], a
+ inc bc
+ add hl, bc
+ ld bc, 5
+ jp ByteFill
+; 5093a
+
+PrintMoveType: ; 5093a
+; Print the type of move b at hl.
+
+ push hl
+ ld a, b
+ dec a
+ ld bc, Move2 - Move1
+ ld hl, Moves
+ call AddNTimes
+ ld de, StringBuffer1
+ ld a, BANK(Moves)
+ call FarCopyBytes
+ ld a, [StringBuffer1 + PlayerMoveType - PlayerMoveStruct]
+ pop hl
+
+ ld b, a
+; 50953
+
+PrintType: ; 50953
+; Print type b at hl.
+ ld a, b
+
+ push hl
+ add a
+ ld hl, TypeNames
+ ld e, a
+ ld d, 0
+ add hl, de
+ ld a, [hli]
+ ld e, a
+ ld d, [hl]
+ pop hl
+
+ jp PlaceString
+; 50964
+
+
+GetTypeName: ; 50964
+; Copy the name of type $d265 to StringBuffer1.
+ ld a, [$d265]
+ ld hl, TypeNames
+ ld e, a
+ ld d, 0
+ add hl, de
+ add hl, de
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, StringBuffer1
+ ld bc, $000d
+ jp CopyBytes
+; 5097b
+
+
+TypeNames: ; 5097b
+ dw Normal
+ dw Fighting
+ dw Flying
+ dw Poison
+ dw Ground
+ dw Rock
+ dw Bird
+ dw Bug
+ dw Ghost
+ dw Steel
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw Normal
+ dw UnknownType
+ dw Fire
+ dw Water
+ dw Grass
+ dw Electric
+ dw Psychic
+ dw Ice
+ dw Dragon
+ dw Dark
+
+Normal:
+ db "NORMAL@"
+Fighting:
+ db "FIGHTING@"
+Flying:
+ db "FLYING@"
+Poison:
+ db "POISON@"
+UnknownType:
+ db "???@"
+Fire:
+ db "FIRE@"
+Water:
+ db "WATER@"
+Grass:
+ db "GRASS@"
+Electric:
+ db "ELECTRIC@"
+Psychic:
+ db "PSYCHIC@"
+Ice:
+ db "ICE@"
+Ground:
+ db "GROUND@"
+Rock:
+ db "ROCK@"
+Bird:
+ db "BIRD@"
+Bug:
+ db "BUG@"
+Ghost:
+ db "GHOST@"
+Steel:
+ db "STEEL@"
+Dragon:
+ db "DRAGON@"
+Dark:
+ db "DARK@"
+; 50a28
+
--- a/wram.asm
+++ b/wram.asm
@@ -477,8 +477,11 @@
BattleMonType2: ; c64b
ds 1
- ds 23
+ ds 10
+OTName: ; c656
+ ds 13
+
CurOTMon: ; c663
ds 1
@@ -585,6 +588,7 @@
ds 1
PlayerFuryCutterCount: ; c678
ds 1
+PlayerProtectCount: ; c679
ds 1
EnemyRolloutCount: ; c67a
@@ -600,6 +604,7 @@
ds 1
EnemyFuryCutterCount: ; c680
ds 1
+EnemyProtectCount: ; c681
ds 1
PlayerDamageTaken: ; c682
@@ -2023,12 +2028,12 @@
PartyMonNicknamesEnd
SECTION "Pokedex",WRAMX[$de99],BANK[1]
-PokedexSeen: ; de99
+PokedexCaught: ; de99
ds 32
-EndPokedexSeen:
-PokedexCaught: ; deb9
- ds 32
EndPokedexCaught:
+PokedexSeen: ; deb9
+ ds 32
+EndPokedexSeen:
UnownDex: ; ded9
ds 26
UnlockedUnowns: ; def3