From 816666615b6e407ddbd924ee1ee5afaeb314b1b1 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Tue, 27 May 2025 16:31:23 +0200 Subject: [PATCH] Apple2: Make 80-columns support dynamic on apple2 target Add a machinetype identifier to help us quickly identify Apple //e (bit 7) and //e enhanced (bit 6). Use it in conio functions for 80-columns code instead of relying entirely on the __APPLE2ENH__ target. Move videomode() to the apple2 target, and have it return an error if 80-columns hardware is not available - this is a lie for now, it is considered available on //e enhanced, which may not be true, and not available on //e, which may also be not true. An ulterior patch will make that check correctly. Adapt the box/line drawing characters so that one can use MouseText on the apple2 target if it is available, by defining DYN_DRAW_BOX. No change by default: MouseText is considered available on apple2enh and not available on apple2. --- doc/apple2.sgml | 5 ++ doc/funcref.sgml | 12 +++-- include/apple2.h | 72 ++++++++++++++++++++++++- include/apple2enh.h | 23 -------- include/conio.h | 13 ++++- libsrc/apple2/boxchars.s | 73 ++++++++++++++++++++++++++ libsrc/apple2/cgetc.s | 13 +++-- libsrc/apple2/cpeekc.s | 19 +++++-- libsrc/apple2/cputc.s | 60 +++++++++++++++------ libsrc/apple2/dynchline.s | 41 +++++++++++++++ libsrc/apple2/dyncvline.s | 40 ++++++++++++++ libsrc/apple2/get_ostype.s | 2 + libsrc/apple2/gotoxy.s | 14 +++-- libsrc/apple2/libref.s | 3 +- libsrc/apple2/machinetype.s | 24 +++++++++ libsrc/apple2/mcbdefault.s | 19 ++++--- libsrc/apple2/{chline.s => mtchline.s} | 19 +++---- libsrc/apple2/{cvline.s => mtcvline.s} | 24 ++++----- libsrc/apple2/tgi/a2.hi.s | 37 ++++++++++--- libsrc/apple2/tgiref.s | 18 +++++++ libsrc/apple2/videomode.s | 39 ++++++++++---- libsrc/apple2/wherex.s | 13 +++-- targettest/conio.c | 47 +++++++++++++++++ 23 files changed, 523 insertions(+), 107 deletions(-) create mode 100644 libsrc/apple2/boxchars.s create mode 100644 libsrc/apple2/dynchline.s create mode 100644 libsrc/apple2/dyncvline.s create mode 100644 libsrc/apple2/machinetype.s rename libsrc/apple2/{chline.s => mtchline.s} (68%) rename libsrc/apple2/{cvline.s => mtcvline.s} (57%) create mode 100644 libsrc/apple2/tgiref.s diff --git a/doc/apple2.sgml b/doc/apple2.sgml index 9cff996b7..719e799f4 100644 --- a/doc/apple2.sgml +++ b/doc/apple2.sgml @@ -361,6 +361,7 @@ usage. rebootafterexit ser_apple2_slot tgi_apple2_mix +videomode @@ -406,6 +407,10 @@ The names in the parentheses denote the symbols to be used for static linking of with rebootafterexit + @@ -8477,24 +8478,27 @@ used in presence of a prototype. , , , / unsigned __fastcall__ videomode (unsigned Mode); /* for apple2enh and c128 */ -signed char __fastcall__ videomode (signed char Mode); /* for cx16 */ +unsigned __fastcall__ videomode (unsigned Mode); /* for c128 */ +signed char __fastcall__ videomode (signed char Mode); /* for apple2 and cx16 */ -The function is specific to the Commodore 128, the enhanced Apple //e, +The function is specific to the Commodore 128, the Apple II, and the Commander X16. This function replaces . The function is available as only a fastcall function, so it may be used only in the presence of a prototype. +On Apple II, this functions returns the previously active video mode, or -1 +if the mode is not supported due to lack of hardware. -, , diff --git a/include/apple2.h b/include/apple2.h index 9f7526f59..e4c8d89b1 100644 --- a/include/apple2.h +++ b/include/apple2.h @@ -83,7 +83,57 @@ #define CH_CURS_LEFT 0x08 #define CH_CURS_RIGHT 0x15 -#if !defined(__APPLE2ENH__) +#if defined(__APPLE2ENH__) + +/* MouseText-based functions for boxes and lines drawing */ +void mt_chline (unsigned char length); +void mt_cvline (unsigned char length); +void mt_chlinexy (unsigned char x, unsigned char y, unsigned char length); +void mt_cvlinexy (unsigned char x, unsigned char y, unsigned char length); + +#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 + +#define _chline(length) mt_chline(length) +#define _chlinexy(x,y,length) mt_chlinexy(x,y,length) +#define _cvline(length) mt_cvline(length) +#define _cvlinexy(x,y,length) mt_cvlinexy(x,y,length) + +#else + +/* Functions that don't depend on MouseText to draw boxes and lines */ +void dyn_chline (unsigned char h, unsigned char length); +void dyn_cvline (unsigned char v, unsigned char length); +void dyn_chlinexy (unsigned char h, unsigned char x, unsigned char y, unsigned char length); +void dyn_cvlinexy (unsigned char v, unsigned char x, unsigned char y, unsigned char length); + +#if defined(DYN_BOX_DRAW) +/* When the user defines DYN_BOX_DRAW, we'll adapt to the machine +** we run on. + */ +extern char CH_HLINE; +extern char CH_VLINE; +extern char CH_ULCORNER; +extern char CH_URCORNER; +extern char CH_LLCORNER; +extern char CH_LRCORNER; +extern char CH_TTEE; +extern char CH_BTEE; +extern char CH_LTEE; +extern char CH_RTEE; +extern char CH_CROSS; + +#else +/* Otherwise, fallback to safety and don't use MouseText at all. */ #define CH_HLINE '-' #define CH_VLINE '!' #define CH_ULCORNER '+' @@ -95,7 +145,14 @@ #define CH_LTEE '+' #define CH_RTEE '+' #define CH_CROSS '+' -#endif +#endif /* DYN_BOX_DRAW */ + +#define _chline(length) dyn_chline(CH_HLINE, length) +#define _chlinexy(x, y, length) dyn_chlinexy(CH_HLINE, x ,y, length) +#define _cvline(length) dyn_cvline(CH_VLINE, length) +#define _cvlinexy(x, y, length) dyn_cvlinexy(CH_VLINE, x, y, length) + +#endif /* __APPLE2ENH__ */ /* Masks for joy_read */ #define JOY_UP_MASK 0x10 @@ -127,6 +184,12 @@ #define TV_PAL 1 #define TV_OTHER 2 +/* Video modes */ +#define VIDEOMODE_40x24 0x15 +#define VIDEOMODE_80x24 0x00 +#define VIDEOMODE_40COL VIDEOMODE_40x24 +#define VIDEOMODE_80COL VIDEOMODE_80x24 + extern unsigned char _dos_type; /* Valid _dos_type values: ** @@ -255,6 +318,11 @@ unsigned char __fastcall__ allow_lowercase (unsigned char onoff); */ #endif +signed char __fastcall__ videomode (unsigned mode); +/* Set the video mode, return the old mode, or -1 if 80-column hardware is not +** installed. Call with one of the VIDEOMODE_xx constants. +*/ + /* End of apple2.h */ diff --git a/include/apple2enh.h b/include/apple2enh.h index 864d24986..1dc75ae13 100644 --- a/include/apple2enh.h +++ b/include/apple2enh.h @@ -57,18 +57,6 @@ #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 @@ -81,12 +69,6 @@ #define CH_F9 0xB9 #define CH_F10 0xB0 -/* Video modes */ -#define VIDEOMODE_40x24 0x15 -#define VIDEOMODE_80x24 0x00 -#define VIDEOMODE_40COL VIDEOMODE_40x24 -#define VIDEOMODE_80COL VIDEOMODE_80x24 - /*****************************************************************************/ @@ -112,11 +94,6 @@ extern void a2e_lo_tgi[]; -unsigned __fastcall__ videomode (unsigned mode); -/* Set the video mode, return the old mode. Call with one of the VIDEOMODE_xx -** constants. -*/ - void waitvsync (void); /* Wait for start of next frame */ diff --git a/include/conio.h b/include/conio.h index bac20e3c5..cf84d1742 100644 --- a/include/conio.h +++ b/include/conio.h @@ -216,7 +216,18 @@ void __fastcall__ cputhex16 (unsigned val); # define cpeekrevers() _cpeekrevers() #endif - +#ifdef _chline +# define chline(len) _chline(len) +#endif +#ifdef _cvline +# define cvline(len) _cvline(len) +#endif +#ifdef _chlinexy +# define chlinexy(x, y, len) _chlinexy(x, y, len) +#endif +#ifdef _cvlinexy +# define cvlinexy(x, y, len) _cvlinexy(x, y, len) +#endif /* End of conio.h */ #endif diff --git a/libsrc/apple2/boxchars.s b/libsrc/apple2/boxchars.s new file mode 100644 index 000000000..8feee3bd3 --- /dev/null +++ b/libsrc/apple2/boxchars.s @@ -0,0 +1,73 @@ +; +; Colin Leroy-Mira and Oliver Schmidt, 26.05.2025 +; +; Initialize box-drawing characters according to +; MouseText availability +; + +.ifndef __APPLE2ENH__ + + .constructor initboxchars + .import machinetype + + .export _CH_HLINE + .export _CH_VLINE + .export _CH_ULCORNER + .export _CH_URCORNER + .export _CH_LLCORNER + .export _CH_LRCORNER + .export _CH_TTEE + .export _CH_BTEE + .export _CH_LTEE + .export _CH_RTEE + .export _CH_CROSS + + .segment "ONCE" + +initboxchars: + bit machinetype ; IIe enhanced or newer? + bvs out + + ldx #NUM_BOXCHARS ; No mousetext, patch characters +: lda std_boxchars,x + sta boxchars,x + dex + bpl :- + +out: rts + +; Replacement chars for when MouseText is not available +std_boxchars: .byte '!' + .byte '-' + .byte '+' + .byte '+' + .byte '+' + .byte '+' + + .data + +; MouseText-based box characters +boxchars: +VERT: .byte $DF +HORIZ: .byte $5F +ULCORNER: .byte $5F +URCORNER: .byte $20 +LLCORNER: .byte $D4 +LRCORNER: .byte $DF + +NUM_BOXCHARS = *-boxchars + +; exported symbols, referencing our 6 bytes +_CH_HLINE = HORIZ +_CH_VLINE = VERT +_CH_ULCORNER = ULCORNER +_CH_URCORNER = URCORNER +_CH_LLCORNER = LLCORNER +_CH_LRCORNER = LRCORNER +_CH_TTEE = ULCORNER +_CH_BTEE = LLCORNER +_CH_LTEE = LLCORNER +_CH_RTEE = LRCORNER +_CH_CROSS = LLCORNER + +.endif ; not __APPLE2ENH__ diff --git a/libsrc/apple2/cgetc.s b/libsrc/apple2/cgetc.s index d2ebe5db8..b82238b02 100644 --- a/libsrc/apple2/cgetc.s +++ b/libsrc/apple2/cgetc.s @@ -7,6 +7,10 @@ ; .export _cgetc + + .ifndef __APPLE2ENH__ + .import machinetype + .endif .import cursor, putchardirect .include "zeropage.inc" @@ -18,11 +22,14 @@ _cgetc: beq :+ ; Show caret. - .ifdef __APPLE2ENH__ - lda #$7F | $80 ; Checkerboard, screen code - .else + .ifndef __APPLE2ENH__ lda #' ' | $40 ; Blank, flashing + bit machinetype + bpl put_caret .endif + + lda #$7F | $80 ; Checkerboard, screen code +put_caret: jsr putchardirect ; Saves old character in tmp3 ; Wait for keyboard strobe. diff --git a/libsrc/apple2/cpeekc.s b/libsrc/apple2/cpeekc.s index a6a082eab..4f5361461 100644 --- a/libsrc/apple2/cpeekc.s +++ b/libsrc/apple2/cpeekc.s @@ -4,14 +4,24 @@ ; char cpeekc (void); ; + .ifndef __APPLE2ENH__ + .import machinetype + .endif + .export _cpeekc .include "apple2.inc" _cpeekc: ldy CH - .ifdef __APPLE2ENH__ + sec ; Assume main memory + + .ifndef __APPLE2ENH__ + bit machinetype + bpl peek + .endif + bit RD80VID ; In 80 column mode? bpl peek ; No, just go ahead lda OURCH @@ -21,13 +31,12 @@ _cpeekc: php sei ; No valid MSLOT et al. in aux memory bit HISCR ; Assume SET80COL - .endif + peek: lda (BASL),Y ; Get character - .ifdef __APPLE2ENH__ bcs :+ ; In main memory bit LOWSCR plp -: .endif - eor #$80 ; Invert high bit + +: eor #$80 ; Invert high bit ldx #>$0000 rts diff --git a/libsrc/apple2/cputc.s b/libsrc/apple2/cputc.s index fdf799357..aa4a383b3 100644 --- a/libsrc/apple2/cputc.s +++ b/libsrc/apple2/cputc.s @@ -5,13 +5,13 @@ ; void __fastcall__ cputc (char c); ; - .ifdef __APPLE2ENH__ .constructor initconio - .endif .export _cputcxy, _cputc .export cputdirect, newline, putchar, putchardirect .import gotoxy, VTABZ + .ifndef __APPLE2ENH__ + .import machinetype .import uppercasemask .endif @@ -22,12 +22,16 @@ .segment "ONCE" - .ifdef __APPLE2ENH__ initconio: + .ifndef __APPLE2ENH__ + bit machinetype + bmi :+ + rts +: + .endif sta SETALTCHAR ; Switch in alternate charset bit LORES ; Limit SET80COL-HISCR to text rts - .endif .code @@ -52,14 +56,22 @@ _cputc: cputdirect: jsr putchar - .ifdef __APPLE2ENH__ + + .ifndef __APPLE2ENH__ + bit machinetype + bpl :+ + .endif bit RD80VID ; In 80 column mode? bpl :+ inc OURCH ; Bump to next column lda OURCH + .ifdef __APPLE2ENH__ bra check ; Must leave CH alone -: .endif - inc CH ; Bump to next column + .else + jmp check + .endif + +: inc CH ; Bump to next column lda CH check: cmp WNDWDTH bcc done @@ -67,13 +79,24 @@ check: cmp WNDWDTH left: .ifdef __APPLE2ENH__ stz CH ; Goto left edge of screen - bit RD80VID ; In 80 column mode? - bpl done - stz OURCH ; Goto left edge of screen .else - lda #$00 ; Goto left edge of screen + lda #$00 sta CH .endif + + .ifndef __APPLE2ENH__ + bit machinetype + bpl done + .endif + + bit RD80VID ; In 80 column mode? + bpl done + .ifdef __APPLE2ENH__ + stz OURCH ; Goto left edge of screen + .else + sta OURCH + .endif + done: rts newline: @@ -100,8 +123,14 @@ mask: and INVFLG ; Apply normal, inverse, flash putchardirect: tax ldy CH - .ifdef __APPLE2ENH__ + sec ; Assume main memory + + .ifndef __APPLE2ENH__ + bit machinetype + bpl put + .endif + bit RD80VID ; In 80 column mode? bpl put ; No, just go ahead lda OURCH @@ -111,14 +140,13 @@ putchardirect: php sei ; No valid MSLOT et al. in aux memory bit HISCR ; Assume SET80COL - .endif + put: lda (BASL),Y ; Get current character sta tmp3 ; Save old character for _cgetc txa sta (BASL),Y - .ifdef __APPLE2ENH__ + bcs :+ ; In main memory bit LOWSCR plp -: .endif - rts +: rts diff --git a/libsrc/apple2/dynchline.s b/libsrc/apple2/dynchline.s new file mode 100644 index 000000000..74cc5a41e --- /dev/null +++ b/libsrc/apple2/dynchline.s @@ -0,0 +1,41 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; Colin Leroy-Mira, 26.05.2025 +; +; void __fastcall__ dyn_chlinexy (unsigned char c, unsigned char x, unsigned char y, unsigned char length); +; void __fastcall__ dyn_chline (unsigned char c, unsigned char length); +; + +.ifndef __APPLE2ENH__ + + .export _dyn_chlinexy, _dyn_chline, chlinedirect + .import gotoxy, cputdirect, popa + .import machinetype + + .include "zeropage.inc" + .include "apple2.inc" + +_dyn_chlinexy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _chline + +_dyn_chline: + pha + jsr popa ; Get the character to draw + eor #$80 ; Invert high bit + tax + pla + +chlinedirect: + stx tmp1 + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp2 +: lda tmp1 ; Screen code + jsr cputdirect ; Direct output + dec tmp2 + bne :- +done: rts + +.endif diff --git a/libsrc/apple2/dyncvline.s b/libsrc/apple2/dyncvline.s new file mode 100644 index 000000000..b74126a4d --- /dev/null +++ b/libsrc/apple2/dyncvline.s @@ -0,0 +1,40 @@ +; +; Ullrich von Bassewitz, 08.08.1998 +; Colin Leroy-Mira, 26.05.2025 +; +; void __fastcall__ dyn_cvlinexy (unsigned char c, unsigned char x, unsigned char y, unsigned char length); +; void __fastcall__ dyn_cvline (unsigned char c, unsigned char length); +; + +.ifndef __APPLE2ENH__ + + .export _dyn_cvlinexy, _dyn_cvline + .import gotoxy, putchar, newline, popa + .import machinetype + + .include "zeropage.inc" + +_dyn_cvlinexy: + pha ; Save the length + jsr gotoxy ; Call this one, will pop params + pla ; Restore the length and run into _cvline + +_dyn_cvline: + pha + jsr popa ; Get the character to draw + eor #$80 ; Invert high bit + tax + pla + + stx tmp1 + cmp #$00 ; Is the length zero? + beq done ; Jump if done + sta tmp2 +: lda tmp1 ; Screen code + jsr putchar ; Write, no cursor advance + jsr newline ; Advance cursor to next line + dec tmp2 + bne :- +done: rts + +.endif diff --git a/libsrc/apple2/get_ostype.s b/libsrc/apple2/get_ostype.s index ea9ff25cc..0bd53717c 100644 --- a/libsrc/apple2/get_ostype.s +++ b/libsrc/apple2/get_ostype.s @@ -4,6 +4,8 @@ ; unsigned char get_ostype (void) ; + ; Priority higher than the default one so that things depending + ; on ostype can get ostype set when called at normal priority .constructor initostype, 9 .export _get_ostype, ostype diff --git a/libsrc/apple2/gotoxy.s b/libsrc/apple2/gotoxy.s index 2a0261eba..2ecd2a513 100644 --- a/libsrc/apple2/gotoxy.s +++ b/libsrc/apple2/gotoxy.s @@ -8,6 +8,10 @@ .export gotoxy, _gotoxy, _gotox .import popa, VTABZ + .ifndef __APPLE2ENH__ + .import machinetype + .endif + .include "apple2.inc" gotoxy: @@ -22,9 +26,13 @@ _gotoxy: _gotox: sta CH ; Store X - .ifdef __APPLE2ENH__ + + .ifndef __APPLE2ENH__ + bit machinetype + bpl :+ + .endif + bit RD80VID ; In 80 column mode? bpl :+ sta OURCH ; Store X -: .endif - rts +: rts diff --git a/libsrc/apple2/libref.s b/libsrc/apple2/libref.s index e3d713a5d..9c6994a5d 100644 --- a/libsrc/apple2/libref.s +++ b/libsrc/apple2/libref.s @@ -2,9 +2,8 @@ ; Oliver Schmidt, 2013-05-31 ; - .export em_libref, ser_libref, tgi_libref + .export em_libref, ser_libref .import _exit em_libref := _exit ser_libref := _exit -tgi_libref := _exit diff --git a/libsrc/apple2/machinetype.s b/libsrc/apple2/machinetype.s new file mode 100644 index 000000000..7fa70f29f --- /dev/null +++ b/libsrc/apple2/machinetype.s @@ -0,0 +1,24 @@ +.ifndef __APPLE2ENH__ + + .constructor initmachinetype, 8 + + .import ostype + .export machinetype + + .segment "ONCE" + +initmachinetype: + ldx ostype + cpx #$31 ; Apple //e enhanced? + ror machinetype ; Carry to high bit + cpx #$30 ; Apple //e? + ror machinetype + rts + + .data + +; bit 7: Machine is a //e or newer +; bit 6: Machine is a //e enhanced or newer +machinetype: .byte 0 + +.endif diff --git a/libsrc/apple2/mcbdefault.s b/libsrc/apple2/mcbdefault.s index 556a9d8fb..6a369114c 100644 --- a/libsrc/apple2/mcbdefault.s +++ b/libsrc/apple2/mcbdefault.s @@ -9,6 +9,10 @@ .export _mouse_def_callbacks + .ifndef __APPLE2ENH__ + .import machinetype + .endif + .include "apple2.inc" ; ------------------------------------------------------------------------ @@ -42,11 +46,14 @@ cursor = '+' | $40 ; Flashing crosshair .endif getcursor: - .ifdef __APPLE2ENH__ + .ifndef __APPLE2ENH__ + bit machinetype + bpl column + .endif 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 @@ -55,9 +62,7 @@ getscr: lda $0400,x ; Patched at runtime setcursor: lda #cursor setscr: sta $0400,x ; Patched at runtime - .ifdef __APPLE2ENH__ bit LOWSCR ; Doesn't hurt in 40 column mode - .endif rts ; ------------------------------------------------------------------------ @@ -65,9 +70,7 @@ setscr: sta $0400,x ; Patched at runtime .code done: - .ifdef __APPLE2ENH__ bit LOWSCR ; Doesn't hurt in 40 column mode - .endif return: rts ; Hide the mouse cursor. @@ -108,14 +111,14 @@ movex: inx bcs :- stx column+1 - .ifdef __APPLE2ENH__ + + ; Patch switch anyway, it will just be skipped over if in 40-col mode adc #7 / 2 ; Left or right half of 40-col column? ldx #$0000 + +: ldx #>$0000 rts diff --git a/targettest/conio.c b/targettest/conio.c index e270d3dab..09b4a9e44 100644 --- a/targettest/conio.c +++ b/targettest/conio.c @@ -9,6 +9,15 @@ * */ +/* Box drawing characters are usually constant expressions. However, there + * are scenarios where this is not the case. To ensure compatibility with + * code that assumes they are constant expressions, the scenarios in question + * must be explicitly enabled by defining DYN_BOX_DRAW. Currently, the only + * such scenario is the apple2 target. There, DYN_BOX_DRAW can be used to + * enable the use of MouseText characters on exactly those machines that + * support them. + */ +#define DYN_BOX_DRAW #include #include @@ -34,6 +43,10 @@ #define CH_VLINE '!' #endif +#if defined(DYN_BOX_DRAW) +static char grid[5][5]; +#else + static char grid[5][5] = { {CH_ULCORNER, CH_HLINE, CH_TTEE, CH_HLINE, CH_URCORNER}, {CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, @@ -41,6 +54,35 @@ static char grid[5][5] = { {CH_VLINE, ' ', CH_VLINE, ' ', CH_VLINE }, {CH_LLCORNER, CH_HLINE, CH_BTEE, CH_HLINE, CH_LRCORNER} }; +#endif + +#if defined(DYN_BOX_DRAW) +static void init_grid(void) +{ + /* Programmatically fill the array with extern chars + * instead of constants. */ + grid[0][0] = CH_ULCORNER; + grid[2][0] = CH_LTEE; + grid[4][0] = CH_LLCORNER; + + grid[0][2] = CH_TTEE; + grid[2][2] = CH_CROSS; + grid[4][2] = CH_BTEE; + + grid[0][4] = CH_URCORNER; + grid[2][4] = CH_RTEE; + grid[4][4] = CH_LRCORNER; + + grid[1][1] = grid[1][3] = + grid[3][1] = grid[3][3] = ' '; + + grid[1][0] = grid[1][2] = grid[1][4] = + grid[3][0] = grid[3][2] = grid[3][4] = CH_VLINE; + grid[0][1] = grid[0][3] = + grid[2][1] = grid[2][3] = + grid[4][1] = grid[4][3] = CH_HLINE; +} +#endif #define LINE_COLORTEST 3 #define LINE_PEEKTEST 11 @@ -152,6 +194,11 @@ void main(void) joy_install(joy_static_stddrv); #endif + +#if defined(DYN_BOX_DRAW) + init_grid(); +#endif + clrscr(); screensize(&xsize, &ysize); cputs("cc65 conio test\n\r");