Category : C Source Code
Archive   : ADVGRAPH.ZIP
Filename : CHARHDLR.C

 
Output of file : CHARHDLR.C contained in archive : ADVGRAPH.ZIP


/* CHARHDLR.C handles characters on display for GRAPHIQ.
*/

#include
#include "graphiq.h"
#include "screen.h"

extern char command[];

union REGS regs;


int write_array(string, row, col, color)
char *string[];
int row, col, color;
{
int i, j, newcol;

for (i = 0, newcol = col; strlen(string[i]) != 0; ++i, ++row)
for (j = 0, newcol = col; j < strlen(string[i]); ++j, ++newcol)
write_char(string[i][j], row, newcol, color, XORIT);
return(i-1);
}




write_str(string, row, col, color)
char *string;
int row, col, color;
{
int j, newcol;

for (j = 0, newcol = col; j < strlen(string); ++j, ++newcol)
write_char(string[j], row, newcol, color, XORIT);

}





write_char(character, row, col, color, orxor)
char character;
int row, col, color, orxor;
{

set_curs(row, col);

regs.h.ah = 9; /* write character */
regs.x.cx = 1; /* one character */
regs.h.al = character; /* character */
regs.h.bl = color | orxor; /* set color (NORMIT, XORIT) */
int86(0x10, ®s, ®s); /* interrupt 10h */
}





read_char(character, row, col)
char *character;
int row, col;
{

set_curs(row, col);

regs.h.ah = 8; /* read character */
regs.h.bh = 0; /* for page 0 */
int86(0x10, ®s, ®s); /* interrupt 10h */
*character = regs.h.al; /* character */
}





set_curs(row, col)
int row, col;
{

regs.h.ah = 2; /* set cursor position */
regs.h.bh = 0; /* for page 0 */
regs.h.dh = row; /* current row */
regs.h.dl = col; /* current col */
int86(0x10, ®s, ®s); /* interrupt 10h */
}






get_curs(row, col)
int *row, *col;
{

regs.h.ah = 3; /* get cursor position */
regs.h.bh = 0; /* for page 0 */
int86(0x10, ®s, ®s); /* interrupt 10h */
*row = regs.h.dh; /* current row */
*col = regs.h.dl; /* current col */
}







/* get_str() uses the current cursor position to get a string
from keyboard input. The text can be written over graphics
without disturbing anything. */

get_str(string, color)
char *string; /* make sure string allows > 80 characters long */
int color;
{
int inchar, row, col, position = 0;
char oldchar;

strcpy(command, "");

get_curs(&row, &col);

while ((inchar = retkey(NOLOC)) != CR)
{
switch (inchar)
{
case BS:
if (position > 0)
{
oldchar = string[--position];
string[position] = NULLCHAR;
if (col < 79)
write_char('_', row, col, color, XORIT);
write_char(oldchar, row, --col, WHITE, XORIT);
write_char('_', row, col, color, XORIT);
}
break;
default:
if (col < 79)
{
write_char('_', row, col, color, XORIT);
write_char(inchar, row, col++, WHITE, XORIT);
write_char('_', row, col, color, XORIT);
string[position++] = inchar;
string[position] = NULLCHAR;
}
else if (col == 79)
{
write_char(inchar, row, col, WHITE, XORIT);
string[position] = inchar;
}
break;
}
}
}



clearscr()
{

regs.h.ah = 7; /* scroll screen down */
regs.h.al = 0; /* entire window */
regs.h.ch = 0; /* upper left corner */
regs.h.cl = 0;
regs.h.dh = 24; /* lower right corner */
regs.h.dl = 79;
regs.h.bh = 0; /* use black background */
int86(0x10, ®s, ®s); /* interrupt 10h */
}





  3 Responses to “Category : C Source Code
Archive   : ADVGRAPH.ZIP
Filename : CHARHDLR.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/