diff options
| author | Rangi <35663410+Rangi42@users.noreply.github.com> | 2026-01-07 22:05:20 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-01-07 22:05:20 -0500 |
| commit | fe1e76466b293c83e6cd3a7d4639fb3c49da26ad (patch) | |
| tree | aba22f9f595e09024b902c08ddfdac67ee0e85f3 /engine | |
| parent | Update RGBDS to 1.0.1 (although 1.0.0 still works) (diff) | |
| download | pokeyellow-fe1e76466b293c83e6cd3a7d4639fb3c49da26ad.tar.gz pokeyellow-fe1e76466b293c83e6cd3a7d4639fb3c49da26ad.tar.xz pokeyellow-fe1e76466b293c83e6cd3a7d4639fb3c49da26ad.zip | |
Use macros to enforce "missable/hide/show object" constraints, and rename them to "toggleable objects" (#557)
Diffstat (limited to 'engine')
| -rw-r--r-- | engine/events/pick_up_item.asm | 16 | ||||
| -rw-r--r-- | engine/movie/oak_speech/init_player_data.asm | 2 | ||||
| -rw-r--r-- | engine/overworld/auto_movement.asm | 4 | ||||
| -rw-r--r-- | engine/overworld/movement.asm | 2 | ||||
| -rw-r--r-- | engine/overworld/toggleable_objects.asm (renamed from engine/overworld/missable_objects.asm) | 81 |
5 files changed, 53 insertions, 52 deletions
diff --git a/engine/events/pick_up_item.asm b/engine/events/pick_up_item.asm index 8fbdcfa2..a55c604a 100644 --- a/engine/events/pick_up_item.asm +++ b/engine/events/pick_up_item.asm @@ -3,19 +3,19 @@ PickUpItem: ldh a, [hSpriteIndex] ld b, a - ld hl, wMissableObjectList -.missableObjectsListLoop + ld hl, wToggleableObjectList +.toggleableObjectsListLoop ld a, [hli] cp $ff ret z cp b - jr z, .isMissable + jr z, .isToggleable inc hl - jr .missableObjectsListLoop + jr .toggleableObjectsListLoop -.isMissable +.isToggleable ld a, [hl] - ldh [hMissableObjectIndex], a + ldh [hToggleableObjectIndex], a ld hl, wMapSpriteExtraData ldh a, [hSpriteIndex] @@ -30,8 +30,8 @@ PickUpItem: call GiveItem jr nc, .BagFull - ldh a, [hMissableObjectIndex] - ld [wMissableObjectIndex], a + ldh a, [hToggleableObjectIndex] + ld [wToggleableObjectIndex], a predef HideObject ld a, 1 ld [wDoNotWaitForButtonPressAfterDisplayingText], a diff --git a/engine/movie/oak_speech/init_player_data.asm b/engine/movie/oak_speech/init_player_data.asm index 843eb96e..bd4f86a4 100644 --- a/engine/movie/oak_speech/init_player_data.asm +++ b/engine/movie/oak_speech/init_player_data.asm @@ -45,7 +45,7 @@ DEF START_MONEY EQU $3000 ld bc, wGameProgressFlagsEnd - wGameProgressFlags call FillMemory ; clear all game progress flags - jp InitializeMissableObjectsFlags + jp InitializeToggleableObjectsFlags InitializeEmptyList: xor a ; count diff --git a/engine/overworld/auto_movement.asm b/engine/overworld/auto_movement.asm index 13d30cca..dc5fc385 100644 --- a/engine/overworld/auto_movement.asm +++ b/engine/overworld/auto_movement.asm @@ -148,8 +148,8 @@ PalletMovementScript_Done: ld a, [wSimulatedJoypadStatesIndex] and a ret nz - ld a, HS_PALLET_TOWN_OAK - ld [wMissableObjectIndex], a + ld a, TOGGLE_PALLET_TOWN_OAK + ld [wToggleableObjectIndex], a predef HideObject ld hl, wStatusFlags5 res BIT_SCRIPTED_MOVEMENT_STATE, [hl] diff --git a/engine/overworld/movement.asm b/engine/overworld/movement.asm index a353c4f1..be8d6f62 100644 --- a/engine/overworld/movement.asm +++ b/engine/overworld/movement.asm @@ -478,7 +478,7 @@ InitializeSpriteScreenPosition: ; tests if sprite is off screen or otherwise unable to do anything CheckSpriteAvailability: predef IsObjectHidden - ldh a, [hIsHiddenMissableObject] + ldh a, [hIsToggleableObjectOff] and a jp nz, .spriteInvisible ld h, HIGH(wSpriteStateData2) diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/toggleable_objects.asm index 8ea79980..bfb3576c 100644 --- a/engine/overworld/missable_objects.asm +++ b/engine/overworld/toggleable_objects.asm @@ -1,4 +1,4 @@ -MarkTownVisitedAndLoadMissableObjects:: +MarkTownVisitedAndLoadToggleableObjects:: ld a, [wCurMap] cp FIRST_ROUTE_MAP jr nc, .notInTown @@ -7,17 +7,17 @@ MarkTownVisitedAndLoadMissableObjects:: ld hl, wTownVisitedFlag ; mark town as visited (for flying) predef FlagActionPredef .notInTown - ld hl, MapHSPointers + ld hl, ToggleableObjectMapPointers ld a, [wCurMap] ld b, $0 ld c, a add hl, bc add hl, bc - ld a, [hli] ; load missable objects pointer in hl + ld a, [hli] ; load toggleable objects pointer in hl ld h, [hl] ld l, a push hl - ld de, MissableObjects ; calculate difference between out pointer and the base pointer + ld de, ToggleableObjectStates ; calculate difference between out pointer and the base pointer ld a, l sub e jr nc, .noCarry @@ -27,6 +27,7 @@ MarkTownVisitedAndLoadMissableObjects:: ld a, h sub d ld h, a + ; divide difference by 3, resulting in the global offset (number of toggleable items before ours) ld a, h ldh [hDividend], a ld a, l @@ -37,14 +38,14 @@ MarkTownVisitedAndLoadMissableObjects:: ld a, $3 ldh [hDivisor], a ld b, $2 - call Divide ; divide difference by 3, resulting in the global offset (number of missable items before ours) + call Divide ld a, [wCurMap] ld b, a ldh a, [hDividend+3] ld c, a ; store global offset in c - ld de, wMissableObjectList + ld de, wToggleableObjectList pop hl -.writeMissableObjectsListLoop +.writeToggleableObjectsListLoop ld a, [hli] cp -1 jr z, .done ; end of list @@ -56,92 +57,92 @@ MarkTownVisitedAndLoadMissableObjects:: inc de ld a, c inc c - ld [de], a ; write (global) missable object index + ld [de], a ; write (global) toggleable object index inc de - jr .writeMissableObjectsListLoop + jr .writeToggleableObjectsListLoop .done ld a, -1 ld [de], a ; write sentinel ret -InitializeMissableObjectsFlags: - ld hl, wMissableObjectFlags - ld bc, wMissableObjectFlagsEnd - wMissableObjectFlags +InitializeToggleableObjectsFlags: + ld hl, wToggleableObjectFlags + ld bc, wToggleableObjectFlagsEnd - wToggleableObjectFlags xor a - call FillMemory ; clear missable objects flags - ld hl, MissableObjects + call FillMemory ; clear toggleable objects flags + ld hl, ToggleableObjectStates xor a - ld [wMissableObjectCounter], a -.missableObjectsLoop + ld [wToggleableObjectCounter], a +.toggleableObjectsLoop ld a, [hli] - cp -1 ; end of list + cp -1 ; end of list ret z push hl inc hl ld a, [hl] - cp HIDE + cp OFF jr nz, .skip - ld hl, wMissableObjectFlags - ld a, [wMissableObjectCounter] + ld hl, wToggleableObjectFlags + ld a, [wToggleableObjectCounter] ld c, a ld b, FLAG_SET - call MissableObjectFlagAction ; set flag if Item is hidden + call ToggleableObjectFlagAction ; set flag if object is toggled off .skip - ld hl, wMissableObjectCounter + ld hl, wToggleableObjectCounter inc [hl] pop hl inc hl inc hl - jr .missableObjectsLoop + jr .toggleableObjectsLoop -; tests if current sprite is a missable object that is hidden/has been removed +; tests if current object is toggled off/has been hidden IsObjectHidden: ldh a, [hCurrentSpriteOffset] swap a ld b, a - ld hl, wMissableObjectList + ld hl, wToggleableObjectList .loop ld a, [hli] cp -1 - jr z, .notHidden ; not missable -> not hidden + jr z, .notHidden ; not toggleable -> not hidden cp b ld a, [hli] jr nz, .loop ld c, a ld b, FLAG_TEST - ld hl, wMissableObjectFlags - call MissableObjectFlagAction + ld hl, wToggleableObjectFlags + call ToggleableObjectFlagAction ld a, c and a jr nz, .hidden .notHidden xor a .hidden - ldh [hIsHiddenMissableObject], a + ldh [hIsToggleableObjectOff], a ret -; adds missable object (items, leg. pokemon, etc.) to the map -; [wMissableObjectIndex]: index of the missable object to be added (global index) +; adds toggleable object (items, leg. pokemon, etc.) to the map +; [wToggleableObjectIndex]: index of the toggleable object to be added (global index) ShowObject: ShowObject2: - ld hl, wMissableObjectFlags - ld a, [wMissableObjectIndex] + ld hl, wToggleableObjectFlags + ld a, [wToggleableObjectIndex] ld c, a ld b, FLAG_RESET - call MissableObjectFlagAction ; reset "removed" flag + call ToggleableObjectFlagAction ; reset "removed" flag jp UpdateSprites -; removes missable object (items, leg. pokemon, etc.) from the map -; [wMissableObjectIndex]: index of the missable object to be removed (global index) +; removes toggleable object (items, leg. pokemon, etc.) from the map +; [wToggleableObjectIndex]: index of the toggleable object to be removed (global index) HideObject: - ld hl, wMissableObjectFlags - ld a, [wMissableObjectIndex] + ld hl, wToggleableObjectFlags + ld a, [wToggleableObjectIndex] ld c, a ld b, FLAG_SET - call MissableObjectFlagAction ; set "removed" flag + call ToggleableObjectFlagAction ; set "removed" flag jp UpdateSprites -MissableObjectFlagAction: +ToggleableObjectFlagAction: ; identical to FlagAction push hl |
