2020-07-04 02:57:43 +00:00
|
|
|
; this function is used to display sign messages, sprite dialog, etc.
|
2024-09-19 01:01:18 +00:00
|
|
|
; INPUT: [hSpriteIndex] = sprite ID or [hTextID] = text ID
|
2020-07-04 02:57:43 +00:00
|
|
|
DisplayTextID::
|
2024-09-19 01:01:18 +00:00
|
|
|
assert hSpriteIndex == hTextID ; these are at the same memory location
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [hLoadedROMBank]
|
2020-07-04 02:57:43 +00:00
|
|
|
push af
|
2020-07-07 01:18:22 +00:00
|
|
|
farcall DisplayTextIDInit ; initialization
|
2020-07-04 02:57:43 +00:00
|
|
|
ld hl, wTextPredefFlag
|
2024-09-24 03:51:44 +00:00
|
|
|
bit BIT_TEXT_PREDEF, [hl]
|
|
|
|
res BIT_TEXT_PREDEF, [hl]
|
2020-07-04 02:57:43 +00:00
|
|
|
jr nz, .skipSwitchToMapBank
|
|
|
|
ld a, [wCurMap]
|
|
|
|
call SwitchToMapRomBank
|
|
|
|
.skipSwitchToMapBank
|
|
|
|
ld a, 30 ; half a second
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hFrameCounter], a ; used as joypad poll timer
|
2023-11-17 18:50:27 +00:00
|
|
|
ld hl, wCurMapTextPtr
|
2020-07-04 02:57:43 +00:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a ; hl = map text pointer
|
|
|
|
ld d, $00
|
2024-09-19 01:01:18 +00:00
|
|
|
ldh a, [hTextID]
|
2020-07-04 02:57:43 +00:00
|
|
|
ld [wSpriteIndex], a
|
2020-07-04 21:09:35 +00:00
|
|
|
|
|
|
|
dict TEXT_START_MENU, DisplayStartMenu
|
|
|
|
dict TEXT_SAFARI_GAME_OVER, DisplaySafariGameOverText
|
|
|
|
dict TEXT_MON_FAINTED, DisplayPokemonFaintedText
|
|
|
|
dict TEXT_BLACKED_OUT, DisplayPlayerBlackedOutText
|
|
|
|
dict TEXT_REPEL_WORE_OFF, DisplayRepelWoreOffText
|
|
|
|
|
2020-07-04 02:57:43 +00:00
|
|
|
ld a, [wNumSprites]
|
|
|
|
ld e, a
|
2024-09-19 01:01:18 +00:00
|
|
|
ldh a, [hSpriteIndex] ; sprite ID
|
2020-07-04 02:57:43 +00:00
|
|
|
cp e
|
|
|
|
jr z, .spriteHandling
|
|
|
|
jr nc, .skipSpriteHandling
|
|
|
|
.spriteHandling
|
|
|
|
; get the text ID of the sprite
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2020-07-07 01:18:22 +00:00
|
|
|
farcall UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction)
|
2020-07-04 02:57:43 +00:00
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
ld hl, wMapSpriteData ; NPC text entries
|
2024-09-19 01:01:18 +00:00
|
|
|
ldh a, [hSpriteIndex]
|
2020-07-04 02:57:43 +00:00
|
|
|
dec a
|
|
|
|
add a
|
|
|
|
add l
|
|
|
|
ld l, a
|
|
|
|
jr nc, .noCarry
|
|
|
|
inc h
|
|
|
|
.noCarry
|
|
|
|
inc hl
|
|
|
|
ld a, [hl] ; a = text ID of the sprite
|
|
|
|
pop hl
|
|
|
|
.skipSpriteHandling
|
|
|
|
; look up the address of the text in the map's text entries
|
|
|
|
dec a
|
|
|
|
ld e, a
|
|
|
|
sla e
|
|
|
|
add hl, de
|
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a ; hl = address of the text
|
|
|
|
ld a, [hl] ; a = first byte of text
|
2020-07-04 21:09:35 +00:00
|
|
|
|
2020-07-04 02:57:43 +00:00
|
|
|
; check first byte of text for special cases
|
2020-07-04 21:09:35 +00:00
|
|
|
|
2022-06-06 21:25:31 +00:00
|
|
|
MACRO dict2
|
2020-07-04 21:09:35 +00:00
|
|
|
cp \1
|
|
|
|
jr nz, .not\@
|
|
|
|
\2
|
2020-07-04 02:57:43 +00:00
|
|
|
jr AfterDisplayingTextID
|
2020-07-04 21:09:35 +00:00
|
|
|
.not\@
|
|
|
|
ENDM
|
|
|
|
|
|
|
|
dict TX_SCRIPT_MART, DisplayPokemartDialogue
|
|
|
|
dict TX_SCRIPT_POKECENTER_NURSE, DisplayPokemonCenterDialogue
|
|
|
|
dict TX_SCRIPT_PLAYERS_PC, TextScript_ItemStoragePC
|
|
|
|
dict TX_SCRIPT_BILLS_PC, TextScript_BillsPC
|
|
|
|
dict TX_SCRIPT_POKECENTER_PC, TextScript_PokemonCenterPC
|
2020-07-07 01:18:22 +00:00
|
|
|
dict2 TX_SCRIPT_VENDING_MACHINE, farcall VendingMachineMenu
|
2020-07-04 21:09:35 +00:00
|
|
|
dict TX_SCRIPT_PRIZE_VENDOR, TextScript_GameCornerPrizeMenu
|
2020-07-07 01:18:22 +00:00
|
|
|
dict2 TX_SCRIPT_CABLE_CLUB_RECEPTIONIST, callfar CableClubNPC
|
2020-07-04 21:09:35 +00:00
|
|
|
|
2020-07-04 02:57:43 +00:00
|
|
|
call PrintText_NoCreatingTextBox ; display the text
|
|
|
|
ld a, [wDoNotWaitForButtonPressAfterDisplayingText]
|
|
|
|
and a
|
|
|
|
jr nz, HoldTextDisplayOpen
|
|
|
|
|
|
|
|
AfterDisplayingTextID::
|
|
|
|
ld a, [wEnteringCableClub]
|
|
|
|
and a
|
|
|
|
jr nz, HoldTextDisplayOpen
|
|
|
|
call WaitForTextScrollButtonPress ; wait for a button press after displaying all the text
|
|
|
|
|
|
|
|
; loop to hold the dialogue box open as long as the player keeps holding down the A button
|
|
|
|
HoldTextDisplayOpen::
|
|
|
|
call Joypad
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [hJoyHeld]
|
2021-11-05 19:40:15 +00:00
|
|
|
bit BIT_A_BUTTON, a
|
2020-07-04 02:57:43 +00:00
|
|
|
jr nz, HoldTextDisplayOpen
|
|
|
|
|
|
|
|
CloseTextDisplay::
|
|
|
|
ld a, [wCurMap]
|
|
|
|
call SwitchToMapRomBank
|
|
|
|
ld a, $90
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hWY], a ; move the window off the screen
|
2020-07-04 02:57:43 +00:00
|
|
|
call DelayFrame
|
|
|
|
call LoadGBPal
|
|
|
|
xor a
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hAutoBGTransferEnabled], a ; disable continuous WRAM to VRAM transfer each V-blank
|
2020-07-04 02:57:43 +00:00
|
|
|
; loop to make sprites face the directions they originally faced before the dialogue
|
2020-07-07 20:57:51 +00:00
|
|
|
ld hl, wSprite01StateData2OrigFacingDirection
|
2020-07-04 02:57:43 +00:00
|
|
|
ld c, $0f
|
2020-07-04 05:00:45 +00:00
|
|
|
ld de, $10
|
2020-07-04 02:57:43 +00:00
|
|
|
.restoreSpriteFacingDirectionLoop
|
2020-07-07 20:57:51 +00:00
|
|
|
ld a, [hl] ; x#SPRITESTATEDATA2_ORIGFACINGDIRECTION
|
2020-07-04 02:57:43 +00:00
|
|
|
dec h
|
2020-07-07 20:57:51 +00:00
|
|
|
ld [hl], a ; [x#SPRITESTATEDATA1_FACINGDIRECTION]
|
2020-07-04 02:57:43 +00:00
|
|
|
inc h
|
|
|
|
add hl, de
|
|
|
|
dec c
|
|
|
|
jr nz, .restoreSpriteFacingDirectionLoop
|
|
|
|
ld a, BANK(InitMapSprites)
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hLoadedROMBank], a
|
2020-07-04 02:57:43 +00:00
|
|
|
ld [MBC1RomBank], a
|
|
|
|
call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns)
|
|
|
|
ld hl, wFontLoaded
|
2024-09-24 03:51:44 +00:00
|
|
|
res BIT_FONT_LOADED, [hl]
|
2024-07-16 17:02:54 +00:00
|
|
|
ld a, [wStatusFlags6]
|
|
|
|
bit BIT_FLY_WARP, a
|
2020-07-04 02:57:43 +00:00
|
|
|
call z, LoadPlayerSpriteGraphics
|
|
|
|
call LoadCurrentMapView
|
|
|
|
pop af
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hLoadedROMBank], a
|
2020-07-04 02:57:43 +00:00
|
|
|
ld [MBC1RomBank], a
|
|
|
|
jp UpdateSprites
|
|
|
|
|
|
|
|
DisplayPokemartDialogue::
|
|
|
|
push hl
|
|
|
|
ld hl, PokemartGreetingText
|
|
|
|
call PrintText
|
|
|
|
pop hl
|
|
|
|
inc hl
|
|
|
|
call LoadItemList
|
|
|
|
ld a, PRICEDITEMLISTMENU
|
|
|
|
ld [wListMenuID], a
|
2020-11-05 15:50:30 +00:00
|
|
|
homecall DisplayPokemartDialogue_
|
2020-07-04 02:57:43 +00:00
|
|
|
jp AfterDisplayingTextID
|
|
|
|
|
|
|
|
PokemartGreetingText::
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _PokemartGreetingText
|
|
|
|
text_end
|
2020-07-04 02:57:43 +00:00
|
|
|
|
|
|
|
LoadItemList::
|
|
|
|
ld a, 1
|
|
|
|
ld [wUpdateSpritesEnabled], a
|
|
|
|
ld a, h
|
|
|
|
ld [wItemListPointer], a
|
|
|
|
ld a, l
|
|
|
|
ld [wItemListPointer + 1], a
|
|
|
|
ld de, wItemList
|
|
|
|
.loop
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
cp $ff
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|
|
|
|
|
|
|
|
DisplayPokemonCenterDialogue::
|
|
|
|
; zeroing these doesn't appear to serve any purpose
|
|
|
|
xor a
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hItemPrice], a
|
|
|
|
ldh [hItemPrice + 1], a
|
|
|
|
ldh [hItemPrice + 2], a
|
2020-07-04 02:57:43 +00:00
|
|
|
|
|
|
|
inc hl
|
2020-11-05 15:50:30 +00:00
|
|
|
homecall DisplayPokemonCenterDialogue_
|
2020-07-04 02:57:43 +00:00
|
|
|
jp AfterDisplayingTextID
|
|
|
|
|
|
|
|
DisplaySafariGameOverText::
|
2020-07-07 01:18:22 +00:00
|
|
|
callfar PrintSafariGameOverText
|
2020-07-04 02:57:43 +00:00
|
|
|
jp AfterDisplayingTextID
|
|
|
|
|
|
|
|
DisplayPokemonFaintedText::
|
|
|
|
ld hl, PokemonFaintedText
|
|
|
|
call PrintText
|
|
|
|
jp AfterDisplayingTextID
|
|
|
|
|
|
|
|
PokemonFaintedText::
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _PokemonFaintedText
|
|
|
|
text_end
|
2020-07-04 02:57:43 +00:00
|
|
|
|
|
|
|
DisplayPlayerBlackedOutText::
|
|
|
|
ld hl, PlayerBlackedOutText
|
|
|
|
call PrintText
|
2024-07-16 17:02:54 +00:00
|
|
|
ld a, [wStatusFlags6]
|
|
|
|
res BIT_ALWAYS_ON_BIKE, a
|
|
|
|
ld [wStatusFlags6], a
|
2020-07-04 02:57:43 +00:00
|
|
|
jp HoldTextDisplayOpen
|
|
|
|
|
|
|
|
PlayerBlackedOutText::
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _PlayerBlackedOutText
|
|
|
|
text_end
|
2020-07-04 02:57:43 +00:00
|
|
|
|
|
|
|
DisplayRepelWoreOffText::
|
|
|
|
ld hl, RepelWoreOffText
|
|
|
|
call PrintText
|
|
|
|
jp AfterDisplayingTextID
|
|
|
|
|
|
|
|
RepelWoreOffText::
|
2020-07-04 21:09:35 +00:00
|
|
|
text_far _RepelWoreOffText
|
|
|
|
text_end
|