[Maintenance] Start a new file for x86 FLAGS comparison macros

Part of P0113, funded by Lmocinemod.
This commit is contained in:
nmlgc 2020-09-05 18:51:10 +02:00
parent be22a72b25
commit 687752160c
2 changed files with 16 additions and 5 deletions

12
decomp.h Normal file
View File

@ -0,0 +1,12 @@
/* ReC98
* -----
* Macros to help decompiling the seemingly impossible
*/
// Flag comparisons
// ----------------
// When used inside a conditional expression like
// if(FLAGS_*) { goto some_label; | return; }
// these assemble into the single given instruction.
#define FLAGS_ZERO (_FLAGS & 0x40) /* JZ */
// ----------------

View File

@ -9,6 +9,7 @@ extern "C" {
#include <dos.h> #include <dos.h>
#include "platform.h" #include "platform.h"
#include "pc98.h" #include "pc98.h"
#include "decomp.h"
#include "libs/sprite16/sprite16.h" #include "libs/sprite16/sprite16.h"
#include "th03/sprite16.hpp" #include "th03/sprite16.hpp"
@ -22,8 +23,6 @@ extern "C" {
#define put_w_words (_AL) #define put_w_words (_AL)
#define should_draw_column (_SI) #define should_draw_column (_SI)
#define RESULT_IS_ZERO (_FLAGS & 0x40)
#define SETUP_VARS(left, top, sprite_offset) \ #define SETUP_VARS(left, top, sprite_offset) \
sprite_offset_local = sprite_offset; \ sprite_offset_local = sprite_offset; \
putpos_left = left; \ putpos_left = left; \
@ -49,7 +48,7 @@ extern "C" {
do { \ do { \
putpos_left += 16; \ putpos_left += 16; \
put_w_words--; \ put_w_words--; \
if(RESULT_IS_ZERO) { \ if(FLAGS_ZERO) { \
return; \ return; \
} \ } \
sprite_offset_local += (16 / 8); \ sprite_offset_local += (16 / 8); \
@ -59,7 +58,7 @@ extern "C" {
do { \ do { \
putpos_right -= 16; \ putpos_right -= 16; \
put_w_words--; \ put_w_words--; \
if(RESULT_IS_ZERO) { \ if(FLAGS_ZERO) { \
return; \ return; \
} \ } \
} while(putpos_right >= clip_right); } while(putpos_right >= clip_right);
@ -107,7 +106,7 @@ put:
should_draw_column = func; should_draw_column = func;
geninterrupt(SPRITE16); geninterrupt(SPRITE16);
should_draw_column--; should_draw_column--;
if(RESULT_IS_ZERO) { if(FLAGS_ZERO) {
return; return;
} }
_BX += _CX; _BX += _CX;