]> git.sur5r.net Git - cc65/blob - libsrc/c64/mcbdefault.s
Working on loadable mouse drivers
[cc65] / libsrc / c64 / mcbdefault.s
1 ;
2 ; Default mouse callbacks for the C64
3 ;
4 ; Ullrich von Bassewitz, 2004-03-20
5 ;
6
7         .export         _mouse_def_callbacks
8
9         .include        "mouse-kernel.inc"
10         .include        "c64.inc"
11
12
13 ; Sprite definitions. The first value can be changed to adjust the number
14 ; of the sprite used for the mouse.
15 MOUSE_SPR       = 0                             ; Sprite used for the mouse
16 MOUSE_SPR_MASK  = $01 .shl MOUSE_SPR            ; Positive mask
17 MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK)  ; Negative mask
18 VIC_SPR_X       = (VIC_SPR0_X + 2*MOUSE_SPR)    ; Sprite X register
19 VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
20
21
22 .code
23
24 ; --------------------------------------------------------------------------
25 ; Hide the mouse pointer
26
27 .proc   hide
28
29         lda     #MOUSE_SPR_NMASK
30         sei
31         and     VIC_SPR_ENA
32         sta     VIC_SPR_ENA
33         cli
34         rts
35
36 .endproc
37
38 ; --------------------------------------------------------------------------
39 ; Show the mouse pointer
40
41 .proc   show
42
43         lda     #MOUSE_SPR_MASK
44         sei
45         ora     VIC_SPR_ENA
46         sta     VIC_SPR_ENA
47         cli
48         rts
49
50 .endproc
51
52 ; --------------------------------------------------------------------------
53 ; Move the mouse pointer X position to the value in a/x
54
55 .proc   movex
56
57 ; Set the low byte, this frees A
58
59         sta     VIC_SPR_X
60
61 ; Set the high byte
62
63         txa                             ; Test high byte of X coord
64         bne     @L1
65         sei
66         lda     VIC_SPR_HI_X            ; Get high X bits of all sprites
67         and     #MOUSE_SPR_NMASK        ; Clear high bit for sprite
68         sta     VIC_SPR_HI_X
69         cli
70         rts
71
72 @L1:    sei
73         lda     VIC_SPR_HI_X            ; Get high X bits of all sprites
74         ora     #MOUSE_SPR_NMASK        ; Set high bit for sprite
75         sta     VIC_SPR_HI_X
76         cli
77         rts
78
79 .endproc
80
81 ; --------------------------------------------------------------------------
82 ; Move the mouse pointer Y position to the value in a/x
83
84 .proc   movey
85
86         sta     VIC_SPR_Y               ; Set Y position
87         rts
88
89 .endproc
90
91 ; --------------------------------------------------------------------------
92 ; Callback structure
93
94 .rodata
95
96 _mouse_def_callbacks:
97         .addr   hide
98         .addr   show
99         .addr   movex
100         .addr   movey
101
102
103