1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-17 09:29: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
@ -13,10 +13,11 @@
.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"
@ -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,9 +193,10 @@ _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
@ -214,6 +215,48 @@ 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