From 687752160cfdfc5c2598afc1015c609b54bf2a5a Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 5 Sep 2020 18:51:10 +0200 Subject: [PATCH] [Maintenance] Start a new file for x86 FLAGS comparison macros Part of P0113, funded by Lmocinemod. --- decomp.h | 12 ++++++++++++ th03/sprite16.cpp | 9 ++++----- 2 files changed, 16 insertions(+), 5 deletions(-) create mode 100644 decomp.h diff --git a/decomp.h b/decomp.h new file mode 100644 index 00000000..4305199b --- /dev/null +++ b/decomp.h @@ -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 */ +// ---------------- diff --git a/th03/sprite16.cpp b/th03/sprite16.cpp index ce84a2dd..7e16b38a 100644 --- a/th03/sprite16.cpp +++ b/th03/sprite16.cpp @@ -9,6 +9,7 @@ extern "C" { #include #include "platform.h" #include "pc98.h" +#include "decomp.h" #include "libs/sprite16/sprite16.h" #include "th03/sprite16.hpp" @@ -22,8 +23,6 @@ extern "C" { #define put_w_words (_AL) #define should_draw_column (_SI) -#define RESULT_IS_ZERO (_FLAGS & 0x40) - #define SETUP_VARS(left, top, sprite_offset) \ sprite_offset_local = sprite_offset; \ putpos_left = left; \ @@ -49,7 +48,7 @@ extern "C" { do { \ putpos_left += 16; \ put_w_words--; \ - if(RESULT_IS_ZERO) { \ + if(FLAGS_ZERO) { \ return; \ } \ sprite_offset_local += (16 / 8); \ @@ -59,7 +58,7 @@ extern "C" { do { \ putpos_right -= 16; \ put_w_words--; \ - if(RESULT_IS_ZERO) { \ + if(FLAGS_ZERO) { \ return; \ } \ } while(putpos_right >= clip_right); @@ -107,7 +106,7 @@ put: should_draw_column = func; geninterrupt(SPRITE16); should_draw_column--; - if(RESULT_IS_ZERO) { + if(FLAGS_ZERO) { return; } _BX += _CX;