dos32a-ng
dos32a-ng copied to clipboard
DPMI function 0800h crashes when trying to map more than 8Mb
While testing VESA modes on FastDoom I've discovered that DPMI function 0800h crashes if you try to map more than 8Mb. This issue also happens on other games, and it's why the NOLFB utility was created. This is the code I use (modified to avoid crashes).
#define MEMORY_LIMIT (128*64*1024)
void *DPMI_MAP_PHYSICAL(void *p, unsigned long size)
{
// Limit memory to 8Mb, mapping 16Mb crashes
if (size > MEMORY_LIMIT)
size = MEMORY_LIMIT;
/* DPMI call 800h map physical memory*/
PrepareRegisters();
regs.w.ax = 0x0800;
regs.w.bx = (unsigned short)(((unsigned long)p) >> 16);
regs.w.cx = (unsigned short)(((unsigned long)p) & 0xffff);
regs.w.si = (unsigned short)(size >> 16);
regs.w.di = (unsigned short)(size & 0xffff);
int386x(0x31, ®s, ®s, &sregs);
return (void *)(((unsigned long)regs.w.bx << 16) | regs.w.cx);
}