summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRangi <remy.oukaour+rangi42@gmail.com>2020-07-01 13:08:08 -0400
committerRangi <remy.oukaour+rangi42@gmail.com>2020-07-01 13:13:40 -0400
commite6f75432928ccd915016162a68df43b0adf6ce04 (patch)
tree8b3efc7441195cb12dcdbd34442da00f45e2fdcc
parent534863abe1d7c57707135574ef8bb1094aa5be22 (diff)
Identify more labels, and use the jumptable macro when possible
-rw-r--r--data/items/mom_phone.asm2
-rw-r--r--engine/events/field_moves.asm11
-rw-r--r--engine/events/magnet_train.asm11
-rw-r--r--engine/events/mom.asm20
-rw-r--r--engine/events/mom_phone.asm2
-rw-r--r--engine/games/card_flip.asm11
-rw-r--r--engine/games/unown_puzzle.asm11
-rw-r--r--engine/menus/debug.asm11
-rw-r--r--engine/menus/naming_screen.asm22
-rw-r--r--engine/menus/options_menu.asm11
-rw-r--r--engine/movie/trade_animation.asm11
-rw-r--r--engine/pokegear/pokegear.asm11
-rw-r--r--engine/pokegear/radio.asm11
-rw-r--r--engine/printer/printer_serial.asm11
-rw-r--r--engine/tilesets/timeofday_pals.asm11
-rw-r--r--home/init.asm2
-rw-r--r--home/map_objects.asm8
-rw-r--r--macros/code.asm4
-rw-r--r--wram.asm1
19 files changed, 30 insertions, 152 deletions
diff --git a/data/items/mom_phone.asm b/data/items/mom_phone.asm
index 407a9a01..27b795f2 100644
--- a/data/items/mom_phone.asm
+++ b/data/items/mom_phone.asm
@@ -25,3 +25,5 @@ MomItems_2:
momitem 50000, 8000, MOM_DOLL, DECO_PIKACHU_DOLL
momitem 100000, 22800, MOM_DOLL, DECO_BIG_SNORLAX_DOLL
.End
+
+ dt 0 ; unused
diff --git a/engine/events/field_moves.asm b/engine/events/field_moves.asm
index e4be7d29..61dba7d9 100644
--- a/engine/events/field_moves.asm
+++ b/engine/events/field_moves.asm
@@ -149,16 +149,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
diff --git a/engine/events/magnet_train.asm b/engine/events/magnet_train.asm
index 715c801c..b6b6e995 100644
--- a/engine/events/magnet_train.asm
+++ b/engine/events/magnet_train.asm
@@ -271,16 +271,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
diff --git a/engine/events/mom.asm b/engine/events/mom.asm
index 18572296..104430c1 100644
--- a/engine/events/mom.asm
+++ b/engine/events/mom.asm
@@ -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_0x16914
+ ld hl, BankOfMom_MenuHeader
call CopyMenuHeader
call VerticalMenu
call CloseWindow
@@ -661,13 +651,13 @@ Mom_DepositString:
Mom_HeldString:
db "HELD@"
-MenuHeader_0x16914:
+BankOfMom_MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 10, 10
- dw MenuData_0x1691c
+ dw .MenuData
db 1 ; default option
-MenuData_0x1691c:
+.MenuData:
db STATICMENU_CURSOR ; flags
db 4 ; items
db "GET@"
diff --git a/engine/events/mom_phone.asm b/engine/events/mom_phone.asm
index cbd91327..697a47a6 100644
--- a/engine/events/mom_phone.asm
+++ b/engine/events/mom_phone.asm
@@ -204,8 +204,6 @@ endr
INCLUDE "data/items/mom_phone.asm"
- db 0, 0, 0 ; unused
-
MomHiHowAreYouText:
text_far _MomHiHowAreYouText
text_end
diff --git a/engine/games/card_flip.asm b/engine/games/card_flip.asm
index 82faf692..0e879ff0 100644
--- a/engine/games/card_flip.asm
+++ b/engine/games/card_flip.asm
@@ -74,16 +74,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
diff --git a/engine/games/unown_puzzle.asm b/engine/games/unown_puzzle.asm
index 6151107d..35caada2 100644
--- a/engine/games/unown_puzzle.asm
+++ b/engine/games/unown_puzzle.asm
@@ -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
diff --git a/engine/menus/debug.asm b/engine/menus/debug.asm
index b1adf7d1..0df9ea3f 100644
--- a/engine/menus/debug.asm
+++ b/engine/menus/debug.asm
@@ -235,16 +235,7 @@ DebugColorMain:
jr nz, .PreviousMon
.asm_fd49e
- ld a, [wJumptableIndex]
- ld e, a
- ld d, 0
- ld hl, Jumptable_fd4e2
- add hl, de
- add hl, de
- ld a, [hli]
- ld h, [hl]
- ld l, a
- jp hl
+ jumptable Jumptable_fd4e2, wJumptableIndex
.NextMon:
call DebugColor_BackupSpriteColors
diff --git a/engine/menus/naming_screen.asm b/engine/menus/naming_screen.asm
index 8153d296..f45916c2 100644
--- a/engine/menus/naming_screen.asm
+++ b/engine/menus/naming_screen.asm
@@ -341,16 +341,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
@@ -1035,16 +1026,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
diff --git a/engine/menus/options_menu.asm b/engine/menus/options_menu.asm
index 4e5ea3b7..216d2e11 100644
--- a/engine/menus/options_menu.asm
+++ b/engine/menus/options_menu.asm
@@ -88,16 +88,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
diff --git a/engine/movie/trade_animation.asm b/engine/movie/trade_animation.asm
index 3e4826ad..30a8de02 100644
--- a/engine/movie/trade_animation.asm
+++ b/engine/movie/trade_animation.asm
@@ -215,16 +215,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
diff --git a/engine/pokegear/pokegear.asm b/engine/pokegear/pokegear.asm
index c3afe830..234dfca1 100644
--- a/engine/pokegear/pokegear.asm
+++ b/engine/pokegear/pokegear.asm
@@ -424,16 +424,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
diff --git a/engine/pokegear/radio.asm b/engine/pokegear/radio.asm
index d161e770..a13de99b 100644
--- a/engine/pokegear/radio.asm
+++ b/engine/pokegear/radio.asm
@@ -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
diff --git a/engine/printer/printer_serial.asm b/engine/printer/printer_serial.asm
index d047418e..9d0bd907 100644
--- a/engine/printer/printer_serial.asm
+++ b/engine/printer/printer_serial.asm
@@ -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
diff --git a/engine/tilesets/timeofday_pals.asm b/engine/tilesets/timeofday_pals.asm
index 0c676d91..24b2211a 100644
--- a/engine/tilesets/timeofday_pals.asm
+++ b/engine/tilesets/timeofday_pals.asm
@@ -150,16 +150,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
diff --git a/home/init.asm b/home/init.asm
index 8c51e9dc..fc04cfd1 100644
--- a/home/init.asm
+++ b/home/init.asm
@@ -83,7 +83,7 @@ Init::
call ClearSprites
- ld a, BANK(WriteOAMDMACodeToHRAM)
+ ld a, BANK(WriteOAMDMACodeToHRAM) ; aka BANK(GameInit)
rst Bankswitch
call WriteOAMDMACodeToHRAM
diff --git a/home/map_objects.asm b/home/map_objects.asm
index d811d421..edbc23f1 100644
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -237,7 +237,7 @@ CheckObjectTime::
ld a, [hl]
cp -1
jr z, .timeofday_always
- ld hl, .TimeOfDayValues_17bb
+ ld hl, .TimesOfDay
ld a, [wTimeOfDay]
add l
ld l, a
@@ -257,7 +257,7 @@ CheckObjectTime::
and a
ret
-.TimeOfDayValues_17bb:
+.TimesOfDay:
; entries correspond to TimeOfDay values
db MORN
db DAY
@@ -362,7 +362,7 @@ CopyPlayerObjectTemplate::
call CopyBytes
ret
-Function1855: ; unreferenced
+DeleteFollowerMapObject: ; unreferenced
call GetMapObject
ld hl, MAPOBJECT_OBJECT_STRUCT_ID
add hl, bc
@@ -376,7 +376,7 @@ Function1855: ; unreferenced
pop af
cp -1
ret z
- cp $d
+ cp NUM_OBJECT_STRUCTS
ret nc
ld b, a
ld a, [wObjectFollow_Leader]
diff --git a/macros/code.asm b/macros/code.asm
index c92e7132..9de3dd1e 100644
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -11,7 +11,11 @@ ENDM
; Design patterns
jumptable: MACRO
+if "\2" == "hl"
+ ld a, [hl]
+else
ld a, [\2]
+endc
ld e, a
ld d, 0
ld hl, \1
diff --git a/wram.asm b/wram.asm
index fe0abfd0..ea05aa8a 100644
--- a/wram.asm
+++ b/wram.asm
@@ -1348,6 +1348,7 @@ wTextDelayFrames:: db
wVBlankOccurred:: db
wceeb:: db
+
wDefaultSpawnpoint:: db
UNION