Removed (pretty inconsistently used) tab chars from source code base.
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -64,18 +64,18 @@ SCREEN_WIDTH = 320
|
||||
.bss
|
||||
|
||||
Vars:
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
OldPotX: .res 1 ; Old hw counter values
|
||||
OldPotY: .res 1
|
||||
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
|
||||
OldValue: .res 1 ; Temp for MoveCheck routine
|
||||
NewValue: .res 1 ; Temp for MoveCheck routine
|
||||
OldValue: .res 1 ; Temp for MoveCheck routine
|
||||
NewValue: .res 1 ; Temp for MoveCheck routine
|
||||
|
||||
; Default values for above variables
|
||||
|
||||
@@ -177,7 +177,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -195,7 +195,7 @@ GETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -219,47 +219,47 @@ MOVE: sei ; No interrupts
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
|
||||
jsr CMOVEX ; Move the cursor
|
||||
jsr CMOVEX ; Move the cursor
|
||||
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BUTTONS: Return the button mask in a/x.
|
||||
|
||||
BUTTONS:
|
||||
lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
cli
|
||||
lda #$7F
|
||||
sei
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
cli
|
||||
ldx #0
|
||||
and #$1F
|
||||
eor #$1F
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; POS: Return the mouse position in the MOUSE_POS struct pointed to by ptr1.
|
||||
; No return code required.
|
||||
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INFO: Returns mouse position and current button mask in the MOUSE_INFO
|
||||
@@ -270,15 +270,15 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
; call _mouse_pos to initialize the struct pointer and fill the position
|
||||
; fields.
|
||||
|
||||
INFO: jsr POS
|
||||
INFO: jsr POS
|
||||
|
||||
; Fill in the button state
|
||||
|
||||
jsr BUTTONS ; Will not touch ptr1
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
jsr BUTTONS ; Will not touch ptr1
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
@@ -297,10 +297,10 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
; MUST return carry clear.
|
||||
;
|
||||
|
||||
IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
sty OldPotX
|
||||
IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
ldy OldPotX
|
||||
jsr MoveCheck ; Calculate movement vector
|
||||
sty OldPotX
|
||||
|
||||
; Skip processing if nothing has changed
|
||||
|
||||
@@ -308,29 +308,29 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
@@ -339,10 +339,10 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
|
||||
; Calculate the Y movement vector
|
||||
|
||||
@SkipX: lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
sty OldPotY
|
||||
@SkipX: lda SID_ADConv2 ; Get mouse Y movement
|
||||
ldy OldPotY
|
||||
jsr MoveCheck ; Calculate movement
|
||||
sty OldPotY
|
||||
|
||||
; Skip processing if nothing has changed
|
||||
|
||||
@@ -350,32 +350,32 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
sta OldValue
|
||||
lda YPos
|
||||
sub OldValue
|
||||
tay
|
||||
stx OldValue
|
||||
lda YPos+1
|
||||
sbc OldValue
|
||||
tax
|
||||
sta OldValue
|
||||
lda YPos
|
||||
sub OldValue
|
||||
tay
|
||||
stx OldValue
|
||||
lda YPos+1
|
||||
sbc OldValue
|
||||
tax
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
@@ -391,38 +391,38 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
|
||||
;
|
||||
; Move check routine, called for both coordinates.
|
||||
;
|
||||
; Entry: y = old value of pot register
|
||||
; a = current value of pot register
|
||||
; Exit: y = value to use for old value
|
||||
; x/a = delta value for position
|
||||
; Entry: y = old value of pot register
|
||||
; a = current value of pot register
|
||||
; Exit: y = value to use for old value
|
||||
; x/a = delta value for position
|
||||
;
|
||||
|
||||
MoveCheck:
|
||||
sty OldValue
|
||||
sta NewValue
|
||||
ldx #$00
|
||||
sty OldValue
|
||||
sta NewValue
|
||||
ldx #$00
|
||||
|
||||
sub OldValue ; a = mod64 (new - old)
|
||||
and #%01111111
|
||||
cmp #%01000000 ; if (a > 0)
|
||||
bcs @L1 ;
|
||||
lsr a ; a /= 2;
|
||||
beq @L2 ; if (a != 0)
|
||||
ldy NewValue ; y = NewValue
|
||||
sub OldValue ; a = mod64 (new - old)
|
||||
and #%01111111
|
||||
cmp #%01000000 ; if (a > 0)
|
||||
bcs @L1 ;
|
||||
lsr a ; a /= 2;
|
||||
beq @L2 ; if (a != 0)
|
||||
ldy NewValue ; y = NewValue
|
||||
sec
|
||||
rts ; return
|
||||
rts ; return
|
||||
|
||||
@L1: ora #%11000000 ; else or in high order bits
|
||||
cmp #$FF ; if (a != -1)
|
||||
beq @L2
|
||||
sec
|
||||
ror a ; a /= 2
|
||||
dex ; high byte = -1 (X = $FF)
|
||||
ldy NewValue
|
||||
@L1: ora #%11000000 ; else or in high order bits
|
||||
cmp #$FF ; if (a != -1)
|
||||
beq @L2
|
||||
sec
|
||||
rts
|
||||
ror a ; a /= 2
|
||||
dex ; high byte = -1 (X = $FF)
|
||||
ldy NewValue
|
||||
sec
|
||||
rts
|
||||
|
||||
@L2: txa ; A = $00
|
||||
@L2: txa ; A = $00
|
||||
clc
|
||||
rts
|
||||
rts
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
.macpack generic
|
||||
|
||||
@@ -73,11 +73,11 @@ SCREEN_WIDTH = 320
|
||||
Vars:
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
|
||||
; Temporary value used in the int handler
|
||||
|
||||
@@ -94,7 +94,7 @@ Temp: .res 1
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.byte 0 ; Buttons
|
||||
.endproc
|
||||
|
||||
.code
|
||||
@@ -183,7 +183,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -201,7 +201,7 @@ GETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -225,41 +225,41 @@ MOVE: sei ; No interrupts
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
|
||||
jsr CMOVEX ; Move the cursor
|
||||
jsr CMOVEX ; Move the cursor
|
||||
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BUTTONS: Return the button mask in a/x.
|
||||
|
||||
BUTTONS:
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; POS: Return the mouse position in the MOUSE_POS struct pointed to by ptr1.
|
||||
; No return code required.
|
||||
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INFO: Returns mouse position and current button mask in the MOUSE_INFO
|
||||
@@ -270,15 +270,15 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
; call _mouse_pos to initialize the struct pointer and fill the position
|
||||
; fields.
|
||||
|
||||
INFO: jsr POS
|
||||
INFO: jsr POS
|
||||
|
||||
; Fill in the button state
|
||||
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
@@ -297,11 +297,11 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
; MUST return carry clear.
|
||||
;
|
||||
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read joystick #0
|
||||
and #$1F
|
||||
eor #$1F ; Make all bits active high
|
||||
eor #$1F ; Make all bits active high
|
||||
sta Temp
|
||||
|
||||
; Check for a pressed button and place the result into Buttons
|
||||
@@ -315,45 +315,45 @@ IRQ: lda #$7F
|
||||
; Check left/right
|
||||
|
||||
lda Temp ; Read joystick #0
|
||||
and #(JOY::LEFT | JOY::RIGHT)
|
||||
beq @SkipX ;
|
||||
and #(JOY::LEFT | JOY::RIGHT)
|
||||
beq @SkipX ;
|
||||
|
||||
; We will cheat here and rely on the fact that either the left, OR the right
|
||||
; bit can be active
|
||||
|
||||
and #JOY::RIGHT ; Check RIGHT bit
|
||||
bne @Right
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
@Right: lda #$01
|
||||
ldx #$00
|
||||
and #JOY::RIGHT ; Check RIGHT bit
|
||||
bne @Right
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
@Right: lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
@AddX: add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
@@ -363,45 +363,45 @@ IRQ: lda #$7F
|
||||
; Calculate the Y movement vector
|
||||
|
||||
@SkipX: lda Temp ; Read joystick #0
|
||||
and #(JOY::UP | JOY::DOWN) ; Check up/down
|
||||
beq @SkipY ;
|
||||
and #(JOY::UP | JOY::DOWN) ; Check up/down
|
||||
beq @SkipY ;
|
||||
|
||||
; We will cheat here and rely on the fact that either the up, OR the down
|
||||
; bit can be active
|
||||
|
||||
lsr a ; Check UP bit
|
||||
bcc @Down
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
lsr a ; Check UP bit
|
||||
bcc @Down
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
|
||||
@@ -5,59 +5,59 @@
|
||||
; Stefan Haubenthal, 2006-08-20
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.inc"
|
||||
.include "zeropage.inc"
|
||||
.include "mouse-kernel.inc"
|
||||
.include "c128.inc"
|
||||
|
||||
.macpack generic
|
||||
.macpack generic
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
.segment "JUMPTABLE"
|
||||
.segment "JUMPTABLE"
|
||||
|
||||
HEADER:
|
||||
|
||||
; Driver signature
|
||||
|
||||
.byte $6d, $6f, $75 ; "mou"
|
||||
.byte MOUSE_API_VERSION ; Mouse driver API version number
|
||||
.byte $6d, $6f, $75 ; "mou"
|
||||
.byte MOUSE_API_VERSION ; Mouse driver API version number
|
||||
|
||||
; Jump table.
|
||||
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr HIDE
|
||||
.addr SHOW
|
||||
.addr SETBOX
|
||||
.addr INSTALL
|
||||
.addr UNINSTALL
|
||||
.addr HIDE
|
||||
.addr SHOW
|
||||
.addr SETBOX
|
||||
.addr GETBOX
|
||||
.addr MOVE
|
||||
.addr BUTTONS
|
||||
.addr POS
|
||||
.addr INFO
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
.addr MOVE
|
||||
.addr BUTTONS
|
||||
.addr POS
|
||||
.addr INFO
|
||||
.addr IOCTL
|
||||
.addr IRQ
|
||||
|
||||
; Callback table, set by the kernel before INSTALL is called
|
||||
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
CSHOW: jmp $0000 ; Show the cursor
|
||||
CMOVEX: jmp $0000 ; Move the cursor to X coord
|
||||
CMOVEY: jmp $0000 ; Move the cursor to Y coord
|
||||
CHIDE: jmp $0000 ; Hide the cursor
|
||||
CSHOW: jmp $0000 ; Show the cursor
|
||||
CMOVEX: jmp $0000 ; Move the cursor to X coord
|
||||
CMOVEY: jmp $0000 ; Move the cursor to Y coord
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; Constants
|
||||
|
||||
SCREEN_HEIGHT = 200
|
||||
SCREEN_WIDTH = 320
|
||||
SCREEN_HEIGHT = 200
|
||||
SCREEN_WIDTH = 320
|
||||
|
||||
.enum JOY
|
||||
UP = $01
|
||||
DOWN = $02
|
||||
LEFT = $04
|
||||
RIGHT = $08
|
||||
FIRE = $10
|
||||
.enum JOY
|
||||
UP = $01
|
||||
DOWN = $02
|
||||
LEFT = $04
|
||||
RIGHT = $08
|
||||
FIRE = $10
|
||||
.endenum
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
@@ -68,30 +68,30 @@ SCREEN_WIDTH = 320
|
||||
.bss
|
||||
|
||||
Vars:
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
YPos: .res 2 ; Current mouse position, Y
|
||||
XPos: .res 2 ; Current mouse position, X
|
||||
XMin: .res 2 ; X1 value of bounding box
|
||||
YMin: .res 2 ; Y1 value of bounding box
|
||||
XMax: .res 2 ; X2 value of bounding box
|
||||
YMax: .res 2 ; Y2 value of bounding box
|
||||
Buttons: .res 1 ; Button mask
|
||||
|
||||
; Temporary value used in the int handler
|
||||
|
||||
Temp: .res 1
|
||||
Temp: .res 1
|
||||
|
||||
; Default values for above variables
|
||||
|
||||
.rodata
|
||||
|
||||
.proc DefVars
|
||||
.word SCREEN_HEIGHT/2 ; YPos
|
||||
.word SCREEN_WIDTH/2 ; XPos
|
||||
.word 0 ; XMin
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.proc DefVars
|
||||
.word SCREEN_HEIGHT/2 ; YPos
|
||||
.word SCREEN_WIDTH/2 ; XPos
|
||||
.word 0 ; XMin
|
||||
.word 0 ; YMin
|
||||
.word SCREEN_WIDTH ; XMax
|
||||
.word SCREEN_HEIGHT ; YMax
|
||||
.byte 0 ; Buttons
|
||||
.endproc
|
||||
|
||||
.code
|
||||
@@ -105,37 +105,37 @@ INSTALL:
|
||||
|
||||
; Initialize variables. Just copy the default stuff over
|
||||
|
||||
ldx #.sizeof(DefVars)-1
|
||||
@L1: lda DefVars,x
|
||||
sta Vars,x
|
||||
dex
|
||||
bpl @L1
|
||||
ldx #.sizeof(DefVars)-1
|
||||
@L1: lda DefVars,x
|
||||
sta Vars,x
|
||||
dex
|
||||
bpl @L1
|
||||
|
||||
; Be sure the mouse cursor is invisible and at the default location. We
|
||||
; need to do that here, because our mouse interrupt handler doesn't set the
|
||||
; mouse position if it hasn't changed.
|
||||
|
||||
sei
|
||||
jsr CHIDE
|
||||
lda XPos
|
||||
ldx XPos+1
|
||||
jsr CMOVEX
|
||||
lda YPos
|
||||
ldx YPos+1
|
||||
jsr CMOVEY
|
||||
cli
|
||||
sei
|
||||
jsr CHIDE
|
||||
lda XPos
|
||||
ldx XPos+1
|
||||
jsr CMOVEX
|
||||
lda YPos
|
||||
ldx YPos+1
|
||||
jsr CMOVEY
|
||||
cli
|
||||
|
||||
; Done, return zero (= MOUSE_ERR_OK)
|
||||
|
||||
ldx #$00
|
||||
txa
|
||||
rts
|
||||
ldx #$00
|
||||
txa
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; UNINSTALL routine. Is called before the driver is removed from memory.
|
||||
; No return code required (the driver is removed from memory on return).
|
||||
|
||||
UNINSTALL = HIDE ; Hide cursor on exit
|
||||
UNINSTALL = HIDE ; Hide cursor on exit
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; HIDE routine. Is called to hide the mouse pointer. The mouse kernel manages
|
||||
@@ -144,10 +144,10 @@ UNINSTALL = HIDE ; Hide cursor on exit
|
||||
; no special action is required besides hiding the mouse cursor.
|
||||
; No return code required.
|
||||
|
||||
HIDE: sei
|
||||
jsr CHIDE
|
||||
cli
|
||||
rts
|
||||
HIDE: sei
|
||||
jsr CHIDE
|
||||
cli
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; SHOW routine. Is called to show the mouse pointer. The mouse kernel manages
|
||||
@@ -156,10 +156,10 @@ HIDE: sei
|
||||
; no special action is required besides enabling the mouse cursor.
|
||||
; No return code required.
|
||||
|
||||
SHOW: sei
|
||||
jsr CSHOW
|
||||
cli
|
||||
rts
|
||||
SHOW: sei
|
||||
jsr CSHOW
|
||||
cli
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; SETBOX: Set the mouse bounding box. The parameters are passed as they come
|
||||
@@ -180,7 +180,7 @@ SETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; GETBOX: Return the mouse bounding box. The parameters are passed as they
|
||||
@@ -198,7 +198,7 @@ GETBOX: sta ptr1
|
||||
bpl @L1
|
||||
|
||||
cli
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; MOVE: Move the mouse to a new position. The position is passed as it comes
|
||||
@@ -208,55 +208,55 @@ GETBOX: sta ptr1
|
||||
; the screen). No return code required.
|
||||
;
|
||||
|
||||
MOVE: sei ; No interrupts
|
||||
MOVE: sei ; No interrupts
|
||||
|
||||
sta YPos
|
||||
stx YPos+1 ; New Y position
|
||||
jsr CMOVEY ; Set it
|
||||
sta YPos
|
||||
stx YPos+1 ; New Y position
|
||||
jsr CMOVEY ; Set it
|
||||
|
||||
ldy #$01
|
||||
lda (sp),y
|
||||
sta XPos+1
|
||||
tax
|
||||
dey
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
ldy #$01
|
||||
lda (sp),y
|
||||
sta XPos+1
|
||||
tax
|
||||
dey
|
||||
lda (sp),y
|
||||
sta XPos ; New X position
|
||||
|
||||
jsr CMOVEX ; Move the cursor
|
||||
jsr CMOVEX ; Move the cursor
|
||||
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
cli ; Allow interrupts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; BUTTONS: Return the button mask in a/x.
|
||||
|
||||
BUTTONS:
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
lda Buttons
|
||||
ldx #$00
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; POS: Return the mouse position in the MOUSE_POS struct pointed to by ptr1.
|
||||
; No return code required.
|
||||
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
sei ; Disable interrupts
|
||||
lda XPos ; Transfer the position
|
||||
sta (ptr1),y
|
||||
lda XPos+1
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos
|
||||
iny
|
||||
sta (ptr1),y
|
||||
lda YPos+1
|
||||
cli ; Enable interrupts
|
||||
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
iny
|
||||
sta (ptr1),y ; Store last byte
|
||||
|
||||
rts ; Done
|
||||
rts ; Done
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; INFO: Returns mouse position and current button mask in the MOUSE_INFO
|
||||
@@ -267,15 +267,15 @@ POS: ldy #MOUSE_POS::XCOORD ; Structure offset
|
||||
; call _mouse_pos to initialize the struct pointer and fill the position
|
||||
; fields.
|
||||
|
||||
INFO: jsr POS
|
||||
INFO: jsr POS
|
||||
|
||||
; Fill in the button state
|
||||
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
lda Buttons
|
||||
ldy #MOUSE_INFO::BUTTONS
|
||||
sta (ptr1),y
|
||||
|
||||
rts
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IOCTL: Driver defined entry point. The wrapper will pass a pointer to ioctl
|
||||
@@ -283,108 +283,108 @@ INFO: jsr POS
|
||||
; Must return an error code in a/x.
|
||||
;
|
||||
|
||||
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
ldx #>MOUSE_ERR_INV_IOCTL
|
||||
rts
|
||||
IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
|
||||
ldx #>MOUSE_ERR_INV_IOCTL
|
||||
rts
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; IRQ: Irq handler entry point. Called as a subroutine but in IRQ context
|
||||
; (so be careful).
|
||||
;
|
||||
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read port #1
|
||||
and #%00001100
|
||||
eor #%00001100 ; Make all bits active high
|
||||
asl
|
||||
sta Buttons
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
and #%00000001
|
||||
ora Buttons
|
||||
sta Buttons
|
||||
ldx #%01000000
|
||||
stx CIA1_PRA
|
||||
ldy #0
|
||||
: dey
|
||||
bne :-
|
||||
ldx SID_ADConv1
|
||||
stx XPos
|
||||
ldx SID_ADConv2
|
||||
stx YPos
|
||||
IRQ: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB ; Read port #1
|
||||
and #%00001100
|
||||
eor #%00001100 ; Make all bits active high
|
||||
asl
|
||||
sta Buttons
|
||||
lsr
|
||||
lsr
|
||||
lsr
|
||||
and #%00000001
|
||||
ora Buttons
|
||||
sta Buttons
|
||||
ldx #%01000000
|
||||
stx CIA1_PRA
|
||||
ldy #0
|
||||
: dey
|
||||
bne :-
|
||||
ldx SID_ADConv1
|
||||
stx XPos
|
||||
ldx SID_ADConv2
|
||||
stx YPos
|
||||
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
lda #$01
|
||||
ldx #$00
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddX ; Branch always
|
||||
lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new X coordinate (--> a/y)
|
||||
|
||||
@AddX: add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
@AddX: add XPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc XPos+1
|
||||
tax
|
||||
|
||||
; Limit the X coordinate to the bounding box
|
||||
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
cpy XMin
|
||||
sbc XMin+1
|
||||
bpl @L1
|
||||
ldy XMin
|
||||
ldx XMin+1
|
||||
jmp @L2
|
||||
@L1: txa
|
||||
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
cpy XMax
|
||||
sbc XMax+1
|
||||
bmi @L2
|
||||
ldy XMax
|
||||
ldx XMax+1
|
||||
@L2: sty XPos
|
||||
stx XPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
tya
|
||||
jsr CMOVEX
|
||||
tya
|
||||
jsr CMOVEX
|
||||
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
lda #$FF
|
||||
tax
|
||||
bne @AddY
|
||||
@Down: lda #$01
|
||||
ldx #$00
|
||||
|
||||
; Calculate the new Y coordinate (--> a/y)
|
||||
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
@AddY: add YPos
|
||||
tay ; Remember low byte
|
||||
txa
|
||||
adc YPos+1
|
||||
tax
|
||||
|
||||
; Limit the Y coordinate to the bounding box
|
||||
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
cpy YMin
|
||||
sbc YMin+1
|
||||
bpl @L3
|
||||
ldy YMin
|
||||
ldx YMin+1
|
||||
jmp @L4
|
||||
@L3: txa
|
||||
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
cpy YMax
|
||||
sbc YMax+1
|
||||
bmi @L4
|
||||
ldy YMax
|
||||
ldx YMax+1
|
||||
@L4: sty YPos
|
||||
stx YPos+1
|
||||
|
||||
; Move the mouse pointer to the new X pos
|
||||
|
||||
tya
|
||||
jmp CMOVEY
|
||||
tya
|
||||
jmp CMOVEY
|
||||
|
||||
Reference in New Issue
Block a user