nuclear@0: #include nuclear@0: #include nuclear@0: #include nuclear@0: #include "wvga.h" nuclear@0: #include "dpmi.h" nuclear@0: nuclear@0: /* VGA DAC registers used for palette setting in 8bpp modes */ nuclear@0: #define VGA_DAC_STATE 0x3c7 nuclear@0: #define VGA_DAC_ADDR_RD 0x3c7 nuclear@0: #define VGA_DAC_ADDR_WR 0x3c8 nuclear@0: #define VGA_DAC_DATA 0x3c9 nuclear@0: nuclear@0: static void *framebuffer; nuclear@0: nuclear@0: int set_video_mode(int mode) nuclear@0: { nuclear@0: struct dpmi_real_regs regs; nuclear@0: nuclear@0: memset(®s, 0, sizeof regs); nuclear@0: regs.eax = mode; nuclear@0: dpmi_real_int(0x10, ®s); nuclear@0: nuclear@0: if(regs.eax == 0x100) { nuclear@0: return -1; nuclear@0: } nuclear@0: nuclear@0: if(mode != 3) { nuclear@3: framebuffer = dpmi_mmap(0xa0000, 64000); nuclear@0: } else { nuclear@0: dpmi_munmap((void*)0xa0000); nuclear@0: } nuclear@0: return 0; nuclear@0: } nuclear@0: nuclear@0: void set_palette(int idx, int *col, int count) nuclear@0: { nuclear@0: int i; nuclear@0: nuclear@0: __asm { nuclear@0: mov dx, VGA_DAC_ADDR_WR nuclear@0: mov eax, idx nuclear@0: out dx, al nuclear@0: } nuclear@0: nuclear@0: for(i=0; i> 2; nuclear@0: unsigned char g = *col++ >> 2; nuclear@0: unsigned char b = *col++ >> 2; nuclear@0: nuclear@0: __asm { nuclear@0: mov dx, VGA_DAC_DATA nuclear@0: mov al, r nuclear@0: out dx, al nuclear@0: mov al, g nuclear@0: out dx, al nuclear@0: mov al, b nuclear@0: out dx, al nuclear@0: } nuclear@0: } nuclear@0: } nuclear@0: nuclear@0: void set_pal_entry(int idx, int r, int g, int b) nuclear@0: { nuclear@0: int color[3]; nuclear@0: color[0] = r; nuclear@0: color[1] = g; nuclear@0: color[2] = b; nuclear@0: nuclear@0: set_palette(idx, color, 1); nuclear@0: } nuclear@0: nuclear@0: void copy_frame(void *pixels) nuclear@0: { nuclear@0: memcpy(framebuffer, pixels, 64000); nuclear@0: }