Skeetendo

’Cause all games were better on the GBC

You are not logged in.

  • Index
  • → Help/Question
  • → [pokecrystal] Holding down an arrow key does not continuously apply it

#1 2017-08-01 06:07:28

Rangi
Member
Registered: 2016-05-09
Post 778/870

[pokecrystal] Holding down an arrow key does not continuously apply it

I'm redesigning the UI for this music player, adapted from the one by Sanqui for Crystal Complete.

LH968I1.png

There are a few different input modes, each with a main loop roughly like this:

jrbutton: MACRO
    ld a, [hJoyPressed]
    and \1
    jr nz, \2
    ENDM

MainLoop:
    call DelayFrame

    ; ...redraw some tiles here...

    call GetJoypad

    jrbutton D_LEFT, .left
    jrbutton D_RIGHT, .right
    jrbutton D_DOWN, .down
    jrbutton D_UP, .up
    jrbutton A_BUTTON, .a
    jrbutton B_BUTTON, .b
    jrbutton START, .start
    jpbutton SELECT, .select

    ; prioritize refreshing the note display
    ld a, 2
    ld [hBGMapThird], a
    jr MainLoop

The button-handling subroutines .left, .right, etc, do not write to [hJoyPressed].

The problem: I want the song list (the right screenshot) to continuously scroll when I hold Up or Down. I've looked at the standard menu code for pokecrystal, comparing the non-continuous Start menu and the continuous item menus, but can't figure out how to allow this. Any help, please?

(If anyone wants to compile the project—with rgbds 0.3.1—and give me feedback on the UI usability before I write documentation for it, that would be great too. It's a challenge fitting features into eight buttons and 160x144 pixels.)

Last edited by Rangi (2017-08-01 06:11:06)


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#2 2017-08-02 22:33:16

Rangi
Member
Registered: 2016-05-09
Post 779/870

Re: [pokecrystal] Holding down an arrow key does not continuously apply it

I solved this! Just had to read from hJoypadDown instead of hJoypadPressed. This comment in home/joypad.asm explained it:

; hJoypadReleased: released this frame (delta)
; hJoypadPressed: pressed this frame (delta)
; hJoypadDown: currently pressed
; hJoypadSum: pressed so far

I also had to add a short delay before allowing another button event, since otherwise it would scroll too fast.

Here's the commit that implements continuous scrolling.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

  • Index
  • → Help/Question
  • → [pokecrystal] Holding down an arrow key does not continuously apply it

Board footer

Powered by FluxBB