1 ;--------------------------------------------------------------------
2 ; Atari 8-bit mouse routines -- 05/07/2000 Freddy Offenga
4 ; The following devices are supported:
9 ; Mouse checks are done in the timer 1 IRQ and the mouse arrow is
10 ; drawn in player 0 during the vertical blank
11 ;--------------------------------------------------------------------
13 .export _mouse_init, _mouse_done, _mouse_box
14 .export _mouse_show, _mouse_hide, _mouse_move
21 TRAK_BALL = 0 ; device Atari trak-ball
22 ST_MOUSE = 1 ; device ST mouse
23 AMIGA_MOUSE = 2 ; device Amiga mouse
24 MAX_TYPE = 3 ; first illegal device type
26 defxmin = 48 ; default x minimum
27 defymin = 32 ; default y minimum
29 defxmax = 204 ; default x maximum
30 defymax = 211 ; default y maximum
32 pmsize = 16 ; size pm shape
34 xinit = 100 ; init. x pos.
35 yinit = 100 ; init. y pos.
37 pmb = $2800 ; pm base memory
38 pm0 = pmb+$400 ; pm 0 memory
40 ;--------------------------------------------------------------------
41 ; Initialize mouse routines
42 ; int mouse_init(unsigned char type, unsigned char port)
107 ora #%00000001 ; timer 1 enable
130 ;--------------------------------------------------------------------
131 ; Finish mouse routines
132 ; void mouse_done(void)
137 and #%11111110 ; timer 1 disable
161 ;--------------------------------------------------------------------
163 ; void mouse_box(char xmin, char ymin, char xmax, char ymax)
175 ;--------------------------------------------------------------------
177 ; void mouse_move(char xpos, char ypos)
185 ;--------------------------------------------------------------------
187 ; void mouse_show(void)
194 ;--------------------------------------------------------------------
196 ; void mouse_hide(void)
203 ;--------------------------------------------------------------------
205 ; int mouse_down(void)
220 ;--------------------------------------------------------------------
221 ; Atari trak-ball check, A,Y = 4-bit port value
254 ;--------------------------------------------------------------------
255 ; ST mouse check, A,Y = 4-bit port value
265 dec mousex ; 1 = left
267 xist: inc mousex ; 0 = right
279 yst: inc mousey ; 1 = down
295 ;--------------------------------------------------------------------
296 ; Amiga mouse check, A,Y = 4-bit port value
308 dec mousex ; 0 = left
310 xiami: inc mousex ; 1 = right
323 yiami: inc mousey ; 1 = down
336 ;--------------------------------------------------------------------
337 ; timer 1 IRQ routine - check mouse
348 lsr ; even number 0/2
364 jsr st_check ; will be modified
373 ;--------------------------------------------------------------------
374 ; VBI - check mouse limits and display mouse arrow
378 bcs ok1 ; xmin <= mousex
384 bcs ok2 ; ymin <= mousey
390 bcs ok3 ; xmax >= mousex
396 bcs ok4 ; ymax >= mousey
416 jmp SYSVBV ; will be modified
418 ;--------------------------------------------------------------------
419 ; initialize mouse pm
441 ;--------------------------------------------------------------------
459 ;--------------------------------------------------------------------
474 ;--------------------------------------------------------------------
478 ; mouse arrow - pm shape
480 mskpm: .byte %00000000
500 ; ST mouse lookup table
502 sttab: .byte $FF,$01,$00,$01
503 .byte $00,$FF,$00,$01
504 .byte $01,$00,$FF,$00
505 .byte $01,$00,$01,$FF
507 ; Amiga mouse lookup table
509 amitab: .byte $FF,$01,$00,$FF
510 .byte $00,$FF,$FF,$01
511 .byte $01,$FF,$FF,$00
512 .byte $FF,$00,$01,$FF
517 .byte <trak_check, <st_check, <amiga_check
519 .byte >trak_check, >st_check, >amiga_check