diff --git a/audio/engine.asm b/audio/engine.asm index 9149223eb..fa3a08297 100644 --- a/audio/engine.asm +++ b/audio/engine.asm @@ -223,16 +223,21 @@ UpdateChannels: jp hl .ChannelFunctions: + table_width 2, UpdateChannels.ChannelFunctions +; music channels dw .Channel1 dw .Channel2 dw .Channel3 dw .Channel4 -; sfx ch ptrs are identical to music chs -; ..except 5 + assert_table_length NUM_MUSIC_CHANS +; sfx channels +; identical to music channels, except .Channel5 is not disabled by the low-HP danger sound +; (instead, PlayDanger does not play the danger sound if sfx is playing) dw .Channel5 dw .Channel6 dw .Channel7 dw .Channel8 + assert_table_length NUM_CHANNELS .Channel1: ld a, [wLowHealthAlarm] @@ -2777,16 +2782,19 @@ StereoTracks: db $11, $22, $44, $88 ChannelPointers: + table_width 2, ChannelPointers ; music channels dw wChannel1 dw wChannel2 dw wChannel3 dw wChannel4 + assert_table_length NUM_MUSIC_CHANS ; sfx channels dw wChannel5 dw wChannel6 dw wChannel7 dw wChannel8 + assert_table_length NUM_CHANNELS ClearChannels:: ; runs ClearChannel for all 4 channels diff --git a/constants/battle_constants.asm b/constants/battle_constants.asm index 4f3ea9703..d39b45381 100644 --- a/constants/battle_constants.asm +++ b/constants/battle_constants.asm @@ -263,3 +263,7 @@ ALL_STATUS EQU (1 << PSN) | (1 << BRN) | (1 << FRZ) | (1 << PAR) | SLP BATTLERESULT_CAUGHT_CELEBI EQU 6 BATTLERESULT_BOX_FULL EQU 7 BATTLERESULT_BITMASK EQU (1 << BATTLERESULT_CAUGHT_CELEBI) | (1 << BATTLERESULT_BOX_FULL) + +; link_battle_record struct +LINK_BATTLE_RECORD_LENGTH EQU 2 + (NAME_LENGTH - 1) + 2 * 3 +NUM_LINK_BATTLE_RECORDS EQU 5 diff --git a/constants/item_data_constants.asm b/constants/item_data_constants.asm index 4c2d761cd..2d955c17e 100644 --- a/constants/item_data_constants.asm +++ b/constants/item_data_constants.asm @@ -17,6 +17,7 @@ ITEMATTR_STRUCT_LENGTH EQU _RS const KEY_ITEM ; 2 const BALL ; 3 const TM_HM ; 4 +NUM_ITEM_TYPES EQU const_value - 1 ; item menu types ; UseItem.dw indexes (see engine/items/pack.asm) diff --git a/constants/pokemon_data_constants.asm b/constants/pokemon_data_constants.asm index 1234d105c..f4d02327e 100644 --- a/constants/pokemon_data_constants.asm +++ b/constants/pokemon_data_constants.asm @@ -49,6 +49,7 @@ GENDER_UNKNOWN EQU -1 const GROWTH_MEDIUM_SLOW const GROWTH_FAST const GROWTH_SLOW +NUM_GROWTH_RATES EQU const_value ; wBaseEggGroups values const_def 1 diff --git a/data/decorations/decorations.asm b/data/decorations/decorations.asm index a5519efa0..9cd24d1fc 100644 --- a/data/decorations/decorations.asm +++ b/data/decorations/decorations.asm @@ -47,6 +47,7 @@ DecorationIDs: db DECO_GEODUDE_DOLL ; 30 db DECO_MACHOP_DOLL ; 31 db DECO_TENTACOOL_DOLL ; 32 + db DECO_BIG_SNORLAX_DOLL ; 1a db DECO_BIG_ONIX_DOLL ; 1b db DECO_BIG_LAPRAS_DOLL ; 1c diff --git a/data/growth_rates.asm b/data/growth_rates.asm index 92948b3d3..cd07fc130 100644 --- a/data/growth_rates.asm +++ b/data/growth_rates.asm @@ -11,9 +11,11 @@ ENDM GrowthRates: ; entries correspond to GROWTH_* (see constants/pokemon_data_constants.asm) + table_width 4, GrowthRates growth_rate 1, 1, 0, 0, 0 ; Medium Fast growth_rate 3, 4, 10, 0, 30 ; Slightly Fast growth_rate 3, 4, 20, 0, 70 ; Slightly Slow growth_rate 6, 5, -15, 100, 140 ; Medium Slow growth_rate 4, 5, 0, 0, 0 ; Fast growth_rate 5, 4, 0, 0, 0 ; Slow + assert_table_length NUM_GROWTH_RATES diff --git a/data/items/pocket_names.asm b/data/items/pocket_names.asm index 880e08fe3..9669c5278 100644 --- a/data/items/pocket_names.asm +++ b/data/items/pocket_names.asm @@ -1,9 +1,11 @@ ItemPocketNames: ; entries correspond to item type constants + table_width 2, ItemPocketNames dw .Item dw .Key dw .Ball dw .TM + assert_table_length NUM_ITEM_TYPES .Item: db "ITEM POCKET@" .Key: db "KEY POCKET@" diff --git a/data/moves/tmhm_moves.asm b/data/moves/tmhm_moves.asm index 7ecf9fec8..50f423596 100644 --- a/data/moves/tmhm_moves.asm +++ b/data/moves/tmhm_moves.asm @@ -17,6 +17,7 @@ endc PURGE MOVE_FOR_TM n = n + 1 endr + assert_table_length NUM_TMS ; HMs n = 1 @@ -30,6 +31,7 @@ endc PURGE MOVE_FOR_HM n = n + 1 endr + assert_table_length NUM_TMS + NUM_HMS ; Move tutor n = 1 @@ -43,7 +45,6 @@ endc PURGE MOVE_FOR_MT n = n + 1 endr - assert_table_length NUM_TM_HM_TUTOR db 0 ; end diff --git a/data/radio/buenas_passwords.asm b/data/radio/buenas_passwords.asm index 078bcdd4c..341b86e57 100644 --- a/data/radio/buenas_passwords.asm +++ b/data/radio/buenas_passwords.asm @@ -13,7 +13,7 @@ BuenasPasswordTable: dw .RadioStations assert_table_length NUM_PASSWORD_CATEGORIES - ; string type, points, option 1, option 2, option 3 + ; string type, points, option 1, option 2, option 3 .JohtoStarters: db BUENA_MON, 10, CYNDAQUIL, TOTODILE, CHIKORITA .Beverages: db BUENA_ITEM, 12, FRESH_WATER, SODA_POP, LEMONADE .HealingItems: db BUENA_ITEM, 12, POTION, ANTIDOTE, PARLYZ_HEAL diff --git a/data/sprites/map_objects.asm b/data/sprites/map_objects.asm index 60a718131..5bc0e0eb6 100644 --- a/data/sprites/map_objects.asm +++ b/data/sprites/map_objects.asm @@ -298,12 +298,12 @@ SpriteMovementData:: db 0 ; flags2 db SWIMMING ; palette flags -; 25 + assert_table_length NUM_SPRITEMOVEDATA + +; unused db SPRITEMOVEFN_00 ; movement function db DOWN ; facing db OBJECT_ACTION_STAND ; action db 0 ; flags1 db 0 ; flags2 db 0 ; palette flags - - assert_table_length NUM_SPRITEMOVEDATA + 1 diff --git a/data/wild/fish.asm b/data/wild/fish.asm index b849b933f..5795dd80e 100644 --- a/data/wild/fish.asm +++ b/data/wild/fish.asm @@ -2,7 +2,8 @@ time_group EQUS "0," ; use the nth TimeFishGroups entry fishgroup: MACRO ; chance, old rod, good rod, super rod - dbwww \1, \2, \3, \4 + db \1 + dw \2, \3, \4 ENDM FishGroups: diff --git a/engine/battle/core.asm b/engine/battle/core.asm index 654559b89..d176c60c4 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -8448,9 +8448,6 @@ IsMobileBattle2: cp LINK_MOBILE ret -LINK_BATTLE_RECORD_LENGTH EQUS "(sLinkBattleRecord1End - sLinkBattleRecord1)" ; 18 -NUM_LINK_BATTLE_RECORDS EQUS "((sLinkBattleStatsEnd - sLinkBattleRecord) / LINK_BATTLE_RECORD_LENGTH)" ; 5 - _DisplayLinkRecord: ld a, BANK(sLinkBattleStats) call OpenSRAM diff --git a/engine/overworld/events.asm b/engine/overworld/events.asm index 0bdab70d2..4118d0efd 100644 --- a/engine/overworld/events.asm +++ b/engine/overworld/events.asm @@ -804,7 +804,6 @@ PlayerMovementPointers: ld a, BANK(Script_ForcedMovement) ld hl, Script_ForcedMovement call CallScript -; ld a, -1 ld c, a scf ret diff --git a/engine/overworld/map_object_action.asm b/engine/overworld/map_object_action.asm index e44fdfeb0..7018bded8 100644 --- a/engine/overworld/map_object_action.asm +++ b/engine/overworld/map_object_action.asm @@ -1,7 +1,7 @@ ObjectActionPairPointers: ; entries correspond to OBJECT_ACTION_* constants (see constants/map_object_constants.asm) -; normal action, frozen action table_width 2 + 2, ObjectActionPairPointers + ; normal action, frozen action dw SetFacingStanding, SetFacingStanding dw SetFacingStandAction, SetFacingCurrent dw SetFacingStepAction, SetFacingCurrent diff --git a/macros/legacy.asm b/macros/legacy.asm index 18ee9f872..01df8e87e 100644 --- a/macros/legacy.asm +++ b/macros/legacy.asm @@ -33,11 +33,11 @@ noise: MACRO ENDM notetype: MACRO -IF _NARG >= 2 +if _NARG >= 2 note_type \1, \2 >> 4, \2 & $0f -ELSE +else note_type \1 -ENDC +endc ENDM pitchoffset: MACRO @@ -57,11 +57,11 @@ ENDM unknownmusic0xde EQUS "sound_duty" sound_duty: MACRO db duty_cycle_pattern_cmd -IF _NARG == 4 +if _NARG == 4 db \1 | (\2 << 2) | (\3 << 4) | (\4 << 6) -ELSE +else db \1 -ENDC +endc ENDM togglesfx EQUS "toggle_sfx" diff --git a/macros/scripts/audio.asm b/macros/scripts/audio.asm index e28dee7e1..9997fb6b1 100644 --- a/macros/scripts/audio.asm +++ b/macros/scripts/audio.asm @@ -26,21 +26,21 @@ ENDM square_note: MACRO db \1 ; length - IF \3 < 0 + if \3 < 0 dn \2, %1000 | (\3 * -1) ; volume envelope - ELSE + else dn \2, \3 ; volume envelope - ENDC + endc dw \4 ; frequency ENDM noise_note: MACRO db \1 ; length - IF \3 < 0 + if \3 < 0 dn \2, %1000 | (\3 * -1) ; volume envelope - ELSE + else dn \2, \3 ; volume envelope - ENDC + endc db \4 ; frequency ENDM @@ -60,13 +60,13 @@ ENDM note_type: MACRO db note_type_cmd db \1 ; note length - IF _NARG >= 2 - IF \3 < 0 + if _NARG >= 2 + if \3 < 0 dn \2, %1000 | (\3 * -1) ; volume envelope - ELSE + else dn \2, \3 ; volume envelope - ENDC - ENDC + endc + endc ENDM ; only valid on the noise channel @@ -95,21 +95,21 @@ ENDM const volume_envelope_cmd ; $dc volume_envelope: MACRO db volume_envelope_cmd - IF \2 < 0 + if \2 < 0 dn \1, %1000 | (\2 * -1) ; volume envelope - ELSE + else dn \1, \2 ; volume envelope - ENDC + endc ENDM const pitch_sweep_cmd ; $dd pitch_sweep: MACRO db pitch_sweep_cmd - IF \2 < 0 + if \2 < 0 dn \1, %1000 | (\2 * -1) ; pitch sweep - ELSE + else dn \1, \2 ; pitch sweep - ENDC + endc ENDM const duty_cycle_pattern_cmd ; $de @@ -134,11 +134,11 @@ ENDM vibrato: MACRO db vibrato_cmd db \1 ; delay - IF _NARG > 2 + if _NARG > 2 dn \2, \3 ; extent, rate - ELSE + else db \2 ; LEGACY: Support for 1-arg extent - ENDC + endc ENDM const unknownmusic0xe2_cmd ; $e2 @@ -150,9 +150,9 @@ ENDM const toggle_noise_cmd ; $e3 toggle_noise: MACRO db toggle_noise_cmd - IF _NARG > 0 + if _NARG > 0 db \1 ; drum kit - ENDC + endc ENDM const force_stereo_panning_cmd ; $e4 @@ -164,11 +164,11 @@ ENDM const volume_cmd ; $e5 volume: MACRO db volume_cmd - IF _NARG > 1 + if _NARG > 1 dn \1, \2 ; left volume, right volume - ELSE + else db \1 ; LEGACY: Support for 1-arg volume - ENDC + endc ENDM const pitch_offset_cmd ; $e6 @@ -232,9 +232,9 @@ ENDM const sfx_toggle_noise_cmd ; $f0 sfx_toggle_noise: MACRO db sfx_toggle_noise_cmd - IF _NARG > 0 + if _NARG > 0 db \1 ; drum kit - ENDC + endc ENDM const music0xf1_cmd ; $f1 diff --git a/sram.asm b/sram.asm index baf1c86df..e981768be 100644 --- a/sram.asm +++ b/sram.asm @@ -142,11 +142,13 @@ sLinkBattleLosses:: dw sLinkBattleDraws:: dw sLinkBattleRecord:: + table_width LINK_BATTLE_RECORD_LENGTH, sLinkBattleRecord sLinkBattleRecord1:: link_battle_record sLinkBattleRecord1 sLinkBattleRecord2:: link_battle_record sLinkBattleRecord2 sLinkBattleRecord3:: link_battle_record sLinkBattleRecord3 sLinkBattleRecord4:: link_battle_record sLinkBattleRecord4 sLinkBattleRecord5:: link_battle_record sLinkBattleRecord5 + assert_table_length NUM_LINK_BATTLE_RECORDS sLinkBattleStatsEnd::