]> git.sur5r.net Git - cc65/blob - libsrc/geos-common/drivers/geos-stdmou.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / geos-common / drivers / geos-stdmou.s
1 ;
2 ; Maciej 'YTM/Elysium' Witkowiak
3 ;
4 ; 2.7.2001
5 ;
6 ; Driver for GEOS standard input device interface
7 ;
8                                          
9             .export _mouse_init, _mouse_done
10             .export _mouse_hide, _mouse_show
11             .export _mouse_box
12             .export _mouse_pos, _mouse_info
13             .export _mouse_move, _mouse_buttons
14
15             .import popsreg, addysp1
16             .importzp sp, sreg, ptr1
17
18             .include "const.inc"
19             .include "jumptab.inc"
20             .include "geossym.inc"
21
22 ; --------------------------------------------------------------------------
23 ;
24 ; unsigned char __fastcall__ mouse_init (unsigned char type);
25 ;
26
27 _mouse_init:
28         jsr StartMouseMode
29         jsr MouseOff
30
31         lda #0
32         sta mouseTop
33         sta mouseLeft
34         sta mouseLeft+1
35 .ifdef __GEOS_CBM__
36         lda #199
37         sta mouseBottom
38         lda graphMode
39         bpl _mse_screen320
40
41         lda #<639               ; 80 columns on C128
42         ldx #>639
43         bne _mse_storex
44 _mse_screen320:
45         lda #<319               ; 40 columns on C64/C128
46         ldx #>319
47 _mse_storex:
48 .else
49         lda #191
50         sta mouseBottom
51         lda #<559
52         ldx #>559
53 .endif
54         sta mouseRight
55         stx mouseRight+1
56 _mse_initend:
57         lda #0
58         tax
59 ; --------------------------------------------------------------------------
60 ;
61 ; void mouse_done (void);
62 ;
63 _mouse_done:
64         rts
65
66 ; --------------------------------------------------------------------------
67 ;
68 ; void mouse_hide (void);
69 ;
70
71 _mouse_hide     = MouseOff
72
73 ; --------------------------------------------------------------------------
74 ;
75 ; void mouse_show (void);
76 ;
77
78 _mouse_show     = MouseUp
79
80 ; --------------------------------------------------------------------------
81 ;
82 ; void __fastcall__ mouse_box (int minx, int miny, int maxx, int maxy);
83 ;
84
85 _mouse_box:
86         ldy #0                  ; Stack offset
87
88         sta mouseBottom
89
90         lda (sp),y
91         sta mouseRight
92         iny
93         lda (sp),y
94         sta mouseRight+1        ; maxx
95
96         iny
97         lda (sp),y
98         sta mouseTop
99         iny                     ; Skip high byte
100
101         iny
102         lda (sp),y
103         sta mouseLeft
104         iny
105         lda (sp),y
106         sta mouseLeft+1         ; minx
107
108         jmp addysp1             ; Drop params, return
109
110 ; --------------------------------------------------------------------------
111 ;
112 ; void __fastcall__ mouse_pos (struct mouse_pos* pos);
113 ; /* Return the current mouse position */
114 ;
115
116 _mouse_pos:
117         sta ptr1
118         stx ptr1+1              ; Remember the argument pointer
119
120         ldy #0                  ; Structure offset
121
122         php
123         sei                     ; Disable interrupts
124
125         lda mouseXPos           ; Transfer the position
126         sta (ptr1),y
127         lda mouseXPos+1
128         iny
129         sta (ptr1),y
130         lda mouseYPos
131         iny
132         sta (ptr1),y
133         lda #$00
134         iny
135         sta (ptr1),y
136
137         plp                     ; Reenable interrupts
138         rts                     ; Done
139
140 ; --------------------------------------------------------------------------
141 ;
142 ; void __fastcall__ mouse_info (struct mouse_info* info);
143 ; /* Return the state of the mouse buttons and the position of the mouse */
144 ;
145
146 _mouse_info:
147
148 ; We're cheating here to keep the code smaller: The first fields of the
149 ; mouse_info struct are identical to the mouse_pos struct, so we will just
150 ; call _mouse_pos to initialize the struct pointer and fill the position
151 ; fields.
152
153         jsr _mouse_pos
154
155 ; Fill in the button state
156
157         jsr _mouse_buttons      ; Will not touch ptr1
158         iny
159         sta (ptr1),y
160
161         rts
162
163 ; --------------------------------------------------------------------------
164 ;
165 ; void __fastcall__ mouse_move (int x, int y);
166 ;
167
168 _mouse_move:
169         jsr popsreg             ; Get X
170         php
171         sei                     ; Disable interrupts
172         sta mouseYPos
173         lda sreg
174         ldx sreg+1
175         sta mouseXPos
176         stx mouseXPos+1
177         plp                     ; Enable interrupts
178         rts
179
180 ; --------------------------------------------------------------------------
181 ;
182 ; unsigned char mouse_buttons (void);
183 ;
184
185 _mouse_buttons:
186         ldx #0
187         lda pressFlag
188         and #SET_MOUSE
189         lsr
190         rts