From a9c3825ce3cc4bd9e0744394d52f52b4dcc18d58 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 25 May 2024 19:20:06 +0200 Subject: [PATCH] [Maintenance] master.hpp: Remove `egc_selectpat()` and `egc_setrop()` egc_setrop() delivers nothing of value, just obscures the single thing it does, and disrupts the visual flow of the code. egc_selectpat() isn't much better, is used a total of two times, says almost nothing from its name alone, and MASTER.MAN's documentation adds so little of value that you'd want to consult hardware documentation anyway once you try to understand it. Not to mention that both add a dependency on master.hpp for what are actually PC-98 hardware constants. Part of P0284, funded by [Anonymous] and Blue Bolt. --- libs/master.lib/macros.inc | 8 -------- master.hpp | 9 ++------- th01/hardware/egc.inc | 4 ++-- th02_main.asm | 4 ++-- th04/hardware/egcrect.cpp | 6 ++++-- 5 files changed, 10 insertions(+), 21 deletions(-) diff --git a/libs/master.lib/macros.inc b/libs/master.lib/macros.inc index 40902b8c..945d3ae4 100644 --- a/libs/master.lib/macros.inc +++ b/libs/master.lib/macros.inc @@ -150,14 +150,6 @@ EGC_SHIFT_VRAM equ 00000h ; cpu write, vram read EGC_RL_MEMWRITE equ 00200h ; RL = pattern Register Load EGC_RL_MEMREAD equ 00100h ; ^at mem write, <-at mem read EGC_RL_NONE equ 00000h ; no touch - -egc_selectpat macro - outw2 EGC_READPLANEREG, 000FFh -endm - -egc_setrop macro mode_rop:rest - outw2 EGC_MODE_ROP_REG, mode_rop -endm ; --- ; .PI diff --git a/master.hpp b/master.hpp index 267b4ebb..444e09ba 100644 --- a/master.hpp +++ b/master.hpp @@ -114,17 +114,12 @@ long MASTER_RET dos_axdx(int axval, const char MASTER_PTR *strval); #define EGC_RL_MEMREAD 0x0100 /* ^at mem write, <-at mem read */ #define EGC_RL_NONE 0x0000 /* no touch */ +// TODO: Document and add helpful macros for the EGC raster ops + void MASTER_RET egc_on(void); void MASTER_RET egc_off(void); void MASTER_RET egc_start(void); -#define egc_selectpat() \ - outport(EGC_READPLANEREG, 0x00ff) - -// TODO: Document and add helpful macros for the EGC raster ops -#define egc_setrop(mode_rop) \ - outport(EGC_MODE_ROP_REG, mode_rop) - #ifdef PC98_H typedef void MASTER_RET egc_shift_func_t( screen_x_t x1, vram_y_t y1, screen_x_t x2, vram_y_t y2, pixel_t dots diff --git a/th01/hardware/egc.inc b/th01/hardware/egc.inc index 129af3d6..070121fe 100644 --- a/th01/hardware/egc.inc +++ b/th01/hardware/egc.inc @@ -19,8 +19,8 @@ endm EGC_SETUP_COPY macro outw2 EGC_ACTIVEPLANEREG, 0FFF0h - egc_selectpat - egc_setrop EGC_COMPAREREAD or EGC_WS_PATREG or EGC_RL_MEMREAD + outw2 EGC_READPLANEREG, 000FFh + outw2 EGC_MODE_ROP_REG, (EGC_COMPAREREAD or EGC_WS_PATREG or EGC_RL_MEMREAD) outw2 EGC_MASKREG, 0FFFFh outw2 EGC_ADDRRESSREG, 0 outw2 EGC_BITLENGTHREG, 0Fh diff --git a/th02_main.asm b/th02_main.asm index 5c443c58..10a77747 100644 --- a/th02_main.asm +++ b/th02_main.asm @@ -23710,10 +23710,10 @@ sub_19E2F proc far outw2 EGC_MASKREG, 0FFFFh outw2 EGC_ADDRRESSREG, 0 outw2 EGC_BITLENGTHREG, 0Fh - egc_setrop EGC_WS_PATREG or EGC_RL_MEMREAD + outw2 EGC_MODE_ROP_REG, (EGC_WS_PATREG or EGC_RL_MEMREAD) call @tiles_invalidate_rect$qiiii pascal, (176 shl 16) or 156, (96 shl 16) or 96 call @tiles_egc_render$qv - egc_setrop EGC_WS_ROP or 0FCh + outw2 EGC_MODE_ROP_REG, (EGC_WS_ROP or 0FCh) mov word_26D54, 152 mov ax, _scroll_line add word_26D54, ax diff --git a/th04/hardware/egcrect.cpp b/th04/hardware/egcrect.cpp index 30ec3a30..eee8edd0 100644 --- a/th04/hardware/egcrect.cpp +++ b/th04/hardware/egcrect.cpp @@ -36,7 +36,9 @@ void DEFCONV egc_copy_rect_1_to_0_16( _asm { cld; } #endif egc_start_copy(); - egc_setrop(EGC_COMPAREREAD | EGC_WS_ROP | EGC_RL_MEMREAD | 0xF0); + + // (EGC_COMPAREREAD | EGC_WS_ROP | EGC_RL_MEMREAD | 0xF0) + outport(EGC_MODE_ROP_REG, 0x29F0); // Using inline assembly rather than register pseudovariables to prevent // parameters from being moved to the SI register @@ -116,7 +118,7 @@ static void near egc_start_copy(void) } graph_egc_on(); outport(EGC_ACTIVEPLANEREG, 0xFFF0); - egc_selectpat(); + outport(EGC_READPLANEREG, 0x00FF); outport(EGC_MASKREG, 0xFFFF); _DX = EGC_ADDRRESSREG; outport(_DX, (_AX - _AX)); // :zunpet: