1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Made Apple II CONIO more flexible.

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)!
This commit is contained in:
Oliver Schmidt 2018-08-19 23:40:50 +02:00
parent 7b8d4b28c7
commit f8c6c58373
8 changed files with 82 additions and 194 deletions

View File

@ -104,8 +104,6 @@ function.
<item>_dos_type
<item><ref id="get_ostype" name="get_ostype">
<item>rebootafterexit
<item>textframe
<item>textframexy
<item><ref id="videomode" name="videomode">
</itemize>

View File

@ -82,6 +82,9 @@
#define CH_CURS_LEFT 0x08
#define CH_CURS_RIGHT 0x15
#if !defined(__APPLE2ENH__)
#define CH_HLINE '-'
#define CH_VLINE '!'
#define CH_ULCORNER '+'
#define CH_URCORNER '+'
#define CH_LLCORNER '+'
@ -91,6 +94,7 @@
#define CH_LTEE '+'
#define CH_RTEE '+'
#define CH_CROSS '+'
#endif
/* Masks for joy_read */
#define JOY_UP_MASK 0x10

View File

@ -57,6 +57,18 @@
#define CH_CURS_UP 0x0B
#define CH_CURS_DOWN 0x0A
#define CH_HLINE 0x5F
#define CH_VLINE 0xDF
#define CH_ULCORNER 0x5F
#define CH_URCORNER 0x20
#define CH_LLCORNER 0xD4
#define CH_LRCORNER 0xDF
#define CH_TTEE 0x5F
#define CH_BTEE 0xD4
#define CH_LTEE 0xD4
#define CH_RTEE 0xDF
#define CH_CROSS 0xD4
/* These are defined to be OpenApple + NumberKey */
#define CH_F1 0xB1
#define CH_F2 0xB2
@ -69,10 +81,6 @@
#define CH_F9 0xB9
#define CH_F10 0xB0
/* Styles for textframe */
#define TEXTFRAME_WIDE 0x00
#define TEXTFRAME_TALL 0x04
/* Video modes */
#define VIDEOMODE_40x24 0x0011
#define VIDEOMODE_80x24 0x0012
@ -103,17 +111,6 @@ extern void a2e_lo_tgi[];
void __fastcall__ textframe (unsigned char width, unsigned char height,
unsigned char style);
/* Output a frame on the text screen with the given width and height
** starting at the current cursor position and using the given style.
*/
void __fastcall__ textframexy (unsigned char x, unsigned char y,
unsigned char width, unsigned char height,
unsigned char style);
/* Same as "gotoxy (x, y); textframe (width, height, style);" */
unsigned __fastcall__ videomode (unsigned mode);
/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx
** constants.

View File

@ -18,12 +18,10 @@ _chlinexy:
_chline:
.ifdef __APPLE2ENH__
ldx #'S' ; MouseText character
ldy INVFLG
cpy #$FF ; Normal character display mode?
beq chlinedirect
ldx #'_' | $80 ; Underscore, screen code
.else
ldx #'-' | $80 ; Minus, screen code
.endif
ldx #'-' | $80 ; Horizontal line, screen code
chlinedirect:
stx tmp1

View File

@ -37,7 +37,7 @@ _cputc:
beq left
cmp #$0A ; Test for \n = line feed
beq newline
ora #$80 ; Turn on high bit
eor #$80 ; Invert high bit
.ifndef __APPLE2ENH__
cmp #$E0 ; Test for lowercase
bcc cputdirect

View File

@ -5,7 +5,7 @@
; void __fastcall__ cvline (unsigned char length);
;
.export _cvlinexy, _cvline, cvlinedirect
.export _cvlinexy, _cvline
.import gotoxy, putchar, newline
.include "zeropage.inc"
@ -17,12 +17,11 @@ _cvlinexy:
_cvline:
.ifdef __APPLE2ENH__
ldx #'|' | $80 ; Vertical line, screen code
ldx #$5F ; Left vertical line MouseText character
.else
ldx #'!' | $80 ; Vertical line, screen code
ldx #'!' | $80 ; Exclamation mark, screen code
.endif
cvlinedirect:
stx tmp1
cmp #$00 ; Is the length zero?
beq done ; Jump if done

View File

@ -36,7 +36,7 @@ _mouse_def_callbacks:
.data
.ifdef __APPLE2ENH__
cursor = 'B' ; MouseText character
cursor = $42 ; Pointer MouseText character
.else
cursor = '+' | $40 ; Flashing crosshair
.endif

View File

@ -1,108 +0,0 @@
;
; Oliver Schmidt, 10.03.2004
;
; void __fastcall__ textframexy (unsigned char x, unsigned char y,
; unsigned char width, unsigned char height,
; unsigned char style);
; void __fastcall__ textframe (unsigned char width, unsigned char height,
; unsigned char style);
;
.ifdef __APPLE2ENH__
.export _textframexy, _textframe
.import popa, pusha, _gotoxy
.import chlinedirect, cvlinedirect
.include "zeropage.inc"
.include "apple2.inc"
WIDTH = ptr1
HEIGHT = ptr1+1
XORIGIN = ptr2
YORIGIN = ptr2+1
_textframexy:
sec
bra :+
_textframe:
clc
: ldx INVFLG
phx ; Save character display mode
ldx #$FF
stx INVFLG ; Set normal character display mode
pha ; Save index
jsr popa ; Get height
sta HEIGHT
jsr popa ; Get width
sta WIDTH
lda CH
ldx CV
bcc noxy
jsr popa ; Get y
tax
jsr popa ; Get x
noxy: sta XORIGIN
stx YORIGIN
plx ; Restore index
loop: lda XOFFS,x
clc
bpl :+ ; Relative to left edge?
adc WIDTH
: adc XORIGIN
jsr pusha
lda YOFFS,x
clc
bpl :+ ; Relative to top?
adc HEIGHT
: adc YORIGIN
jsr _gotoxy ; Call this one, will pop params
txa
tay
lsr ; Get bit 0 (vline) into carry
lda LENGTH,x
phx ; Save index
ldx CHAR,y
bcc hline
clc
adc HEIGHT
jsr cvlinedirect
bra next
hline: adc WIDTH
jsr chlinedirect
next: plx ; Restore index
inx
txa
and #$03 ; Mask style
bne loop
pla
sta INVFLG ; Restore character display mode
rts
.rodata
; 2 styles with 4 lines each make up 8 entries per table
; - even entry numbers mean horizontal lines
; - odd entry numbers mean vertical lines
; x offset for the line starting point
; - a positive value means relative to the frame left edge
; - a negative value menas relative to the frame right edge
XOFFS: .byte 0, 0, 0, <-2, 1, 0, 1, <-2
; y offset for the line starting point
; - a positive value means relative to the frame top
; - a negative value menas relative to the frame bottom
YOFFS: .byte 0, 1, <-2, 1, 0, 0, <-2, 0
; length of the line relative to the frame size
; - a negative value for hlines means shorter than the width
; - a negative value for vlines menas shorter than the height
LENGTH: .byte 0, <-2, 0, <-2, <-2, 0, <-2, 0
; character to use for drawing the line
; - hibit set means normal printable character
; - hibit clear means MouseText character
CHAR: .byte '_'|$80, '_', 'L', 'Z', 'L', 'Z', '_'|$80, '_'
.endif ; __APPLE2ENH__