Merge remote-tracking branch 'upstream/master' into something_to_pull

This commit is contained in:
Christian Groessler
2014-01-16 23:34:56 +01:00
16 changed files with 158 additions and 46 deletions

View File

@@ -78,6 +78,10 @@
.byte .byte
CSHOW .addr CSHOW .addr
.byte .byte
CDRAW .addr
.byte
CMOVE .addr
.byte
CMOVEX .addr CMOVEX .addr
.byte .byte
CMOVEY .addr CMOVEY .addr
@@ -90,14 +94,16 @@
.struct MOUSE_CALLBACKS .struct MOUSE_CALLBACKS
HIDE .addr ; Hide the mouse cursor HIDE .addr ; Hide the mouse cursor
SHOW .addr ; Show the mouse cursor SHOW .addr ; Show the mouse cursor
MOVEX .addr ; Move the mouse cursor DRAW .addr ; Draw the mouse cursor
MOVEY .addr ; Dito for Y MOVE .addr ; Prepare to move the mouse cursor
MOVEX .addr ; Move the mouse cursor to X coord
MOVEY .addr ; Move the mouse cursor to Y coord
.endstruct .endstruct
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; The mouse API version, stored in MOUSE_HDR::VERSION ; The mouse API version, stored in MOUSE_HDR::VERSION
MOUSE_API_VERSION = $04 MOUSE_API_VERSION = $05
;------------------------------------------------------------------------------ ;------------------------------------------------------------------------------
; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS. ; Bitmapped mouse driver flags, stored in MOUSE_HDR::FLAGS.
@@ -176,5 +182,3 @@ MOUSE_BTN_RIGHT = $01
.global mouse_pos .global mouse_pos
.global mouse_info .global mouse_info
.global mouse_ioctl .global mouse_ioctl

View File

@@ -16,6 +16,7 @@
.bss .bss
backup: .res 1 backup: .res 1
visible:.res 1
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@@ -25,6 +26,8 @@ backup: .res 1
_mouse_def_callbacks: _mouse_def_callbacks:
.addr hide .addr hide
.addr show .addr show
.addr draw
.addr move
.addr movex .addr movex
.addr movey .addr movey
@@ -65,10 +68,15 @@ done:
.ifdef __APPLE2ENH__ .ifdef __APPLE2ENH__
bit LOWSCR ; Doesn't hurt in 40 column mode bit LOWSCR ; Doesn't hurt in 40 column mode
.endif .endif
rts return: rts
; Hide the mouse cursor. ; Hide the mouse cursor.
hide: hide:
dec visible
; Fall through
; Prepare to move the mouse cursor.
move:
jsr getcursor ; Cursor visible at current position? jsr getcursor ; Cursor visible at current position?
bne done ; No, we're done bne done ; No, we're done
lda backup ; Get character at cursor position lda backup ; Get character at cursor position
@@ -76,6 +84,13 @@ hide:
; Show the mouse cursor. ; Show the mouse cursor.
show: show:
inc visible
; Fall through
; Draw the mouse cursor.
draw:
lda visible
beq return
jsr getcursor ; Cursor visible at current position? jsr getcursor ; Cursor visible at current position?
beq done ; Yes, we're done beq done ; Yes, we're done
sta backup ; Save character at cursor position sta backup ; Save character at cursor position

View File

