summaryrefslogtreecommitdiff
path: root/engine/overworld/hidden_items.asm
diff options
context:
space:
mode:
Diffstat (limited to 'engine/overworld/hidden_items.asm')
-rwxr-xr-xengine/overworld/hidden_items.asm90
1 files changed, 44 insertions, 46 deletions
diff --git a/engine/overworld/hidden_items.asm b/engine/overworld/hidden_items.asm
index 17288a17..28528116 100755
--- a/engine/overworld/hidden_items.asm
+++ b/engine/overworld/hidden_items.asm
@@ -1,43 +1,41 @@
HiddenItems: ; 76688 (1d:6688)
ld hl, HiddenItemCoords
- call Func_76857
- ld [wTrainerScreenX], a
- ld hl, wd6f0
- ld a, [wTrainerScreenX]
+ call FindHiddenItemOrCoinsIndex
+ ld [wHiddenItemOrCoinsIndex], a
+ ld hl, wObtainedHiddenItemsFlags
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
and a
ret nz
call EnableAutoTextBoxDrawing
- ld a, $1
+ ld a, 1
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
- ld a, [wWhichTrade] ; item ID
+ ld a, [wHiddenObjectFunctionArgument] ; item ID
ld [wd11e], a
call GetItemName
- ld a, $24
- jp PrintPredefTextID
+ tx_pre_jump FoundHiddenItemText
INCLUDE "data/hidden_item_coords.asm"
FoundHiddenItemText: ; 7675b (1d:675b)
-; XXX where is the pointer to this?
TX_FAR _FoundHiddenItemText
- db $8
- ld a, [wWhichTrade] ; item ID
+ TX_ASM
+ ld a, [wHiddenObjectFunctionArgument] ; item ID
ld b, a
ld c, 1
call GiveItem
jr nc, .BagFull
- ld hl, wd6f0
- ld a, [wTrainerScreenX]
+ ld hl, wObtainedHiddenItemsFlags
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
predef FlagActionPredef
- ld a, (SFX_02_3b - SFX_Headers_02) / 3
- call PlaySoundWaitForCurrent ; play sound
- call WaitForSoundToFinish ; wait for sound to finish playing
+ ld a, SFX_GET_ITEM_2
+ call PlaySoundWaitForCurrent
+ call WaitForSoundToFinish
jp TextScriptEnd
.BagFull
call WaitForTextScrollButtonPress ; wait for button press
@@ -53,26 +51,26 @@ HiddenItemBagFullText: ; 76794 (1d:6794)
HiddenCoins: ; 76799 (1d:6799)
ld b, COIN_CASE
- predef IsItemInBag_
+ predef GetQuantityOfItemInBag
ld a, b
and a
ret z
ld hl, HiddenCoinCoords
- call Func_76857
- ld [wTrainerScreenX], a
- ld hl, wd6fe
- ld a, [wTrainerScreenX]
+ call FindHiddenItemOrCoinsIndex
+ ld [wHiddenItemOrCoinsIndex], a
+ ld hl, wObtainedHiddenCoinsFlags
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
- ld b, $2
+ ld b, FLAG_TEST
predef FlagActionPredef
ld a, c
and a
ret nz
xor a
- ld [$ff9f], a
- ld [$ffa0], a
- ld [$ffa1], a
- ld a, [wWhichTrade]
+ ld [hUnusedCoinsByte], a
+ ld [hCoins], a
+ ld [hCoins + 1], a
+ ld a, [wHiddenObjectFunctionArgument]
sub COIN
cp 10
jr z, .bcd10
@@ -83,28 +81,28 @@ HiddenCoins: ; 76799 (1d:6799)
jr .bcd100
.bcd10
ld a, $10
- ld [$ffa1], a
+ ld [hCoins + 1], a
jr .bcddone
.bcd20
ld a, $20
- ld [$ffa1], a
+ ld [hCoins + 1], a
jr .bcddone
.bcd40 ; due to a typo, this is never used
ld a, $40
- ld [$ffa1], a
+ ld [hCoins + 1], a
jr .bcddone
.bcd100
ld a, $1
- ld [$ffa0], a
+ ld [hCoins], a
.bcddone
ld de, wPlayerCoins + 1
- ld hl, $ffa1
+ ld hl, hCoins + 1
ld c, $2
predef AddBCDPredef
- ld hl, wd6fe
- ld a, [wTrainerScreenX]
+ ld hl, wObtainedHiddenCoinsFlags
+ ld a, [wHiddenItemOrCoinsIndex]
ld c, a
- ld b, $1
+ ld b, FLAG_SET
predef FlagActionPredef
call EnableAutoTextBoxDrawing
ld a, [wPlayerCoins]
@@ -113,10 +111,10 @@ HiddenCoins: ; 76799 (1d:6799)
ld a, [wPlayerCoins + 1]
cp $99
jr nz, .RoomInCoinCase
- ld a, $2c
+ tx_pre_id DroppedHiddenCoinsText
jr .done
.RoomInCoinCase
- ld a, $2b
+ tx_pre_id FoundHiddenCoinsText
.done
jp PrintPredefTextID
@@ -132,31 +130,31 @@ DroppedHiddenCoinsText: ; 7684d (1d:684d)
TX_FAR _DroppedHiddenCoinsText
db "@"
-Func_76857: ; 76857 (1d:6857)
- ld a, [wTrainerScreenY]
+FindHiddenItemOrCoinsIndex: ; 76857 (1d:6857)
+ ld a, [wHiddenObjectY]
ld d, a
- ld a, [wTrainerScreenX]
+ ld a, [wHiddenObjectX]
ld e, a
ld a, [W_CURMAP]
ld b, a
- ld c, $ff
+ ld c, -1
.loop
inc c
ld a, [hli]
cp $ff ; end of the list?
ret z ; if so, we're done here
cp b
- jr nz, .asm_76877 ; 0x7686b $a
+ jr nz, .next1
ld a, [hli]
cp d
- jr nz, .asm_76878 ; 0x7686f $7
+ jr nz, .next2
ld a, [hli]
cp e
jr nz, .loop
ld a, c
ret
-.asm_76877
+.next1
inc hl
-.asm_76878
+.next2
inc hl
jr .loop