home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Transactor
/
Transactor_26_1988_Transactor_Publishing.d64
/
screen.c
< prev
next >
Wrap
Text File
|
2023-02-26
|
4KB
|
253 lines
/* screen.c - screen routines */
/* W Mat Waites - Sept 1988 */
#include <stdio.h>
#define PLOT 0xfff0
/* initscr() - initialize cursor, etc */
initscr()
{SHIFT-+}
int i;
char *tmp;
char *sprite0 = 0x07f8;
char *spcol0 = 0xd027;
/* cursor sprite is defined in
basic input buffer */
/* put sprite 0 at $0200 */
*sprite0 = 8;
/* set color to white */
*spcol0 = 1;
/* first, set sprite to all bgd */
for(i=0; i<64; i++)
{SHIFT-+}
tmp = 0x0200 + i;
*tmp = 0;
{SHIFT--}
/* fill in fgd of sprite */
for(i=7; i<8; i++)
{SHIFT-+}
tmp = 0x0200 + 3*i;
*tmp = 0xff;
{SHIFT--}
{SHIFT--}
/* cursoron() - turn on cursor */
cursoron()
{SHIFT-+}
char *enab = 0xd015;
*enab = 0x01; /* turn on sprite 0 */
{SHIFT--}
/* cursoroff() - turn off cursor */
cursoroff()
{SHIFT-+}
char *enab = 0xd015;
*enab = 0x00; /* turn off sprite 0 */
{SHIFT--}
/* updatecursor() - correct sprite loc */
updatecursor()
{SHIFT-+}
char *cury, *curx;
char *ypos, *xpos;
char *highx;
int sy, sx;
cury = 0x00d6;
curx = 0x00d3;
xpos = 0xd000;
ypos = 0xd001;
highx = 0xd010;
/* compute cursor screen location */
sy = (int)*cury;
sx = (int)*curx;
if(sx > 39) /* check for wrap */
{SHIFT-+}
sx -= 40;
{SHIFT--}
sy = sy << 3;
sx = sx << 3;
sy += 50;
sx += 24;
*ypos = (char)sy;
*xpos = (char)sx;
if(sx > 255)
{SHIFT-+}
*highx = 0x01;
{SHIFT--}
else
{SHIFT-+}
*highx = 0x00;
{SHIFT--}
{SHIFT--}
/* erase() - clear screen */
erase()
{SHIFT-+}
putchar((char)147);
{SHIFT--}
/* standout() - reverse video */
standout()
{SHIFT-+}
putchar((char)18);
{SHIFT--}
/* standend() - standard video */
standend()
{SHIFT-+}
putchar((char)146);
{SHIFT--}
/* center() - center string on line */
center(y, str)
int y;
char *str;
{SHIFT-+}
int x;
x = 20 - strlen(str)/2;
move(y, x);
printf(str);
{SHIFT--}
/* move() - cursor positioning */
move(y, x)
int y, x;
{SHIFT-+}
char ac, xc, yc;
/* check for bozo parameters */
if(y > 24) y = 24;
if(y < 0) y = 0;
if(x > 79) x = 79;
if(x < 0) x = 0;
xc = (char)y;
yc = (char)x;
sys(PLOT, &ac, &xc, &yc);
{SHIFT--}
/* setborder() - set border color */
setborder(color)
int color;
{SHIFT-+}
char *border = 0xd020;
*border = (char)color;
{SHIFT--}
/* setbg() - set background color */
setbg(color)
int color;
{SHIFT-+}
char *bg = 0xd021;
*bg = (char)color;
{SHIFT--}
/* setfg() - set foreground color */
setfg(color)
int color;
{SHIFT-+}
static char colchars[16] =
{SHIFT-+}
144, /* black */
5, /* white */
28, /* red */
159, /* cyan */
156, /* purple */
32, /* green */
31, /* blue */
158, /* yellow */
129, /* orange */
149, /* brown */
150, /* lt. red */
151, /* grey 1 */
152, /* grey 2 */
153, /* lt. green */
154, /* lt. blue */
155 /* grey 3 */
{SHIFT--};
if(color < 0) color = 0;
if(color > 15) color = 15;
putchar(colchars[color]);
{SHIFT--}
/* getstring() - get string with echo */
getstring(s, len)
char *s;
int len;
{SHIFT-+}
int done, kbchar, ll;
char *ls;
done = 0;
ll = 0;
ls = s;
*ls = '\0';
updatecursor();
cursoron();
while(!done)
{SHIFT-+}
/* check for <C=> key */
if(chkstop())
{SHIFT-+}
cursoroff();
return(0);
{SHIFT--}
if(charsinq() > 0)
{SHIFT-+}
kbchar = getkb();
/* only printable characters */
if(isprint(kbchar))
{SHIFT-+}
*ls = (char)kbchar;
ls++;
ll++;
*ls = '\0';
putchar((char)kbchar);
updatecursor();
if(ll >= len)
{SHIFT-+}
done = 1;
{SHIFT--}
{SHIFT--}
else if(kbchar == 13)
{SHIFT-+}
done = 1;
{SHIFT--}
else if(kbchar == 20)
{SHIFT-+}
/* backspace */
if(ll > 0)
{SHIFT-+}
ll--;
ls--;
*ls = '\0';
putchar((char)20);
updatecursor();
{SHIFT--}
{SHIFT--}
{SHIFT--}
{SHIFT--}
cursoroff();
return(strlen(s));
{SHIFT--}
/* end of file */