Skip to content

Commit d206d1c

Browse files
committed
Use loadable TGI driver
The first TGI driver found on disk will be used. To use low-res mode, delete the TGI-VDCHI driver.
1 parent 44f2803 commit d206d1c

File tree

7 files changed

+111
-158
lines changed

7 files changed

+111
-158
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,8 @@ dist-c128: $(PROGRAM).c128
360360
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-joy.mou mou-joy
361361
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-pot.mou mou-pot
362362
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-swlink.ser ser-swlink
363+
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-vdc2.tgi tgi-vdchi
364+
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-vdc.tgi tgi-vdclo
363365
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/splash.bin splash.bin
364366

365367
dist-apple2: $(PROGRAM).apple2

dist.c128/c128-vdc.tgi

1.98 KB
Binary file not shown.

dist.c128/c128-vdc2.tgi

2.01 KB
Binary file not shown.

src/c128/font.c

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44

55
#include <stdint.h>
66

7-
#ifdef __C128_HIRES__
8-
97
uint8_t FONT_SIZE_X=8;
10-
uint8_t FONT_SIZE_Y=15; // Last line not used, for now
8+
uint8_t FONT_SIZE_Y_400=15; // Last line not used, for now
119

12-
uint8_t font[]={
10+
uint8_t font_400[]={
1311
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x20 space */
1412
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1513

@@ -494,12 +492,9 @@ uint8_t font[]={
494492

495493
uint8_t fontm23[2048];
496494

497-
#else
498-
499-
uint8_t FONT_SIZE_X=8;
500-
uint8_t FONT_SIZE_Y=6;
495+
uint8_t FONT_SIZE_Y_200=6;
501496

502-
uint8_t font[]={
497+
uint8_t font_200[]={
503498
0x00,0x00,0x00,0x00,0x00,0x00, /* SPACE 0x20 */
504499
0x08,0x08,0x08,0x00,0x08,0x00, /* ! 0x21 */
505500
0x24,0x24,0x00,0x00,0x00,0x00, /* " 0x22 */
@@ -662,7 +657,3 @@ uint8_t font[]={
662657
0x00,0x00,0x00,0x00,0x00,0x00,
663658
0x00,0x00,0x00,0x00,0x00,0x00
664659
};
665-
666-
uint8_t fontm23[768];
667-
668-
#endif

src/c128/scale.c

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -9,75 +9,6 @@
99

1010
#include <stdint.h>
1111

12-
#ifdef __C128_HIRES__
13-
14-
/* X and Y tables used to scale 512x512 PLATO display to 640x480 */
15-
unsigned short scalex[]={
16-
64,65,66,67,68,69,70,71,
17-
72,73,74,75,76,77,78,79,
18-
80,81,82,83,84,85,86,87,
19-
88,89,90,91,92,93,94,95,
20-
96,97,98,99,100,101,102,103,
21-
104,105,106,107,108,109,110,111,
22-
112,113,114,115,116,117,118,119,
23-
120,121,122,123,124,125,126,127,
24-
128,129,130,131,132,133,134,135,
25-
136,137,138,139,140,141,142,143,
26-
144,145,146,147,148,149,150,151,
27-
152,153,154,155,156,157,158,159,
28-
160,161,162,163,164,165,166,167,
29-
168,169,170,171,172,173,174,175,
30-
176,177,178,179,180,181,182,183,
31-
184,185,186,187,188,189,190,191,
32-
192,193,194,195,196,197,198,199,
33-
200,201,202,203,204,205,206,207,
34-
208,209,210,211,212,213,214,215,
35-
216,217,218,219,220,221,222,223,
36-
224,225,226,227,228,229,230,231,
37-
232,233,234,235,236,237,238,239,
38-
240,241,242,243,244,245,246,247,
39-
248,249,250,251,252,253,254,255,
40-
256,257,258,259,260,261,262,263,
41-
264,265,266,267,268,269,270,271,
42-
272,273,274,275,276,277,278,279,
43-
280,281,282,283,284,285,286,287,
44-
288,289,290,291,292,293,294,295,
45-
296,297,298,299,300,301,302,303,
46-
304,305,306,307,308,309,310,311,
47-
312,313,314,315,316,317,318,319,
48-
320,321,322,323,324,325,326,327,
49-
328,329,330,331,332,333,334,335,
50-
336,337,338,339,340,341,342,343,
51-
344,345,346,347,348,349,350,351,
52-
352,353,354,355,356,357,358,359,
53-
360,361,362,363,364,365,366,367,
54-
368,369,370,371,372,373,374,375,
55-
376,377,378,379,380,381,382,383,
56-
384,385,386,387,388,389,390,391,
57-
392,393,394,395,396,397,398,399,
58-
400,401,402,403,404,405,406,407,
59-
408,409,410,411,412,413,414,415,
60-
416,417,418,419,420,421,422,423,
61-
424,425,426,427,428,429,430,431,
62-
432,433,434,435,436,437,438,439,
63-
440,441,442,443,444,445,446,447,
64-
448,449,450,451,452,453,454,455,
65-
456,457,458,459,460,461,462,463,
66-
464,465,466,467,468,469,470,471,
67-
472,473,474,475,476,477,478,479,
68-
480,481,482,483,484,485,486,487,
69-
488,489,490,491,492,493,494,495,
70-
496,497,498,499,500,501,502,503,
71-
504,505,506,507,508,509,510,511,
72-
512,513,514,515,516,517,518,519,
73-
520,521,522,523,524,525,526,527,
74-
528,529,530,531,532,533,534,535,
75-
536,537,538,539,540,541,542,543,
76-
544,545,546,547,548,549,550,551,
77-
552,553,554,555,556,557,558,559,
78-
560,561,562,563,564,565,566,567,
79-
568,569,570,571,572,573,574,575,
80-
};
8112

8213
unsigned short scaley[]={
8314
479,478,477,476,475,474,473,472,
@@ -145,5 +76,3 @@ unsigned short scaley[]={
14576
14,13,12,11,10,9,8,7,
14677
6,5,4,3,2,1,0,0,
14778
};
148-
149-
#endif

src/c128/screen.c

Lines changed: 54 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,46 @@
1313
#include <tgi.h>
1414
#include <stdint.h>
1515
#include <stdlib.h>
16+
#include <stdio.h>
1617
#include "../config.h"
1718
#include "../protocol.h"
1819
#include "../screen.h"
1920

2021
extern uint8_t pal[2];
2122
extern ConfigInfo config;
2223

23-
#ifdef __C128_HIRES__
2424
extern unsigned short scalex[];
2525
extern unsigned short scaley[];
26-
#define SCALEX(x) (scalex[x])
27-
#define SCALEY(y) (scaley[y])
28-
#define FONTPTR(a) (a<<4)
29-
#else
26+
27+
#define SCALEX(x) (x+64)
28+
#define SCALEY(y) scaley[y]
29+
3030
extern uint16_t mul0375(uint16_t val);
31-
#define SCALEX(x) (x+24)
32-
#define SCALEY(y) (mul0375(y ^ 0x01ff))
33-
#define FONTPTR(a) (((a << 1) + a) << 1)
34-
#endif
31+
#define FONTPTR_200(a) (((a << 1) + a) << 1)
32+
#define FONTPTR_400(a) (a<<4)
33+
34+
#define FONTPTR(a) ((vdcmode == VDC_LORES) ? FONTPTR_200(a) : FONTPTR_400(a))
3535

36-
extern uint8_t font[];
36+
extern uint8_t font_200[];
37+
extern uint8_t font_400[];
3738
extern uint8_t fontm23[];
3839
extern uint8_t FONT_SIZE_X;
39-
extern uint8_t FONT_SIZE_Y;
40-
extern padBool FastText; /* protocol.c */
41-
extern padPt TTYLoc;
40+
extern uint8_t FONT_SIZE_Y_200;
41+
extern uint8_t FONT_SIZE_Y_400;
42+
43+
uint8_t * font;
44+
uint8_t FONT_SIZE_Y;
45+
46+
#define VDC_LORES 0
47+
#define VDC_HIRES 1
48+
uint8_t vdcmode;
49+
4250
extern uint8_t CharWide;
4351
extern uint8_t CharHigh;
4452

53+
extern padBool FastText; /* protocol.c */
54+
extern padPt TTYLoc;
55+
4556
extern void (*io_recv_serial_flow_on)(void);
4657
extern void (*io_recv_serial_flow_off)(void);
4758

@@ -65,11 +76,36 @@ void screen_init_hook(void)
6576
*/
6677
void screen_load_driver(void)
6778
{
68-
#ifdef __C128_HIRES__
69-
tgi_install(&c128_vdc2_tgi);
70-
#else
71-
tgi_install(&c128_vdc_tgi);
72-
#endif
79+
uint16_t i;
80+
81+
tgi_load_driver("tgi-vdc*");
82+
if (tgi_geterror()) {
83+
puts("Unable to load a TGI driver; exiting...\r\n");
84+
exit(1);
85+
}
86+
87+
switch (tgi_getyres()) {
88+
case 480:
89+
vdcmode = VDC_HIRES;
90+
font = font_400;
91+
FONT_SIZE_Y = FONT_SIZE_Y_400;
92+
break;
93+
case 200:
94+
vdcmode = VDC_LORES;
95+
font = font_200;
96+
FONT_SIZE_Y = FONT_SIZE_Y_200;
97+
98+
// Overwrite default hi-res Y scale table with low-res one
99+
for (i = 0; i < 512; i++){
100+
scaley[i] = mul0375(i ^ 0x01ff);
101+
}
102+
break;
103+
default:
104+
tgi_unload();
105+
printf("Unknown Y resolution %d; exiting...\r\n", tgi_getyres());
106+
exit(1);
107+
break;
108+
}
73109
}
74110

75111
/**

src/c128/terminal_char_load.c

Lines changed: 51 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -11,80 +11,75 @@
1111
#include "../terminal.h"
1212
#include "../protocol.h"
1313

14-
#ifdef __C128_HIRES__
14+
static unsigned char char_data[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
15+
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1516

16-
static unsigned char BTAB[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; // flip one bit on (OR)
17+
static unsigned char BTAB[] = {0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01}; // flip one bit on (OR)
1718
static unsigned char u;
1819
static unsigned char curr_word;
1920

20-
extern unsigned char fontm23[768];
21+
#define VDC_LORES 0
22+
#define VDC_HIRES 1
23+
extern uint8_t vdcmode;
2124

22-
#define FONTPTR(a) (a<<4)
25+
extern unsigned char fontm23[2048];
26+
27+
#define FONTPTR_200(a) (((a << 1) + a) << 1)
28+
#define FONTPTR_400(a) (a << 4)
29+
30+
#define FONTPTR(a) ((vdcmode == VDC_LORES) ? FONTPTR_200(a) : FONTPTR_400(a))
2331

2432
/**
2533
* terminal_char_load - Store a character into the user definable
2634
* character set.
2735
*/
28-
void terminal_char_load(padWord charnum, charData theChar)
36+
void terminal_char_load(padWord charNum, charData theChar)
2937
{
30-
// clear char data
31-
memset(&fontm23[FONTPTR(charnum)],0,16);
32-
33-
// Transpose character data
34-
for (curr_word=0;curr_word<8;curr_word++)
38+
switch (vdcmode)
39+
{
40+
case VDC_HIRES:
41+
// clear char data
42+
memset(&fontm23[FONTPTR(charNum)], 0, 16);
43+
44+
// Transpose character data
45+
for (curr_word = 0; curr_word < 8; curr_word++)
3546
{
36-
for (u=16; u-->0; )
37-
{
38-
if (theChar[curr_word] & 1<<u)
39-
{
40-
fontm23[FONTPTR(charnum)+u^0x0f&0x0f]|=BTAB[curr_word];
41-
}
42-
}
47+
for (u = 16; u-- > 0;)
48+
{
49+
if (theChar[curr_word] & 1 << u)
50+
{
51+
fontm23[FONTPTR(charNum) + u ^ 0x0f & 0x0f] |= BTAB[curr_word];
52+
}
53+
}
4354
}
4455

45-
// and...that's it, really. :)
46-
47-
}
48-
49-
#else
50-
51-
static unsigned char char_data[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
52-
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
53-
54-
static unsigned char BTAB[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; // flip one bit on (OR)
56+
// and...that's it, really. :)
5557

56-
static unsigned char curr_word; // current word
57-
static unsigned char u; // loop counter
58+
break;
5859

59-
extern unsigned char fontm23[768];
60-
61-
/**
62-
* terminal_char_load - Store a character into the user definable
63-
* character set.
64-
*/
65-
void terminal_char_load(padWord charNum, charData theChar)
66-
{
67-
// Clear char data.
68-
memset(char_data,0,sizeof(char_data));
60+
case VDC_LORES:
61+
// Clear char data.
62+
memset(char_data, 0, sizeof(char_data));
6963

70-
// load and transpose character data into 8x16 array
71-
for (curr_word=0; curr_word<8; curr_word++)
64+
// load and transpose character data into 8x16 array
65+
for (curr_word = 0; curr_word < 8; curr_word++)
7266
{
73-
for (u=16; u-->0; )
74-
{
75-
if (theChar[curr_word] & 1<<u)
76-
{
77-
char_data[u^0x0F&0x0F]|=BTAB[curr_word];
78-
}
79-
}
67+
for (u = 16; u-- > 0;)
68+
{
69+
if (theChar[curr_word] & 1 << u)
70+
{
71+
char_data[u ^ 0x0F & 0x0F] |= BTAB[curr_word];
72+
}
73+
}
8074
}
8175

82-
// OR pixel rows together from 16 to 6 rows
83-
fontm23[(charNum*6)+0]=char_data[0]|char_data[1]|char_data[2];
84-
fontm23[(charNum*6)+1]=char_data[3]|char_data[4];
85-
fontm23[(charNum*6)+2]=char_data[5]|char_data[6]|char_data[7];
86-
fontm23[(charNum*6)+3]=char_data[8]|char_data[9];
87-
fontm23[(charNum*6)+4]=char_data[10]|char_data[11]|char_data[12];
88-
fontm23[(charNum*6)+5]=char_data[13]|char_data[14]|char_data[15];
76+
// OR pixel rows together from 16 to 6 rows
77+
fontm23[(charNum * 6) + 0] = char_data[0] | char_data[1] | char_data[2];
78+
fontm23[(charNum * 6) + 1] = char_data[3] | char_data[4];
79+
fontm23[(charNum * 6) + 2] = char_data[5] | char_data[6] | char_data[7];
80+
fontm23[(charNum * 6) + 3] = char_data[8] | char_data[9];
81+
fontm23[(charNum * 6) + 4] = char_data[10] | char_data[11] | char_data[12];
82+
fontm23[(charNum * 6) + 5] = char_data[13] | char_data[14] | char_data[15];
83+
break;
84+
}
8985
}
90-
#endif

0 commit comments

Comments
 (0)