]> git.sur5r.net Git - cc65/blob - libsrc/gamate/joy/gamate-stdjoy.s
Merge branch 'master' into kbrepeat
[cc65] / libsrc / gamate / joy / gamate-stdjoy.s
1
2 ;
3 ; Standard joystick driver for the Gamate
4 ;
5
6         .include        "joy-kernel.inc"
7         .include        "joy-error.inc"
8         .include        "gamate.inc"
9
10         .macpack        module
11
12
13 ; ------------------------------------------------------------------------
14 ; Header. Includes jump table
15
16         module_header   _gamate_stdjoy_joy
17
18 ; Driver signature
19
20         .byte   $6A, $6F, $79           ; "joy"
21         .byte   JOY_API_VERSION         ; Driver API version number
22
23 ; Library reference
24
25         .addr   $0000
26
27 ; Button state masks (8 values)
28
29         .byte   $01                     ; JOY_UP
30         .byte   $02                     ; JOY_DOWN
31         .byte   $04                     ; JOY_LEFT
32         .byte   $08                     ; JOY_RIGHT
33         .byte   $10                     ; JOY_FIRE_A
34         .byte   $20                     ; JOY_FIRE_B
35         .byte   $80                     ; JOY_SELECT
36         .byte   $40                     ; JOY_START
37
38 ; Jump table.
39
40         .addr   INSTALL
41         .addr   UNINSTALL
42         .addr   COUNT
43         .addr   READJOY
44         .addr   0                       ; IRQ entry unused
45
46 ; ------------------------------------------------------------------------
47 ; Constants
48
49 JOY_COUNT       = 1             ; Number of joysticks we support
50
51
52 .code
53
54 ; ------------------------------------------------------------------------
55 ; INSTALL routine. Is called after the driver is loaded into memory. If
56 ; possible, check if the hardware is present and determine the amount of
57 ; memory available.
58 ; Must return an JOY_ERR_xx code in a/x.
59 ;
60
61 INSTALL:
62         lda     #<JOY_ERR_OK
63         ldx     #>JOY_ERR_OK
64
65 ;        rts                     ; Run into UNINSTALL instead
66
67 ; ------------------------------------------------------------------------
68 ; DEINSTALL routine. Is called before the driver is removed from memory.
69 ; Can do cleanup or whatever. Must not return anything.
70 ;
71
72 UNINSTALL:
73         rts
74
75
76 ; ------------------------------------------------------------------------
77 ; COUNT: Return the total number of available joysticks in a/x.
78 ;
79 ;unsigned char __fastcall__ joy_count (void);
80
81 COUNT:
82         lda     #<JOY_COUNT
83         ldx     #>JOY_COUNT
84         rts
85
86 ; ------------------------------------------------------------------------
87 ; READ: Read a particular joystick passed in A.
88 ;
89 ;unsigned char __fastcall__ joy_read (unsigned char joystick);
90
91 READJOY:
92         lda     JOY_DATA
93         ldx     #0
94         rts
95