gbdk-2020 | GameBoy Development Kit |
| download: https://git.y1.nz/archives/gbdk.tar.gz | |
| README | Files | Log | Refs | LICENSE |
gbdk-lib/libc/targets/mos6502/pad_ex.s
1 .include "global.s"
2
3 MAX_JOYPADS = 4
4 .globl _read_joypad
5
6 .area GBDKOVR (PAG, OVR)
7 _joypad_init_PARM_2:: .ds 2
8
9 .area _HOME
10
11 _joypad_init::
12 ; Report at most MAX_JOYPADS number of joypads available
13 cmp #MAX_JOYPADS
14 bcc 1$
15 lda #MAX_JOYPADS
16 1$:
17 pha
18 tax
19 ldy #0
20 sta [*_joypad_init_PARM_2],y
21 iny
22 lda #0
23 _joypad_init_loop:
24 sta [*_joypad_init_PARM_2],y
25 iny
26 dex
27 bne _joypad_init_loop
28 pla
29 rts
30
31 _joypad_ex::
32 .joypad_ex::
33 .define .joypads_ptr "___SDCC_m6502_ret0"
34 .define .joypads_endof ".tmp"
35 sta *.joypads_ptr
36 stx *.joypads_ptr+1
37 ; endof = Number of joypads + 1
38 ldy #0
39 lda [*.joypads_ptr],y
40 iny
41 sta *.joypads_endof
42 inc *.joypads_endof
43 ;
44 jsr _strobe_joypads
45 .joypad_ex_loop:
46 lda .joypad_ex_lut,y
47 tax
48 jsr _read_joypad_no_strobe
49 sta [*.joypads_ptr],y
50 iny
51 cpy *.joypads_endof
52 bne .joypad_ex_loop
53 rts
54
55 ;
56 ; Look-up table for getting joypad port offset from offset into joypads_t (=joypad index + 1)
57 ;
58 .joypad_ex_lut:
59 .db 0
60 .db 0
61 .db 1
62 .db 0
63 .db 1
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.