mirror of https://github.com/nmlgc/ReC98.git
[Maintenance] Move `nearfunc_t_near* = farfunc_t_far;` workaround to decomp.hpp
Shinki will also require it. At least there's hope that we can get rid of it close to the completion of TH04 and TH05. Part of P0191, funded by nrook.
This commit is contained in:
parent
9ef178431a
commit
70b30221da
12
decomp.hpp
12
decomp.hpp
|
@ -55,6 +55,18 @@ template <class T> union StupidBytewiseWrapperAround {
|
|||
}
|
||||
#endif
|
||||
|
||||
// Trying to assign a `near` function to a nearfunc_t_near* outside the group
|
||||
// of the function will cause a fixup overflow error at link time. The only
|
||||
// known workaround involves lying to the compiler about the true distance of
|
||||
// the function, removing any declaration of the function from global scope to
|
||||
// prevent a redefinition error, and casting away its segment.
|
||||
// TODO: Might no longer be necessary once we can fully rely on segment names
|
||||
// for code layout, and don't have to mess with groups anymore.
|
||||
#define set_nearfunc_ptr_to_farfunc(ptr, func) { \
|
||||
void pascal far func(void); \
|
||||
ptr = reinterpret_cast<nearfunc_t_near>(func); \
|
||||
}
|
||||
|
||||
// poke() versions that actually inline with pseudoregisters
|
||||
// ---------------------------------------------------------
|
||||
#define pokew(sgm, off, val) { *(uint16_t far *)(MK_FP(sgm, off)) = val; }
|
||||
|
|
|
@ -1,17 +1,6 @@
|
|||
/// TRAM text overlaid on top of the playfield
|
||||
/// -------------------------------------------
|
||||
|
||||
/// Quite an awkward micro-optimization: The two overlay function pointers are
|
||||
/// `near`, despite the fact that we also have to set them from outside the
|
||||
/// group where the target functions are defined in. The only known way of
|
||||
/// achieving this in Turbo C++ 4.0J involves lying to the compiler about the
|
||||
/// true distance of the function. That's also why we can't correctly declare
|
||||
/// some of the target functions at global scope.
|
||||
#define set_nearfunc_ptr_to_farfunc(ptr, func) { \
|
||||
void pascal far func(void); \
|
||||
ptr = reinterpret_cast<nearfunc_t_near>(func); \
|
||||
}
|
||||
|
||||
extern nearfunc_t_near overlay1; // Rendered first
|
||||
extern nearfunc_t_near overlay2; // Rendered second
|
||||
|
||||
|
@ -32,6 +21,8 @@ void near overlay_black(void);
|
|||
);
|
||||
#endif
|
||||
|
||||
#include "decomp.hpp"
|
||||
|
||||
// Shows the fade-in effect, followed by either the stage or BGM title or the
|
||||
// blinking DEMO PLAY text.
|
||||
#define overlay_stage_enter() \
|
||||
|
|
Loading…
Reference in New Issue