📄 pc.htm
字号:
int biosequip( void );
The return values are,
bit 15,14 number of printers
13 not used
12 game i/o attached
11,10,9 number of serial cards
8 unused
7,6 number of disk drives
5,4 initial video mode
3,2 base ram size
1 unused (some systems use this for 8087
detection)
0 boot from disk
example usage,
if( (biosequip() & 0xe00) == 0) {
printstr("Serial card is not installed.");
beep();
}
<B>INTERFACE TO ROM BIOS KEY ROUTINES</B> bioskey()
This function uses int16h. It emulates that supplied in the TurboC
library. The prototype is,
int bioskey( int cmd );
cmd = 0; read character from keyboard
cmd = 1; check keyboard for character (0 = not available)
cmd = 2; return key status (see function kbstatus() )
<B>MEMORY SIZE DETERMINATION</B> biosmemory()
This function uses int21h to determine the number of contiguos 1k
byte blocks of memory; the prototype is
int biosmemory( void );
<B>PRINTER SERVICES</B> biosprint()
This function provides emulation of the similar function supplied with
TurboC. Its prototype is,
int biosprint( int cmd, int byte, int port );
The return value is the current printer status.
cmd = 0 Print character
cmd = 1 Initialize printer port
cmd = 2 Return printer status (refer prn_status() )
example usage,
unsigned char *message = "Welcome.";
while( message++ )
biosprint( 0, *message, 0 );
<B>GET INTERRUPT VECTOR</B> getvect()
This function returns a long int representing the interrupt vector
(seg:off) of the specified interrupt number. Its prototype is,
long int getvect( int intnumber );
example usage,
usigned long oldcom1vect;
oldcom1vect = getvect( 0x0c );
<B>SET AN INTERRUPT VECTOR</B> setvect()
This function writes the interrupt vector. The prototype is,
void setvect( int intnumber, unsigned seg, offset );
example usage,
unsigned seg, off;
char far *icode = 0xf6000000l;
seg = FP_SEG( icode );
off = FP_OFF( icode );
setvect( 0x0c, seg, off );
<B>VIDEO ROUTINES INT10h</B>
<B>SET VIDEO MODE</B> setvmode()
This function sets the video mode to that specified. The prototype is,
void setvmode( int videomode );
example usage,
int vmode = 6; /* 640.200 hires on cga */
setvmode( vmode );
<B>SET VIDEO CURSOR SHAPE</B> setvcurs()
This function sets the number of scanlines which make up the cursor.
It can be used to generate block or underline cursors. The prototype is,
void setvcurs( int startline, endline );
example usage,
int startline = 12, endline = 13; /* underline cursor */
setvcurs( startline, endline );
<B>SET VIDEO CURSOR POSITION</B> setvcpos()
This function positions the cursor to the specified x,y co-ordinates.
Its prototype is,
void setvcpos( int xpos, ypos, vpage );
example usage,
int vpage, xpos = 10, ypos = 10;
getvmode();
vpage = _BH;
setvcpos( xpos, ypos, vpage );
<B>READ VIDEO CURSOR POSITION</B> getvcpos()
This function returns the current x,y co-ordinates of the cursor.
The prototype is,
int getvcpos( int vpage );
example usage,
int temp, vpage, xpos, ypos;
getvmode();
temp = getvcpos( _BH );
xpos = temp & 0xff;
ypos = (temp & 0xff00) >> 8;
<B>SET ACTIVE VIDEO PAGE</B> setvpage()
This function makes the specified page active. The prototype is
void setvpage( int vpage );
example usage,
int vpage = 2;
setvpage( vpage );
<B>SCROLL VIDEO WINDOW UP</B> scrollvup()
This function accepts the co-ordinates of a window, scrolling it upwards
the number of lines specified, using the desired attribute. The prototype is,
void scrollvup(int tplftx,tplfty,btmrghtx,btmrgthy,attr,lines);
example usage,
scrollvup( 10,10,30,15,0x0f,0 ) /* clear a window */
scrollvup( 10,10,30,15,0x0f,1 ) /* up window 1 line */
<B>SCROLL VIDEO WINDOW DOWN</B> scrollvdn()
This function accepts the co-ordinates of a window, scrolling it downwards
the number of lines specified, using the desired attribute. The prototype is,
void scrollvdn(int tplftx,tplfty,btmrghtx,btmrgthy,attr,lines);
example usage,
scrollvdn( 10,10,30,15,0x0f,0 ) /* clear a window */
scrollvup( 10,10,30,15,0x0f,1 ) /* down window 1 line */
<B>READ ATTRIBUTE AND CHARACTER AT CURSOR</B> getvattrchar()
This function returns the attribute and character at the current
cursor position. The prototype is,
int getvattrchar( int videopage );
example usage;
int temp, attr, ch, vpage;
getvmode();
vpage = _BH;
temp = getvattrchar( vpage );
attr = (temp & 0xff00) >> 8;
ch = (temp & 0x00ff);
<B>WRITE CHARACTER AND ATTRIBUTE AT CURSOR</B> setvattrchar()
This function writes the specified attribute and character values to
the current cursor position. It does not increment the cursor position.
The prototype is,
void setvattrchar( int vpage, ch, attr, number );
example usage,
int vpage = 0, attr= 0x0f, number = 25;
char ch = '*';
setvattrchar(vpage, ch, attr, number);
/* write 25 * on screen */
<B>WRITE CHARACTER ONLY TO CURSOR POSITION</B> setvchar()
This function writes the character to the current cursor location. The
cursor is not moved. The prototype is,
void setvchar( int video_page, int ch, int number );
example usage,
int vpage = 0, number = 25;
char ch = '*';
setvchar( vpage, ch, number ); /* write 25 *'s on screen */
<B>SET PALETTE COLORS IN MEDIUM RES CGA</B> setvpall()
This function updates the palette color in medium resolution mode. The
prototype is,
void setvpall( int palette_color, int color_value );
example usage,
int palette = 0, color_val = 15;
setvpall( palette, color_val ); /* set backgnd to yellow */
<B>WRITE PIXEL DOT</B> setvdot()
This function writes a pixel (either on or off) at the specified
co-ordinates. Its prototype is,
void setvdot( int xpos, ypos, color_value );
example usage,
setvdot( 100, 100, 1 );
<B>READ PIXEL COLOR VALUE</B> getvdot()
This function returns the pixel color value of the specified pixel.
The prototype is,
int getvdot( int xpos, ypos );
example usage,
int color, xpos = 100, ypos = 50;
color = getvdot( xpos, ypos );
<B>WRITE CHARACTER AND MOVE CURSOR</B> setvstring()
This function writes the character to the current cursor position,
incrementing the cursor. It also performs line-wrap and scrolling.
The prototype is,
void setvstring( int ch, video_page, med_res_color_value );
example usage,
int vpage = 0;
char *msg = "Help";
while( *msg++ )
setvstring( *msg, vpage, 1 );
<B>GET VIDEO MODE, COLUMN AND PAGE INFO</B> getvmode()
This function returns the video status. The video mode is returned in _
BH, the video mode in _AL, and the number of columns in _AH. Its
prototype is,
int getvmode( void );
example usage,
int temp, vpage, columns, videomode;
temp = getvmode();
vpage = _BH;
columns = (temp & 0xff00) >> 8;
videomode = temp & 0xff;
<B>SAVE VIDEO MEMORY</B> savevscrn()
This function copies the current video memory (page zero) into the
designated buffer space. Its prototype is,
void savevscrn( char far *buffer, int screen_type );
where screen_type = 0 for monochrome and 1 for cga.
example usage,
#define mono 0
#define cga 1
char far buffer[80*25*2];
savescrn( buffer, mono );
<B>RESTORE VIDEO SCREEN MEMORY</B> getvscrn()
This function restores the video memory (page zero) from the
designated buffer space. Its prototype is,
void getvscrn( char far *buffer, int screen_type );
where screen_type = 0 for monochrome and 1 for cga.
example usage,
#define mono 0
#define cga 1
char far buffer[80*25*2];
getvscrn( buffer, mono );
<B>PRINT NULL TERMINATED STRING</B> printstr()
This function prints each character of the string till it finds a null.
It uses the function _setvstring(). The prototype is,
void printstr( char *message );
example usage,
char *msg = "Hello there.";
printstr( msg );
<B>SOUND SPEAKER</B> beep()
This function beeps the speaker for 500ms at 100hz. The prototype is
void beep( void );
example usage;
beep();
<B>ENABLE INTERRUPTS</B> enable()
This function is used to enable the processing of interrupts. Its
prototype is,
void enable( void );
example usage,
enable();
<B>DISABLE INTERRUPTS</B> disable()
This function is used to disable the processing of interrupts. Its
prototype is,
void disable( void );
example usage,
disable();
</PRE>
<HR>
<A HREF="sw/romlib/romlib.h"><B>ROMLIB.H</B></A><BR>
<PRE>
/* romlib.h */
#define TRUE 1
#define FALSE 0
struct XREGS {
unsigned int ax; /* definitions for int86 calls */
unsigned int bx;
unsigned int cx;
unsigned int dx;
unsigned int si;
unsigned int di;
unsigned int cflag;
};
struct HREGS {
unsigned char al, ah;
unsigned char bl, bh;
unsigned char cl, ch;
unsigned char dl, dh;
};
union REGS {
struct XREGS x;
struct HREGS h;
};
struct SREGS {
unsigned int es;
unsigned int cs;
unsigned int ss;
unsigned int ds;
};
/* Function declarations which reside in romlib.asm */
extern void ipl_load(), basic_rom();
extern void ser_init(), serial_out();
extern int serial_in(), serial_status();
extern void prn_out();
extern int prn_status(), prn_init();
extern int kbhit(), kbgetch(), kbstatus();
extern void segread();
extern int inportb();
extern void outportb();
extern void int86();
extern void pokeb();
extern char peekb();
extern int biosequip(), bioskey(), biosmemory(), biosprint();
extern long int getvect();
extern void setvect(), setvmode(), setvcurs(), setvpos();
extern int getvpos();
extern void setvpage(), scrollvup(), scrollvdn();
extern int getvattrchar();
extern void setvattrchar(), setvchar(), setvpall(), setvdot(), setvstring();
extern int getvdot(), getvmode();
extern void savevscrn(), getvscrn(), printstr();
extern void beep();
extern void enable(), disable();
</PRE>
<HR>
<A HREF="sw/romlib/romlib.mac"><B>ROMLIB.MAC</B></A><BR>
<PRE>
; macros for saving and restoring registers within procedures.
;
; Define SMALL if you are interfacing to a small memory model C program
; eg,
;
; MASM /DSMALL ROMLIB;
;
; DEFINE NREGISTER if you intend NOT working with register variables in your
; C program, eg,
;
; MASM /DNREGISTER ROMLIB;
;
;The default settings are LARGE MEMORY MODEL
; Registers SI and DI are saved.
;
ifdef SMALL
PTY macro macname
macname PROC NEAR
ENDM
curbase = 4
else
PTY macro macname
macname PROC FAR
ENDM
LARGE = 1
curbase = 6 ; offset to 1st parameter
endif
ifdef NREGISTER ; using register based variables
save MACRO
push bp
mov bp,sp
ENDM
restore MACRO
pop bp
ENDM
else
curbase = curbase + 4
REGISTER = 1
save MACRO
push bp
push si
push di
mov bp,sp
ENDM
restore MACRO
pop di
pop si
pop bp
ENDM
endif
base EQU curbase
</PRE>
<HR>
<A HREF="sw/romlib/romlib.asm"><B>ROMLIB.ASM</B></A><BR>
<PRE>
;***********************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -