Identify more labels, and use the jumptable macro when possible

This commit is contained in:
Rangi
2020-07-01 13:13:49 -04:00
parent e171c84c29
commit fce6243b43
26 changed files with 41 additions and 253 deletions

View File

@@ -204,16 +204,7 @@ _BattleTowerBattle:
ret
.do_dw
ld a, [wBattleTowerBattleEnded]
ld e, a
ld d, 0
ld hl, .dw
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .dw, wBattleTowerBattleEnded
.dw
dw RunBattleTowerTrainer
@@ -625,16 +616,7 @@ Function1704e1:
ret
.DoJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .dw
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .dw, wJumptableIndex
.dw
dw .Jumptable_0
@@ -869,16 +851,7 @@ Function1704e1:
db "れきだいりーダーいちらん@"
BattleTowerAction:
ld a, [wScriptVar]
ld e, a
ld d, 0
ld hl, .dw
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .dw, wScriptVar
.dw
dw BattleTowerAction_CheckExplanationRead

View File

@@ -154,16 +154,7 @@ CutGrassGFX:
INCBIN "gfx/overworld/cut_grass.2bpp"
OWCutJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .dw
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .dw, wJumptableIndex
.dw
dw Cut_SpawnAnimateTree

View File

@@ -272,16 +272,7 @@ SetMagnetTrainPals:
ret
MagnetTrain_Jumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
dw .InitPlayerSpriteAnim

View File

@@ -18,19 +18,9 @@ BankOfMom:
ret
.RunJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .dw
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .dw, wJumptableIndex
.dw
dw .CheckIfBankInitialized
dw .InitializeBank
dw .IsThisAboutYourMoney
@@ -98,7 +88,7 @@ BankOfMom:
ld hl, MomBankWhatDoYouWantToDoText
call PrintText
call LoadStandardMenuHeader
ld hl, MenuHeader_0x166b5
ld hl, BankOfMom_MenuHeader
call CopyMenuHeader
call VerticalMenu
call CloseWindow
@@ -659,13 +649,13 @@ Mom_DepositString:
Mom_HeldString:
db "HELD@"
MenuHeader_0x166b5:
BankOfMom_MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 10, 10
dw MenuData_0x166bd
dw .MenuData
db 1 ; default option
MenuData_0x166bd:
.MenuData:
db STATICMENU_CURSOR ; flags
db 4 ; items
db "GET@"

View File

@@ -204,8 +204,6 @@ endr
INCLUDE "data/items/mom_phone.asm"
db 0, 0, 0 ; unused
MomHiHowAreYouText:
text_far _MomHiHowAreYouText
text_end

View File

@@ -75,16 +75,7 @@ _CardFlip:
ret
.CardFlip:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
dw .AskPlayWithThree

View File

@@ -169,16 +169,7 @@ PlaceStartCancelBoxBorder:
ret
UnownPuzzleJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
dw .Function

View File

@@ -230,16 +230,7 @@ Function81a74:
jr nz, .asm_81aab
.asm_81a8b
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, Jumptable_81acf
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable Jumptable_81acf, wJumptableIndex
.asm_81a9a
call Function81eca

View File

@@ -363,16 +363,7 @@ NamingScreenJoypadLoop:
ret
.RunJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, $0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
dw .InitCursor
@@ -1050,16 +1041,7 @@ INCBIN "gfx/icons/mail_big.2bpp"
ret
.DoJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
dw .init_blinking_cursor

View File

@@ -91,16 +91,7 @@ StringOptions:
db "CANCEL@"
GetOptionPointer:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Pointers
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Pointers, wJumptableIndex
.Pointers:
; entries correspond to OPT_* constants

View File

@@ -384,16 +384,7 @@ CrystalIntro:
ret
IntroSceneJumper:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, IntroScenes
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable IntroScenes, wJumptableIndex
IntroScenes:
dw IntroScene1

View File

@@ -228,16 +228,7 @@ DoTradeAnimation:
ret
.DoTradeAnimCommand:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .JumpTable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .JumpTable, wJumptableIndex
.JumpTable:
; entries correspond to macros/scripts/trade_anims.asm enumeration

View File

@@ -432,16 +432,7 @@ Pokegear_FinishTilemap:
ret
PokegearJumptable:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
; entries correspond to POKEGEARSTATE_* constants

View File

@@ -16,16 +16,7 @@ PlayRadioShow:
ld [wCurRadioLine], a
.ok
; Jump to the currently loaded station. The index to which we need to jump is in wCurRadioLine.
ld a, [wCurRadioLine]
ld e, a
ld d, 0
ld hl, RadioJumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable RadioJumptable, wCurRadioLine
RadioJumptable:
; entries correspond to constants/radio_constants.asm

View File

@@ -16,16 +16,7 @@ Printer_StartTransmission:
ret
PrinterJumptableIteration:
ld a, [wJumptableIndex]
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .Jumptable, wJumptableIndex
.Jumptable:
dw Print_InitPrinterHandshake ; 00

View File

@@ -224,16 +224,7 @@ ReplaceTimeOfDayPals:
dc 3, 2, 1, 0
GetTimePalette:
ld a, [wTimeOfDay]
ld e, a
ld d, 0
ld hl, .TimePalettes
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
jumptable .TimePalettes, wTimeOfDay
.TimePalettes:
dw .MorningPalette