endif
inc = -Isrc -Isrc/dos -Ilibs -Ilibs/imago/src -Ilibs/anim/src -Ilibs/mikmod/include
-opt = -O3 -ffast-math -fno-strict-aliasing
+#opt = -O3 -ffast-math -fno-strict-aliasing
dbg = -g
warn = -pedantic -Wall -Wno-unused-function -Wno-unused-variable
#ifdef __DJGPP__
#include <dpmi.h>
-#endif
+#include <sys/nearptr.h>
+
+#define virt_to_phys(v) ((v) + __djgpp_base_address)
+#define phys_to_virt(p) ((p) - __djgpp_base_address)
+
+#else /* not djgpp (basically watcom) */
+
+#define virt_to_phys(v) (v)
+#define phys_to_virt(p) (p)
+
+#endif /* __DJGPP__ */
#include "inttypes.h"
#include "util.h"
#include <stdio.h>
+#include <string.h>
#include "gfx.h"
#include "vbe.h"
#include "vga.h"
#include "cdpmi.h"
-#ifdef __DJGPP__
-#include <sys/nearptr.h>
-#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 SAME_BPP(a, b) \
((a) == (b) || ((a) == 16 && (b) == 15) || ((a) == 15 && (b) == 16) || \
((a) == 32 && (b) == 24) || ((a) == 24 && (b) == 32))
} else { \
paddr = ((uint32_t)pseg << 4) + poffs; \
} \
- (ptr) = (void*)paddr; \
+ (ptr) = (void*)phys_to_virt(paddr); \
} while(0)
/* hijack the "VESA" sig field, to pre-cache number of modes */
if(!(seg = dpmi_alloc(sizeof *info / 16, &sel))) {
return -1;
}
- lowbuf = (void*)((uint32_t)seg << 4);
+ lowbuf = (void*)phys_to_virt((uint32_t)seg << 4);
memcpy(lowbuf, "VBE2", 4);
if(!(seg = dpmi_alloc(sizeof *minf / 16, &sel))) {
return -1;
}
- lowbuf = (void*)((uint32_t)seg << 4);
+ lowbuf = (void*)phys_to_virt((uint32_t)seg << 4);
regs.eax = 0x4f01;
regs.ecx = mode;
if(!(seg = dpmi_alloc((sizeof *crtc + 15) / 16, &sel))) {
return -1;
}
- lowbuf = (void*)((uint32_t)seg << 4);
+ lowbuf = (void*)phys_to_virt((uint32_t)seg << 4);
memcpy(lowbuf, crtc, sizeof *crtc);
if(!(seg = dpmi_alloc((sz + 15) / 16, &sel))) {
return -1;
}
- lowbuf = (void*)((uint32_t)seg << 4);
+ lowbuf = (void*)phys_to_virt((uint32_t)seg << 4);
regs.eax = 0x4f04;
regs.edx = 1; /* save */
if(!(seg = dpmi_alloc((sz + 15) / 16, &sel))) {
return -1;
}
- lowbuf = (void*)((uint32_t)seg << 4);
+ lowbuf = (void*)phys_to_virt((uint32_t)seg << 4);
memcpy(lowbuf, stbuf, sz);