2006-04-06 19:51:37 +00:00
|
|
|
;
|
2013-05-09 11:56:54 +00:00
|
|
|
; Default mouse callbacks for the Apple II
|
2006-04-06 19:51:37 +00:00
|
|
|
;
|
|
|
|
; Oliver Schmidt, 22.09.2005
|
|
|
|
;
|
2013-05-09 11:56:54 +00:00
|
|
|
; All functions in this module should be interrupt safe, because they may
|
2006-04-06 19:51:37 +00:00
|
|
|
; be called from an interrupt handler
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _mouse_def_callbacks
|
|
|
|
|
|
|
|
.include "apple2.inc"
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.bss
|
|
|
|
|
|
|
|
backup: .res 1
|
2014-01-15 21:47:59 +00:00
|
|
|
visible:.res 1
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.rodata
|
2006-04-06 19:51:37 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
; Callback structure
|
2006-04-06 19:51:37 +00:00
|
|
|
_mouse_def_callbacks:
|
2013-05-09 11:56:54 +00:00
|
|
|
.addr hide
|
|
|
|
.addr show
|
2014-01-17 20:09:15 +00:00
|
|
|
.addr prep
|
2014-01-15 21:47:59 +00:00
|
|
|
.addr draw
|
2013-05-09 11:56:54 +00:00
|
|
|
.addr movex
|
|
|
|
.addr movey
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.data
|
2006-04-06 19:51:37 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.ifdef __APPLE2ENH__
|
2009-09-07 14:00:17 +00:00
|
|
|
cursor = 'B' ; MouseText character
|
|
|
|
.else
|
|
|
|
cursor = '+' | $40 ; Flashing crosshair
|
|
|
|
.endif
|
|
|
|
|
2006-04-06 19:51:37 +00:00
|
|
|
getcursor:
|
|
|
|
.ifdef __APPLE2ENH__
|
|
|
|
bit RD80VID ; In 80 column mode?
|
2013-05-09 11:56:54 +00:00
|
|
|
bpl column ; No, skip bank switching
|
|
|
|
switch: bit LOWSCR ; Patched at runtime
|
2006-04-06 19:51:37 +00:00
|
|
|
.endif
|
2013-05-09 11:56:54 +00:00
|
|
|
column: ldx #$00 ; Patched at runtime
|
|
|
|
getscr: lda $0400,x ; Patched at runtime
|
|
|
|
cmp #cursor
|
|
|
|
rts
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
setcursor:
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #cursor
|
|
|
|
setscr: sta $0400,x ; Patched at runtime
|
|
|
|
.ifdef __APPLE2ENH__
|
|
|
|
bit LOWSCR ; Doesn't hurt in 40 column mode
|
2006-04-06 19:51:37 +00:00
|
|
|
.endif
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.code
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
done:
|
2013-05-09 11:56:54 +00:00
|
|
|
.ifdef __APPLE2ENH__
|
|
|
|
bit LOWSCR ; Doesn't hurt in 40 column mode
|
2006-04-06 19:51:37 +00:00
|
|
|
.endif
|
2014-01-15 21:47:59 +00:00
|
|
|
return: rts
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; Hide the mouse cursor.
|
|
|
|
hide:
|
2014-01-15 21:47:59 +00:00
|
|
|
dec visible
|
|
|
|
; Fall through
|
|
|
|
|
|
|
|
; Prepare to move the mouse cursor.
|
2014-01-17 20:09:15 +00:00
|
|
|
prep:
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr getcursor ; Cursor visible at current position?
|
|
|
|
bne done ; No, we're done
|
|
|
|
lda backup ; Get character at cursor position
|
|
|
|
jmp setscr ; Draw character
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; Show the mouse cursor.
|
|
|
|
show:
|
2014-01-15 21:47:59 +00:00
|
|
|
inc visible
|
|
|
|
; Fall through
|
|
|
|
|
|
|
|
; Draw the mouse cursor.
|
|
|
|
draw:
|
|
|
|
lda visible
|
|
|
|
beq return
|
2013-05-09 11:56:54 +00:00
|
|
|
jsr getcursor ; Cursor visible at current position?
|
|
|
|
beq done ; Yes, we're done
|
|
|
|
sta backup ; Save character at cursor position
|
|
|
|
jmp setcursor ; Draw cursor
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; Move the mouse cursor x position to the value in A/X.
|
|
|
|
movex:
|
2013-05-09 11:56:54 +00:00
|
|
|
dex ; Is position [256..279]?
|
|
|
|
bmi :+ ; No, start with column 0
|
|
|
|
clc
|
|
|
|
adc #$0100 .MOD 7 ; Bias position
|
|
|
|
ldx #$0100 / 7 - 1 ; Bias column
|
|
|
|
: sec
|
|
|
|
: sbc #7 ; 280 positions / 40 columns
|
|
|
|
inx
|
|
|
|
bcs :-
|
|
|
|
stx column+1
|
2006-04-06 19:51:37 +00:00
|
|
|
.ifdef __APPLE2ENH__
|
2013-05-09 11:56:54 +00:00
|
|
|
adc #7 / 2 ; Left or right half of 40-col column?
|
|
|
|
ldx #<LOWSCR ; Columns 1,3,5..79
|
|
|
|
bcs :+
|
|
|
|
.assert LOWSCR + 1 = HISCR, error
|
|
|
|
inx ; Columns 0,2,4..78
|
|
|
|
: stx switch+1
|
2006-04-06 19:51:37 +00:00
|
|
|
.endif
|
2013-05-09 11:56:54 +00:00
|
|
|
rts
|
2006-04-06 19:51:37 +00:00
|
|
|
|
|
|
|
; Move the mouse cursor y position to the value in A/X.
|
|
|
|
movey:
|
2013-05-09 11:56:54 +00:00
|
|
|
tax ; ABCDExxx
|
|
|
|
lsr ; 0ABCDExx
|
|
|
|
lsr ; 00ABCDEx
|
|
|
|
lsr ; 000ABCDE
|
|
|
|
sta getscr+1
|
|
|
|
lsr ; 0000ABCD
|
|
|
|
and #%00000011 ; 000000CD
|
|
|
|
ora #>$0400 ; 000001CD
|
|
|
|
sta getscr+2
|
|
|
|
sta setscr+2
|
|
|
|
txa ; ABCDExxx
|
|
|
|
ror ; EABCDExx
|
|
|
|
and #%11100000 ; EAB00000
|
|
|
|
ora getscr+1 ; EABABCDE
|
|
|
|
and #%11111000 ; EABAB000
|
|
|
|
sta getscr+1
|
|
|
|
sta setscr+1
|
|
|
|
rts
|