pokered/engine/hidden_object_functions17.asm

476 lines
9.3 KiB
NASM
Raw Normal View History

2016-06-12 00:24:04 +00:00
PrintRedSNESText:
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
tx_pre_jump RedBedroomSNESText
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
RedBedroomSNESText:
2014-05-22 22:13:20 +00:00
TX_FAR _RedBedroomSNESText
db "@"
2016-06-12 00:24:04 +00:00
OpenRedsPC:
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
tx_pre_jump RedBedroomPCText
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
RedBedroomPCText:
TX_PLAYERS_PC
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
Route15GateLeftBinoculars:
ld a, [wSpriteStateData1 + 9]
cp SPRITE_FACING_UP
2014-05-22 22:13:20 +00:00
ret nz
call EnableAutoTextBoxDrawing
tx_pre Route15UpstairsBinocularsText
2014-05-22 22:13:20 +00:00
ld a, ARTICUNO
ld [wcf91], a
2014-05-22 22:13:20 +00:00
call PlayCry
jp DisplayMonFrontSpriteInBox
2016-06-12 00:24:04 +00:00
Route15UpstairsBinocularsText:
2014-05-22 22:13:20 +00:00
TX_FAR _Route15UpstairsBinocularsText
db "@"
2016-06-12 00:24:04 +00:00
AerodactylFossil:
2014-05-22 22:13:20 +00:00
ld a, FOSSIL_AERODACTYL
ld [wcf91], a
2014-05-22 22:13:20 +00:00
call DisplayMonFrontSpriteInBox
call EnableAutoTextBoxDrawing
tx_pre AerodactylFossilText
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
AerodactylFossilText:
2014-05-22 22:13:20 +00:00
TX_FAR _AerodactylFossilText
db "@"
2016-06-12 00:24:04 +00:00
KabutopsFossil:
2014-05-22 22:13:20 +00:00
ld a, FOSSIL_KABUTOPS
ld [wcf91], a
2014-05-22 22:13:20 +00:00
call DisplayMonFrontSpriteInBox
call EnableAutoTextBoxDrawing
tx_pre KabutopsFossilText
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
KabutopsFossilText:
2014-05-22 22:13:20 +00:00
TX_FAR _KabutopsFossilText
db "@"
2016-06-12 00:24:04 +00:00
DisplayMonFrontSpriteInBox:
2014-05-22 22:13:20 +00:00
; Displays a pokemon's front sprite in a pop-up window.
2017-06-24 20:01:43 +00:00
; [wcf91] = pokemon internal id number
2015-07-19 03:49:52 +00:00
ld a, 1
ld [H_AUTOBGTRANSFERENABLED], a
2014-05-22 22:13:20 +00:00
call Delay3
xor a
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer1
2015-02-07 20:27:36 +00:00
ld a, MON_SPRITE_POPUP
2015-02-07 10:43:08 +00:00
ld [wTextBoxID], a
2014-05-22 22:13:20 +00:00
call DisplayTextBoxID
call UpdateSprites
ld a, [wcf91]
ld [wd0b5], a
2014-05-22 22:13:20 +00:00
call GetMonHeader
2014-05-29 08:31:46 +00:00
ld de, vChars1 + $310
2014-05-22 22:13:20 +00:00
call LoadMonFrontSprite
ld a, $80
2015-07-24 03:48:35 +00:00
ld [hStartTileID], a
2015-07-18 20:52:03 +00:00
coord hl, 10, 11
predef AnimateSendingOutMon
2014-05-22 22:13:20 +00:00
call WaitForTextScrollButtonPress
call LoadScreenTilesFromBuffer1
call Delay3
ld a, $90
2014-09-23 22:02:03 +00:00
ld [hWY], a
2014-05-22 22:13:20 +00:00
ret
2016-06-12 00:24:04 +00:00
PrintBlackboardLinkCableText:
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
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]
2014-05-22 22:13:20 +00:00
call PrintPredefTextID
ret
2016-06-12 00:24:04 +00:00
LinkCableHelp:
2015-07-03 19:58:50 +00:00
TX_ASM
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer1
ld hl, LinkCableHelpText1
call PrintText
xor a
2015-08-30 00:15:05 +00:00
ld [wMenuItemOffset], a ; not used
2014-05-22 22:13:20 +00:00
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
2015-08-11 05:34:32 +00:00
ld a, A_BUTTON | B_BUTTON
2014-05-22 22:13:20 +00:00
ld [wMenuWatchedKeys], a
2015-08-30 00:15:05 +00:00
ld a, 3
2014-05-22 22:13:20 +00:00
ld [wMaxMenuItem], a
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemY], a
2015-08-30 00:15:05 +00:00
ld a, 1
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemX], a
2015-08-11 05:34:32 +00:00
.linkHelpLoop
ld hl, wd730
2014-05-22 22:13:20 +00:00
set 6, [hl]
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-08-30 00:15:05 +00:00
ld b, 8
ld c, 13
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 2, 2
2014-05-22 22:13:20 +00:00
ld de, HowToLinkText
call PlaceString
ld hl, LinkCableHelpText2
call PrintText
call HandleMenuInput
2015-08-11 05:34:32 +00:00
bit 1, a ; pressed b
jr nz, .exit
2014-05-22 22:13:20 +00:00
ld a, [wCurrentMenuItem]
2015-08-30 00:15:05 +00:00
cp 3 ; pressed a on "STOP READING"
2015-08-11 05:34:32 +00:00
jr z, .exit
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 6, [hl]
ld hl, LinkCableInfoTexts
add a
2015-08-30 00:15:05 +00:00
ld d, 0
2014-05-22 22:13:20 +00:00
ld e, a
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
2015-08-11 05:34:32 +00:00
jp .linkHelpLoop
.exit
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 6, [hl]
call LoadScreenTilesFromBuffer1
jp TextScriptEnd
2016-06-12 00:24:04 +00:00
LinkCableHelpText1:
2014-05-22 22:13:20 +00:00
TX_FAR _LinkCableHelpText1
db "@"
2016-06-12 00:24:04 +00:00
LinkCableHelpText2:
2014-05-22 22:13:20 +00:00
TX_FAR _LinkCableHelpText2
db "@"
2016-06-12 00:24:04 +00:00
HowToLinkText:
2014-05-22 22:13:20 +00:00
db "HOW TO LINK"
next "COLOSSEUM"
next "TRADE CENTER"
next "STOP READING@"
2016-06-12 00:24:04 +00:00
LinkCableInfoTexts:
2014-05-22 22:13:20 +00:00
dw LinkCableInfoText1
dw LinkCableInfoText2
dw LinkCableInfoText3
2016-06-12 00:24:04 +00:00
LinkCableInfoText1:
2014-05-22 22:13:20 +00:00
TX_FAR _LinkCableInfoText1
db "@"
2016-06-12 00:24:04 +00:00
LinkCableInfoText2:
2014-05-22 22:13:20 +00:00
TX_FAR _LinkCableInfoText2
db "@"
2016-06-12 00:24:04 +00:00
LinkCableInfoText3:
2014-05-22 22:13:20 +00:00
TX_FAR _LinkCableInfoText3
db "@"
2016-06-12 00:24:04 +00:00
ViridianSchoolBlackboard:
2015-07-03 19:58:50 +00:00
TX_ASM
2014-05-22 22:13:20 +00:00
call SaveScreenTilesToBuffer1
ld hl, ViridianSchoolBlackboardText1
call PrintText
xor a
2015-08-30 00:15:05 +00:00
ld [wMenuItemOffset], a
2014-05-22 22:13:20 +00:00
ld [wCurrentMenuItem], a
ld [wLastMenuItem], a
2015-08-11 05:34:32 +00:00
ld a, D_LEFT | D_RIGHT | A_BUTTON | B_BUTTON
2014-05-22 22:13:20 +00:00
ld [wMenuWatchedKeys], a
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wMaxMenuItem], a
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemY], a
2015-08-30 00:15:05 +00:00
ld a, 1
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemX], a
2015-08-11 05:34:32 +00:00
.blackboardLoop
ld hl, wd730
2014-05-22 22:13:20 +00:00
set 6, [hl]
2015-07-18 20:52:03 +00:00
coord hl, 0, 0
2015-08-05 21:20:29 +00:00
lb bc, 6, 10
2014-05-22 22:13:20 +00:00
call TextBoxBorder
2015-07-18 20:52:03 +00:00
coord hl, 1, 2
2014-05-22 22:13:20 +00:00
ld de, StatusAilmentText1
call PlaceString
2015-07-18 20:52:03 +00:00
coord hl, 6, 2
2014-05-22 22:13:20 +00:00
ld de, StatusAilmentText2
call PlaceString
ld hl, ViridianSchoolBlackboardText2
call PrintText
2015-08-11 05:34:32 +00:00
call HandleMenuInput ; pressing up and down is handled in here
bit 1, a ; pressed b
2014-05-22 22:13:20 +00:00
jr nz, .exitBlackboard
2015-08-11 05:34:32 +00:00
bit 4, a ; pressed right
jr z, .didNotPressRight
; move cursor to right column
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wMaxMenuItem], a
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemY], a
2015-08-30 00:15:05 +00:00
ld a, 6
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemX], a
2015-08-30 00:15:05 +00:00
ld a, 3 ; in the the right column, use an offset to prevent overlap
ld [wMenuItemOffset], a
2015-08-11 05:34:32 +00:00
jr .blackboardLoop
.didNotPressRight
bit 5, a ; pressed left
jr z, .didNotPressLeftOrRight
; move cursor to left column
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wMaxMenuItem], a
2015-08-30 00:15:05 +00:00
ld a, 2
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemY], a
2015-08-30 00:15:05 +00:00
ld a, 1
2014-05-22 22:13:20 +00:00
ld [wTopMenuItemX], a
xor a
2015-08-30 00:15:05 +00:00
ld [wMenuItemOffset], a
2015-08-11 05:34:32 +00:00
jr .blackboardLoop
.didNotPressLeftOrRight
2014-05-22 22:13:20 +00:00
ld a, [wCurrentMenuItem]
ld b, a
2015-08-30 00:15:05 +00:00
ld a, [wMenuItemOffset]
2014-05-22 22:13:20 +00:00
add b
2015-08-30 00:15:05 +00:00
cp 5 ; cursor is pointing to "QUIT"
2014-05-22 22:13:20 +00:00
jr z, .exitBlackboard
2015-08-11 05:34:32 +00:00
; we must have pressed a on a status condition
; so print the text
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 6, [hl]
ld hl, ViridianBlackboardStatusPointers
add a
2015-08-30 00:15:05 +00:00
ld d, 0
2014-05-22 22:13:20 +00:00
ld e, a
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
call PrintText
2015-08-11 05:34:32 +00:00
jp .blackboardLoop
2014-05-22 22:13:20 +00:00
.exitBlackboard
ld hl, wd730
2014-05-22 22:13:20 +00:00
res 6, [hl]
call LoadScreenTilesFromBuffer1
jp TextScriptEnd
2016-06-12 00:24:04 +00:00
ViridianSchoolBlackboardText1:
2014-05-22 22:13:20 +00:00
TX_FAR _ViridianSchoolBlackboardText1
db "@"
2016-06-12 00:24:04 +00:00
ViridianSchoolBlackboardText2:
2014-05-22 22:13:20 +00:00
TX_FAR _ViridianSchoolBlackboardText2
db "@"
2016-06-12 00:24:04 +00:00
StatusAilmentText1:
2014-05-22 22:13:20 +00:00
db " SLP"
next " PSN"
next " PAR@"
2016-06-12 00:24:04 +00:00
StatusAilmentText2:
2014-05-22 22:13:20 +00:00
db " BRN"
next " FRZ"
next " QUIT@@"
2016-06-12 00:24:04 +00:00
ViridianBlackboardStatusPointers:
2014-05-22 22:13:20 +00:00
dw ViridianBlackboardSleepText
dw ViridianBlackboardPoisonText
2016-01-05 21:32:25 +00:00
dw ViridianBlackboardPrlzText
2014-05-22 22:13:20 +00:00
dw ViridianBlackboardBurnText
dw ViridianBlackboardFrozenText
2016-06-12 00:24:04 +00:00
ViridianBlackboardSleepText:
2014-05-22 22:13:20 +00:00
TX_FAR _ViridianBlackboardSleepText
db "@"
2016-06-12 00:24:04 +00:00
ViridianBlackboardPoisonText:
2014-05-22 22:13:20 +00:00
TX_FAR _ViridianBlackboardPoisonText
db "@"
2016-06-12 00:24:04 +00:00
ViridianBlackboardPrlzText:
2016-01-05 21:32:25 +00:00
TX_FAR _ViridianBlackboardPrlzText
2014-05-22 22:13:20 +00:00
db "@"
2016-06-12 00:24:04 +00:00
ViridianBlackboardBurnText:
2014-05-22 22:13:20 +00:00
TX_FAR _ViridianBlackboardBurnText
db "@"
2016-06-12 00:24:04 +00:00
ViridianBlackboardFrozenText:
2014-05-22 22:13:20 +00:00
TX_FAR _ViridianBlackboardFrozenText
db "@"
2016-06-12 00:24:04 +00:00
PrintTrashText:
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
tx_pre_jump VermilionGymTrashText
2014-05-22 22:13:20 +00:00
2016-06-12 00:24:04 +00:00
VermilionGymTrashText:
2014-05-22 22:13:20 +00:00
TX_FAR _VermilionGymTrashText
db "@"
2016-06-12 00:24:04 +00:00
GymTrashScript:
2014-05-22 22:13:20 +00:00
call EnableAutoTextBoxDrawing
2015-07-19 03:49:52 +00:00
ld a, [wHiddenObjectFunctionArgument]
2015-07-25 03:27:59 +00:00
ld [wGymTrashCanIndex], a
2014-05-22 22:13:20 +00:00
; Don't do the trash can puzzle if it's already been done.
2015-07-21 01:32:02 +00:00
CheckEvent EVENT_2ND_LOCK_OPENED
2014-05-22 22:13:20 +00:00
jr z, .ok
tx_pre_jump VermilionGymTrashText
2014-05-22 22:13:20 +00:00
.ok
2015-07-25 03:27:59 +00:00
CheckEventReuseA EVENT_1ST_LOCK_OPENED
2014-05-22 22:13:20 +00:00
jr nz, .trySecondLock
2015-07-25 03:27:59 +00:00
ld a, [wFirstLockTrashCanIndex]
2014-05-22 22:13:20 +00:00
ld b, a
2015-07-25 03:27:59 +00:00
ld a, [wGymTrashCanIndex]
2014-05-22 22:13:20 +00:00
cp b
jr z, .openFirstLock
tx_pre_id VermilionGymTrashText
2014-05-22 22:13:20 +00:00
jr .done
.openFirstLock
; Next can is trying for the second switch.
2015-07-21 01:32:02 +00:00
SetEvent EVENT_1ST_LOCK_OPENED
2014-05-22 22:13:20 +00:00
ld hl, GymTrashCans
2015-07-25 03:27:59 +00:00
ld a, [wGymTrashCanIndex]
2014-05-22 22:13:20 +00:00
; * 5
ld b, a
add a
add a
add b
ld d, 0
ld e, a
add hl, de
ld a, [hli]
2015-07-26 02:26:54 +00:00
; There is a bug in this code. It should calculate a value in the range [0, 3]
; but if the mask and random number don't have any 1 bits in common, then
; the result of the AND will be 0. When 1 is subtracted from that, the value
; will become $ff. This will result in 255 being added to hl, which will cause
; hl to point to one of the zero bytes that pad the end of the ROM bank.
; Trash can 0 was intended to be able to have the second lock only when the
; first lock was in trash can 1 or 3. However, due to this bug, trash can 0 can
; have the second lock regardless of which trash can had the first lock.
ld [hGymTrashCanRandNumMask], a
2014-05-22 22:13:20 +00:00
push hl
call Random
2014-05-22 22:13:20 +00:00
swap a
ld b, a
2015-07-26 02:26:54 +00:00
ld a, [hGymTrashCanRandNumMask]
2014-05-22 22:13:20 +00:00
and b
dec a
pop hl
ld d, 0
ld e, a
add hl, de
ld a, [hl]
and $f
2015-07-25 03:27:59 +00:00
ld [wSecondLockTrashCanIndex], a
2014-05-22 22:13:20 +00:00
2016-01-09 11:03:55 +00:00
tx_pre_id VermilionGymTrashSuccessText1
2014-05-22 22:13:20 +00:00
jr .done
.trySecondLock
2015-07-25 03:27:59 +00:00
ld a, [wSecondLockTrashCanIndex]
2014-05-22 22:13:20 +00:00
ld b, a
2015-07-25 03:27:59 +00:00
ld a, [wGymTrashCanIndex]
2014-05-22 22:13:20 +00:00
cp b
jr z, .openSecondLock
; Reset the cans.
2015-07-21 01:32:02 +00:00
ResetEvent EVENT_1ST_LOCK_OPENED
call Random
2014-05-22 22:13:20 +00:00
and $e
2015-07-25 03:27:59 +00:00
ld [wFirstLockTrashCanIndex], a
2014-05-22 22:13:20 +00:00
tx_pre_id VermilionGymTrashFailText
2014-05-22 22:13:20 +00:00
jr .done
.openSecondLock
; Completed the trash can puzzle.
2015-07-21 01:32:02 +00:00
SetEvent EVENT_2ND_LOCK_OPENED
2016-01-03 19:17:10 +00:00
ld hl, wCurrentMapScriptFlags
2014-05-22 22:13:20 +00:00
set 6, [hl]
2016-01-09 11:03:55 +00:00
tx_pre_id VermilionGymTrashSuccessText3
2014-05-22 22:13:20 +00:00
.done
jp PrintPredefTextID
2016-06-12 00:24:04 +00:00
GymTrashCans:
2015-07-26 02:26:54 +00:00
; byte 0: mask for random number
; bytes 1-4: indices of the trash cans that can have the second lock
; (but see the comment above explaining a bug regarding this)
; Note that the mask is simply the number of valid trash can indices that
; follow. The remaining bytes are filled with 0 to pad the length of each entry
; to 5 bytes.
2014-05-22 22:13:20 +00:00
db 2, 1, 3, 0, 0 ; 0
db 3, 0, 2, 4, 0 ; 1
db 2, 1, 5, 0, 0 ; 2
db 3, 0, 4, 6, 0 ; 3
db 4, 1, 3, 5, 7 ; 4
db 3, 2, 4, 8, 0 ; 5
db 3, 3, 7, 9, 0 ; 6
db 4, 4, 6, 8, 10 ; 7
db 3, 5, 7, 11, 0 ; 8
db 3, 6, 10, 12, 0 ; 9
db 4, 7, 9, 11, 13 ; 10
db 3, 8, 10, 14, 0 ; 11
db 2, 9, 13, 0, 0 ; 12
db 3, 10, 12, 14, 0 ; 13
db 2, 11, 13, 0, 0 ; 14
2016-06-12 00:24:04 +00:00
VermilionGymTrashSuccessText1:
2016-01-09 11:03:55 +00:00
TX_FAR _VermilionGymTrashSuccessText1
2015-07-03 19:58:50 +00:00
TX_ASM
2014-05-22 22:13:20 +00:00
call WaitForSoundToFinish
2015-07-19 08:46:12 +00:00
ld a, SFX_SWITCH
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
jp TextScriptEnd
2015-06-12 15:26:00 +00:00
; unused
2016-06-12 00:24:04 +00:00
VermilionGymTrashSuccessText2:
2016-01-09 11:03:55 +00:00
TX_FAR _VermilionGymTrashSuccessText2
2014-05-22 22:13:20 +00:00
db "@"
2015-06-12 15:26:00 +00:00
; unused
2016-06-12 00:24:04 +00:00
VermilionGymTrashSuccesPlaySfx:
2015-07-03 19:58:50 +00:00
TX_ASM
2014-05-22 22:13:20 +00:00
call WaitForSoundToFinish
2015-07-19 08:46:12 +00:00
ld a, SFX_SWITCH
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
jp TextScriptEnd
2016-06-12 00:24:04 +00:00
VermilionGymTrashSuccessText3:
2016-01-09 11:03:55 +00:00
TX_FAR _VermilionGymTrashSuccessText3
2015-07-03 19:58:50 +00:00
TX_ASM
2014-05-22 22:13:20 +00:00
call WaitForSoundToFinish
2015-07-19 08:46:12 +00:00
ld a, SFX_GO_INSIDE
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
jp TextScriptEnd
2016-06-12 00:24:04 +00:00
VermilionGymTrashFailText:
2014-05-22 22:13:20 +00:00
TX_FAR _VermilionGymTrashFailText
2015-07-03 19:58:50 +00:00
TX_ASM
2014-05-22 22:13:20 +00:00
call WaitForSoundToFinish
2015-07-19 08:46:12 +00:00
ld a, SFX_DENIED
2014-05-22 22:13:20 +00:00
call PlaySound
call WaitForSoundToFinish
jp TextScriptEnd