mirror of
https://github.com/pret/pokered.git
synced 2026-04-25 07:32:40 -05:00
Constant limit value
Introduce a constant limit value cap as a third argument during const_def, throw an error in const if const_value pass const_limit.
This commit is contained in:
parent
0555b42dc0
commit
25bbf5b73c
|
|
@ -55,7 +55,7 @@ DEF HW_CH4_DISABLE_MASK EQU (~HW_CH4_ENABLE_MASK & $ff)
|
|||
const REG_FREQUENCY_LO ; 3
|
||||
|
||||
; wChannelFlags1 constants
|
||||
const_def
|
||||
const_def 0, 1, BIT
|
||||
const BIT_PERFECT_PITCH ; 0 ; controlled by toggle_perfect_pitch command
|
||||
const BIT_SOUND_CALL ; 1 ; if in sound call
|
||||
const BIT_NOISE_OR_SFX ; 2 ; if channel is the music noise channel or an SFX channel
|
||||
|
|
|
|||
16
constants/constants_limits_constants.asm
Normal file
16
constants/constants_limits_constants.asm
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
; Some functions like IsInArray use value $FF as a list terminator.
|
||||
DEF FF_TERMINATED_CONST EQU $FF - 1
|
||||
|
||||
; Tileset IDs values are limited by the fact that the function LoadTilesetHeader (engine/overworld/tilesets.asm) multiply the ID by 8 before taking carry into account.
|
||||
; Hence any value bigger than 31 would overflow.
|
||||
; Note : even without this limitation, would be FF_TERMINATED_CONST
|
||||
DEF TILESET_CONST_LIMIT EQU $FF / 8
|
||||
|
||||
; Pokemons and trainers share ID values, trainer values start at 200, making 199 the last pokemon ID value available.
|
||||
; Note : even without this limitation, would be FF_TERMINATED_CONST
|
||||
DEF POKEMON_CONST_LIMIT EQU 200 - 1
|
||||
|
||||
; Trainer constant value is limited by its matching OPP_* ID which start at 200.
|
||||
; Opp_* constants are also FF_TERMINATED_CONST
|
||||
DEF TRAINER_CONST_LIMIT EQU FF_TERMINATED_CONST - (POKEMON_CONST_LIMIT + 1)
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
; wEventFlags bit flags
|
||||
|
||||
; Pallet Town events
|
||||
const_def
|
||||
const_def 0, 1, WORD
|
||||
const EVENT_FOLLOWED_OAK_INTO_LAB
|
||||
const_skip 2
|
||||
const EVENT_HALL_OF_FAME_DEX_RATING
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
; - TechnicalMachinePrices (see data/items/tm_prices.asm)
|
||||
; - KeyItemFlags (see data/items/key_items.asm)
|
||||
; - ItemUsePtrTable (see engine/items/item_effects.asm)
|
||||
const_def
|
||||
const_def 0, 1, FF_TERMINATED_CONST
|
||||
const NO_ITEM ; $00
|
||||
const MASTER_BALL ; $01
|
||||
const ULTRA_BALL ; $02
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ ENDM
|
|||
; - WildDataPointers (see data/wild/grass_water.asm)
|
||||
; Each map also has associated data in maps.asm.
|
||||
; Order: towns/cities, then routes, then indoor/dungeon maps
|
||||
const_def
|
||||
const_def 0, 1, FF_TERMINATED_CONST
|
||||
map_const PALLET_TOWN, 10, 9 ; $00
|
||||
map_const VIRIDIAN_CITY, 20, 18 ; $01
|
||||
map_const PEWTER_CITY, 20, 18 ; $02
|
||||
|
|
@ -401,5 +401,3 @@ DEF NUM_MAPS EQU const_value
|
|||
; Indoor maps, such as houses, use this as the Map ID in their exit warps
|
||||
; This map ID takes the player back to the last outdoor map they were on, stored in wLastMap
|
||||
DEF LAST_MAP EQU $ff
|
||||
|
||||
ASSERT NUM_MAPS <= LAST_MAP, "map IDs overlap LAST_MAP"
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ DEF BAG_ITEM_CAPACITY EQU 20
|
|||
DEF PC_ITEM_CAPACITY EQU 50
|
||||
|
||||
; text box IDs
|
||||
const_def 1
|
||||
const_def 1, 1, FF_TERMINATED_CONST
|
||||
const MESSAGE_BOX ; $01
|
||||
const_skip ; $02
|
||||
const MENU_TEMPLATE_03 ; $03 unused
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
; special effects that are part of move animations
|
||||
; SpecialEffectPointers associates them with effect routines (see data/battle_anims/special_effect_pointers.asm)
|
||||
const_def $C0
|
||||
const_def $C0, 1, FF_TERMINATED_CONST
|
||||
DEF SUBANIM_CONST_LIMIT EQU const_value - 1
|
||||
DEF FIRST_SE_ID EQU const_value
|
||||
const_skip $18
|
||||
const SE_WAVY_SCREEN ; $D8 used in Psywave/Night Shade/Psychic etc.
|
||||
|
|
@ -48,7 +49,7 @@ DEF FIRST_SE_ID EQU const_value
|
|||
|
||||
; The 0 or 1 in the name of a subanim indicates whether to use tileset 0 or 1 data/moves/animations.asm.
|
||||
; "Both" indicates either can be used for different images using the same animation.
|
||||
const_def
|
||||
const_def 0, 1, SUBANIM_CONST_LIMIT
|
||||
const SUBANIM_0_STAR
|
||||
const SUBANIM_0_STAR_TWICE
|
||||
const SUBANIM_0_STAR_THRICE
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
; - MoveNames (see data/moves/names.asm)
|
||||
; - AttackAnimationPointers (see data/moves/animations.asm)
|
||||
; - MoveSoundTable (see data/moves/sfx.asm)
|
||||
const_def
|
||||
const_def 0, 1, FF_TERMINATED_CONST
|
||||
const NO_MOVE ; 00
|
||||
const POUND ; 01
|
||||
const KARATE_CHOP ; 02
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
; {status condition}_EFFECT means that the move causes the status condition every time it hits the target
|
||||
|
||||
; MoveEffectPointerTable indexes (see data/moves/effects_pointers.asm)
|
||||
const_def
|
||||
const_def 0, 1, FF_TERMINATED_CONST
|
||||
const NO_ADDITIONAL_EFFECT ; $00
|
||||
const EFFECT_01 ; $01 unused
|
||||
const POISON_SIDE_EFFECT1 ; $02
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
; - CryData (see data/pokemon/cries.asm)
|
||||
; - PokedexOrder (see data/pokemon/dex_order.asm)
|
||||
; - PokedexEntryPointers (see data/pokemon/dex_entries.asm)
|
||||
const_def
|
||||
const_def 0, 1, POKEMON_CONST_LIMIT
|
||||
const NO_MON ; $00
|
||||
const RHYDON ; $01
|
||||
const KANGASKHAN ; $02
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
; sprite facing directions
|
||||
const_def 0, $04
|
||||
const_def 0, $04, $0C
|
||||
const SPRITE_FACING_DOWN ; $00
|
||||
const SPRITE_FACING_UP ; $04
|
||||
const SPRITE_FACING_LEFT ; $08
|
||||
const SPRITE_FACING_RIGHT ; $0C
|
||||
|
||||
const_def 0, $40
|
||||
const_def 0, $40, $C0
|
||||
const NPC_MOVEMENT_DOWN ; $00
|
||||
const NPC_MOVEMENT_UP ; $40
|
||||
const NPC_MOVEMENT_LEFT ; $80
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
DEF NPC_CHANGE_FACING EQU $E0
|
||||
|
||||
; player direction constants
|
||||
const_def
|
||||
const_def 0, 1, BIT
|
||||
const PLAYER_DIR_BIT_RIGHT ; 0
|
||||
const PLAYER_DIR_BIT_LEFT ; 1
|
||||
const PLAYER_DIR_BIT_DOWN ; 2
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
; tileset ids
|
||||
; Tilesets indexes (see data/tilesets/tileset_headers.asm)
|
||||
const_def
|
||||
const_def 0, 1, TILESET_CONST_LIMIT
|
||||
const OVERWORLD ; 0
|
||||
const REDS_HOUSE_1 ; 1
|
||||
const MART ; 2
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
DEF OPP_ID_OFFSET EQU 200
|
||||
DEF OPP_ID_OFFSET EQU POKEMON_CONST_LIMIT + 1 ; 200
|
||||
|
||||
MACRO trainer_const
|
||||
const \1
|
||||
|
|
@ -13,7 +13,7 @@ ENDM
|
|||
; - TrainerPicAndMoneyPointers (see data/trainers/pic_pointers_money.asm)
|
||||
; - TrainerAIPointers (see data/trainers/ai_pointers.asm)
|
||||
; - TrainerClassMoveChoiceModifications (see data/trainers/move_choices.asm)
|
||||
const_def
|
||||
const_def 0, 1, TRAINER_CONST_LIMIT
|
||||
trainer_const NOBODY ; $00
|
||||
trainer_const YOUNGSTER ; $01
|
||||
trainer_const BUG_CATCHER ; $02
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
; TypeNames indexes (see data/types/names.asm)
|
||||
const_def
|
||||
const_def 0, 1, FF_TERMINATED_CONST
|
||||
|
||||
DEF PHYSICAL EQU const_value
|
||||
const NORMAL ; $00
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ INCLUDE "macros/scripts/maps.asm"
|
|||
INCLUDE "macros/scripts/events.asm"
|
||||
INCLUDE "macros/scripts/text.asm"
|
||||
|
||||
INCLUDE "constants/constants_limits_constants.asm"
|
||||
INCLUDE "constants/charmap.asm"
|
||||
INCLUDE "constants/hardware.inc"
|
||||
INCLUDE "constants/oam_constants.asm"
|
||||
|
|
|
|||
|
|
@ -11,11 +11,45 @@ MACRO? const_def
|
|||
ELSE
|
||||
DEF const_inc = 1
|
||||
ENDC
|
||||
IF const_inc > 0
|
||||
REDEF const_size_compare EQUS "bigger"
|
||||
DEF const_format_sign = 1
|
||||
ELSE
|
||||
REDEF const_size_compare EQUS "smaller"
|
||||
DEF const_format_sign = -1
|
||||
ENDC
|
||||
DEF const_format = $FF
|
||||
DEF undefined_const_limit = 1
|
||||
IF _NARG >= 3
|
||||
IF !STRCMP("\3", "WORD")
|
||||
DEF const_format = $FFFF
|
||||
ELIF !STRCMP("\3", "NYBBLE")
|
||||
DEF const_format = $F
|
||||
ELIF !STRCMP("\3", "BIT")
|
||||
DEF const_format = 7
|
||||
ELSE
|
||||
DEF undefined_const_limit = 0
|
||||
DEF const_limit = \3
|
||||
ENDC
|
||||
ENDC
|
||||
IF undefined_const_limit
|
||||
IF (const_value >= 0 && const_inc > 0) || (const_value <= 0 && const_inc < 0)
|
||||
DEF const_limit = const_format_sign * const_format
|
||||
ELSE
|
||||
DEF const_limit = const_value + const_format_sign * const_format
|
||||
ENDC
|
||||
ENDC
|
||||
REDEF last_const_string EQUS " as first constant."
|
||||
ENDM
|
||||
|
||||
MACRO? const
|
||||
DEF \1 EQU const_value
|
||||
DEF const_value += const_inc
|
||||
IF (const_inc > 0 && const_value > const_limit) || (const_inc < 0 && const_value < const_limit)
|
||||
fail "Constant value cannot be {const_size_compare} than {const_limit}. Tried to define constant \1 for value {const_value}{last_const_string}"
|
||||
ELSE
|
||||
REDEF last_const_string EQUS ". Last valid constant was \1 for value {const_value}."
|
||||
DEF \1 EQU const_value
|
||||
DEF const_value += const_inc
|
||||
ENDC
|
||||
ENDM
|
||||
|
||||
MACRO? const_export
|
||||
|
|
|
|||
|
|
@ -181,9 +181,11 @@ MACRO text_end
|
|||
db TX_END
|
||||
ENDM
|
||||
|
||||
DEF TEXT_SCRIPT_CONST_LIMIT EQU const_value
|
||||
|
||||
|
||||
; Text script IDs (see home/text_script.asm)
|
||||
const_def -1, -1
|
||||
const_def $ff, -1, TEXT_SCRIPT_CONST_LIMIT
|
||||
|
||||
const TX_SCRIPT_POKECENTER_NURSE ; $ff
|
||||
MACRO script_pokecenter_nurse
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user