From 7a7a6d689c1fc2cd42ae925e4c7e19434a4e0267 Mon Sep 17 00:00:00 2001 From: Vortyne <104168801+Vortyne@users.noreply.github.com> Date: Mon, 20 Nov 2023 17:23:22 -0500 Subject: Identify the unnamed HRAM variables and one WRAM label (#438) --- engine/overworld/sprite_collisions.asm | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) (limited to 'engine/overworld') diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index dc57d5b9..46c29e3e 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -80,7 +80,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ldh [hFF90], a ; store Y coordinate adjusted for direction of movement + ldh [hCollidingSpriteTempYValue], a ; y adjusted for direction of movement ld a, [hli] ; a = [i#SPRITESTATEDATA1_XSTEPVECTOR] (-1, 0, or 1) call SetSpriteCollisionValues @@ -93,7 +93,7 @@ DetectCollisionBetweenSprites: and $f0 or c - ldh [hFF91], a ; store X coordinate adjusted for direction of movement + ldh [hCollidingSpriteTempXValue], a ; x adjusted for direction of movement ld a, l add 7 @@ -103,15 +103,15 @@ DetectCollisionBetweenSprites: ld [hld], a ; zero [i#SPRITESTATEDATA1_0D] XXX what's this for? ld [hld], a ; zero [i#SPRITESTATEDATA1_COLLISIONDATA] - ldh a, [hFF91] + ldh a, [hCollidingSpriteTempXValue] ld [hld], a ; [i#SPRITESTATEDATA1_XADJUSTED] - ldh a, [hFF90] + ldh a, [hCollidingSpriteTempYValue] ld [hl], a ; [i#SPRITESTATEDATA1_YADJUSTED] xor a ; zero the loop counter .loop - ldh [hFF8F], a ; store loop counter + ldh [hCollidingSpriteOffset], a swap a ld e, a ldh a, [hCurrentSpriteOffset] @@ -155,7 +155,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry1 - ldh [hFF90], a ; store the distance between the two sprites' adjusted Y values + ldh [hCollidingSpriteTempYValue], a ; store the distance between the two sprites' adjusted Y values ; Use the carry flag set by the above subtraction to determine which sprite's ; Y coordinate is larger. This information is used later to set @@ -177,11 +177,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next1 - ldh a, [hFF90] ; a = distance between adjusted Y coordinates + ldh a, [hCollidingSpriteTempYValue] ; a = distance between adjusted Y coordinates sub b - ldh [hFF92], a ; store distance adjusted using sprite i's direction + ldh [hCollidingSpriteAdjustedDistance], a ld a, b - ldh [hFF90], a ; store 7 or 9 depending on sprite i's delta Y + ldh [hCollidingSpriteTempYValue], a ; store 7 or 9 depending on sprite i's delta Y jr c, .checkXDistance ; If sprite j's delta Y is 0, then b = 7, else b = 9. @@ -194,7 +194,7 @@ DetectCollisionBetweenSprites: ld b, 9 .next2 - ldh a, [hFF92] ; a = distance adjusted using sprite i's direction + ldh a, [hCollidingSpriteAdjustedDistance] sub b ; adjust distance using sprite j's direction jr z, .checkXDistance jr nc, .next ; go to next sprite if distance is still positive after both adjustments @@ -226,7 +226,7 @@ DetectCollisionBetweenSprites: cpl inc a .noCarry2 - ldh [hFF91], a ; store the distance between the two sprites' adjusted X values + ldh [hCollidingSpriteTempXValue], a ; store the distance between the two sprites' adjusted X values ; Use the carry flag set by the above subtraction to determine which sprite's ; X coordinate is larger. This information is used later to set @@ -248,11 +248,11 @@ DetectCollisionBetweenSprites: ld b, 9 .next3 - ldh a, [hFF91] ; a = distance between adjusted X coordinates + ldh a, [hCollidingSpriteTempXValue] ; a = distance between adjusted X coordinates sub b - ldh [hFF92], a ; store distance adjusted using sprite i's direction + ldh [hCollidingSpriteAdjustedDistance], a ld a, b - ldh [hFF91], a ; store 7 or 9 depending on sprite i's delta X + ldh [hCollidingSpriteTempXValue], a ; store 7 or 9 depending on sprite i's delta X jr c, .collision ; If sprite j's delta X is 0, then b = 7, else b = 9. @@ -265,15 +265,15 @@ DetectCollisionBetweenSprites: ld b, 9 .next4 - ldh a, [hFF92] ; a = distance adjusted using sprite i's direction + ldh a, [hCollidingSpriteAdjustedDistance] sub b ; adjust distance using sprite j's direction jr z, .collision jr nc, .next ; go to next sprite if distance is still positive after both adjustments .collision - ldh a, [hFF91] ; a = 7 or 9 depending on sprite i's delta X + ldh a, [hCollidingSpriteTempXValue] ; a = 7 or 9 depending on sprite i's delta X ld b, a - ldh a, [hFF90] ; a = 7 or 9 depending on sprite i's delta Y + ldh a, [hCollidingSpriteTempYValue] ; a = 7 or 9 depending on sprite i's delta Y inc l ; If delta X isn't 0 and delta Y is 0, then b = %0011, else b = %1100. @@ -296,7 +296,7 @@ DetectCollisionBetweenSprites: ; to indicate which sprite the collision occurred with inc l inc l - ldh a, [hFF8F] ; a = loop counter + ldh a, [hCollidingSpriteOffset] ld de, SpriteCollisionBitTable add a add e @@ -313,7 +313,7 @@ DetectCollisionBetweenSprites: ld [hl], a .next - ldh a, [hFF8F] ; a = loop counter + ldh a, [hCollidingSpriteOffset] inc a cp $10 jp nz, .loop -- cgit v1.3.1-sl0p From b066d3c9bc02cf4213173538d148cfabcc7212a8 Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Mon, 20 Nov 2023 17:53:19 -0500 Subject: Add `bigdw` and `dc` data macros --- engine/battle/animations.asm | 54 +++++++++++++++++----------------- engine/battle/battle_transitions.asm | 24 +++++++-------- engine/battle/scale_sprites.asm | 21 +++---------- engine/movie/credits.asm | 8 ++--- engine/movie/oak_speech/oak_speech.asm | 12 ++++---- engine/overworld/sprite_collisions.asm | 19 ++---------- home/fade.asm | 18 ++++++------ macros/data.asm | 11 +++++++ 8 files changed, 76 insertions(+), 91 deletions(-) (limited to 'engine/overworld') diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index fcfec14d..712958bc 100644 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -976,7 +976,7 @@ AnimationFlashScreenLong: push hl .innerLoop ld a, [hli] - cp $01 ; is it the end of the palettes? + cp 1 jr z, .endOfPalettes ldh [rBGP], a call FlashScreenLongDelay @@ -992,35 +992,35 @@ AnimationFlashScreenLong: ; BG palettes FlashScreenLongMonochrome: - db %11111001 ; 3, 3, 2, 1 - db %11111110 ; 3, 3, 3, 2 - db %11111111 ; 3, 3, 3, 3 - db %11111110 ; 3, 3, 3, 2 - db %11111001 ; 3, 3, 2, 1 - db %11100100 ; 3, 2, 1, 0 - db %10010000 ; 2, 1, 0, 0 - db %01000000 ; 1, 0, 0, 0 - db %00000000 ; 0, 0, 0, 0 - db %01000000 ; 1, 0, 0, 0 - db %10010000 ; 2, 1, 0, 0 - db %11100100 ; 3, 2, 1, 0 - db $01 ; terminator + dc 3, 3, 2, 1 + dc 3, 3, 3, 2 + dc 3, 3, 3, 3 + dc 3, 3, 3, 2 + dc 3, 3, 2, 1 + dc 3, 2, 1, 0 + dc 2, 1, 0, 0 + dc 1, 0, 0, 0 + dc 0, 0, 0, 0 + dc 1, 0, 0, 0 + dc 2, 1, 0, 0 + dc 3, 2, 1, 0 + db 1 ; end ; BG palettes FlashScreenLongSGB: - db %11111000 ; 3, 3, 2, 0 - db %11111100 ; 3, 3, 3, 0 - db %11111111 ; 3, 3, 3, 3 - db %11111100 ; 3, 3, 3, 0 - db %11111000 ; 3, 3, 2, 0 - db %11100100 ; 3, 2, 1, 0 - db %10010000 ; 2, 1, 0, 0 - db %01000000 ; 1, 0, 0, 0 - db %00000000 ; 0, 0, 0, 0 - db %01000000 ; 1, 0, 0, 0 - db %10010000 ; 2, 1, 0, 0 - db %11100100 ; 3, 2, 1, 0 - db $01 ; terminator + dc 3, 3, 2, 0 + dc 3, 3, 3, 0 + dc 3, 3, 3, 3 + dc 3, 3, 3, 0 + dc 3, 3, 2, 0 + dc 3, 2, 1, 0 + dc 2, 1, 0, 0 + dc 1, 0, 0, 0 + dc 0, 0, 0, 0 + dc 1, 0, 0, 0 + dc 2, 1, 0, 0 + dc 3, 2, 1, 0 + db 1 ; end ; causes a delay of 2 frames for the first cycle ; causes a delay of 1 frame for the second and third cycles diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index a16fd250..363533ce 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -335,18 +335,18 @@ BattleTransition_FlashScreen_: ret BattleTransition_FlashScreenPalettes: - db %11111001 - db %11111110 - db %11111111 - db %11111110 - db %11111001 - db %11100100 - db %10010000 - db %01000000 - db %00000000 - db %01000000 - db %10010000 - db %11100100 + dc 3, 3, 2, 1 + dc 3, 3, 3, 2 + dc 3, 3, 3, 3 + dc 3, 3, 3, 2 + dc 3, 3, 2, 1 + dc 3, 2, 1, 0 + dc 2, 1, 0, 0 + dc 1, 0, 0, 0 + dc 0, 0, 0, 0 + dc 1, 0, 0, 0 + dc 2, 1, 0, 0 + dc 3, 2, 1, 0 db 1 ; end ; used for low level trainer dungeon battles diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index 8b8942e6..9e24c89d 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -77,21 +77,8 @@ ScalePixelsByTwo: add hl, bc ; add offset ret -; repeats each input bit twice +; repeats each input bit twice, e.g. DuplicateBitsTable[%0101] = %00110011 DuplicateBitsTable: - db %00000000 - db %00000011 - db %00001100 - db %00001111 - db %00110000 - db %00110011 - db %00111100 - db %00111111 - db %11000000 - db %11000011 - db %11001100 - db %11001111 - db %11110000 - db %11110011 - db %11111100 - db %11111111 +FOR n, 16 + db (n & 1) * 3 + (n & 2) * 6 + (n & 4) * 12 + (n & 8) * 24 +ENDR diff --git a/engine/movie/credits.asm b/engine/movie/credits.asm index 0410de21..5f258503 100644 --- a/engine/movie/credits.asm +++ b/engine/movie/credits.asm @@ -131,10 +131,10 @@ ScrollCreditsMonLeft_SetSCX: ret HoFGBPalettes: - db %11000000 - db %11010000 - db %11100000 - db %11110000 + dc 3, 0, 0, 0 + dc 3, 1, 0, 0 + dc 3, 2, 0, 0 + dc 3, 3, 0, 0 CreditsCopyTileMapToVRAM: ld a, l diff --git a/engine/movie/oak_speech/oak_speech.asm b/engine/movie/oak_speech/oak_speech.asm index 4ed4735e..3e339619 100644 --- a/engine/movie/oak_speech/oak_speech.asm +++ b/engine/movie/oak_speech/oak_speech.asm @@ -192,12 +192,12 @@ FadeInIntroPic: ret IntroFadePalettes: - db %01010100 - db %10101000 - db %11111100 - db %11111000 - db %11110100 - db %11100100 + dc 1, 1, 1, 0 + dc 2, 2, 2, 0 + dc 3, 3, 3, 0 + dc 3, 3, 2, 0 + dc 3, 3, 1, 0 + dc 3, 2, 1, 0 MovePicLeft: ld a, 119 diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index 46c29e3e..ffed3708 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -340,19 +340,6 @@ SetSpriteCollisionValues: ret SpriteCollisionBitTable: - db %00000000,%00000001 - db %00000000,%00000010 - db %00000000,%00000100 - db %00000000,%00001000 - db %00000000,%00010000 - db %00000000,%00100000 - db %00000000,%01000000 - db %00000000,%10000000 - db %00000001,%00000000 - db %00000010,%00000000 - db %00000100,%00000000 - db %00001000,%00000000 - db %00010000,%00000000 - db %00100000,%00000000 - db %01000000,%00000000 - db %10000000,%00000000 +FOR n, $10 + bigdw 1 << n +ENDR diff --git a/home/fade.asm b/home/fade.asm index f5ddf964..b67f4b1c 100644 --- a/home/fade.asm +++ b/home/fade.asm @@ -62,12 +62,12 @@ GBFadeDecCommon: jr nz, GBFadeDecCommon ret -FadePal1:: db %11111111, %11111111, %11111111 -FadePal2:: db %11111110, %11111110, %11111000 -FadePal3:: db %11111001, %11100100, %11100100 -FadePal4:: db %11100100, %11010000, %11100000 -; rBGP rOBP0 rOBP1 -FadePal5:: db %11100100, %11010000, %11100000 -FadePal6:: db %10010000, %10000000, %10010000 -FadePal7:: db %01000000, %01000000, %01000000 -FadePal8:: db %00000000, %00000000, %00000000 +FadePal1:: dc 3,3,3,3, 3,3,3,3, 3,3,3,3 +FadePal2:: dc 3,3,3,2, 3,3,3,2, 3,3,2,0 +FadePal3:: dc 3,3,2,1, 3,2,1,0, 3,2,1,0 +FadePal4:: dc 3,2,1,0, 3,1,0,0, 3,2,0,0 +; rBGP rOBP0 rOBP1 +FadePal5:: dc 3,2,1,0, 3,1,0,0, 3,2,0,0 +FadePal6:: dc 2,1,0,0, 2,0,0,0, 2,1,0,0 +FadePal7:: dc 1,0,0,0, 1,0,0,0, 1,0,0,0 +FadePal8:: dc 0,0,0,0, 0,0,0,0, 0,0,0,0 diff --git a/macros/data.asm b/macros/data.asm index 5092b74e..2e4a7ce2 100644 --- a/macros/data.asm +++ b/macros/data.asm @@ -56,6 +56,17 @@ MACRO dn ; nybbles ENDR ENDM +MACRO dc ; "crumbs" + REPT _NARG / 4 + db ((\1) << 6) | ((\2) << 4) | ((\3) << 2) | (\4) + SHIFT 4 + ENDR +ENDM + +MACRO bigdw ; big-endian word + db HIGH(\1), LOW(\1) +ENDM + MACRO dba ; dbw bank, address REPT _NARG dbw BANK(\1), \1 -- cgit v1.3.1-sl0p From 77887be2512b4b8af688dc4552bdb4490d35e65b Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Mon, 20 Nov 2023 18:53:23 -0500 Subject: Identify `wSavedCoordIndex` and its other usages --- engine/gfx/sprite_oam.asm | 4 ++-- engine/items/item_effects.asm | 2 +- engine/menus/pokedex.asm | 2 +- engine/overworld/auto_movement.asm | 4 ++-- engine/overworld/movement.asm | 2 +- home/overworld.asm | 2 +- home/pathfinding.asm | 2 +- ram/wram.asm | 13 ++++++++----- scripts/FightingDojo.asm | 10 +++++----- scripts/PalletTown.asm | 8 ++++---- scripts/Route22.asm | 24 ++++++++++++------------ scripts/SafariZoneGate.asm | 18 +++++++++--------- scripts/SilphCo11F.asm | 10 +++++----- scripts/SilphCo7F.asm | 8 ++++---- scripts/VermilionCity.asm | 2 +- 15 files changed, 57 insertions(+), 54 deletions(-) (limited to 'engine/overworld') diff --git a/engine/gfx/sprite_oam.asm b/engine/gfx/sprite_oam.asm index 4a31ab5e..8704814f 100644 --- a/engine/gfx/sprite_oam.asm +++ b/engine/gfx/sprite_oam.asm @@ -28,7 +28,7 @@ PrepareOAMData:: inc e inc e ld a, [de] ; [x#SPRITESTATEDATA1_IMAGEINDEX] - ld [wSpriteImageIndexBackup], a + ld [wSavedSpriteImageIndex], a cp $ff ; off-screen (don't draw) jr nz, .visible @@ -98,7 +98,7 @@ PrepareOAMData:: push bc ld b, a - ld a, [wSpriteImageIndexBackup] + ld a, [wSavedSpriteImageIndex] swap a ; high nybble determines sprite used (0 is always player sprite, next are some npcs) and $f diff --git a/engine/items/item_effects.asm b/engine/items/item_effects.asm index 927f54cb..12c7dade 100644 --- a/engine/items/item_effects.asm +++ b/engine/items/item_effects.asm @@ -740,7 +740,7 @@ ItemUseSurfboard: ld a, b ld [wSimulatedJoypadStatesEnd], a xor a - ld [wWastedByteCD39], a + ld [wUnusedCD39], a inc a ld [wSimulatedJoypadStatesIndex], a ret diff --git a/engine/menus/pokedex.asm b/engine/menus/pokedex.asm index 3411f729..96bae343 100644 --- a/engine/menus/pokedex.asm +++ b/engine/menus/pokedex.asm @@ -36,7 +36,7 @@ ShowPokedexMenu: ld [wCurrentMenuItem], a ld [wLastMenuItem], a ldh [hJoy7], a - ld [wWastedByteCD3A], a + ld [wUnusedCD3A], a ld [wOverrideSimulatedJoypadStatesMask], a pop af ld [wListScrollOffset], a diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index 75816886..53b70c19 100644 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -17,7 +17,7 @@ PlayerStepOutFromDoor:: ret .notStandingOnDoor xor a - ld [wWastedByteCD3A], a + ld [wUnusedCD3A], a ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a ld hl, wd736 @@ -39,7 +39,7 @@ _EndNPCMovementScript:: ld [wNPCMovementScriptSpriteOffset], a ld [wNPCMovementScriptPointerTableNum], a ld [wNPCMovementScriptFunctionNum], a - ld [wWastedByteCD3A], a + ld [wUnusedCD3A], a ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a ret diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index e08da61a..eb186f1e 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -179,7 +179,7 @@ UpdateNPCSprite: res 0, [hl] xor a ld [wSimulatedJoypadStatesIndex], a - ld [wWastedByteCD3A], a + ld [wUnusedCD3A], a ret .next cp WALK diff --git a/home/overworld.asm b/home/overworld.asm index 8085f484..885a5327 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -1869,7 +1869,7 @@ JoypadOverworld:: ; if done simulating button presses .doneSimulating xor a - ld [wWastedByteCD3A], a + ld [wUnusedCD3A], a ld [wSimulatedJoypadStatesIndex], a ld [wSimulatedJoypadStatesEnd], a ld [wJoyIgnore], a diff --git a/home/pathfinding.asm b/home/pathfinding.asm index 53f98847..77cb5c4b 100644 --- a/home/pathfinding.asm +++ b/home/pathfinding.asm @@ -40,7 +40,7 @@ MoveSprite_:: ld [wSimulatedJoypadStatesEnd], a dec a ld [wJoyIgnore], a - ld [wWastedByteCD3A], a + ld [wUnusedCD3A], a ret ; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2] diff --git a/ram/wram.asm b/ram/wram.asm index 8c246b8a..32749db3 100644 --- a/ram/wram.asm +++ b/ram/wram.asm @@ -576,10 +576,10 @@ wFilteredBagItemsCount:: db wSimulatedJoypadStatesIndex:: db ; written to but nothing ever reads it -wWastedByteCD39:: db +wUnusedCD39:: db ; written to but nothing ever reads it -wWastedByteCD3A:: db +wUnusedCD3A:: db ; mask indicating which real button presses can override simulated ones ; XXX is it ever not 0? @@ -979,7 +979,10 @@ wBattleResult:: db ; bit 0: if set, DisplayTextID automatically draws a text box wAutoTextBoxDrawingControl:: db -wcf0d:: db ; used with some overworld scripts (not exactly sure what it's used for) +; used in some overworld scripts to vary scripted movement +wSavedCoordIndex:: +wOakWalkedToPlayer:: +wNextSafariZoneGateScript:: db ; used in CheckForTilePairCollisions2 to store the tile the player is on wTilePlayerStandingOn:: db @@ -1913,8 +1916,8 @@ wMissableObjectFlagsEnd:: ds 7 -; temp copy of SPRITESTATEDATA1_IMAGEINDEX (used for sprite facing/anim) -wSpriteImageIndexBackup:: db +; saved copy of SPRITESTATEDATA1_IMAGEINDEX (used for sprite facing/anim) +wSavedSpriteImageIndex:: db ; each entry consists of 2 bytes ; * the sprite ID (depending on the current map) diff --git a/scripts/FightingDojo.asm b/scripts/FightingDojo.asm index 298c2fcb..d434f681 100644 --- a/scripts/FightingDojo.asm +++ b/scripts/FightingDojo.asm @@ -32,15 +32,15 @@ FightingDojoDefaultScript: ret nz xor a ldh [hJoyHeld], a - ld [wcf0d], a + ld [wSavedCoordIndex], a ld a, [wYCoord] cp 3 ret nz ld a, [wXCoord] cp 4 ret nz - ld a, $1 - ld [wcf0d], a + ld a, 1 + ld [wSavedCoordIndex], a ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a ld a, FIGHTINGDOJO_KARATE_MASTER @@ -57,8 +57,8 @@ FightingDojoKarateMasterPostBattleScript: ld a, [wIsInBattle] cp $ff jp z, FightingDojoResetScripts - ld a, [wcf0d] - and a + ld a, [wSavedCoordIndex] + and a ; nz if the player was at (4, 3), left of the Karate Master jr z, .already_facing ld a, PLAYER_DIR_RIGHT ld [wPlayerMovingDirection], a diff --git a/scripts/PalletTown.asm b/scripts/PalletTown.asm index dd898ac6..4d5bebf0 100644 --- a/scripts/PalletTown.asm +++ b/scripts/PalletTown.asm @@ -45,7 +45,7 @@ PalletTownDefaultScript: PalletTownOakHeyWaitScript: xor a - ld [wcf0d], a + ld [wOakWalkedToPlayer], a ld a, TEXT_PALLETTOWN_OAK ldh [hSpriteIndexOrTextID], a call DisplayTextID @@ -96,8 +96,8 @@ PalletTownOakNotSafeComeWithMeScript: ret nz xor a ; ld a, SPRITE_FACING_DOWN ld [wSpritePlayerStateData1FacingDirection], a - ld a, 1 - ld [wcf0d], a + ld a, TRUE + ld [wOakWalkedToPlayer], a ld a, SELECT | START | D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a ld a, TEXT_PALLETTOWN_OAK @@ -161,7 +161,7 @@ PalletTown_TextPointers: PalletTownOakText: text_asm - ld a, [wcf0d] + ld a, [wOakWalkedToPlayer] and a jr nz, .next ld a, 1 diff --git a/scripts/Route22.asm b/scripts/Route22.asm index abf6c8e4..1e575e43 100644 --- a/scripts/Route22.asm +++ b/scripts/Route22.asm @@ -38,7 +38,7 @@ Route22GetRivalTrainerNoByStarterScript: Route22MoveRivalRightScript: ld de, Route22RivalMovementData - ld a, [wcf0d] + ld a, [wSavedCoordIndex] cp $1 jr z, .skip_first_right inc de @@ -62,7 +62,7 @@ Route22DefaultScript: call ArePlayerCoordsInArray ret nc ld a, [wCoordIndex] - ld [wcf0d], a + ld [wSavedCoordIndex], a xor a ldh [hJoyHeld], a ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN @@ -107,8 +107,8 @@ Route22Rival1StartBattleScript: ld a, [wd730] bit 0, a ret nz - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, lower entry in Route22DefaultScript.Route22RivalBattleCoords jr nz, .set_rival_facing_right ld a, PLAYER_DIR_DOWN ld [wPlayerMovingDirection], a @@ -172,8 +172,8 @@ Route22Rival1AfterBattleScript: ld [wNewSoundID], a call PlaySound farcall Music_RivalAlternateStart - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, lower entry in Route22DefaultScript.Route22RivalBattleCoords jr nz, .exit_movement_2 call .RivalExit1Script jr .next_script @@ -263,8 +263,8 @@ Route22Rival2StartBattleScript: ret nz ld a, ROUTE22_RIVAL2 ldh [hSpriteIndex], a - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, lower entry in Route22DefaultScript.Route22RivalBattleCoords jr nz, .set_player_direction_left ld a, PLAYER_DIR_DOWN ld [wPlayerMovingDirection], a @@ -307,8 +307,8 @@ Route22Rival2AfterBattleScript: jp z, Route22SetDefaultScript ld a, ROUTE22_RIVAL2 ldh [hSpriteIndex], a - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, lower entry in Route22DefaultScript.Route22RivalBattleCoords jr nz, .set_player_direction_left ld a, PLAYER_DIR_DOWN ld [wPlayerMovingDirection], a @@ -331,8 +331,8 @@ Route22Rival2AfterBattleScript: ld [wNewSoundID], a call PlaySound farcall Music_RivalAlternateStartAndTempo - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, lower entry in Route22DefaultScript.Route22RivalBattleCoords jr nz, .exit_movement_2 call .RivalExit1Script jr .next_script diff --git a/scripts/SafariZoneGate.asm b/scripts/SafariZoneGate.asm index a0f9c1f4..14a8a79b 100644 --- a/scripts/SafariZoneGate.asm +++ b/scripts/SafariZoneGate.asm @@ -29,14 +29,14 @@ SafariZoneGateDefaultScript: ld a, SPRITE_FACING_RIGHT ld [wSpritePlayerStateData1FacingDirection], a ld a, [wCoordIndex] - cp $1 + cp 1 ; index of second, lower entry in .PlayerNextToSafariZoneWorker1CoordsArray jr z, .player_not_next_to_worker ld a, SCRIPT_SAFARIZONEGATE_WOULD_YOU_LIKE_TO_JOIN ld [wSafariZoneGateCurScript], a ret .player_not_next_to_worker ld a, D_RIGHT - ld c, $1 + ld c, 1 call SafariZoneEntranceAutoWalk ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN ld [wJoyIgnore], a @@ -88,7 +88,7 @@ SafariZoneGateLeavingSafariScript: xor a ld [wNumSafariBalls], a ld a, D_DOWN - ld c, $3 + ld c, 3 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_PLAYER_MOVING_DOWN ld [wSafariZoneGateCurScript], a @@ -113,7 +113,7 @@ SafariZoneGateSetScriptAfterMoveScript: call SafariZoneGateReturnSimulatedJoypadStateScript ret nz call Delay3 - ld a, [wcf0d] + ld a, [wNextSafariZoneGateScript] ld [wSafariZoneGateCurScript], a ret @@ -236,11 +236,11 @@ SafariZoneGateSafariZoneWorker1LeavingEarlyText: xor a ld [wSpritePlayerStateData1FacingDirection], a ld a, D_DOWN - ld c, $3 + ld c, 3 call SafariZoneEntranceAutoWalk ResetEvents EVENT_SAFARI_GAME_OVER, EVENT_IN_SAFARI_ZONE - ld a, $0 - ld [wcf0d], a + ld a, SCRIPT_SAFARIZONEGATE_DEFAULT + ld [wNextSafariZoneGateScript], a jr .set_current_script .not_ready_to_leave ld hl, .GoodLuckText @@ -248,10 +248,10 @@ SafariZoneGateSafariZoneWorker1LeavingEarlyText: ld a, SPRITE_FACING_UP ld [wSpritePlayerStateData1FacingDirection], a ld a, D_UP - ld c, $1 + ld c, 1 call SafariZoneEntranceAutoWalk ld a, SCRIPT_SAFARIZONEGATE_LEAVING_SAFARI - ld [wcf0d], a + ld [wNextSafariZoneGateScript], a .set_current_script ld a, SCRIPT_SAFARIZONEGATE_SET_SCRIPT_AFTER_MOVE ld [wSafariZoneGateCurScript], a diff --git a/scripts/SilphCo11F.asm b/scripts/SilphCo11F.asm index 1a2978a8..778283c5 100644 --- a/scripts/SilphCo11F.asm +++ b/scripts/SilphCo11F.asm @@ -170,7 +170,7 @@ SilphCo11FDefaultScript: call ArePlayerCoordsInArray jp nc, CheckFightingMapTrainers ld a, [wCoordIndex] - ld [wcf0d], a + ld [wSavedCoordIndex], a xor a ldh [hJoyHeld], a ld a, D_RIGHT | D_LEFT | D_UP | D_DOWN @@ -209,8 +209,8 @@ SilphCo11FGiovanniAfterBattleScript: ld a, [wIsInBattle] cp $ff jp z, SilphCo11FResetCurScript - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, upper-right entry in SilphCo11FDefaultScript.PlayerCoordsArray jr z, .face_player_up ld a, PLAYER_DIR_LEFT ld b, SPRITE_FACING_RIGHT @@ -242,8 +242,8 @@ SilphCo11FGiovanniBattleFacingScript: ld a, SILPHCO11F_GIOVANNI ldh [hSpriteIndex], a call SetSpriteMovementBytesToFF - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, upper-right entry in SilphCo11FDefaultScript.PlayerCoordsArray jr z, .face_player_up ld a, PLAYER_DIR_LEFT ld b, SPRITE_FACING_RIGHT diff --git a/scripts/SilphCo7F.asm b/scripts/SilphCo7F.asm index c6afd27a..bfa78847 100644 --- a/scripts/SilphCo7F.asm +++ b/scripts/SilphCo7F.asm @@ -145,8 +145,8 @@ SilphCo7FDefaultScript: call SetSpriteMovementBytesToFF ld de, .RivalMovementUp ld a, [wCoordIndex] - ld [wcf0d], a - cp $1 + ld [wSavedCoordIndex], a + cp 1 ; index of second, lower entry in .RivalEncounterCoordinates jr z, .full_rival_movement inc de .full_rival_movement @@ -225,8 +225,8 @@ SilphCo7FRivalAfterBattleScript: call PlaySound farcall Music_RivalAlternateStart ld de, .RivalWalkAroundPlayerMovement - ld a, [wcf0d] - cp $1 + ld a, [wSavedCoordIndex] + cp 1 ; index of second, lower entry in SilphCo7FDefaultScript.RivalEncounterCoordinates jr nz, .walk_around_player ld de, .RivalExitRightMovement .walk_around_player diff --git a/scripts/VermilionCity.asm b/scripts/VermilionCity.asm index 4c8a0b18..9d800233 100644 --- a/scripts/VermilionCity.asm +++ b/scripts/VermilionCity.asm @@ -47,7 +47,7 @@ VermilionCityDefaultScript: ret nc xor a ldh [hJoyHeld], a - ld [wcf0d], a + ld [wSavedCoordIndex], a ; unnecessary ld a, TEXT_VERMILIONCITY_SAILOR1 ldh [hSpriteIndexOrTextID], a call DisplayTextID -- cgit v1.3.1-sl0p From 41ec74e1f0481ec995a5ad9e9dd73e7ad91c181f Mon Sep 17 00:00:00 2001 From: Rangi42 Date: Tue, 21 Nov 2023 20:36:00 -0500 Subject: Fix inaccurate comment in UpdateNPCSprite Fixes #404 --- engine/overworld/movement.asm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'engine/overworld') diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index eb186f1e..fd26f9cb 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -129,7 +129,7 @@ UpdateNPCSprite: and a jp z, InitializeSpriteStatus call CheckSpriteAvailability - ret c ; if sprite is invisible, on tile >=MAP_TILESET_SIZE, in grass or player is currently walking + ret c ; don't do anything if sprite is invisible ld h, HIGH(wSpriteStateData1) ldh a, [hCurrentSpriteOffset] ld l, a @@ -148,7 +148,7 @@ UpdateNPCSprite: jp z, UpdateSpriteInWalkingAnimation ; [x#SPRITESTATEDATA1_MOVEMENTSTATUS] == 3 ld a, [wWalkCounter] and a - ret nz ; don't do anything yet if player is currently moving (redundant, already tested in CheckSpriteAvailability) + ret nz ; don't do anything yet if player is currently moving call InitializeSpriteScreenPosition ld h, HIGH(wSpriteStateData2) ldh a, [hCurrentSpriteOffset] -- cgit v1.3.1-sl0p From a247120ac115c7c7f48d487dbaf9aaaf26e18757 Mon Sep 17 00:00:00 2001 From: dannye <33dannye@gmail.com> Date: Tue, 21 Nov 2023 20:18:04 -0600 Subject: Fix a few usages of EFFECTIVE --- engine/battle/core.asm | 3 +-- engine/battle/display_effectiveness.asm | 2 +- engine/overworld/sprite_collisions.asm | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) (limited to 'engine/overworld') diff --git a/engine/battle/core.asm b/engine/battle/core.asm index b93b6fa7..ca3294b8 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -5324,8 +5324,7 @@ AIGetTypeEffectiveness: inc hl ld c, [hl] ; c = type 2 of player's pokemon ; initialize to neutral effectiveness - ; bug: this is $10 (MORE_EFFECTIVE + 1) but should be 10 (EFFECTIVE) - ld a, MORE_EFFECTIVE + 1 + ld a, $10 ; bug: should be EFFECTIVE (10) ld [wTypeEffectiveness], a ld hl, TypeEffects .loop diff --git a/engine/battle/display_effectiveness.asm b/engine/battle/display_effectiveness.asm index b23695cf..2879f847 100644 --- a/engine/battle/display_effectiveness.asm +++ b/engine/battle/display_effectiveness.asm @@ -1,7 +1,7 @@ DisplayEffectiveness: ld a, [wDamageMultipliers] and $7F - cp $0A + cp EFFECTIVE ret z ld hl, SuperEffectiveText jr nc, .done diff --git a/engine/overworld/sprite_collisions.asm b/engine/overworld/sprite_collisions.asm index ffed3708..e6d89480 100644 --- a/engine/overworld/sprite_collisions.asm +++ b/engine/overworld/sprite_collisions.asm @@ -1,5 +1,5 @@ _UpdateSprites:: - ld h, $c1 + ld h, HIGH(wSpriteStateData1) inc h ld a, SPRITESTATEDATA2_IMAGEBASEOFFSET .spriteLoop -- cgit v1.3.1-sl0p