[PATCH 02/20] Convert jaguar C++ blitter code into plain C code |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- Subject: [PATCH 02/20] Convert jaguar C++ blitter code into plain C code
- From: Thomas Huth <huth@xxxxxxxxxxxxx>
- Date: Sat, 23 Dec 2023 08:21:04 +0100
---
src/jaguar/blitter.c | 247 ++++++++++++++++++++++---------------------
src/jaguar/blitter.h | 12 +--
2 files changed, 130 insertions(+), 129 deletions(-)
diff --git a/src/jaguar/blitter.c b/src/jaguar/blitter.c
index 3d4207d4..4081f1cf 100644
--- a/src/jaguar/blitter.c
+++ b/src/jaguar/blitter.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <stdio.h>
+#include <stdbool.h>
#include <string.h>
#include "jaguar.h"
#include "log.h"
@@ -2641,30 +2642,30 @@ blitter_done:
#ifdef USE_MIDSUMMER_BLITTER_MKII
-void ADDRGEN(uint32 &, uint32 &, bool, bool,
+void ADDRGEN(uint32 *, uint32 *, bool, bool,
uint16, uint16, uint32, uint8, uint8, uint8, uint8,
uint16, uint16, uint32, uint8, uint8, uint8, uint8);
void ADDARRAY(uint16 * addq, uint8 daddasel, uint8 daddbsel, uint8 daddmode,
uint64 dstd, uint32 iinc, uint8 initcin[], uint64 initinc, uint16 initpix,
uint32 istep, uint64 patd, uint64 srcd, uint64 srcz1, uint64 srcz2,
uint32 zinc, uint32 zstep);
-void ADD16SAT(uint16 &r, uint8 &co, uint16 a, uint16 b, uint8 cin, bool sat, bool eightbit, bool hicinh);
-void ADDAMUX(int16 &adda_x, int16 &adda_y, uint8 addasel, int16 a1_step_x, int16 a1_step_y,
+void ADD16SAT(uint16_t *r, uint8_t *co, uint16_t a, uint16_t b, uint8_t cin, bool sat, bool eightbit, bool hicinh);
+void ADDAMUX(int16 *adda_x, int16 *adda_y, uint8 addasel, int16 a1_step_x, int16 a1_step_y,
int16 a1_stepf_x, int16 a1_stepf_y, int16 a2_step_x, int16 a2_step_y,
int16 a1_inc_x, int16 a1_inc_y, int16 a1_incf_x, int16 a1_incf_y, uint8 adda_xconst,
bool adda_yconst, bool addareg, bool suba_x, bool suba_y);
-void ADDBMUX(int16 &addb_x, int16 &addb_y, uint8 addbsel, int16 a1_x, int16 a1_y,
+void ADDBMUX(int16 *addb_x, int16 *addb_y, uint8 addbsel, int16 a1_x, int16 a1_y,
int16 a2_x, int16 a2_y, int16 a1_frac_x, int16 a1_frac_y);
-void DATAMUX(int16 &data_x, int16 &data_y, uint32 gpu_din, int16 addq_x, int16 addq_y, bool addqsel);
-void ADDRADD(int16 &addq_x, int16 &addq_y, bool a1fracldi,
+void DATAMUX(int16_t *data_x, int16_t *data_y, uint32_t gpu_din, int16_t addq_x, int16_t addq_y, bool addqsel);
+void ADDRADD(int16 *addq_x, int16 *addq_y, bool a1fracldi,
uint16 adda_x, uint16 adda_y, uint16 addb_x, uint16 addb_y, uint8 modx, bool suba_x, bool suba_y);
-void DATA(uint64 &wdata, uint8 &dcomp, uint8 &zcomp, bool &nowrite,
+void DATA(uint64 *wdata, uint8 *dcomp, uint8 *zcomp, bool *nowrite,
bool big_pix, bool cmpdst, uint8 daddasel, uint8 daddbsel, uint8 daddmode, bool daddq_sel, uint8 data_sel,
- uint8 dbinh, uint8 dend, uint8 dstart, uint64 dstd, uint32 iinc, uint8 lfu_func, uint64 &patd, bool patdadd,
+ uint8 dbinh, uint8 dend, uint8 dstart, uint64 dstd, uint32 iinc, uint8 lfu_func, uint64 *patd, bool patdadd,
bool phrase_mode, uint64 srcd, bool srcdread, bool srczread, bool srcz2add, uint8 zmode,
bool bcompen, bool bkgwren, bool dcompen, uint8 icount, uint8 pixsize,
- uint64 &srcz, uint64 dstz, uint32 zinc);
-void COMP_CTRL(uint8 &dbinh, bool &nowrite,
+ uint64 *srcz, uint64 dstz, uint32 zinc);
+void COMP_CTRL(uint8 *dbinh, bool *nowrite,
bool bcompen, bool big_pix, bool bkgwren, uint8 dcomp, bool dcompen, uint8 icount,
uint8 pixsize, bool phrase_mode, uint8 srcd, uint8 zcomp);
#define VERBOSE_BLITTER_LOGGING
@@ -3709,7 +3710,7 @@ uint8 data_sel = ((!patdsel && !adddsel) || dzwrite ? 0x01 : 0x00)
| (adddsel || dzwrite ? 0x02 : 0x00);
uint32 address, pixAddr;
-ADDRGEN(address, pixAddr, gena2i, zaddr,
+ADDRGEN(&address, &pixAddr, gena2i, zaddr,
a1_x, a1_y, a1_base, a1_pitch, a1_pixsize, a1_width, a1_zoffset,
a2_x, a2_y, a2_base, a2_pitch, a2_pixsize, a2_width, a2_zoffset);
@@ -3767,7 +3768,7 @@ fflush(stdout);
}
#endif
//uint32 srcAddr, pixAddr;
-//ADDRGEN(srcAddr, pixAddr, gena2i, zaddr,
+//ADDRGEN(&srcAddr, &pixAddr, gena2i, zaddr,
// a1_x, a1_y, a1_base, a1_pitch, a1_pixsize, a1_width, a1_zoffset,
// a2_x, a2_y, a2_base, a2_pitch, a2_pixsize, a2_width, a2_zoffset);
srcd2 = srcd1;
@@ -3832,7 +3833,7 @@ fflush(stdout);
}
#endif
//uint32 srcAddr, pixAddr;
-//ADDRGEN(srcAddr, pixAddr, gena2i, zaddr,
+//ADDRGEN(&srcAddr, &pixAddr, gena2i, zaddr,
// a1_x, a1_y, a1_base, a1_pitch, a1_pixsize, a1_width, a1_zoffset,
// a2_x, a2_y, a2_base, a2_pitch, a2_pixsize, a2_width, a2_zoffset);
srcd2 = srcd1;
@@ -3897,7 +3898,7 @@ fflush(stdout);
}
#endif
//uint32 dstAddr, pixAddr;
-//ADDRGEN(dstAddr, pixAddr, gena2i, zaddr,
+//ADDRGEN(&dstAddr, &pixAddr, gena2i, zaddr,
// a1_x, a1_y, a1_base, a1_pitch, a1_pixsize, a1_width, a1_zoffset,
// a2_x, a2_y, a2_base, a2_pitch, a2_pixsize, a2_width, a2_zoffset);
dstd = ((uint64)JaguarReadLong(address, BLITTER) << 32) | (uint64)JaguarReadLong(address + 4, BLITTER);
@@ -4069,7 +4070,7 @@ Start and end from the address level of the pipeline are used.
uint8 pwidth = (((dend | dstart) & 0x07) == 0 ? 0x08 : (dend - dstart) & 0x07);
//uint32 dstAddr, pixAddr;
-//ADDRGEN(dstAddr, pixAddr, gena2i, zaddr,
+//ADDRGEN(&dstAddr, &pixAddr, gena2i, zaddr,
// a1_x, a1_y, a1_base, a1_pitch, a1_pixsize, a1_width, a1_zoffset,
// a2_x, a2_y, a2_base, a2_pitch, a2_pixsize, a2_width, a2_zoffset);
#ifdef VERBOSE_BLITTER_LOGGING
@@ -4190,12 +4191,12 @@ if (patfadd)
uint64 wdata;
uint8 dcomp, zcomp;
-DATA(wdata, dcomp, zcomp, winhibit,
+DATA(&wdata, &dcomp, &zcomp, &winhibit,
true, cmpdst, daddasel, daddbsel, daddmode, daddq_sel, data_sel, 0/*dbinh*/,
- dend, dstart, dstd, iinc, lfufunc, patd, patdadd,
+ dend, dstart, dstd, iinc, lfufunc, &patd, patdadd,
phrase_mode, srcd, false/*srcdread*/, false/*srczread*/, srcz2add, zmode,
bcompen, bkgwren, dcompen, icount & 0x07, pixsize,
- srcz, dstz, zinc);
+ &srcz, dstz, zinc);
/*
Seems that the phrase mode writes with DCOMPEN and DSTEN are corrupting inside of DATA: !!! FIX !!!
It's fairly random as well. 7CFE -> 7DFE, 7FCA -> 78CA, 7FA4 -> 78A4, 7F88 -> 8F88
@@ -4431,10 +4432,10 @@ fflush(stdout);
}
#endif
int16 adda_x, adda_y, addb_x, addb_y, data_x, data_y, addq_x, addq_y;
-ADDAMUX(adda_x, adda_y, addasel, a1_step_x, a1_step_y, a1_stepf_x, a1_stepf_y, a2_step_x, a2_step_y,
+ADDAMUX(&adda_x, &adda_y, addasel, a1_step_x, a1_step_y, a1_stepf_x, a1_stepf_y, a2_step_x, a2_step_y,
a1_inc_x, a1_inc_y, a1_incf_x, a1_incf_y, adda_xconst, adda_yconst, addareg, suba_x, suba_y);
-ADDBMUX(addb_x, addb_y, addbsel, a1_x, a1_y, a2_x, a2_y, a1_frac_x, a1_frac_y);
-ADDRADD(addq_x, addq_y, a1fracldi, adda_x, adda_y, addb_x, addb_y, modx, suba_x, suba_y);
+ADDBMUX(&addb_x, &addb_y, addbsel, a1_x, a1_y, a2_x, a2_y, a1_frac_x, a1_frac_y);
+ADDRADD(&addq_x, &addq_y, a1fracldi, adda_x, adda_y, addb_x, addb_y, modx, suba_x, suba_y);
#if 0//def VERBOSE_BLITTER_LOGGING
if (logBlit)
@@ -4456,10 +4457,10 @@ if (a1addx == 3)
a1_frac_x = addq_x, a1_frac_y = addq_y;
addasel = 2, addbsel = 0, a1fracldi = false;
-ADDAMUX(adda_x, adda_y, addasel, a1_step_x, a1_step_y, a1_stepf_x, a1_stepf_y, a2_step_x, a2_step_y,
+ADDAMUX(&adda_x, &adda_y, addasel, a1_step_x, a1_step_y, a1_stepf_x, a1_stepf_y, a2_step_x, a2_step_y,
a1_inc_x, a1_inc_y, a1_incf_x, a1_incf_y, adda_xconst, adda_yconst, addareg, suba_x, suba_y);
-ADDBMUX(addb_x, addb_y, addbsel, a1_x, a1_y, a2_x, a2_y, a1_frac_x, a1_frac_y);
-ADDRADD(addq_x, addq_y, a1fracldi, adda_x, adda_y, addb_x, addb_y, modx, suba_x, suba_y);
+ADDBMUX(&addb_x, &addb_y, addbsel, a1_x, a1_y, a2_x, a2_y, a1_frac_x, a1_frac_y);
+ADDRADD(&addq_x, &addq_y, a1fracldi, adda_x, adda_y, addb_x, addb_y, modx, suba_x, suba_y);
a1_x = addq_x, a1_y = addq_y;
}
@@ -4487,10 +4488,10 @@ fflush(stdout);
// int16 adda_x, int16 adda_y, int16 addb_x, int16 addb_y, uint8 modx, bool suba_x, bool suba_y)
//void DATAMUX(int16 &data_x, int16 &data_y, uint32 gpu_din, int16 addq_x, int16 addq_y, bool addqsel)
int16 adda_x, adda_y, addb_x, addb_y, data_x, data_y, addq_x, addq_y;
-ADDAMUX(adda_x, adda_y, addasel, a1_step_x, a1_step_y, a1_stepf_x, a1_stepf_y, a2_step_x, a2_step_y,
+ADDAMUX(&adda_x, &adda_y, addasel, a1_step_x, a1_step_y, a1_stepf_x, a1_stepf_y, a2_step_x, a2_step_y,
a1_inc_x, a1_inc_y, a1_incf_x, a1_incf_y, adda_xconst, adda_yconst, addareg, suba_x, suba_y);
-ADDBMUX(addb_x, addb_y, addbsel, a1_x, a1_y, a2_x, a2_y, a1_frac_x, a1_frac_y);
-ADDRADD(addq_x, addq_y, a1fracldi, adda_x, adda_y, addb_x, addb_y, modx, suba_x, suba_y);
+ADDBMUX(&addb_x, &addb_y, addbsel, a1_x, a1_y, a2_x, a2_y, a1_frac_x, a1_frac_y);
+ADDRADD(&addq_x, &addq_y, a1fracldi, adda_x, adda_y, addb_x, addb_y, modx, suba_x, suba_y);
#if 0//def VERBOSE_BLITTER_LOGGING
if (logBlit)
@@ -4759,7 +4760,7 @@ INT21/ a2_base
:IN);
*/
-void ADDRGEN(uint32 &address, uint32 &pixa, bool gena2, bool zaddr,
+void ADDRGEN(uint32 *address, uint32 *pixa, bool gena2, bool zaddr,
uint16 a1_x, uint16 a1_y, uint32 a1_base, uint8 a1_pitch, uint8 a1_pixsize, uint8 a1_width, uint8 a1_zoffset,
uint16 a2_x, uint16 a2_y, uint32 a2_base, uint8 a2_pitch, uint8 a2_pixsize, uint8 a2_width, uint8 a2_zoffset)
{
@@ -4778,27 +4779,27 @@ void ADDRGEN(uint32 &address, uint32 &pixa, bool gena2, bool zaddr,
uint32 pa = ya + x;
- /*uint32*/ pixa = pa << pixsize;
+ *pixa = pa << pixsize;
uint8 pt = ((pitch & 0x01) && !(pitch & 0x02) ? 0x01 : 0x00)
| (!(pitch & 0x01) && (pitch & 0x02) ? 0x02 : 0x00);
-// uint32 phradr = pixa << pt;
- uint32 phradr = (pixa >> 6) << pt;
- uint32 shup = (pitch == 0x03 ? (pixa >> 6) : 0);
+// uint32_t phradr = *pixa << pt;
+ uint32_t phradr = (*pixa >> 6) << pt;
+ uint32_t shup = (pitch == 0x03 ? (*pixa >> 6) : 0);
uint8 za = (zaddr ? zoffset : 0) & 0x03;
// uint32 addr = za + (phradr & 0x07) + (shup << 1) + base;
uint32 addr = za + phradr + (shup << 1) + base;
- /*uint32*/ address = ((pixa & 0x38) >> 3) | ((addr & 0x1FFFFF) << 3);
+ *address = ((*pixa & 0x38) >> 3) | ((addr & 0x1FFFFF) << 3);
#if 0//def VERBOSE_BLITTER_LOGGING
if (logBlit)
{
printf(" [gena2=%s, x=%04X, y=%04X, w=%1X, pxsz=%1X, ptch=%1X, b=%08X, zoff=%1X]\n", (gena2 ? "T" : "F"), x, y, width, pixsize, pitch, base, zoffset);
-printf(" [ytm=%X, ya=%X, pa=%X, pixa=%X, pt=%X, phradr=%X, shup=%X, za=%X, addr=%X, address=%X]\n", ytm, ya, pa, pixa, pt, phradr, shup, za, addr, address);
+printf(" [ytm=%X, ya=%X, pa=%X, pixa=%X, pt=%X, phradr=%X, shup=%X, za=%X, addr=%X, address=%X]\n", ytm, ya, pa, *pixa, pt, phradr, shup, za, addr, *address);
fflush(stdout);
}
#endif
- pixa &= 0x07;
+ *pixa &= 0x07;
/*
Entering INNER state...
[gena2=T, x=0002, y=0000, w=20, pxsz=4, ptch=0, b=000012BA, zoff=0]
@@ -5054,7 +5055,7 @@ static uint8 co[4];//These are preserved between calls...
//Note that the carry out is saved between calls to this function...
for(int i=0; i<4; i++)
- ADD16SAT(addq[i], co[i], adda[i], addb[i], cin[i], sat, eightbit, hicinh);
+ ADD16SAT(&addq[i], &co[i], adda[i], addb[i], cin[i], sat, eightbit, hicinh);
}
/*
@@ -5070,7 +5071,7 @@ INT16/ b
hicinh
:IN);
*/
-void ADD16SAT(uint16 &r, uint8 &co, uint16 a, uint16 b, uint8 cin, bool sat, bool eightbit, bool hicinh)
+void ADD16SAT(uint16_t *r, uint8_t *co, uint16_t a, uint16_t b, uint8_t cin, bool sat, bool eightbit, bool hicinh)
{
/*if (logBlit)
{
@@ -5087,11 +5088,11 @@ void ADD16SAT(uint16 &r, uint8 &co, uint16 a, uint16 b, uint8 cin, bool sat, boo
q |= qt & 0x0F00;
carry[3] = (carry[2] && !hicinh ? carry[2] : 0);
qt = (a & 0xF000) + (b & 0xF000) + (carry[3] << 12);
- co = (qt & 0x10000 ? 1 : 0);
+ *co = (qt & 0x10000 ? 1 : 0);
q |= qt & 0xF000;
uint8 btop = (eightbit ? (b & 0x0080) >> 7 : (b & 0x8000) >> 15);
- uint8 ctop = (eightbit ? carry[0] : co);
+ uint8_t ctop = (eightbit ? carry[0] : *co);
bool saturate = sat && (btop ^ ctop);
bool hisaturate = saturate && !eightbit;
@@ -5101,11 +5102,11 @@ void ADD16SAT(uint16 &r, uint8 &co, uint16 a, uint16 b, uint8 cin, bool sat, boo
fflush(stdout);
}*/
- r = (saturate ? (ctop ? 0x00FF : 0x0000) : q & 0x00FF);
- r |= (hisaturate ? (ctop ? 0xFF00 : 0x0000) : q & 0xFF00);
+ *r = (saturate ? (ctop ? 0x00FF : 0x0000) : q & 0x00FF);
+ *r |= (hisaturate ? (ctop ? 0xFF00 : 0x0000) : q & 0xFF00);
/*if (logBlit)
{
- printf("%04X (co=%u)\n", r, co);
+ printf("%04X (co=%u)\n", r, *co);
fflush(stdout);
}*/
}
@@ -5158,7 +5159,7 @@ INT16/ a1_incf_y
suba_x
suba_y :IN);
*/
-void ADDAMUX(int16 &adda_x, int16 &adda_y, uint8 addasel, int16 a1_step_x, int16 a1_step_y,
+void ADDAMUX(int16 *adda_x, int16 *adda_y, uint8 addasel, int16 a1_step_x, int16 a1_step_y,
int16 a1_stepf_x, int16 a1_stepf_y, int16 a2_step_x, int16 a2_step_y,
int16 a1_inc_x, int16 a1_inc_y, int16 a1_incf_x, int16 a1_incf_y, uint8 adda_xconst,
bool adda_yconst, bool addareg, bool suba_x, bool suba_y)
@@ -5221,8 +5222,8 @@ Suba_y16 := JOIN (suba_y16, suba_y, suba_y, suba_y, suba_y, suba_y, suba_y, suba
Adda_x := EO (adda_x, suba_x16, addas_x);
Adda_y := EO (adda_y, suba_y16, addas_y);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
- adda_x = addas_x ^ (suba_x ? 0xFFFF : 0x0000);
- adda_y = addas_y ^ (suba_y ? 0xFFFF : 0x0000);
+ *adda_x = addas_x ^ (suba_x ? 0xFFFF : 0x0000);
+ *adda_y = addas_y ^ (suba_y ? 0xFFFF : 0x0000);
//////////////////////////////////////////////////////////////////////////////////////
//END;
@@ -5250,7 +5251,7 @@ INT16/ a1_frac_y
:IN);
INT16/ zero16 :LOCAL;
BEGIN*/
-void ADDBMUX(int16 &addb_x, int16 &addb_y, uint8 addbsel, int16 a1_x, int16 a1_y,
+void ADDBMUX(int16 *addb_x, int16 *addb_y, uint8 addbsel, int16 a1_x, int16 a1_y,
int16 a2_x, int16 a2_y, int16 a1_frac_x, int16 a1_frac_y)
{
@@ -5264,8 +5265,8 @@ Addb_y := MX4 (addb_y, a1_y, a2_y, a1_frac_y, zero16, addbselb[0..1]);*/
int16 xterm[4], yterm[4];
xterm[0] = a1_x, xterm[1] = a2_x, xterm[2] = a1_frac_x, xterm[3] = 0;
yterm[0] = a1_y, yterm[1] = a2_y, yterm[2] = a1_frac_y, yterm[3] = 0;
- addb_x = xterm[addbsel & 0x03];
- addb_y = yterm[addbsel & 0x03];
+ *addb_x = xterm[addbsel & 0x03];
+ *addb_y = yterm[addbsel & 0x03];
//////////////////////////////////////////////////////////////////////////////////////
//END;
@@ -5289,7 +5290,7 @@ INT16/ addq_y
INT16/ gpu_lo, gpu_hi
:LOCAL;
BEGIN*/
-void DATAMUX(int16 &data_x, int16 &data_y, uint32 gpu_din, int16 addq_x, int16 addq_y, bool addqsel)
+void DATAMUX(int16_t *data_x, int16_t *data_y, uint32_t gpu_din, int16_t addq_x, int16_t addq_y, bool addqsel)
{
/*Gpu_lo := JOIN (gpu_lo, gpu_din{0..15});
Gpu_hi := JOIN (gpu_hi, gpu_din{16..31});
@@ -5298,8 +5299,8 @@ Addqselb := BUF8 (addqselb, addqsel);
Data_x := MX2 (data_x, gpu_lo, addq_x, addqselb);
Data_y := MX2 (data_y, gpu_hi, addq_y, addqselb);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
- data_x = (addqsel ? addq_x : (int16)(gpu_din & 0xFFFF));
- data_y = (addqsel ? addq_y : (int16)(gpu_din >> 16));
+ *data_x = (addqsel ? addq_x : (int16)(gpu_din & 0xFFFF));
+ *data_y = (addqsel ? addq_y : (int16)(gpu_din >> 16));
//////////////////////////////////////////////////////////////////////////////////////
//END;
@@ -5345,7 +5346,7 @@ INT16/ addb_y
BEGIN
Zero := TIE0 (zero);*/
-void ADDRADD(int16 &addq_x, int16 &addq_y, bool a1fracldi,
+void ADDRADD(int16 *addq_x, int16 *addq_y, bool a1fracldi,
uint16 adda_x, uint16 adda_y, uint16 addb_x, uint16 addb_y, uint8 modx, bool suba_x, bool suba_y)
{
@@ -5388,8 +5389,8 @@ Addq_y := JOIN (addq_y, addq_y[0..15]);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
int16 mask[8] = { 0xFFFF, 0xFFFE, 0xFFFC, 0xFFF8, 0xFFF0, 0xFFE0, 0xFFC0, 0x0000 };
- addq_x = addqt_x & mask[modx];
- addq_y = addqt_y & 0xFFFF;
+ *addq_x = addqt_x & mask[modx];
+ *addq_y = addqt_y & 0xFFFF;
//////////////////////////////////////////////////////////////////////////////////////
//Unused[0-1] := DUMMY (unused[0-1]);
@@ -5463,12 +5464,12 @@ INT32/ gpu_din // GPU data bus
:IN);
*/
-void DATA(uint64 &wdata, uint8 &dcomp, uint8 &zcomp, bool &nowrite,
+void DATA(uint64 *wdata, uint8 *dcomp, uint8 *zcomp, bool *nowrite,
bool big_pix, bool cmpdst, uint8 daddasel, uint8 daddbsel, uint8 daddmode, bool daddq_sel, uint8 data_sel,
- uint8 dbinh, uint8 dend, uint8 dstart, uint64 dstd, uint32 iinc, uint8 lfu_func, uint64 &patd, bool patdadd,
+ uint8 dbinh, uint8 dend, uint8 dstart, uint64 dstd, uint32 iinc, uint8 lfu_func, uint64 *patd, bool patdadd,
bool phrase_mode, uint64 srcd, bool srcdread, bool srczread, bool srcz2add, uint8 zmode,
bool bcompen, bool bkgwren, bool dcompen, uint8 icount, uint8 pixsize,
- uint64 &srcz, uint64 dstz, uint32 zinc)
+ uint64 *srcz, uint64 dstz, uint32 zinc)
{
/*
Stuff we absolutely *need* to have passed in/out:
@@ -5535,25 +5536,25 @@ Zstep := JOIN (zstep, zstep[0..31]);*/
/*Datacomp := DATACOMP (dcomp[0..7], cmpdst, dstdlo, dstdhi, patdlo, patdhi, srcdlo, srcdhi);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
- dcomp = 0;
- uint64 cmpd = patd ^ (cmpdst ? dstd : srcd);
+ *dcomp = 0;
+ uint64 cmpd = *patd ^ (cmpdst ? dstd : srcd);
if ((cmpd & 0x00000000000000FFLL) == 0)
- dcomp |= 0x01;
+ *dcomp |= 0x01;
if ((cmpd & 0x000000000000FF00LL) == 0)
- dcomp |= 0x02;
+ *dcomp |= 0x02;
if ((cmpd & 0x0000000000FF0000LL) == 0)
- dcomp |= 0x04;
+ *dcomp |= 0x04;
if ((cmpd & 0x00000000FF000000LL) == 0)
- dcomp |= 0x08;
+ *dcomp |= 0x08;
if ((cmpd & 0x000000FF00000000LL) == 0)
- dcomp |= 0x10;
+ *dcomp |= 0x10;
if ((cmpd & 0x0000FF0000000000LL) == 0)
- dcomp |= 0x20;
+ *dcomp |= 0x20;
if ((cmpd & 0x00FF000000000000LL) == 0)
- dcomp |= 0x40;
+ *dcomp |= 0x40;
if ((cmpd & 0xFF00000000000000LL) == 0)
- dcomp |= 0x80;
+ *dcomp |= 0x80;
//////////////////////////////////////////////////////////////////////////////////////
// Zed comparator for Z-buffer operations
@@ -5569,38 +5570,38 @@ Zstep := JOIN (zstep, zstep[0..31]);*/
with srcshift bits 4 & 5 selecting the start position
*/
//So... basically what we have here is:
- zcomp = 0;
+ *zcomp = 0;
- if ((((srcz & 0x000000000000FFFFLL) < (dstz & 0x000000000000FFFFLL)) && (zmode & 0x01))
- || (((srcz & 0x000000000000FFFFLL) == (dstz & 0x000000000000FFFFLL)) && (zmode & 0x02))
- || (((srcz & 0x000000000000FFFFLL) > (dstz & 0x000000000000FFFFLL)) && (zmode & 0x04)))
- zcomp |= 0x01;
+ if ((((*srcz & 0x000000000000FFFFLL) < (dstz & 0x000000000000FFFFLL)) && (zmode & 0x01))
+ || (((*srcz & 0x000000000000FFFFLL) == (dstz & 0x000000000000FFFFLL)) && (zmode & 0x02))
+ || (((*srcz & 0x000000000000FFFFLL) > (dstz & 0x000000000000FFFFLL)) && (zmode & 0x04)))
+ *zcomp |= 0x01;
- if ((((srcz & 0x00000000FFFF0000LL) < (dstz & 0x00000000FFFF0000LL)) && (zmode & 0x01))
- || (((srcz & 0x00000000FFFF0000LL) == (dstz & 0x00000000FFFF0000LL)) && (zmode & 0x02))
- || (((srcz & 0x00000000FFFF0000LL) > (dstz & 0x00000000FFFF0000LL)) && (zmode & 0x04)))
- zcomp |= 0x02;
+ if ((((*srcz & 0x00000000FFFF0000LL) < (dstz & 0x00000000FFFF0000LL)) && (zmode & 0x01))
+ || (((*srcz & 0x00000000FFFF0000LL) == (dstz & 0x00000000FFFF0000LL)) && (zmode & 0x02))
+ || (((*srcz & 0x00000000FFFF0000LL) > (dstz & 0x00000000FFFF0000LL)) && (zmode & 0x04)))
+ *zcomp |= 0x02;
- if ((((srcz & 0x0000FFFF00000000LL) < (dstz & 0x0000FFFF00000000LL)) && (zmode & 0x01))
- || (((srcz & 0x0000FFFF00000000LL) == (dstz & 0x0000FFFF00000000LL)) && (zmode & 0x02))
- || (((srcz & 0x0000FFFF00000000LL) > (dstz & 0x0000FFFF00000000LL)) && (zmode & 0x04)))
- zcomp |= 0x04;
+ if ((((*srcz & 0x0000FFFF00000000LL) < (dstz & 0x0000FFFF00000000LL)) && (zmode & 0x01))
+ || (((*srcz & 0x0000FFFF00000000LL) == (dstz & 0x0000FFFF00000000LL)) && (zmode & 0x02))
+ || (((*srcz & 0x0000FFFF00000000LL) > (dstz & 0x0000FFFF00000000LL)) && (zmode & 0x04)))
+ *zcomp |= 0x04;
- if ((((srcz & 0xFFFF000000000000LL) < (dstz & 0xFFFF000000000000LL)) && (zmode & 0x01))
- || (((srcz & 0xFFFF000000000000LL) == (dstz & 0xFFFF000000000000LL)) && (zmode & 0x02))
- || (((srcz & 0xFFFF000000000000LL) > (dstz & 0xFFFF000000000000LL)) && (zmode & 0x04)))
- zcomp |= 0x08;
+ if ((((*srcz & 0xFFFF000000000000LL) < (dstz & 0xFFFF000000000000LL)) && (zmode & 0x01))
+ || (((*srcz & 0xFFFF000000000000LL) == (dstz & 0xFFFF000000000000LL)) && (zmode & 0x02))
+ || (((*srcz & 0xFFFF000000000000LL) > (dstz & 0xFFFF000000000000LL)) && (zmode & 0x04)))
+ *zcomp |= 0x08;
//TEMP, TO TEST IF ZCOMP IS THE CULPRIT...
//Nope, this is NOT the problem...
-//zcomp=0;
+//*zcomp=0;
// We'll do the comparison/bit/byte inhibits here, since that's they way it happens
// in the real thing (dcomp goes out to COMP_CTRL and back into DATA through dbinh)...
#if 1
uint8 dbinht;
// bool nowrite;
- COMP_CTRL(dbinht, nowrite,
- bcompen, true/*big_pix*/, bkgwren, dcomp, dcompen, icount, pixsize, phrase_mode, srcd & 0xFF, zcomp);
+ COMP_CTRL(&dbinht, nowrite,
+ bcompen, true/*big_pix*/, bkgwren, *dcomp, dcompen, icount, pixsize, phrase_mode, srcd & 0xFF, *zcomp);
dbinh = dbinht;
// dbinh = 0x00;
#endif
@@ -5609,7 +5610,7 @@ with srcshift bits 4 & 5 selecting the start position
#ifdef VERBOSE_BLITTER_LOGGING
if (logBlit)
{
- printf("\n[dcomp=%02X zcomp=%02X dbinh=%02X]\n", dcomp, zcomp, dbinh);
+ printf("\n[dcomp=%02X zcomp=%02X dbinh=%02X]\n", *dcomp, *zcomp, dbinh);
fflush(stdout);
}//*/
#endif
@@ -5634,14 +5635,14 @@ if (logBlit)
////////////////////////////////////// C++ CODE //////////////////////////////////////
uint16 addq[4];
uint8 initcin[4] = { 0, 0, 0, 0 };
- ADDARRAY(addq, daddasel, daddbsel, daddmode, dstd, iinc, initcin, 0, 0, 0, patd, srcd, 0, 0, 0, 0);
+ ADDARRAY(addq, daddasel, daddbsel, daddmode, dstd, iinc, initcin, 0, 0, 0, *patd, srcd, 0, 0, 0, 0);
//This is normally done asynchronously above (thru local_data) when in patdadd mode...
//And now it's passed back to the caller to be persistent between calls...!
//But it's causing some serious fuck-ups in T2K now... !!! FIX !!! [DONE--???]
//Weird! It doesn't anymore...!
if (patdadd)
- patd = ((uint64)addq[3] << 48) | ((uint64)addq[2] << 32) | ((uint64)addq[1] << 16) | (uint64)addq[0];
+ *patd = ((uint64)addq[3] << 48) | ((uint64)addq[2] << 32) | ((uint64)addq[1] << 16) | (uint64)addq[0];
//////////////////////////////////////////////////////////////////////////////////////
// Local data bus multiplexer
@@ -5829,7 +5830,7 @@ Ddatlo := MX4 (ddatlo, patd[0], lfu[0], addql[0], zero32, dsel0b[0], dsel1b[0])
Ddathi := MX4 (ddathi, patd[1], lfu[1], addql[1], zero32, dsel0b[1], dsel1b[1]);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
uint64 dmux[4];
- dmux[0] = patd;
+ dmux[0] = *patd;
dmux[1] = lfu;
dmux[2] = ((uint64)addq[3] << 48) | ((uint64)addq[2] << 32) | ((uint64)addq[1] << 16) | (uint64)addq[0];
dmux[3] = 0;
@@ -5848,14 +5849,14 @@ Dat[40-47] := MX4 (dat[40-47], dstdhi{8-15}, ddathi{8-15}, dstzhi{8-15}, srcz
Dat[48-55] := MX4 (dat[48-55], dstdhi{16-23}, ddathi{16-23}, dstzhi{16-23}, srczhi{16-23}, mask[13], zed_selb[1]);
Dat[56-63] := MX4 (dat[56-63], dstdhi{24-31}, ddathi{24-31}, dstzhi{24-31}, srczhi{24-31}, mask[14], zed_selb[1]);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
- wdata = ((ddat & mask) | (dstd & ~mask)) & 0x00000000000000FFLL;
- wdata |= (mask & 0x0100 ? ddat : dstd) & 0x000000000000FF00LL;
- wdata |= (mask & 0x0200 ? ddat : dstd) & 0x0000000000FF0000LL;
- wdata |= (mask & 0x0400 ? ddat : dstd) & 0x00000000FF000000LL;
- wdata |= (mask & 0x0800 ? ddat : dstd) & 0x000000FF00000000LL;
- wdata |= (mask & 0x1000 ? ddat : dstd) & 0x0000FF0000000000LL;
- wdata |= (mask & 0x2000 ? ddat : dstd) & 0x00FF000000000000LL;
- wdata |= (mask & 0x4000 ? ddat : dstd) & 0xFF00000000000000LL;
+ *wdata = ((ddat & mask) | (dstd & ~mask)) & 0x00000000000000FFLL;
+ *wdata |= (mask & 0x0100 ? ddat : dstd) & 0x000000000000FF00LL;
+ *wdata |= (mask & 0x0200 ? ddat : dstd) & 0x0000000000FF0000LL;
+ *wdata |= (mask & 0x0400 ? ddat : dstd) & 0x00000000FF000000LL;
+ *wdata |= (mask & 0x0800 ? ddat : dstd) & 0x000000FF00000000LL;
+ *wdata |= (mask & 0x1000 ? ddat : dstd) & 0x0000FF0000000000LL;
+ *wdata |= (mask & 0x2000 ? ddat : dstd) & 0x00FF000000000000LL;
+ *wdata |= (mask & 0x4000 ? ddat : dstd) & 0xFF00000000000000LL;
/*if (logBlit)
{
printf("\n[ddat=%08X%08X dstd=%08X%08X wdata=%08X%08X mask=%04X]\n",
@@ -5866,23 +5867,23 @@ Dat[56-63] := MX4 (dat[56-63], dstdhi{24-31}, ddathi{24-31}, dstzhi{24-31}, srcz
}//*/
//This is a crappy way of handling this, but it should work for now...
uint64 zwdata;
- zwdata = ((srcz & mask) | (dstz & ~mask)) & 0x00000000000000FFLL;
- zwdata |= (mask & 0x0100 ? srcz : dstz) & 0x000000000000FF00LL;
- zwdata |= (mask & 0x0200 ? srcz : dstz) & 0x0000000000FF0000LL;
- zwdata |= (mask & 0x0400 ? srcz : dstz) & 0x00000000FF000000LL;
- zwdata |= (mask & 0x0800 ? srcz : dstz) & 0x000000FF00000000LL;
- zwdata |= (mask & 0x1000 ? srcz : dstz) & 0x0000FF0000000000LL;
- zwdata |= (mask & 0x2000 ? srcz : dstz) & 0x00FF000000000000LL;
- zwdata |= (mask & 0x4000 ? srcz : dstz) & 0xFF00000000000000LL;
+ zwdata = ((*srcz & mask) | (dstz & ~mask)) & 0x00000000000000FFLL;
+ zwdata |= (mask & 0x0100 ? *srcz : dstz) & 0x000000000000FF00LL;
+ zwdata |= (mask & 0x0200 ? *srcz : dstz) & 0x0000000000FF0000LL;
+ zwdata |= (mask & 0x0400 ? *srcz : dstz) & 0x00000000FF000000LL;
+ zwdata |= (mask & 0x0800 ? *srcz : dstz) & 0x000000FF00000000LL;
+ zwdata |= (mask & 0x1000 ? *srcz : dstz) & 0x0000FF0000000000LL;
+ zwdata |= (mask & 0x2000 ? *srcz : dstz) & 0x00FF000000000000LL;
+ zwdata |= (mask & 0x4000 ? *srcz : dstz) & 0xFF00000000000000LL;
if (logBlit)
{
printf("\n[srcz=%08X%08X dstz=%08X%08X zwdata=%08X%08X mask=%04X]\n",
- (uint32)(srcz >> 32), (uint32)(srcz & 0xFFFFFFFF),
+ (uint32)(*srcz >> 32), (uint32)(*srcz & 0xFFFFFFFF),
(uint32)(dstz >> 32), (uint32)(dstz & 0xFFFFFFFF),
(uint32)(zwdata >> 32), (uint32)(zwdata & 0xFFFFFFFF), mask);
fflush(stdout);
}//*/
- srcz = zwdata;
+ *srcz = zwdata;
//////////////////////////////////////////////////////////////////////////////////////
/*Data_enab[0-1] := BUF8 (data_enab[0-1], data_ena);
@@ -5942,7 +5943,7 @@ pipe-lining the comparator inputs where appropriate.
step_inner // inner loop advance
zcomp[0..3] // output of word zed comparators
:IN);*/
-void COMP_CTRL(uint8 &dbinh, bool &nowrite,
+void COMP_CTRL(uint8 *dbinh, bool *nowrite,
bool bcompen, bool big_pix, bool bkgwren, uint8 dcomp, bool dcompen, uint8 icount,
uint8 pixsize, bool phrase_mode, uint8 srcd, uint8 zcomp)
{
@@ -6006,7 +6007,7 @@ Nowt3 := NAN5 (nowt[3], zcomp[0], phrase_mode\, pixsize[2], pixsize\[0..1]);
Nowt4 := NAN4 (nowt[4], nowt[0..3]);
Nowrite := AN2 (nowrite, nowt[4], bkgwren\);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
- nowrite = ((bcompen && !bcompbit && !phrase_mode)
+ *nowrite = ((bcompen && !bcompbit && !phrase_mode)
|| (dcompen && (dcomp & 0x01) && !phrase_mode && (pixsize == 3))
|| (dcompen && ((dcomp & 0x03) == 0x03) && !phrase_mode && (pixsize == 4))
|| ((zcomp & 0x01) && !phrase_mode && (pixsize == 4)))
@@ -6026,7 +6027,7 @@ Winhibit := NAN4 (winhibit, winht, nowt[1..3]);*/
#ifdef LOG_COMP_CTRL
if (logBlit)
{
- printf("[nw=%s wi=%s]", (nowrite ? "T" : "F"), (winhibit ? "T" : "F"));
+ printf("[nw=%s wi=%s]", (*nowrite ? "T" : "F"), (winhibit ? "T" : "F"));
fflush(stdout);
}
#endif
@@ -6052,13 +6053,13 @@ Di0t3 := NAN3 (di0t[3], pixsize\[2], dcomp[0], dcompen);
Di0t4 := NAN4 (di0t[4], di0t[0..3]);
Dbinh[0] := ANR1P (dbinh\[0], di0t[4], phrase_mode, winhibit);*/
////////////////////////////////////// C++ CODE //////////////////////////////////////
- dbinh = 0;
+ *dbinh = 0;
bool di0t0_1 = ((pixsize & 0x04) && (zcomp & 0x01))
|| ((pixsize & 0x04) && (dcomp & 0x01) && (dcomp & 0x02) && dcompen);
bool di0t4 = di0t0_1
|| (!(srcd & 0x01) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x01) && dcompen);
- dbinh |= (!((di0t4 && phrase_mode) || winhibit) ? 0x01 : 0x00);
+ *dbinh |= (!((di0t4 && phrase_mode) || winhibit) ? 0x01 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6076,7 +6077,7 @@ Dbinh[1] := ANR1 (dbinh\[1], di1t[2], phrase_mode, winhibit);*/
bool di1t2 = di0t0_1
|| (!(srcd & 0x02) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x02) && dcompen);
- dbinh |= (!((di1t2 && phrase_mode) || winhibit) ? 0x02 : 0x00);
+ *dbinh |= (!((di1t2 && phrase_mode) || winhibit) ? 0x02 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6101,7 +6102,7 @@ Dbinh[2] := ANR1 (dbinh\[2], di2t[4], phrase_mode, winhibit);*/
bool di2t4 = di2t0_1
|| (!(srcd & 0x04) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x04) && dcompen);
- dbinh |= (!((di2t4 && phrase_mode) || winhibit) ? 0x04 : 0x00);
+ *dbinh |= (!((di2t4 && phrase_mode) || winhibit) ? 0x04 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6119,7 +6120,7 @@ Dbinh[3] := ANR1 (dbinh\[3], di3t[2], phrase_mode, winhibit);*/
bool di3t2 = di2t0_1
|| (!(srcd & 0x08) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x08) && dcompen);
- dbinh |= (!((di3t2 && phrase_mode) || winhibit) ? 0x08 : 0x00);
+ *dbinh |= (!((di3t2 && phrase_mode) || winhibit) ? 0x08 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6141,7 +6142,7 @@ Dbinh[4] := NAN2 (dbinh\[4], di4t[4], phrase_mode);*/
bool di4t4 = di4t0_1
|| (!(srcd & 0x10) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x10) && dcompen);
- dbinh |= (!(di4t4 && phrase_mode) ? 0x10 : 0x00);
+ *dbinh |= (!(di4t4 && phrase_mode) ? 0x10 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6159,7 +6160,7 @@ Dbinh[5] := NAN2 (dbinh\[5], di5t[2], phrase_mode);*/
bool di5t2 = di4t0_1
|| (!(srcd & 0x20) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x20) && dcompen);
- dbinh |= (!(di5t2 && phrase_mode) ? 0x20 : 0x00);
+ *dbinh |= (!(di5t2 && phrase_mode) ? 0x20 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6181,7 +6182,7 @@ Dbinh[6] := NAN2 (dbinh\[6], di6t[4], phrase_mode);*/
bool di6t4 = di6t0_1
|| (!(srcd & 0x40) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x40) && dcompen);
- dbinh |= (!(di6t4 && phrase_mode) ? 0x40 : 0x00);
+ *dbinh |= (!(di6t4 && phrase_mode) ? 0x40 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6199,7 +6200,7 @@ Dbinh[7] := NAN2 (dbinh\[7], di7t[2], phrase_mode);*/
bool di7t2 = di6t0_1
|| (!(srcd & 0x80) && bcompen)
|| (!(pixsize & 0x04) && (dcomp & 0x80) && dcompen);
- dbinh |= (!(di7t2 && phrase_mode) ? 0x80 : 0x00);
+ *dbinh |= (!(di7t2 && phrase_mode) ? 0x80 : 0x00);
#ifdef LOG_COMP_CTRL
if (logBlit)
{
@@ -6211,11 +6212,11 @@ if (logBlit)
//END;
//kludge
-dbinh = ~dbinh;
+*dbinh = ~*dbinh;
#ifdef LOG_COMP_CTRL
if (logBlit)
{
- printf("[dcomp=$%02X dbinh=$%02X]\n ", dcomp, dbinh);
+ printf("[dcomp=$%02X dbinh=$%02X]\n ", dcomp, *dbinh);
fflush(stdout);
}
#endif
diff --git a/src/jaguar/blitter.h b/src/jaguar/blitter.h
index 5c3febba..f7a09265 100644
--- a/src/jaguar/blitter.h
+++ b/src/jaguar/blitter.h
@@ -12,12 +12,12 @@ void BlitterInit(void);
void BlitterReset(void);
void BlitterDone(void);
-uint8 BlitterReadByte(uint32, uint32 who = UNKNOWN);
-uint16 BlitterReadWord(uint32, uint32 who = UNKNOWN);
-uint32 BlitterReadLong(uint32, uint32 who = UNKNOWN);
-void BlitterWriteByte(uint32, uint8, uint32 who = UNKNOWN);
-void BlitterWriteWord(uint32, uint16, uint32 who = UNKNOWN);
-void BlitterWriteLong(uint32, uint32, uint32 who = UNKNOWN);
+uint8 BlitterReadByte(uint32, uint32 who /*= UNKNOWN*/);
+uint16 BlitterReadWord(uint32, uint32 who /*= UNKNOWN*/);
+uint32 BlitterReadLong(uint32, uint32 who /*= UNKNOWN*/);
+void BlitterWriteByte(uint32, uint8, uint32 who /*= UNKNOWN*/);
+void BlitterWriteWord(uint32, uint16, uint32 who /*= UNKNOWN*/);
+void BlitterWriteLong(uint32, uint32, uint32 who /*= UNKNOWN*/);
uint32 blitter_reg_read(uint32 offset);
void blitter_reg_write(uint32 offset, uint32 data);
--
2.48.1
--MP_/VkVZp1l8MIESxWVe2vPSxV2
Content-Type: text/x-patch
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename=0003-Convert-the-C-code-constructs-to-plain-C.patch