[Platform] [PC-98] Hardware palette setters

Optimally, these are called *at most* once per frame. No need to
micro-optimize here.

Part of P0232, funded by [Anonymous].
This commit is contained in:
nmlgc 2023-02-21 22:48:56 +01:00
parent f1108b5548
commit d22c1e6db3
4 changed files with 31 additions and 12 deletions

View File

@ -56,7 +56,7 @@ th05:: $(TH05:\=bin\th05\)
.obj.com:
tlink /t /3 $**
bin\Pipeline\grzview.com: Pipeline\grzview.cpp th01\formats\grz.cpp bin\th01\f_imgd.obj
bin\Pipeline\grzview.com: Pipeline\grzview.cpp th01\formats\grz.cpp bin\th01\f_imgd.obj platform\x86real\pc98\palette.cpp
$(CC) $(CFLAGS) -Z -DGAME=1 -mt -lt -nbin\Pipeline\ @&&|
$**
| masters.lib

View File

@ -5,6 +5,7 @@
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "platform/x86real/pc98/palette.hpp"
#include "th01/formats/grz.h"
void grcg_setcolor_rmw(int col)
@ -17,16 +18,6 @@ void grcg_off_func(void)
grcg_off();
}
void z_palette_set_all_show(const Palette4& pal)
{
for(int i = 0; i < COLOR_COUNT; i++) {
outportb(0xA8, i);
outportb(0xAA, pal[i].c.g);
outportb(0xAC, pal[i].c.r);
outportb(0xAE, pal[i].c.b);
}
}
const Palette4 boss8_grz_pal = {
0x0, 0x0, 0x0,
0x5, 0x5, 0x5,
@ -71,7 +62,7 @@ int main(int argc, const char **argv)
}
text_hide();
graph_start();
z_palette_set_all_show(boss8_grz_pal);
palette_show(boss8_grz_pal);
grx_put(0);
dos_getch();

View File

@ -0,0 +1,20 @@
#include "platform.h"
#include "pc98.h"
#include "x86real.h"
#include "platform/x86real/pc98/palette.hpp"
void palette_show_single(uint4_t col, const RGB4& c)
{
outportb(0xA8, col);
outportb(0xAA, c.c.g);
outportb(0xAC, c.c.r);
outportb(0xAE, c.c.b);
}
void palette_show(const Palette4& pal)
{
const RGB4* color = pal.colors;
for(int i = 0; i < COLOR_COUNT; i++) {
palette_show_single(i, *(color++));
}
}

View File

@ -0,0 +1,8 @@
// 16-color VRAM palette
// ---------------------
// Sets the given hardware [col] to the given RGB value.
void palette_show_single(uint4_t col, const RGB4& c);
// Calls palette_show_single() for all colors in [pal].
void palette_show(const Palette4& pal);