dos32a-ng icon indicating copy to clipboard operation
dos32a-ng copied to clipboard

DPMI function 0800h crashes when trying to map more than 8Mb

Open viti95 opened this issue 10 months ago • 0 comments

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, &regs, &regs, &sregs);
  return (void *)(((unsigned long)regs.w.bx << 16) | regs.w.cx);
}

viti95 avatar Apr 05 '24 05:04 viti95