Define vga_set_palette() to define current display palette.

Signed-off-by: Laurent Vivier <Laurent@lvivier.info>
This commit is contained in:
Laurent Vivier 2008-09-17 14:53:27 +02:00
parent 094feb6fe2
commit 20e785f628
2 changed files with 31 additions and 2 deletions

View File

@ -15,7 +15,6 @@
#include "misc.h"
#include "vga.h"
#include "keyboard.h"
#include "head.h"
#include "config.h"
static QDGlobals qd;
@ -544,7 +543,7 @@ vga_init(char *mode)
pm = *(**hdl).gdPMap;
vga.video = (unsigned char *)pm->baseAddr;
vga.row_bytes = pm->rowBytes & 0x3fff;
vga.row_bytes = pm->rowBytes & 0x3fff;
vga.width = pm->bounds.right - pm->bounds.left;
vga.height = pm->bounds.bottom - pm->bounds.top;
vga.depth = pm->pixelSize;
@ -820,3 +819,29 @@ int vga_is_available(void)
{
return vga.enabled;
}
void vga_set_palette(RGBColor *palette)
{
GDHandle hdl = LMGetMainDevice();
short depth, gdID;
ColorSpec colors[256];
int i;
if (hdl == NULL || (*hdl)->gdType != clutType)
return;
depth = (*(*hdl)->gdPMap)->pixelSize;
if (depth < 1 || depth > 8)
return;
gdID = (*hdl)->gdID & 0xff;
for (i = 0; i < (1 << depth); i++)
{
colors[i].value = gdID;
colors[i].rgb.red = palette[i].red;
colors[i].rgb.green = palette[i].green;
colors[i].rgb.blue = palette[i].blue;
}
SetEntries(0, (1 << depth) - 1, colors);
}

View File

@ -7,6 +7,9 @@
#ifndef __VGA_H__
#define __VGA_H__
#include <macos/types.h>
#include <macos/video.h>
#include "head.h"
extern int vga_init(char *mode);
@ -22,5 +25,6 @@ extern unsigned long vga_get_width();
extern unsigned long vga_get_height();
extern unsigned long vga_get_video();
extern int vga_is_available(void);
extern void vga_set_palette(RGBColor *palette);
#endif