|
11 | 11 | #include <peekpoke.h> |
12 | 12 | #include <tgi.h> |
13 | 13 | #include <stdint.h> |
| 14 | +#include <stdlib.h> |
14 | 15 | #include "../config.h" |
| 16 | +#include "../protocol.h" |
15 | 17 |
|
16 | 18 | extern ConfigInfo config; |
17 | 19 |
|
| 20 | +extern unsigned short scalex[]; |
| 21 | +extern unsigned short scaley[]; |
| 22 | +extern uint8_t font[]; |
| 23 | +extern uint8_t fontm23[]; |
| 24 | +extern uint16_t fontptr[]; |
| 25 | +extern uint8_t FONT_SIZE_X; |
| 26 | +extern uint8_t FONT_SIZE_Y; |
| 27 | +extern padBool FastText; /* protocol.c */ |
| 28 | + |
18 | 29 | #define outb(addr,val) (*(addr)) = (val) |
19 | 30 | #define outw(addr,val) (*(addr)) = (val) |
20 | 31 |
|
@@ -68,3 +79,199 @@ void screen_beep(void) |
68 | 79 | } |
69 | 80 | } |
70 | 81 | } |
| 82 | + |
| 83 | +/** |
| 84 | + * screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters |
| 85 | + */ |
| 86 | +void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count) |
| 87 | +{ |
| 88 | + int16_t offset; /* due to negative offsets */ |
| 89 | + uint16_t x; /* Current X and Y coordinates */ |
| 90 | + uint16_t y; |
| 91 | + uint16_t* px; /* Pointers to X and Y coordinates used for actual plotting */ |
| 92 | + uint16_t* py; |
| 93 | + uint8_t i; /* current character counter */ |
| 94 | + uint8_t a; /* current character byte */ |
| 95 | + uint8_t j,k; /* loop counters */ |
| 96 | + int8_t b; /* current character row bit signed */ |
| 97 | + uint8_t width=FONT_SIZE_X; |
| 98 | + uint8_t height=FONT_SIZE_Y; |
| 99 | + uint16_t deltaX=1; |
| 100 | + uint16_t deltaY=1; |
| 101 | + uint8_t mainColor=1; |
| 102 | + uint8_t altColor=0; |
| 103 | + uint8_t *p; |
| 104 | + uint8_t* curfont; |
| 105 | + |
| 106 | + switch(CurMem) |
| 107 | + { |
| 108 | + case M0: |
| 109 | + curfont=font; |
| 110 | + offset=-32; |
| 111 | + break; |
| 112 | + case M1: |
| 113 | + curfont=font; |
| 114 | + offset=64; |
| 115 | + break; |
| 116 | + case M2: |
| 117 | + curfont=fontm23; |
| 118 | + offset=-32; |
| 119 | + break; |
| 120 | + case M3: |
| 121 | + curfont=fontm23; |
| 122 | + offset=32; |
| 123 | + break; |
| 124 | + } |
| 125 | + |
| 126 | + if (CurMode==ModeRewrite) |
| 127 | + { |
| 128 | + altColor=0; |
| 129 | + } |
| 130 | + else if (CurMode==ModeInverse) |
| 131 | + { |
| 132 | + altColor=1; |
| 133 | + } |
| 134 | + |
| 135 | + if (CurMode==ModeErase || CurMode==ModeInverse) |
| 136 | + mainColor=0; |
| 137 | + else |
| 138 | + mainColor=1; |
| 139 | + |
| 140 | + tgi_setcolor(mainColor); |
| 141 | + |
| 142 | +#ifdef __ATARI__ |
| 143 | + x=mul0625((Coord->x&0x1FF)); |
| 144 | + y=mul0375((Coord->y+14^0x1FF)&0x1FF); |
| 145 | +#else |
| 146 | + x=scalex[(Coord->x&0x1FF)]; |
| 147 | + y=scaley[(Coord->y)+14&0x1FF]; |
| 148 | +#endif |
| 149 | + |
| 150 | + if (FastText==padF) |
| 151 | + { |
| 152 | + goto chardraw_with_fries; |
| 153 | + } |
| 154 | + |
| 155 | + /* the diet chardraw routine - fast text output. */ |
| 156 | + |
| 157 | + for (i=0;i<count;++i) |
| 158 | + { |
| 159 | + a=*ch; |
| 160 | + ++ch; |
| 161 | + a+=offset; |
| 162 | + p=&curfont[fontptr[a]]; |
| 163 | + |
| 164 | + for (j=0;j<FONT_SIZE_Y;++j) |
| 165 | + { |
| 166 | + b=*p; |
| 167 | + |
| 168 | + for (k=0;k<FONT_SIZE_X;++k) |
| 169 | + { |
| 170 | + if (b<0) /* check sign bit. */ |
| 171 | + { |
| 172 | + tgi_setcolor(mainColor); |
| 173 | + tgi_setpixel(x,y); |
| 174 | + } |
| 175 | + |
| 176 | + ++x; |
| 177 | + b<<=1; |
| 178 | + } |
| 179 | + |
| 180 | + ++y; |
| 181 | + x-=width; |
| 182 | + ++p; |
| 183 | + } |
| 184 | + |
| 185 | + x+=width; |
| 186 | + y-=height; |
| 187 | + } |
| 188 | + |
| 189 | + return; |
| 190 | + |
| 191 | + chardraw_with_fries: |
| 192 | + if (Rotate) |
| 193 | + { |
| 194 | + deltaX=-abs(deltaX); |
| 195 | + width=-abs(width); |
| 196 | + px=&y; |
| 197 | + py=&x; |
| 198 | + } |
| 199 | + else |
| 200 | + { |
| 201 | + px=&x; |
| 202 | + py=&y; |
| 203 | + } |
| 204 | + |
| 205 | + if (ModeBold) |
| 206 | + { |
| 207 | + deltaX = deltaY = 2; |
| 208 | + width<<=1; |
| 209 | + height<<=1; |
| 210 | + } |
| 211 | + |
| 212 | + for (i=0;i<count;++i) |
| 213 | + { |
| 214 | + a=*ch; |
| 215 | + ++ch; |
| 216 | + a+=offset; |
| 217 | + p=&curfont[fontptr[a]]; |
| 218 | + for (j=0;j<FONT_SIZE_Y;++j) |
| 219 | + { |
| 220 | + b=*p; |
| 221 | + |
| 222 | + if (Rotate) |
| 223 | + { |
| 224 | + px=&y; |
| 225 | + py=&x; |
| 226 | + } |
| 227 | + else |
| 228 | + { |
| 229 | + px=&x; |
| 230 | + py=&y; |
| 231 | + } |
| 232 | + |
| 233 | + for (k=0;k<FONT_SIZE_X;++k) |
| 234 | + { |
| 235 | + if (b<0) /* check sign bit. */ |
| 236 | + { |
| 237 | + tgi_setcolor(mainColor); |
| 238 | + if (ModeBold) |
| 239 | + { |
| 240 | + tgi_setpixel(*px+1,*py); |
| 241 | + tgi_setpixel(*px,*py+1); |
| 242 | + tgi_setpixel(*px+1,*py+1); |
| 243 | + } |
| 244 | + tgi_setpixel(*px,*py); |
| 245 | + } |
| 246 | + else |
| 247 | + { |
| 248 | + if (CurMode==ModeInverse || CurMode==ModeRewrite) |
| 249 | + { |
| 250 | + tgi_setcolor(altColor); |
| 251 | + if (ModeBold) |
| 252 | + { |
| 253 | + tgi_setpixel(*px+1,*py); |
| 254 | + tgi_setpixel(*px,*py+1); |
| 255 | + tgi_setpixel(*px+1,*py+1); |
| 256 | + } |
| 257 | + tgi_setpixel(*px,*py); |
| 258 | + } |
| 259 | + } |
| 260 | + |
| 261 | + x += deltaX; |
| 262 | + b<<=1; |
| 263 | + } |
| 264 | + |
| 265 | + y+=deltaY; |
| 266 | + x-=width; |
| 267 | + ++p; |
| 268 | + } |
| 269 | + |
| 270 | + Coord->x+=width; |
| 271 | + x+=width; |
| 272 | + y-=height; |
| 273 | + } |
| 274 | + |
| 275 | + return; |
| 276 | + |
| 277 | +} |
0 commit comments