2020-02-23 05:33:53 -08:00
|
|
|
Joypad::
|
2020-04-16 06:30:50 -07:00
|
|
|
; Replaced by UpdateJoypad, called from VBlank instead of the useless
|
2013-02-19 20:57:07 -08:00
|
|
|
; joypad interrupt.
|
|
|
|
|
|
|
|
; This is a placeholder in case the interrupt is somehow enabled.
|
|
|
|
reti
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ClearJoypad::
|
2013-02-19 20:57:07 -08:00
|
|
|
xor a
|
|
|
|
; Pressed this frame (delta)
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyPressed], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Currently pressed
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyDown], a
|
2013-02-19 20:57:07 -08:00
|
|
|
ret
|
|
|
|
|
2020-02-23 05:33:53 -08:00
|
|
|
UpdateJoypad::
|
2020-02-16 03:20:20 -08:00
|
|
|
; This is called automatically every frame in VBlank.
|
2013-02-19 20:57:07 -08:00
|
|
|
; Read the joypad register and translate it to something more
|
|
|
|
; workable for use in-game. There are 8 buttons, so we can use
|
|
|
|
; one byte to contain all player input.
|
|
|
|
|
|
|
|
; Updates:
|
|
|
|
|
2013-03-20 19:55:09 -07:00
|
|
|
; hJoypadReleased: released this frame (delta)
|
|
|
|
; hJoypadPressed: pressed this frame (delta)
|
|
|
|
; hJoypadDown: currently pressed
|
|
|
|
; hJoypadSum: pressed so far
|
2013-02-19 20:57:07 -08:00
|
|
|
|
|
|
|
; Any of these three bits can be used to disable input.
|
2020-10-28 10:35:39 -07:00
|
|
|
ld a, [wJoypadDisable]
|
|
|
|
and (1 << JOYPAD_DISABLE_MON_FAINT_F) | (1 << JOYPAD_DISABLE_SGB_TRANSFER_F) | (1 << 4)
|
2013-02-19 20:57:07 -08:00
|
|
|
ret nz
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; If we're saving, input is disabled.
|
2016-05-08 11:11:24 -07:00
|
|
|
ld a, [wGameLogicPaused]
|
2013-02-19 20:57:07 -08:00
|
|
|
and a
|
|
|
|
ret nz
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; We can only get four inputs at a time.
|
|
|
|
; We take d-pad first for no particular reason.
|
2015-10-16 10:35:43 -07:00
|
|
|
ld a, R_DPAD
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rJOYP], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Read twice to give the request time to take.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rJOYP]
|
|
|
|
ldh a, [rJOYP]
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; The Joypad register output is in the lo nybble (inversed).
|
|
|
|
; We make the hi nybble of our new container d-pad input.
|
|
|
|
cpl
|
|
|
|
and $f
|
|
|
|
swap a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; We'll keep this in b for now.
|
|
|
|
ld b, a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Buttons make 8 total inputs (A, B, Select, Start).
|
|
|
|
; We can fit this into one byte.
|
2015-10-16 10:35:43 -07:00
|
|
|
ld a, R_BUTTONS
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rJOYP], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Wait for input to stabilize.
|
2015-07-20 19:18:18 -07:00
|
|
|
rept 6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [rJOYP]
|
2015-07-20 19:18:18 -07:00
|
|
|
endr
|
2013-02-19 20:57:07 -08:00
|
|
|
; Buttons take the lo nybble.
|
|
|
|
cpl
|
|
|
|
and $f
|
|
|
|
or b
|
|
|
|
ld b, a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Reset the joypad register since we're done with it.
|
|
|
|
ld a, $30
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [rJOYP], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; To get the delta we xor the last frame's input with the new one.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoypadDown] ; last frame
|
2013-02-19 20:57:07 -08:00
|
|
|
ld e, a
|
|
|
|
xor b
|
|
|
|
ld d, a
|
|
|
|
; Released this frame:
|
|
|
|
and e
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoypadReleased], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Pressed this frame:
|
|
|
|
ld a, d
|
|
|
|
and b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoypadPressed], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Add any new presses to the list of collective presses:
|
|
|
|
ld c, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoypadSum]
|
2013-02-19 20:57:07 -08:00
|
|
|
or c
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoypadSum], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Currently pressed:
|
|
|
|
ld a, b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoypadDown], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Now that we have the input, we can do stuff with it.
|
|
|
|
|
|
|
|
; For example, soft reset:
|
2013-09-07 20:49:20 -07:00
|
|
|
and A_BUTTON | B_BUTTON | SELECT | START
|
|
|
|
cp A_BUTTON | B_BUTTON | SELECT | START
|
2013-07-26 20:49:33 -07:00
|
|
|
jp z, Reset
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
GetJoypad::
|
2013-03-20 19:55:09 -07:00
|
|
|
; Update mirror joypad input from hJoypadDown (real input)
|
2013-02-19 20:57:07 -08:00
|
|
|
|
2013-03-20 19:55:09 -07:00
|
|
|
; hJoyReleased: released this frame (delta)
|
|
|
|
; hJoyPressed: pressed this frame (delta)
|
|
|
|
; hJoyDown: currently pressed
|
2013-02-19 20:57:07 -08:00
|
|
|
|
|
|
|
; bit 0 A
|
|
|
|
; 1 B
|
|
|
|
; 2 SELECT
|
|
|
|
; 3 START
|
|
|
|
; 4 RIGHT
|
|
|
|
; 5 LEFT
|
|
|
|
; 6 UP
|
|
|
|
; 7 DOWN
|
|
|
|
|
|
|
|
push af
|
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; The player input can be automated using an input stream.
|
|
|
|
; See more below.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wInputType]
|
2017-12-09 21:06:20 -08:00
|
|
|
cp AUTO_INPUT
|
2013-02-19 20:57:07 -08:00
|
|
|
jr z, .auto
|
|
|
|
|
|
|
|
; To get deltas, take this and last frame's input.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoypadDown] ; real input
|
2013-02-19 20:57:07 -08:00
|
|
|
ld b, a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyDown] ; last frame mirror
|
2013-02-19 20:57:07 -08:00
|
|
|
ld e, a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Released this frame:
|
|
|
|
xor b
|
|
|
|
ld d, a
|
|
|
|
and e
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyReleased], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Pressed this frame:
|
|
|
|
ld a, d
|
|
|
|
and b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyPressed], a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; It looks like the collective presses got commented out here.
|
|
|
|
ld c, a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Currently pressed:
|
|
|
|
ld a, b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyDown], a ; frame input
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
.quit
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
pop af
|
2016-04-10 11:42:14 -07:00
|
|
|
ret
|
2013-02-19 20:57:07 -08:00
|
|
|
|
|
|
|
.auto
|
|
|
|
; Use a predetermined input stream (used in the catching tutorial).
|
|
|
|
|
|
|
|
; Stream format: [input][duration]
|
|
|
|
; A value of $ff will immediately end the stream.
|
|
|
|
|
|
|
|
; Read from the input stream.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hROMBank]
|
2013-02-19 20:57:07 -08:00
|
|
|
push af
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAutoInputBank]
|
2013-02-19 20:57:07 -08:00
|
|
|
rst Bankswitch
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld hl, wAutoInputAddress
|
2013-02-19 20:57:07 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; We only update when the input duration has expired.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wAutoInputLength]
|
2013-02-19 20:57:07 -08:00
|
|
|
and a
|
|
|
|
jr z, .updateauto
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; Until then, don't change anything.
|
|
|
|
dec a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputLength], a
|
2013-02-19 20:57:07 -08:00
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
jr .quit
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
.updateauto
|
|
|
|
; An input of $ff will end the stream.
|
|
|
|
ld a, [hli]
|
2017-12-09 21:06:20 -08:00
|
|
|
cp -1
|
2013-02-19 20:57:07 -08:00
|
|
|
jr z, .stopauto
|
|
|
|
ld b, a
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; A duration of $ff will end the stream indefinitely.
|
|
|
|
ld a, [hli]
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputLength], a
|
2017-12-09 21:06:20 -08:00
|
|
|
cp -1
|
2013-02-19 20:57:07 -08:00
|
|
|
jr nz, .next
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
; The current input is overwritten.
|
|
|
|
dec hl
|
2016-05-04 08:46:23 -07:00
|
|
|
dec hl
|
2013-02-19 20:57:07 -08:00
|
|
|
ld b, NO_INPUT
|
|
|
|
jr .finishauto
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
.next
|
|
|
|
; On to the next input...
|
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputAddress], a
|
2013-02-19 20:57:07 -08:00
|
|
|
ld a, h
|
2018-07-28 22:40:23 -07:00
|
|
|
ld [wAutoInputAddress + 1], a
|
2013-02-19 20:57:07 -08:00
|
|
|
jr .finishauto
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
.stopauto
|
|
|
|
call StopAutoInput
|
|
|
|
ld b, NO_INPUT
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
.finishauto
|
|
|
|
pop af
|
|
|
|
rst Bankswitch
|
|
|
|
ld a, b
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyPressed], a ; pressed
|
|
|
|
ldh [hJoyDown], a ; input
|
2013-02-19 20:57:07 -08:00
|
|
|
jr .quit
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StartAutoInput::
|
2013-02-19 20:57:07 -08:00
|
|
|
; Start reading automated input stream at a:hl.
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputBank], a
|
2013-02-19 20:57:07 -08:00
|
|
|
ld a, l
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputAddress], a
|
2013-02-19 20:57:07 -08:00
|
|
|
ld a, h
|
2018-07-28 22:40:23 -07:00
|
|
|
ld [wAutoInputAddress + 1], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Start reading the stream immediately.
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputLength], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Reset input mirrors.
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyPressed], a ; pressed this frame
|
|
|
|
ldh [hJoyReleased], a ; released this frame
|
|
|
|
ldh [hJoyDown], a ; currently pressed
|
2016-04-10 11:42:14 -07:00
|
|
|
|
2013-02-19 20:57:07 -08:00
|
|
|
ld a, AUTO_INPUT
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wInputType], a
|
2013-02-19 20:57:07 -08:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
StopAutoInput::
|
2013-02-19 20:57:07 -08:00
|
|
|
; Clear variables related to automated input.
|
|
|
|
xor a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputBank], a
|
|
|
|
ld [wAutoInputAddress], a
|
2018-07-28 22:40:23 -07:00
|
|
|
ld [wAutoInputAddress + 1], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wAutoInputLength], a
|
2013-02-19 20:57:07 -08:00
|
|
|
; Back to normal input.
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wInputType], a
|
2013-02-19 20:57:07 -08:00
|
|
|
ret
|
|
|
|
|
2020-06-21 15:33:31 -07:00
|
|
|
JoyTitleScreenInput:: ; unreferenced
|
2015-10-17 09:58:26 -07:00
|
|
|
.loop
|
2013-08-29 16:10:06 -07:00
|
|
|
call DelayFrame
|
|
|
|
|
|
|
|
push bc
|
2015-10-17 09:58:26 -07:00
|
|
|
call JoyTextDelay
|
2013-08-29 16:10:06 -07:00
|
|
|
pop bc
|
|
|
|
|
2020-06-21 15:33:31 -07:00
|
|
|
; Save data can be deleted by pressing Up + B + Select.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyDown]
|
2013-09-07 20:49:20 -07:00
|
|
|
cp D_UP | SELECT | B_BUTTON
|
2015-10-17 09:58:26 -07:00
|
|
|
jr z, .keycombo
|
2013-08-29 16:10:06 -07:00
|
|
|
|
2020-06-21 15:33:31 -07:00
|
|
|
; Press Start or A to start the game.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyLast]
|
2013-09-07 20:49:20 -07:00
|
|
|
and START | A_BUTTON
|
2015-10-17 09:58:26 -07:00
|
|
|
jr nz, .keycombo
|
2013-08-29 16:10:06 -07:00
|
|
|
|
|
|
|
dec c
|
2015-10-17 09:58:26 -07:00
|
|
|
jr nz, .loop
|
2013-08-29 16:10:06 -07:00
|
|
|
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
2015-10-17 09:58:26 -07:00
|
|
|
.keycombo
|
2013-08-29 16:10:06 -07:00
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
JoyWaitAorB::
|
2015-10-17 09:58:26 -07:00
|
|
|
.loop
|
2013-08-29 16:10:06 -07:00
|
|
|
call DelayFrame
|
2013-12-22 14:30:35 -08:00
|
|
|
call GetJoypad
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyPressed]
|
2013-09-07 20:49:20 -07:00
|
|
|
and A_BUTTON | B_BUTTON
|
2013-08-29 16:10:06 -07:00
|
|
|
ret nz
|
2020-02-19 10:08:40 -08:00
|
|
|
call UpdateTimeAndPals
|
2015-10-17 09:58:26 -07:00
|
|
|
jr .loop
|
2013-08-29 16:10:06 -07:00
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WaitButton::
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hOAMUpdate]
|
2013-08-29 16:10:06 -07:00
|
|
|
push af
|
|
|
|
ld a, 1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2013-08-29 16:10:06 -07:00
|
|
|
call WaitBGMap
|
2015-10-17 09:58:26 -07:00
|
|
|
call JoyWaitAorB
|
2013-08-29 16:10:06 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
JoyTextDelay::
|
2013-12-22 14:30:35 -08:00
|
|
|
call GetJoypad
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hInMenu]
|
2013-08-29 16:10:06 -07:00
|
|
|
and a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyPressed]
|
2015-10-16 10:35:43 -07:00
|
|
|
jr z, .ok
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyDown]
|
2015-10-16 10:35:43 -07:00
|
|
|
.ok
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyLast], a
|
|
|
|
ldh a, [hJoyPressed]
|
2013-08-29 16:10:06 -07:00
|
|
|
and a
|
2015-10-16 10:35:43 -07:00
|
|
|
jr z, .checkframedelay
|
2013-08-29 16:10:06 -07:00
|
|
|
ld a, 15
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTextDelayFrames], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2015-10-16 10:35:43 -07:00
|
|
|
.checkframedelay
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wTextDelayFrames]
|
2013-08-29 16:10:06 -07:00
|
|
|
and a
|
2015-10-16 10:35:43 -07:00
|
|
|
jr z, .restartframedelay
|
2013-08-29 16:10:06 -07:00
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hJoyLast], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2015-10-16 10:35:43 -07:00
|
|
|
.restartframedelay
|
2013-08-29 16:10:06 -07:00
|
|
|
ld a, 5
|
2018-01-23 14:39:09 -08:00
|
|
|
ld [wTextDelayFrames], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
WaitPressAorB_BlinkCursor::
|
2019-11-03 12:55:32 -08:00
|
|
|
; Show a blinking cursor in the lower right-hand
|
|
|
|
; corner of a textbox and wait until A or B is
|
|
|
|
; pressed.
|
|
|
|
;
|
|
|
|
; NOTE: The cursor has to be shown before calling
|
|
|
|
; this function or no cursor will be shown at all.
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
2013-08-29 16:10:06 -07:00
|
|
|
push af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hObjectStructIndexBuffer]
|
2013-08-29 16:10:06 -07:00
|
|
|
push af
|
|
|
|
xor a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, 6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hObjectStructIndexBuffer], a
|
2015-10-19 07:23:58 -07:00
|
|
|
|
|
|
|
.loop
|
2013-08-29 16:10:06 -07:00
|
|
|
push hl
|
2015-02-10 15:14:41 -08:00
|
|
|
hlcoord 18, 17
|
2015-11-10 20:23:28 -08:00
|
|
|
call BlinkCursor
|
2013-08-29 16:10:06 -07:00
|
|
|
pop hl
|
2015-10-19 07:23:58 -07:00
|
|
|
|
2015-10-17 09:58:26 -07:00
|
|
|
call JoyTextDelay
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyLast]
|
2015-10-19 07:23:58 -07:00
|
|
|
and A_BUTTON | B_BUTTON
|
|
|
|
jr z, .loop
|
|
|
|
|
2013-08-29 16:10:06 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hObjectStructIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
SimpleWaitPressAorB::
|
2015-10-19 07:23:58 -07:00
|
|
|
.loop
|
2015-10-17 09:58:26 -07:00
|
|
|
call JoyTextDelay
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyLast]
|
2013-09-07 20:49:20 -07:00
|
|
|
and A_BUTTON | B_BUTTON
|
2015-10-19 07:23:58 -07:00
|
|
|
jr z, .loop
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2019-11-03 09:48:54 -08:00
|
|
|
PromptButton::
|
2019-11-03 12:55:32 -08:00
|
|
|
; Show a blinking cursor in the lower right-hand
|
|
|
|
; corner of a textbox and wait until A or B is
|
|
|
|
; pressed, afterwards, play a sound.
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, [wLinkMode]
|
2013-08-29 16:10:06 -07:00
|
|
|
and a
|
2015-10-19 07:23:58 -07:00
|
|
|
jr nz, .link
|
|
|
|
call .wait_input
|
2013-08-29 16:10:06 -07:00
|
|
|
push de
|
|
|
|
ld de, SFX_READ_TEXT_2
|
2013-10-08 10:10:36 -07:00
|
|
|
call PlaySFX
|
2013-08-29 16:10:06 -07:00
|
|
|
pop de
|
|
|
|
ret
|
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
.link
|
2013-08-29 16:10:06 -07:00
|
|
|
ld c, 65
|
|
|
|
jp DelayFrames
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.wait_input
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hOAMUpdate]
|
2013-08-29 16:10:06 -07:00
|
|
|
push af
|
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2018-01-23 14:39:09 -08:00
|
|
|
ld a, [wInputType]
|
2013-08-29 16:10:06 -07:00
|
|
|
or a
|
2015-10-19 07:23:58 -07:00
|
|
|
jr z, .input_wait_loop
|
2017-12-24 09:47:30 -08:00
|
|
|
farcall _DudeAutoInput_A
|
2015-10-19 07:23:58 -07:00
|
|
|
|
|
|
|
.input_wait_loop
|
|
|
|
call .blink_cursor
|
2015-10-17 09:58:26 -07:00
|
|
|
call JoyTextDelay
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hJoyPressed]
|
2015-10-19 07:23:58 -07:00
|
|
|
and A_BUTTON | B_BUTTON
|
|
|
|
jr nz, .received_input
|
2020-02-19 10:08:40 -08:00
|
|
|
call UpdateTimeAndPals
|
2013-08-29 16:10:06 -07:00
|
|
|
ld a, $1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hBGMapMode], a
|
2013-08-29 16:10:06 -07:00
|
|
|
call DelayFrame
|
2015-10-19 07:23:58 -07:00
|
|
|
jr .input_wait_loop
|
2013-08-29 16:10:06 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
.received_input
|
2013-08-29 16:10:06 -07:00
|
|
|
pop af
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hOAMUpdate], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.blink_cursor
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hVBlankCounter]
|
2015-10-19 07:23:58 -07:00
|
|
|
and %00010000 ; bit 4, a
|
|
|
|
jr z, .cursor_off
|
|
|
|
ld a, "▼"
|
|
|
|
jr .load_cursor_state
|
2013-08-29 16:10:06 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
.cursor_off
|
2017-12-29 14:07:21 -08:00
|
|
|
lda_coord 17, 17
|
2013-08-29 16:10:06 -07:00
|
|
|
|
2015-10-19 07:23:58 -07:00
|
|
|
.load_cursor_state
|
2017-12-29 14:07:21 -08:00
|
|
|
ldcoord_a 18, 17
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
BlinkCursor::
|
2013-08-29 16:10:06 -07:00
|
|
|
push bc
|
|
|
|
ld a, [hl]
|
|
|
|
ld b, a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, "▼"
|
2013-08-29 16:10:06 -07:00
|
|
|
cp b
|
|
|
|
pop bc
|
2015-11-10 20:23:28 -08:00
|
|
|
jr nz, .place_arrow
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
2013-08-29 16:10:06 -07:00
|
|
|
dec a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret nz
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hObjectStructIndexBuffer]
|
2013-08-29 16:10:06 -07:00
|
|
|
dec a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hObjectStructIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret nz
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, "─"
|
2013-08-29 16:10:06 -07:00
|
|
|
ld [hl], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, -1
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2015-10-19 07:23:58 -07:00
|
|
|
ld a, 6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hObjectStructIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret
|
|
|
|
|
2015-11-10 20:23:28 -08:00
|
|
|
.place_arrow
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh a, [hMapObjectIndexBuffer]
|
2013-08-29 16:10:06 -07:00
|
|
|
and a
|
|
|
|
ret z
|
|
|
|
dec a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret nz
|
|
|
|
dec a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hMapObjectIndexBuffer], a
|
|
|
|
ldh a, [hObjectStructIndexBuffer]
|
2013-08-29 16:10:06 -07:00
|
|
|
dec a
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hObjectStructIndexBuffer], a
|
2013-08-29 16:10:06 -07:00
|
|
|
ret nz
|
2015-11-10 20:23:28 -08:00
|
|
|
ld a, 6
|
2018-08-25 11:28:22 -07:00
|
|
|
ldh [hObjectStructIndexBuffer], a
|
2015-11-10 20:23:28 -08:00
|
|
|
ld a, "▼"
|
2013-08-29 16:10:06 -07:00
|
|
|
ld [hl], a
|
|
|
|
ret
|