Skip to content

Commit 4849244

Browse files
committed
Move screen_char_draw to device specific trees in preparation for replacing atari routines.
1 parent 6fc677a commit 4849244

File tree

5 files changed

+632
-196
lines changed

5 files changed

+632
-196
lines changed

src/apple2/screen.c

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,21 @@
1111
#include <peekpoke.h>
1212
#include <tgi.h>
1313
#include <stdint.h>
14+
#include <stdlib.h>
1415
#include "../config.h"
16+
#include "../protocol.h"
1517

1618
extern ConfigInfo config;
1719

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+
1829
#define outb(addr,val) (*(addr)) = (val)
1930
#define outw(addr,val) (*(addr)) = (val)
2031

@@ -68,3 +79,199 @@ void screen_beep(void)
6879
}
6980
}
7081
}
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+
}

src/atari/screen.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@
1212
#include <stdint.h>
1313
#include <conio.h>
1414
#include "../config.h"
15+
#include "../protocol.h"
1516

1617
extern uint8_t pal[2];
1718
extern ConfigInfo config;
1819

20+
extern short FONT_SIZE_X;
21+
extern short FONT_SIZE_Y;
22+
1923
/**
2024
* screen_init_hook()
2125
* Called after tgi_init to set any special features, e.g. nmi trampolines.
@@ -115,3 +119,10 @@ void screen_beep(void)
115119
{
116120
// My feeble attempt at a beep.
117121
}
122+
123+
/**
124+
* screen_char_draw(Coord, ch, count) - Output buffer from ch* of length count as PLATO characters
125+
*/
126+
void screen_char_draw(padPt* Coord, unsigned char* ch, unsigned char count)
127+
{
128+
}

0 commit comments

Comments
 (0)