diff options
| author | dannye <33dannye@gmail.com> | 2026-01-17 22:38:33 -0600 |
|---|---|---|
| committer | dannye <33dannye@gmail.com> | 2026-01-17 22:38:33 -0600 |
| commit | bc2354dd6626ce28bb9561547ed2107cfa56c18e (patch) | |
| tree | 5902d4c3389253c76b7c3351e0d7dfecb551c28d /engine/overworld/toggleable_objects.asm | |
| parent | Identify characters in `_OakSpeechText2B` and `Printer_GetMonStats.IDNo` (#144) (diff) | |
| parent | Use macros for `WildMonEncounterSlotChances` (#562) (diff) | |
| download | pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.gz pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.tar.xz pokeyellow-bc2354dd6626ce28bb9561547ed2107cfa56c18e.zip | |
Merge branch 'master' of https://github.com/pret/pokered
Diffstat (limited to '')
| -rw-r--r-- | engine/overworld/toggleable_objects.asm (renamed from engine/overworld/missable_objects.asm) | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/engine/overworld/missable_objects.asm b/engine/overworld/toggleable_objects.asm index bcaa731b..a97f2bd2 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,22 +7,23 @@ 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 a, l - sub LOW(MissableObjects) ; calculate difference between out pointer and the base pointer + sub LOW(ToggleableObjectStates) ; calculate difference between out pointer and the base pointer ld l, a ld a, h - sbc HIGH(MissableObjects) + sbc HIGH(ToggleableObjectStates) 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 @@ -33,14 +34,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 @@ -52,92 +53,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 @@ -174,10 +175,10 @@ MissableObjectFlagAction: ld a, b and a jr z, .reset - cp 2 + cp FLAG_TEST jr z, .read -.set +; set ld a, [hl] ld b, a ld a, d |
