diff --git a/Makefile b/Makefile index cf3c8fd..a671207 100644 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/dist.c128/c128-vdc.tgi b/dist.c128/c128-vdc.tgi new file mode 100644 index 0000000..378167f Binary files /dev/null and b/dist.c128/c128-vdc.tgi differ diff --git a/dist.c128/c128-vdc2.tgi b/dist.c128/c128-vdc2.tgi new file mode 100644 index 0000000..5de6f1d Binary files /dev/null and b/dist.c128/c128-vdc2.tgi differ diff --git a/src/c128/font.c b/src/c128/font.c index 7b7d473..1c9748a 100644 --- a/src/c128/font.c +++ b/src/c128/font.c @@ -5,9 +5,9 @@ #include 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, @@ -489,7 +489,171 @@ uint8_t font[]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -// Get rid of font pointer table. -#define FONTPTR(a) (1<<4) uint8_t fontm23[2048]; + +uint8_t FONT_SIZE_Y_200=6; + +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 */ + 0x24,0x7E,0x24,0x7E,0x24,0x00, /* # 0x23 */ + 0x08,0x3E,0x38,0x0E,0x3E,0x08, /* $ 0x24 */ + 0x62,0x64,0x08,0x13,0x23,0x00, /* % 0x25 */ + 0x38,0x38,0x7E,0x48,0x77,0x00, /* & 0x26 */ + 0x08,0x08,0x00,0x00,0x00,0x00, /* ' 0x27 */ + 0x08,0x10,0x10,0x10,0x08,0x00, /* ( 0x28 */ + 0x08,0x04,0x04,0x04,0x08,0x00, /* ) 0x29 */ + 0x08,0x6B,0x1C,0x6B,0x08,0x00, /* * 0x2a */ + 0x00,0x18,0x7E,0x18,0x00,0x00, /* + 0x2b */ + 0x00,0x00,0x00,0x00,0x18,0x08, /* , 0x2c */ + 0x00,0x00,0x7E,0x00,0x00,0x00, /* - 0x2d */ + 0x00,0x00,0x00,0x00,0x18,0x00, /* . 0x2e */ + 0x02,0x04,0x08,0x10,0x20,0x00, /* / 0x2f */ + 0x3C,0x46,0x4A,0x52,0x3C,0x00, /* 0 0x30 */ + 0x08,0x38,0x08,0x08,0x3E,0x00, /* 1 0x31 */ + 0x3C,0x02,0x3C,0x40,0x7E,0x00, /* 2 0x32 */ + 0x3C,0x02,0x1C,0x02,0x3C,0x00, /* 3 0x33 */ + 0x1C,0x24,0x44,0x7E,0x04,0x00, /* 4 0x34 */ + 0x7E,0x40,0x7C,0x02,0x7C,0x00, /* 5 0x35 */ + 0x3C,0x40,0x7C,0x42,0x3C,0x00, /* 6 0x36 */ + 0x7E,0x02,0x0C,0x10,0x10,0x00, /* 7 0x37 */ + 0x3C,0x42,0x3C,0x42,0x3C,0x00, /* 8 0x38 */ + 0x3C,0x42,0x3E,0x02,0x3C,0x00, /* 9 0x39 */ + 0x00,0x00,0x18,0x00,0x18,0x00, /* : 0x3a */ + 0x00,0x00,0x18,0x00,0x18,0x08, /* ; 0x3b */ + 0x00,0x0C,0x30,0x0C,0x00,0x00, /* < 0x3c */ + 0x00,0x7E,0x00,0x7E,0x00,0x00, /* = 0x3d */ + 0x00,0x18,0x06,0x18,0x00,0x00, /* > 0x3e */ + 0x3C,0x42,0x1C,0x00,0x10,0x00, /* ? 0x3f */ + 0x3C,0x4E,0x5E,0x40,0x3E,0x00, /* @ 0x40 */ + 0x3C,0x42,0x7E,0x42,0x42,0x00, /* A 0x41 */ + 0x7C,0x42,0x7C,0x42,0x7C,0x00, /* B 0x42 */ + 0x3C,0x42,0x40,0x42,0x3C,0x00, /* C 0x43 */ + 0x78,0x44,0x42,0x44,0x78,0x00, /* D 0x44 */ + 0x7E,0x40,0x7C,0x40,0x7E,0x00, /* E 0x45 */ + 0x7E,0x40,0x7C,0x40,0x40,0x00, /* F 0x46 */ + 0x3E,0x40,0x4E,0x42,0x3E,0x00, /* G 0x47 */ + 0x42,0x42,0x7E,0x42,0x42,0x00, /* H 0x48 */ + 0x1C,0x08,0x08,0x08,0x1C,0x00, /* I 0x49 */ + 0x02,0x02,0x02,0x42,0x3C,0x00, /* J 0x4a */ + 0x46,0x48,0x78,0x44,0x42,0x00, /* K 0x4b */ + 0x40,0x40,0x40,0x40,0x7E,0x00, /* L 0x4c */ + 0x42,0x66,0x5A,0x42,0x42,0x00, /* M 0x4d */ + 0x62,0x52,0x4A,0x46,0x42,0x00, /* N 0x4e */ + 0x3C,0x42,0x42,0x42,0x3C,0x00, /* O 0x4f */ + 0x7C,0x42,0x7C,0x40,0x40,0x00, /* P 0x50 */ + 0x3C,0x42,0x4A,0x46,0x3E,0x00, /* Q 0x51 */ + 0x7C,0x42,0x7C,0x42,0x42,0x00, /* R 0x52 */ + 0x3C,0x40,0x3C,0x02,0x3C,0x00, /* S 0x53 */ + 0x7F,0x08,0x08,0x08,0x08,0x00, /* T 0x54 */ + 0x42,0x42,0x42,0x42,0x3C,0x00, /* U 0x55 */ + 0x42,0x42,0x42,0x24,0x18,0x00, /* V 0x56 */ + 0x42,0x42,0x5A,0x66,0x42,0x00, /* W 0x57 */ + 0x42,0x24,0x18,0x24,0x42,0x00, /* X 0x58 */ + 0x41,0x41,0x3E,0x08,0x08,0x00, /* Y 0x59 */ + 0x7E,0x04,0x18,0x20,0x7E,0x00, /* Z 0x5a */ + 0x38,0x20,0x20,0x20,0x38,0x00, /* [ 0x5b */ + 0x40,0x20,0x10,0x08,0x04,0x00, /* \ 0x5c */ + 0x1C,0x04,0x04,0x04,0x1C,0x00, /* ] 0x5d */ + 0x18,0x24,0x00,0x00,0x00,0x00, /* CIRCUMFLEX ^ 0x5e*/ + 0x00,0x00,0x00,0x00,0x7E,0x00, /* _ 0x5f */ + 0x30,0x08,0x00,0x00,0x00,0x00, /* GRAVE ACCENT ` 0x60 */ + 0x00,0x3C,0x02,0x3E,0X3E,0x00, /* a 0x61 */ + 0x40,0x7C,0x42,0x42,0x7C,0x00, /* b 0x62 */ + 0x00,0x3C,0x40,0x40,0x3C,0x00, /* c 0x63 */ + 0x02,0x3E,0x42,0x42,0x3E,0x00, /* d 0x64 */ + 0x00,0x3c,0x7e,0x40,0x3c,0x00, /* e 0x65 */ + 0x0E,0x10,0x3C,0x10,0x10,0x00, /* f 0x66 */ + 0x00,0x3C,0x42,0x3E,0x02,0x1C, /* g 0x67 */ + 0x40,0x7C,0x42,0x42,0x42,0x00, /* h 0x68 */ + 0x08,0x00,0x18,0x08,0x1C,0x00, /* i 0x69 */ + 0x08,0x00,0x18,0x08,0x08,0x30, /* j 0x6a */ + 0x40,0x46,0x78,0x48,0x46,0x00, /* k 0x6b */ + 0x18,0x08,0x08,0x08,0x1C,0x00, /* l 0x6c */ + 0x00,0x7E,0x49,0x49,0x49,0x00, /* m 0x6d */ + 0x00,0x7C,0x42,0x42,0x42,0x00, /* n 0x6e */ + 0x00,0x3C,0x42,0x42,0x3C,0x00, /* o 0x6f */ + 0x00,0x7C,0x42,0x42,0x7C,0x40, /* p 0x70 */ + 0x00,0x3C,0x42,0x3E,0x02,0x03, /* q 0x67 */ + 0x00,0x2E,0x30,0x20,0x20,0x00, /* r 0x72 */ + 0x00,0x1E,0x70,0x0E,0x7C,0x00, /* s 0x73 */ + 0x10,0x3E,0x10,0x10,0x0E,0x00, /* t 0x74 */ + 0x00,0x42,0x42,0x42,0x3E,0x00, /* u 0x75 */ + 0x00,0x22,0x22,0x14,0x08,0x00, /* v 0x76 */ + 0x00,0x41,0x49,0x49,0x36,0x00, /* w 0x77 */ + 0x00,0x63,0x1C,0x14,0x63,0x00, /* x 0x78 */ + 0x00,0x42,0x42,0x3E,0x02,0x1C, /* y 0x79 */ + 0x00,0x3E,0x0C,0x18,0x3E,0x00, /* z 0x7a */ + 0x0E,0x08,0x30,0x08,0x0E,0x00, /* { 0x7b */ + 0x08,0x08,0x08,0x08,0x08,0x00, /* | 0x7c */ + 0x38,0x08,0x06,0x08,0x38,0x00, /* } 0x7d */ + 0x32,0x4C,0x00,0x00,0x00,0x00, /* ~ 0x7e */ + + 0x00,0x70,0x50,0x70,0x00,0x00, /* BOX 0x7f */ /* TODO: PLATO extended characters */ + 0x00,0x00,0x00,0x00,0x00,0x00, /* SPACE 0xa0 */ + 0x00,0x10,0x20,0x40,0x80,0x00, /* / 0xa1 */ + 0x00,0xF0,0x00,0xF0,0x00,0xF0, /* EQUIVALENT 0xa2 */ + 0x00,0x00,0x00,0x00,0x68,0xB0, /* LOW TILDE 0xa3 */ + 0x20,0x70,0x80,0x70,0x20,0x00, /* ASSIGN 0xa4 */ + 0x20,0xF0,0x20,0xF0,0x40,0x00, /* NOT EQUAL 0xa5 */ + 0x00,0x20,0x70,0x20,0x20,0x00, /* UP ARROW 0xa6 */ + 0x00,0x00,0x20,0xF0,0x20,0x00, /* RIGHT ARROW 0xa7 */ + 0x00,0x20,0x20,0x70,0x20,0x00, /* DOWN ARROW 0xa8 */ + 0x00,0x00,0x40,0xF0,0x40,0x00, /* LEFT ARROW 0xa9 */ + 0x00,0x50,0x20,0x50,0x00,0x00, /* MULTIPLY 0xaa */ + 0xF0,0x80,0x60,0x80,0xF0,0x00, /* SIGMA 0xab */ + 0x00,0x20,0x50,0x88,0xF8,0x00, /* DELTA 0xac*/ + 0x00,0x90,0x90,0x60,0x00,0x00, /* UNION 0xad*/ + 0x00,0x60,0x90,0x90,0x00,0x00, /* INTERSECT 0xae */ + 0x00,0x60,0x00,0x60,0x00,0x00, /* DIVIDE 0xaf */ + 0x00,0x50,0xA0,0x70,0x00,0x00, /* ALPHA 0xb0 */ + 0x20,0x50,0xA0,0x90,0xE0,0x80, /* BETA 0xb1 */ + 0x20,0x40,0x20,0x50,0x70,0x00, /* DELTA 0xb2 */ + 0x80,0x40,0x20,0x50,0x90,0x00, /* LAMBDA 0xb3 */ + 0x00,0x00,0x50,0x50,0x60,0x80, /* MU 0xb4 */ + 0x08,0x78,0xD0,0x50,0x50,0x00, /* PI 0xb5 */ + 0x00,0x20,0x50,0x50,0xA0,0x80, /* RHO 0xb6 */ + 0x30,0x40,0xA0,0xA0,0x40,0x00, /* SIGMA 0xb7 */ + 0x00,0x00,0x90,0xB0,0x60,0x00, /* OMEGA 0xb8 */ + 0x20,0x40,0x80,0x40,0x20,0xE0, /* LESS THAN OR EQUAL 0xb9 */ + 0x80,0x40,0x20,0x40,0x80,0xE0, /* GREATER THAN OR EQUAL 0xba */ + 0x20,0x50,0x70,0x50,0x20,0x00, /* THETA 0xbb */ + 0x30,0x60,0xA0,0x60,0x30,0x00, /* l-embed 0xbc */ + 0x00,0x60,0x90,0x60,0x00,0x00, /* DEGREE 0xbd */ + 0xC0,0x60,0x50,0x60,0xC0,0x00, /* r-embed 0xbe */ + 0xC0,0xA0,0x50,0x50,0xA0,0xC0, /* ANSWER ARROW 0xbf */ + 0xFF,0x1C,0x20,0x20,0x1C,0xFF, /* COPYRIGHT 0xc0 */ + 0x50,0x00,0x00,0x00,0x00,0x00, /* DIERESIS 0xc1 */ + 0x00,0x70,0x50,0x70,0x00,0x00, /* BOX 0xc2 */ + 0x00,0x00,0x20,0x00,0x00,0x00, /* INTERPUNCT 0xc3 */ + 0x20,0x70,0xF8,0x70,0x20,0x00, /* DIAMOND 0xc4 */ + 0x00,0x50,0x20,0x50,0x00,0x00, /* MULTIPLY 0xc5 */ + 0x10,0x20,0x00,0x00,0x00,0x00, /* ACUTE ACCENT 0xc6 */ + 0x00,0x00,0x00,0x08,0x10,0x00, /* CEDILLA 0xc7 */ + 0x10,0x20,0x00,0x00,0x00,0x00, /* HACEK 0xc8 */ + 0x20,0x70,0xF8,0x70,0x20,0x00, /* DIAMOND 0xc9 */ + 0x20,0x20,0x20,0x20,0x20,0x20, /* | 0xca */ + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00 +}; diff --git a/src/c128/nmi-trampoline.s b/src/c128/nmi-trampoline.s deleted file mode 100644 index 2247291..0000000 --- a/src/c128/nmi-trampoline.s +++ /dev/null @@ -1,40 +0,0 @@ -; -; nmi_trampoline.s -- Catches Non-Maskable Interrupts when the C64 ROM and I/O are disabled. -; -; 2018-05-15, Greg King -; -; void install_nmi_trampoline (void); -; - - .export _install_nmi_trampoline - - .include "c64.inc" - -nmi_vec := $FFFA - -_install_nmi_trampoline: - lda #nmi_trampoline - sta nmi_vec - stx nmi_vec+1 - rts - -.segment "LOWCODE" - -nmi_trampoline: - pha - lda $01 ; save RAM config. - pha - ora #%00000110 ; enable Kernal and I/O - sta $01 - lda #>ret ; create NMI return address - pha - lda # -/* 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, diff --git a/src/c128/screen.c b/src/c128/screen.c index 0b19eb5..3988463 100644 --- a/src/c128/screen.c +++ b/src/c128/screen.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "../config.h" #include "../protocol.h" #include "../screen.h" @@ -22,25 +23,42 @@ extern ConfigInfo config; extern unsigned short scalex[]; extern unsigned short scaley[]; -extern uint8_t font[]; + +#define SCALEX(x) (x+64) +#define SCALEY(y) scaley[y] + +extern uint16_t mul0375(uint16_t val); +#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_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); #define outb(addr,val) (*(addr)) = (val) #define outw(addr,val) (*(addr)) = (val) -#define FONTPTR(a) (a<<4) - -extern void install_nmi_trampoline(void); /* nmi_trampoline.s */ - /** * screen_init_hook() * Called after tgi_init to set any special features, e.g. nmi trampolines. @@ -48,7 +66,6 @@ extern void install_nmi_trampoline(void); /* nmi_trampoline.s */ void screen_init_hook(void) { unsigned char pal[2]={0,1}; - install_nmi_trampoline(); fast(); tgi_setpalette(pal); } @@ -59,7 +76,36 @@ void screen_init_hook(void) */ void screen_load_driver(void) { - tgi_install(&c128_vdc2_tgi); + 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; + } } /** @@ -110,7 +156,7 @@ void screen_block_draw(padPt* Coord1, padPt* Coord2) io_recv_serial_flow_off(); screen_set_pen_mode(); - tgi_bar(scalex[Coord1->x],scaley[Coord1->y],scalex[Coord2->x],scaley[Coord2->y]); + tgi_bar(SCALEX(Coord1->x),SCALEY(Coord1->y),SCALEX(Coord2->x),SCALEY(Coord2->y)); io_recv_serial_flow_on(); } @@ -121,7 +167,7 @@ void screen_block_draw(padPt* Coord1, padPt* Coord2) void screen_dot_draw(padPt* Coord) { screen_set_pen_mode(); - tgi_setpixel(scalex[Coord->x],scaley[Coord->y]); + tgi_setpixel(SCALEX(Coord->x),SCALEY(Coord->y)); } /** @@ -129,10 +175,10 @@ void screen_dot_draw(padPt* Coord) */ void screen_line_draw(padPt* Coord1, padPt* Coord2) { - uint16_t x1=scalex[Coord1->x]; - uint16_t x2=scalex[Coord2->x]; - uint16_t y1=scaley[Coord1->y]; - uint16_t y2=scaley[Coord2->y]; + uint16_t x1=SCALEX(Coord1->x); + uint16_t x2=SCALEX(Coord2->x); + uint16_t y1=SCALEY(Coord1->y); + uint16_t y2=SCALEY(Coord2->y); screen_set_pen_mode(); tgi_line(x1,y1,x2,y2); @@ -155,7 +201,7 @@ void screen_tty_char(padByte theChar) { TTYLoc.x -= CharWide; tgi_setcolor(TGI_COLOR_BLACK); - tgi_bar(scalex[TTYLoc.x],scaley[TTYLoc.y],scalex[TTYLoc.x+CharWide],scaley[TTYLoc.y+CharHigh]); + tgi_bar(SCALEX(TTYLoc.x),SCALEY(TTYLoc.y),SCALEX(TTYLoc.x+CharWide),SCALEY(TTYLoc.y+CharHigh)); tgi_setcolor(TGI_COLOR_WHITE); } else if (theChar == 0x0A) /* line feed */ @@ -273,12 +319,12 @@ void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count) tgi_setcolor(mainColor); - x=scalex[(Coord->x&0x1FF)]; + x=SCALEX((Coord->x&0x1FF)); if (ModeBold) - y=scaley[(Coord->y)+30&0x1FF]; + y=SCALEY((Coord->y)+30&0x1FF); else - y=scaley[(Coord->y)+15&0x1FF]; + y=SCALEY((Coord->y)+15&0x1FF); if (FastText==padF) { diff --git a/src/c128/terminal_char_load.c b/src/c128/terminal_char_load.c index 707e607..8944fe8 100644 --- a/src/c128/terminal_char_load.c +++ b/src/c128/terminal_char_load.c @@ -11,36 +11,75 @@ #include "../terminal.h" #include "../protocol.h" -static unsigned char BTAB[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01}; // flip one bit on (OR) +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 u; static unsigned char curr_word; -extern unsigned char fontm23[768]; +#define VDC_LORES 0 +#define VDC_HIRES 1 +extern uint8_t vdcmode; + +extern unsigned char fontm23[2048]; + +#define FONTPTR_200(a) (((a << 1) + a) << 1) +#define FONTPTR_400(a) (a << 4) -#define FONTPTR(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); + 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++) + // Transpose character data + for (curr_word = 0; curr_word < 8; curr_word++) { - for (u=16; u-->0; ) - { - if (theChar[curr_word] & 1< 0;) + { + if (theChar[curr_word] & 1 << u) + { + fontm23[FONTPTR(charNum) + u ^ 0x0f & 0x0f] |= BTAB[curr_word]; + } + } } - // and...that's it, really. :) - -} + // and...that's it, really. :) + + break; + 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++) + { + 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]; + break; + } +}