Merge pull request #220 from Rangi42/master

Replace some hard-coded values with constants
This commit is contained in:
Daniel Harding 2019-07-17 17:30:53 -05:00 committed by GitHub
commit 36597a7917
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 37 additions and 30 deletions

View file

@ -371,7 +371,7 @@ PlayBattleMusic::
jr .playSong jr .playSong
.notGymLeaderBattle .notGymLeaderBattle
ld a, [wCurOpponent] ld a, [wCurOpponent]
cp 200 cp OPP_ID_OFFSET
jr c, .wildBattle jr c, .wildBattle
cp OPP_SONY3 cp OPP_SONY3
jr z, .finalBattle jr z, .finalBattle

View file

@ -152,4 +152,4 @@ const_value = 1
const DEX_MEWTWO ; 150 const DEX_MEWTWO ; 150
const DEX_MEW ; 151 const DEX_MEW ; 151
NUM_POKEMON EQU 151 NUM_POKEMON EQU const_value + -1

View file

@ -190,3 +190,5 @@ const_value = 1
const BELLSPROUT ; $BC const BELLSPROUT ; $BC
const WEEPINBELL ; $BD const WEEPINBELL ; $BD
const VICTREEBEL ; $BE const VICTREEBEL ; $BE
NUM_POKEMON_INDEXES EQU const_value + -1

View file

@ -1,6 +1,8 @@
OPP_ID_OFFSET EQU 200
trainer_const: MACRO trainer_const: MACRO
\1 EQU const_value \1 EQU const_value
OPP_\1 EQU const_value + 200 OPP_\1 EQU const_value + OPP_ID_OFFSET
const_value = const_value + 1 const_value = const_value + 1
ENDM ENDM

View file

@ -82,7 +82,7 @@ BattleTransitions:
GetBattleTransitionID_WildOrTrainer: GetBattleTransitionID_WildOrTrainer:
ld a, [wCurOpponent] ld a, [wCurOpponent]
cp 200 cp OPP_ID_OFFSET
jr nc, .trainer jr nc, .trainer
res 0, c res 0, c
ret ret

View file

@ -6867,7 +6867,7 @@ InitBattleCommon:
res 1, [hl] res 1, [hl]
callab InitBattleVariables callab InitBattleVariables
ld a, [wEnemyMonSpecies2] ld a, [wEnemyMonSpecies2]
sub 200 sub OPP_ID_OFFSET
jp c, InitWildBattle jp c, InitWildBattle
ld [wTrainerClass], a ld [wTrainerClass], a
call GetTrainerInformation call GetTrainerInformation

View file

@ -101,7 +101,7 @@ ReadTrainer:
; get trainer class number ; get trainer class number
ld a, [wCurOpponent] ld a, [wCurOpponent]
sub 200 sub OPP_ID_OFFSET
ld b, a ld b, a
ld hl, TeamMoves ld hl, TeamMoves

View file

@ -1,3 +1,5 @@
MAP_TILESET_SIZE EQU $60
UpdatePlayerSprite: UpdatePlayerSprite:
ld a, [wSpriteStateData2] ld a, [wSpriteStateData2]
and a and a
@ -13,7 +15,7 @@ UpdatePlayerSprite:
.checkIfTextBoxInFrontOfSprite .checkIfTextBoxInFrontOfSprite
aCoord 8, 9 aCoord 8, 9
ld [hTilePlayerStandingOn], a ld [hTilePlayerStandingOn], a
cp $60 cp MAP_TILESET_SIZE
jr c, .lowerLeftTileIsMapTile jr c, .lowerLeftTileIsMapTile
.disableSprite .disableSprite
ld a, $ff ld a, $ff
@ -127,7 +129,7 @@ UpdateNPCSprite:
and a and a
jp z, InitializeSpriteStatus jp z, InitializeSpriteStatus
call CheckSpriteAvailability call CheckSpriteAvailability
ret c ; if sprite is invisible, on tile >=$60, in grass or player is currently walking ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking
ld h, $c1 ld h, $c1
ld a, [H_CURRENTSPRITEOFFSET] ld a, [H_CURRENTSPRITEOFFSET]
ld l, a ld l, a
@ -508,21 +510,21 @@ CheckSpriteAvailability:
; make the sprite invisible if a text box is in front of it ; make the sprite invisible if a text box is in front of it
; $5F is the maximum number for map tiles ; $5F is the maximum number for map tiles
call GetTileSpriteStandsOn call GetTileSpriteStandsOn
ld d, $60 ld d, MAP_TILESET_SIZE
ld a, [hli] ld a, [hli]
cp d cp d
jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom left tile) jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom left tile)
ld a, [hld] ld a, [hld]
cp d cp d
jr nc, .spriteInvisible ; standing on tile with ID >=$60 (bottom right tile) jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (bottom right tile)
ld bc, -20 ld bc, -20
add hl, bc ; go back one row of tiles add hl, bc ; go back one row of tiles
ld a, [hli] ld a, [hli]
cp d cp d
jr nc, .spriteInvisible ; standing on tile with ID >=$60 (top left tile) jr nc, .spriteInvisible ; standing on tile with ID >=MAP_TILESET_SIZE (top left tile)
ld a, [hl] ld a, [hl]
cp d cp d
jr c, .spriteVisible ; standing on tile with ID >=$60 (top right tile) jr c, .spriteVisible ; standing on tile with ID >=MAP_TILESET_SIZE (top right tile)
.spriteInvisible .spriteInvisible
ld h, wSpriteStateData1 / $100 ld h, wSpriteStateData1 / $100
ld a, [H_CURRENTSPRITEOFFSET] ld a, [H_CURRENTSPRITEOFFSET]

