1
0
mirror of https://github.com/cc65/cc65.git synced 2025-02-26 07:29:25 +00:00

fixed & adapted for cc65

git-svn-id: svn://svn.cc65.org/cc65/trunk@442 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cpg 2000-11-17 01:24:38 +00:00
parent 2326ca6274
commit 6eef1c5d9a

View File

@ -1,5 +1,6 @@
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Atari 8-bit mouse routines -- 05/07/2000 Freddy Offenga ; Atari 8-bit mouse routines -- 05/07/2000 Freddy Offenga
; Some changes by Christian Groessler
; ;
; The following devices are supported: ; The following devices are supported:
; - Atari trak-ball ; - Atari trak-ball
@ -12,9 +13,9 @@
.export _mouse_init, _mouse_done, _mouse_box .export _mouse_init, _mouse_done, _mouse_box
.export _mouse_show, _mouse_hide, _mouse_move .export _mouse_show, _mouse_hide, _mouse_move
.export _mouse_down .export _mouse_buttons
.import popa .import popa,popax
.include "atari.inc" .include "atari.inc"
@ -23,13 +24,13 @@ ST_MOUSE = 1 ; device ST mouse
AMIGA_MOUSE = 2 ; device Amiga mouse AMIGA_MOUSE = 2 ; device Amiga mouse
MAX_TYPE = 3 ; first illegal device type MAX_TYPE = 3 ; first illegal device type
; the default values force the mouse cursor inside the test screen (no access to border)
defxmin = 48 ; default x minimum defxmin = 48 ; default x minimum
defymin = 32 ; default y minimum defymin = 32 ; default y minimum
defxmax = 204 ; default x maximum defxmax = 204 ; default x maximum
defymax = 211 ; default y maximum defymax = 211 ; default y maximum
pmsize = 16 ; size pm shape pmsize = 16 ; y size pm shape
xinit = 100 ; init. x pos. xinit = 100 ; init. x pos.
yinit = 100 ; init. y pos. yinit = 100 ; init. y pos.
@ -39,19 +40,16 @@ pm0 = pmb+$400 ; pm 0 memory
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Initialize mouse routines ; Initialize mouse routines
; int mouse_init(unsigned char type, unsigned char port) ; void __fastcall__ mouse_init (unsigned char port, unsigned char sprite, unsigned char type);
_mouse_init: _mouse_init:
ldy #0 pha ; remember mouse type
sta (SAVMSC),y jsr popa ; ignore sprite / pm for now
sta port_nr
jsr popa jsr popa
ldy #1 sta port_nr
sta (SAVMSC),y pla ; get mouse type again
sta mouse_type
ldx mouse_type cmp #MAX_TYPE+1
cpx #MAX_TYPE
bcc setup bcc setup
ifail: ifail:
@ -60,26 +58,12 @@ ifail:
rts rts
setup: setup:
tax
lda lvectab,x lda lvectab,x
sta mouse_vec+1 sta mouse_vec+1
lda hvectab,x lda hvectab,x
sta mouse_vec+2 sta mouse_vec+2
lda #defxmin
sta xmin
lda #defymin
sta ymin
lda #defxmax
sta xmax
lda #defymax
sta ymax
lda #xinit
sta mousex
lda #yinit
sta mousey
jsr pminit jsr pminit
lda VTIMR1 lda VTIMR1
@ -160,25 +144,25 @@ _mouse_done:
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Set mouse limits ; Set mouse limits
; void mouse_box(char xmin, char ymin, char xmax, char ymax) ; void __fastcall__ mouse_box(int xmin, int ymin, int xmax, int ymax)
_mouse_box: _mouse_box:
sta ymax sta ymax
jsr popa jsr popax ; always ignore high byte
sta xmax sta xmax
jsr popa jsr popax
sta ymin sta ymin
jsr popa jsr popax
sta xmin sta xmin
rts rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Set mouse position ; Set mouse position
; void mouse_move(char xpos, char ypos) ; void __fastcall__ mouse_move(int xpos, int ypos)
_mouse_move: _mouse_move:
sta mousey sta mousey ; always ignore high byte
jsr popa jsr popax
sta mousex sta mousex
rts rts
@ -202,14 +186,14 @@ _mouse_hide:
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Ask mouse button ; Ask mouse button
; int mouse_down(void) ; unsigned char mouse_buttons(void)
_mouse_down: _mouse_buttons:
ldx port_nr ldx port_nr
lda STRIG0,x lda STRIG0,x
bne nobut bne nobut
lda #14 ; lda #14
sta COLOR1 ;??? sta COLOR1
ldx #0 ldx #0
lda #1 lda #1
rts rts
@ -341,17 +325,19 @@ t1_vec: tya
txa txa
pha pha
.ifdef DEBUG
lda RANDOM lda RANDOM
sta COLBK ; debug sta COLBK ; debug
.endif
lda port_nr lda port_nr
lsr ; even number 0/2 lsr ; even number 0/2
tay tay
lda PORTA,y lda PORTA,y
ldy port_nr ldy port_nr
cpy #1 cpy #0
beq oddp beq oddp
cpy #3 cpy #2
beq oddp beq oddp
lsr lsr
@ -361,7 +347,7 @@ t1_vec: tya
oddp: tay oddp: tay
mouse_vec: mouse_vec:
jsr st_check ; will be modified jsr st_check ; will be modified; won't be ROMmable
pla pla
tax tax
@ -413,7 +399,7 @@ mon: jsr drwpm
moff: sta GRACTL moff: sta GRACTL
vbi_jmp: vbi_jmp:
jmp SYSVBV ; will be modified jmp SYSVBV ; will be modified; won't be ROMmable
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; initialize mouse pm ; initialize mouse pm
@ -472,8 +458,7 @@ fmp1: sta pm0,x
rts rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
.rodata
.data
; mouse arrow - pm shape ; mouse arrow - pm shape
@ -518,30 +503,28 @@ lvectab:
hvectab: hvectab:
.byte >trak_check, >st_check, >amiga_check .byte >trak_check, >st_check, >amiga_check
; default values
xmin: .byte defxmin
ymin: .byte defymin
xmax: .byte defxmax
ymax: .byte defymax
mousex: .byte xinit
mousey: .byte yinit
;--------------------------------------------------------------------
.bss
; Misc. vars ; Misc. vars
old_t1: .res 2 old_t1: .res 2 ; old timer interrupt vector
oldval: .res 1 ; used by trakball routines
dumx: .res 1 dumx: .res 1
dumy: .res 1 dumy: .res 1
oldval: .res 1 omy: .res 1 ; old y pos
omy: .res 1
mousex: .res 1
mousey: .res 1
xmin: .res 1
ymin: .res 1
xmax: .res 1
ymax: .res 1
mouse_on: mouse_on:
.res 1 .res 1
mouse_type:
.res 1
port_nr: port_nr:
.res 1 .res 1