ref: dbe2360ecd3eb11fd144168427e1323f5e1b2ec2
parent: 8daf8fe19c9e356df34ca8da3423618999d4405a
author: Rangi <[email protected]>
date: Mon Mar 22 12:41:17 EDT 2021
Miscellaneous cleanup
--- a/audio/engine.asm
+++ b/audio/engine.asm
@@ -223,16 +223,21 @@
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 @@
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
--- a/constants/battle_constants.asm
+++ b/constants/battle_constants.asm
@@ -263,3 +263,7 @@
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
--- a/constants/item_data_constants.asm
+++ b/constants/item_data_constants.asm
@@ -17,6 +17,7 @@
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)
--- a/constants/pokemon_data_constants.asm
+++ b/constants/pokemon_data_constants.asm
@@ -49,6 +49,7 @@
const GROWTH_MEDIUM_SLOW
const GROWTH_FAST
const GROWTH_SLOW
+NUM_GROWTH_RATES EQU const_value
; wBaseEggGroups values
const_def 1
--- a/data/decorations/decorations.asm
+++ b/data/decorations/decorations.asm
@@ -47,6 +47,7 @@
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
--- a/data/growth_rates.asm
+++ b/data/growth_rates.asm
@@ -11,6 +11,7 @@
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
@@ -17,3 +18,4 @@
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
--- 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@"
--- a/data/moves/tmhm_moves.asm
+++ b/data/moves/tmhm_moves.asm
@@ -17,6 +17,7 @@
PURGE MOVE_FOR_TM
n = n + 1
endr
+ assert_table_length NUM_TMS
; HMs
n = 1
@@ -30,6 +31,7 @@
PURGE MOVE_FOR_HM
n = n + 1
endr
+ assert_table_length NUM_TMS + NUM_HMS
; Move tutor
n = 1
@@ -43,7 +45,6 @@
PURGE MOVE_FOR_MT
n = n + 1
endr
-
assert_table_length NUM_TM_HM_TUTOR
db 0 ; end
--- a/data/radio/buenas_passwords.asm
+++ b/data/radio/buenas_passwords.asm
@@ -13,7 +13,7 @@
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
--- a/data/sprites/map_objects.asm
+++ b/data/sprites/map_objects.asm
@@ -298,7 +298,9 @@
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
@@ -305,5 +307,3 @@
db 0 ; flags1
db 0 ; flags2
db 0 ; palette flags
-
- assert_table_length NUM_SPRITEMOVEDATA + 1
--- a/data/wild/fish.asm
+++ b/data/wild/fish.asm
@@ -2,7 +2,8 @@
fishgroup: MACRO
; chance, old rod, good rod, super rod
- dbwww \1, \2, \3, \4
+ db \1
+ dw \2, \3, \4
ENDM
FishGroups:
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -8448,9 +8448,6 @@
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
--- a/engine/overworld/events.asm
+++ b/engine/overworld/events.asm
@@ -804,7 +804,6 @@
ld a, BANK(Script_ForcedMovement)
ld hl, Script_ForcedMovement
call CallScript
-; ld a, -1
ld c, a
scf
ret
--- 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
--- a/macros/legacy.asm
+++ b/macros/legacy.asm
@@ -33,11 +33,11 @@
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 @@
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"
--- a/macros/scripts/audio.asm
+++ b/macros/scripts/audio.asm
@@ -26,21 +26,21 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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
--- a/sram.asm
+++ b/sram.asm
@@ -142,11 +142,13 @@
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::