@@ -57,6 +57,8 @@ status := $0778
; Callback table, set by the kernel before INSTALL is called ; Callback table, set by the kernel before INSTALL is called
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -67,7 +69,6 @@ CMOVEY: jmp $0000 ; Move the cursor to Y coord
box: .tag MOUSE_BOX box: .tag MOUSE_BOX
info: .tag MOUSE_INFO info: .tag MOUSE_INFO
slot: .res 1 slot: .res 1
visible:.res 1
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@@ -321,7 +322,6 @@ MOVE:
; no special action is required besides hiding the mouse cursor. ; no special action is required besides hiding the mouse cursor.
; No return code required. ; No return code required.
HIDE: HIDE:
dec visible
sei sei
jsr CHIDE jsr CHIDE
cli cli
@@ -333,7 +333,9 @@ HIDE:
; no special action is required besides enabling the mouse cursor. ; no special action is required besides enabling the mouse cursor.
; No return code required. ; No return code required.
SHOW: SHOW:
inc visible sei
jsr CSHOW
cli
rts rts
; BUTTONS: Return the button mask in A/X. ; BUTTONS: Return the button mask in A/X.
@@ -409,7 +411,7 @@ done: rts
beq :+ beq :+
; Remove the cursor at the old position ; Remove the cursor at the old position
update: jsr CHIDE update: jsr CMOVE
; Get and set the new X position ; Get and set the new X position
ldy slot ldy slot
@@ -427,11 +429,7 @@ update: jsr CHIDE
stx info + MOUSE_POS::YCOORD+1 stx info + MOUSE_POS::YCOORD+1
jsr CMOVEY jsr CMOVEY
; Check for visibility
: lda visible
beq :+
; Draw the cursor at the new position ; Draw the cursor at the new position
jsr CSHOW : jsr CDRAW
: sec ; Interrupt handled sec ; Interrupt handled
rts rts

View File

@@ -1,5 +1,5 @@
; ;
; Default mouse callbacks for the C64 ; Default mouse callbacks for the C128
; ;
; Ullrich von Bassewitz, 2004-03-20 ; Ullrich von Bassewitz, 2004-03-20
; ;
@@ -48,6 +48,24 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
.endproc .endproc
; --------------------------------------------------------------------------
; Draw the mouse pointer. Always called with interrupts disabled.
.proc draw
rts
.endproc
; --------------------------------------------------------------------------
; Prepare to move the mouse pointer. Always called with interrupts disabled.
.proc move
rts
.endproc
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x. Always called with ; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled. ; interrupts disabled.
@@ -103,7 +121,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
_mouse_def_callbacks: _mouse_def_callbacks:
.addr hide .addr hide
.addr show .addr show
.addr draw
.addr move
.addr movex .addr movex
.addr movey .addr movey

View File

@@ -50,6 +50,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -302,7 +304,8 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: lda SID_ADConv1 ; Get mouse X movement IRQ: jsr CMOVE
lda SID_ADConv1 ; Get mouse X movement
ldy OldPotX ldy OldPotX
jsr MoveCheck ; Calculate movement vector jsr MoveCheck ; Calculate movement vector
sty OldPotX sty OldPotX
@@ -389,8 +392,9 @@ IRQ: lda SID_ADConv1 ; Get mouse X movement
; Done ; Done
clc ; Interrupt not "handled" @SkipY: jsr CDRAW
@SkipY: rts clc ; Interrupt not "handled"
rts
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; ;

View File

@@ -49,6 +49,8 @@ LIBREF: .addr $0000
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X co-ord. CMOVEX: jmp $0000 ; Move the cursor to X co-ord.
CMOVEY: jmp $0000 ; Move the cursor to Y co-ord. CMOVEY: jmp $0000 ; Move the cursor to Y co-ord.
@@ -343,7 +345,7 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: IRQ: jsr CMOVE
; Record the state of the buttons. ; Record the state of the buttons.
; Try to avoid crosstalk between the keyboard and the lightpen. ; Try to avoid crosstalk between the keyboard and the lightpen.
@@ -441,7 +443,8 @@ IRQ:
; Done ; Done
@SkipX: clc ; Interrupt not "handled" @SkipX: jsr CDRAW
clc ; Interrupt not "handled"
rts rts
; Move the lightpen pointer to the new Y pos. ; Move the lightpen pointer to the new Y pos.

View File

@@ -49,6 +49,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -302,7 +304,8 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: lda #$7F IRQ: jsr CMOVE
lda #$7F
sta CIA1_PRA sta CIA1_PRA
lda CIA1_PRB ; Read joystick #0 lda CIA1_PRB ; Read joystick #0
and #$1F and #$1F
@@ -415,6 +418,6 @@ IRQ: lda #$7F
; Done ; Done
@SkipY: clc ; Interrupt not "handled" @SkipY: jsr CDRAW
clc ; Interrupt not "handled"
rts rts

