Skip to content

Commit

Permalink
[Platform] [PC-98] Hardware palette setters
Browse files Browse the repository at this point in the history
Optimally, these are called *at most* once per frame. No need to
micro-optimize here.

Part of P0232, funded by [Anonymous].
  • Loading branch information
nmlgc committed Feb 28, 2023
1 parent f1108b5 commit d22c1e6
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile.mak
Expand Up @@ -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
Expand Down
13 changes: 2 additions & 11 deletions Pipeline/grzview.cpp
Expand Up @@ -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)
Expand All @@ -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,
Expand Down Expand Up @@ -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();
Expand Down
20 changes: 20 additions & 0 deletions platform/x86real/pc98/palette.cpp
@@ -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++));
}
}
8 changes: 8 additions & 0 deletions platform/x86real/pc98/palette.hpp
@@ -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);

0 comments on commit d22c1e6

Please sign in to comment.