mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Templatize RGB and palette types for 4- and 8-bit components
Right, PC-98 hardware only supports 4 bits per RGB component, for a total of 4,096 possible colors. The 8-bit RGB color values we've been seeing throughout the later games are a master.lib extension, to allow for more toning precision. Which TH01, with all its NIH syndrome, doesn't use. And yup, that means templates in the most basic header files… Since that would have meant renaming *everything* to compile as C++, I simply made these types exclusive to C++ code, thcrap style. Part of P0066, funded by Keyblade Wiedling Neko and Splashman.
This commit is contained in:
parent
042b7802bf
commit
0e19e52572
17
ReC98.h
17
ReC98.h
|
@ -14,17 +14,12 @@
|
||||||
palette_entry_rgb(fn); \
|
palette_entry_rgb(fn); \
|
||||||
palette_show();
|
palette_show();
|
||||||
|
|
||||||
// RGB color triple, used for the Palettes structure
|
#ifdef __cplusplus
|
||||||
typedef union {
|
// master.lib palettes use twice the bits per RGB component for more
|
||||||
struct {
|
// toning precision
|
||||||
unsigned char r, g, b;
|
typedef RGB<uint8_t> RGB8;
|
||||||
} c;
|
typedef Palette<RGB8> Palette8;
|
||||||
unsigned char v[3];
|
#endif
|
||||||
} rgb_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
rgb_t colors[16];
|
|
||||||
} palette_t;
|
|
||||||
// ---------------------
|
// ---------------------
|
||||||
|
|
||||||
// Macros
|
// Macros
|
||||||
|
|
26
pc98.h
26
pc98.h
|
@ -15,6 +15,32 @@
|
||||||
#define RES_Y 400
|
#define RES_Y 400
|
||||||
#define ROW_SIZE (RES_X / 8)
|
#define ROW_SIZE (RES_X / 8)
|
||||||
#define PLANE_SIZE (ROW_SIZE * RES_Y)
|
#define PLANE_SIZE (ROW_SIZE * RES_Y)
|
||||||
|
|
||||||
|
#define COLOR_COUNT 16
|
||||||
|
|
||||||
|
#pragma option -a1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
template <class ComponentType> union RGB {
|
||||||
|
struct {
|
||||||
|
ComponentType r, g, b;
|
||||||
|
} c;
|
||||||
|
ComponentType v[3];
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class RGBType> struct Palette {
|
||||||
|
RGBType colors[COLOR_COUNT];
|
||||||
|
};
|
||||||
|
|
||||||
|
// The 16-color mode supports 4 bits per RGB component, for a total of
|
||||||
|
// 4,096 colors
|
||||||
|
typedef int8_t uint4_t;
|
||||||
|
|
||||||
|
typedef RGB<uint4_t> RGB4;
|
||||||
|
typedef Palette<RGB4> Palette4;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#pragma option -a.
|
||||||
/// --------
|
/// --------
|
||||||
|
|
||||||
/// Keyboard
|
/// Keyboard
|
||||||
|
|
1
pc98.inc
1
pc98.inc
|
@ -16,4 +16,5 @@ RES_Y = 400
|
||||||
ROW_SIZE = (RES_X / 8)
|
ROW_SIZE = (RES_X / 8)
|
||||||
; Collides with master.lib's bfnt_entry_pat.asm
|
; Collides with master.lib's bfnt_entry_pat.asm
|
||||||
; PLANE_SIZE = (ROW_SIZE * RES_Y)
|
; PLANE_SIZE = (ROW_SIZE * RES_Y)
|
||||||
|
COLOR_COUNT = 16
|
||||||
; ========
|
; ========
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
|
#include "platform.h"
|
||||||
#include "pc98.h"
|
#include "pc98.h"
|
||||||
#include "th03/sprite16.hpp"
|
#include "th03/sprite16.hpp"
|
||||||
#include "th03/playfld.hpp"
|
#include "th03/playfld.hpp"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// Copy of the palette used during the logo, to allow non-blocking fades in
|
// Copy of the palette used during the logo, to allow non-blocking fades in
|
||||||
// contrast to master.lib's blocking palette_black_in() and palette_black_out()
|
// contrast to master.lib's blocking palette_black_in() and palette_black_out()
|
||||||
// functions. (Then again, master.lib has the PaletteTone global for that...)
|
// functions. (Then again, master.lib has the PaletteTone global for that...)
|
||||||
extern rgb_t zunsoft_palette[16];
|
extern Palette8 zunsoft_palette;
|
||||||
|
|
||||||
// Spawns [n] new explosions at the given screen-coordinate [origin] position.
|
// Spawns [n] new explosions at the given screen-coordinate [origin] position.
|
||||||
void pascal zunsoft_pyro_new(Point screen_origin, int n, char patnum_base);
|
void pascal zunsoft_pyro_new(Point screen_origin, int n, char patnum_base);
|
||||||
|
|
Loading…
Reference in New Issue