View File

@@ -46,6 +46,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -297,7 +299,8 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; (so be careful). ; (so be careful).
; ;
IRQ: lda #$7F IRQ: jsr CMOVE
lda #$7F
sta CIA1_PRA sta CIA1_PRA
lda CIA1_PRB ; Read port #1 lda CIA1_PRB ; Read port #1
and #%00001100 and #%00001100
@@ -392,4 +395,7 @@ IRQ: lda #$7F
; Move the mouse pointer to the new X pos ; Move the mouse pointer to the new X pos
tya tya
jmp CMOVEY jsr CMOVEY
jsr CDRAW
clc ; Interrupt not "handled"
rts

View File

@@ -48,6 +48,24 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
.endproc .endproc
; --------------------------------------------------------------------------
; Draw the mouse pointer. Always called with interrupts disabled.
.proc draw
rts
.endproc
; --------------------------------------------------------------------------
; Prepare to move the mouse pointer. Always called with interrupts disabled.
.proc move
rts
.endproc
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Move the mouse pointer X position to the value in a/x. Always called with ; Move the mouse pointer X position to the value in a/x. Always called with
; interrupts disabled. ; interrupts disabled.
@@ -96,7 +114,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
_mouse_def_callbacks: _mouse_def_callbacks:
.addr hide .addr hide
.addr show .addr show
.addr draw
.addr move
.addr movex .addr movex
.addr movey .addr movey

View File

@@ -69,6 +69,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -314,7 +316,7 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: IRQ: jsr CMOVE
; Record the state of the buttons. ; Record the state of the buttons.
; Avoid crosstalk between the keyboard and the mouse. ; Avoid crosstalk between the keyboard and the mouse.
@@ -417,8 +419,9 @@ IRQ:
; Done ; Done
@SkipY: jsr CDRAW
clc ; Interrupt not "handled" clc ; Interrupt not "handled"
@SkipY: rts rts
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; ;

View File

@@ -49,6 +49,8 @@ LIBREF: .addr $0000
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X co-ord. CMOVEX: jmp $0000 ; Move the cursor to X co-ord.
CMOVEY: jmp $0000 ; Move the cursor to Y co-ord. CMOVEY: jmp $0000 ; Move the cursor to Y co-ord.
@@ -324,7 +326,7 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: IRQ: jsr CMOVE
; Record the state of the buttons. ; Record the state of the buttons.
; Try to avoid crosstalk between the keyboard and the lightpen. ; Try to avoid crosstalk between the keyboard and the lightpen.
@@ -422,7 +424,8 @@ IRQ:
; Done ; Done
@SkipX: clc ; Interrupt not "handled" @SkipX: jsr CDRAW
clc ; Interrupt not "handled"
rts rts
; Move the lightpen pointer to the new Y pos. ; Move the lightpen pointer to the new Y pos.

View File

@@ -68,6 +68,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -319,9 +321,11 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: jsr CMOVE
; Avoid crosstalk between the keyboard and a joystick. ; Avoid crosstalk between the keyboard and a joystick.
IRQ: ldy #%00000000 ; Set ports A and B to input ldy #%00000000 ; Set ports A and B to input
sty CIA1_DDRB sty CIA1_DDRB
sty CIA1_DDRA ; Keyboard won't look like joystick sty CIA1_DDRA ; Keyboard won't look like joystick
lda CIA1_PRB ; Read Control-Port 1 lda CIA1_PRB ; Read Control-Port 1
@@ -438,6 +442,7 @@ IRQ: ldy #%00000000 ; Set ports A and B to input
; Done ; Done
@SkipY: clc ; Interrupt not handled @SkipY: jsr CDRAW
clc ; Interrupt not "handled"
rts rts

View File

