X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdos%2Fvbe.c;h=009d5cac3485d7e8bab81874b0e077ad1be50c12;hb=a5c65ceb155188c8acee31a475f8db9f5b58f4b6;hp=5182e0af99f15ce1977914d026756ed7f04ec5e2;hpb=8a64d603ee67cd98070360b40938e123ea845154;p=dosdemo diff --git a/src/dos/vbe.c b/src/dos/vbe.c index 5182e0a..009d5ca 100644 --- a/src/dos/vbe.c +++ b/src/dos/vbe.c @@ -1,7 +1,20 @@ #include #include +#include #include "vbe.h" -#include "dpmi.h" +#include "cdpmi.h" +#include "inttypes.h" + +#ifdef __DJGPP__ +#include +#include + +#define SEG_ADDR(s) (((uint32_t)(s) << 4) - __djgpp_base_address) + +#define outp(p, v) outportb(p, v) +#else +#define SEG_ADDR(s) ((uint32_t)(s) << 4) +#endif /* VGA DAC registers used for palette setting in 8bpp modes */ #define VGA_DAC_STATE 0x3c7 @@ -14,14 +27,14 @@ struct vbe_info *vbe_get_info(void) { - static unsigned short info_block_seg; + static uint16_t info_block_seg, info_block_selector; static struct vbe_info *info; struct dpmi_real_regs regs; if(!info) { /* allocate 32 paragraphs (512 bytes) */ - info_block_seg = dpmi_alloc(32); - info = (struct vbe_info*)(info_block_seg << 4); + info_block_seg = dpmi_alloc(32, &info_block_selector); + info = (struct vbe_info*)SEG_ADDR(info_block_seg); } memcpy(info->sig, "VBE2", 4); @@ -37,14 +50,14 @@ struct vbe_info *vbe_get_info(void) struct vbe_mode_info *vbe_get_mode_info(int mode) { - static unsigned short mode_info_seg; + static uint16_t mode_info_seg, mode_info_selector; static struct vbe_mode_info *mi; struct dpmi_real_regs regs; if(!mi) { /* allocate 16 paragraphs (256 bytes) */ - mode_info_seg = dpmi_alloc(16); - mi = (struct vbe_mode_info*)(mode_info_seg << 4); + mode_info_seg = dpmi_alloc(16, &mode_info_selector); + mi = (struct vbe_mode_info*)SEG_ADDR(mode_info_seg); } memset(®s, 0, sizeof regs); @@ -85,7 +98,7 @@ int vbe_set_palette_bits(int bits) regs.ebx = bits << 8; /* bits in bh */ dpmi_real_int(0x10, ®s); - if((regs.eax >> 8) & 0xff == 3) { + if(((regs.eax >> 8) & 0xff) == 3) { return -1; } return regs.ebx >> 8 & 0xff; /* new color bits in bh */ @@ -98,11 +111,7 @@ void vbe_set_palette(int idx, int *col, int count, int bits) { int i, shift = 8 - bits; - __asm { - mov dx, VGA_DAC_ADDR_WR - mov eax, idx - out dx, al - } + outp(VGA_DAC_ADDR_WR, idx); for(i=0; i>= shift; } - __asm { - mov dx, VGA_DAC_DATA - mov al, r - out dx, al - mov al, g - out dx, al - mov al, b - out dx, al - } + outp(VGA_DAC_DATA, r); + outp(VGA_DAC_DATA, g); + outp(VGA_DAC_DATA, b); } } @@ -149,5 +152,5 @@ void print_mode_info(FILE *fp, struct vbe_mode_info *mi) fprintf(fp, "red bits: %d (mask: %x)\n", (int)mi->rmask_size, get_mask(mi->rmask_size, mi->rpos)); fprintf(fp, "green bits: %d (mask: %x)\n", (int)mi->gmask_size, get_mask(mi->gmask_size, mi->gpos)); fprintf(fp, "blue bits: %d (mask: %x)\n", (int)mi->bmask_size, get_mask(mi->bmask_size, mi->bpos)); - fprintf(fp, "framebuffer address: %x\n", mi->fb_addr); + fprintf(fp, "framebuffer address: %x\n", (unsigned int)mi->fb_addr); }