2019-11-08 20:03:03 +00:00
|
|
|
// ReC98
|
|
|
|
// -----
|
|
|
|
// PC-98 hardware constants not covered by master.lib
|
|
|
|
|
2024-05-22 21:30:38 +00:00
|
|
|
#ifndef PC98_H
|
2020-10-14 19:29:47 +00:00
|
|
|
#define PC98_H
|
|
|
|
|
2024-05-25 18:31:09 +00:00
|
|
|
#include "platform.h"
|
|
|
|
|
2020-08-21 18:13:08 +00:00
|
|
|
/// Spaces
|
|
|
|
/// ------
|
|
|
|
/// These don't necessarily have to be relative to the top-left corner of the
|
|
|
|
/// display.
|
|
|
|
|
|
|
|
// Display-space widths, heights, and object-space coordinates
|
|
|
|
typedef int pixel_t;
|
|
|
|
typedef unsigned int upixel_t;
|
2023-06-03 22:01:13 +00:00
|
|
|
typedef int8_t pixel_delta_8_t;
|
|
|
|
typedef uint8_t pixel_length_8_t;
|
2020-08-21 18:13:08 +00:00
|
|
|
|
2023-05-18 09:00:28 +00:00
|
|
|
// A version of master.lib's Point without the constructor, even in C++
|
|
|
|
struct point_t {
|
|
|
|
pixel_t x, y;
|
|
|
|
};
|
|
|
|
|
2020-08-21 18:13:08 +00:00
|
|
|
// VRAM widths and object-space coordinates
|
|
|
|
typedef int vram_byte_amount_t;
|
|
|
|
typedef int vram_word_amount_t;
|
|
|
|
typedef int vram_dword_amount_t;
|
2022-08-09 21:23:54 +00:00
|
|
|
typedef unsigned int uvram_byte_amount_t;
|
|
|
|
typedef unsigned int uvram_word_amount_t;
|
|
|
|
typedef unsigned int uvram_dword_amount_t;
|
2023-05-30 17:55:56 +00:00
|
|
|
|
2024-04-16 13:31:17 +00:00
|
|
|
// VRAM heights. Different from `pixel_t` in 200-line mode.
|
|
|
|
typedef int vram_h_t;
|
|
|
|
|
2023-10-17 09:03:41 +00:00
|
|
|
// TRAM widths or heights
|
2023-05-30 17:55:56 +00:00
|
|
|
typedef int tram_cell_amount_t;
|
2020-08-21 18:13:08 +00:00
|
|
|
/// ------
|
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
/// Coordinate systems
|
|
|
|
/// ------------------
|
|
|
|
/// All of these are relative to the top-left corner of the final display.
|
2024-06-29 14:14:35 +00:00
|
|
|
/// MODDERS: Remove the unsigned variants.
|
2020-08-20 19:59:45 +00:00
|
|
|
|
|
|
|
// Display-space coordinate, with [0; RES_X[ being the visible area.
|
|
|
|
typedef int screen_x_t;
|
|
|
|
typedef unsigned int uscreen_x_t;
|
2022-08-04 13:29:34 +00:00
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
// Display-space coordinate, with [0; RES_Y[ being the visible area. Does not
|
|
|
|
// care about 200- or 400-line graphics modes or vertical scrolling.
|
|
|
|
typedef int screen_y_t;
|
|
|
|
typedef unsigned int uscreen_y_t;
|
|
|
|
|
2023-05-18 09:00:28 +00:00
|
|
|
// Display-space point.
|
|
|
|
struct screen_point_t {
|
|
|
|
screen_x_t x;
|
|
|
|
screen_y_t y;
|
|
|
|
};
|
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
// VRAM X coordinate, ranging from 0 to (RES_X / BYTE_DOTS).
|
|
|
|
typedef int vram_x_t;
|
2022-08-04 13:29:34 +00:00
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
// VRAM Y coordinate, ranging from 0 to either 400 or 200 depending on the
|
|
|
|
// current graphics mode, and with an added vertical scrolling offset.
|
|
|
|
typedef int vram_y_t;
|
|
|
|
typedef unsigned int uvram_y_t;
|
|
|
|
|
|
|
|
// Text RAM X coordinate, ranging from 0 to (RES_X / GLYPH_HALF_W).
|
|
|
|
typedef int tram_x_t;
|
|
|
|
typedef unsigned int utram_x_t;
|
2022-08-04 13:29:34 +00:00
|
|
|
|
2020-08-20 19:59:45 +00:00
|
|
|
// Text RAM Y coordinate, ranging from 0 to (RES_Y / GLYPH_H).
|
|
|
|
typedef int tram_y_t;
|
|
|
|
typedef unsigned int utram_y_t;
|
|
|
|
/// ------------------
|
|
|
|
|
2019-11-26 11:51:08 +00:00
|
|
|
/// Text
|
|
|
|
/// ----
|
2019-12-28 20:20:48 +00:00
|
|
|
#define GAIJI_W 16
|
|
|
|
#define GAIJI_TRAM_W (GAIJI_W / 8)
|
2020-01-13 21:52:19 +00:00
|
|
|
#define GLYPH_HALF_W 8
|
|
|
|
#define GLYPH_FULL_W 16
|
|
|
|
#define GLYPH_H 16
|
2023-02-24 14:40:56 +00:00
|
|
|
#define GLYPH_HALF_H 8
|
2021-09-19 20:46:21 +00:00
|
|
|
|
|
|
|
#define shiftjis_w(literal) \
|
|
|
|
((sizeof(literal) - 1) * GLYPH_HALF_W)
|
2023-11-27 09:32:04 +00:00
|
|
|
|
|
|
|
// Text RAM attribute byte. ZUN bloat: Only keep tram_atrb_t.
|
|
|
|
typedef uint8_t tram_atrb_t;
|
|
|
|
typedef uint16_t tram_atrb2;
|
2019-11-26 11:51:08 +00:00
|
|
|
/// ----
|
|
|
|
|
2019-11-08 20:03:03 +00:00
|
|
|
/// Graphics
|
|
|
|
/// --------
|
2020-08-05 21:04:47 +00:00
|
|
|
#define BYTE_DOTS 8
|
2022-06-12 14:14:24 +00:00
|
|
|
#define BYTE_MASK (BYTE_DOTS - 1)
|
2023-02-25 15:35:08 +00:00
|
|
|
#define BYTE_BITS 3
|
2019-11-08 20:03:03 +00:00
|
|
|
#define RES_X 640
|
|
|
|
#define RES_Y 400
|
2020-08-05 21:04:47 +00:00
|
|
|
#define ROW_SIZE (RES_X / BYTE_DOTS)
|
2019-11-08 20:03:03 +00:00
|
|
|
#define PLANE_SIZE (ROW_SIZE * RES_Y)
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
|
2021-02-24 13:24:58 +00:00
|
|
|
#define PLANE_COUNT 4
|
|
|
|
|
2020-01-06 13:40:42 +00:00
|
|
|
typedef bool page_t;
|
|
|
|
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
#define COLOR_COUNT 16
|
2022-07-20 17:33:33 +00:00
|
|
|
|
|
|
|
#define COMPONENT_R 0
|
|
|
|
#define COMPONENT_G 1
|
|
|
|
#define COMPONENT_B 2
|
2021-05-16 20:40:36 +00:00
|
|
|
#define COMPONENT_COUNT 3
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
|
2023-06-25 18:41:05 +00:00
|
|
|
// Colors
|
|
|
|
// ------
|
2020-03-01 16:15:24 +00:00
|
|
|
// The 16-color mode supports 4 bits per RGB component, for a total of
|
2023-06-25 18:41:05 +00:00
|
|
|
// 4,096 colors.
|
|
|
|
|
|
|
|
typedef int8_t int4_t;
|
|
|
|
typedef uint8_t uint4_t;
|
|
|
|
|
|
|
|
// Video palette indices. ZUN bloat: Only keep vc_t.
|
|
|
|
typedef uint4_t vc_t;
|
|
|
|
typedef int4_t svc_t;
|
|
|
|
typedef uint16_t vc2;
|
|
|
|
typedef int16_t svc2; // Mainly needed for loops where ZUN used `int`.
|
|
|
|
|
|
|
|
// Intensity of a video color's R, G, or B component.
|
|
|
|
// ZUN bloat: Only keep vc_comp_t.
|
|
|
|
typedef uint4_t vc_comp_t;
|
|
|
|
typedef int4_t svc_comp_t;
|
|
|
|
typedef uint16_t vc_comp2;
|
|
|
|
typedef int16_t svc_comp2;
|
|
|
|
// ------
|
2020-03-01 16:15:24 +00:00
|
|
|
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
#ifdef __cplusplus
|
2020-03-01 11:24:18 +00:00
|
|
|
template <class ComponentType, int Range> union RGB {
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
struct {
|
|
|
|
ComponentType r, g, b;
|
|
|
|
} c;
|
2021-05-16 20:40:36 +00:00
|
|
|
ComponentType v[COMPONENT_COUNT];
|
2020-03-01 11:24:18 +00:00
|
|
|
|
|
|
|
// Yes, we actually need this function in certain cases where code
|
|
|
|
// generation calls for a 0 in the ComponentType.
|
|
|
|
static ComponentType min() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static ComponentType max() {
|
|
|
|
return (Range - 1);
|
|
|
|
}
|
2021-11-05 19:45:34 +00:00
|
|
|
|
|
|
|
void set(ComponentType r, ComponentType g, ComponentType b) {
|
|
|
|
this->c.r = r;
|
|
|
|
this->c.g = g;
|
|
|
|
this->c.b = b;
|
|
|
|
}
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class RGBType> struct Palette {
|
|
|
|
RGBType colors[COLOR_COUNT];
|
2020-03-03 10:45:03 +00:00
|
|
|
|
2020-03-01 11:24:18 +00:00
|
|
|
static int range() {
|
|
|
|
return RGBType::Range;
|
|
|
|
}
|
|
|
|
|
2023-06-25 18:41:05 +00:00
|
|
|
RGBType& operator [](vc2 col) {
|
2020-03-03 10:45:03 +00:00
|
|
|
return colors[col];
|
|
|
|
}
|
2020-03-01 17:48:44 +00:00
|
|
|
|
2023-06-25 18:41:05 +00:00
|
|
|
const RGBType& operator [](vc2 col) const {
|
2020-03-01 17:48:44 +00:00
|
|
|
return colors[col];
|
|
|
|
}
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
};
|
|
|
|
|
2023-06-25 18:41:05 +00:00
|
|
|
typedef RGB<svc_comp_t, 16> RGB4;
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
typedef Palette<RGB4> Palette4;
|
2021-10-30 23:11:05 +00:00
|
|
|
|
|
|
|
#define palette_foreach(tmp_col, tmp_comp, func) { \
|
|
|
|
for(tmp_col = 0; tmp_col < COLOR_COUNT; tmp_col++) { \
|
|
|
|
for(tmp_comp = 0; tmp_comp < COMPONENT_COUNT; tmp_comp++) { \
|
|
|
|
func \
|
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sets all components of all colors to the given grayscale [value].
|
|
|
|
#define palette_set_grayscale(dst, value, tmp_col, tmp_comp) \
|
|
|
|
palette_foreach(tmp_col, tmp_comp, { \
|
|
|
|
dst[tmp_col].v[tmp_comp] = value; \
|
|
|
|
})
|
|
|
|
|
|
|
|
#define palette_copy(dst, src, tmp_col, tmp_comp) \
|
|
|
|
palette_foreach(tmp_col, tmp_comp, { \
|
2022-06-05 18:03:48 +00:00
|
|
|
dst[tmp_col].v[tmp_comp] = src[tmp_col].v[tmp_comp]; \
|
2021-10-30 23:11:05 +00:00
|
|
|
})
|
[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.
2020-01-05 11:05:42 +00:00
|
|
|
#endif
|
2019-11-08 20:03:03 +00:00
|
|
|
/// --------
|
|
|
|
|
2020-01-10 20:25:29 +00:00
|
|
|
/// Memory segments
|
|
|
|
/// ---------------
|
2022-08-04 13:29:34 +00:00
|
|
|
|
2021-08-25 20:22:31 +00:00
|
|
|
#define SEG_TRAM_JIS 0xA000
|
|
|
|
#define SEG_TRAM_ATRB 0xA200
|
|
|
|
|
2020-01-10 20:25:29 +00:00
|
|
|
#define SEG_PLANE_B 0xA800
|
|
|
|
#define SEG_PLANE_R 0xB000
|
|
|
|
#define SEG_PLANE_G 0xB800
|
|
|
|
#define SEG_PLANE_E 0xE000
|
2020-09-06 22:21:38 +00:00
|
|
|
|
|
|
|
// Segment distance between B↔R↔G
|
|
|
|
#define SEG_PLANE_DIST_BRG 0x800
|
2022-08-04 13:29:34 +00:00
|
|
|
|
2020-09-06 22:21:38 +00:00
|
|
|
// Segment distance between G↔E
|
|
|
|
#define SEG_PLANE_DIST_E 0x2800
|
2020-01-10 20:25:29 +00:00
|
|
|
/// ---------------
|
2022-08-09 17:43:22 +00:00
|
|
|
|
|
|
|
/// EGC
|
|
|
|
/// ---
|
|
|
|
/// The PC-98 EGC always operates on 16 dots at a time.
|
|
|
|
|
|
|
|
static const int EGC_REGISTER_DOTS = 16;
|
2023-02-26 23:23:45 +00:00
|
|
|
static const int EGC_REGISTER_BITS = 4;
|
|
|
|
static const int EGC_REGISTER_MASK = (EGC_REGISTER_DOTS - 1);
|
2022-08-09 17:43:22 +00:00
|
|
|
static const int EGC_REGISTER_SIZE = (EGC_REGISTER_DOTS / BYTE_DOTS);
|
|
|
|
/// ---
|
2024-05-22 21:30:38 +00:00
|
|
|
|
|
|
|
#endif /* PC98_H */
|