@@ -46,6 +46,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X coord CMOVEX: jmp $0000 ; Move the cursor to X coord
CMOVEY: jmp $0000 ; Move the cursor to Y coord CMOVEY: jmp $0000 ; Move the cursor to Y coord
@@ -297,7 +299,8 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioclts for now
; (so be careful). ; (so be careful).
; ;
IRQ: lda #$7F IRQ: jsr CMOVE
lda #$7F
sta CIA1_PRA sta CIA1_PRA
lda CIA1_PRB ; Read port #1 lda CIA1_PRB ; Read port #1
and #%00001100 and #%00001100
@@ -392,4 +395,7 @@ IRQ: lda #$7F
; Move the mouse pointer to the new X pos ; Move the mouse pointer to the new X pos
tya tya
jmp CMOVEY jsr CMOVEY
jsr CDRAW
clc ; Interrupt not "handled"
rts

View File

@@ -62,6 +62,24 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
.endproc .endproc
; --------------------------------------------------------------------------
; Draw the mouse pointer. Always called with interrupts disabled.
.proc draw
rts
.endproc
; --------------------------------------------------------------------------
; Prepare to move the mouse pointer. Always called with interrupts disabled.
.proc move
rts
.endproc
; -------------------------------------------------------------------------- ; --------------------------------------------------------------------------
; Move the mouse pointer x position to the value in .XA. Always called with ; Move the mouse pointer x position to the value in .XA. Always called with
; interrupts disabled. ; interrupts disabled.
@@ -125,7 +143,7 @@ VIC_SPR_Y = (VIC_SPR0_Y + 2*MOUSE_SPR) ; Sprite Y register
_mouse_def_callbacks: _mouse_def_callbacks:
.addr hide .addr hide
.addr show .addr show
.addr draw
.addr move
.addr movex .addr movex
.addr movey .addr movey

View File

@@ -53,6 +53,8 @@ LIBREF: .addr $0000
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to X co-ord. CMOVEX: jmp $0000 ; Move the cursor to X co-ord.
CMOVEY: jmp $0000 ; Move the cursor to Y co-ord. CMOVEY: jmp $0000 ; Move the cursor to Y co-ord.
@@ -336,7 +338,8 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
; MUST return carry clear. ; MUST return carry clear.
; ;
IRQ: ldx #15 ; To system bank IRQ: jsr CMOVE
ldx #15 ; To system bank
stx IndReg stx IndReg
; Read the VIC-II lightpen registers. ; Read the VIC-II lightpen registers.
@@ -428,7 +431,8 @@ IRQ: ldx #15 ; To system bank
; Done ; Done
@SkipX: clc ; Interrupt not "handled" @SkipX: jsr CDRAW
clc ; Interrupt not "handled"
rts rts
; Move the lightpen pointer to the new Y pos. ; Move the lightpen pointer to the new Y pos.

View File

@@ -52,6 +52,8 @@ HEADER:
CHIDE: jmp $0000 ; Hide the cursor CHIDE: jmp $0000 ; Hide the cursor
CSHOW: jmp $0000 ; Show the cursor CSHOW: jmp $0000 ; Show the cursor
CDRAW: jmp $0000 ; Draw the cursor
CMOVE: jmp $0000 ; Prepare to move the cursor
CMOVEX: jmp $0000 ; Move the cursor to x co-ord. CMOVEX: jmp $0000 ; Move the cursor to x co-ord.
CMOVEY: jmp $0000 ; Move the cursor to y co-ord. CMOVEY: jmp $0000 ; Move the cursor to y co-ord.
@@ -323,7 +325,8 @@ IOCTL: lda #<MOUSE_ERR_INV_IOCTL ; We don't support ioctls, for now
; Reads joystick 2. ; Reads joystick 2.
; ;
IRQ: ldy #15 ; Switch to the system bank IRQ: jsr CMOVE
ldy #15 ; Switch to the system bank
sty IndReg sty IndReg
; Get the direction bits. ; Get the direction bits.
@@ -430,7 +433,8 @@ IRQ: ldy #15 ; Switch to the system bank
; Done ; Done
@SkipY: clc ; Interrupt not handled @SkipY: jsr CDRAW
clc ; Interrupt not "handled"
rts rts
; Move the mouse pointer to the new x pos. ; Move the mouse pointer to the new x pos.