mirror of
https://github.com/cc65/cc65.git
synced 2024-09-09 23:54:45 +00:00
Originally the Apple II had a 64 char set and used the upper two bits to control inverse and blinking. The Apple //e brought then an alternate char set without blinking but more individual chars. However, it does _not_ contain 128 chars and use the upper bit to control inverse as one would assume. Rather it contains more than 128 chars - the MouseText chars. And because Apple wanted to provide as much backward compatibility as possible with the original char set, the alternate char set has a rather weird layout for chars > 128 with the inverse lowercase chars _not_ at (normal lowercase char + 128). So far the Apple II CONIO implementation mapped chars 128-255 to chars 0-127 (with the exception of \r and \n). It made use of alternate chars > 128 transparently for the user via reverse(1). The user didn't have direct access to the MouseText chars, they were only used interally for things like chline() and cvline(). Now the mapping of chars 128-255 to 0-127 is removed. Using chars > 128 gives the user direct access to the "raw" alternate chars > 128. This especially give the use direct access to the MouseText chars. But this clashes with the exsisting (and still desirable) revers(1) logic. Combining reverse(1) with chars > 128 just doesn't result in anything usable! What motivated this change? When I worked on the VT100 line drawing support for Telnet65 on the Apple //e (not using CONIO at all) I finally understood how MouseText is intended to be used to draw arbitrary grids with just three chars: A special "L" type char, the underscore and a vertical bar at the left side of the char box. I notice that with those chars it is possible to follow the CONIO approach to boxes and grids: Combining chline()/cvline() with special CH_... char constants for edges and intersections. But in order to actually do so I needed to be able to define CH_... constants that when fed into the ordinary cputc() pipeline end up as MouseText chars. The obvious approach was to allow chars > 128 to directly access MouseText chars :-) Now that the native CONIO box/grid approach works I deleted the Apple //e proprietary textframe() function that I added as replacement quite some years ago. Again: Please note that chline()/cvline() and the CH... constants don't work with reverse(1)!
141 lines
3.9 KiB
ArmAsm
141 lines
3.9 KiB
ArmAsm
;
|
|
; Default mouse callbacks for the Apple II
|
|
;
|
|
; Oliver Schmidt, 22.09.2005
|
|
;
|
|
; All functions in this module should be interrupt safe, because they may
|
|
; be called from an interrupt handler
|
|
;
|
|
|
|
.export _mouse_def_callbacks
|
|
|
|
.include "apple2.inc"
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
.bss
|
|
|
|
backup: .res 1
|
|
visible:.res 1
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
.rodata
|
|
|
|
; Callback structure
|
|
_mouse_def_callbacks:
|
|
.addr hide
|
|
.addr show
|
|
.addr prep
|
|
.addr draw
|
|
.addr movex
|
|
.addr movey
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
.data
|
|
|
|
.ifdef __APPLE2ENH__
|
|
cursor = $42 ; Pointer MouseText character
|
|
.else
|
|
cursor = '+' | $40 ; Flashing crosshair
|
|
.endif
|
|
|
|
getcursor:
|
|
.ifdef __APPLE2ENH__
|
|
bit RD80VID ; In 80 column mode?
|
|
bpl column ; No, skip bank switching
|
|
switch: bit LOWSCR ; Patched at runtime
|
|
.endif
|
|
column: ldx #$00 ; Patched at runtime
|
|
getscr: lda $0400,x ; Patched at runtime
|
|
cmp #cursor
|
|
rts
|
|
|
|
setcursor:
|
|
lda #cursor
|
|
setscr: sta $0400,x ; Patched at runtime
|
|
.ifdef __APPLE2ENH__
|
|
bit LOWSCR ; Doesn't hurt in 40 column mode
|
|
.endif
|
|
rts
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
.code
|
|
|
|
done:
|
|
.ifdef __APPLE2ENH__
|
|
bit LOWSCR ; Doesn't hurt in 40 column mode
|
|
.endif
|
|
return: rts
|
|
|
|
; Hide the mouse cursor.
|
|
hide:
|
|
dec visible
|
|
; Fall through
|
|
|
|
; Prepare to move the mouse cursor.
|
|
prep:
|
|
jsr getcursor ; Cursor visible at current position?
|
|
bne done ; No, we're done
|
|
lda backup ; Get character at cursor position
|
|
jmp setscr ; Draw character
|
|
|
|
; Show the mouse cursor.
|
|
show:
|
|
inc visible
|
|
; Fall through
|
|
|
|
; Draw the mouse cursor.
|
|
draw:
|
|
lda visible
|
|
beq return
|
|
jsr getcursor ; Cursor visible at current position?
|
|
beq done ; Yes, we're done
|
|
sta backup ; Save character at cursor position
|
|
jmp setcursor ; Draw cursor
|
|
|
|
; Move the mouse cursor x position to the value in A/X.
|
|
movex:
|
|
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
|
|
.ifdef __APPLE2ENH__
|
|
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
|
|
.endif
|
|
rts
|
|
|
|
; Move the mouse cursor y position to the value in A/X.
|
|
movey:
|
|
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
|