cscg22-gearboy

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

pad.s (780B)


      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        ret
     15
     16	;; Wait until all buttons have been released
     17.padup::
     18_waitpadup::
     191$:
     20        ld h,#0x7f      ; wait for .jpad return zero 127 times in a row
     212$:
     22        call .jpad
     23        or a            ; have all buttons been released?
     24        jr nz,1$        ; not yet
     25
     26        dec h
     27        jr nz,2$
     28        
     29        ret
     30
     31        ;; Wait for the key to be pressed
     32_waitpad::
     33.wait_pad::
     341$:
     35        call .jpad      ; read pad
     36        and l           ; compare with mask?
     37        jr z,1$         ; loop if no intersection
     38        ret