[Maintenance] Make decomp.h exclusive to C++

eeb4e7e changed the final C translation unit that used this header to
C++, and we got some more helpful inline functions upcoming.

Part of P0136, funded by [Anonymous].
This commit is contained in:
nmlgc 2021-03-07 13:07:29 +01:00
parent c6c724ac21
commit 29abdd5b6a
15 changed files with 52 additions and 52 deletions

View File

@ -1,6 +1,6 @@
/* ReC98
* -----
* Macros to help decompiling the seemingly impossible
* Macros and inline functions to help decompiling the seemingly impossible
*/
// Flag comparisons
@ -55,48 +55,48 @@
//
// Also, hey, no need for the MK_FP() macro if we directly return the correct
// types.
#ifdef __cplusplus
} // extern "C" was a mistake
#if defined(__TURBOC__) && defined(__MSDOS__)
// Declared in <dos.h> in these compilers.
void __emit__(uint8_t __byte, ...);
#endif
struct Decomp_ES { void __seg* value() { return (void __seg *)(_ES); } };
struct Decomp_FS { void __seg* value() { return (void __seg *)(_FS); } };
struct Decomp_GS { void __seg* value() { return (void __seg *)(_GS); } };
struct Decomp_DI { void __near* value() { return (void __near *)(_DI); } };
// Removing [val] from the parameter lists of the template functions below
// perfects the inlining.
#define poked(sgm, off, val) \
_EAX = val; \
poked_eax((Decomp##sgm *)NULL, (Decomp##off *)NULL, (uint8_t)(0x89));
#define poke_or_d(sgm, off, val) \
_EAX = val; \
poked_eax((Decomp##sgm *)NULL, (Decomp##off *)NULL, (uint8_t)(0x09));
template <class Segment, class Offset> inline void poked_eax(
Segment *sgm, Offset *off, uint8_t op
) {
if(op == 0x89) {
*(uint32_t far *)(sgm->value() + off->value()) = _EAX;
} else if(op == 0x09) {
*(uint32_t far *)(sgm->value() + off->value()) |= _EAX;
}
}
#if defined(__TURBOC__) && defined(__MSDOS__)
// Declared in <dos.h> in these compilers.
void __emit__(uint8_t __byte, ...);
#endif
struct Decomp_ES { void __seg* value() { return (void __seg *)(_ES); } };
struct Decomp_FS { void __seg* value() { return (void __seg *)(_FS); } };
struct Decomp_GS { void __seg* value() { return (void __seg *)(_GS); } };
struct Decomp_DI { void __near* value() { return (void __near *)(_DI); } };
inline void poked_eax(Decomp_FS *sgm, Decomp_DI *off, uint8_t op) {
__emit__(0x66, 0x64, op, 0x05); // [op] FS:[DI], EAX
}
// Removing [val] from the parameter lists of the template functions below
// perfects the inlining.
#define poked(sgm, off, val) \
_EAX = val; \
poked_eax((Decomp##sgm *)NULL, (Decomp##off *)NULL, (uint8_t)(0x89));
#define poke_or_d(sgm, off, val) \
_EAX = val; \
poked_eax((Decomp##sgm *)NULL, (Decomp##off *)NULL, (uint8_t)(0x09));
template <class Segment, class Offset> inline void poked_eax(
Segment *sgm, Offset *off, uint8_t op
) {
if(op == 0x89) {
*(uint32_t far *)(sgm->value() + off->value()) = _EAX;
} else if(op == 0x09) {
*(uint32_t far *)(sgm->value() + off->value()) |= _EAX;
}
}
inline void poked_eax(Decomp_FS *sgm, Decomp_DI *off, uint8_t op) {
__emit__(0x66, 0x64, op, 0x05); // [op] FS:[DI], EAX
}
inline void poked_eax(Decomp_GS *sgm, Decomp_DI *off, uint8_t op) {
__emit__(0x66, 0x65, op, 0x05); // [op] GS:[DI], EAX
}
inline void poked_eax(Decomp_GS *sgm, Decomp_DI *off, uint8_t op) {
__emit__(0x66, 0x65, op, 0x05); // [op] GS:[DI], EAX
}
extern "C" {
#endif
// ---------------------------------------------------------
// 32-bit ASM instructions not supported by Turbo C++ 4.0J's built-in

View File

@ -10,7 +10,7 @@ void pascal end_pics_load_palette_show(const char *fn)
// Avoid symbol duplication...
#define egc_start_copy egc_start_copy_1
#include "th01/hardware/egcstart.c"
#include "th01/hardware/egcstart.cpp"
static const pixel_t PIC_W = (RES_X / 2);
static const pixel_t PIC_H = (RES_Y / 2);

View File

@ -1,4 +1,4 @@
#include "th01/hardware/egcstart.c"
#include "th01/hardware/egcstart.cpp"
void egc_copy_rect_1_to_0_16(screen_x_t x, vram_y_t y, pixel_t w, pixel_t h)
{

View File

@ -1,5 +1,5 @@
#include "decomp.hpp"
#include "th01/hardware/egc.h"
#include "decomp.h"
void pascal egc_start_copy(void)
{

View File

@ -10,7 +10,7 @@ extern "C" {
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "th01/hardware/egc.h"
#include "th01/hardware/graph.h"

View File

@ -7,7 +7,7 @@ extern "C" {
#include "platform.h"
#include "x86real.h"
#include "pc98.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "th01/hardware/egc.h"
#include "th01/math/vector.hpp"

View File

@ -6,7 +6,7 @@ extern "C" {
#include "platform.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "th03/formats/hfliplut.h"
}

View File

@ -11,7 +11,7 @@ extern "C" {
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "libs/sprite16/sprite16.h"
#include "th03/sprite16.hpp"

View File

@ -2,7 +2,7 @@
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "twobyte.h"
#include "master.hpp"

View File

@ -5,7 +5,7 @@ extern "C" {
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "th01/hardware/egc.h"

View File

@ -6,7 +6,7 @@ extern "C" {
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "th04/formats/cdg.h"
}

View File

@ -1,6 +1,6 @@
// Shared parts of the pi_put_*() functions.
#include "decomp.h"
#include "decomp.hpp"
inline void imul_di(int8_t factor) {
__emit__(0x6B, 0xFF, factor);

View File

@ -2,7 +2,7 @@
extern "C" {
#include "platform.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "th05/hardware/input.h"
}

View File

@ -6,7 +6,7 @@ extern "C" {
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "libs/kaja/kaja.h"
#include "th05/music/piano.h"

View File

@ -5,7 +5,7 @@ extern "C" {
#include <errno.h>
#include "platform.h"
#include "x86real.h"
#include "decomp.h"
#include "decomp.hpp"
#include "master.hpp"
#include "libs/kaja/kaja.h"
#include "th05/snd/snd.h"