View file

@ -70,7 +70,7 @@ SetPal_StatusScreen:
ld bc, $10 ld bc, $10
call CopyData call CopyData
ld a, [wcf91] ld a, [wcf91]
cp VICTREEBEL + 1 cp NUM_POKEMON_INDEXES + 1
jr c, .pokemon jr c, .pokemon
ld a, $1 ; not pokemon ld a, $1 ; not pokemon
.pokemon .pokemon

View file

@ -86,7 +86,7 @@ DexRatingsTable:
dw PokedexRatingText_44242 dw PokedexRatingText_44242
db 150 db 150
dw PokedexRatingText_44247 dw PokedexRatingText_44247
db 152 db NUM_POKEMON + 1
dw PokedexRatingText_4424c dw PokedexRatingText_4424c
PokedexRatingText_44201: PokedexRatingText_44201:

View file

@ -2390,7 +2390,7 @@ EndTrainerBattle::
ld b, FLAG_SET ld b, FLAG_SET
call TrainerFlagAction ; flag trainer as fought call TrainerFlagAction ; flag trainer as fought
ld a, [wEnemyMonOrTrainerClass] ld a, [wEnemyMonOrTrainerClass]
cp 200 cp OPP_ID_OFFSET
jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite) jr nc, .skipRemoveSprite ; test if trainer was fought (in that case skip removing the corresponding sprite)
ld hl, wMissableObjectList ld hl, wMissableObjectList
ld de, $2 ld de, $2
@ -2424,7 +2424,7 @@ InitBattleEnemyParameters::
ld a, [wEngagedTrainerClass] ld a, [wEngagedTrainerClass]
ld [wCurOpponent], a ld [wCurOpponent], a
ld [wEnemyMonOrTrainerClass], a ld [wEnemyMonOrTrainerClass], a
cp 200 cp OPP_ID_OFFSET
ld a, [wEngagedTrainerSet] ld a, [wEngagedTrainerSet]
jr c, .noTrainer jr c, .noTrainer
ld [wTrainerNo], a ld [wTrainerNo], a

View file

@ -887,7 +887,7 @@ LoadTileBlockMap::
ld hl, wOverworldMap ld hl, wOverworldMap
ld a, [wMapBackgroundTile] ld a, [wMapBackgroundTile]
ld d, a ld d, a
ld bc, $0514 ld bc, wOverworldMapEnd - wOverworldMap
.backgroundTileLoop .backgroundTileLoop
ld a, d ld a, d
ld [hli], a ld [hli], a

View file

