mirror of https://github.com/nmlgc/ReC98.git
[Decompilation] Templatize subpixels to offer both 16-bit and 8-bit variants
Yup, TH03 actually uses a 4.4 fixed-point format. Part of P0061, funded by Touhou Patch Center.
This commit is contained in:
parent
bb6b0f1cc3
commit
4d3d6acd28
|
@ -7,30 +7,37 @@ inline subpixel_t to_sp(float screen_v) {
|
|||
return static_cast<subpixel_t>(screen_v * 16.0f);
|
||||
}
|
||||
|
||||
class Subpixel {
|
||||
template <class T> class SubpixelBase {
|
||||
public:
|
||||
// Code generation will require direct access to v, if performing
|
||||
// arithmetic with a local variable...
|
||||
subpixel_t v;
|
||||
T v;
|
||||
|
||||
void operator +=(float screen_v) {
|
||||
this->v += to_sp(screen_v);
|
||||
this->v += static_cast<T>(to_sp(screen_v));
|
||||
}
|
||||
|
||||
void operator -=(float screen_v) {
|
||||
this->v -= to_sp(screen_v);
|
||||
this->v -= static_cast<T>(to_sp(screen_v));
|
||||
}
|
||||
|
||||
void operator =(float screen_v) {
|
||||
v = to_sp(screen_v);
|
||||
v = static_cast<T>(to_sp(screen_v));
|
||||
}
|
||||
};
|
||||
|
||||
struct SPPoint {
|
||||
Subpixel x, y;
|
||||
template <class T> struct SPPointBase {
|
||||
T x, y;
|
||||
|
||||
void set(float screen_x, float screen_y) {
|
||||
x = screen_x;
|
||||
y = screen_y;
|
||||
}
|
||||
};
|
||||
|
||||
// 16-bit (Q12.4)
|
||||
typedef SubpixelBase<subpixel_t> Subpixel;
|
||||
typedef SPPointBase<Subpixel> SPPoint;
|
||||
// 8-bit (Q4.4)
|
||||
typedef SubpixelBase<char> Subpixel8;
|
||||
typedef SPPointBase<Subpixel8> SPPoint8;
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
SPPoint8 struc
|
||||
db ? ; x
|
||||
db ? ; y
|
||||
SPPoint8 ends
|
Loading…
Reference in New Issue