cscg22-gearboy

CSCG 2022 Challenge 'Gearboy'
git clone https://git.sinitax.com/sinitax/cscg22-gearboy
Log | Files | Refs | sfeed.txt

pad.s (873B)


      1        .include        "global.s"
      2
      3        .title  "JOYPad utilities"
      4        .module JOYPad
      5        .area   _HOME
      6
      7	;; Get Keypad Button Status
      8_joypad::
      9.jpad::
     10        in a, (.JOY_PORT1)
     11        cpl
     12        and #0b00111111
     13        ld l, a
     14        in a, (.GG_STATE)
     15        cpl
     16        and #.GGSTATE_STT
     17        or l
     18        ld l, a
     19        ret
     20
     21	;; Wait until all buttons have been released
     22.padup::
     23_waitpadup::
     241$:
     25        ld h,#0x7f      ; wait for .jpad return zero 127 times in a row
     262$:
     27        call .jpad
     28        or a            ; have all buttons been released?
     29        jr nz,1$        ; not yet
     30
     31        dec h
     32        jr nz,2$
     33        
     34        ret
     35
     36        ;; Wait for the key to be pressed
     37_waitpad::
     38.wait_pad::
     391$:
     40        call .jpad      ; read pad
     41        and l           ; compare with mask?
     42        jr z,1$         ; loop if no intersection
     43        ret