@ -16,18 +16,18 @@ Mansion3Script_52204:
CheckEvent EVENT_MANSION_SWITCH_ON CheckEvent EVENT_MANSION_SWITCH_ON
jr nz, .asm_52224 jr nz, .asm_52224
ld a, $e ld a, $e
ld bc, $207 lb bc, 2, 7
call Mansion2Script_5202f call Mansion2Script_5202f
ld a, $5f ld a, $5f
ld bc, $507 lb bc, 5, 7
call Mansion2Script_5202f call Mansion2Script_5202f
ret ret
.asm_52224 .asm_52224
ld a, $5f ld a, $5f
ld bc, $207 lb bc, 2, 7
call Mansion2Script_5202f call Mansion2Script_5202f
ld a, $e ld a, $e
ld bc, $507 lb bc, 5, 7
call Mansion2Script_5202f call Mansion2Script_5202f
ret ret
@ -43,9 +43,9 @@ Mansion3Script0:
and a and a
jp z, CheckFightingMapTrainers jp z, CheckFightingMapTrainers
cp $3 cp $3
ld a, $a5 ld a, POKEMON_MANSION_1F
jr nz, .asm_52250 jr nz, .asm_52250
ld a, $d6 ld a, POKEMON_MANSION_2F
.asm_52250 .asm_52250
ld [wDungeonWarpDestinationMap], a ld [wDungeonWarpDestinationMap], a
ret ret

View file

@ -32,7 +32,7 @@ SeafoamIslands1F_Script:
ld [wMissableObjectIndex], a ld [wMissableObjectIndex], a
predef_jump ShowObject predef_jump ShowObject
.asm_4483b .asm_4483b
ld a, $9f ld a, SEAFOAM_ISLANDS_B1F
ld [wDungeonWarpDestinationMap], a ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam1HolesCoords ld hl, Seafoam1HolesCoords
jp IsPlayerOnDungeonWarp jp IsPlayerOnDungeonWarp

View file

@ -31,7 +31,7 @@ SeafoamIslandsB1F_Script:
ld [wMissableObjectIndex], a ld [wMissableObjectIndex], a
predef_jump ShowObject predef_jump ShowObject
.asm_46362 .asm_46362
ld a, $a0 ld a, SEAFOAM_ISLANDS_B2F
ld [wDungeonWarpDestinationMap], a ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam2HolesCoords ld hl, Seafoam2HolesCoords
jp IsPlayerOnDungeonWarp jp IsPlayerOnDungeonWarp

View file

@ -31,7 +31,7 @@ SeafoamIslandsB2F_Script:
ld [wMissableObjectIndex], a ld [wMissableObjectIndex], a
predef_jump ShowObject predef_jump ShowObject
.asm_4649e .asm_4649e
ld a, $a1 ld a, SEAFOAM_ISLANDS_B3F
ld [wDungeonWarpDestinationMap], a ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam3HolesCoords ld hl, Seafoam3HolesCoords
jp IsPlayerOnDungeonWarp jp IsPlayerOnDungeonWarp

View file

@ -32,7 +32,7 @@ SeafoamIslandsB3F_Script:
predef ShowObject predef ShowObject
jr .asm_465ed jr .asm_465ed
.asm_465dc .asm_465dc
ld a, $a2 ld a, SEAFOAM_ISLANDS_B4F
ld [wDungeonWarpDestinationMap], a ld [wDungeonWarpDestinationMap], a
ld hl, Seafoam4HolesCoords ld hl, Seafoam4HolesCoords
call IsPlayerOnDungeonWarp call IsPlayerOnDungeonWarp

View file

@ -346,6 +346,7 @@ wSerialEnemyMonsPatchList:: ; c5d0
wTempPic:: wTempPic::
wOverworldMap:: ; c6e8 wOverworldMap:: ; c6e8
ds 1300 ds 1300
wOverworldMapEnd::
wRedrawRowOrColumnSrcTiles:: ; cbfc wRedrawRowOrColumnSrcTiles:: ; cbfc
; the tiles of the row or column to be redrawn by RedrawRowOrColumn ; the tiles of the row or column to be redrawn by RedrawRowOrColumn
@ -1638,7 +1639,7 @@ wPartyGainExpFlags:: ; d058
wCurOpponent:: ; d059 wCurOpponent:: ; d059
; in a wild battle, this is the species of pokemon ; in a wild battle, this is the species of pokemon
; in a trainer battle, this is the trainer class + 200 ; in a trainer battle, this is the trainer class + OPP_ID_OFFSET
ds 1 ds 1
wBattleType:: ; d05a wBattleType:: ; d05a
@ -2916,7 +2917,7 @@ wFossilMon:: ; d710
ds 2 ds 2
wEnemyMonOrTrainerClass:: ; d713 wEnemyMonOrTrainerClass:: ; d713
; trainer classes start at 200 ; trainer classes start at OPP_ID_OFFSET
ds 1 ds 1
wPlayerJumpingYScreenCoordsIndex:: ; d714 wPlayerJumpingYScreenCoordsIndex:: ; d714