Updated the mouse module
git-svn-id: svn://svn.cc65.org/cc65/trunk@440 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
8f6b114bb8
commit
df52e29196
1 changed files with 33 additions and 13 deletions
|
@ -9,8 +9,9 @@
|
||||||
.export _mouse_hide, _mouse_show
|
.export _mouse_hide, _mouse_show
|
||||||
.export _mouse_box, _mouse_info
|
.export _mouse_box, _mouse_info
|
||||||
.export _mouse_x, _mouse_y
|
.export _mouse_x, _mouse_y
|
||||||
.export _mouse_move
|
.export _mouse_move, _mouse_buttons
|
||||||
|
|
||||||
|
.import _readjoy
|
||||||
.import popa, popsreg, addysp1
|
.import popa, popsreg, addysp1
|
||||||
.importzp sp, sreg
|
.importzp sp, sreg
|
||||||
|
|
||||||
|
@ -22,7 +23,9 @@
|
||||||
|
|
||||||
; --------------------------------------------------------------------------
|
; --------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; void __fastcall__ mouse_init (unsigned char port, unsigned char sprite, unsigned char type);
|
; unsigned char __fastcall__ mouse_init (unsigned char port,
|
||||||
|
; unsigned char sprite,
|
||||||
|
; unsigned char type);
|
||||||
;
|
;
|
||||||
|
|
||||||
_mouse_init:
|
_mouse_init:
|
||||||
|
@ -31,7 +34,7 @@ _mouse_init:
|
||||||
jsr popa ; Get the port number
|
jsr popa ; Get the port number
|
||||||
|
|
||||||
ldy OldIRQ+1 ; Already initialized?
|
ldy OldIRQ+1 ; Already initialized?
|
||||||
bne Done ; Jump if yes
|
bne AlreadyInitialized ; Jump if yes
|
||||||
|
|
||||||
stx MouseSprite ; Remember the sprite number
|
stx MouseSprite ; Remember the sprite number
|
||||||
sta MousePort ; Remember the port number
|
sta MousePort ; Remember the port number
|
||||||
|
@ -66,11 +69,18 @@ _mouse_init:
|
||||||
lda IRQVec+1
|
lda IRQVec+1
|
||||||
sta OldIRQ+1
|
sta OldIRQ+1
|
||||||
|
|
||||||
; Set our own IRQ vector
|
; Set our own IRQ vector. We cheat here to save a few bytes of code:
|
||||||
|
; The function is expected to return a value not equal to zero on success,
|
||||||
|
; and since we know that the high byte of the IRQ handler address is never
|
||||||
|
; zweo, we will return just this byte.
|
||||||
|
|
||||||
lda #<MouseIRQ
|
ldx #<MouseIRQ
|
||||||
ldx #>MouseIRQ
|
lda #>MouseIRQ
|
||||||
bne SetIRQ
|
bne SetIRQ ; Branch always
|
||||||
|
|
||||||
|
AlreadyInitialized:
|
||||||
|
lda #0 ; Error
|
||||||
|
rts
|
||||||
|
|
||||||
; --------------------------------------------------------------------------
|
; --------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
|
@ -78,14 +88,14 @@ _mouse_init:
|
||||||
;
|
;
|
||||||
|
|
||||||
_mouse_done:
|
_mouse_done:
|
||||||
lda OldIRQ ; Initialized?
|
ldx OldIRQ ; Initialized?
|
||||||
ldx OldIRQ+1
|
lda OldIRQ+1
|
||||||
beq Done ; Jump if no
|
beq Done ; Jump if no
|
||||||
ldy #0
|
ldy #0
|
||||||
sty OldIRQ+1 ; Reset the initialized flag
|
sty OldIRQ+1 ; Reset the initialized flag
|
||||||
SetIRQ: sei ; Disable interrupts
|
SetIRQ: sei ; Disable interrupts
|
||||||
sta IRQVec ; Set the new/old vector
|
stx IRQVec ; Set the new/old vector
|
||||||
stx IRQVec+1
|
sta IRQVec+1
|
||||||
cli ; Enable interrupts
|
cli ; Enable interrupts
|
||||||
Done: rts
|
Done: rts
|
||||||
|
|
||||||
|
@ -229,6 +239,16 @@ _mouse_move:
|
||||||
@L9: cli ; Enable interrupts
|
@L9: cli ; Enable interrupts
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
|
; --------------------------------------------------------------------------
|
||||||
|
;
|
||||||
|
; unsigned char mouse_buttons (void);
|
||||||
|
;
|
||||||
|
|
||||||
|
_mouse_buttons:
|
||||||
|
lda MousePort ; Get the port
|
||||||
|
jmp _readjoy ; Same as joystick
|
||||||
|
|
||||||
; --------------------------------------------------------------------------
|
; --------------------------------------------------------------------------
|
||||||
;
|
;
|
||||||
; Mouse interrupt handler
|
; Mouse interrupt handler
|
||||||
|
|
Loading…
Add table
Reference in a new issue