DOS: use custom VGA color palette, rgui looks nice but still is not green
This commit is contained in:
parent
89fc14d165
commit
5c83e993ba
|
@ -46,7 +46,7 @@ static float lerp(float x, float y, float a, float b, float d)
|
||||||
return a + (b - a) * ((d - x) / (y - x));
|
return a + (b - a) * ((d - x) / (y - x));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_mode_13h()
|
static void vga_set_mode_13h()
|
||||||
{
|
{
|
||||||
__dpmi_regs r;
|
__dpmi_regs r;
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ static void set_mode_13h()
|
||||||
__dpmi_int(0x10, &r);
|
__dpmi_int(0x10, &r);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void return_to_text_mode()
|
static void vga_return_to_text_mode()
|
||||||
{
|
{
|
||||||
__dpmi_regs r;
|
__dpmi_regs r;
|
||||||
|
|
||||||
|
@ -62,24 +62,57 @@ static void return_to_text_mode()
|
||||||
__dpmi_int(0x10, &r);
|
__dpmi_int(0x10, &r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void vga_upload_palette()
|
||||||
|
{
|
||||||
|
unsigned i;
|
||||||
|
unsigned char r = 0;
|
||||||
|
unsigned char g = 0;
|
||||||
|
unsigned char b = 0;
|
||||||
|
|
||||||
|
outp(0x03c8, 0);
|
||||||
|
|
||||||
|
/* RGB332 */
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
outp(0x03c9, i * r * (63.0f / 255.0f));
|
||||||
|
outp(0x03c9, i * g * (63.0f / 255.0f));
|
||||||
|
outp(0x03c9, i * b * (63.0f / 255.0f));
|
||||||
|
|
||||||
|
r++;
|
||||||
|
|
||||||
|
if (i % 64 == 0)
|
||||||
|
{
|
||||||
|
r = 0;
|
||||||
|
g = 0;
|
||||||
|
b++;
|
||||||
|
}
|
||||||
|
else if (i % 8 == 0)
|
||||||
|
{
|
||||||
|
r = 0;
|
||||||
|
g++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void vga_vsync()
|
static void vga_vsync()
|
||||||
{
|
{
|
||||||
/* wait until any previous retrace has ended */
|
/* wait until any previous retrace has ended */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
while (inportb(0x3DA) & 8);
|
while (inportb(0x3da) & 8);
|
||||||
|
|
||||||
/* wait until a new retrace has just begun */
|
/* wait until a new retrace has just begun */
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
while (!(inportb(0x3DA) & 8));
|
while (!(inportb(0x3da) & 8));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void vga_gfx_create(void)
|
static void vga_gfx_create(void)
|
||||||
{
|
{
|
||||||
set_mode_13h();
|
vga_set_mode_13h();
|
||||||
|
vga_upload_palette();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *vga_gfx_init(const video_info_t *video,
|
static void *vga_gfx_init(const video_info_t *video,
|
||||||
|
@ -220,7 +253,7 @@ static void vga_gfx_free(void *data)
|
||||||
vga_menu_frame = NULL;
|
vga_menu_frame = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
return_to_text_mode();
|
vga_return_to_text_mode();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool vga_gfx_set_shader(void *data,
|
static bool vga_gfx_set_shader(void *data,
|
||||||
|
@ -292,7 +325,11 @@ static void vga_set_texture_frame(void *data,
|
||||||
{
|
{
|
||||||
for(x = 0; x < VGA_WIDTH; x++)
|
for(x = 0; x < VGA_WIDTH; x++)
|
||||||
{
|
{
|
||||||
vga_menu_frame[VGA_WIDTH * y + x] = lerp(0, 65535, 0, 254, video_frame[width * y + x]);
|
unsigned short pixel = video_frame[width * y + x];
|
||||||
|
unsigned r = (7.0f / 15.0f) * ((pixel & 0xF) >> 0);
|
||||||
|
unsigned g = (7.0f / 15.0f) * ((pixel & 0xF0) >> 4);
|
||||||
|
unsigned b = (3.0f / 15.0f) * ((pixel & 0xF00) >> 8);
|
||||||
|
vga_menu_frame[VGA_WIDTH * y + x] = (b << 6) | (g << 3) | r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue