From df6b636053cd1a6f8eb3ac101363b509776b9a56 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 15 Mar 2020 20:11:55 +0100 Subject: [PATCH] [Decompilation] Add an inline function for VRAM offset calculation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Which actually does inline… in C++, because Turbo C++ doesn't support the `inline` keyword in C mode. So much for the superiority of that language, even in 1994… Part of P0083, funded by Yanga. --- ReC98.h | 7 +++++++ th01/hardware/graph.cpp | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ReC98.h b/ReC98.h index a40c3954..3461ab3b 100644 --- a/ReC98.h +++ b/ReC98.h @@ -116,6 +116,13 @@ extern dots8_t *VRAM_PLANE_E; #define VRAM_OFFSET(x, y) ((x) >> 3) + (y << 6) + (y << 4) +#ifdef __cplusplus +static inline unsigned int vram_offset_shift(int x, int y) +{ + return VRAM_OFFSET(x, y); +} +#endif + #define VRAM_CHUNK(plane, offset, bit_count) \ *(dots##bit_count##_t *)(VRAM_PLANE_##plane + offset) diff --git a/th01/hardware/graph.cpp b/th01/hardware/graph.cpp index 46e10871..08cca560 100644 --- a/th01/hardware/graph.cpp +++ b/th01/hardware/graph.cpp @@ -462,7 +462,7 @@ void graph_r_vline(int x, int top, int bottom, int col) egc_copy_rect_1_to_0(x, top, sizeof(pattern) * 8, bottom - top); return; } - vram_row_offset = VRAM_OFFSET(x, top); + vram_row_offset = vram_offset_shift(x, top); pattern = graph_r_pattern >> (x & 7); pattern |= graph_r_pattern << (16 - (x & 7)); @@ -611,7 +611,7 @@ void graph_r_line(int left, int top, int right, int bottom, int col) plot_loop(y_cur, h, y_direction, x_cur, w, 1); } restore_last: - vram_offset = VRAM_OFFSET(x_cur, y_cur) - 1; + vram_offset = vram_offset_shift(x_cur, y_cur) - 1; restore_at(vram_offset); end: if(!graph_r_restore_from_1) {