ref: 40b537d45b4b8937038126f7e5d2d21ccee460c0
parent: e4b41fad4fd3787ca2e61adb5377ba8f68fca7ef
parent: 53ff57ca663dc5bf9c3731022b0eb0dc73f2207f
author: yenatch <[email protected]>
date: Mon Apr 9 17:30:24 EDT 2018
Merge pull request #503 from Rangi42/master Factor wMisc into meaningful parts; move most code out of home.asm
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -1081,7 +1081,7 @@
ret z
; are we in a sfx channel?
ld a, [wCurChannel]
- bit 2, a ; sfx
+ bit NOISE_CHAN_F, a
jr nz, .next
; is ch8 on? (noise)
ld hl, wChannel8Flags
@@ -1330,7 +1330,7 @@
call SetNoteDuration
; check current channel
ld a, [wCurChannel]
- bit 2, a ; are we in a sfx channel?
+ bit NOISE_CHAN_F, a
jr nz, .sfx
ld hl, wChannel8Flags
bit SOUND_CHANNEL_ON, [hl] ; is ch8 on? (noise)
--- a/constants/audio_constants.asm
+++ b/constants/audio_constants.asm
@@ -31,6 +31,8 @@
const CHAN8 ; 7
NUM_CHANNELS EQU const_value
+NOISE_CHAN_F EQU 2 ; bit set in CHAN5-CHAN7
+
; Flags1
const_def
const SOUND_CHANNEL_ON ; 0
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -157,7 +157,7 @@
const FRZ
const PAR
-ALL_STATUS EQU (1 << PSN) + (1 << BRN) + (1 << FRZ) + (1 << PAR) + SLP
+ALL_STATUS EQU (1 << PSN) | (1 << BRN) | (1 << FRZ) | (1 << PAR) | SLP
; wPlayerSubStatus1 or wEnemySubStatus1 bit flags
enum_start 7, -1
@@ -248,3 +248,7 @@
const WIN
const LOSE
const DRAW
+
+BATTLERESULT_CAUGHT_CELEBI EQU 6
+BATTLERESULT_BOX_FULL EQU 7
+BATTLERESULT_BITMASK EQU (1 << BATTLERESULT_CAUGHT_CELEBI) | (1 << BATTLERESULT_BOX_FULL)
--- a/constants/gfx_constants.asm
+++ b/constants/gfx_constants.asm
@@ -16,8 +16,12 @@
BG_MAP_WIDTH EQU 32 ; tiles
BG_MAP_HEIGHT EQU 32 ; tiles
-WMISC_WIDTH EQU 6 * 4
-WMISC_HEIGHT EQU 5 * 4
+
+METATILE_WIDTH EQU 4 ; tiles
+SCREEN_META_WIDTH EQU 6 ; metatiles
+SCREEN_META_HEIGHT EQU 5 ; metatiles
+SURROUNDING_WIDTH EQU SCREEN_META_WIDTH * METATILE_WIDTH ; tiles
+SURROUNDING_HEIGHT EQU SCREEN_META_HEIGHT * METATILE_WIDTH ; tiles
HP_BAR_LENGTH EQU 6 ; tiles
--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -15,11 +15,15 @@
; map group ids
; `newgroup` indexes are for:
-; - MapGroupPointers (see data/maps/definitions.asm)
+; - MapGroupPointers (see data/maps/maps.asm)
; - MapGroupRoofs (see data/maps/roofs.asm)
; - OutdoorSprites (see data/maps/outdoor_sprites.asm)
; - RoofPals (see gfx/tilesets/roofs.pal)
-; `map_const` indexes are for the sub-tables of MapGroupPointers (see data/maps/definitions.asm)
+; `map_const` indexes are for the sub-tables of MapGroupPointers (see data/maps/maps.asm)
+; Each map also has associated data:
+; - attributes (see data/maps/attributes.asm)
+; - blocks (see data/maps/blocks.asm)
+; - scripts and events (see data/maps/scripts.asm)
const_def
newgroup ; 1
--- a/data/events/unown_walls.asm
+++ b/data/events/unown_walls.asm
@@ -2,21 +2,15 @@
rept _NARG
if \1 == "-"
x = $64
-else
-if \1 >= "Y"
+elif \1 >= "Y"
x = 2 * (\1 - "Y") + $60
-else
-if \1 >= "Q"
+elif \1 >= "Q"
x = 2 * (\1 - "Q") + $40
-else
-if \1 >= "I"
+elif \1 >= "I"
x = 2 * (\1 - "I") + $20
else
x = 2 * (\1 - "A")
endc
-endc
-endc
-endc
db x
shift
endr
@@ -25,16 +19,16 @@
UnownWalls: ; 8aebc
; UNOWNWORDS_ESCAPE
- ; db $08, $44, $04, $00, $2e, $08, $ff
+ ; db $08, $44, $04, $00, $2e, $08, -1
unownwall "E", "S", "C", "A", "P", "E"
; UNOWNWORDS_LIGHT
- ; db $26, $20, $0c, $0e, $46, $ff
+ ; db $26, $20, $0c, $0e, $46, -1
unownwall "L", "I", "G", "H", "T"
; UNOWNWORDS_WATER
- ; db $4c, $00, $46, $08, $42, $ff
+ ; db $4c, $00, $46, $08, $42, -1
unownwall "W", "A", "T", "E", "R"
; UNOWNWORDS_HO_OH
- ; db $0e, $2c, $64, $2c, $0e, $ff
+ ; db $0e, $2c, $64, $2c, $0e, -1
unownwall "H", "O", "-", "O", "H"
; 8aed5
--- a/data/maps/attributes.asm
+++ b/data/maps/attributes.asm
@@ -27,39 +27,39 @@
if "\1" == "north"
map_id \3
dw \2_Blocks + \3_WIDTH * (\3_HEIGHT - 3) + \5
- dw wOverworldMap + \4 + 3
+ dw wOverworldMapBlocks + \4 + 3
db \6
db \3_WIDTH
db \3_HEIGHT * 2 - 1
db (\4 - \5) * -2
- dw wOverworldMap + \3_HEIGHT * (\3_WIDTH + 6) + 1
+ dw wOverworldMapBlocks + \3_HEIGHT * (\3_WIDTH + 6) + 1
elif "\1" == "south"
map_id \3
dw \2_Blocks + \5
- dw wOverworldMap + (CURRENT_MAP_HEIGHT + 3) * (CURRENT_MAP_WIDTH + 6) + \4 + 3
+ dw wOverworldMapBlocks + (CURRENT_MAP_HEIGHT + 3) * (CURRENT_MAP_WIDTH + 6) + \4 + 3
db \6
db \3_WIDTH
db 0
db (\4 - \5) * -2
- dw wOverworldMap + \3_WIDTH + 7
+ dw wOverworldMapBlocks + \3_WIDTH + 7
elif "\1" == "west"
map_id \3
dw \2_Blocks + (\3_WIDTH * \5) + \3_WIDTH - 3
- dw wOverworldMap + (CURRENT_MAP_WIDTH + 6) * (\4 + 3)
+ dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * (\4 + 3)
db \6
db \3_WIDTH
db (\4 - \5) * -2
db \3_WIDTH * 2 - 1
- dw wOverworldMap + \3_WIDTH * 2 + 6
+ dw wOverworldMapBlocks + \3_WIDTH * 2 + 6
elif "\1" == "east"
map_id \3
dw \2_Blocks + (\3_WIDTH * \5)
- dw wOverworldMap + (CURRENT_MAP_WIDTH + 6) * (\4 + 3 + 1) - 3
+ dw wOverworldMapBlocks + (CURRENT_MAP_WIDTH + 6) * (\4 + 3 + 1) - 3
db \6
db \3_WIDTH
db (\4 - \5) * -2
db 0
- dw wOverworldMap + \3_WIDTH + 7
+ dw wOverworldMapBlocks + \3_WIDTH + 7
endc
ENDM
--- a/docs/bugs_and_glitches.md
+++ b/docs/bugs_and_glitches.md
@@ -949,18 +949,18 @@
add 3
ld hl, wEnemyMonLevel
cp [hl]
- jr nc, .okay
- set 0, e
-.okay
+ jr nc, .not_stronger
+ set TRANS_STRONGER_F, e
+.not_stronger
ld a, [wEnvironment]
cp CAVE
- jr z, .okay2
+ jr z, .cave
cp ENVIRONMENT_5
- jr z, .okay2
+ jr z, .cave
cp DUNGEON
- jr z, .okay2
- set 1, e
-.okay2
+ jr z, .cave
+ set TRANS_NO_CAVE_F, e
+.cave
ld hl, .StartingPoints
add hl, de
ld a, [hl]
@@ -969,8 +969,11 @@
; 8c38f (23:438f)
.StartingPoints: ; 8c38f
- db 1, 9
- db 16, 24
+; entries correspond to TRANS_* constants
+ db BATTLETRANSITION_CAVE
+ db BATTLETRANSITION_CAVE_STRONGER
+ db BATTLETRANSITION_NO_CAVE
+ db BATTLETRANSITION_NO_CAVE_STRONGER
; 8c393
```
--- a/engine/battle/battle_transition.asm
+++ b/engine/battle/battle_transition.asm
@@ -1,3 +1,11 @@
+; BattleTransitionJumptable.Jumptable indexes
+BATTLETRANSITION_CAVE EQU $01
+BATTLETRANSITION_CAVE_STRONGER EQU $09
+BATTLETRANSITION_NO_CAVE EQU $10
+BATTLETRANSITION_NO_CAVE_STRONGER EQU $18
+BATTLETRANSITION_FINISH EQU $20
+BATTLETRANSITION_END EQU $80
+
DoBattleTransition: ; 8c20f
call .InitGFX
ld a, [rBGP]
@@ -14,7 +22,7 @@
.loop
ld a, [wJumptableIndex]
- bit 7, a
+ bit 7, a ; BATTLETRANSITION_END?
jr nz, .done
call BattleTransitionJumptable
call DelayFrame
@@ -145,13 +153,13 @@
BattleTransitionJumptable: ; 8c314
- jumptable .dw, wJumptableIndex
+ jumptable .Jumptable, wJumptableIndex
; 8c323
-.dw ; 8c323 (23:4323)
+.Jumptable ; 8c323 (23:4323)
dw StartTrainerBattle_DetermineWhichAnimation ; 00
- ; Animation 1: cave
+ ; BATTLETRANSITION_CAVE
dw StartTrainerBattle_LoadPokeBallGraphics ; 01
dw StartTrainerBattle_SetUpBGMap ; 02
dw StartTrainerBattle_Flash ; 03
@@ -161,7 +169,7 @@
dw StartTrainerBattle_SetUpForWavyOutro ; 07
dw StartTrainerBattle_SineWave ; 08
- ; Animation 2: cave, stronger
+ ; BATTLETRANSITION_CAVE_STRONGER
dw StartTrainerBattle_LoadPokeBallGraphics ; 09
dw StartTrainerBattle_SetUpBGMap ; 0a
dw StartTrainerBattle_Flash ; 0b
@@ -171,7 +179,7 @@
; There is no setup for this one
dw StartTrainerBattle_ZoomToBlack ; 0f
- ; Animation 3: no cave
+ ; BATTLETRANSITION_NO_CAVE
dw StartTrainerBattle_LoadPokeBallGraphics ; 10
dw StartTrainerBattle_SetUpBGMap ; 11
dw StartTrainerBattle_Flash ; 12
@@ -181,7 +189,7 @@
dw StartTrainerBattle_SetUpForSpinOutro ; 16
dw StartTrainerBattle_SpinToBlack ; 17
- ; Animation 4: no cave, stronger
+ ; BATTLETRANSITION_NO_CAVE_STRONGER
dw StartTrainerBattle_LoadPokeBallGraphics ; 18
dw StartTrainerBattle_SetUpBGMap ; 19
dw StartTrainerBattle_Flash ; 1a
@@ -191,10 +199,20 @@
dw StartTrainerBattle_SetUpForRandomScatterOutro ; 1e
dw StartTrainerBattle_SpeckleToBlack ; 1f
- ; All animations jump to here.
+ ; BATTLETRANSITION_FINISH
dw StartTrainerBattle_Finish ; 20
+; transition animations
+ const_def
+ const TRANS_CAVE
+ const TRANS_CAVE_STRONGER
+ const TRANS_NO_CAVE
+ const TRANS_NO_CAVE_STRONGER
+; transition animation bits
+TRANS_STRONGER_F EQU 0 ; bit set in TRANS_CAVE_STRONGER and TRANS_NO_CAVE_STRONGER
+TRANS_NO_CAVE_F EQU 1 ; bit set in TRANS_NO_CAVE and TRANS_NO_CAVE_STRONGER
+
StartTrainerBattle_DetermineWhichAnimation: ; 8c365 (23:4365)
; The screen flashes a different number of times depending on the level of
; your lead Pokemon relative to the opponent's.
@@ -205,18 +223,18 @@
add 3
ld hl, wEnemyMonLevel
cp [hl]
- jr nc, .okay
- set 0, e
-.okay
+ jr nc, .not_stronger
+ set TRANS_STRONGER_F, e
+.not_stronger
ld a, [wEnvironment]
cp CAVE
- jr z, .okay2
+ jr z, .cave
cp ENVIRONMENT_5
- jr z, .okay2
+ jr z, .cave
cp DUNGEON
- jr z, .okay2
- set 1, e
-.okay2
+ jr z, .cave
+ set TRANS_NO_CAVE_F, e
+.cave
ld hl, .StartingPoints
add hl, de
ld a, [hl]
@@ -225,13 +243,16 @@
; 8c38f (23:438f)
.StartingPoints: ; 8c38f
- db 1, 9
- db 16, 24
+; entries correspond to TRANS_* constants
+ db BATTLETRANSITION_CAVE
+ db BATTLETRANSITION_CAVE_STRONGER
+ db BATTLETRANSITION_NO_CAVE
+ db BATTLETRANSITION_NO_CAVE_STRONGER
; 8c393
StartTrainerBattle_Finish: ; 8c393 (23:4393)
call ClearSprites
- ld a, $80
+ ld a, BATTLETRANSITION_END
ld [wJumptableIndex], a
ret
@@ -322,7 +343,7 @@
ret
.end
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
@@ -394,7 +415,7 @@
call DelayFrame
xor a
ld [hBGMapMode], a
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
; 8c490 (23:4490)
@@ -406,6 +427,10 @@
const LOWER_LEFT
const LOWER_RIGHT
+; quadrant bits
+RIGHT_QUADRANT_F EQU 0 ; bit set in UPPER_RIGHT and LOWER_RIGHT
+LOWER_QUADRANT_F EQU 1 ; bit set in LOWER_LEFT and LOWER_RIGHT
+
.spintable ; 8c490
spintable_entry: MACRO
db \1
@@ -451,7 +476,7 @@
.loop1
ld [hl], $ff
ld a, [wcf65]
- bit 0, a
+ bit RIGHT_QUADRANT_F, a
jr z, .leftside
inc hl
jr .okay1
@@ -462,7 +487,7 @@
jr nz, .loop1
pop hl
ld a, [wcf65]
- bit 1, a
+ bit LOWER_QUADRANT_F, a
ld bc, SCREEN_WIDTH
jr z, .upper
ld bc, -SCREEN_WIDTH
@@ -477,7 +502,7 @@
ld c, a
.loop2
ld a, [wcf65]
- bit 0, a
+ bit RIGHT_QUADRANT_F, a
jr z, .leftside2
dec hl
jr .okay2
@@ -530,7 +555,7 @@
call DelayFrame
xor a
ld [hBGMapMode], a
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
@@ -778,7 +803,7 @@
jr .loop
.done
- ld a, $20
+ ld a, BATTLETRANSITION_FINISH
ld [wJumptableIndex], a
ret
; 8c792 (23:4792)
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -119,8 +119,8 @@
WildFled_EnemyFled_LinkBattleCanceled: ; 3c0e5
call Call_LoadTempTileMapToTileMap
ld a, [wBattleResult]
- and $c0
- add $2
+ and BATTLERESULT_BITMASK
+ add DRAW
ld [wBattleResult], a
ld a, [wLinkMode]
and a
@@ -128,8 +128,8 @@
jr z, .print_text
ld a, [wBattleResult]
- and $c0
- ld [wBattleResult], a
+ and BATTLERESULT_BITMASK
+ ld [wBattleResult], a ; WIN
ld hl, BattleText_EnemyFled
call CheckMobileBattleError
jr nc, .print_text
@@ -575,8 +575,8 @@
and a
jr nz, .contest_not_over
ld a, [wBattleResult]
- and $c0
- add $2
+ and BATTLERESULT_BITMASK
+ add DRAW
ld [wBattleResult], a
scf
ret
@@ -2199,8 +2199,8 @@
call EmptyBattleTextBox
call LoadTileMapToTempTileMap
ld a, [wBattleResult]
- and $c0
- ld [wBattleResult], a
+ and BATTLERESULT_BITMASK
+ ld [wBattleResult], a ; WIN
call IsAnyMonHoldingExpShare
jr z, .skip_exp
ld hl, wEnemyMonBaseStats
@@ -2745,8 +2745,8 @@
ld [wCurPartyMon], a
callfar ChangeHappiness
ld a, [wBattleResult]
- and %11000000
- add $1
+ and BATTLERESULT_BITMASK
+ add LOSE
ld [wBattleResult], a
ld a, [wWhichMonFaintedFirst]
and a
@@ -3050,8 +3050,8 @@
jr nz, .not_tied
ld hl, TiedAgainstText
ld a, [wBattleResult]
- and $c0
- add 2
+ and BATTLERESULT_BITMASK
+ add DRAW
ld [wBattleResult], a
jr .text
@@ -3928,11 +3928,11 @@
cp BATTLEACTION_FORFEIT
ld a, DRAW
jr z, .fled
- dec a
+ dec a ; LOSE
.fled
ld b, a
ld a, [wBattleResult]
- and $c0
+ and BATTLERESULT_BITMASK
add b
ld [wBattleResult], a
call StopDangerSound
@@ -5180,8 +5180,8 @@
xor a
ld [wWildMon], a
ld a, [wBattleResult]
- and $c0
- ld [wBattleResult], a
+ and BATTLERESULT_BITMASK
+ ld [wBattleResult], a ; WIN
call ClearWindowData
call SetPalettes
scf
@@ -8607,9 +8607,10 @@
.proceed
ld a, [wBattleResult]
and $f
- cp $1
- jr c, .victory
- jr z, .loss
+ cp LOSE
+ jr c, .victory ; WIN
+ jr z, .loss ; LOSE
+ ; DRAW
farcall StubbedTrainerRankings_ColosseumDraws
ld de, .Draw
jr .store_result
@@ -8841,7 +8842,7 @@
jr nz, .not_roaming
ld a, [wBattleResult]
and $f
- jr z, .caught_or_defeated_roam_mon
+ jr z, .caught_or_defeated_roam_mon ; WIN
call GetRoamMonHP
ld a, [wEnemyMonHP + 1]
ld [hl], a
@@ -9001,11 +9002,12 @@
.StoreResult: ; 3faa0
ld a, [wBattleResult]
and $f
- cp $1
+ cp LOSE
ld bc, sLinkBattleWins + 1 - sLinkBattleResults
- jr c, .okay
+ jr c, .okay ; WIN
ld bc, sLinkBattleLosses + 1 - sLinkBattleResults
- jr z, .okay
+ jr z, .okay ; LOSE
+ ; DRAW
ld bc, sLinkBattleDraws + 1 - sLinkBattleResults
.okay
add hl, bc
--- a/engine/battle/effect_commands.asm
+++ b/engine/battle/effect_commands.asm
@@ -5390,8 +5390,8 @@
SetBattleDraw: ; 36804
ld a, [wBattleResult]
- and $c0
- or $2
+ and BATTLERESULT_BITMASK
+ or DRAW
ld [wBattleResult], a
ret
--- a/engine/battle/link_result.asm
+++ b/engine/battle/link_result.asm
@@ -41,13 +41,13 @@
.victory
ld a, [wBattleResult]
and $f0
- ld [wBattleResult], a
+ ld [wBattleResult], a ; WIN
ret
.defeat
ld a, [wBattleResult]
and $f0
- add $1
+ add LOSE
ld [wBattleResult], a
ret
@@ -54,7 +54,7 @@
.drawn
ld a, [wBattleResult]
and $f0
- add $2
+ add DRAW
ld [wBattleResult], a
ret
@@ -123,16 +123,16 @@
jr nz, .finish ; we have a pokemon that's neither fainted nor at full health
ld hl, wOTPartyMon1HP
call .CheckFaintedOrFullHealth
- ld e, $1
+ ld e, $1 ; victory
ret
.finish
ld hl, wOTPartyMon1HP
call .CheckFaintedOrFullHealth
- ld e, $0
+ ld e, $0 ; drawn
ret nz ; we both have pokemon that are neither fainted nor at full health
- ld e, $2
- ld a, $1
+ ld e, $2 ; defeat
+ ld a, $1 ; not drawn
and a
ret
--- a/engine/events/battle_tower/battle_tower.asm
+++ b/engine/events/battle_tower/battle_tower.asm
@@ -64,7 +64,7 @@
ld a, $5
call GetSRAMBank
ld hl, $a948
- ld de, wMisc
+ ld de, wc608
ld bc, $f6 ; 246
call CopyBytes
call CloseSRAM
@@ -90,11 +90,11 @@
ld b, $0
add hl, bc
call CloseSRAM
-; Store that number in wMisc
+; Store that number in wc608
ld a, h
- ld [wMisc], a
+ ld [wc608], a
ld a, l
- ld [wMisc + 1], a
+ ld [wc608 + 1], a
ld hl, wBT_OTTempMon1DVs
ld a, [wPlayerID]
ld [hli], a
@@ -161,7 +161,7 @@
ld hl, $a894
ld bc, NAME_LENGTH_JAPANESE
call CopyBytes
- ld hl, wMisc
+ ld hl, wc608
ld de, $a948
ld bc, $f6
call CopyBytes
@@ -254,7 +254,7 @@
farcall HealParty
ld a, [wBattleResult]
ld [wScriptVar], a
- and a
+ and a ; WIN?
jr nz, .lost
ld a, BANK(sNrOfBeatenBattleTowerTrainers)
call GetSRAMBank
@@ -674,7 +674,7 @@
call CopyBytes
ld hl, $a8b2
- ld de, wMisc
+ ld de, wc608
ld bc, $0096
call CopyBytes
@@ -793,7 +793,7 @@
call .PlaceUpDownArrows
ld a, $50
ld [wcd4e], a
- ld hl, wMisc
+ ld hl, wc608
ld a, [wNrOfBeatenBattleTowerTrainers]
ld c, a
xor a
@@ -1441,7 +1441,7 @@
ld a, $5
call GetSRAMBank
ld hl, $b023
- ld de, wMisc
+ ld de, wc608
ld bc, $0069
call CopyBytes
ld a, [$a825]
@@ -1460,7 +1460,7 @@
ld a, $0
call GetSRAMBank
ld hl, wRTC
- ld de, wMisc
+ ld de, wc608
ld bc, $0004
call CopyBytes
call CloseSRAM
@@ -1467,7 +1467,7 @@
ld a, $5
call GetSRAMBank
ld hl, $b08c
- ld de, wMisc
+ ld de, wc608
ld c, $4
.compare_loop
ld a, [de]
--- a/engine/events/bug_contest/display_stats.asm
+++ b/engine/events/bug_contest/display_stats.asm
@@ -7,7 +7,7 @@
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
hlcoord 0, 0
ld b, 4
--- a/engine/events/celebi.asm
+++ b/engine/events/celebi.asm
@@ -325,15 +325,15 @@
CheckCaughtCelebi: ; 49bf9
ld a, [wBattleResult]
- bit 6, a
+ bit BATTLERESULT_CAUGHT_CELEBI, a
jr z, .false
- ld a, $1
+ ld a, TRUE
ld [wScriptVar], a
jr .done
.false
- xor a
+ xor a ; FALSE
ld [wScriptVar], a
.done
--- a/engine/events/halloffame.asm
+++ b/engine/events/halloffame.asm
@@ -143,12 +143,12 @@
GetHallOfFameParty: ; 8653f
- ld hl, wOverworldMap
- ld bc, HOF_LENGTH
+ ld hl, wHallOfFamePokemonList
+ ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
xor a
call ByteFill
ld a, [wHallOfFameCount]
- ld de, wOverworldMap
+ ld de, wHallOfFamePokemonList
ld [de], a
inc de
ld hl, wPartySpecies
@@ -216,7 +216,7 @@
pop bc
inc c
pop de
- ld hl, HOF_MON_LENGTH
+ ld hl, wHallOfFamePokemonListMon1End - wHallOfFamePokemonListMon1
add hl, de
ld e, l
ld d, h
@@ -224,7 +224,7 @@
jr .next
.done
- ld a, $ff
+ ld a, -1
ld [de], a
ret
; 865b5
@@ -422,7 +422,7 @@
cp NUM_HOF_TEAMS
jr nc, .invalid
ld hl, sHallOfFame
- ld bc, HOF_LENGTH
+ ld bc, wHallOfFameTempEnd - wHallOfFameTemp + 1
call AddNTimes
ld a, BANK(sHallOfFame)
call GetSRAMBank
@@ -430,7 +430,7 @@
and a
jr z, .absent
ld de, wHallOfFameTemp
- ld bc, HOF_LENGTH
+ ld bc, wHallOfFameTempEnd - wHallOfFameTemp + 1
call CopyBytes
call CloseSRAM
and a
--- a/engine/events/overworld.asm
+++ b/engine/events/overworld.asm
@@ -179,7 +179,7 @@
farcall CheckCutCollision
pop de
jr nc, .fail
- ; Get the location of the current block in wOverworldMap.
+ ; Get the location of the current block in wOverworldMapBlocks.
call GetBlockLocation
ld c, [hl]
; See if that block contains something that can be cut.
@@ -188,7 +188,7 @@
call CheckOverworldTileArrays
pop hl
jr nc, .fail
- ; Back up the wOverworldMap address to wBuffer3
+ ; Back up the wOverworldMapBlocks address to wBuffer3
ld a, l
ld [wBuffer3], a
ld a, h
--- a/engine/events/print_unown_2.asm
+++ b/engine/events/print_unown_2.asm
@@ -12,7 +12,7 @@
ld de, wd002
call .Copy
call .Rotate
- ld hl, UnownPrinter_OverworldMapRectangle
+ ld hl, UnownPrinter_GBPrinterRectangle
pop bc
add hl, bc
add hl, bc
@@ -30,7 +30,7 @@
cp 7 * 7
jr c, .loop
- ld hl, wOverworldMap
+ ld hl, wGameboyPrinterRAM
ld de, sScratch
ld bc, 7 * 7 tiles
call CopyBytes
@@ -95,12 +95,12 @@
jr nz, .loop_count
ret
-overworldmaprect: MACRO
+gbprinterrect: MACRO
y = 0
rept \1
x = \1 * (\2 + -1) + y
rept \2
- dw wOverworldMap tile x
+ dw wGameboyPrinterRAM tile x
x = x + -\2
endr
y = y + 1
@@ -107,5 +107,5 @@
endr
ENDM
-UnownPrinter_OverworldMapRectangle: ; e008b
- overworldmaprect 7, 7
+UnownPrinter_GBPrinterRectangle: ; e008b
+ gbprinterrect 7, 7
--- a/engine/games/card_flip.asm
+++ b/engine/games/card_flip.asm
@@ -12,7 +12,7 @@
_CardFlip: ; e00ee (38:40ee)
ld hl, wOptions
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
call ClearBGPalettes
call ClearTileMap
call ClearSprites
--- a/engine/games/unown_puzzle.asm
+++ b/engine/games/unown_puzzle.asm
@@ -14,8 +14,8 @@
xor a
ld [hBGMapMode], a
call DisableLCD
- ld hl, wMisc ; includes wPuzzlePieces
- ld bc, wMiscEnd - wMisc
+ ld hl, wc608 ; includes wPuzzlePieces
+ ld bc, wc7e8 - wc608
xor a
call ByteFill
ld hl, UnownPuzzleCursorGFX
--- a/engine/items/item_effects.asm
+++ b/engine/items/item_effects.asm
@@ -537,7 +537,7 @@
cp BATTLETYPE_CELEBI
jr nz, .not_celebi
ld hl, wBattleResult
- set 6, [hl]
+ set BATTLERESULT_CAUGHT_CELEBI, [hl]
.not_celebi
ld a, [wPartyCount]
@@ -615,7 +615,7 @@
cp MONS_PER_BOX
jr nz, .BoxNotFullYet
ld hl, wBattleResult
- set 7, [hl]
+ set BATTLERESULT_BOX_FULL, [hl]
.BoxNotFullYet:
ld a, [wCurItem]
cp FRIEND_BALL
@@ -2196,8 +2196,8 @@
inc a
ld [wForcedSwitch], a
ld a, [wBattleResult]
- and $c0
- or $2
+ and BATTLERESULT_BITMASK
+ or DRAW
ld [wBattleResult], a
jp UseItemText
--- a/engine/link/link.asm
+++ b/engine/link/link.asm
@@ -84,9 +84,9 @@
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
- ld hl, wMisc
- ld de, wPlayerTrademonSpecies
- ld bc, wPlayerTrademonSpecies - wMisc
+ ld hl, wLink_c608
+ ld de, wTrademons
+ ld bc, wTrademons - wLink_c608
call Serial_ExchangeBytes
xor a
ld [rIF], a
@@ -229,9 +229,9 @@
call Serial_ExchangeBytes
ld a, SERIAL_NO_DATA_BYTE
ld [de], a
- ld hl, wMisc
- ld de, wPlayerTrademonSpecies
- ld bc, $c8
+ ld hl, wLink_c608
+ ld de, wTrademons
+ ld bc, wTrademons - wLink_c608
call Serial_ExchangeBytes
ld a, [wLinkMode]
cp LINK_TRADECENTER
@@ -581,7 +581,7 @@
ld [hli], a
dec b
jr nz, .loop2
- ld hl, wMisc
+ ld hl, wLink_c608
ld a, SERIAL_PREAMBLE_BYTE
ld [hli], a
ld [hli], a
--- a/engine/link/mystery_gift.asm
+++ b/engine/link/mystery_gift.asm
@@ -394,7 +394,7 @@
jp nz, Function104d32
call Function104d38
ret nz
- ld hl, wOverworldMap
+ ld hl, wLinkData
ld a, [wca02]
ld b, a
call Function104d4e
@@ -551,7 +551,7 @@
jp nz, Function104d32
call Function104d38
ret nz
- ld hl, wOverworldMap
+ ld hl, wLinkData
ld a, [wca02]
ld b, a
call Function104d4e
@@ -1543,7 +1543,7 @@
ret
Function10578c: ; 10578c (41:578c)
- ld de, wOverworldMap
+ ld de, wLinkData
ld a, BANK(sPlayerData)
call GetSRAMBank
ld hl, sPlayerData + wPlayerName - wPlayerData
--- a/engine/menus/debug.asm
+++ b/engine/menus/debug.asm
@@ -71,7 +71,7 @@
ld hl, PokemonPalettes
Function818fd: ; 818fd
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
ld c, NUM_POKEMON + 1
.asm_81902
push bc
@@ -87,7 +87,7 @@
Function81911: ; 81911
ld hl, TrainerPalettes
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
ld c, NUM_TRAINER_CLASSES
.asm_81919
push bc
@@ -424,7 +424,7 @@
ld h, $0
add hl, hl
add hl, hl
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
add hl, de
ld de, wc608
ld bc, 4
@@ -876,7 +876,7 @@
ld h, $0
add hl, hl
add hl, hl
- ld de, wOverworldMap
+ ld de, wOverworldMapBlocks
add hl, de
ld e, l
ld d, h
--- a/engine/menus/save.asm
+++ b/engine/menus/save.asm
@@ -165,9 +165,9 @@
ld a, c
or b
jr nz, .loop
- ld hl, wOverworldMap
+ ld hl, wHallOfFamePokemonList
ld de, sHallOfFame
- ld bc, HOF_LENGTH
+ ld bc, wHallOfFamePokemonListEnd - wHallOfFamePokemonList + 1
call CopyBytes
call CloseSRAM
ret
@@ -943,8 +943,8 @@
; 150f9
SaveBoxAddress: ; 150f9
-; Save box via wMisc.
-; We do this in three steps because the size of wMisc is less than
+; Save box via wBoxPartialData.
+; We do this in three steps because the size of wBoxPartialData is less than
; the size of sBox.
push hl
; Load the first part of the active box.
@@ -953,8 +953,8 @@
ld a, BANK(sBox)
call GetSRAMBank
ld hl, sBox
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop de
@@ -963,8 +963,8 @@
push af
push de
call GetSRAMBank
- ld hl, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld hl, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
@@ -971,15 +971,15 @@
; Load the second part of the active box.
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, sBox + (wMiscEnd - wMisc)
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop de
pop af
- ld hl, (wMiscEnd - wMisc)
+ ld hl, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
ld e, l
ld d, h
@@ -987,8 +987,8 @@
push af
push de
call GetSRAMBank
- ld hl, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld hl, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
@@ -995,22 +995,22 @@
; Load the third and final part of the active box.
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, sBox + (wMiscEnd - wMisc) * 2
- ld de, wMisc
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld hl, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
+ ld de, wBoxPartialData
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
pop de
pop af
- ld hl, (wMiscEnd - wMisc)
+ ld hl, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
ld e, l
ld d, h
; Save it to the final part of the target box.
call GetSRAMBank
- ld hl, wMisc
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld hl, wBoxPartialData
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
@@ -1020,8 +1020,8 @@
LoadBoxAddress: ; 1517d (5:517d)
-; Load box via wMisc.
-; We do this in three steps because the size of wMisc is less than
+; Load box via wBoxPartialData.
+; We do this in three steps because the size of wBoxPartialData is less than
; the size of sBox.
push hl
ld l, e
@@ -1030,52 +1030,52 @@
push af
push hl
call GetSRAMBank
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, wMisc
+ ld hl, wBoxPartialData
ld de, sBox
- ld bc, (wMiscEnd - wMisc)
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop hl
pop af
- ld de, (wMiscEnd - wMisc)
+ ld de, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
; Load part 2
push af
push hl
call GetSRAMBank
- ld de, wMisc
- ld bc, (wMiscEnd - wMisc)
+ ld de, wBoxPartialData
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, wMisc
- ld de, sBox + (wMiscEnd - wMisc)
- ld bc, (wMiscEnd - wMisc)
+ ld hl, wBoxPartialData
+ ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData)
+ ld bc, (wBoxPartialDataEnd - wBoxPartialData)
call CopyBytes
call CloseSRAM
pop hl
pop af
; Load part 3
- ld de, (wMiscEnd - wMisc)
+ ld de, (wBoxPartialDataEnd - wBoxPartialData)
add hl, de
call GetSRAMBank
- ld de, wMisc
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld de, wBoxPartialData
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
ld a, BANK(sBox)
call GetSRAMBank
- ld hl, wMisc
- ld de, sBox + (wMiscEnd - wMisc) * 2
- ld bc, sBoxEnd - (sBox + (wMiscEnd - wMisc) * 2) ; $8e
+ ld hl, wBoxPartialData
+ ld de, sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2
+ ld bc, sBoxEnd - (sBox + (wBoxPartialDataEnd - wBoxPartialData) * 2) ; $8e
call CopyBytes
call CloseSRAM
--- a/engine/movie/trade_animation.asm
+++ b/engine/movie/trade_animation.asm
@@ -126,7 +126,7 @@
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
call .TradeAnimLayout
ld a, [wcf66]
and a
--- a/engine/overworld/load_map_part.asm
+++ b/engine/overworld/load_map_part.asm
@@ -1,9 +1,9 @@
_LoadMapPart:: ; 4d15b
- ld hl, wMisc
+ ld hl, wSurroundingTiles
ld a, [wMetatileStandingY]
and a
jr z, .top_row
- ld bc, WMISC_WIDTH * 2
+ ld bc, SURROUNDING_WIDTH * 2
add hl, bc
.top_row
@@ -25,7 +25,7 @@
dec c
jr nz, .loop2
ld a, l
- add 4
+ add METATILE_WIDTH
ld l, a
jr nc, .carry
inc h
--- a/engine/overworld/scripting.asm
+++ b/engine/overworld/scripting.asm
@@ -1359,7 +1359,7 @@
call BufferScreen
predef StartBattle
ld a, [wBattleResult]
- and $3f
+ and $ff ^ BATTLERESULT_BITMASK
ld [wScriptVar], a
ret
@@ -1378,10 +1378,10 @@
ld hl, wBattleScriptFlags
ld d, [hl]
- ld [hl], $0
+ ld [hl], 0
ld a, [wBattleResult]
- and $3f
- cp $1
+ and $ff ^ BATTLERESULT_BITMASK
+ cp LOSE
jr nz, .notblackedout
ld b, BANK(Script_BattleWhiteout)
ld hl, Script_BattleWhiteout
@@ -1395,7 +1395,7 @@
.was_wild
ld a, [wBattleResult]
- bit 7, a
+ bit BATTLERESULT_BOX_FULL, a
jr z, .done
ld b, BANK(Script_SpecialBillCall)
ld de, Script_SpecialBillCall
--- a/engine/overworld/variables.asm
+++ b/engine/overworld/variables.asm
@@ -146,6 +146,6 @@
.BattleResult: ; 80728
ld a, [wBattleResult]
- and $3f
+ and $ff ^ BATTLERESULT_BITMASK
jp .loadstringbuffer2
; 80730
--- a/engine/overworld/warp_connection.asm
+++ b/engine/overworld/warp_connection.asm
@@ -392,7 +392,7 @@
GetCoordOfUpperLeftCorner:: ; 10486d
- ld hl, wOverworldMap
+ ld hl, wOverworldMapBlocks
ld a, [wXCoord]
bit 0, a
jr nz, .increment_then_halve1
--- a/engine/pokemon/bills_pc.asm
+++ b/engine/pokemon/bills_pc.asm
@@ -2,7 +2,7 @@
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
@@ -264,7 +264,7 @@
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
@@ -507,7 +507,7 @@
ld hl, wOptions
ld a, [hl]
push af
- set 4, [hl]
+ set NO_TEXT_SCROLL, [hl]
ld a, [wVramState]
push af
xor a
--- a/engine/pokemon/check_nick_errors.asm
+++ /dev/null
@@ -1,74 +1,0 @@
-CheckNickErrors:: ; 669f
-; error-check monster nick before use
-; must be a peace offering to gamesharkers
-
-; input: de = nick location
-
- push bc
- push de
- ld b, MON_NAME_LENGTH
-
-.checkchar
-; end of nick?
- ld a, [de]
- cp "@" ; terminator
- jr z, .end
-
-; check if this char is a text command
- ld hl, .textcommands
- dec hl
-.loop
-; next entry
- inc hl
-; reached end of commands table?
- ld a, [hl]
- cp -1
- jr z, .done
-
-; is the current char between this value (inclusive)...
- ld a, [de]
- cp [hl]
- inc hl
- jr c, .loop
-; ...and this one?
- cp [hl]
- jr nc, .loop
-
-; replace it with a "?"
- ld a, "?"
- ld [de], a
- jr .loop
-
-.done
-; next char
- inc de
-; reached end of nick without finding a terminator?
- dec b
- jr nz, .checkchar
-
-; change nick to "?@"
- pop de
- push de
- ld a, "?"
- ld [de], a
- inc de
- ld a, "@"
- ld [de], a
-.end
-; if the nick has any errors at this point it's out of our hands
- pop de
- pop bc
- ret
-
-.textcommands ; 66cf
-; table defining which characters are actually text commands
-; format:
- ; ≥ <
- db TX_START, TX_BOX + 1
- db "<PLAY_G>", "<JP_18>" + 1
- db "<NI>", "<NO>" + 1
- db "<ROUTE>", "<GREEN>" + 1
- db "<ENEMY>", "<ENEMY>" + 1
- db "<MOM>", "<TM>" + 1
- db "<ROCKET>", "┘" + 1
- db -1 ; end
--- /dev/null
+++ b/engine/pokemon/correct_nick_errors.asm
@@ -1,0 +1,74 @@
+CorrectNickErrors:: ; 669f
+; error-check monster nick before use
+; must be a peace offering to gamesharkers
+
+; input: de = nick location
+
+ push bc
+ push de
+ ld b, MON_NAME_LENGTH
+
+.checkchar
+; end of nick?
+ ld a, [de]
+ cp "@" ; terminator
+ jr z, .end
+
+; check if this char is a text command
+ ld hl, .textcommands
+ dec hl
+.loop
+; next entry
+ inc hl
+; reached end of commands table?
+ ld a, [hl]
+ cp -1
+ jr z, .done
+
+; is the current char between this value (inclusive)...
+ ld a, [de]
+ cp [hl]
+ inc hl
+ jr c, .loop
+; ...and this one?
+ cp [hl]
+ jr nc, .loop
+
+; replace it with a "?"
+ ld a, "?"
+ ld [de], a
+ jr .loop
+
+.done
+; next char
+ inc de
+; reached end of nick without finding a terminator?
+ dec b
+ jr nz, .checkchar
+
+; change nick to "?@"
+ pop de
+ push de
+ ld a, "?"
+ ld [de], a
+ inc de
+ ld a, "@"
+ ld [de], a
+.end
+; if the nick has any errors at this point it's out of our hands
+ pop de
+ pop bc
+ ret
+
+.textcommands ; 66cf
+; table defining which characters are actually text commands
+; format:
+ ; ≥ <
+ db TX_START, TX_BOX + 1
+ db "<PLAY_G>", "<JP_18>" + 1
+ db "<NI>", "<NO>" + 1
+ db "<ROUTE>", "<GREEN>" + 1
+ db "<ENEMY>", "<ENEMY>" + 1
+ db "<MOM>", "<TM>" + 1
+ db "<ROCKET>", "┘" + 1
+ db -1 ; end
--- a/engine/pokemon/party_menu.asm
+++ b/engine/pokemon/party_menu.asm
@@ -778,7 +778,7 @@
.gotstring ; 504be
ld a, [wOptions]
push af
- set 4, a ; disable text delay
+ set NO_TEXT_SCROLL, a
ld [wOptions], a
hlcoord 1, 16 ; Coord
call PlaceString
--- a/engine/pokemon/stats_screen.asm
+++ b/engine/pokemon/stats_screen.asm
@@ -772,7 +772,7 @@
ld hl, .OTNamePointers
call GetNicknamePointer
call CopyNickname
- farcall CheckNickErrors
+ farcall CorrectNickErrors
hlcoord 2, 13
call PlaceString
ld a, [wTempMonCaughtGender]
--- a/home.asm
+++ b/home.asm
@@ -37,7 +37,7 @@
INCLUDE "home/map_objects.asm"
INCLUDE "home/sine.asm"
INCLUDE "home/movement.asm"
-INCLUDE "home/tilemap.asm"
+INCLUDE "home/menu_window.asm"
INCLUDE "home/menu.asm"
INCLUDE "home/handshake.asm"
INCLUDE "home/game_time.asm"
@@ -87,65 +87,10 @@
ret
; 2ed3
-DisableSpriteUpdates:: ; 0x2ed3
-; disables overworld sprite updating?
- xor a
- ld [hMapAnims], a
- ld a, [wVramState]
- res 0, a
- ld [wVramState], a
- ld a, $0
- ld [wSpriteUpdatesEnabled], a
- ret
-; 0x2ee4
-
-EnableSpriteUpdates:: ; 2ee4
- ld a, $1
- ld [wSpriteUpdatesEnabled], a
- ld a, [wVramState]
- set 0, a
- ld [wVramState], a
- ld a, $1
- ld [hMapAnims], a
- ret
-; 2ef6
-
+INCLUDE "home/sprite_updates.asm"
INCLUDE "home/string.asm"
+INCLUDE "home/region.asm"
-IsInJohto:: ; 2f17
-; Return 0 if the player is in Johto, and 1 in Kanto.
-
- ld a, [wMapGroup]
- ld b, a
- ld a, [wMapNumber]
- ld c, a
- call GetWorldMapLocation
-
- cp FAST_SHIP
- jr z, .Johto
-
- cp SPECIAL_MAP
- jr nz, .CheckRegion
-
- ld a, [wBackupMapGroup]
- ld b, a
- ld a, [wBackupMapNumber]
- ld c, a
- call GetWorldMapLocation
-
-.CheckRegion:
- cp KANTO_LANDMARK
- jr nc, .Kanto
-
-.Johto:
- xor a
- ret
-
-.Kanto:
- ld a, 1
- ret
-; 2f3e
-
ret_2f3e:: ; 2f3e
ret
; 2f3f
@@ -166,89 +111,11 @@
; 2fef
INCLUDE "home/double_speed.asm"
-
-ClearSprites:: ; 300b
-; Erase OAM data
- ld hl, wVirtualOAM
- ld b, wVirtualOAMEnd - wVirtualOAM
- xor a
-.loop
- ld [hli], a
- dec b
- jr nz, .loop
- ret
-; 3016
-
-HideSprites:: ; 3016
-; Set all OAM y-positions to 160 to hide them offscreen
- ld hl, wVirtualOAMSprite00YCoord
- ld de, SPRITEOAMSTRUCT_LENGTH
- ld b, NUM_SPRITE_OAM_STRUCTS
- ld a, SCREEN_WIDTH_PX
-.loop
- ld [hl], a ; y
- add hl, de
- dec b
- jr nz, .loop
- ret
-; 3026
-
+INCLUDE "home/clear_sprites.asm"
INCLUDE "home/copy2.asm"
+INCLUDE "home/copy_tilemap.asm"
+INCLUDE "home/copy_name.asm"
-LoadTileMapToTempTileMap:: ; 309d
-; Load wTileMap into wTempTileMap
- ld a, [rSVBK]
- push af
- ld a, BANK(wTempTileMap)
- ld [rSVBK], a
- hlcoord 0, 0
- decoord 0, 0, wTempTileMap
- ld bc, wTileMapEnd - wTileMap
- call CopyBytes
- pop af
- ld [rSVBK], a
- ret
-; 30b4
-
-Call_LoadTempTileMapToTileMap:: ; 30b4
- xor a
- ld [hBGMapMode], a
- call LoadTempTileMapToTileMap
- ld a, 1
- ld [hBGMapMode], a
- ret
-; 30bf
-
-LoadTempTileMapToTileMap:: ; 30bf
-; Load wTempTileMap into wTileMap
- ld a, [rSVBK]
- push af
- ld a, BANK(wTempTileMap)
- ld [rSVBK], a
- hlcoord 0, 0, wTempTileMap
- decoord 0, 0
- ld bc, wTileMapEnd - wTileMap
- call CopyBytes
- pop af
- ld [rSVBK], a
- ret
-; 30d6
-
-CopyName1:: ; 30d6
-; Copies the name from de to wStringBuffer2
- ld hl, wStringBuffer2
-
-CopyName2:: ; 30d9
-; Copies the name from de to hl
-.loop
- ld a, [de]
- inc de
- ld [hli], a
- cp "@"
- jr nz, .loop
- ret
-; 30e1
-
IsInArray:: ; 30e1
; Find value a for every de bytes in array hl.
; Return index in b and carry if found.
@@ -287,133 +154,8 @@
; 0x30fe
INCLUDE "home/math.asm"
+INCLUDE "home/print_text.asm"
-PrintLetterDelay:: ; 313d
-; Wait before printing the next letter.
-
-; The text speed setting in wOptions is actually a frame count:
-; fast: 1 frame
-; mid: 3 frames
-; slow: 5 frames
-
-; wTextBoxFlags[!0] and A or B override text speed with a one-frame delay.
-; wOptions[4] and wTextBoxFlags[!1] disable the delay.
-
- ld a, [wOptions]
- bit NO_TEXT_SCROLL, a
- ret nz
-
-; non-scrolling text?
- ld a, [wTextBoxFlags]
- bit NO_TEXT_DELAY_F, a
- ret z
-
- push hl
- push de
- push bc
-
- ld hl, hOAMUpdate
- ld a, [hl]
- push af
-
-; orginally turned oam update off...
-; ld a, 1
- ld [hl], a
-
-; force fast scroll?
- ld a, [wTextBoxFlags]
- bit FAST_TEXT_DELAY_F, a
- jr z, .fast
-
-; text speed
- ld a, [wOptions]
- and %111
- jr .updatedelay
-
-.fast
- ld a, TEXT_DELAY_FAST
-
-.updatedelay
- ld [wTextDelayFrames], a
-
-.checkjoypad
- call GetJoypad
-
-; input override
- ld a, [wDisableTextAcceleration]
- and a
- jr nz, .wait
-
-; Wait one frame if holding A or B.
- ld a, [hJoyDown]
- bit A_BUTTON_F, a
- jr z, .checkb
- jr .delay
-.checkb
- bit B_BUTTON_F, a
- jr z, .wait
-
-.delay
- call DelayFrame
- jr .end
-
-.wait
- ld a, [wTextDelayFrames]
- and a
- jr nz, .checkjoypad
-
-.end
- pop af
- ld [hOAMUpdate], a
- pop bc
- pop de
- pop hl
- ret
-; 318c
-
-CopyDataUntil:: ; 318c
-; Copy [hl .. bc) to de.
-
-; In other words, the source data is
-; from hl up to but not including bc,
-; and the destination is de.
-
- ld a, [hli]
- ld [de], a
- inc de
- ld a, h
- cp b
- jr nz, CopyDataUntil
- ld a, l
- cp c
- jr nz, CopyDataUntil
- ret
-; 0x3198
-
-PrintNum:: ; 3198
- homecall _PrintNum
- ret
-; 31a4
-
-MobilePrintNum:: ; 31a4
- homecall _MobilePrintNum
- ret
-; 31b0
-
-FarPrintText:: ; 31b0
- ld [hBuffer], a
- ld a, [hROMBank]
- push af
- ld a, [hBuffer]
- rst Bankswitch
-
- call PrintText
-
- pop af
- rst Bankswitch
- ret
-; 31be
-
CallPointerAt:: ; 31be
ld a, [hROMBank]
push af
@@ -484,236 +226,8 @@
ret
; 31f3
-ClearBGPalettes:: ; 31f3
- call ClearPalettes
-WaitBGMap:: ; 31f6
-; Tell VBlank to update BG Map
- ld a, 1 ; BG Map 0 tiles
- ld [hBGMapMode], a
-; Wait for it to do its magic
- ld c, 4
- call DelayFrames
- ret
-; 3200
+INCLUDE "home/tilemap.asm"
-WaitBGMap2:: ; 0x3200
- ld a, [hCGB]
- and a
- jr z, .bg0
-
- ld a, 2
- ld [hBGMapMode], a
- ld c, 4
- call DelayFrames
-
-.bg0
- ld a, 1
- ld [hBGMapMode], a
- ld c, 4
- call DelayFrames
- ret
-; 0x3218
-
-IsCGB:: ; 3218
- ld a, [hCGB]
- and a
- ret
-; 321c
-
-ApplyTilemap:: ; 321c
- ld a, [hCGB]
- and a
- jr z, .dmg
-
- ld a, [wSpriteUpdatesEnabled]
- cp 0
- jr z, .dmg
-
- ld a, 1
- ld [hBGMapMode], a
- jr CopyTilemapAtOnce
-
-.dmg
-; WaitBGMap
- ld a, 1
- ld [hBGMapMode], a
- ld c, 4
- call DelayFrames
- ret
-; 3238
-
-CGBOnly_CopyTilemapAtOnce:: ; 3238
- ld a, [hCGB]
- and a
- jr z, WaitBGMap
-
-CopyTilemapAtOnce:: ; 323d
- jr .CopyTilemapAtOnce
-; 323f
-
-; unused
- farcall HDMATransferAttrMapAndTileMapToWRAMBank3
- ret
-; 3246
-
-.CopyTilemapAtOnce: ; 3246
- ld a, [hBGMapMode]
- push af
- xor a
- ld [hBGMapMode], a
-
- ld a, [hMapAnims]
- push af
- xor a
- ld [hMapAnims], a
-
-.wait
- ld a, [rLY]
- cp $7f
- jr c, .wait
-
- di
- ld a, BANK(vTiles3)
- ld [rVBK], a
- hlcoord 0, 0, wAttrMap
- call .StackPointerMagic
- ld a, BANK(vTiles0)
- ld [rVBK], a
- hlcoord 0, 0
- call .StackPointerMagic
-
-.wait2
- ld a, [rLY]
- cp $7f
- jr c, .wait2
- ei
-
- pop af
- ld [hMapAnims], a
- pop af
- ld [hBGMapMode], a
- ret
-; 327b
-
-.StackPointerMagic: ; 327b
-; Copy all tiles to vBGMap
- ld [hSPBuffer], sp
- ld sp, hl
- ld a, [hBGMapAddress + 1]
- ld h, a
- ld l, 0
- ld a, SCREEN_HEIGHT
- ld [hTilesPerCycle], a
- ld b, 1 << 1 ; not in v/hblank
- ld c, LOW(rSTAT)
-
-.loop
-rept SCREEN_WIDTH / 2
- pop de
-; if in v/hblank, wait until not in v/hblank
-.loop\@
- ld a, [$ff00+c]
- and b
- jr nz, .loop\@
-; load BGMap0
- ld [hl], e
- inc l
- ld [hl], d
- inc l
-endr
-
- ld de, BG_MAP_WIDTH - SCREEN_WIDTH
- add hl, de
- ld a, [hTilesPerCycle]
- dec a
- ld [hTilesPerCycle], a
- jr nz, .loop
-
- ld a, [hSPBuffer]
- ld l, a
- ld a, [hSPBuffer + 1]
- ld h, a
- ld sp, hl
- ret
-; 32f9
-
-SetPalettes:: ; 32f9
-; Inits the Palettes
-; depending on the system the monochromes palettes or color palettes
- ld a, [hCGB]
- and a
- jr nz, .SetPalettesForGameBoyColor
- ld a, %11100100
- ld [rBGP], a
- ld a, %11010000
- ld [rOBP0], a
- ld [rOBP1], a
- ret
-
-.SetPalettesForGameBoyColor:
- push de
- ld a, %11100100
- call DmgToCgbBGPals
- lb de, %11100100, %11100100
- call DmgToCgbObjPals
- pop de
- ret
-; 3317
-
-ClearPalettes:: ; 3317
-; Make all palettes white
-
-; CGB: make all the palette colors white
- ld a, [hCGB]
- and a
- jr nz, .cgb
-
-; DMG: just change palettes to 0 (white)
- xor a
- ld [rBGP], a
- ld [rOBP0], a
- ld [rOBP1], a
- ret
-
-.cgb
- ld a, [rSVBK]
- push af
-
- ld a, BANK(wBGPals2)
- ld [rSVBK], a
-
-; Fill wBGPals2 and wOBPals2 with $ffff (white)
- ld hl, wBGPals2
- ld bc, 16 palettes
- ld a, $ff
- call ByteFill
-
- pop af
- ld [rSVBK], a
-
-; Request palette update
- ld a, 1
- ld [hCGBPalUpdate], a
- ret
-; 333e
-
-GetMemSGBLayout:: ; 333e
- ld b, SCGB_RAM
-GetSGBLayout:: ; 3340
-; load sgb packets unless dmg
-
- ld a, [hCGB]
- and a
- jr nz, .sgb
-
- ld a, [hSGB]
- and a
- ret z
-
-.sgb
- predef_jump LoadSGBLayout
-; 334e
-
SetHPPal:: ; 334e
; Set palette for hp bar pixel length e at hl.
call GetHPPal
@@ -769,634 +283,17 @@
; 3380
INCLUDE "home/pokedex_flags.asm"
-
INCLUDE "home/names.asm"
-
-ScrollingMenu:: ; 350c
- call CopyMenuData
- ld a, [hROMBank]
- push af
-
- ld a, BANK(_ScrollingMenu)
- rst Bankswitch
-
- call _InitScrollingMenu
- call .UpdatePalettes
- call _ScrollingMenu
-
- pop af
- rst Bankswitch
-
- ld a, [wMenuJoypad]
- ret
-; 3524
-
-.UpdatePalettes: ; 3524
- ld hl, wVramState
- bit 0, [hl]
- jp nz, UpdateTimePals
- jp SetPalettes
-; 352f
-
-InitScrollingMenu:: ; 352f
- ld a, [wMenuBorderTopCoord]
- dec a
- ld b, a
- ld a, [wMenuBorderBottomCoord]
- sub b
- ld d, a
- ld a, [wMenuBorderLeftCoord]
- dec a
- ld c, a
- ld a, [wMenuBorderRightCoord]
- sub c
- ld e, a
- push de
- call Coord2Tile
- pop bc
- jp TextBox
-; 354b
-
-JoyTextDelay_ForcehJoyDown:: ; 354b joypad
- call DelayFrame
-
- ld a, [hInMenu]
- push af
- ld a, $1
- ld [hInMenu], a
- call JoyTextDelay
- pop af
- ld [hInMenu], a
-
- ld a, [hJoyLast]
- and D_RIGHT + D_LEFT + D_UP + D_DOWN
- ld c, a
- ld a, [hJoyPressed]
- and A_BUTTON + B_BUTTON + SELECT + START
- or c
- ld c, a
- ret
-; 3567
-
-HandleStoneQueue:: ; 3567
- ld a, [hROMBank]
- push af
-
- call SwitchToMapScriptsBank
- call .WarpAction
-
- pop bc
- ld a, b
- rst Bankswitch
- ret
-; 3574
-
-.WarpAction: ; 3574
- ld hl, OBJECT_MAP_OBJECT_INDEX
- add hl, de
- ld a, [hl]
- cp $ff
- jr z, .nope
-
- ld l, a
- push hl
- call .IsObjectOnWarp
- pop hl
- jr nc, .nope
- ld d, a
- ld e, l
- call .IsObjectInStoneTable
- jr nc, .nope
- call CallMapScript
- farcall EnableScriptMode
- scf
- ret
-
-.nope
- and a
- ret
-; 3599
-
-.IsObjectOnWarp: ; 3599
- push de
-
- ld hl, OBJECT_NEXT_MAP_X
- add hl, de
- ld a, [hl]
- ld hl, OBJECT_NEXT_MAP_Y
- add hl, de
- ld e, [hl]
-
- sub 4
- ld d, a
- ld a, e
- sub 4
- ld e, a
- call .check_on_warp
-
- pop de
- ret
-; 35b0
-
-.check_on_warp ; 35b0
- ld hl, wCurrMapWarpsPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld a, [wCurrMapWarpCount]
- and a
- jr z, .nope2
-
-.loop
- push af
- ld a, [hl]
- cp e
- jr nz, .not_on_warp
- inc hl
- ld a, [hld]
- cp d
- jr nz, .not_on_warp
- jr .found_warp
-
-.not_on_warp
- ld a, 5
- add l
- ld l, a
- jr nc, .no_carry
- inc h
-.no_carry
-
- pop af
- dec a
- jr nz, .loop
-
-.nope2
- and a
- ret
-
-.found_warp
- pop af
- ld d, a
- ld a, [wCurrMapWarpCount]
- sub d
- inc a
- scf
- ret
-; 35de
-
-.IsObjectInStoneTable: ; 35de
- inc e
- ld hl, CMDQUEUE_ADDR
- add hl, bc
- ld a, [hli]
- ld h, [hl]
- ld l, a
-.loop2
- ld a, [hli]
- cp $ff
- jr z, .nope3
- cp d
- jr nz, .next_inc3
- ld a, [hli]
- cp e
- jr nz, .next_inc2
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jr .yes
-
-.next_inc3
- inc hl
-
-.next_inc2
- inc hl
- inc hl
- jr .loop2
-
-.nope3
- and a
- ret
-
-.yes
- scf
- ret
-; 3600
-
+INCLUDE "home/scrolling_menu.asm"
+INCLUDE "home/stone_queue.asm"
INCLUDE "home/trainers.asm"
-
-IsAPokemon:: ; 3741
-; Return carry if species a is not a Pokemon.
- and a
- jr z, .NotAPokemon
- cp EGG
- jr z, .Pokemon
- cp NUM_POKEMON + 1
- jr c, .Pokemon
-
-.NotAPokemon:
- scf
- ret
-
-.Pokemon:
- and a
- ret
-; 3750
-
-DrawBattleHPBar:: ; 3750
-; Draw an HP bar d tiles long at hl
-; Fill it up to e pixels
-
- push hl
- push de
- push bc
-
-; Place 'HP:'
- ld a, $60
- ld [hli], a
- ld a, $61
- ld [hli], a
-
-; Draw a template
- push hl
- ld a, $62 ; empty bar
-.template
- ld [hli], a
- dec d
- jr nz, .template
- ld a, $6b ; bar end
- add b
- ld [hl], a
- pop hl
-
-; Safety check # pixels
- ld a, e
- and a
- jr nz, .fill
- ld a, c
- and a
- jr z, .done
- ld e, 1
-
-.fill
-; Keep drawing tiles until pixel length is reached
- ld a, e
- sub TILE_WIDTH
- jr c, .lastbar
-
- ld e, a
- ld a, $6a ; full bar
- ld [hli], a
- ld a, e
- and a
- jr z, .done
- jr .fill
-
-.lastbar
- ld a, $62 ; empty bar
- add e ; + e
- ld [hl], a
-
-.done
- pop bc
- pop de
- pop hl
- ret
-; 3786
-
-PrepMonFrontpic:: ; 3786
- ld a, $1
- ld [wBoxAlignment], a
-
-_PrepMonFrontpic:: ; 378b
- ld a, [wCurPartySpecies]
- call IsAPokemon
- jr c, .not_pokemon
-
- push hl
- ld de, vTiles2
- predef GetMonFrontpic
- pop hl
- xor a
- ld [hGraphicStartTile], a
- lb bc, 7, 7
- predef PlaceGraphic
- xor a
- ld [wBoxAlignment], a
- ret
-
-.not_pokemon
- xor a
- ld [wBoxAlignment], a
- inc a
- ld [wCurPartySpecies], a
- ret
-; 37b6
-
+INCLUDE "home/mon_stats.asm"
INCLUDE "home/cry.asm"
-
-PrintLevel:: ; 382d
-; Print wTempMonLevel at hl
-
- ld a, [wTempMonLevel]
- ld [hl], "<LV>"
- inc hl
-
-; How many digits?
- ld c, 2
- cp 100 ; This is distinct from MAX_LEVEL.
- jr c, Print8BitNumRightAlign
-
-; 3-digit numbers overwrite the :L.
- dec hl
- inc c
- jr Print8BitNumRightAlign
-; 383d
-
-PrintLevel_Force3Digits:: ; 383d
-; Print :L and all 3 digits
- ld [hl], "<LV>"
- inc hl
- ld c, 3
-; 3842
-
-Print8BitNumRightAlign:: ; 3842
- ld [wd265], a
- ld de, wd265
- ld b, PRINTNUM_RIGHTALIGN | 1
- jp PrintNum
-; 384d
-
-Unreferenced_Function384d:: ; 384d
-; GetNthMove
- ld hl, wListMoves_MoveIndicesBuffer
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [hl]
- ret
-; 3856
-
-GetBaseData:: ; 3856
- push bc
- push de
- push hl
- ld a, [hROMBank]
- push af
- ld a, BANK(BaseData)
- rst Bankswitch
-
-; Egg doesn't have BaseData
- ld a, [wCurSpecies]
- cp EGG
- jr z, .egg
-
-; Get BaseData
- dec a
- ld bc, BASE_DATA_SIZE
- ld hl, BaseData
- call AddNTimes
- ld de, wCurBaseData
- ld bc, BASE_DATA_SIZE
- call CopyBytes
- jr .end
-
-.egg
-; ????
- ld de, UnknownEggPic
-
-; Sprite dimensions
- ld b, $55 ; 5x5
- ld hl, wBasePicSize
- ld [hl], b
-
-; ????
- ld hl, wBasePadding
- ld [hl], e
- inc hl
- ld [hl], d
- inc hl
- ld [hl], e
- inc hl
- ld [hl], d
- jr .end
-
-.end
-; Replace Pokedex # with species
- ld a, [wCurSpecies]
- ld [wBaseDexNo], a
-
- pop af
- rst Bankswitch
- pop hl
- pop de
- pop bc
- ret
-; 389c
-
-GetCurNick:: ; 389c
- ld a, [wCurPartyMon]
- ld hl, wPartyMonNicknames
-
-GetNick:: ; 38a2
-; Get nickname a from list hl.
-
- push hl
- push bc
-
- call SkipNames
- ld de, wStringBuffer1
-
- push de
- ld bc, MON_NAME_LENGTH
- call CopyBytes
- pop de
-
- callfar CheckNickErrors
-
- pop bc
- pop hl
- ret
-; 38bb
-
-PrintBCDNumber:: ; 38bb
-; function to print a BCD (Binary-coded decimal) number
-; de = address of BCD number
-; hl = destination address
-; c = flags and length
-; bit 7: if set, do not print leading zeroes
-; if unset, print leading zeroes
-; bit 6: if set, left-align the string (do not pad empty digits with spaces)
-; if unset, right-align the string
-; bit 5: if set, print currency symbol at the beginning of the string
-; if unset, do not print the currency symbol
-; bits 0-4: length of BCD number in bytes
-; Note that bits 5 and 7 are modified during execution. The above reflects
-; their meaning at the beginning of the functions's execution.
- ld b, c ; save flags in b
- res 7, c
- res 6, c
- res 5, c ; c now holds the length
- bit 5, b
- jr z, .loop
- bit 7, b
- jr nz, .loop ; skip currency symbol
- ld [hl], "¥"
- inc hl
-.loop
- ld a, [de]
- swap a
- call PrintBCDDigit ; print upper digit
- ld a, [de]
- call PrintBCDDigit ; print lower digit
- inc de
- dec c
- jr nz, .loop
- bit 7, b ; were any non-zero digits printed?
- jr z, .done ; if so, we are done
-.numberEqualsZero ; if every digit of the BCD number is zero
- bit 6, b ; left or right alignment?
- jr nz, .skipRightAlignmentAdjustment
- dec hl ; if the string is right-aligned, it needs to be moved back one space
-.skipRightAlignmentAdjustment
- bit 5, b
- jr z, .skipCurrencySymbol
- ld [hl], "¥" ; currency symbol
- inc hl
-.skipCurrencySymbol
- ld [hl], "0"
- call PrintLetterDelay
- inc hl
-.done
- ret
-; 0x38f2
-
-PrintBCDDigit:: ; 38f2
- and %00001111
- and a
- jr z, .zeroDigit
-.nonzeroDigit
- bit 7, b ; have any non-space characters been printed?
- jr z, .outputDigit
-; if bit 7 is set, then no numbers have been printed yet
- bit 5, b ; print the currency symbol?
- jr z, .skipCurrencySymbol
- ld [hl], "¥"
- inc hl
- res 5, b
-.skipCurrencySymbol
- res 7, b ; unset 7 to indicate that a nonzero digit has been reached
-.outputDigit
- add "0"
- ld [hli], a
- jp PrintLetterDelay
-
-.zeroDigit
- bit 7, b ; either printing leading zeroes or already reached a nonzero digit?
- jr z, .outputDigit ; if so, print a zero digit
- bit 6, b ; left or right alignment?
- ret nz
- ld a, " "
- ld [hli], a ; if right-aligned, "print" a space by advancing the pointer
- ret
-; 0x3917
-
-GetPartyParamLocation:: ; 3917
-; Get the location of parameter a from wCurPartyMon in hl
- push bc
- ld hl, wPartyMons
- ld c, a
- ld b, 0
- add hl, bc
- ld a, [wCurPartyMon]
- call GetPartyLocation
- pop bc
- ret
-; 3927
-
-GetPartyLocation:: ; 3927
-; Add the length of a PartyMon struct to hl a times.
- ld bc, PARTYMON_STRUCT_LENGTH
- jp AddNTimes
-; 392d
-
-Unreferenced_Function392d:: ; 392d
-; GetDexNumber
-; Probably used in gen 1 to convert index number to dex number
-; Not required in gen 2 because index number == dex number
- push hl
- ld a, b
- dec a
- ld b, 0
- add hl, bc
- ld hl, BaseData + BASE_DEX_NO
- ld bc, BASE_DATA_SIZE
- call AddNTimes
- ld a, BANK(BaseData)
- call GetFarHalfword
- ld b, l
- ld c, h
- pop hl
- ret
-; 3945
-
+INCLUDE "home/print_level.asm"
+INCLUDE "home/mon_data.asm"
+INCLUDE "home/print_bcd.asm"
+INCLUDE "home/mon_data_2.asm"
INCLUDE "home/battle.asm"
-
-PushLYOverrides:: ; 3b0c
-
- ld a, [hLCDCPointer]
- and a
- ret z
-
- ld a, LOW(wLYOverridesBackup)
- ld [wRequested2bppSource], a
- ld a, HIGH(wLYOverridesBackup)
- ld [wRequested2bppSource + 1], a
-
- ld a, LOW(wLYOverrides)
- ld [wRequested2bppDest], a
- ld a, HIGH(wLYOverrides)
- ld [wRequested2bppDest + 1], a
-
- ld a, (wLYOverridesEnd - wLYOverrides) / 16
- ld [wRequested2bpp], a
- ret
-; 3b2a
-
-_InitSpriteAnimStruct:: ; 3b2a
-
- ld [wSpriteAnimIDBuffer], a
- ld a, [hROMBank]
- push af
-
- ld a, BANK(InitSpriteAnimStruct)
- rst Bankswitch
- ld a, [wSpriteAnimIDBuffer]
-
- call InitSpriteAnimStruct
-
- pop af
- rst Bankswitch
-
- ret
-; 3b3c
-
-ReinitSpriteAnimFrame:: ; 3b3c
-
- ld [wSpriteAnimIDBuffer], a
- ld a, [hROMBank]
- push af
-
- ld a, BANK(_ReinitSpriteAnimFrame)
- rst Bankswitch
- ld a, [wSpriteAnimIDBuffer]
-
- call _ReinitSpriteAnimFrame
-
- pop af
- rst Bankswitch
-
- ret
-; 3b4e
-
+INCLUDE "home/sprite_anims.asm"
INCLUDE "home/audio.asm"
INCLUDE "home/mobile.asm"
--- /dev/null
+++ b/home/clear_sprites.asm
@@ -1,0 +1,25 @@
+ClearSprites:: ; 300b
+; Erase OAM data
+ ld hl, wVirtualOAM
+ ld b, wVirtualOAMEnd - wVirtualOAM
+ xor a
+.loop
+ ld [hli], a
+ dec b
+ jr nz, .loop
+ ret
+; 3016
+
+HideSprites:: ; 3016
+; Set all OAM y-positions to 160 to hide them offscreen
+ ld hl, wVirtualOAMSprite00YCoord
+ ld de, SPRITEOAMSTRUCT_LENGTH
+ ld b, NUM_SPRITE_OAM_STRUCTS
+ ld a, SCREEN_WIDTH_PX
+.loop
+ ld [hl], a ; y
+ add hl, de
+ dec b
+ jr nz, .loop
+ ret
+; 3026
--- /dev/null
+++ b/home/copy_name.asm
@@ -1,0 +1,14 @@
+CopyName1:: ; 30d6
+; Copies the name from de to wStringBuffer2
+ ld hl, wStringBuffer2
+
+CopyName2:: ; 30d9
+; Copies the name from de to hl
+.loop
+ ld a, [de]
+ inc de
+ ld [hli], a
+ cp "@"
+ jr nz, .loop
+ ret
+; 30e1
--- /dev/null
+++ b/home/copy_tilemap.asm
@@ -1,0 +1,38 @@
+LoadTileMapToTempTileMap:: ; 309d
+; Load wTileMap into wTempTileMap
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wTempTileMap)
+ ld [rSVBK], a
+ hlcoord 0, 0
+ decoord 0, 0, wTempTileMap
+ ld bc, wTileMapEnd - wTileMap
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ ret
+; 30b4
+
+Call_LoadTempTileMapToTileMap:: ; 30b4
+ xor a
+ ld [hBGMapMode], a
+ call LoadTempTileMapToTileMap
+ ld a, 1
+ ld [hBGMapMode], a
+ ret
+; 30bf
+
+LoadTempTileMapToTileMap:: ; 30bf
+; Load wTempTileMap into wTileMap
+ ld a, [rSVBK]
+ push af
+ ld a, BANK(wTempTileMap)
+ ld [rSVBK], a
+ hlcoord 0, 0, wTempTileMap
+ decoord 0, 0
+ ld bc, wTileMapEnd - wTileMap
+ call CopyBytes
+ pop af
+ ld [rSVBK], a
+ ret
+; 30d6
--- a/home/map.asm
+++ b/home/map.asm
@@ -109,7 +109,7 @@
rst Bankswitch
call LoadMetatiles
- ld a, $60
+ ld a, "■"
hlcoord 0, 0
ld bc, SCREEN_WIDTH * SCREEN_HEIGHT
call ByteFill
@@ -129,13 +129,13 @@
ld e, a
ld a, [wOverworldMapAnchor + 1]
ld d, a
- ld hl, wMisc
- ld b, WMISC_HEIGHT / 4 ; 5
+ ld hl, wSurroundingTiles
+ ld b, SURROUNDING_HEIGHT / METATILE_WIDTH ; 5
.row
push de
push hl
- ld c, WMISC_WIDTH / 4 ; 6
+ ld c, SURROUNDING_WIDTH / METATILE_WIDTH ; 6
.col
push de
@@ -148,7 +148,7 @@
ld a, [wMapBorderBlock]
.ok
- ; Load the current wMisc address into de.
+ ; Load the current wSurroundingTiles address into de.
ld e, l
ld d, h
; Set hl to the address of the current metatile data ([wTilesetBlocksAddress] + (a) tiles).
@@ -169,20 +169,20 @@
ld h, a
; copy the 4x4 metatile
-rept 3
-rept 4
+rept METATILE_WIDTH + -1
+rept METATILE_WIDTH
ld a, [hli]
ld [de], a
inc de
endr
ld a, e
- add WMISC_WIDTH - 4
+ add SURROUNDING_WIDTH - METATILE_WIDTH
ld e, a
jr nc, .next\@
inc d
.next\@
endr
-rept 4
+rept METATILE_WIDTH
ld a, [hli]
ld [de], a
inc de
@@ -189,7 +189,7 @@
endr
; Next metatile
pop hl
- ld de, 4
+ ld de, METATILE_WIDTH
add hl, de
pop de
inc de
@@ -197,7 +197,7 @@
jp nz, .col
; Next metarow
pop hl
- ld de, WMISC_WIDTH * 4
+ ld de, SURROUNDING_WIDTH * METATILE_WIDTH
add hl, de
pop de
ld a, [wMapWidth]
@@ -260,10 +260,10 @@
.GetDestinationWarpNumber: ; 2266
ld a, [wPlayerStandingMapY]
- sub $4
+ sub 4
ld e, a
ld a, [wPlayerStandingMapX]
- sub $4
+ sub 4
ld d, a
ld a, [wCurrMapWarpCount]
and a
@@ -732,8 +732,8 @@
; 24cd
LoadBlockData:: ; 24cd
- ld hl, wOverworldMap
- ld bc, wOverworldMapEnd - wOverworldMap
+ ld hl, wOverworldMapBlocks
+ ld bc, wOverworldMapBlocksEnd - wOverworldMapBlocks
ld a, 0
call ByteFill
call ChangeMap
@@ -747,7 +747,7 @@
ld a, [hROMBank]
push af
- ld hl, wOverworldMap
+ ld hl, wOverworldMapBlocks
ld a, [wMapWidth]
ld [hConnectedMapWidth], a
add $6
@@ -1454,8 +1454,8 @@
ld h, [hl]
ld l, a
ld de, wScreenSave
- ld c, $5
- ld b, $6
+ ld c, SCREEN_META_HEIGHT
+ ld b, SCREEN_META_WIDTH
.row
push bc
push hl
@@ -1467,9 +1467,9 @@
jr nz, .col
pop hl
ld a, [wMapWidth]
- add $6
+ add 6
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
pop bc
dec c
@@ -1498,10 +1498,10 @@
ret
.up
- ld de, wScreenSave + 6
+ ld de, wScreenSave + SCREEN_META_WIDTH
ld a, [hMapObjectIndexBuffer]
ld c, a
- ld b, $0
+ ld b, 0
add hl, bc
jr .vertical
@@ -1508,8 +1508,8 @@
.down
ld de, wScreenSave
.vertical
- ld b, 6
- ld c, 4
+ ld b, SCREEN_META_WIDTH
+ ld c, SCREEN_META_HEIGHT - 1
jr SaveScreen_LoadNeighbor
.left
@@ -1520,8 +1520,8 @@
.right
ld de, wScreenSave
.horizontal
- ld b, 5
- ld c, 5
+ ld b, SCREEN_META_WIDTH - 1
+ ld c, SCREEN_META_HEIGHT
jr SaveScreen_LoadNeighbor
LoadNeighboringBlockData:: ; 28e3
@@ -1533,8 +1533,8 @@
add 6
ld [hConnectionStripLength], a
ld de, wScreenSave
- ld b, 6
- ld c, 5
+ ld b, SCREEN_META_WIDTH
+ ld c, SCREEN_META_HEIGHT
SaveScreen_LoadNeighbor:: ; 28f7
.row
@@ -1816,7 +1816,7 @@
add 6
ld c, a
ld b, 0
- ld hl, wOverworldMap + 1
+ ld hl, wOverworldMapBlocks + 1
add hl, bc
ld a, e
srl a
--- /dev/null
+++ b/home/menu_window.asm
@@ -1,0 +1,257 @@
+PushWindow:: ; 1c00
+ callfar _PushWindow
+ ret
+; 1c07
+
+ExitMenu:: ; 0x1c07
+ push af
+ callfar _ExitMenu
+ pop af
+ ret
+
+InitVerticalMenuCursor:: ; 0x1c10
+ callfar _InitVerticalMenuCursor
+ ret
+
+CloseWindow:: ; 0x1c17
+ push af
+ call ExitMenu
+ call ApplyTilemap
+ call UpdateSprites
+ pop af
+ ret
+
+RestoreTileBackup:: ; 0x1c23
+ call MenuBoxCoord2Tile
+ call .copy
+ call MenuBoxCoord2Attr
+ call .copy
+ ret
+; 0x1c30
+
+.copy ; 0x1c30
+ call GetMenuBoxDims
+ inc b
+ inc c
+
+.row
+ push bc
+ push hl
+
+.col
+ ld a, [de]
+ ld [hli], a
+ dec de
+ dec c
+ jr nz, .col ; 0x1c3b $fa
+
+ pop hl
+ ld bc, SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .row ; 0x1c44 $ef
+
+ ret
+
+PopWindow:: ; 0x1c47
+ ld b, $10
+ ld de, wMenuFlags
+.loop
+ ld a, [hld]
+ ld [de], a
+ inc de
+ dec b
+ jr nz, .loop ; 0x1c50 $fa
+ ret
+
+GetMenuBoxDims:: ; 0x1c53
+ ld a, [wMenuBorderTopCoord] ; top
+ ld b, a
+ ld a, [wMenuBorderBottomCoord] ; bottom
+ sub b
+ ld b, a
+ ld a, [wMenuBorderLeftCoord] ; left
+ ld c, a
+ ld a, [wMenuBorderRightCoord] ; right
+ sub c
+ ld c, a
+ ret
+; 0x1c66
+
+CopyMenuData:: ; 1c66
+ push hl
+ push de
+ push bc
+ push af
+ ld hl, wMenuDataPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld de, wMenuDataFlags
+ ld bc, wMenuDataEnd - wMenuDataFlags
+ call CopyBytes
+ pop af
+ pop bc
+ pop de
+ pop hl
+ ret
+; 1c7e
+
+GetWindowStackTop:: ; 1c7e
+ ld hl, wWindowStackPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ inc hl
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ret
+; 1c89
+
+PlaceVerticalMenuItems:: ; 1c89
+ call CopyMenuData
+ ld hl, wMenuDataPointer
+ ld e, [hl]
+ inc hl
+ ld d, [hl]
+ call GetMenuTextStartCoord
+ call Coord2Tile ; hl now contains the tilemap address where we will start printing text.
+ inc de
+ ld a, [de] ; Number of items
+ inc de
+ ld b, a
+.loop
+ push bc
+ call PlaceString
+ inc de
+ ld bc, 2 * SCREEN_WIDTH
+ add hl, bc
+ pop bc
+ dec b
+ jr nz, .loop
+
+ ld a, [wMenuDataFlags]
+ bit 4, a
+ ret z
+
+ call MenuBoxCoord2Tile
+ ld a, [de]
+ ld c, a
+ inc de
+ ld b, $0
+ add hl, bc
+ jp PlaceString
+; 1cbb
+
+MenuBox:: ; 1cbb
+ call MenuBoxCoord2Tile
+ call GetMenuBoxDims
+ dec b
+ dec c
+ jp TextBox
+; 1cc6
+
+GetMenuTextStartCoord:: ; 1cc6
+ ld a, [wMenuBorderTopCoord]
+ ld b, a
+ inc b
+ ld a, [wMenuBorderLeftCoord]
+ ld c, a
+ inc c
+; bit 6: if not set, leave extra room on top
+ ld a, [wMenuDataFlags]
+ bit 6, a
+ jr nz, .bit_6_set
+ inc b
+
+.bit_6_set
+; bit 7: if set, leave extra room on the left
+ ld a, [wMenuDataFlags]
+ bit 7, a
+ jr z, .bit_7_clear
+ inc c
+
+.bit_7_clear
+ ret
+; 1ce1
+
+ClearMenuBoxInterior:: ; 1ce1
+ call MenuBoxCoord2Tile
+ ld bc, SCREEN_WIDTH + 1
+ add hl, bc
+ call GetMenuBoxDims
+ dec b
+ dec c
+ call ClearBox
+ ret
+; 1cf1
+
+ClearWholeMenuBox:: ; 1cf1
+ call MenuBoxCoord2Tile
+ call GetMenuBoxDims
+ inc c
+ inc b
+ call ClearBox
+ ret
+; 1cfd
+
+
+MenuBoxCoord2Tile:: ; 1cfd
+ ld a, [wMenuBorderLeftCoord]
+ ld c, a
+ ld a, [wMenuBorderTopCoord]
+ ld b, a
+; 1d05
+
+
+Coord2Tile:: ; 1d05
+; Return the address of wTileMap(c, b) in hl.
+ xor a
+ ld h, a
+ ld l, b
+ ld a, c
+ ld b, h
+ ld c, l
+ add hl, hl
+ add hl, hl
+ add hl, bc
+ add hl, hl
+ add hl, hl
+ ld c, a
+ xor a
+ ld b, a
+ add hl, bc
+ bccoord 0, 0
+ add hl, bc
+ ret
+; 1d19
+
+MenuBoxCoord2Attr:: ; 1d19
+ ld a, [wMenuBorderLeftCoord]
+ ld c, a
+ ld a, [wMenuBorderTopCoord]
+ ld b, a
+
+Coord2Attr:: ; 1d21
+; Return the address of wAttrMap(c, b) in hl.
+ xor a
+ ld h, a
+ ld l, b
+ ld a, c
+ ld b, h
+ ld c, l
+ add hl, hl
+ add hl, hl
+ add hl, bc
+ add hl, hl
+ add hl, hl
+ ld c, a
+ xor a
+ ld b, a
+ add hl, bc
+ bccoord 0, 0, wAttrMap
+ add hl, bc
+ ret
+; 1d35
--- /dev/null
+++ b/home/mon_data.asm
@@ -1,0 +1,90 @@
+Unreferenced_GetNthMove:: ; 384d
+ ld hl, wListMoves_MoveIndicesBuffer
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [hl]
+ ret
+; 3856
+
+GetBaseData:: ; 3856
+ push bc
+ push de
+ push hl
+ ld a, [hROMBank]
+ push af
+ ld a, BANK(BaseData)
+ rst Bankswitch
+
+; Egg doesn't have BaseData
+ ld a, [wCurSpecies]
+ cp EGG
+ jr z, .egg
+
+; Get BaseData
+ dec a
+ ld bc, BASE_DATA_SIZE
+ ld hl, BaseData
+ call AddNTimes
+ ld de, wCurBaseData
+ ld bc, BASE_DATA_SIZE
+ call CopyBytes
+ jr .end
+
+.egg
+; ????
+ ld de, UnknownEggPic
+
+; Sprite dimensions
+ ld b, $55 ; 5x5
+ ld hl, wBasePicSize
+ ld [hl], b
+
+; ????
+ ld hl, wBasePadding
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ inc hl
+ ld [hl], e
+ inc hl
+ ld [hl], d
+ jr .end
+
+.end
+; Replace Pokedex # with species
+ ld a, [wCurSpecies]
+ ld [wBaseDexNo], a
+
+ pop af
+ rst Bankswitch
+ pop hl
+ pop de
+ pop bc
+ ret
+; 389c
+
+GetCurNick:: ; 389c
+ ld a, [wCurPartyMon]
+ ld hl, wPartyMonNicknames
+
+GetNick:: ; 38a2
+; Get nickname a from list hl.
+
+ push hl
+ push bc
+
+ call SkipNames
+ ld de, wStringBuffer1
+
+ push de
+ ld bc, MON_NAME_LENGTH
+ call CopyBytes
+ pop de
+
+ callfar CorrectNickErrors
+
+ pop bc
+ pop hl
+ ret
+; 38bb
--- /dev/null
+++ b/home/mon_data_2.asm
@@ -1,0 +1,37 @@
+GetPartyParamLocation:: ; 3917
+; Get the location of parameter a from wCurPartyMon in hl
+ push bc
+ ld hl, wPartyMons
+ ld c, a
+ ld b, 0
+ add hl, bc
+ ld a, [wCurPartyMon]
+ call GetPartyLocation
+ pop bc
+ ret
+; 3927
+
+GetPartyLocation:: ; 3927
+; Add the length of a PartyMon struct to hl a times.
+ ld bc, PARTYMON_STRUCT_LENGTH
+ jp AddNTimes
+; 392d
+
+Unreferenced_GetDexNumber:: ; 392d
+; Probably used in gen 1 to convert index number to dex number
+; Not required in gen 2 because index number == dex number
+ push hl
+ ld a, b
+ dec a
+ ld b, 0
+ add hl, bc
+ ld hl, BaseData + BASE_DEX_NO
+ ld bc, BASE_DATA_SIZE
+ call AddNTimes
+ ld a, BANK(BaseData)
+ call GetFarHalfword
+ ld b, l
+ ld c, h
+ pop hl
+ ret
+; 3945
--- /dev/null
+++ b/home/mon_stats.asm
@@ -1,0 +1,107 @@
+IsAPokemon:: ; 3741
+; Return carry if species a is not a Pokemon.
+ and a
+ jr z, .NotAPokemon
+ cp EGG
+ jr z, .Pokemon
+ cp NUM_POKEMON + 1
+ jr c, .Pokemon
+
+.NotAPokemon:
+ scf
+ ret
+
+.Pokemon:
+ and a
+ ret
+; 3750
+
+DrawBattleHPBar:: ; 3750
+; Draw an HP bar d tiles long at hl
+; Fill it up to e pixels
+
+ push hl
+ push de
+ push bc
+
+; Place 'HP:'
+ ld a, $60
+ ld [hli], a
+ ld a, $61
+ ld [hli], a
+
+; Draw a template
+ push hl
+ ld a, $62 ; empty bar
+.template
+ ld [hli], a
+ dec d
+ jr nz, .template
+ ld a, $6b ; bar end
+ add b
+ ld [hl], a
+ pop hl
+
+; Safety check # pixels
+ ld a, e
+ and a
+ jr nz, .fill
+ ld a, c
+ and a
+ jr z, .done
+ ld e, 1
+
+.fill
+; Keep drawing tiles until pixel length is reached
+ ld a, e
+ sub TILE_WIDTH
+ jr c, .lastbar
+
+ ld e, a
+ ld a, $6a ; full bar
+ ld [hli], a
+ ld a, e
+ and a
+ jr z, .done
+ jr .fill
+
+.lastbar
+ ld a, $62 ; empty bar
+ add e ; + e
+ ld [hl], a
+
+.done
+ pop bc
+ pop de
+ pop hl
+ ret
+; 3786
+
+PrepMonFrontpic:: ; 3786
+ ld a, $1
+ ld [wBoxAlignment], a
+
+_PrepMonFrontpic:: ; 378b
+ ld a, [wCurPartySpecies]
+ call IsAPokemon
+ jr c, .not_pokemon
+
+ push hl
+ ld de, vTiles2
+ predef GetMonFrontpic
+ pop hl
+ xor a
+ ld [hGraphicStartTile], a
+ lb bc, 7, 7
+ predef PlaceGraphic
+ xor a
+ ld [wBoxAlignment], a
+ ret
+
+.not_pokemon
+ xor a
+ ld [wBoxAlignment], a
+ inc a
+ ld [wCurPartySpecies], a
+ ret
+; 37b6
--- /dev/null
+++ b/home/print_bcd.asm
@@ -1,0 +1,81 @@
+PrintBCDNumber:: ; 38bb
+; function to print a BCD (Binary-coded decimal) number
+; de = address of BCD number
+; hl = destination address
+; c = flags and length
+; bit 7: if set, do not print leading zeroes
+; if unset, print leading zeroes
+; bit 6: if set, left-align the string (do not pad empty digits with spaces)
+; if unset, right-align the string
+; bit 5: if set, print currency symbol at the beginning of the string
+; if unset, do not print the currency symbol
+; bits 0-4: length of BCD number in bytes
+; Note that bits 5 and 7 are modified during execution. The above reflects
+; their meaning at the beginning of the functions's execution.
+ ld b, c ; save flags in b
+ res 7, c
+ res 6, c
+ res 5, c ; c now holds the length
+ bit 5, b
+ jr z, .loop
+ bit 7, b
+ jr nz, .loop ; skip currency symbol
+ ld [hl], "¥"
+ inc hl
+.loop
+ ld a, [de]
+ swap a
+ call PrintBCDDigit ; print upper digit
+ ld a, [de]
+ call PrintBCDDigit ; print lower digit
+ inc de
+ dec c
+ jr nz, .loop
+ bit 7, b ; were any non-zero digits printed?
+ jr z, .done ; if so, we are done
+.numberEqualsZero ; if every digit of the BCD number is zero
+ bit 6, b ; left or right alignment?
+ jr nz, .skipRightAlignmentAdjustment
+ dec hl ; if the string is right-aligned, it needs to be moved back one space
+.skipRightAlignmentAdjustment
+ bit 5, b
+ jr z, .skipCurrencySymbol
+ ld [hl], "¥" ; currency symbol
+ inc hl
+.skipCurrencySymbol
+ ld [hl], "0"
+ call PrintLetterDelay
+ inc hl
+.done
+ ret
+; 0x38f2
+
+PrintBCDDigit:: ; 38f2
+ and %00001111
+ and a
+ jr z, .zeroDigit
+.nonzeroDigit
+ bit 7, b ; have any non-space characters been printed?
+ jr z, .outputDigit
+; if bit 7 is set, then no numbers have been printed yet
+ bit 5, b ; print the currency symbol?
+ jr z, .skipCurrencySymbol
+ ld [hl], "¥"
+ inc hl
+ res 5, b
+.skipCurrencySymbol
+ res 7, b ; unset 7 to indicate that a nonzero digit has been reached
+.outputDigit
+ add "0"
+ ld [hli], a
+ jp PrintLetterDelay
+
+.zeroDigit
+ bit 7, b ; either printing leading zeroes or already reached a nonzero digit?
+ jr z, .outputDigit ; if so, print a zero digit
+ bit 6, b ; left or right alignment?
+ ret nz
+ ld a, " "
+ ld [hli], a ; if right-aligned, "print" a space by advancing the pointer
+ ret
+; 0x3917
--- /dev/null
+++ b/home/print_level.asm
@@ -1,0 +1,31 @@
+PrintLevel:: ; 382d
+; Print wTempMonLevel at hl
+
+ ld a, [wTempMonLevel]
+ ld [hl], "<LV>"
+ inc hl
+
+; How many digits?
+ ld c, 2
+ cp 100 ; This is distinct from MAX_LEVEL.
+ jr c, Print8BitNumRightAlign
+
+; 3-digit numbers overwrite the :L.
+ dec hl
+ inc c
+ jr Print8BitNumRightAlign
+; 383d
+
+PrintLevel_Force3Digits:: ; 383d
+; Print :L and all 3 digits
+ ld [hl], "<LV>"
+ inc hl
+ ld c, 3
+; 3842
+
+Print8BitNumRightAlign:: ; 3842
+ ld [wd265], a
+ ld de, wd265
+ ld b, PRINTNUM_RIGHTALIGN | 1
+ jp PrintNum
+; 384d
--- /dev/null
+++ b/home/print_text.asm
@@ -1,0 +1,125 @@
+PrintLetterDelay:: ; 313d
+; Wait before printing the next letter.
+
+; The text speed setting in wOptions is actually a frame count:
+; fast: 1 frame
+; mid: 3 frames
+; slow: 5 frames
+
+; wTextBoxFlags[!0] and A or B override text speed with a one-frame delay.
+; wOptions[4] and wTextBoxFlags[!1] disable the delay.
+
+ ld a, [wOptions]
+ bit NO_TEXT_SCROLL, a
+ ret nz
+
+; non-scrolling text?
+ ld a, [wTextBoxFlags]
+ bit NO_TEXT_DELAY_F, a
+ ret z
+
+ push hl
+ push de
+ push bc
+
+ ld hl, hOAMUpdate
+ ld a, [hl]
+ push af
+
+; orginally turned oam update off...
+; ld a, 1
+ ld [hl], a
+
+; force fast scroll?
+ ld a, [wTextBoxFlags]
+ bit FAST_TEXT_DELAY_F, a
+ jr z, .fast
+
+; text speed
+ ld a, [wOptions]
+ and %111
+ jr .updatedelay
+
+.fast
+ ld a, TEXT_DELAY_FAST
+
+.updatedelay
+ ld [wTextDelayFrames], a
+
+.checkjoypad
+ call GetJoypad
+
+; input override
+ ld a, [wDisableTextAcceleration]
+ and a
+ jr nz, .wait
+
+; Wait one frame if holding A or B.
+ ld a, [hJoyDown]
+ bit A_BUTTON_F, a
+ jr z, .checkb
+ jr .delay
+.checkb
+ bit B_BUTTON_F, a
+ jr z, .wait
+
+.delay
+ call DelayFrame
+ jr .end
+
+.wait
+ ld a, [wTextDelayFrames]
+ and a
+ jr nz, .checkjoypad
+
+.end
+ pop af
+ ld [hOAMUpdate], a
+ pop bc
+ pop de
+ pop hl
+ ret
+; 318c
+
+CopyDataUntil:: ; 318c
+; Copy [hl .. bc) to de.
+
+; In other words, the source data is
+; from hl up to but not including bc,
+; and the destination is de.
+
+ ld a, [hli]
+ ld [de], a
+ inc de
+ ld a, h
+ cp b
+ jr nz, CopyDataUntil
+ ld a, l
+ cp c
+ jr nz, CopyDataUntil
+ ret
+; 0x3198
+
+PrintNum:: ; 3198
+ homecall _PrintNum
+ ret
+; 31a4
+
+MobilePrintNum:: ; 31a4
+ homecall _MobilePrintNum
+ ret
+; 31b0
+
+FarPrintText:: ; 31b0
+ ld [hBuffer], a
+ ld a, [hROMBank]
+ push af
+ ld a, [hBuffer]
+ rst Bankswitch
+
+ call PrintText
+
+ pop af
+ rst Bankswitch
+ ret
+; 31be
--- /dev/null
+++ b/home/region.asm
@@ -1,0 +1,33 @@
+IsInJohto:: ; 2f17
+; Return 0 if the player is in Johto, and 1 in Kanto.
+
+ ld a, [wMapGroup]
+ ld b, a
+ ld a, [wMapNumber]
+ ld c, a
+ call GetWorldMapLocation
+
+ cp FAST_SHIP
+ jr z, .Johto
+
+ cp SPECIAL_MAP
+ jr nz, .CheckRegion
+
+ ld a, [wBackupMapGroup]
+ ld b, a
+ ld a, [wBackupMapNumber]
+ ld c, a
+ call GetWorldMapLocation
+
+.CheckRegion:
+ cp KANTO_LANDMARK
+ jr nc, .Kanto
+
+.Johto:
+ xor a
+ ret
+
+.Kanto:
+ ld a, 1
+ ret
+; 2f3e
--- /dev/null
+++ b/home/scrolling_menu.asm
@@ -1,0 +1,65 @@
+ScrollingMenu:: ; 350c
+ call CopyMenuData
+ ld a, [hROMBank]
+ push af
+
+ ld a, BANK(_ScrollingMenu)
+ rst Bankswitch
+
+ call _InitScrollingMenu
+ call .UpdatePalettes
+ call _ScrollingMenu
+
+ pop af
+ rst Bankswitch
+
+ ld a, [wMenuJoypad]
+ ret
+; 3524
+
+.UpdatePalettes: ; 3524
+ ld hl, wVramState
+ bit 0, [hl]
+ jp nz, UpdateTimePals
+ jp SetPalettes
+; 352f
+
+InitScrollingMenu:: ; 352f
+ ld a, [wMenuBorderTopCoord]
+ dec a
+ ld b, a
+ ld a, [wMenuBorderBottomCoord]
+ sub b
+ ld d, a
+ ld a, [wMenuBorderLeftCoord]
+ dec a
+ ld c, a
+ ld a, [wMenuBorderRightCoord]
+ sub c
+ ld e, a
+ push de
+ call Coord2Tile
+ pop bc
+ jp TextBox
+; 354b
+
+JoyTextDelay_ForcehJoyDown:: ; 354b joypad
+ call DelayFrame
+
+ ld a, [hInMenu]
+ push af
+ ld a, $1
+ ld [hInMenu], a
+ call JoyTextDelay
+ pop af
+ ld [hInMenu], a
+
+ ld a, [hJoyLast]
+ and D_RIGHT + D_LEFT + D_UP + D_DOWN
+ ld c, a
+ ld a, [hJoyPressed]
+ and A_BUTTON + B_BUTTON + SELECT + START
+ or c
+ ld c, a
+ ret
+; 3567
--- /dev/null
+++ b/home/sprite_anims.asm
@@ -1,0 +1,53 @@
+PushLYOverrides:: ; 3b0c
+ ld a, [hLCDCPointer]
+ and a
+ ret z
+
+ ld a, LOW(wLYOverridesBackup)
+ ld [wRequested2bppSource], a
+ ld a, HIGH(wLYOverridesBackup)
+ ld [wRequested2bppSource + 1], a
+
+ ld a, LOW(wLYOverrides)
+ ld [wRequested2bppDest], a
+ ld a, HIGH(wLYOverrides)
+ ld [wRequested2bppDest + 1], a
+
+ ld a, (wLYOverridesEnd - wLYOverrides) / 16
+ ld [wRequested2bpp], a
+ ret
+; 3b2a
+
+_InitSpriteAnimStruct:: ; 3b2a
+ ld [wSpriteAnimIDBuffer], a
+ ld a, [hROMBank]
+ push af
+
+ ld a, BANK(InitSpriteAnimStruct)
+ rst Bankswitch
+ ld a, [wSpriteAnimIDBuffer]
+
+ call InitSpriteAnimStruct
+
+ pop af
+ rst Bankswitch
+
+ ret
+; 3b3c
+
+ReinitSpriteAnimFrame:: ; 3b3c
+ ld [wSpriteAnimIDBuffer], a
+ ld a, [hROMBank]
+ push af
+
+ ld a, BANK(_ReinitSpriteAnimFrame)
+ rst Bankswitch
+ ld a, [wSpriteAnimIDBuffer]
+
+ call _ReinitSpriteAnimFrame
+
+ pop af
+ rst Bankswitch
+
+ ret
+; 3b4e
--- /dev/null
+++ b/home/sprite_updates.asm
@@ -1,0 +1,21 @@
+DisableSpriteUpdates:: ; 0x2ed3
+ xor a
+ ld [hMapAnims], a
+ ld a, [wVramState]
+ res 0, a
+ ld [wVramState], a
+ ld a, $0
+ ld [wSpriteUpdatesEnabled], a
+ ret
+; 0x2ee4
+
+EnableSpriteUpdates:: ; 2ee4
+ ld a, $1
+ ld [wSpriteUpdatesEnabled], a
+ ld a, [wVramState]
+ set 0, a
+ ld [wVramState], a
+ ld a, $1
+ ld [hMapAnims], a
+ ret
+; 2ef6
--- /dev/null
+++ b/home/stone_queue.asm
@@ -1,0 +1,143 @@
+HandleStoneQueue:: ; 3567
+ ld a, [hROMBank]
+ push af
+
+ call SwitchToMapScriptsBank
+ call .WarpAction
+
+ pop bc
+ ld a, b
+ rst Bankswitch
+ ret
+; 3574
+
+.WarpAction: ; 3574
+ ld hl, OBJECT_MAP_OBJECT_INDEX
+ add hl, de
+ ld a, [hl]
+ cp $ff
+ jr z, .nope
+
+ ld l, a
+ push hl
+ call .IsObjectOnWarp
+ pop hl
+ jr nc, .nope
+ ld d, a
+ ld e, l
+ call .IsObjectInStoneTable
+ jr nc, .nope
+ call CallMapScript
+ farcall EnableScriptMode
+ scf
+ ret
+
+.nope
+ and a
+ ret
+; 3599
+
+.IsObjectOnWarp: ; 3599
+ push de
+
+ ld hl, OBJECT_NEXT_MAP_X
+ add hl, de
+ ld a, [hl]
+ ld hl, OBJECT_NEXT_MAP_Y
+ add hl, de
+ ld e, [hl]
+
+ sub 4
+ ld d, a
+ ld a, e
+ sub 4
+ ld e, a
+ call .check_on_warp
+
+ pop de
+ ret
+; 35b0
+
+.check_on_warp ; 35b0
+ ld hl, wCurrMapWarpsPointer
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ ld a, [wCurrMapWarpCount]
+ and a
+ jr z, .nope2
+
+.loop
+ push af
+ ld a, [hl]
+ cp e
+ jr nz, .not_on_warp
+ inc hl
+ ld a, [hld]
+ cp d
+ jr nz, .not_on_warp
+ jr .found_warp
+
+.not_on_warp
+ ld a, 5
+ add l
+ ld l, a
+ jr nc, .no_carry
+ inc h
+.no_carry
+
+ pop af
+ dec a
+ jr nz, .loop
+
+.nope2
+ and a
+ ret
+
+.found_warp
+ pop af
+ ld d, a
+ ld a, [wCurrMapWarpCount]
+ sub d
+ inc a
+ scf
+ ret
+; 35de
+
+.IsObjectInStoneTable: ; 35de
+ inc e
+ ld hl, CMDQUEUE_ADDR
+ add hl, bc
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+.loop2
+ ld a, [hli]
+ cp $ff
+ jr z, .nope3
+ cp d
+ jr nz, .next_inc3
+ ld a, [hli]
+ cp e
+ jr nz, .next_inc2
+ ld a, [hli]
+ ld h, [hl]
+ ld l, a
+ jr .yes
+
+.next_inc3
+ inc hl
+
+.next_inc2
+ inc hl
+ inc hl
+ jr .loop2
+
+.nope3
+ and a
+ ret
+
+.yes
+ scf
+ ret
+; 3600
--- a/home/tilemap.asm
+++ b/home/tilemap.asm
@@ -1,257 +1,229 @@
-PushWindow:: ; 1c00
- callfar _PushWindow
+ClearBGPalettes:: ; 31f3
+ call ClearPalettes
+WaitBGMap:: ; 31f6
+; Tell VBlank to update BG Map
+ ld a, 1 ; BG Map 0 tiles
+ ld [hBGMapMode], a
+; Wait for it to do its magic
+ ld c, 4
+ call DelayFrames
ret
-; 1c07
+; 3200
-ExitMenu:: ; 0x1c07
- push af
- callfar _ExitMenu
- pop af
- ret
+WaitBGMap2:: ; 0x3200
+ ld a, [hCGB]
+ and a
+ jr z, .bg0
-InitVerticalMenuCursor:: ; 0x1c10
- callfar _InitVerticalMenuCursor
- ret
+ ld a, 2
+ ld [hBGMapMode], a
+ ld c, 4
+ call DelayFrames
-CloseWindow:: ; 0x1c17
- push af
- call ExitMenu
- call ApplyTilemap
- call UpdateSprites
- pop af
+.bg0
+ ld a, 1
+ ld [hBGMapMode], a
+ ld c, 4
+ call DelayFrames
ret
+; 0x3218
-RestoreTileBackup:: ; 0x1c23
- call MenuBoxCoord2Tile
- call .copy
- call MenuBoxCoord2Attr
- call .copy
+IsCGB:: ; 3218
+ ld a, [hCGB]
+ and a
ret
-; 0x1c30
+; 321c
-.copy ; 0x1c30
- call GetMenuBoxDims
- inc b
- inc c
+ApplyTilemap:: ; 321c
+ ld a, [hCGB]
+ and a
+ jr z, .dmg
-.row
- push bc
- push hl
+ ld a, [wSpriteUpdatesEnabled]
+ cp 0
+ jr z, .dmg
-.col
- ld a, [de]
- ld [hli], a
- dec de
- dec c
- jr nz, .col ; 0x1c3b $fa
+ ld a, 1
+ ld [hBGMapMode], a
+ jr CopyTilemapAtOnce
- pop hl
- ld bc, SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .row ; 0x1c44 $ef
-
+.dmg
+; WaitBGMap
+ ld a, 1
+ ld [hBGMapMode], a
+ ld c, 4
+ call DelayFrames
ret
+; 3238
-PopWindow:: ; 0x1c47
- ld b, $10
- ld de, wMenuFlags
-.loop
- ld a, [hld]
- ld [de], a
- inc de
- dec b
- jr nz, .loop ; 0x1c50 $fa
- ret
+CGBOnly_CopyTilemapAtOnce:: ; 3238
+ ld a, [hCGB]
+ and a
+ jr z, WaitBGMap
-GetMenuBoxDims:: ; 0x1c53
- ld a, [wMenuBorderTopCoord] ; top
- ld b, a
- ld a, [wMenuBorderBottomCoord] ; bottom
- sub b
- ld b, a
- ld a, [wMenuBorderLeftCoord] ; left
- ld c, a
- ld a, [wMenuBorderRightCoord] ; right
- sub c
- ld c, a
+CopyTilemapAtOnce:: ; 323d
+ jr .CopyTilemapAtOnce
+; 323f
+
+; unused
+ farcall HDMATransferAttrMapAndTileMapToWRAMBank3
ret
-; 0x1c66
+; 3246
-CopyMenuData:: ; 1c66
- push hl
- push de
- push bc
+.CopyTilemapAtOnce: ; 3246
+ ld a, [hBGMapMode]
push af
- ld hl, wMenuDataPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ld de, wMenuDataFlags
- ld bc, wMenuDataEnd - wMenuDataFlags
- call CopyBytes
- pop af
- pop bc
- pop de
- pop hl
- ret
-; 1c7e
+ xor a
+ ld [hBGMapMode], a
-GetWindowStackTop:: ; 1c7e
- ld hl, wWindowStackPointer
- ld a, [hli]
- ld h, [hl]
- ld l, a
- inc hl
- ld a, [hli]
- ld h, [hl]
- ld l, a
- ret
-; 1c89
+ ld a, [hMapAnims]
+ push af
+ xor a
+ ld [hMapAnims], a
-PlaceVerticalMenuItems:: ; 1c89
- call CopyMenuData
- ld hl, wMenuDataPointer
- ld e, [hl]
- inc hl
- ld d, [hl]
- call GetMenuTextStartCoord
- call Coord2Tile ; hl now contains the tilemap address where we will start printing text.
- inc de
- ld a, [de] ; Number of items
- inc de
- ld b, a
-.loop
- push bc
- call PlaceString
- inc de
- ld bc, 2 * SCREEN_WIDTH
- add hl, bc
- pop bc
- dec b
- jr nz, .loop
+.wait
+ ld a, [rLY]
+ cp $7f
+ jr c, .wait
- ld a, [wMenuDataFlags]
- bit 4, a
- ret z
+ di
+ ld a, BANK(vTiles3)
+ ld [rVBK], a
+ hlcoord 0, 0, wAttrMap
+ call .StackPointerMagic
+ ld a, BANK(vTiles0)
+ ld [rVBK], a
+ hlcoord 0, 0
+ call .StackPointerMagic
- call MenuBoxCoord2Tile
- ld a, [de]
- ld c, a
- inc de
- ld b, $0
- add hl, bc
- jp PlaceString
-; 1cbb
+.wait2
+ ld a, [rLY]
+ cp $7f
+ jr c, .wait2
+ ei
-MenuBox:: ; 1cbb
- call MenuBoxCoord2Tile
- call GetMenuBoxDims
- dec b
- dec c
- jp TextBox
-; 1cc6
+ pop af
+ ld [hMapAnims], a
+ pop af
+ ld [hBGMapMode], a
+ ret
+; 327b
-GetMenuTextStartCoord:: ; 1cc6
- ld a, [wMenuBorderTopCoord]
- ld b, a
- inc b
- ld a, [wMenuBorderLeftCoord]
- ld c, a
- inc c
-; bit 6: if not set, leave extra room on top
- ld a, [wMenuDataFlags]
- bit 6, a
- jr nz, .bit_6_set
- inc b
+.StackPointerMagic: ; 327b
+; Copy all tiles to vBGMap
+ ld [hSPBuffer], sp
+ ld sp, hl
+ ld a, [hBGMapAddress + 1]
+ ld h, a
+ ld l, 0
+ ld a, SCREEN_HEIGHT
+ ld [hTilesPerCycle], a
+ ld b, 1 << 1 ; not in v/hblank
+ ld c, LOW(rSTAT)
-.bit_6_set
-; bit 7: if set, leave extra room on the left
- ld a, [wMenuDataFlags]
- bit 7, a
- jr z, .bit_7_clear
- inc c
+.loop
+rept SCREEN_WIDTH / 2
+ pop de
+; if in v/hblank, wait until not in v/hblank
+.loop\@
+ ld a, [$ff00+c]
+ and b
+ jr nz, .loop\@
+; load BGMap0
+ ld [hl], e
+ inc l
+ ld [hl], d
+ inc l
+endr
-.bit_7_clear
+ ld de, BG_MAP_WIDTH - SCREEN_WIDTH
+ add hl, de
+ ld a, [hTilesPerCycle]
+ dec a
+ ld [hTilesPerCycle], a
+ jr nz, .loop
+
+ ld a, [hSPBuffer]
+ ld l, a
+ ld a, [hSPBuffer + 1]
+ ld h, a
+ ld sp, hl
ret
-; 1ce1
+; 32f9
-ClearMenuBoxInterior:: ; 1ce1
- call MenuBoxCoord2Tile
- ld bc, SCREEN_WIDTH + 1
- add hl, bc
- call GetMenuBoxDims
- dec b
- dec c
- call ClearBox
+SetPalettes:: ; 32f9
+; Inits the Palettes
+; depending on the system the monochromes palettes or color palettes
+ ld a, [hCGB]
+ and a
+ jr nz, .SetPalettesForGameBoyColor
+ ld a, %11100100
+ ld [rBGP], a
+ ld a, %11010000
+ ld [rOBP0], a
+ ld [rOBP1], a
ret
-; 1cf1
-ClearWholeMenuBox:: ; 1cf1
- call MenuBoxCoord2Tile
- call GetMenuBoxDims
- inc c
- inc b
- call ClearBox
+.SetPalettesForGameBoyColor:
+ push de
+ ld a, %11100100
+ call DmgToCgbBGPals
+ lb de, %11100100, %11100100
+ call DmgToCgbObjPals
+ pop de
ret
-; 1cfd
+; 3317
+ClearPalettes:: ; 3317
+; Make all palettes white
-MenuBoxCoord2Tile:: ; 1cfd
- ld a, [wMenuBorderLeftCoord]
- ld c, a
- ld a, [wMenuBorderTopCoord]
- ld b, a
-; 1d05
+; CGB: make all the palette colors white
+ ld a, [hCGB]
+ and a
+ jr nz, .cgb
-
-Coord2Tile:: ; 1d05
-; Return the address of wTileMap(c, b) in hl.
+; DMG: just change palettes to 0 (white)
xor a
- ld h, a
- ld l, b
- ld a, c
- ld b, h
- ld c, l
- add hl, hl
- add hl, hl
- add hl, bc
- add hl, hl
- add hl, hl
- ld c, a
- xor a
- ld b, a
- add hl, bc
- bccoord 0, 0
- add hl, bc
+ ld [rBGP], a
+ ld [rOBP0], a
+ ld [rOBP1], a
ret
-; 1d19
-MenuBoxCoord2Attr:: ; 1d19
- ld a, [wMenuBorderLeftCoord]
- ld c, a
- ld a, [wMenuBorderTopCoord]
- ld b, a
+.cgb
+ ld a, [rSVBK]
+ push af
-Coord2Attr:: ; 1d21
-; Return the address of wAttrMap(c, b) in hl.
- xor a
- ld h, a
- ld l, b
- ld a, c
- ld b, h
- ld c, l
- add hl, hl
- add hl, hl
- add hl, bc
- add hl, hl
- add hl, hl
- ld c, a
- xor a
- ld b, a
- add hl, bc
- bccoord 0, 0, wAttrMap
- add hl, bc
+ ld a, BANK(wBGPals2)
+ ld [rSVBK], a
+
+; Fill wBGPals2 and wOBPals2 with $ffff (white)
+ ld hl, wBGPals2
+ ld bc, 16 palettes
+ ld a, $ff
+ call ByteFill
+
+ pop af
+ ld [rSVBK], a
+
+; Request palette update
+ ld a, 1
+ ld [hCGBPalUpdate], a
ret
-; 1d35
+; 333e
+
+GetMemSGBLayout:: ; 333e
+ ld b, SCGB_RAM
+GetSGBLayout:: ; 3340
+; load sgb packets unless dmg
+
+ ld a, [hCGB]
+ and a
+ jr nz, .sgb
+
+ ld a, [hSGB]
+ and a
+ ret z
+
+.sgb
+ predef_jump LoadSGBLayout
+; 334e
--- a/home/trainers.asm
+++ b/home/trainers.asm
@@ -247,7 +247,7 @@
.canlose
ld a, [wBattleResult]
ld hl, wWinTextPointer
- and $f
+ and $f ; WIN?
jr z, .ok
ld hl, wLossTextPointer
--- a/home/window.asm
+++ b/home/window.asm
@@ -1,5 +1,4 @@
RefreshScreen:: ; 2dba
-
call ClearWindowData
ld a, [hROMBank]
push af
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -233,7 +233,7 @@
\1Mon4:: hof_mon \1Mon4
\1Mon5:: hof_mon \1Mon5
\1Mon6:: hof_mon \1Mon6
-\1End:: ds 1
+\1End:: db
ENDM
link_battle_record: MACRO
--- a/main.asm
+++ b/main.asm
@@ -9,7 +9,7 @@
INCLUDE "engine/menus/intro_menu.asm"
INCLUDE "engine/overworld/init_map.asm"
INCLUDE "engine/pokemon/learn.asm"
-INCLUDE "engine/pokemon/check_nick_errors.asm"
+INCLUDE "engine/pokemon/correct_nick_errors.asm"
INCLUDE "engine/math/math.asm"
INCLUDE "data/items/attributes.asm"
INCLUDE "engine/overworld/npc_movement.asm"
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -75,8 +75,8 @@
EnableMobile: ; 100082
xor a
- ld hl, wOverworldMap
- ld bc, wOverworldMapEnd - wOverworldMap
+ ld hl, wOverworldMapBlocks
+ ld bc, wOverworldMapBlocksEnd - wOverworldMapBlocks
call ByteFill
di
--- a/mobile/mobile_5c.asm
+++ b/mobile/mobile_5c.asm
@@ -106,7 +106,7 @@
call GetSRAMBank
ld hl, $a894
ld a, [wBattleResult]
- and a
+ and a ; WIN?
jr nz, .asm_170c15
inc [hl]
--- a/wram.asm
+++ b/wram.asm
@@ -361,11 +361,15 @@
wc608:: ds 480
NEXTU ; c608
-; miscellaneous
-wMisc:: ds WMISC_WIDTH * WMISC_HEIGHT
-wMiscEnd::
+; surrounding tiles
+wSurroundingTiles:: ds SURROUNDING_WIDTH * SURROUNDING_HEIGHT
NEXTU ; c608
+; box save buffer
+wBoxPartialData:: ds 480
+wBoxPartialDataEnd::
+
+NEXTU ; c608
; odd egg
wOddEgg:: party_struct wOddEgg
wOddEggName:: ds MON_NAME_LENGTH
@@ -389,7 +393,7 @@
NEXTU ; c608
; link engine data
- ds 10
+wLink_c608:: ds 10
wc612:: ds 10
NEXTU ; c608
@@ -884,8 +888,9 @@
SECTION "Overworld Map", WRAM0
UNION ; c800
-wOverworldMap:: ds 1300 ; c800
-wOverworldMapEnd::
+; overworld map blocks
+wOverworldMapBlocks:: ds 1300 ; c800
+wOverworldMapBlocksEnd::
NEXTU ; c800
; GB Printer screen RAM
@@ -928,11 +933,15 @@
NEXTU ; c800
; bill's pc data
-wBillsPCPokemonList:: ; c800
-; Pokemon, box number, list index
+wBillsPCPokemonList::
+; (species, box number, list index) x30
ds 3 * 30
NEXTU ; c800
+; Hall of Fame data
+wHallOfFamePokemonList:: hall_of_fame wHallOfFamePokemonList
+
+NEXTU ; c800
; raw link data
wLinkData:: ds $514
wLinkDataEnd::
@@ -1495,8 +1504,11 @@
ds 1
-wcfbe:: ; SGB flags?
-; bit 7
+wcfbe:: ; cfbe
+; bits 4, 6, or 7 can be used to disable joypad input
+; bit 4
+; bit 6: mon fainted?
+; bit 7: SGB flag?
db
ds 1
@@ -1884,7 +1896,11 @@
; flickers when climbing waterfall
db
-wBattleResult:: db ; d0ee
+wBattleResult:: ; d0ee
+; WIN, LOSE, or DRAW
+; bit 6: caught celebi
+; bit 7: box full
+ db
wUsingItemWithSelect:: db ; d0ef
UNION ; d0f0
@@ -2760,7 +2776,7 @@
wMapNumber:: db ; dcb6 ; map number of current map
wYCoord:: db ; dcb7 ; current y coordinate relative to top-left corner of current map
wXCoord:: db ; dcb8 ; current x coordinate relative to top-left corner of current map
-wScreenSave:: ds 6 * 5
+wScreenSave:: ds SCREEN_META_WIDTH * SCREEN_META_HEIGHT
wCurrMapDataEnd::