typedef struct BITMAP /* a bitmap structure */
{
int w, h; /* width and height in pixels */
int clip; /* flag if clipping is turned on */
int cl, cr, ct, cb; /* clip left, right, top and bottom values */
GFX_VTABLE *vtable; /* drawing functions */
void (*write_bank)(void); /* write bank selector, see bank.s */
void (*read_bank)(void); /* read bank selector, see bank.s */
void *dat; /* the memory we allocated for the bitmap */
int bitmap_id; /* for identifying sub-bitmaps */
void *extra; /* points to a structure with more info */
int x_ofs; /* horizontal offset (for sub-bitmaps) */
int y_ofs; /* vertical offset (for sub-bitmaps) */
int seg; /* bitmap segment */
unsigned char *line[0]; /* pointers to the start of each line */
} BITMAP;
/*********************************************/
/************ Video memory access ************/
/*********************************************/
#if !defined alleg_vidmem_unused
__INLINE__ unsigned long bmp_write_line(BITMAP *bmp, int line)
{
unsigned long result;
asm volatile (
" call *%3 "
: "=a" (result) /* result in eax */
: "d" (bmp), /* bitmap in edx */
"0" (line), /* line number in eax */
"r" (bmp->write_bank) /* the bank switch routine */
);
return result;
}
__INLINE__ unsigned long bmp_read_line(BITMAP *bmp, int line)
{
unsigned long result;
asm volatile (
" call *%3 "
: "=a" (result) /* result in eax */
: "d" (bmp), /* bitmap in edx */
"0" (line), /* line number in eax */
"r" (bmp->read_bank) /* the bank switch routine */
);
return result;
}
__INLINE__ void _putpixel(BITMAP *bmp, int x, int y, unsigned char color)
{
#if defined __GNUC__ && defined __i386__
asm (
" movw %w0, %%fs ; "
" .byte 0x64 ; "
" movb %b3, (%1, %2) "
: /* no outputs */
: "rm" (bmp->seg), /* segment selector in reg or mem */
"r" (bmp_write_line(bmp, y)), /* line pointer in reg */
"r" (x), /* line offset in reg */
"qi" (color) /* the pixel in reg or immediate */
);
#else
_farpokeb(bmp->seg, bmp_write_line(bmp, y) + x, color);
#endif
}
__INLINE__ unsigned char _getpixel(BITMAP *bmp, int x, int y)
{
#if defined __GNUC__ && defined __i386__
unsigned char result;
问题1:
也许是 DOS 或者 LINUX 下的东西,读写显存普通的话通过端口就可以了。高分辨率和颜色需要通过VESA接口分页读取,也不太难。具体可以参考某本叫VESA 图像设计(类似名字)的书,不过非常难找。既然是读写端口,就自然无法移植到 VC++ 上,因为windows下不允许,除非你自己写个驱动来读。
问题2:
DirectX也不能直接读写显存,只能通过它给你的方法去操作,好像是lockrect 还是什么的。
不过 ATI 显卡在窗口模式中一般会出问题。