1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-23 04:30:10 +00:00

Added mouse_pos(), mouse_info(). Changed mouse_hide() and mouse_show() to

use a counter instead of a flag.


git-svn-id: svn://svn.cc65.org/cc65/trunk@868 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-09-08 15:22:06 +00:00
parent 8b73812212
commit c501c18b95

View File

@ -1,6 +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 ; Some changes by Christian Groessler, Ullrich von Bassewitz
; ;
; The following devices are supported: ; The following devices are supported:
; - Atari trak-ball ; - Atari trak-ball
@ -11,12 +11,13 @@
; drawn in player 0 during the vertical blank ; drawn in player 0 during the vertical blank
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
.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_buttons .export _mouse_buttons, _mouse_pos, _mouse_info
.constructor initmouse,27 .constructor initmouse,27
.import popa,popax .import popa,popax
.importzp ptr1
.include "atari.inc" .include "atari.inc"
@ -51,7 +52,7 @@ initmouse:
sta APPMHI sta APPMHI
stx APPMHI+1 stx APPMHI+1
rts rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Initialize mouse routines ; Initialize mouse routines
@ -184,8 +185,7 @@ _mouse_move:
; void mouse_show(void) ; void mouse_show(void)
_mouse_show: _mouse_show:
lda #1 inc mouse_on
sta mouse_on
rts rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
@ -193,37 +193,80 @@ _mouse_show:
; void mouse_hide(void) ; void mouse_hide(void)
_mouse_hide: _mouse_hide:
lda #0 lda mouse_on
sta mouse_on beq @L1
rts dec mouse_on
@L1: rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Ask mouse button ; Ask mouse button
; unsigned char mouse_buttons(void) ; unsigned char mouse_buttons(void)
_mouse_buttons: _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
nobut: ldx #0 nobut: ldx #0
txa txa
rts rts
;--------------------------------------------------------------------
; Get the mouse position
; void mouse_pos (struct mouse_pos* pos);
_mouse_pos:
sta ptr1
stx ptr1+1 ; Store argument pointer
ldy #0
lda mousex ; X position
sta (ptr1),y
lda #0
iny
sta (ptr1),y
lda mousey ; Y position
iny
sta (ptr1),y
lda #0
iny
sta (ptr1),y
rts
;--------------------------------------------------------------------
; Get the mouse position and button information
; void mouse_info (struct mouse_info* info);
_mouse_info:
; We're cheating here to keep the code smaller: The first fields of the
; mouse_info struct are identical to the mouse_pos struct, so we will just
; call _mouse_pos to initialize the struct pointer and fill the position
; fields.
jsr _mouse_pos
; Fill in the button state
jsr _mouse_buttons ; Will not touch ptr1
ldy #4
sta (ptr1),y
rts
;-------------------------------------------------------------------- ;--------------------------------------------------------------------
; Atari trak-ball check, A,Y = 4-bit port value ; Atari trak-ball check, A,Y = 4-bit port value
trak_check: trak_check:
eor oldval eor oldval
and #%00001000 and #%00001000
beq horiz beq horiz
tya tya
and #%00000100 and #%00000100
beq mmup beq mmup
inc mousey inc mousey
@ -421,7 +464,7 @@ pminit: lda mouse_pm0
sta mpatch1+2 sta mpatch1+2
sta mpatch2+2 sta mpatch2+2
sta mpatch3+2 sta mpatch3+2
ldx #0 ldx #0
txa txa
mpatch1: mpatch1: