From 774b1720282461f3630bbd4f5bba401097665a96 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 25 Oct 2020 14:02:12 +0100 Subject: [PATCH] [Maintenance] Only define pi_load_put_8_free() a single time The change of pi_free() from a macro to a function in TH05 doesn't require a complete redefinition. Part of P0124, funded by [Anonymous] and Blue Bolt. --- th02/formats/pi.h | 5 ++++- th02/formats/pi_slots.inc | 8 -------- th02/op_01.c | 8 ++++---- th02/op_03.c | 6 +++--- th02/op_05.cpp | 6 +++--- th05/formats/pi.h | 10 +--------- 6 files changed, 15 insertions(+), 28 deletions(-) diff --git a/th02/formats/pi.h b/th02/formats/pi.h index 969ae125..1c3f1d0a 100644 --- a/th02/formats/pi.h +++ b/th02/formats/pi.h @@ -15,6 +15,9 @@ int DEFCONV pi_load(int slot, const char *fn); void DEFCONV pi_palette_apply(int slot); +#define pi_free(slot) \ + graph_pi_free(&pi_headers[slot], pi_buffers[slot]); + // Displays the PI image in slot #[slot] at (⌊left/8⌋*8, top). Horizontally, // the image is cut off at 640 pixels; vertically, it is wrapped if it exceeds // the clipping frame defined via grc_setclip(). @@ -24,4 +27,4 @@ void DEFCONV pi_put_8(screen_x_t left, vram_y_t top, int slot); pi_load(slot, (fn)); \ pi_palette_apply(slot); \ pi_put_8(0, 0, slot); \ - graph_pi_free(&pi_headers[slot], pi_buffers[slot]); + pi_free(slot); \ diff --git a/th02/formats/pi_slots.inc b/th02/formats/pi_slots.inc index 50332736..1105266a 100644 --- a/th02/formats/pi_slots.inc +++ b/th02/formats/pi_slots.inc @@ -1,14 +1,6 @@ ; PI-related macros. Need to be in a separate file because TASM doesn't seem ; to like macro definitions inside segments... -freePISlot macro slot - push ds - push offset _pi_headers + (slot * size PiHeader) - push word ptr _pi_buffers + (slot * dPtrSize) + 2 - push word ptr _pi_buffers + (slot * dPtrSize) - call graph_pi_free -endm - freePISlotLarge macro slot push ds push offset _pi_headers + (slot * size PiHeader) diff --git a/th02/op_01.c b/th02/op_01.c index 2acad259..8c9c9566 100644 --- a/th02/op_01.c +++ b/th02/op_01.c @@ -110,7 +110,7 @@ void pascal near pi_load_put_8_free_to(const char near *fn, char page) graph_accesspage(page); pi_palette_apply(0); pi_put_8(0, 0, 0); - graph_pi_free(&pi_headers[0], pi_buffers[0]); + pi_free(0); } void op_animate(void) @@ -231,9 +231,9 @@ void start_demo(void) resident->shottype = 0; cfg_save(); text_clear(); - graph_pi_free(&pi_headers[0], pi_buffers[0]); - graph_pi_free(&pi_headers[1], pi_buffers[1]); - graph_pi_free(&pi_headers[2], pi_buffers[2]); + pi_free(0); + pi_free(1); + pi_free(2); gaiji_restore(); super_free(); game_exit(); diff --git a/th02/op_03.c b/th02/op_03.c index 2737cbf5..c431ceaa 100644 --- a/th02/op_03.c +++ b/th02/op_03.c @@ -34,7 +34,7 @@ void title_flash(void) frame_delay(1); } graph_showpage(0); - graph_pi_free(&pi_headers[0], pi_buffers[0]); - graph_pi_free(&pi_headers[1], pi_buffers[1]); - graph_pi_free(&pi_headers[2], pi_buffers[2]); + pi_free(0); + pi_free(1); + pi_free(2); } diff --git a/th02/op_05.cpp b/th02/op_05.cpp index e87e2f46..0471510f 100644 --- a/th02/op_05.cpp +++ b/th02/op_05.cpp @@ -213,9 +213,9 @@ void pascal shottype_menu(void) input_delay = 0; } } while(1); - graph_pi_free(&pi_headers[0], pi_buffers[0]); - graph_pi_free(&pi_headers[1], pi_buffers[1]); - graph_pi_free(&pi_headers[2], pi_buffers[2]); + pi_free(0); + pi_free(1); + pi_free(2); palette_black_out(1); } diff --git a/th05/formats/pi.h b/th05/formats/pi.h index 204e5253..e7e9ad59 100644 --- a/th05/formats/pi.h +++ b/th05/formats/pi.h @@ -1,16 +1,8 @@ #include "th03/formats/pi.h" +#undef pi_free int pascal pi_free(int slot); -#undef pi_load_put_8_free - -static inline void pi_load_put_8_free(int slot, const char *fn) { - pi_load(slot, fn); - pi_palette_apply(slot); - pi_put_8(0, 0, slot); - pi_free(0); -} - // Like pi_put_8() and pi_put_quarter_8(), but applying the mask with the given // ID while blitting. int pascal pi_put_mask_8(screen_x_t left, vram_y_t top, int slot, int mask_id);