]> git.sur5r.net Git - cc65/blob - libsrc/geos/mousesprite/mouse.s
added dio interface, standard mouse and joystick functions, osmaperrno
[cc65] / libsrc / geos / mousesprite / mouse.s
1 ;
2 ; Maciej 'YTM/Elysium' Witkowiak
3 ;
4 ; 2.7.2001
5 ;
6 ; Wrapper for GEOS standard input device interface
7 ;
8
9         .export         _mouse_init, _mouse_done
10         .export         _mouse_hide, _mouse_show
11         .export         _mouse_box, _mouse_info
12         .export         _mouse_x, _mouse_y
13         .export         _mouse_move, _mouse_buttons
14                                                    
15         .import         popax, popsreg, addysp1
16         .importzp       sp, sreg
17
18         .include "../inc/const.inc"
19         .include "../inc/jumptab.inc"
20         .include "../inc/geossym.inc"
21
22 ;       .macpack        generic
23
24 .code
25
26 ; --------------------------------------------------------------------------
27 ;
28 ; unsigned char __fastcall__ mouse_init (unsigned char port,
29 ;                                        unsigned char sprite,
30 ;                                        unsigned char type);
31 ;
32
33 _mouse_init:
34         jsr     popax                   ; ignore all parameters
35
36         jsr     StartMouseMode
37         jsr     MouseOff
38
39         lda     #0
40         sta     mouseTop
41         sta     mouseLeft
42         sta     mouseLeft+1
43         lda     #199
44         sta     mouseBottom
45         lda     #<319
46         sta     mouseRight
47         lda     #>319
48         sta     mouseRight+1
49
50         lda     #0
51 ; --------------------------------------------------------------------------
52 ;
53 ; void mouse_done (void);
54 ;
55 _mouse_done:
56         rts
57
58 ; --------------------------------------------------------------------------
59 ;
60 ; void mouse_hide (void);
61 ;
62
63 _mouse_hide = MouseOff
64
65 ; --------------------------------------------------------------------------
66 ;
67 ; void mouse_show (void);
68 ;
69
70 _mouse_show = MouseUp
71
72 ; --------------------------------------------------------------------------
73 ;
74 ; void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
75 ;
76
77 _mouse_box:
78         ldy     #0                      ; Stack offset
79
80         sta     mouseBottom
81 ;       stx     YMax+1                  ; maxy
82
83         lda     (sp),y
84         sta     mouseRight
85         iny
86         lda     (sp),y
87         sta     mouseRight+1            ; maxx
88
89         iny
90         lda     (sp),y
91         sta     mouseTop
92         iny
93 ;       lda     (sp),y
94 ;       sta     YMin+1                  ; miny
95
96         iny
97         lda     (sp),y
98         sta     mouseLeft
99         iny
100         lda     (sp),y
101         sta     mouseLeft+1             ; minx
102
103         jmp     addysp1                 ; Drop params, return
104
105 ; --------------------------------------------------------------------------
106 ;
107 ; int __fastcall__ mouse_x (void);
108 ;
109
110 _mouse_x:
111         lda     mouseXPos
112         ldx     mouseXPos+1
113         rts
114
115 ; --------------------------------------------------------------------------
116 ;
117 ; int __fastcall__ mouse_y (void);
118 ;
119
120 _mouse_y:
121         lda     mouseYPos
122         ldx     #0
123         rts
124
125 ; --------------------------------------------------------------------------
126 ;
127 ; void mouse_info (...);
128 ;
129
130 _mouse_info:
131         rts
132
133
134 ; --------------------------------------------------------------------------
135 ;
136 ; void __fastcall__ mouse_move (int x, int y);
137 ;
138
139 _mouse_move:
140         jsr     popsreg                 ; Get X
141         sei                             ; Disable interrupts
142
143         sta     mouseYPos
144 ;       stx     YPos+1
145         lda     sreg
146         ldx     sreg+1
147         sta     mouseXPos
148         stx     mouseXPos+1
149         rts
150
151 ; --------------------------------------------------------------------------
152 ;
153 ; unsigned char mouse_buttons (void);
154 ;
155
156 _mouse_buttons:
157         lda     pressFlag
158         and     #SET_MOUSE
159         lsr
160         rts