1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-19 06:31:31 +00:00

Debugged the mouse routines

git-svn-id: svn://svn.cc65.org/cc65/trunk@342 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2000-09-26 19:44:44 +00:00
parent 9633ff1882
commit c15fb9b50f

View File

@ -16,6 +16,8 @@
.include "c64.inc" .include "c64.inc"
.macpack generic
.code .code
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
@ -43,17 +45,18 @@ _mouse_init:
stx OldPotX stx OldPotX
stx OldPotY stx OldPotY
stx XMin stx XMin
stx XMin+1 stx XMin+1 ; XMin = 0
stx YMin lda #29
stx YMin+1 sta YMin
stx YMax+1 stx YMin+1 ; YMin = 29
lda #250
sta YMax
stx YMax+1 ; YMax = 250
inx ; X = 1 inx ; X = 1
stx Visible ; Mouse *not* visible stx Visible ; Mouse *not* visible
stx XMax+1 ; >320 lda #<344
ldx #<320 sta XMax
stx XMax stx XMax+1 ; XMax = 344
ldx #200
stx YMax
; Remember the old IRQ vector ; Remember the old IRQ vector
@ -116,7 +119,7 @@ _mouse_show:
beq @L1 ; Jump if yes beq @L1 ; Jump if yes
dec Visible ; Get the flag dec Visible ; Get the flag
bne @L1 ; Jump if still invisible bne @L1 ; Jump if still invisible
ldx MouseSprite ; Sprite defined? ldx MouseSprite ; Sprite defined?
beq @L1 ; Jump if no beq @L1 ; Jump if no
sei ; Disable interrupts sei ; Disable interrupts
@ -239,8 +242,7 @@ MouseIRQ:
; Calculate the new X coordinate (--> a/y) ; Calculate the new X coordinate (--> a/y)
clc add XPos
adc XPos
tay ; Remember low byte tay ; Remember low byte
txa txa
adc XPos+1 adc XPos+1
@ -273,11 +275,14 @@ MouseIRQ:
; Calculate the new Y coordinate (--> a/y) ; Calculate the new Y coordinate (--> a/y)
clc sta OldValue
adc YPos lda YPos
tay ; Remember low byte sub OldValue
txa tay
adc YPos+1 stx OldValue
lda YPos+1
sbc OldValue
tax
cpy YMin cpy YMin
sbc YMin+1 sbc YMin+1
@ -319,8 +324,7 @@ MoveCheck:
sta NewValue sta NewValue
ldx #$00 ldx #$00
sec ; a = mod64 (new - old) sub OldValue ; a = mod64 (new - old)
sbc OldValue
and #%01111111 and #%01111111
cmp #%01000000 ; if (a > 0) cmp #%01000000 ; if (a > 0)
bcs @L1 ; bcs @L1 ;
@ -334,11 +338,11 @@ MoveCheck:
beq @L2 beq @L2
sec sec
ror a ; a /= 2 ror a ; a /= 2
ldx #$FF ; high byte = -1 dex ; high byte = -1 (X = $FF)
ldy NewValue ldy NewValue
rts rts
@L2: lda #0 @L2: txa ; A = $00
rts rts
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
@ -397,7 +401,7 @@ OldValue: .res 1 ; Temp for MoveCheck routine
NewValue: .res 1 ; Temp for MoveCheck routine NewValue: .res 1 ; Temp for MoveCheck routine
Visible: .res 1 ; Is the mouse visible? Visible: .res 1 ; Is the mouse visible?
OldPotX: .res 1 ; Old hw counter values OldPotX: .res 1 ; Old hw counter values
OldPotY: .res 1 OldPotY: .res 1
XPos: .res 2 ; Current mouse position, X XPos: .res 2 ; Current mouse position, X