pokered/engine/overworld/hidden_items.asm

161 lines
2.9 KiB
NASM
Raw Normal View History

2014-05-22 22:13:20 +00:00
HiddenItems: ; 76688 (1d:6688)
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
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
ld [wd11e], a
2014-05-22 22:13:20 +00:00
call GetItemName
tx_pre_jump FoundHiddenItemText
2014-05-22 22:13:20 +00:00
INCLUDE "data/hidden_item_coords.asm"
FoundHiddenItemText: ; 7675b (1d:675b)
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
jr nc, .BagFull
2015-07-19 03:49:52 +00:00
ld hl, wObtainedHiddenItemsFlags
ld a, [wTrainerScreenX]
2014-05-22 22:13:20 +00:00
ld c, a
2015-07-20 03:45:34 +00:00
ld b, FLAG_SET
predef FlagActionPredef
2015-07-19 08:46:12 +00:00
ld a, SFX_GET_ITEM_2
call PlaySoundWaitForCurrent
call WaitForSoundToFinish
2014-05-22 22:13:20 +00:00
jp TextScriptEnd
.BagFull
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
HiddenItemBagFullText: ; 76794 (1d:6794)
TX_FAR _HiddenItemBagFullText
db "@"
HiddenCoins: ; 76799 (1d:6799)
ld b, COIN_CASE
2015-01-23 03:05:13 +00:00
predef IsItemInBag_
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
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
jr z, .bcd20
jr .bcd100
.bcd10
ld a, $10
2015-07-17 08:21:40 +00:00
ld [hCoins + 1], a
2014-05-22 22:13:20 +00:00
jr .bcddone
.bcd20
ld a, $20
2015-07-17 08:21:40 +00:00
ld [hCoins + 1], a
2014-05-22 22:13:20 +00:00
jr .bcddone
.bcd40 ; due to a typo, this is never used
ld a, $40
2015-07-17 08:21:40 +00:00
ld [hCoins + 1], a
2014-05-22 22:13:20 +00:00
jr .bcddone
.bcd100
ld a, $1
2015-07-17 08:21:40 +00:00
ld [hCoins], a
2014-05-22 22:13:20 +00:00
.bcddone
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
predef AddBCDPredef
2015-07-19 03:49:52 +00:00
ld hl, wObtainedHiddenCoinsFlags
ld a, [wTrainerScreenX]
2014-05-22 22:13:20 +00:00
ld c, a
2015-07-20 03:45:34 +00:00
ld b, FLAG_SET
predef FlagActionPredef
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
ld a, [wPlayerCoins]
cp $99
jr nz, .RoomInCoinCase
ld a, [wPlayerCoins + 1]
cp $99
jr nz, .RoomInCoinCase
tx_pre_id DroppedHiddenCoinsText
2014-05-22 22:13:20 +00:00
jr .done
.RoomInCoinCase
tx_pre_id FoundHiddenCoinsText
2014-05-22 22:13:20 +00:00
.done
jp PrintPredefTextID
INCLUDE "data/hidden_coins.asm"
FoundHiddenCoinsText: ; 76847 (1d:6847)
TX_FAR _FoundHiddenCoinsText
db $10,"@"
DroppedHiddenCoinsText: ; 7684d (1d:684d)
TX_FAR _FoundHiddenCoins2Text
db $10
TX_FAR _DroppedHiddenCoinsText
db "@"
2015-07-19 03:49:52 +00:00
FindHiddenItemOrCoinsIndex: ; 76857 (1d:6857)
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
ld a, [W_CURMAP]
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