]> git.sur5r.net Git - cc65/blob - libsrc/c64/mcbdefault.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / c64 / mcbdefault.s
1 ;
2 ; Default mouse callbacks for the C64
3 ;
4 ; Ullrich von Bassewitz, 2004-03-20
5 ;
6 ; All functions in this module should be interrupt safe, because they may
7 ; be called from an interrupt handler
8 ;
9
10         .export         _mouse_def_callbacks
11
12         .include        "mouse-kernel.inc"
13         .include        "c64.inc"
14
15         .macpack        generic
16
17 ; Sprite definitions. The first value can be changed to adjust the number
18 ; of the sprite used for the mouse. All others depend on this value.
19 MOUSE_SPR       = 0                             ; Sprite used for the mouse
20 MOUSE_SPR_MASK  = $01 .shl MOUSE_SPR            ; Positive mask
21 MOUSE_SPR_NMASK = .lobyte(.not MOUSE_SPR_MASK)  ; Negative mask
22 VIC_SPR_X       = (VIC_SPR0_X + 2*MOUSE_SPR)    ; Sprite X register
23 VIC_SPR_Y       = (VIC_SPR0_Y + 2*MOUSE_SPR)    ; Sprite Y register
24
25 .code
26
27 ; --------------------------------------------------------------------------
28 ; Hide the mouse pointer. Always called with interrupts disabled.
29
30 .proc   hide
31
32         lda     #MOUSE_SPR_NMASK
33         and     VIC_SPR_ENA
34         sta     VIC_SPR_ENA
35         rts
36
37 .endproc
38
39 ; --------------------------------------------------------------------------
40 ; Show the mouse pointer. Always called with interrupts disabled.
41
42 .proc   show
43
44         lda     #MOUSE_SPR_MASK
45         ora     VIC_SPR_ENA
46         sta     VIC_SPR_ENA
47         rts
48
49 .endproc
50
51 ; --------------------------------------------------------------------------
52 ; Move the mouse pointer X position to the value in a/x. Always called with
53 ; interrupts disabled.
54
55 .proc   movex
56
57 ; Add the X correction and set the low byte. This frees A.
58
59         add     #24                     ; X correction
60         sta     VIC_SPR_X
61
62 ; Set the high byte
63
64         txa
65         adc     #0
66         bne     @L1                     ; Branch if high byte not zero
67         lda     VIC_SPR_HI_X            ; Get high X bits of all sprites
68         and     #MOUSE_SPR_NMASK        ; Clear high bit for sprite
69         sta     VIC_SPR_HI_X
70         rts
71
72 @L1:    lda     VIC_SPR_HI_X            ; Get high X bits of all sprites
73         ora     #MOUSE_SPR_MASK         ; Set high bit for sprite
74         sta     VIC_SPR_HI_X
75         rts
76
77 .endproc
78
79 ; --------------------------------------------------------------------------
80 ; Move the mouse pointer Y position to the value in a/x. Always called with
81 ; interrupts disabled.
82
83 .proc   movey
84
85         add     #50                     ; Y correction (first visible line)
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