X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdos%2Fgfx.c;fp=src%2Fdos%2Fgfx.c;h=46cec310e5eb9c64c6fb915e10fdcfdca5046f7a;hb=0165ec15f868a16a70b56ada2d42db0cb69ea193;hp=a07d77a35eacc1bc52901ff7182d62e5df450add;hpb=a1f76b7a26c675e16cb78fecc9b6a1c0fc9c05c3;p=dosdemo diff --git a/src/dos/gfx.c b/src/dos/gfx.c index a07d77a..46cec31 100644 --- a/src/dos/gfx.c +++ b/src/dos/gfx.c @@ -6,15 +6,23 @@ #include #include #include "vbe.h" -#include "dpmi.h" +#include "cdpmi.h" +#ifdef __DJGPP__ +#include + +#define REALPTR(s, o) (void*)(((uint32_t)(s) << 4) - __djgpp_base_address + (uint32_t)(o)) +#else #define REALPTR(s, o) (void*)(((uint32_t)(s) << 4) + (uint32_t)(o)) +#endif + #define VBEPTR(x) REALPTR(((x) & 0xffff0000) >> 16, (x) & 0xffff) #define VBEPTR_SEG(x) (((x) & 0xffff0000) >> 16) #define VBEPTR_OFF(x) ((x) & 0xffff) #define SAME_BPP(a, b) \ - ((a) == (b) || (a) == 16 && (b) == 15 || (a) == 15 && (b) == 16 || (a) == 32 && (b) == 24 || (a) == 24 && (b) == 32) + ((a) == (b) || ((a) == 16 && (b) == 15) || ((a) == 15 && (b) == 16) || \ + ((a) == 32 && (b) == 24) || ((a) == 24 && (b) == 32)) static unsigned int make_mask(int sz, int pos); @@ -25,9 +33,14 @@ static int pal_bits = 6; void *set_video_mode(int xsz, int ysz, int bpp) { int i; - uint16_t *modes, best = 0; + static uint16_t *modes; + uint16_t best = 0; unsigned int fbsize; +#ifdef __DJGPP__ + __djgpp_nearptr_enable(); +#endif + /* check for VBE2 support and output some info */ if(!vbe_info) { if(!(vbe_info = vbe_get_info())) { @@ -41,8 +54,8 @@ void *set_video_mode(int xsz, int ysz, int bpp) return 0; } - printf("Graphics adapter: %s, %s (%s)\n", VBEPTR(vbe_info->oem_vendor_name_ptr), - VBEPTR(vbe_info->oem_product_name_ptr), VBEPTR(vbe_info->oem_product_rev_ptr)); + printf("Graphics adapter: %s, %s (%s)\n", (char*)VBEPTR(vbe_info->oem_vendor_name_ptr), + (char*)VBEPTR(vbe_info->oem_product_name_ptr), (char*)VBEPTR(vbe_info->oem_product_rev_ptr)); printf("Video memory: %dkb\n", vbe_info->total_mem << 6); modes = VBEPTR(vbe_info->vid_mode_ptr); @@ -141,20 +154,42 @@ void set_palette(int idx, int r, int g, int b) vbe_set_palette(idx, col, 1, pal_bits); } +#ifdef __WATCOMC__ +void wait_vsync_asm(void); +#pragma aux wait_vsync_asm = \ + "mov dx, 0x3da" \ + "l1:" \ + "in al, dx" \ + "and al, 0x8" \ + "jnz l1" \ + "l2:" \ + "in al, dx" \ + "and al, 0x8" \ + "jz l2" \ + modify[al dx]; + void wait_vsync(void) { - __asm { - mov dx, 0x3da - l1: - in al, dx - and al, 0x8 - jnz l1 - l2: - in al, dx - and al, 0x8 - jz l2 - } + wait_vsync_asm(); +} +#endif + +#ifdef __DJGPP__ +void wait_vsync(void) +{ + asm volatile ( + "mov $0x3da, %%dx\n\t" + "0:\n\t" + "in %%dx, %%al\n\t" + "and $8, %%al\n\t" + "jnz 0b\n\t" + "0:\n\t" + "in %%dx, %%al\n\t" + "and $8, %%al\n\t" + "jz 0b\n\t" + :::"%eax","%edx"); } +#endif static unsigned int make_mask(int sz, int pos) {