X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fdos%2Fdrv_vga.c;fp=src%2Fdos%2Fdrv_vga.c;h=f6b7b01fd625f786c0045c7f646d868e0470fab1;hb=4e4ac855a9d53fd7dee3d640f3ab46740b991b5c;hp=0000000000000000000000000000000000000000;hpb=f87f51babcc2d9c15e1ecaca19c26acf58292bf7;p=retroray diff --git a/src/dos/drv_vga.c b/src/dos/drv_vga.c new file mode 100644 index 0000000..f6b7b01 --- /dev/null +++ b/src/dos/drv_vga.c @@ -0,0 +1,172 @@ +#include +#include +#include +#include "vidsys.h" +#include "drv.h" +#include "vga.h" + +static int init(void); +static void cleanup(void); +static int setmode(int mode); +static int curmode(void); + +static void setpal4(int idx, int count, const struct vid_color *col); +static void getpal4(int idx, int count, struct vid_color *col); +static void clear4(uint32_t color); +static void blitfb4(void *fb, int pitch); +static void fill4(int x, int y, int w, int h, uint32_t color); + +static void clear8(uint32_t color); +static void blitfb8(void *fb, int pitch); +static void fill8(int x, int y, int w, int h, uint32_t color); + + +static struct vid_driver drv; +static struct vid_drvops drvops = {init, cleanup, setmode, curmode}; +static struct vid_modeinfo modes[] = { + {3, 80, 25, 4}, + {0x12, 640, 480, 4}, + {0x13, 320, 200, 8} +}; + +static struct vid_gfxops gfxops_mode12h = { + 0, 0, setpal4, getpal4, vid_vsync, clear4, blitfb4, 0, fill4 }; +static struct vid_gfxops gfxops_mode13h = { + 0, 0, vga_setpal, vga_getpal, vid_vsync, clear8, blitfb8, 0, fill8 }; + +void vid_register_vga(void) +{ + int i; + + drv.name = "vga"; + drv.prio = 1; + drv.ops = &drvops; + drv.modes = modes; + drv.num_modes = sizeof modes / sizeof *modes; + + for(i=0; ir >> 2); + outp(VGA_DAC_DATA_PORT, col->g >> 2); + outp(VGA_DAC_DATA_PORT, col->b >> 2); + col++; + } +} + +void vga_getpal(int idx, int count, struct vid_color *col) +{ + int i; + outp(VGA_DAC_RADDR_PORT, idx); + for(i=0; ir = inp(VGA_DAC_DATA_PORT) << 2; + col->g = inp(VGA_DAC_DATA_PORT) << 2; + col->b = inp(VGA_DAC_DATA_PORT) << 2; + col++; + } +} + + +static int init(void) +{ + return 0; +} + +static void cleanup(void) +{ +} + +static int setmode(int mode) +{ + union REGS regs = {0}; + regs.w.ax = mode; + int386(0x10, ®s, ®s); + return 0; +} + +static int curmode(void) +{ + union REGS regs = {0}; + regs.w.ax = 0xf00; + int386(0x10, ®s, ®s); + return regs.x.eax & 0xff; +} + +static void setpal4(int idx, int count, const struct vid_color *col) +{ +} + +static void getpal4(int idx, int count, struct vid_color *col) +{ +} + +static void clear4(uint32_t color) +{ +} + +static void blitfb4(void *fb, int pitch) +{ +} + +static void fill4(int x, int y, int w, int h, uint32_t color) +{ +} + +static void clear8(uint32_t color) +{ + memset((void*)0xa0000, color, 64000); +} + +static void blitfb8(void *fb, int pitch) +{ + int i; + unsigned char *src = fb; + unsigned char *dest = (unsigned char*)0xa0000; + for(i=0; i<200; i++) { + memcpy(dest, src, 320); + dest += 320; + src += pitch; + } +} + +static void fill8(int x, int y, int w, int h, uint32_t color) +{ + int i; + unsigned char *fbptr = (unsigned char*)0xa0000; + + fbptr += y * 320 + x; + for(i=0; i