2016-06-12 00:24:04 +00:00
|
|
|
HiddenItems:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, HiddenItemCoords
|
2015-07-19 03:49:52 +00:00
|
|
|
call FindHiddenItemOrCoinsIndex
|
|
|
|
ld [wHiddenItemOrCoinsIndex], a
|
|
|
|
ld hl, wObtainedHiddenItemsFlags
|
|
|
|
ld a, [wHiddenItemOrCoinsIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b, FLAG_TEST
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
call EnableAutoTextBoxDrawing
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, 1
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [wHiddenObjectFunctionArgument] ; item ID
|
2014-05-26 21:04:56 +00:00
|
|
|
ld [wd11e], a
|
2014-05-22 22:13:20 +00:00
|
|
|
call GetItemName
|
2015-07-04 05:44:12 +00:00
|
|
|
tx_pre_jump FoundHiddenItemText
|
2014-05-22 22:13:20 +00:00
|
|
|
|
|
|
|
INCLUDE "data/hidden_item_coords.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
FoundHiddenItemText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _FoundHiddenItemText
|
2015-07-03 19:58:50 +00:00
|
|
|
TX_ASM
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [wHiddenObjectFunctionArgument] ; item ID
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
|
|
|
ld c, 1
|
|
|
|
call GiveItem
|
2016-06-12 04:30:05 +00:00
|
|
|
jr nc, .bagFull
|
2015-07-19 03:49:52 +00:00
|
|
|
ld hl, wObtainedHiddenItemsFlags
|
2015-07-23 13:07:12 +00:00
|
|
|
ld a, [wHiddenItemOrCoinsIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b, FLAG_SET
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2015-07-19 08:46:12 +00:00
|
|
|
ld a, SFX_GET_ITEM_2
|
2015-07-03 19:37:53 +00:00
|
|
|
call PlaySoundWaitForCurrent
|
|
|
|
call WaitForSoundToFinish
|
2014-05-22 22:13:20 +00:00
|
|
|
jp TextScriptEnd
|
2016-06-12 04:30:05 +00:00
|
|
|
.bagFull
|
2014-05-22 22:13:20 +00:00
|
|
|
call WaitForTextScrollButtonPress ; wait for button press
|
|
|
|
xor a
|
2014-09-13 07:50:56 +00:00
|
|
|
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
|
2014-05-22 22:13:20 +00:00
|
|
|
ld hl, HiddenItemBagFullText
|
|
|
|
call PrintText
|
|
|
|
jp TextScriptEnd
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
HiddenItemBagFullText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _HiddenItemBagFullText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
HiddenCoins:
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, COIN_CASE
|
2015-08-13 05:14:31 +00:00
|
|
|
predef GetQuantityOfItemInBag
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, b
|
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
ld hl, HiddenCoinCoords
|
2015-07-19 03:49:52 +00:00
|
|
|
call FindHiddenItemOrCoinsIndex
|
|
|
|
ld [wHiddenItemOrCoinsIndex], a
|
|
|
|
ld hl, wObtainedHiddenCoinsFlags
|
|
|
|
ld a, [wHiddenItemOrCoinsIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b, FLAG_TEST
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, c
|
|
|
|
and a
|
|
|
|
ret nz
|
|
|
|
xor a
|
2015-07-19 21:01:08 +00:00
|
|
|
ld [hUnusedCoinsByte], a
|
2015-07-17 08:21:40 +00:00
|
|
|
ld [hCoins], a
|
|
|
|
ld [hCoins + 1], a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [wHiddenObjectFunctionArgument]
|
2014-05-22 22:13:20 +00:00
|
|
|
sub COIN
|
|
|
|
cp 10
|
|
|
|
jr z, .bcd10
|
|
|
|
cp 20
|
|
|
|
jr z, .bcd20
|
|
|
|
cp 40
|
2016-06-12 04:30:05 +00:00
|
|
|
jr z, .bcd20 ; should be bcd40
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .bcd100
|
|
|
|
.bcd10
|
|
|
|
ld a, $10
|
2015-07-17 08:21:40 +00:00
|
|
|
ld [hCoins + 1], a
|
2016-06-12 04:30:05 +00:00
|
|
|
jr .bcdDone
|
2014-05-22 22:13:20 +00:00
|
|
|
.bcd20
|
|
|
|
ld a, $20
|
2015-07-17 08:21:40 +00:00
|
|
|
ld [hCoins + 1], a
|
2016-06-12 04:30:05 +00:00
|
|
|
jr .bcdDone
|
2014-05-22 22:13:20 +00:00
|
|
|
.bcd40 ; due to a typo, this is never used
|
|
|
|
ld a, $40
|
2015-07-17 08:21:40 +00:00
|
|
|
ld [hCoins + 1], a
|
2016-06-12 04:30:05 +00:00
|
|
|
jr .bcdDone
|
2014-05-22 22:13:20 +00:00
|
|
|
.bcd100
|
|
|
|
ld a, $1
|
2015-07-17 08:21:40 +00:00
|
|
|
ld [hCoins], a
|
2016-06-12 04:30:05 +00:00
|
|
|
.bcdDone
|
2014-05-26 21:04:56 +00:00
|
|
|
ld de, wPlayerCoins + 1
|
2015-07-17 08:21:40 +00:00
|
|
|
ld hl, hCoins + 1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, $2
|
2014-06-16 20:57:26 +00:00
|
|
|
predef AddBCDPredef
|
2015-07-19 03:49:52 +00:00
|
|
|
ld hl, wObtainedHiddenCoinsFlags
|
2015-07-23 13:07:12 +00:00
|
|
|
ld a, [wHiddenItemOrCoinsIndex]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld c, a
|
2015-07-20 03:45:34 +00:00
|
|
|
ld b, FLAG_SET
|
2014-06-16 20:57:26 +00:00
|
|
|
predef FlagActionPredef
|
2014-05-22 22:13:20 +00:00
|
|
|
call EnableAutoTextBoxDrawing
|
|
|
|
ld a, [wPlayerCoins]
|
|
|
|
cp $99
|
2016-06-12 04:30:05 +00:00
|
|
|
jr nz, .roomInCoinCase
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [wPlayerCoins + 1]
|
|
|
|
cp $99
|
2016-06-12 04:30:05 +00:00
|
|
|
jr nz, .roomInCoinCase
|
2015-07-04 05:44:12 +00:00
|
|
|
tx_pre_id DroppedHiddenCoinsText
|
2014-05-22 22:13:20 +00:00
|
|
|
jr .done
|
2016-06-12 04:30:05 +00:00
|
|
|
.roomInCoinCase
|
2015-07-04 05:44:12 +00:00
|
|
|
tx_pre_id FoundHiddenCoinsText
|
2014-05-22 22:13:20 +00:00
|
|
|
.done
|
|
|
|
jp PrintPredefTextID
|
|
|
|
|
|
|
|
INCLUDE "data/hidden_coins.asm"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
FoundHiddenCoinsText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _FoundHiddenCoinsText
|
|
|
|
db $10,"@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
DroppedHiddenCoinsText:
|
2014-05-22 22:13:20 +00:00
|
|
|
TX_FAR _FoundHiddenCoins2Text
|
|
|
|
db $10
|
|
|
|
TX_FAR _DroppedHiddenCoinsText
|
|
|
|
db "@"
|
|
|
|
|
2016-06-12 00:24:04 +00:00
|
|
|
FindHiddenItemOrCoinsIndex:
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [wHiddenObjectY]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld d, a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld a, [wHiddenObjectX]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld e, a
|
2015-08-31 02:38:41 +00:00
|
|
|
ld a, [wCurMap]
|
2014-05-22 22:13:20 +00:00
|
|
|
ld b, a
|
2015-07-19 03:49:52 +00:00
|
|
|
ld c, -1
|
2014-05-22 22:13:20 +00:00
|
|
|
.loop
|
|
|
|
inc c
|
|
|
|
ld a, [hli]
|
|
|
|
cp $ff ; end of the list?
|
|
|
|
ret z ; if so, we're done here
|
|
|
|
cp b
|
2015-07-19 03:49:52 +00:00
|
|
|
jr nz, .next1
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
cp d
|
2015-07-19 03:49:52 +00:00
|
|
|
jr nz, .next2
|
2014-05-22 22:13:20 +00:00
|
|
|
ld a, [hli]
|
|
|
|
cp e
|
|
|
|
jr nz, .loop
|
|
|
|
ld a, c
|
|
|
|
ret
|
2015-07-19 03:49:52 +00:00
|
|
|
.next1
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
2015-07-19 03:49:52 +00:00
|
|
|
.next2
|
2014-05-22 22:13:20 +00:00
|
|
|
inc hl
|
|
|
|
jr .loop
|