2015-02-24 15:17:50 +00:00
|
|
|
/* ReC98
|
|
|
|
* -----
|
2015-03-03 05:47:23 +00:00
|
|
|
* Main include file
|
2015-02-24 15:17:50 +00:00
|
|
|
*/
|
|
|
|
|
2020-03-13 00:42:40 +00:00
|
|
|
#ifndef REC98_H
|
|
|
|
#define REC98_H
|
|
|
|
|
2015-03-03 05:47:23 +00:00
|
|
|
#include <master.h>
|
2015-03-16 21:35:52 +00:00
|
|
|
#include <stddef.h>
|
2019-12-11 20:42:27 +00:00
|
|
|
#include "platform.h"
|
2019-11-08 20:03:03 +00:00
|
|
|
#include "pc98.h"
|
2020-06-10 20:54:22 +00:00
|
|
|
#include "planar.h"
|
2015-03-16 21:35:52 +00:00
|
|
|
|
|
|
|
// master.lib extensions
|
|
|
|
// ---------------------
|
|
|
|
#define palette_entry_rgb_show(fn) \
|
|
|
|
palette_entry_rgb(fn); \
|
|
|
|
palette_show();
|
2019-11-26 21:47:07 +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
|
|
|
|
// master.lib palettes use twice the bits per RGB component for more
|
|
|
|
// toning precision
|
2020-03-01 11:24:18 +00:00
|
|
|
typedef RGB<uint8_t, 256> RGB8;
|
[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<RGB8> Palette8;
|
|
|
|
#endif
|
2020-08-05 18:51:14 +00:00
|
|
|
|
|
|
|
// A version of master.lib's Point without the constructor, even in C++
|
|
|
|
struct point_t {
|
|
|
|
int x, y;
|
|
|
|
};
|
2015-03-16 21:35:52 +00:00
|
|
|
// ---------------------
|
2015-03-03 05:47:23 +00:00
|
|
|
|
2015-03-01 21:52:25 +00:00
|
|
|
// Macros
|
|
|
|
// ------
|
|
|
|
#define CLAMP_INC(val, max) \
|
|
|
|
(val)++; \
|
|
|
|
if((val) > (max)) { \
|
|
|
|
(val) = (max); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define CLAMP_DEC(val, min) \
|
|
|
|
(val)--; \
|
|
|
|
if((val) < (min)) { \
|
|
|
|
(val) = (min); \
|
|
|
|
}
|
|
|
|
|
2020-08-05 17:14:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
// This is, in fact, the only way to circumvent 16-bit promotion inside
|
|
|
|
// comparisons between two 8-bit values in C++. I kid you not.
|
|
|
|
static inline char ring_min() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define ring_min() 0
|
|
|
|
#endif
|
|
|
|
|
2015-03-01 21:52:25 +00:00
|
|
|
#define RING_INC(val, ring_end) \
|
|
|
|
(val)++; \
|
|
|
|
if((val) > (ring_end)) { \
|
|
|
|
(val) = 0; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RING_DEC(val, ring_end) \
|
|
|
|
(val)--; \
|
2020-08-05 17:14:38 +00:00
|
|
|
if(val < ring_min()) { \
|
2015-03-01 21:52:25 +00:00
|
|
|
(val) = ring_end; \
|
|
|
|
}
|
2015-03-07 16:35:30 +00:00
|
|
|
|
|
|
|
// Resident structure
|
|
|
|
#define RES_ID_LEN sizeof(RES_ID)
|
|
|
|
#define RES_ID_STRLEN (RES_ID_LEN - 1)
|
|
|
|
#define RES_PARASIZE ((sizeof(resident_t) + 0xF) >> 4)
|
2015-03-01 21:52:25 +00:00
|
|
|
// ------
|
|
|
|
|
2019-11-30 14:48:36 +00:00
|
|
|
typedef union {
|
|
|
|
struct {
|
2019-12-11 20:42:27 +00:00
|
|
|
int8_t lo, hi;
|
2019-11-30 14:48:36 +00:00
|
|
|
} byte;
|
2019-12-11 20:42:27 +00:00
|
|
|
int16_t v;
|
2019-11-30 14:48:36 +00:00
|
|
|
} twobyte_t;
|
|
|
|
|
2019-09-15 14:09:08 +00:00
|
|
|
/// Typedefs
|
|
|
|
/// --------
|
|
|
|
// Generic callback function types. Note the difference between function
|
|
|
|
// distance (nearfunc / farfunc) and pointer variable distance
|
|
|
|
// (t_near / t_far).
|
|
|
|
typedef void (near pascal *near nearfunc_t_near)(void);
|
|
|
|
typedef void ( far pascal *near farfunc_t_near)(void);
|
|
|
|
typedef void (near pascal * far nearfunc_t_far)(void);
|
|
|
|
typedef void ( far pascal * far farfunc_t_far)(void);
|
|
|
|
/// --------
|
|
|
|
|
2020-03-13 00:42:40 +00:00
|
|
|
#endif /* REC98_H */
|