/* Set a 256 entry pallette with the values given in "palbuf". */ static void setmany(unsigned char palbuf[256][3], int start, int count) { unsigned char _far *fp; union REGS regs; struct SREGS sregs; unsigned i; #if defined( __GNUC__ ) /* This should work for most compilers - only tested with GNU C++, so it isn't turned on for anything else */ for (i=start;i<start+count;i++) { regs.x.ax = 0x1010; regs.x.bx = i; regs.h.ch = palbuf[i][1]; regs.h.cl = palbuf[i][2]; regs.h.dh = palbuf[i][0]; int86x(0x10, ®s, ®s, &sregs); return; } #elif defined( DOS386 ) /* Put the contents of the new palette into real memory, the only place I know that won't impact things is the video RAM. */ fp = MK_FP(_x386_zero_base_selector, 0xA0000); #else /* If you aren't using GNU C++ or Zortech C++ for 386 protected mode, then you need to use a compiler that supports access to all of the registers, including ES, to be able to set the pallette all at once. */ fp = MK_FP(0xA000, 0); #endif /* If you got here then you are using Zortech C++ */ for (i=start;i<start+count;i++) { fp[3*(i-start) ] = palbuf[i][0]; fp[3*(i-start)+1] = palbuf[i][1]; fp[3*(i-start)+2] = palbuf[i][2]; } regs.x.ax = 0x1012; regs.x.bx = start; regs.x.cx = count; regs.x.dx = 0; segread(&sregs); sregs.es = 0xA000; #if defined( DOS386 ) int86x_real(0x10, ®s, ®s, &sregs); #else int86x(0x10, ®s, ®s, &sregs); #endif /* Now clear off the values that got dumped into the video RAM */ for (i=0;i<3*count; i++) *fp++ = 0; }
static int setvesamode(int mode, int clear) { union REGS regs; struct SREGS sregs; struct ModeInfoBlock *VgaPtr = &VESAModeInfo; unsigned i; /* Call VESA function 1 to get mode info */ regs.h.ah = 0x4f; regs.h.al = 0x01; regs.x.cx = mode; #if defined( DOS386 ) regs.x.di = real_buf[0]; segread(&sregs); sregs.es = real_buf[1]; int86x_real(0x10, ®s, ®s, &sregs); if (regs.h.al != 0x4f || regs.h.ah != 0) return 0; for (i=0; i<sizeof(struct ModeInfoBlock); i++) ((unsigned char *)VgaPtr)[i] = real_ptr[i]; #elif defined( __GNUC__ ) regs.x.di = real_buf[0]; int86x(0x10, ®s, ®s, &sregs); if (regs.h.al != 0x4f || regs.h.ah != 0) return 0; for (i=0; i<sizeof(struct ModeInfoBlock); i++) ((unsigned char *)VgaPtr)[i] = real_ptr[i]; #else regs.x.di = FP_OFF(VgaPtr); sregs.es = FP_SEG(VgaPtr); int86x(0x10, ®s, ®s, &sregs); if (regs.h.al != 0x4f || regs.h.ah != 0) return 0; #endif /* The mode is supported - save useful information and initialize the graphics display */ line_length = VgaPtr->BytesPerScanLine; granularity = ((unsigned long)VgaPtr->WinGranularity) << 10; screen_maxx = VgaPtr->XResolution; screen_maxy = VgaPtr->YResolution; if (Reset_Display_Flag) { /* Now go set the video adapter into the requested mode */ regs.h.ah = 0x4f; regs.h.al = 0x02; regs.x.bx = mode; int86(0x10, ®s, ®s); return (regs.h.al == 0x4f && regs.h.ah == 0x00 ? 1 : 0); } }