summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRemy Oukaour <remy.oukaour@gmail.com>2017-12-24 19:35:35 -0500
committerRemy Oukaour <remy.oukaour@gmail.com>2017-12-24 19:35:35 -0500
commit7d4486e6a34a5163575400f21e806471be496e3d (patch)
treec0cc5f242b92420325d12a9cdedd6c1a3bcc3a4f
parent15f1fc7c6ce0444ebfd87b1edc22da0ffd61c667 (diff)
Remove all code from main.asm (some labeled INCBINs, like out-of-context graphics, are still present)
engine/routines/ stores isolated out-of-context routines as individual files. It might be preferable later to append them to their related engine/ files in unique little SECTIONs, relying on the linkerscript to place them appropriately; or some other organization method. In the meantime, they're now easily findable apart from main.asm's other content.
-rw-r--r--battle/core.asm18
-rw-r--r--constants/misc_constants.asm2
-rwxr-xr-xengine/card_flip.asm4
-rw-r--r--engine/diploma.asm1
-rw-r--r--engine/item_effects.asm2
-rw-r--r--engine/link_2.asm91
-rwxr-xr-xengine/money.asm4
-rw-r--r--engine/player_gfx_2.asm5
-rw-r--r--engine/routines/applypokerustick.asm (renamed from engine/pokerus_tick.asm)0
-rw-r--r--engine/routines/battlestart_copytilemapatonce.asm3
-rw-r--r--engine/routines/checkbattlescene.asm (renamed from engine/check_battle_scene.asm)0
-rw-r--r--engine/routines/checknickerrors.asm (renamed from engine/check_nick_errors.asm)0
-rw-r--r--engine/routines/checkpokerus.asm25
-rw-r--r--engine/routines/checksave.asm20
-rw-r--r--engine/routines/checktime.asm (renamed from engine/check_time.asm)4
-rw-r--r--engine/routines/consumehelditem.asm (renamed from engine/consume_held_item.asm)0
-rw-r--r--engine/routines/correcterrorsinplayerparty.asm (renamed from engine/unused_correct_party.asm)0
-rw-r--r--engine/routines/drawkrispackgfx.asm (renamed from engine/pack_f.asm)0
-rw-r--r--engine/routines/emptyallsrambanks.asm (renamed from engine/empty_sram.asm)0
-rw-r--r--engine/routines/flagpredef.asm (renamed from engine/flag_predef.asm)0
-rw-r--r--engine/routines/getbreedmonlevelgrowth.asm (renamed from engine/get_breedmon_growth.asm)0
-rwxr-xr-xengine/routines/getpokeballwobble.asm (renamed from engine/pokeball_wobble.asm)0
-rw-r--r--engine/routines/getsquareroot.asm (renamed from engine/square_root.asm)4
-rw-r--r--engine/routines/initlist.asm (renamed from engine/init_list.asm)0
-rw-r--r--engine/routines/knowsmove.asm (renamed from engine/knows_move.asm)0
-rw-r--r--engine/routines/kurt_selectquantity_interpretjoypad.asm4
-rw-r--r--engine/routines/leveluphappinessmod.asm20
-rw-r--r--engine/routines/loadmappart.asm36
-rw-r--r--engine/routines/loadpushoam.asm21
-rw-r--r--engine/routines/newpokedexentry.asm (renamed from engine/new_pokedex_entry.asm)0
-rw-r--r--engine/routines/phonering_copytilemapatonce.asm80
-rw-r--r--engine/routines/placegraphic.asm (renamed from engine/place_graphics.asm)0
-rw-r--r--engine/routines/placewaitingtext.asm24
-rw-r--r--engine/routines/playslowcry.asm (renamed from engine/play_slow_cry.asm)0
-rw-r--r--engine/routines/printhoursmins.asm (renamed from engine/printhoursmins.asm)2
-rw-r--r--engine/routines/returntobattle_useball.asm19
-rw-r--r--engine/routines/savemenu_copytilemapatonce.asm77
-rwxr-xr-xengine/routines/sine.asm (renamed from engine/sine.asm)0
-rw-r--r--engine/routines/switchpartymons.asm (renamed from engine/switch_party_mons.asm)0
-rw-r--r--engine/routines/townmap_convertlinebreakcharacters.asm (renamed from engine/pokegear_2.asm)4
-rw-r--r--engine/routines/trademonfrontpic.asm (renamed from engine/trademon_frontpic.asm)0
-rw-r--r--engine/routines/updatebattlehuds.asm9
-rw-r--r--engine/routines/updateitemdescription.asm13
-rwxr-xr-xengine/slot_machine.asm4
-rw-r--r--engine/spawn_points.asm1
-rwxr-xr-xengine/unown_dex.asm1
-rw-r--r--main.asm532
47 files changed, 513 insertions, 517 deletions
diff --git a/battle/core.asm b/battle/core.asm
index 57088ebdd..7a1d9bf73 100644
--- a/battle/core.asm
+++ b/battle/core.asm
@@ -2573,11 +2573,11 @@ WinTrainerBattle: ; 3cfa4
.CheckMaxedOutMomMoney: ; 3d0b1
ld hl, wMomsMoney + 2
ld a, [hld]
- cp 999999 % $100
+ cp MAX_MONEY % $100
ld a, [hld]
- sbc 999999 / $100 % $100
+ sbc MAX_MONEY / $100 % $100
ld a, [hl]
- sbc 999999 / $10000 % $100
+ sbc MAX_MONEY / $10000 % $100
ret
; 3d0be
@@ -2602,17 +2602,17 @@ AddBattleMoneyToAccount: ; 3d0be
jr nz, .loop
pop hl
ld a, [hld]
- cp 999999 % $100
+ cp MAX_MONEY % $100
ld a, [hld]
- sbc 999999 / $100 % $100
+ sbc MAX_MONEY / $100 % $100
ld a, [hl]
- sbc 999999 / $10000 % $100
+ sbc MAX_MONEY / $10000 % $100
ret c
- ld [hl], 999999 / $10000 % $100
+ ld [hl], MAX_MONEY / $10000 % $100
inc hl
- ld [hl], 999999 / $100 % $100
+ ld [hl], MAX_MONEY / $100 % $100
inc hl
- ld [hl], 999999 % $100
+ ld [hl], MAX_MONEY % $100
ret
; 3d0ea
diff --git a/constants/misc_constants.asm b/constants/misc_constants.asm
index 25032cc10..70b97a21d 100644
--- a/constants/misc_constants.asm
+++ b/constants/misc_constants.asm
@@ -93,6 +93,8 @@ NUM_HOF_TEAMS = 30
; significant money values
START_MONEY EQU 3000
MOM_MONEY EQU 2300
+MAX_MONEY EQU 999999
+MAX_COINS EQU 9999
; ChangeHappiness arguments (see data/happiness_changes.asm)
diff --git a/engine/card_flip.asm b/engine/card_flip.asm
index cfcd949e6..c0c4639ad 100755
--- a/engine/card_flip.asm
+++ b/engine/card_flip.asm
@@ -1185,14 +1185,14 @@ CardFlip_CheckWinCondition: ; e0637
.IsCoinCaseFull: ; e0833
ld a, [Coins]
- cp 9999 / $100
+ cp MAX_COINS / $100
jr c, .less
jr z, .check_low
jr .more
.check_low
ld a, [Coins + 1]
- cp 9999 % $100
+ cp MAX_COINS % $100
jr c, .less
.more
diff --git a/engine/diploma.asm b/engine/diploma.asm
index 582d0cd1c..f1c67ea37 100644
--- a/engine/diploma.asm
+++ b/engine/diploma.asm
@@ -1,4 +1,3 @@
-
_Diploma: ; 1dd702
call PlaceDiplomaOnScreen
call WaitPressAorB_BlinkCursor
diff --git a/engine/item_effects.asm b/engine/item_effects.asm
index 2d7aa4c69..7fd2b7196 100644
--- a/engine/item_effects.asm
+++ b/engine/item_effects.asm
@@ -3314,5 +3314,3 @@ GetMthMoveOfCurrentMon: ; f969
add hl, bc
ret
; f971
-
-INCLUDE "engine/pokeball_wobble.asm"
diff --git a/engine/link_2.asm b/engine/link_2.asm
new file mode 100644
index 000000000..72e5262b3
--- /dev/null
+++ b/engine/link_2.asm
@@ -0,0 +1,91 @@
+LinkMonStatsScreen: ; 4d319
+ ld a, [wMenuCursorY]
+ dec a
+ ld [CurPartyMon], a
+ call LowVolume
+ predef StatsScreenInit
+ ld a, [CurPartyMon]
+ inc a
+ ld [wMenuCursorY], a
+ call ClearScreen
+ call ClearBGPalettes
+ call MaxVolume
+ farcall LoadTradeScreenBorder
+ farcall Link_WaitBGMap
+ farcall InitTradeSpeciesList
+ farcall SetTradeRoomBGPals
+ call WaitBGMap2
+ ret
+
+Link_WaitBGMap: ; 4d354
+ call WaitBGMap
+ call WaitBGMap2
+ ret
+
+LinkTextbox2: ; 4d35b
+ ld h, d
+ ld l, e
+ push bc
+ push hl
+ call .PlaceBorder
+ pop hl
+ pop bc
+ ld de, AttrMap - TileMap
+ add hl, de
+ inc b
+ inc b
+ inc c
+ inc c
+ ld a, $7
+.row
+ push bc
+ push hl
+.col
+ ld [hli], a
+ dec c
+ jr nz, .col
+ pop hl
+ ld de, SCREEN_WIDTH
+ add hl, de
+ pop bc
+ dec b
+ jr nz, .row
+ ret
+
+.PlaceBorder: ; 4d37e
+ push hl
+ ld a, $76
+ ld [hli], a
+ inc a
+ call .PlaceRow
+ inc a
+ ld [hl], a
+ pop hl
+ ld de, SCREEN_WIDTH
+ add hl, de
+.loop
+ push hl
+ ld a, "┌"
+ ld [hli], a
+ ld a, " "
+ call .PlaceRow
+ ld [hl], "─"
+ pop hl
+ ld de, SCREEN_WIDTH
+ add hl, de
+ dec b
+ jr nz, .loop
+ ld a, "┐"
+ ld [hli], a
+ ld a, "│"
+ call .PlaceRow
+ ld [hl], "└"
+ ret
+
+.PlaceRow: ; 4d3ab
+ ld d, c
+.row_loop
+ ld [hli], a
+ dec d
+ jr nz, .row_loop
+ ret
diff --git a/engine/money.asm b/engine/money.asm
index 874821814..60de97568 100755
--- a/engine/money.asm
+++ b/engine/money.asm
@@ -24,7 +24,7 @@ GiveMoney:: ; 15fd7
; 15ff7
MaxMoney: ; 15ff7
- dt 999999
+ dt MAX_MONEY
; 15ffa
@@ -192,7 +192,7 @@ GiveCoins:: ; 1606f
; 1608d
.maxcoins ; 1608d
- bigdw 9999
+ bigdw MAX_COINS
; 1608f
diff --git a/engine/player_gfx_2.asm b/engine/player_gfx_2.asm
deleted file mode 100644
index d6e7791a3..000000000
--- a/engine/player_gfx_2.asm
+++ /dev/null
@@ -1,5 +0,0 @@
-ChrisBackpic: ; 2ba1a
-INCBIN "gfx/player/chris_back.2bpp.lz"
-
-DudeBackpic: ; 2bbaa
-INCBIN "gfx/battle/dude.2bpp.lz"
diff --git a/engine/pokerus_tick.asm b/engine/routines/applypokerustick.asm
index 3c97fdc5e..3c97fdc5e 100644
--- a/engine/pokerus_tick.asm
+++ b/engine/routines/applypokerustick.asm
diff --git a/engine/routines/battlestart_copytilemapatonce.asm b/engine/routines/battlestart_copytilemapatonce.asm
new file mode 100644
index 000000000..2952e833b
--- /dev/null
+++ b/engine/routines/battlestart_copytilemapatonce.asm
@@ -0,0 +1,3 @@
+BattleStart_CopyTilemapAtOnce: ; 8cf4f
+ call CGBOnly_CopyTilemapAtOnce
+ ret
diff --git a/engine/check_battle_scene.asm b/engine/routines/checkbattlescene.asm
index b63f00907..b63f00907 100644
--- a/engine/check_battle_scene.asm
+++ b/engine/routines/checkbattlescene.asm
diff --git a/engine/check_nick_errors.asm b/engine/routines/checknickerrors.asm
index 1cedca420..1cedca420 100644
--- a/engine/check_nick_errors.asm
+++ b/engine/routines/checknickerrors.asm
diff --git a/engine/routines/checkpokerus.asm b/engine/routines/checkpokerus.asm
new file mode 100644
index 000000000..285024754
--- /dev/null
+++ b/engine/routines/checkpokerus.asm
@@ -0,0 +1,25 @@
+CheckPokerus: ; 4d860
+; Return carry if a monster in your party has Pokerus
+
+; Get number of monsters to iterate over
+ ld a, [PartyCount]
+ and a
+ jr z, .NoPokerus
+ ld b, a
+; Check each monster in the party for Pokerus
+ ld hl, PartyMon1PokerusStatus
+ ld de, PARTYMON_STRUCT_LENGTH
+.Check:
+ ld a, [hl]
+ and $0f ; only the bottom nybble is used
+ jr nz, .HasPokerus
+; Next PartyMon
+ add hl, de
+ dec b
+ jr nz, .Check
+.NoPokerus:
+ and a
+ ret
+.HasPokerus:
+ scf
+ ret
diff --git a/engine/routines/checksave.asm b/engine/routines/checksave.asm
new file mode 100644
index 000000000..2280f0e53
--- /dev/null
+++ b/engine/routines/checksave.asm
@@ -0,0 +1,20 @@
+CheckSave:: ; 4cffe
+ ld a, BANK(sCheckValue1) ; BANK(sCheckValue2)
+ call GetSRAMBank
+ ld a, [sCheckValue1]
+ ld b, a
+ ld a, [sCheckValue2]
+ ld c, a
+ call CloseSRAM
+ ld a, b
+ cp SAVE_CHECK_VALUE_1
+ jr nz, .ok
+ ld a, c
+ cp SAVE_CHECK_VALUE_2
+ jr nz, .ok
+ ld c, $1
+ ret
+
+.ok
+ ld c, $0
+ ret
diff --git a/engine/check_time.asm b/engine/routines/checktime.asm
index 615b51d29..ada151dbf 100644
--- a/engine/check_time.asm
+++ b/engine/routines/checktime.asm
@@ -1,6 +1,6 @@
CheckTime:: ; c000
ld a, [TimeOfDay]
- ld hl, TimeOfDayTable
+ ld hl, .TimeOfDayTable
ld de, 2
call IsInArray
inc hl
@@ -11,7 +11,7 @@ CheckTime:: ; c000
ld c, a
ret
-TimeOfDayTable: ; c012
+.TimeOfDayTable: ; c012
db MORN_F, MORN
db DAY_F, DAY
db NITE_F, NITE
diff --git a/engine/consume_held_item.asm b/engine/routines/consumehelditem.asm
index a6f7766fb..a6f7766fb 100644
--- a/engine/consume_held_item.asm
+++ b/engine/routines/consumehelditem.asm
diff --git a/engine/unused_correct_party.asm b/engine/routines/correcterrorsinplayerparty.asm
index 2fa98a545..2fa98a545 100644
--- a/engine/unused_correct_party.asm
+++ b/engine/routines/correcterrorsinplayerparty.asm
diff --git a/engine/pack_f.asm b/engine/routines/drawkrispackgfx.asm
index f71e43db8..f71e43db8 100644
--- a/engine/pack_f.asm
+++ b/engine/routines/drawkrispackgfx.asm
diff --git a/engine/empty_sram.asm b/engine/routines/emptyallsrambanks.asm
index aa4b28e0d..aa4b28e0d 100644
--- a/engine/empty_sram.asm
+++ b/engine/routines/emptyallsrambanks.asm
diff --git a/engine/flag_predef.asm b/engine/routines/flagpredef.asm
index bd4f37882..bd4f37882 100644
--- a/engine/flag_predef.asm
+++ b/engine/routines/flagpredef.asm
diff --git a/engine/get_breedmon_growth.asm b/engine/routines/getbreedmonlevelgrowth.asm
index b029043d6..b029043d6 100644
--- a/engine/get_breedmon_growth.asm
+++ b/engine/routines/getbreedmonlevelgrowth.asm
diff --git a/engine/pokeball_wobble.asm b/engine/routines/getpokeballwobble.asm
index 7fb4d3e38..7fb4d3e38 100755
--- a/engine/pokeball_wobble.asm
+++ b/engine/routines/getpokeballwobble.asm
diff --git a/engine/square_root.asm b/engine/routines/getsquareroot.asm
index 496f66c83..009d9f4fe 100644
--- a/engine/square_root.asm
+++ b/engine/routines/getsquareroot.asm
@@ -4,7 +4,7 @@ GetSquareRoot: ; 13b87
; Rather than calculating the result, we take the index of the
; first value in a table of squares that isn't lower than de.
- ld hl, Squares
+ ld hl, .Squares
ld b, 0
.loop
; Make sure we don't go past the end of the table.
@@ -22,7 +22,7 @@ GetSquareRoot: ; 13b87
jr c, .loop
ret
-Squares: ; 13b98
+.Squares: ; 13b98
root set 1
rept $ff
dw root*root
diff --git a/engine/init_list.asm b/engine/routines/initlist.asm
index e2b7235ab..e2b7235ab 100644
--- a/engine/init_list.asm
+++ b/engine/routines/initlist.asm
diff --git a/engine/knows_move.asm b/engine/routines/knowsmove.asm
index 4ec3da347..4ec3da347 100644
--- a/engine/knows_move.asm
+++ b/engine/routines/knowsmove.asm
diff --git a/engine/routines/kurt_selectquantity_interpretjoypad.asm b/engine/routines/kurt_selectquantity_interpretjoypad.asm
new file mode 100644
index 000000000..12a43e325
--- /dev/null
+++ b/engine/routines/kurt_selectquantity_interpretjoypad.asm
@@ -0,0 +1,4 @@
+Kurt_SelectQuantity_InterpretJoypad: ; 27a28
+ call BuySellToss_InterpretJoypad
+ ld b, a
+ ret
diff --git a/engine/routines/leveluphappinessmod.asm b/engine/routines/leveluphappinessmod.asm
new file mode 100644
index 000000000..c253e8872
--- /dev/null
+++ b/engine/routines/leveluphappinessmod.asm
@@ -0,0 +1,20 @@
+LevelUpHappinessMod: ; 2709e
+ ld a, [CurPartyMon]
+ ld hl, PartyMon1CaughtLocation
+ call GetPartyLocation
+ ld a, [hl]
+ and $7f
+ ld d, a
+ ld a, [MapGroup]
+ ld b, a
+ ld a, [MapNumber]
+ ld c, a
+ call GetWorldMapLocation
+ cp d
+ ld c, HAPPINESS_GAINLEVEL
+ jr nz, .ok
+ ld c, HAPPINESS_GAINLEVELATHOME
+
+.ok
+ callfar ChangeHappiness
+ ret
diff --git a/engine/routines/loadmappart.asm b/engine/routines/loadmappart.asm
new file mode 100644
index 000000000..2184ebf7e
--- /dev/null
+++ b/engine/routines/loadmappart.asm
@@ -0,0 +1,36 @@
+_LoadMapPart:: ; 4d15b
+ ld hl, wMisc
+ ld a, [wMetatileStandingY]
+ and a
+ jr z, .top_row
+ ld bc, WMISC_WIDTH * 2
+ add hl, bc
+
+.top_row
+ ld a, [wMetatileStandingX]
+ and a
+ jr z, .left_column
+ inc hl
+ inc hl
+
+.left_column
+ decoord 0, 0
+ ld b, SCREEN_HEIGHT
+.loop
+ ld c, SCREEN_WIDTH
+.loop2
+ ld a, [hli]
+ ld [de], a
+ inc de
+ dec c
+ jr nz, .loop2
+ ld a, l
+ add 4
+ ld l, a
+ jr nc, .carry
+ inc h
+
+.carry
+ dec b
+ jr nz, .loop
+ ret
diff --git a/engine/routines/loadpushoam.asm b/engine/routines/loadpushoam.asm
new file mode 100644
index 000000000..6fcccbcae
--- /dev/null
+++ b/engine/routines/loadpushoam.asm
@@ -0,0 +1,21 @@
+LoadPushOAM:: ; 4031
+ ld c, hPushOAM - $ff00
+ ld b, .PushOAMEnd - .PushOAM
+ ld hl, .PushOAM
+.loop
+ ld a, [hli]
+ ld [$ff00+c], a
+ inc c
+ dec b
+ jr nz, .loop
+ ret
+
+.PushOAM: ; 403f
+ ld a, Sprites / $100
+ ld [rDMA], a
+ ld a, (SpritesEnd - Sprites) / 4 ; 40
+.pushoam_loop
+ dec a
+ jr nz, .pushoam_loop
+ ret
+.PushOAMEnd
diff --git a/engine/new_pokedex_entry.asm b/engine/routines/newpokedexentry.asm
index acf9fca7b..acf9fca7b 100644
--- a/engine/new_pokedex_entry.asm
+++ b/engine/routines/newpokedexentry.asm
diff --git a/engine/routines/phonering_copytilemapatonce.asm b/engine/routines/phonering_copytilemapatonce.asm
new file mode 100644
index 000000000..2ffa688a9
--- /dev/null
+++ b/engine/routines/phonering_copytilemapatonce.asm
@@ -0,0 +1,80 @@
+PhoneRing_CopyTilemapAtOnce: ; 4d188
+ ld a, [hCGB]
+ and a
+ jp z, WaitBGMap
+ ld a, [wSpriteUpdatesEnabled]
+ cp $0
+ jp z, WaitBGMap
+
+; What follows is a modified version of CopyTilemapAtOnce.
+ 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 $8f
+ jr c, .wait
+
+ di
+ ld a, BANK(VBGMap2)
+ ld [rVBK], a
+ hlcoord 0, 0, AttrMap
+ call .CopyTilemapAtOnce
+ ld a, BANK(VBGMap0)
+ ld [rVBK], a
+ hlcoord 0, 0
+ call .CopyTilemapAtOnce
+.wait2
+ ld a, [rLY]
+ cp $8f
+ jr c, .wait2
+ ei
+
+ pop af
+ ld [hMapAnims], a
+ pop af
+ ld [hBGMapMode], a
+ ret
+
+.CopyTilemapAtOnce: ; 4d1cb
+ 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, rSTAT % $100
+
+.loop
+rept SCREEN_WIDTH / 2
+ pop de
+.loop\@
+ ld a, [$ff00+c]
+ and b
+ jr nz, .loop\@
+ 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
diff --git a/engine/place_graphics.asm b/engine/routines/placegraphic.asm
index d72364776..d72364776 100644
--- a/engine/place_graphics.asm
+++ b/engine/routines/placegraphic.asm
diff --git a/engine/routines/placewaitingtext.asm b/engine/routines/placewaitingtext.asm
new file mode 100644
index 000000000..37fc2a056
--- /dev/null
+++ b/engine/routines/placewaitingtext.asm
@@ -0,0 +1,24 @@
+PlaceWaitingText:: ; 4000
+ hlcoord 3, 10
+ ld b, 1
+ ld c, 11
+
+ ld a, [wBattleMode]
+ and a
+ jr z, .notinbattle
+
+ call TextBox
+ jr .proceed
+
+.notinbattle
+ predef Predef_LinkTextbox
+
+.proceed
+ hlcoord 4, 11
+ ld de, .Waiting
+ call PlaceString
+ ld c, 50
+ jp DelayFrames
+
+.Waiting: ; 4025
+ db "Waiting...!@"
diff --git a/engine/play_slow_cry.asm b/engine/routines/playslowcry.asm
index 3cc347a55..3cc347a55 100644
--- a/engine/play_slow_cry.asm
+++ b/engine/routines/playslowcry.asm
diff --git a/engine/printhoursmins.asm b/engine/routines/printhoursmins.asm
index 711ff89b6..50117188c 100644
--- a/engine/printhoursmins.asm
+++ b/engine/routines/printhoursmins.asm
@@ -14,7 +14,7 @@ Function1dd6a9: ; 1dd6a9
pop bc
ret
-PrintHoursMins ; 1dd6bb (77:56bb)
+PrintHoursMins: ; 1dd6bb (77:56bb)
; Hours in b, minutes in c
ld a, b
cp 12
diff --git a/engine/routines/returntobattle_useball.asm b/engine/routines/returntobattle_useball.asm
new file mode 100644
index 000000000..e6e33f900
--- /dev/null
+++ b/engine/routines/returntobattle_useball.asm
@@ -0,0 +1,19 @@
+_ReturnToBattle_UseBall: ; 2715c
+ call ClearBGPalettes
+ call ClearTileMap
+ ld a, [BattleType]
+ cp BATTLETYPE_TUTORIAL
+ jr z, .gettutorialbackpic
+ farcall GetBattleMonBackpic
+ jr .continue
+
+.gettutorialbackpic
+ farcall GetTrainerBackpic
+.continue
+ farcall GetEnemyMonFrontpic
+ farcall _LoadBattleFontsHPBar
+ call GetMemSGBLayout
+ call CloseWindow
+ call LoadStandardMenuDataHeader
+ call WaitBGMap
+ jp SetPalettes
diff --git a/engine/routines/savemenu_copytilemapatonce.asm b/engine/routines/savemenu_copytilemapatonce.asm
new file mode 100644
index 000000000..de7cbaa8f
--- /dev/null
+++ b/engine/routines/savemenu_copytilemapatonce.asm
@@ -0,0 +1,77 @@
+SaveMenu_CopyTilemapAtOnce: ; 4cf45 (13:4f45)
+ ld a, [hCGB]
+ and a
+ jp z, WaitBGMap
+
+; The following is a modified version of CopyTilemapAtOnce.
+ ld a, [hBGMapMode]
+ push af
+ xor a
+ ld [hBGMapMode], a
+ ld a, [hMapAnims]
+ push af
+ xor a
+ ld [hMapAnims], a
+.WaitLY:
+ ld a, [rLY]
+ cp $60
+ jr c, .WaitLY
+
+ di
+ ld a, BANK(VBGMap2)
+ ld [rVBK], a
+ hlcoord 0, 0, AttrMap
+ call .CopyTilemapAtOnce
+ ld a, BANK(VBGMap0)
+ ld [rVBK], a
+ hlcoord 0, 0
+ call .CopyTilemapAtOnce
+.WaitLY2:
+ ld a, [rLY]
+ cp $60
+ jr c, .WaitLY2
+ ei
+
+ pop af
+ ld [hMapAnims], a
+ pop af
+ ld [hBGMapMode], a
+ ret
+
+.CopyTilemapAtOnce: ; 4cf80 (13:4f80)
+ ld [hSPBuffer], sp ; $ffd9
+ ld sp, hl
+ ld a, [hBGMapAddress + 1]
+ ld h, a
+ ld l, 0
+ ld a, SCREEN_HEIGHT
+ ld [hTilesPerCycle], a
+ ld b, 1 << 1
+ ld c, rSTAT % $100
+
+.loop
+rept SCREEN_WIDTH / 2
+ pop de
+.loop\@
+ ld a, [$ff00+c]
+ and b
+ jr nz, .loop\@
+ 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
diff --git a/engine/sine.asm b/engine/routines/sine.asm
index 89a905d2e..89a905d2e 100755
--- a/engine/sine.asm
+++ b/engine/routines/sine.asm
diff --git a/engine/switch_party_mons.asm b/engine/routines/switchpartymons.asm
index cde9c82b2..cde9c82b2 100644
--- a/engine/switch_party_mons.asm
+++ b/engine/routines/switchpartymons.asm
diff --git a/engine/pokegear_2.asm b/engine/routines/townmap_convertlinebreakcharacters.asm
index a5cceecfd..f08b436c9 100644
--- a/engine/pokegear_2.asm
+++ b/engine/routines/townmap_convertlinebreakcharacters.asm
@@ -19,7 +19,3 @@ TownMap_ConvertLineBreakCharacters: ; 1de2c5
hlcoord 9, 0
call PlaceString
ret
-
-
-PokegearGFX: ; 1de2e4
-INCBIN "gfx/pokegear/pokegear.2bpp.lz"
diff --git a/engine/trademon_frontpic.asm b/engine/routines/trademonfrontpic.asm
index 3a38688d7..3a38688d7 100644
--- a/engine/trademon_frontpic.asm
+++ b/engine/routines/trademonfrontpic.asm
diff --git a/engine/routines/updatebattlehuds.asm b/engine/routines/updatebattlehuds.asm
new file mode 100644
index 000000000..ec7f662e8
--- /dev/null
+++ b/engine/routines/updatebattlehuds.asm
@@ -0,0 +1,9 @@
+_UpdateBattleHUDs:
+ farcall DrawPlayerHUD
+ ld hl, PlayerHPPal
+ call SetHPPal
+ farcall DrawEnemyHUD
+ ld hl, EnemyHPPal
+ call SetHPPal
+ farcall FinishBattleAnim
+ ret
diff --git a/engine/routines/updateitemdescription.asm b/engine/routines/updateitemdescription.asm
new file mode 100644
index 000000000..b684dd4d8
--- /dev/null
+++ b/engine/routines/updateitemdescription.asm
@@ -0,0 +1,13 @@
+UpdateItemDescription: ; 0x244c3
+ ld a, [MenuSelection]
+ ld [CurSpecies], a
+ hlcoord 0, 12
+ ld b, 4
+ ld c, SCREEN_WIDTH - 2
+ call TextBox
+ ld a, [MenuSelection]
+ cp -1
+ ret z
+ decoord 1, 14
+ farcall PrintItemDescription
+ ret
diff --git a/engine/slot_machine.asm b/engine/slot_machine.asm
index 383573c03..037340413 100755
--- a/engine/slot_machine.asm
+++ b/engine/slot_machine.asm
@@ -471,10 +471,10 @@ Slots_LoadReelState: ; 929f6 (24:69f6)
Slot_CheckCoinCaseFull: ; 92a04 (24:6a04)
ld a, d
- cp 9999 / $100
+ cp MAX_COINS / $100
jr c, .not_full
ld a, e
- cp 9999 % $100
+ cp MAX_COINS % $100
jr c, .not_full
scf
ret
diff --git a/engine/spawn_points.asm b/engine/spawn_points.asm
index b8637da17..daebb6159 100644
--- a/engine/spawn_points.asm
+++ b/engine/spawn_points.asm
@@ -1,4 +1,3 @@
-
INCLUDE "data/maps/spawn_points.asm"
diff --git a/engine/unown_dex.asm b/engine/unown_dex.asm
index 6d14f8b3c..dc6db9dc6 100755
--- a/engine/unown_dex.asm
+++ b/engine/unown_dex.asm
@@ -48,4 +48,5 @@ PrintUnownWord: ; fba2e (3e:7a2e)
jr .loop
; fba5a (3e:7a5a)
+
INCLUDE "data/unown_words.asm"
diff --git a/main.asm b/main.asm
index 01f5699b7..e9794516e 100644
--- a/main.asm
+++ b/main.asm
@@ -3,58 +3,13 @@ INCLUDE "includes.asm"
SECTION "bank1", ROMX
-PlaceWaitingText:: ; 4000
- hlcoord 3, 10
- ld b, 1
- ld c, 11
-
- ld a, [wBattleMode]
- and a
- jr z, .notinbattle
-
- call TextBox
- jr .proceed
-
-.notinbattle
- predef Predef_LinkTextbox
-
-.proceed
- hlcoord 4, 11
- ld de, .Waiting
- call PlaceString
- ld c, 50
- jp DelayFrames
-
-.Waiting: ; 4025
- db "Waiting...!@"
-
-LoadPushOAM:: ; 4031
- ld c, hPushOAM - $ff00
- ld b, PushOAMEnd - PushOAM
- ld hl, PushOAM
-.loop
- ld a, [hli]
- ld [$ff00+c], a
- inc c
- dec b
- jr nz, .loop
- ret
-
-PushOAM: ; 403f
- ld a, Sprites / $100
- ld [rDMA], a
- ld a, (SpritesEnd - Sprites) / 4 ; 40
-.loop
- dec a
- jr nz, .loop
- ret
-PushOAMEnd
-
+INCLUDE "engine/routines/placewaitingtext.asm"
+INCLUDE "engine/routines/loadpushoam.asm"
INCLUDE "engine/map_objects.asm"
INCLUDE "engine/intro_menu.asm"
INCLUDE "engine/init_map.asm"
INCLUDE "engine/learn.asm"
-INCLUDE "engine/check_nick_errors.asm"
+INCLUDE "engine/routines/checknickerrors.asm"
INCLUDE "engine/math.asm"
INCLUDE "data/items/item_attributes.asm"
INCLUDE "engine/npc_movement.asm"
@@ -65,14 +20,14 @@ INCLUDE "event/special.asm"
SECTION "bank2", ROMX
INCLUDE "engine/player_object.asm"
-INCLUDE "engine/sine.asm"
+INCLUDE "engine/routines/sine.asm"
INCLUDE "engine/predef.asm"
INCLUDE "engine/color.asm"
SECTION "bank3", ROMX
-INCLUDE "engine/check_time.asm"
+INCLUDE "engine/routines/checktime.asm"
INCLUDE "engine/specials.asm"
INCLUDE "engine/printnum.asm"
INCLUDE "engine/health.asm"
@@ -82,10 +37,11 @@ INCLUDE "engine/player_step.asm"
INCLUDE "engine/anim_hp_bar.asm"
INCLUDE "engine/move_mon.asm"
INCLUDE "engine/billspctop.asm"
-INCLUDE "engine/get_breedmon_growth.asm"
+INCLUDE "engine/routines/getbreedmonlevelgrowth.asm"
INCLUDE "event/bug_contest/caught_mon.asm"
INCLUDE "engine/item_effects.asm"
-INCLUDE "engine/knows_move.asm"
+INCLUDE "engine/routines/getpokeballwobble.asm"
+INCLUDE "engine/routines/knowsmove.asm"
SECTION "bank4", ROMX
@@ -106,10 +62,10 @@ INCLUDE "event/bug_contest/contest.asm"
INCLUDE "event/misc_scripts_2.asm"
INCLUDE "event/std_collision.asm"
INCLUDE "event/bug_contest/judging.asm"
-INCLUDE "engine/pokerus_tick.asm"
+INCLUDE "engine/routines/applypokerustick.asm"
INCLUDE "event/bug_contest/contest_2.asm"
-INCLUDE "engine/unused_correct_party.asm"
-INCLUDE "engine/square_root.asm"
+INCLUDE "engine/routines/correcterrorsinplayerparty.asm"
+INCLUDE "engine/routines/getsquareroot.asm"
SECTION "bank5", ROMX
@@ -141,21 +97,7 @@ SECTION "bank9", ROMX
INCLUDE "data/text_buffers.asm"
INCLUDE "engine/menu.asm"
-
-UpdateItemDescription: ; 0x244c3
- ld a, [MenuSelection]
- ld [CurSpecies], a
- hlcoord 0, 12
- ld b, 4
- ld c, SCREEN_WIDTH - 2
- call TextBox
- ld a, [MenuSelection]
- cp -1
- ret z
- decoord 1, 14
- farcall PrintItemDescription
- ret
-
+INCLUDE "engine/routines/updateitemdescription.asm"
INCLUDE "engine/pokepic.asm"
INCLUDE "engine/map_objects_2.asm"
INCLUDE "engine/scrolling_menu.asm"
@@ -167,58 +109,13 @@ INCLUDE "engine/buy_sell_toss.asm"
INCLUDE "engine/trainer_card.asm"
INCLUDE "engine/prof_oaks_pc.asm"
INCLUDE "engine/decorations.asm"
-
-LevelUpHappinessMod: ; 2709e
- ld a, [CurPartyMon]
- ld hl, PartyMon1CaughtLocation
- call GetPartyLocation
- ld a, [hl]
- and $7f
- ld d, a
- ld a, [MapGroup]
- ld b, a
- ld a, [MapNumber]
- ld c, a
- call GetWorldMapLocation
- cp d
- ld c, HAPPINESS_GAINLEVEL
- jr nz, .ok
- ld c, HAPPINESS_GAINLEVELATHOME
-
-.ok
- callfar ChangeHappiness
- ret
-
+INCLUDE "engine/routines/leveluphappinessmod.asm"
INCLUDE "data/trainers/trainer_dvs.asm"
-
-_ReturnToBattle_UseBall: ; 2715c
- call ClearBGPalettes
- call ClearTileMap
- ld a, [BattleType]
- cp BATTLETYPE_TUTORIAL
- jr z, .gettutorialbackpic
- farcall GetBattleMonBackpic
- jr .continue
-
-.gettutorialbackpic
- farcall GetTrainerBackpic
-.continue
- farcall GetEnemyMonFrontpic
- farcall _LoadBattleFontsHPBar
- call GetMemSGBLayout
- call CloseWindow
- call LoadStandardMenuDataHeader
- call WaitBGMap
- jp SetPalettes
-
-INCLUDE "engine/consume_held_item.asm"
+INCLUDE "engine/routines/returntobattle_useball.asm"
+INCLUDE "engine/routines/consumehelditem.asm"
INCLUDE "battle/moves/move_effects_pointers.asm"
INCLUDE "battle/moves/move_effects.asm"
-
-Kurt_SelectQuantity_InterpretJoypad: ; 27a28
- call BuySellToss_InterpretJoypad
- ld b, a
- ret
+INCLUDE "engine/routines/kurt_selectquantity_interpretjoypad.asm"
SECTION "bankA", ROMX
@@ -226,7 +123,12 @@ SECTION "bankA", ROMX
INCLUDE "engine/link.asm"
INCLUDE "engine/wildmons.asm"
INCLUDE "battle/link_result.asm"
-INCLUDE "engine/player_gfx_2.asm"
+
+ChrisBackpic: ; 2ba1a
+INCBIN "gfx/player/chris_back.2bpp.lz"
+
+DudeBackpic: ; 2bbaa
+INCBIN "gfx/battle/dude.2bpp.lz"
SECTION "bankB", ROMX
@@ -240,7 +142,7 @@ INCLUDE "engine/tmhm2.asm"
INCLUDE "battle/moves/move_descriptions.asm"
INCLUDE "engine/pokerus.asm"
INCLUDE "engine/start_battle.asm"
-INCLUDE "engine/place_graphics.asm"
+INCLUDE "engine/routines/placegraphic.asm"
SECTION "Effect Commands", ROMX
@@ -284,7 +186,7 @@ INCLUDE "engine/mail.asm"
SECTION "Crystal Unique", ROMX
INCLUDE "engine/init_gender.asm"
-INCLUDE "engine/pack_f.asm"
+INCLUDE "engine/routines/drawkrispackgfx.asm"
INCLUDE "event/move_tutor.asm"
INCLUDE "engine/crystal_colors.asm"
INCLUDE "event/celebi.asm"
@@ -300,233 +202,20 @@ SECTION "bank13", ROMX
INCLUDE "engine/map_palettes.asm"
INCLUDE "tilesets/palette_maps.asm"
-Unknown_4ce05: ; unreferenced
+; unreferenced
+; 0x4ce05
rept 26
db $06
endr
; 0x4ce1f
INCLUDE "data/collision_permissions.asm"
-INCLUDE "engine/empty_sram.asm"
-
-SaveMenu_CopyTilemapAtOnce: ; 4cf45 (13:4f45)
- ld a, [hCGB]
- and a
- jp z, WaitBGMap
-
-; The following is a modified version of CopyTilemapAtOnce.
- ld a, [hBGMapMode]
- push af
- xor a
- ld [hBGMapMode], a
- ld a, [hMapAnims]
- push af
- xor a
- ld [hMapAnims], a
-.WaitLY:
- ld a, [rLY]
- cp $60
- jr c, .WaitLY
-
- di
- ld a, BANK(VBGMap2)
- ld [rVBK], a
- hlcoord 0, 0, AttrMap
- call .CopyTilemapAtOnce
- ld a, BANK(VBGMap0)
- ld [rVBK], a
- hlcoord 0, 0
- call .CopyTilemapAtOnce
-.WaitLY2:
- ld a, [rLY]
- cp $60
- jr c, .WaitLY2
- ei
-
- pop af
- ld [hMapAnims], a
- pop af
- ld [hBGMapMode], a
- ret
-
-.CopyTilemapAtOnce: ; 4cf80 (13:4f80)
- ld [hSPBuffer], sp ; $ffd9
- ld sp, hl
- ld a, [hBGMapAddress + 1]
- ld h, a
- ld l, 0
- ld a, SCREEN_HEIGHT
- ld [hTilesPerCycle], a
- ld b, 1 << 1
- ld c, rSTAT % $100
-
-.loop
-rept SCREEN_WIDTH / 2
- pop de
-.loop\@
- ld a, [$ff00+c]
- and b
- jr nz, .loop\@
- 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
-
-CheckSave:: ; 4cffe
- ld a, BANK(sCheckValue1) ; BANK(sCheckValue2)
- call GetSRAMBank
- ld a, [sCheckValue1]
- ld b, a
- ld a, [sCheckValue2]
- ld c, a
- call CloseSRAM
- ld a, b
- cp SAVE_CHECK_VALUE_1
- jr nz, .ok
- ld a, c
- cp SAVE_CHECK_VALUE_2
- jr nz, .ok
- ld c, $1
- ret
-
-.ok
- ld c, $0
- ret
-
+INCLUDE "engine/routines/emptyallsrambanks.asm"
+INCLUDE "engine/routines/savemenu_copytilemapatonce.asm"
+INCLUDE "engine/routines/checksave.asm"
INCLUDE "data/maps/map_scenes.asm"
-
-_LoadMapPart:: ; 4d15b
- ld hl, wMisc
- ld a, [wMetatileStandingY]
- and a
- jr z, .top_row
- ld bc, WMISC_WIDTH * 2
- add hl, bc
-
-.top_row
- ld a, [wMetatileStandingX]
- and a
- jr z, .left_column
- inc hl
- inc hl
-
-.left_column
- decoord 0, 0
- ld b, SCREEN_HEIGHT
-.loop
- ld c, SCREEN_WIDTH
-.loop2
- ld a, [hli]
- ld [de], a
- inc de
- dec c
- jr nz, .loop2
- ld a, l
- add 4
- ld l, a
- jr nc, .carry
- inc h
-
-.carry
- dec b
- jr nz, .loop
- ret
-
-PhoneRing_CopyTilemapAtOnce: ; 4d188
- ld a, [hCGB]
- and a
- jp z, WaitBGMap
- ld a, [wSpriteUpdatesEnabled]
- cp $0
- jp z, WaitBGMap
-
-; What follows is a modified version of CopyTilemapAtOnce.
- 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 $8f
- jr c, .wait
-
- di
- ld a, BANK(VBGMap2)
- ld [rVBK], a
- hlcoord 0, 0, AttrMap
- call .CopyTilemapAtOnce
- ld a, BANK(VBGMap0)
- ld [rVBK], a
- hlcoord 0, 0
- call .CopyTilemapAtOnce
-.wait2
- ld a, [rLY]
- cp $8f
- jr c, .wait2
- ei
-
- pop af
- ld [hMapAnims], a
- pop af
- ld [hBGMapMode], a
- ret
-
-.CopyTilemapAtOnce: ; 4d1cb
- 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, rSTAT % $100
-
-.loop
-rept SCREEN_WIDTH / 2
- pop de
-.loop\@
- ld a, [$ff00+c]
- and b
- jr nz, .loop\@
- 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
+INCLUDE "engine/routines/loadmappart.asm"
+INCLUDE "engine/routines/phonering_copytilemapatonce.asm"
Shrink1Pic: ; 4d249
INCBIN "gfx/shrink/shrink1.2bpp.lz"
@@ -534,129 +223,12 @@ INCBIN "gfx/shrink/shrink1.2bpp.lz"
Shrink2Pic: ; 4d2d9
INCBIN "gfx/shrink/shrink2.2bpp.lz"
-LinkMonStatsScreen: ; 4d319
- ld a, [wMenuCursorY]
- dec a
- ld [CurPartyMon], a
- call LowVolume
- predef StatsScreenInit
- ld a, [CurPartyMon]
- inc a
- ld [wMenuCursorY], a
- call ClearScreen
- call ClearBGPalettes
- call MaxVolume
- farcall LoadTradeScreenBorder
- farcall Link_WaitBGMap
- farcall InitTradeSpeciesList
- farcall SetTradeRoomBGPals
- call WaitBGMap2
- ret
-
-Link_WaitBGMap: ; 4d354
- call WaitBGMap
- call WaitBGMap2
- ret
-
-LinkTextbox2: ; 4d35b
- ld h, d
- ld l, e
- push bc
- push hl
- call .PlaceBorder
- pop hl
- pop bc
- ld de, AttrMap - TileMap
- add hl, de
- inc b
- inc b
- inc c
- inc c
- ld a, $7
-.row
- push bc
- push hl
-.col
- ld [hli], a
- dec c
- jr nz, .col
- pop hl
- ld de, SCREEN_WIDTH
- add hl, de
- pop bc
- dec b
- jr nz, .row
- ret
-
-.PlaceBorder: ; 4d37e
- push hl
- ld a, $76
- ld [hli], a
- inc a
- call .PlaceRow
- inc a
- ld [hl], a
- pop hl
- ld de, SCREEN_WIDTH
- add hl, de
-.loop
- push hl
- ld a, "┌"
- ld [hli], a
- ld a, " "
- call .PlaceRow
- ld [hl], "─"
- pop hl
- ld de, SCREEN_WIDTH
- add hl, de
- dec b
- jr nz, .loop
- ld a, "┐"
- ld [hli], a
- ld a, "│"
- call .PlaceRow
- ld [hl], "└"
- ret
-
-.PlaceRow: ; 4d3ab
- ld d, c
-.row_loop
- ld [hli], a
- dec d
- jr nz, .row_loop
- ret
-
+INCLUDE "engine/link_2.asm"
INCLUDE "engine/delete_save_change_clock.asm"
INCLUDE "tilesets/tileset_headers.asm"
-INCLUDE "engine/flag_predef.asm"
-INCLUDE "engine/trademon_frontpic.asm"
-
-CheckPokerus: ; 4d860
-; Return carry if a monster in your party has Pokerus
-
-; Get number of monsters to iterate over
- ld a, [PartyCount]
- and a
- jr z, .NoPokerus
- ld b, a
-; Check each monster in the party for Pokerus
- ld hl, PartyMon1PokerusStatus
- ld de, PARTYMON_STRUCT_LENGTH
-.Check:
- ld a, [hl]
- and $0f ; only the bottom nybble is used
- jr nz, .HasPokerus
-; Next PartyMon
- add hl, de
- dec b
- jr nz, .Check
-.NoPokerus:
- and a
- ret
-.HasPokerus:
- scf
- ret
-
+INCLUDE "engine/routines/flagpredef.asm"
+INCLUDE "engine/routines/trademonfrontpic.asm"
+INCLUDE "engine/routines/checkpokerus.asm"
INCLUDE "event/lucky_number.asm"
INCLUDE "engine/caught_data.asm"
INCLUDE "engine/search2.asm"
@@ -667,7 +239,7 @@ INCLUDE "engine/init_hof_credits.asm"
INCLUDE "mobile/get_trainer_class.asm"
INCLUDE "battle/sliding_intro.asm"
INCLUDE "mobile/print_opp_message.asm"
-INCLUDE "engine/check_battle_scene.asm"
+INCLUDE "engine/routines/checkbattlescene.asm"
INCLUDE "engine/gbc_only.asm"
INCLUDE "event/poke_seer.asm"
@@ -685,9 +257,9 @@ INCLUDE "engine/tempmon.asm"
INCLUDE "text/types.asm"
INCLUDE "text/unused_gen_1_trainers.asm"
INCLUDE "engine/mon_stats.asm"
-INCLUDE "engine/init_list.asm"
+INCLUDE "engine/routines/initlist.asm"
INCLUDE "engine/experience.asm"
-INCLUDE "engine/switch_party_mons.asm"
+INCLUDE "engine/routines/switchpartymons.asm"
INCLUDE "gfx/load_pics.asm"
INCLUDE "engine/move_mon_wo_mail.asm"
INCLUDE "data/pokemon/base_stats.asm"
@@ -751,11 +323,7 @@ INCLUDE "engine/timeofdaypals.asm"
INCLUDE "engine/battle_transition.asm"
INCLUDE "event/field_moves.asm"
INCLUDE "event/magnet_train.asm"
-
-BattleStart_CopyTilemapAtOnce: ; 8cf4f
- call CGBOnly_CopyTilemapAtOnce
- ret
-
+INCLUDE "engine/routines/battlestart_copytilemapatonce.asm"
INCLUDE "engine/sprites.asm"
INCLUDE "engine/mon_icons.asm"
@@ -897,8 +465,8 @@ SECTION "bank3E", ROMX
INCLUDE "gfx/font.asm"
INCLUDE "engine/time_capsule.asm"
INCLUDE "event/name_rater.asm"
-INCLUDE "engine/play_slow_cry.asm"
-INCLUDE "engine/new_pokedex_entry.asm"
+INCLUDE "engine/routines/playslowcry.asm"
+INCLUDE "engine/routines/newpokedexentry.asm"
INCLUDE "engine/time_capsule_2.asm"
INCLUDE "engine/unown_dex.asm"
INCLUDE "event/magikarp.asm"
@@ -973,15 +541,7 @@ INCLUDE "text/phone/extra2.asm"
SECTION "bank5E", ROMX
-_UpdateBattleHUDs:
- farcall DrawPlayerHUD
- ld hl, PlayerHPPal
- call SetHPPal
- farcall DrawEnemyHUD
- ld hl, EnemyHPPal
- call SetHPPal
- farcall FinishBattleAnim
- ret
+INCLUDE "engine/routines/updatebattlehuds.asm"
SECTION "mobile_5e", ROMX
@@ -1036,11 +596,15 @@ INCLUDE "engine/print_party.asm"
SECTION "bank77_2", ROMX
-INCLUDE "engine/printhoursmins.asm"
+INCLUDE "engine/routines/printhoursmins.asm"
INCLUDE "engine/diploma.asm"
INCLUDE "engine/pokedex_3.asm"
INCLUDE "event/catch_tutorial_input.asm"
-INCLUDE "engine/pokegear_2.asm"
+INCLUDE "engine/routines/townmap_convertlinebreakcharacters.asm"
+
+PokegearGFX: ; 1de2e4
+INCBIN "gfx/pokegear/pokegear.2bpp.lz"
+
INCLUDE "engine/european_mail.asm"