diff --git a/Research/Borland C++ decompilation.md b/Research/Borland C++ decompilation.md index 1642bd48..8aa7ad19 100644 --- a/Research/Borland C++ decompilation.md +++ b/Research/Borland C++ decompilation.md @@ -39,6 +39,7 @@ where the scalar-type variable is declared in relation to them. |-|-| | `ADD [m8], imm8` | Only achievable through a C++ method operating on a member? | | `MOV AL, [m8]`
`ADD AL, imm8`
`MOV [m8], AL` | Opposite; *not* an inlined function | +| `CWD`
`SUB AX, DX`
`SAR AX, 1` | `AX / 2`, `AX` is *int* | ### Arithmetic on a register *after* assigning it to a variable? diff --git a/th03/chars/chars.h b/th03/chars/chars.hpp similarity index 57% rename from th03/chars/chars.h rename to th03/chars/chars.hpp index 8b61c5f8..18a3cc95 100644 --- a/th03/chars/chars.h +++ b/th03/chars/chars.hpp @@ -11,6 +11,23 @@ typedef enum { PLAYCHAR_COUNT = 9, } playchars_t; +// Encodes a playchars_t together with its alternate palette flag. +#pragma option -a1 +struct playchar_paletted_t { + unsigned char v; + + int filename_id() const { + return (v - 1); + } + + playchars_t char_id() const { + return static_cast(filename_id() / 2); + } +}; +#pragma option -a. + +#define TO_PALETTED(playchar) ((playchar << 1) + 1) + typedef struct { SPPoint8 aligned; SPPoint8 diagonal; diff --git a/th03/player/player.hpp b/th03/player/player.hpp index dee0d8de..c6685c83 100644 --- a/th03/player/player.hpp +++ b/th03/player/player.hpp @@ -37,10 +37,7 @@ typedef struct { uint8_t unused_1; unsigned char invincibility_time; char halfhearts; - - // ( + 1) << 1 | - unsigned char playchar_paletted; - + playchar_paletted_t playchar_paletted; speed_t speed; shot_mode_t shot_mode; unsigned char patnum_movement;