home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DOS/V Power Report 1997 March
/
VPR9703A.ISO
/
VPR_DATA
/
DOGA
/
SOURCES
/
POLYEDIT.LZH
/
MODEL
/
TEXT98.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-15
|
2KB
|
169 lines
#include <stdio.h>
#include <string.h>
#include <dos.h>
#include "text.h"
#include "graph.h"
#define TRUE 1
#define FALSE 0
#define iskanji( c ) ( ( (c) & 0x80 ) != 0 )
int Cols, Lines ;
static int Cx, Cy ;
static int Attr ;
static int Cursor ;
void InitText()
{
Cols = 80 ;
Lines = 25 ;
Attr = ColorNomal ;
Cx = Cy = 0 ;
CursorOFF();
}
void ExitText()
{
ClearScreen();
}
/* コンソール入力 */
int GetChar()
{
int code ;
union REGS regs;
regs.h.ah = 0x07 ;
intdos( ®s, ®s );
code = regs.h.al ;
return code ;
}
int KeyIn()
{
union REGS regs;
int code ;
regs.h.ah = 0x00 ;
int86( 0x18, ®s, ®s );
code = regs.x.ax >> 8 ;
if ( 0x62 <= code && code <= 0x6b )
{
if ( ShiftSense() & 1 )
code = 0x8000 + code - 0x62 + 11 ;
else
code = 0x8000 + code - 0x62 + 1 ;
}
else if ( 0x36 <= code && code <= 0x3d )
{
code = 0x8000 + code - 0x36 + 0x15 ;
}
else if ( code == 0x3e )
{
code = 0x8000 + 0x1f ;
}
else if ( code == 0x3f )
{
code = 0x8000 + 0x1e ;
}
else
code = regs.x.ax & 0xff ;
return code ;
}
int KeySense()
{
union REGS regs;
regs.h.ah = 0x01 ;
int86( 0x18, ®s, ®s );
return regs.h.bh ;
}
int ShiftSense()
{
union REGS regs;
regs.h.ah = 0x02 ;
int86( 0x18, ®s, ®s );
return regs.h.al ;
}
void Wait()
{
int i ;
for( i = 0 ; i < 10000 ; ++i )
KeySense();
}
void ClearScreen()
{
int i ;
short *vram, *attr ;
vram = (short*)0xe00a0000 ;
attr = (short*)0xe00a2000 ;
for( i = 0 ; i < Cols*Lines ; ++i )
{
*vram++ = ' ' ;
*attr++ = 0xE1 ;
}
graph_fill( 0, 0, 639, 399, Attr >> 4 );
}
void Locate( x, y )
int x, y ;
{
union REGS regs ;
Cx = x ;
Cy = y ;
if ( Cursor )
{
regs.h.ah = 0x13 ;
regs.x.dx = ( y * 80 + x ) * 2 ;
int86( 0x18, ®s, ®s );
}
}
void CursorON()
{
union REGS regs ;
Cursor = TRUE ;
Locate( Cx, Cy );
regs.h.ah = 0x11 ;
int86( 0x18, ®s, ®s );
}
void CursorOFF()
{
union REGS regs ;
Cursor = FALSE ;
regs.h.ah = 0x12 ;
int86( 0x18, ®s, ®s );
}
void Bell()
{
bdos( 6, 7, 0 );
}
void GetCursor( xp, yp )
int *xp, *yp ;
{
*xp = Cx ;
*yp = Cy ;
}