[Decompilation] [th05] .PI: EGC setup for masked blitting

And again.

Part of P0134, funded by [Anonymous].
This commit is contained in:
nmlgc 2021-02-16 18:24:41 +01:00
parent 76cefb1e37
commit 0dfe3bc3c9
2 changed files with 37 additions and 22 deletions

View File

@ -5,12 +5,16 @@
extern "C" {
#include <stddef.h>
#include "platform.h"
#include "x86real.h"
#include "pc98.h"
#include "planar.h"
#include "master.hpp"
#include "th05/formats/pi.h"
#include "th05/formats/pi_impl.hpp"
extern dots16_t near *pi_mask_ptr;
extern unsigned int pi_mask_y;
// Additionally takes:
// • `void far *pi_buf` in ES:SI
// • `pixel_t h` in DI
@ -18,6 +22,36 @@ void pascal near pi_put_8_rowloop(
screen_x_t left, vram_y_t top, pixel_t w, size_t stride_packed
);
#pragma option -k-
// MODDERS: Just give egc_setup_copy() a mask parameter and remove this
// abomination of a function.
void near pi_mask_setup_egc_and_advance(void)
{
#define mask_ptr _BX
egc_on();
outport2(EGC_ACTIVEPLANEREG, 0xFFF0);
outport2(EGC_READPLANEREG, 0xFF);
// EGC_COMPAREREAD | EGC_WS_PATREG | EGC_RL_MEMREAD
outport2(EGC_MODE_ROP_REG, 0x3100);
// Turbo C++ is too smart to emit this instruction with pseudo-registers!
__asm { mov ax, 0; }
outport(EGC_ADDRRESSREG, _AX);
outport2(EGC_BITLENGTHREG, 0xF);
mask_ptr = reinterpret_cast<uint16_t>(pi_mask_ptr);
_AX = (pi_mask_y & (PI_MASK_H - 1));
__asm { shl ax, 1; } // And again!
mask_ptr += _AX;
outport(EGC_MASKREG, *reinterpret_cast<dots16_t near *>(mask_ptr));
pi_mask_y++;
#undef mask_ptr
}
#pragma option -k
int DEFCONV pi_load(int slot, const char *fn)
{
_DI = slot;

View File

@ -1,3 +1,5 @@
_pi_mask_setup_egc_and_advance procdesc near
public PI_PUT_MASKED_8
pi_put_masked_8 proc far
@@mask_id = word ptr 6
@ -125,7 +127,7 @@ TEMP_ROW = RES_Y
sub _pi_put_masked_vram_offset, PLANE_SIZE
@@next_row:
call egc_setup_copy_with_pi_mask
call _pi_mask_setup_egc_and_advance
mov ax, GRAM_400
mov es, ax
assume es:nothing
@ -153,24 +155,3 @@ TEMP_ROW = RES_Y
jnz short @@put_row
retn 8
pi_put_masked_8_rowloop endp
; ---------------------------------------------------------------------------
egc_setup_copy_with_pi_mask proc near
call egc_on
outw2 EGC_ACTIVEPLANEREG, 0FFF0h
egc_selectpat
egc_setrop EGC_COMPAREREAD or EGC_WS_PATREG or EGC_RL_MEMREAD
outw2 EGC_ADDRRESSREG, 0
outw2 EGC_BITLENGTHREG, 0Fh
mov bx, _pi_mask_ptr
mov ax, _pi_mask_y
and ax, 3
shl ax, 1
add bx, ax
outw2 EGC_MASKREG, [bx]
inc _pi_mask_y
retn
egc_setup_copy_with_pi_mask endp