void PC_DispChar (char x, char y, char c, char color) { char far *pscr; int offset;
offset = (int)y * DISP_MAX_X * 2 + (int)x * 2; /* Calculate position on the screen */ pscr = (char far *)MK_FP(DISP_BASE, offset); *pscr++ = c; /* Put character in video RAM */ *pscr = color; /* Put video attribute in video RAM */ } main() { PC_DispChar(20,14,50,12); return 0; }
用户67038 2007-6-19 20:41
这个在BC45下面编译通不过
*pscr++ = c;
好像是提示这个有错
用户67038 2007-6-19 20:40
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include <malloc.h>
#define DISP_MAX_X 80
#define DISP_BASE 0xB800
void PC_DispChar (char x, char y, char c, char color)
{
char far *pscr;
int offset;
offset = (int)y * DISP_MAX_X * 2 + (int)x * 2; /* Calculate position on the screen */
pscr = (char far *)MK_FP(DISP_BASE, offset);
*pscr++ = c; /* Put character in video RAM */
*pscr = color; /* Put video attribute in video RAM */
}
main()
{ PC_DispChar(20,14,50,12);
return 0;
}
用户67038 2007-6-19 20:24
/* MK_FP example */
#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <dos.h>
#include <malloc.h>
main()
{
char *str = "hello\n";
char far *farstr;
printf ("the address pointed to by str is %04X:%04X\n",
FP_SEG(str), FP_OFF(str));
farstr = (char far *)MK_FP( FP_SEG(str), FP_OFF(str));
printf ("the string pointed by far pointer is %s\n", farstr);
return 0;
}