From a7230ba26a1f2faac3f6064855accc37d9df1094 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sat, 23 May 2020 18:20:56 +0200 Subject: [PATCH] [Maintenance] Move the EGC copy setup function to a separate file Too bad we still have to bother with renaming the function via #define in the few cases where an executable contains two or more copies of this function. We can't just make it `static`, since TH02 MAINE.EXE actually does far-call it from a different segment (and thus, translation unit). Part of P0094, funded by Yanga. --- th01/hardware/egccopyr.c | 19 +------------------ th01/hardware/egcscopy.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 18 deletions(-) create mode 100644 th01/hardware/egcscopy.c diff --git a/th01/hardware/egccopyr.c b/th01/hardware/egccopyr.c index 3c307895..0d14dc9f 100644 --- a/th01/hardware/egccopyr.c +++ b/th01/hardware/egccopyr.c @@ -1,21 +1,4 @@ -// Alternate version that sets the value first -#define OUTW2(port, val) __asm { \ - mov ax, val; \ - mov dx, port; \ - out dx, ax; \ -} - -void pascal egc_start_copy(void) -{ - egc_on(); - OUTW2(EGC_ACTIVEPLANEREG, 0xFFF0); - OUTW2(EGC_READPLANEREG, 0x00FF); - // EGC_COMPAREREAD | EGC_WS_PATREG | EGC_RL_MEMREAD - OUTW2(EGC_MODE_ROP_REG, 0x3100); - OUTW2(EGC_MASKREG, 0xFFFF); - OUTW2(EGC_ADDRRESSREG, 0); - OUTW2(EGC_BITLENGTHREG, 0xF); -} +#include "th01/hardware/egcscopy.c" void egc_copy_rect_1_to_0(int x, int y, int w, int h) { diff --git a/th01/hardware/egcscopy.c b/th01/hardware/egcscopy.c new file mode 100644 index 00000000..4c78319a --- /dev/null +++ b/th01/hardware/egcscopy.c @@ -0,0 +1,18 @@ +// Alternate version that sets the value first +#define OUTW2(port, val) __asm { \ + mov ax, val; \ + mov dx, port; \ + out dx, ax; \ +} + +void pascal egc_start_copy(void) +{ + egc_on(); + OUTW2(EGC_ACTIVEPLANEREG, 0xFFF0); + OUTW2(EGC_READPLANEREG, 0x00FF); + // EGC_COMPAREREAD | EGC_WS_PATREG | EGC_RL_MEMREAD + OUTW2(EGC_MODE_ROP_REG, 0x3100); + OUTW2(EGC_MASKREG, 0xFFFF); + OUTW2(EGC_ADDRRESSREG, 0); + OUTW2(EGC_BITLENGTHREG, 0xF); +}