Skip to content

Commit

Permalink
Use loadable TGI driver
Browse files Browse the repository at this point in the history
The first TGI driver found on disk will be used. To use low-res mode,
delete the TGI-VDCHI driver.
  • Loading branch information
rhalkyard committed Sep 19, 2019
1 parent 44f2803 commit d206d1c
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 158 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ dist-c128: $(PROGRAM).c128
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-joy.mou mou-joy
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-pot.mou mou-pot
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-swlink.ser ser-swlink
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-vdc2.tgi tgi-vdchi
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/c128-vdc.tgi tgi-vdclo
c1541 -attach dist.c128/platoterm128-1_0.d64 -write dist.c128/splash.bin splash.bin

dist-apple2: $(PROGRAM).apple2
Expand Down
Binary file added dist.c128/c128-vdc.tgi
Binary file not shown.
Binary file added dist.c128/c128-vdc2.tgi
Binary file not shown.
17 changes: 4 additions & 13 deletions src/c128/font.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@

#include <stdint.h>

#ifdef __C128_HIRES__

uint8_t FONT_SIZE_X=8;
uint8_t FONT_SIZE_Y=15; // Last line not used, for now
uint8_t FONT_SIZE_Y_400=15; // Last line not used, for now

uint8_t font[]={
uint8_t font_400[]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, /* 0x20 space */
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,

Expand Down Expand Up @@ -494,12 +492,9 @@ uint8_t font[]={

uint8_t fontm23[2048];

#else

uint8_t FONT_SIZE_X=8;
uint8_t FONT_SIZE_Y=6;
uint8_t FONT_SIZE_Y_200=6;

uint8_t font[]={
uint8_t font_200[]={
0x00,0x00,0x00,0x00,0x00,0x00, /* SPACE 0x20 */
0x08,0x08,0x08,0x00,0x08,0x00, /* ! 0x21 */
0x24,0x24,0x00,0x00,0x00,0x00, /* " 0x22 */
Expand Down Expand Up @@ -662,7 +657,3 @@ uint8_t font[]={
0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00
};

uint8_t fontm23[768];

#endif
71 changes: 0 additions & 71 deletions src/c128/scale.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,75 +9,6 @@

#include <stdint.h>

#ifdef __C128_HIRES__

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

unsigned short scaley[]={
479,478,477,476,475,474,473,472,
Expand Down Expand Up @@ -145,5 +76,3 @@ unsigned short scaley[]={
14,13,12,11,10,9,8,7,
6,5,4,3,2,1,0,0,
};

#endif
72 changes: 54 additions & 18 deletions src/c128/screen.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,46 @@
#include <tgi.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include "../config.h"
#include "../protocol.h"
#include "../screen.h"

extern uint8_t pal[2];
extern ConfigInfo config;

#ifdef __C128_HIRES__
extern unsigned short scalex[];
extern unsigned short scaley[];
#define SCALEX(x) (scalex[x])
#define SCALEY(y) (scaley[y])
#define FONTPTR(a) (a<<4)
#else

#define SCALEX(x) (x+64)
#define SCALEY(y) scaley[y]

extern uint16_t mul0375(uint16_t val);
#define SCALEX(x) (x+24)
#define SCALEY(y) (mul0375(y ^ 0x01ff))
#define FONTPTR(a) (((a << 1) + a) << 1)
#endif
#define FONTPTR_200(a) (((a << 1) + a) << 1)
#define FONTPTR_400(a) (a<<4)

#define FONTPTR(a) ((vdcmode == VDC_LORES) ? FONTPTR_200(a) : FONTPTR_400(a))

extern uint8_t font[];
extern uint8_t font_200[];
extern uint8_t font_400[];
extern uint8_t fontm23[];
extern uint8_t FONT_SIZE_X;
extern uint8_t FONT_SIZE_Y;
extern padBool FastText; /* protocol.c */
extern padPt TTYLoc;
extern uint8_t FONT_SIZE_Y_200;
extern uint8_t FONT_SIZE_Y_400;

uint8_t * font;
uint8_t FONT_SIZE_Y;

#define VDC_LORES 0
#define VDC_HIRES 1
uint8_t vdcmode;

extern uint8_t CharWide;
extern uint8_t CharHigh;

extern padBool FastText; /* protocol.c */
extern padPt TTYLoc;

extern void (*io_recv_serial_flow_on)(void);
extern void (*io_recv_serial_flow_off)(void);

Expand All @@ -65,11 +76,36 @@ void screen_init_hook(void)
*/
void screen_load_driver(void)
{
#ifdef __C128_HIRES__
tgi_install(&c128_vdc2_tgi);
#else
tgi_install(&c128_vdc_tgi);
#endif
uint16_t i;

tgi_load_driver("tgi-vdc*");
if (tgi_geterror()) {
puts("Unable to load a TGI driver; exiting...\r\n");
exit(1);
}

switch (tgi_getyres()) {
case 480:
vdcmode = VDC_HIRES;
font = font_400;
FONT_SIZE_Y = FONT_SIZE_Y_400;
break;
case 200:
vdcmode = VDC_LORES;
font = font_200;
FONT_SIZE_Y = FONT_SIZE_Y_200;

// Overwrite default hi-res Y scale table with low-res one
for (i = 0; i < 512; i++){
scaley[i] = mul0375(i ^ 0x01ff);
}
break;
default:
tgi_unload();
printf("Unknown Y resolution %d; exiting...\r\n", tgi_getyres());
exit(1);
break;
}
}

/**
Expand Down
107 changes: 51 additions & 56 deletions src/c128/terminal_char_load.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,80 +11,75 @@
#include "../terminal.h"
#include "../protocol.h"

#ifdef __C128_HIRES__
static unsigned char char_data[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

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

extern unsigned char fontm23[768];
#define VDC_LORES 0
#define VDC_HIRES 1
extern uint8_t vdcmode;

#define FONTPTR(a) (a<<4)
extern unsigned char fontm23[2048];

#define FONTPTR_200(a) (((a << 1) + a) << 1)
#define FONTPTR_400(a) (a << 4)

#define FONTPTR(a) ((vdcmode == VDC_LORES) ? FONTPTR_200(a) : FONTPTR_400(a))

/**
* terminal_char_load - Store a character into the user definable
* character set.
*/
void terminal_char_load(padWord charnum, charData theChar)
void terminal_char_load(padWord charNum, charData theChar)
{
// clear char data
memset(&fontm23[FONTPTR(charnum)],0,16);

// Transpose character data
for (curr_word=0;curr_word<8;curr_word++)
switch (vdcmode)
{
case VDC_HIRES:
// clear char data
memset(&fontm23[FONTPTR(charNum)], 0, 16);

// Transpose character data
for (curr_word = 0; curr_word < 8; curr_word++)
{
for (u=16; u-->0; )
{
if (theChar[curr_word] & 1<<u)
{
fontm23[FONTPTR(charnum)+u^0x0f&0x0f]|=BTAB[curr_word];
}
}
for (u = 16; u-- > 0;)
{
if (theChar[curr_word] & 1 << u)
{
fontm23[FONTPTR(charNum) + u ^ 0x0f & 0x0f] |= BTAB[curr_word];
}
}
}

// and...that's it, really. :)

}

#else

static unsigned char char_data[]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};

static unsigned char BTAB[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; // flip one bit on (OR)
// and...that's it, really. :)

static unsigned char curr_word; // current word
static unsigned char u; // loop counter
break;

extern unsigned char fontm23[768];

/**
* terminal_char_load - Store a character into the user definable
* character set.
*/
void terminal_char_load(padWord charNum, charData theChar)
{
// Clear char data.
memset(char_data,0,sizeof(char_data));
case VDC_LORES:
// Clear char data.
memset(char_data, 0, sizeof(char_data));

// load and transpose character data into 8x16 array
for (curr_word=0; curr_word<8; curr_word++)
// load and transpose character data into 8x16 array
for (curr_word = 0; curr_word < 8; curr_word++)
{
for (u=16; u-->0; )
{
if (theChar[curr_word] & 1<<u)
{
char_data[u^0x0F&0x0F]|=BTAB[curr_word];
}
}
for (u = 16; u-- > 0;)
{
if (theChar[curr_word] & 1 << u)
{
char_data[u ^ 0x0F & 0x0F] |= BTAB[curr_word];
}
}
}

// OR pixel rows together from 16 to 6 rows
fontm23[(charNum*6)+0]=char_data[0]|char_data[1]|char_data[2];
fontm23[(charNum*6)+1]=char_data[3]|char_data[4];
fontm23[(charNum*6)+2]=char_data[5]|char_data[6]|char_data[7];
fontm23[(charNum*6)+3]=char_data[8]|char_data[9];
fontm23[(charNum*6)+4]=char_data[10]|char_data[11]|char_data[12];
fontm23[(charNum*6)+5]=char_data[13]|char_data[14]|char_data[15];
// OR pixel rows together from 16 to 6 rows
fontm23[(charNum * 6) + 0] = char_data[0] | char_data[1] | char_data[2];
fontm23[(charNum * 6) + 1] = char_data[3] | char_data[4];
fontm23[(charNum * 6) + 2] = char_data[5] | char_data[6] | char_data[7];
fontm23[(charNum * 6) + 3] = char_data[8] | char_data[9];
fontm23[(charNum * 6) + 4] = char_data[10] | char_data[11] | char_data[12];
fontm23[(charNum * 6) + 5] = char_data[13] | char_data[14] | char_data[15];
break;
}
}
#endif

0 comments on commit d206d1c

Please sign in to comment.