From 26461e510dbce1964c68942589cfd9c9ceef176e Mon Sep 17 00:00:00 2001 From: ogamespec Date: Thu, 27 Aug 2020 16:05:30 +0300 Subject: [PATCH 1/5] Fifo fixes and cleanup --- SRC/Backends/DolwinVideo/Fifo.cpp | 259 ++++++++++++------ SRC/Backends/DolwinVideo/GPRegs.cpp | 9 +- SRC/Backends/DolwinVideo/GPRegs.h | 134 +-------- .../Scripts/VS2015/DolwinVideo.vcxproj | 4 +- .../VS2015/DolwinVideo.vcxproj.filters | 12 +- 5 files changed, 194 insertions(+), 224 deletions(-) diff --git a/SRC/Backends/DolwinVideo/Fifo.cpp b/SRC/Backends/DolwinVideo/Fifo.cpp index 02b9c89c..43dd8373 100644 --- a/SRC/Backends/DolwinVideo/Fifo.cpp +++ b/SRC/Backends/DolwinVideo/Fifo.cpp @@ -60,7 +60,7 @@ static int gx_vtxsize(unsigned v) static int cntn[] = { 3, 9 }; static int cntt[] = { 1, 2 }; static int fmtsz[] = { 1, 1, 2, 2, 4 }; - static int cfmtsz[] = { 2, 3, 1, 2, 4, 4 }; + static int cfmtsz[] = { 2, 3, 4, 2, 4, 4 }; if (cpRegs.vcdLo.pmidx) vtxsize++; if (cpRegs.vcdLo.t0midx) vtxsize++; @@ -72,32 +72,171 @@ static int gx_vtxsize(unsigned v) if (cpRegs.vcdLo.t6midx) vtxsize++; if (cpRegs.vcdLo.t7midx) vtxsize++; - if (cpRegs.vcdLo.pos & 2) vtxsize += cpRegs.vcdLo.pos - 1; - if (cpRegs.vcdLo.nrm & 2) vtxsize += cpRegs.vcdLo.nrm - 1; - if (cpRegs.vcdLo.col0 & 2) vtxsize += cpRegs.vcdLo.col0 - 1; - if (cpRegs.vcdLo.col1 & 2) vtxsize += cpRegs.vcdLo.col1 - 1; - if (cpRegs.vcdHi.tex0 & 2) vtxsize += cpRegs.vcdHi.tex0 - 1; - if (cpRegs.vcdHi.tex1 & 2) vtxsize += cpRegs.vcdHi.tex1 - 1; - if (cpRegs.vcdHi.tex2 & 2) vtxsize += cpRegs.vcdHi.tex2 - 1; - if (cpRegs.vcdHi.tex3 & 2) vtxsize += cpRegs.vcdHi.tex3 - 1; - if (cpRegs.vcdHi.tex4 & 2) vtxsize += cpRegs.vcdHi.tex4 - 1; - if (cpRegs.vcdHi.tex5 & 2) vtxsize += cpRegs.vcdHi.tex5 - 1; - if (cpRegs.vcdHi.tex6 & 2) vtxsize += cpRegs.vcdHi.tex6 - 1; - if (cpRegs.vcdHi.tex7 & 2) vtxsize += cpRegs.vcdHi.tex7 - 1; - - if (cpRegs.vcdLo.pos == 1) vtxsize += fmtsz[cpRegs.vatA[v].posfmt] * cntp[cpRegs.vatA[v].poscnt]; - if (cpRegs.vcdLo.nrm == 1) vtxsize += fmtsz[cpRegs.vatA[v].nrmfmt] * cntn[cpRegs.vatA[v].nrmcnt]; - if (cpRegs.vcdHi.tex0 == 1) vtxsize += fmtsz[cpRegs.vatA[v].tex0fmt] * cntt[cpRegs.vatA[v].tex0cnt]; - if (cpRegs.vcdHi.tex1 == 1) vtxsize += fmtsz[cpRegs.vatB[v].tex1fmt] * cntt[cpRegs.vatB[v].tex1cnt]; - if (cpRegs.vcdHi.tex2 == 1) vtxsize += fmtsz[cpRegs.vatB[v].tex2fmt] * cntt[cpRegs.vatB[v].tex2cnt]; - if (cpRegs.vcdHi.tex3 == 1) vtxsize += fmtsz[cpRegs.vatB[v].tex3fmt] * cntt[cpRegs.vatB[v].tex3cnt]; - if (cpRegs.vcdHi.tex4 == 1) vtxsize += fmtsz[cpRegs.vatB[v].tex4fmt] * cntt[cpRegs.vatB[v].tex4cnt]; - if (cpRegs.vcdHi.tex5 == 1) vtxsize += fmtsz[cpRegs.vatC[v].tex5fmt] * cntt[cpRegs.vatC[v].tex5cnt]; - if (cpRegs.vcdHi.tex6 == 1) vtxsize += fmtsz[cpRegs.vatC[v].tex6fmt] * cntt[cpRegs.vatC[v].tex6cnt]; - if (cpRegs.vcdHi.tex7 == 1) vtxsize += fmtsz[cpRegs.vatC[v].tex7fmt] * cntt[cpRegs.vatC[v].tex7cnt]; - - if (cpRegs.vcdLo.col0 == 1) vtxsize += cfmtsz[cpRegs.vatA[v].col0fmt]; - if (cpRegs.vcdLo.col1 == 1) vtxsize += cfmtsz[cpRegs.vatA[v].col1fmt]; + // Position + + switch (cpRegs.vcdLo.pos) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatA[v].posfmt] * cntp[cpRegs.vatA[v].poscnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + // Normal + + switch (cpRegs.vcdLo.nrm) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatA[v].nrmfmt] * cntn[cpRegs.vatA[v].nrmcnt]; + break; + case VCD_INDX8: + if (cpRegs.vatA[v].nrmidx3) vtxsize += 3; + else vtxsize += 1; + break; + case VCD_INDX16: + if (cpRegs.vatA[v].nrmidx3) vtxsize += 2 * 3; + else vtxsize += 2; + break; + } + + // Colors + + switch (cpRegs.vcdLo.col0) + { + case VCD_DIRECT: + vtxsize += cfmtsz[cpRegs.vatA[v].col0fmt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdLo.col1) + { + case VCD_DIRECT: + vtxsize += cfmtsz[cpRegs.vatA[v].col1fmt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + // TexCoords + + switch (cpRegs.vcdHi.tex0) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatA[v].tex0fmt] * cntt[cpRegs.vatA[v].tex0cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex1) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatB[v].tex1fmt] * cntt[cpRegs.vatB[v].tex1cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex2) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatB[v].tex2fmt] * cntt[cpRegs.vatB[v].tex2cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex3) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatB[v].tex3fmt] * cntt[cpRegs.vatB[v].tex3cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex4) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatB[v].tex4fmt] * cntt[cpRegs.vatB[v].tex4cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex5) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatC[v].tex5fmt] * cntt[cpRegs.vatC[v].tex5cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex6) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatC[v].tex6fmt] * cntt[cpRegs.vatC[v].tex6cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } + + switch (cpRegs.vcdHi.tex7) + { + case VCD_DIRECT: + vtxsize += fmtsz[cpRegs.vatC[v].tex7fmt] * cntt[cpRegs.vatC[v].tex7cnt]; + break; + case VCD_INDX8: + vtxsize += 1; + break; + case VCD_INDX16: + vtxsize += 2; + break; + } return vtxsize; } @@ -115,7 +254,7 @@ void FifoReconfigure() void * GetArrayPtr(ArrayId arrayId, int idx) { uint32_t address = cpRegs.arbase[(size_t)arrayId] + (uint32_t)idx * cpRegs.arstride[(size_t)arrayId]; - return &RAM[address]; + return &RAM[address & 0x03ff'ffff]; } void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFuture::FifoProcessor* fifo, ArrayId arrayId) @@ -305,29 +444,6 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur switch (fmt) { - case VFMT_U8: - if (type == VCD_DIRECT) - { - for (int i = 0; i < count; i++) - { - Comp.u8[i] = fifo->Read8(); - } - } - else - { - for (int i = 0; i < count; i++) - { - void* ptr = *ptrptr[i / 3]; - Comp.u8[i] = ((uint8_t*)ptr)[i]; - } - } - - for (int i = 0; i < count; i++) - { - comp[i] = (float)(Comp.u8[i] >> shft); - } - break; - case VFMT_S8: if (type == VCD_DIRECT) { @@ -351,29 +467,6 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur } break; - case VFMT_U16: - if (type == VCD_DIRECT) - { - for (int i = 0; i < count; i++) - { - Comp.u16[i] = fifo->Read16(); - } - } - else - { - for (int i = 0; i < count; i++) - { - void* ptr = *ptrptr[i / 3]; - Comp.u16[i] = _byteswap_ushort(((uint16_t*)ptr)[i]); - } - } - - for (int i = 0; i < count; i++) - { - comp[i] = (float)(Comp.u16[i] >> shft); - } - break; - case VFMT_S16: if (type == VCD_DIRECT) { @@ -655,7 +748,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatA[vatnum].poscnt == VCNT_POS_XYZ ? 3 : 2, cpRegs.vcdLo.pos, cpRegs.vatA[vatnum].posfmt, - cpRegs.vatA[vatnum].posshft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatA[vatnum].posshft : 0, fifo, ArrayId::Pos); @@ -702,7 +795,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatA[vatnum].tex0cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex0, cpRegs.vatA[vatnum].tex0fmt, - cpRegs.vatA[vatnum].tex0shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatA[vatnum].tex0shft : 0, fifo, ArrayId::Tex0Coord); @@ -712,7 +805,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatB[vatnum].tex1cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex1, cpRegs.vatB[vatnum].tex1fmt, - cpRegs.vatB[vatnum].tex1shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatB[vatnum].tex1shft : 0, fifo, ArrayId::Tex1Coord); @@ -722,7 +815,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatB[vatnum].tex2cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex2, cpRegs.vatB[vatnum].tex2fmt, - cpRegs.vatB[vatnum].tex2shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatB[vatnum].tex2shft : 0, fifo, ArrayId::Tex2Coord); @@ -732,7 +825,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatB[vatnum].tex3cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex3, cpRegs.vatB[vatnum].tex3fmt, - cpRegs.vatB[vatnum].tex3shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatB[vatnum].tex3shft : 0, fifo, ArrayId::Tex3Coord); @@ -742,7 +835,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatB[vatnum].tex4cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex4, cpRegs.vatB[vatnum].tex4fmt, - cpRegs.vatC[vatnum].tex4shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatC[vatnum].tex4shft : 0, fifo, ArrayId::Tex4Coord); @@ -752,7 +845,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatC[vatnum].tex5cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex5, cpRegs.vatC[vatnum].tex5fmt, - cpRegs.vatC[vatnum].tex5shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatC[vatnum].tex5shft : 0, fifo, ArrayId::Tex5Coord); @@ -762,7 +855,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatC[vatnum].tex6cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex6, cpRegs.vatC[vatnum].tex6fmt, - cpRegs.vatC[vatnum].tex6shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatC[vatnum].tex6shft : 0, fifo, ArrayId::Tex6Coord); @@ -772,7 +865,7 @@ static void FifoWalk(unsigned vatnum, GX_FromFuture::FifoProcessor * fifo) cpRegs.vatC[vatnum].tex7cnt == VCNT_TEX_ST ? 2 : 1, cpRegs.vcdHi.tex7, cpRegs.vatC[vatnum].tex7fmt, - cpRegs.vatC[vatnum].tex7shft, + cpRegs.vatA[vatnum].bytedeq ? cpRegs.vatC[vatnum].tex7shft : 0, fifo, ArrayId::Tex7Coord); } diff --git a/SRC/Backends/DolwinVideo/GPRegs.cpp b/SRC/Backends/DolwinVideo/GPRegs.cpp index 036515e9..5d16fa55 100644 --- a/SRC/Backends/DolwinVideo/GPRegs.cpp +++ b/SRC/Backends/DolwinVideo/GPRegs.cpp @@ -71,8 +71,7 @@ void loadCPReg(size_t index, uint32_t value) case CP_VAT6_A: case CP_VAT7_A: { - unsigned vatnum = index & 7; - cpRegs.vatA[vatnum].vata = value; + cpRegs.vatA[index & 7].vata = value; FifoReconfigure(); } return; @@ -86,8 +85,7 @@ void loadCPReg(size_t index, uint32_t value) case CP_VAT6_B: case CP_VAT7_B: { - unsigned vatnum = index & 7; - cpRegs.vatB[vatnum].vatb = value; + cpRegs.vatB[index & 7].vatb = value; FifoReconfigure(); } return; @@ -101,8 +99,7 @@ void loadCPReg(size_t index, uint32_t value) case CP_VAT6_C: case CP_VAT7_C: { - unsigned vatnum = index & 7; - cpRegs.vatC[vatnum].vatc = value; + cpRegs.vatC[index & 7].vatc = value; FifoReconfigure(); } return; diff --git a/SRC/Backends/DolwinVideo/GPRegs.h b/SRC/Backends/DolwinVideo/GPRegs.h index 41bdfddc..310fa155 100644 --- a/SRC/Backends/DolwinVideo/GPRegs.h +++ b/SRC/Backends/DolwinVideo/GPRegs.h @@ -46,8 +46,6 @@ extern GXDrawTokenCallback GxDrawToken; #define CP_VAT7_C 0x97 #define CP_ARRAY_BASE 0xA0 #define CP_ARRAY_STRIDE 0xB0 -#define CP_NUMCOL 0xB2 // number of colors attributes -#define CP_NUMTEX 0xB4 // number of texcoord attributes // vertex attribute types (from VCD register) enum @@ -217,131 +215,13 @@ enum #define XF_LIGHT0_DHY 0x060E // light dir y, or 1/2 angle y #define XF_LIGHT0_DHZ 0x060F // light dir z, or 1/2 angle z -// LIGHT 1 DATA -#define XF_LIGHT1 0x0610 // reserved -#define XF_0x0611 0x0611 // reserved -#define XF_0x0612 0x0612 // reserved -#define XF_LIGHT1_RGBA 0x0613 // RGBA (8b/comp) -#define XF_LIGHT1_A0 0x0614 // cos atten a0 -#define XF_LIGHT1_A1 0x0615 // cos atten a1 -#define XF_LIGHT1_A2 0x0616 // cos atten a2 -#define XF_LIGHT1_K0 0x0617 // dist atten k0 -#define XF_LIGHT1_K1 0x0618 // dist atten k1 -#define XF_LIGHT1_K2 0x0619 // dist atten k2 -#define XF_LIGHT1_LPX 0x061A // x light pos, or inf 1dir x -#define XF_LIGHT1_LPY 0x061B // y light pos, or inf 1dir y -#define XF_LIGHT1_LPZ 0x061C // z light pos, or inf 1dir z -#define XF_LIGHT1_DHX 0x061D // light dir x, or 1/2 angle x -#define XF_LIGHT1_DHY 0x061E // light dir y, or 1/2 angle y -#define XF_LIGHT1_DHZ 0x061F // light dir z, or 1/2 angle z - -// LIGHT 2 DATA -#define XF_LIGHT2 0x0620 // reserved -#define XF_0x0621 0x0621 // reserved -#define XF_0x0622 0x0622 // reserved -#define XF_LIGHT2_RGBA 0x0623 // RGBA (8b/comp) -#define XF_LIGHT2_A0 0x0624 // cos atten a0 -#define XF_LIGHT2_A1 0x0625 // cos atten a1 -#define XF_LIGHT2_A2 0x0626 // cos atten a2 -#define XF_LIGHT2_K0 0x0627 // dist atten k0 -#define XF_LIGHT2_K1 0x0628 // dist atten k1 -#define XF_LIGHT2_K2 0x0629 // dist atten k2 -#define XF_LIGHT2_LPX 0x062A // x light pos, or inf 1dir x -#define XF_LIGHT2_LPY 0x062B // y light pos, or inf 1dir y -#define XF_LIGHT2_LPZ 0x062C // z light pos, or inf 1dir z -#define XF_LIGHT2_DHX 0x062D // light dir x, or 1/2 angle x -#define XF_LIGHT2_DHY 0x062E // light dir y, or 1/2 angle y -#define XF_LIGHT2_DHZ 0x062F // light dir z, or 1/2 angle z - -// LIGHT 3 DATA -#define XF_LIGHT3 0x0630 // reserved -#define XF_0x0631 0x0631 // reserved -#define XF_0x0632 0x0632 // reserved -#define XF_LIGHT3_RGBA 0x0633 // RGBA (8b/comp) -#define XF_LIGHT3_A0 0x0634 // cos atten a0 -#define XF_LIGHT3_A1 0x0635 // cos atten a1 -#define XF_LIGHT3_A2 0x0636 // cos atten a2 -#define XF_LIGHT3_K0 0x0637 // dist atten k0 -#define XF_LIGHT3_K1 0x0638 // dist atten k1 -#define XF_LIGHT3_K2 0x0639 // dist atten k2 -#define XF_LIGHT3_LPX 0x063A // x light pos, or inf 1dir x -#define XF_LIGHT3_LPY 0x063B // y light pos, or inf 1dir y -#define XF_LIGHT3_LPZ 0x063C // z light pos, or inf 1dir z -#define XF_LIGHT3_DHX 0x063D // light dir x, or 1/2 angle x -#define XF_LIGHT3_DHY 0x063E // light dir y, or 1/2 angle y -#define XF_LIGHT3_DHZ 0x063F // light dir z, or 1/2 angle z - -// LIGHT 4 DATA -#define XF_LIGHT4 0x0640 // reserved -#define XF_0x0641 0x0641 // reserved -#define XF_0x0642 0x0642 // reserved -#define XF_LIGHT4_RGBA 0x0643 // RGBA (8b/comp) -#define XF_LIGHT4_A0 0x0644 // cos atten a0 -#define XF_LIGHT4_A1 0x0645 // cos atten a1 -#define XF_LIGHT4_A2 0x0646 // cos atten a2 -#define XF_LIGHT4_K0 0x0647 // dist atten k0 -#define XF_LIGHT4_K1 0x0648 // dist atten k1 -#define XF_LIGHT4_K2 0x0649 // dist atten k2 -#define XF_LIGHT4_LPX 0x064A // x light pos, or inf 1dir x -#define XF_LIGHT4_LPY 0x064B // y light pos, or inf 1dir y -#define XF_LIGHT4_LPZ 0x064C // z light pos, or inf 1dir z -#define XF_LIGHT4_DHX 0x064D // light dir x, or 1/2 angle x -#define XF_LIGHT4_DHY 0x064E // light dir y, or 1/2 angle y -#define XF_LIGHT4_DHZ 0x064F // light dir z, or 1/2 angle z - -// LIGHT 5 DATA -#define XF_LIGHT5 0x0650 // reserved -#define XF_0x0651 0x0651 // reserved -#define XF_0x0652 0x0652 // reserved -#define XF_LIGHT5_RGBA 0x0653 // RGBA (8b/comp) -#define XF_LIGHT5_A0 0x0654 // cos atten a0 -#define XF_LIGHT5_A1 0x0655 // cos atten a1 -#define XF_LIGHT5_A2 0x0656 // cos atten a2 -#define XF_LIGHT5_K0 0x0657 // dist atten k0 -#define XF_LIGHT5_K1 0x0658 // dist atten k1 -#define XF_LIGHT5_K2 0x0659 // dist atten k2 -#define XF_LIGHT5_LPX 0x065A // x light pos, or inf 1dir x -#define XF_LIGHT5_LPY 0x065B // y light pos, or inf 1dir y -#define XF_LIGHT5_LPZ 0x065C // z light pos, or inf 1dir z -#define XF_LIGHT5_DHX 0x065D // light dir x, or 1/2 angle x -#define XF_LIGHT5_DHY 0x065E // light dir y, or 1/2 angle y -#define XF_LIGHT5_DHZ 0x065F // light dir z, or 1/2 angle z - -// LIGHT 6 DATA -#define XF_LIGHT6 0x0660 // reserved -#define XF_0x0661 0x0661 // reserved -#define XF_0x0662 0x0662 // reserved -#define XF_LIGHT6_RGBA 0x0663 // RGBA (8b/comp) -#define XF_LIGHT6_A0 0x0664 // cos atten a0 -#define XF_LIGHT6_A1 0x0665 // cos atten a1 -#define XF_LIGHT6_A2 0x0666 // cos atten a2 -#define XF_LIGHT6_K0 0x0667 // dist atten k0 -#define XF_LIGHT6_K1 0x0668 // dist atten k1 -#define XF_LIGHT6_K2 0x0669 // dist atten k2 -#define XF_LIGHT6_LPX 0x066A // x light pos, or inf 1dir x -#define XF_LIGHT6_LPY 0x066B // y light pos, or inf 1dir y -#define XF_LIGHT6_LPZ 0x066C // z light pos, or inf 1dir z -#define XF_LIGHT6_DHX 0x066D // light dir x, or 1/2 angle x -#define XF_LIGHT6_DHY 0x066E // light dir y, or 1/2 angle y -#define XF_LIGHT6_DHZ 0x066F // light dir z, or 1/2 angle z - -// LIGHT 7 DATA -#define XF_LIGHT7 0x0670 // reserved -#define XF_0x0671 0x0671 // reserved -#define XF_0x0672 0x0672 // reserved -#define XF_LIGHT7_RGBA 0x0673 // RGBA (8b/comp) -#define XF_LIGHT7_A0 0x0674 // cos atten a0 -#define XF_LIGHT7_A1 0x0675 // cos atten a1 -#define XF_LIGHT7_A2 0x0676 // cos atten a2 -#define XF_LIGHT7_K0 0x0677 // dist atten k0 -#define XF_LIGHT7_K1 0x0678 // dist atten k1 -#define XF_LIGHT7_K2 0x0679 // dist atten k2 -#define XF_LIGHT7_LPX 0x067A // x light pos, or inf 1dir x -#define XF_LIGHT7_LPY 0x067B // y light pos, or inf 1dir y -#define XF_LIGHT7_LPZ 0x067C // z light pos, or inf 1dir z -#define XF_LIGHT7_DHX 0x067D // light dir x, or 1/2 angle x -#define XF_LIGHT7_DHY 0x067E // light dir y, or 1/2 angle y -#define XF_LIGHT7_DHZ 0x067F // light dir z, or 1/2 angle z +#define XF_LIGHT1 0x0610 +#define XF_LIGHT2 0x0620 +#define XF_LIGHT3 0x0630 +#define XF_LIGHT4 0x0640 +#define XF_LIGHT5 0x0650 +#define XF_LIGHT6 0x0660 +#define XF_LIGHT7 0x0670 // XF 0x0680...0x07FF reserved diff --git a/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj b/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj index 5a6ca460..3e21e4dc 100644 --- a/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj +++ b/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj @@ -152,17 +152,18 @@ + - + @@ -174,7 +175,6 @@ Create Create - diff --git a/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj.filters b/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj.filters index 9616e064..27fbcd4a 100644 --- a/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj.filters +++ b/SRC/Backends/DolwinVideo/Scripts/VS2015/DolwinVideo.vcxproj.filters @@ -24,9 +24,6 @@ Header Files - - Header Files - Header Files @@ -42,6 +39,9 @@ Header Files + + Header Files + @@ -53,9 +53,6 @@ Source Files - - Source Files - Source Files @@ -71,6 +68,9 @@ Source Files + + Source Files + From e6157fc40fb8e7b8611fdf033085d6ceac9e5e05 Mon Sep 17 00:00:00 2001 From: ogamespec Date: Thu, 27 Aug 2020 18:13:51 +0300 Subject: [PATCH 2/5] Fifo fixes --- Data/Json/DolwinVideoJdi.json | 14 ++++ SRC/Backends/DolwinVideo/Fifo.cpp | 81 ++++++++++++------- SRC/Backends/DolwinVideo/GX.cpp | 72 +++++++++++++++++ .../Scripts/VS2019/DolwinVideo.vcxproj | 1 + .../VS2019/DolwinVideo.vcxproj.filters | 1 + SRC/Backends/DolwinVideo/pch.h | 6 +- 6 files changed, 147 insertions(+), 28 deletions(-) create mode 100644 Data/Json/DolwinVideoJdi.json diff --git a/Data/Json/DolwinVideoJdi.json b/Data/Json/DolwinVideoJdi.json new file mode 100644 index 00000000..3fa8f80a --- /dev/null +++ b/Data/Json/DolwinVideoJdi.json @@ -0,0 +1,14 @@ +{ + "info": { + "description": "DolwinVideo Commands", + "helpGroup": "DolwinVideo Debug Commands" + }, + + "can": { + + "DumpVat": { + "help": "Dump CommandProcessor VCD/VAT settings" + } + + } +} diff --git a/SRC/Backends/DolwinVideo/Fifo.cpp b/SRC/Backends/DolwinVideo/Fifo.cpp index 43dd8373..46fb0900 100644 --- a/SRC/Backends/DolwinVideo/Fifo.cpp +++ b/SRC/Backends/DolwinVideo/Fifo.cpp @@ -251,7 +251,7 @@ void FifoReconfigure() // --------------------------------------------------------------------------- -void * GetArrayPtr(ArrayId arrayId, int idx) +void * GetArrayPtr(ArrayId arrayId, int idx, int compSize) { uint32_t address = cpRegs.arbase[(size_t)arrayId] + (uint32_t)idx * cpRegs.arstride[(size_t)arrayId]; return &RAM[address & 0x03ff'ffff]; @@ -260,6 +260,7 @@ void * GetArrayPtr(ArrayId arrayId, int idx) void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFuture::FifoProcessor* fifo, ArrayId arrayId) { void* ptr; + static int fmtsz[] = { 1, 1, 2, 2, 4 }; union { @@ -275,10 +276,10 @@ void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFutur case VCD_NONE: // Skip attribute return; case VCD_INDX8: - ptr = GetArrayPtr(arrayId, fifo->Read8()); + ptr = GetArrayPtr(arrayId, fifo->Read8(), fmtsz[fmt]); break; case VCD_INDX16: - ptr = GetArrayPtr(arrayId, fifo->Read16()); + ptr = GetArrayPtr(arrayId, fifo->Read16(), fmtsz[fmt]); break; default: ptr = nullptr; @@ -305,7 +306,7 @@ void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFutur for (int i = 0; i < count; i++) { - comp[i] = (float)(Comp.u8[i] >> shft); + comp[i] = (float)(Comp.u8[i]) / pow(2.0, shft); } break; @@ -327,7 +328,7 @@ void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFutur for (int i = 0; i < count; i++) { - comp[i] = (float)(Comp.s8[i] >> shft); + comp[i] = (float)(Comp.s8[i]) / pow(2.0, shft); } break; @@ -349,7 +350,7 @@ void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFutur for (int i = 0; i < count; i++) { - comp[i] = (float)(Comp.u16[i] >> shft); + comp[i] = (float)(Comp.u16[i]) / pow(2.0, shft); } break; @@ -371,7 +372,7 @@ void FetchComp(float* comp, int count, int type, int fmt, int shft, GX_FromFutur for (int i = 0; i < count; i++) { - comp[i] = (float)(Comp.s16[i] >> shft); + comp[i] = (float)(Comp.s16[i]) / pow(2.0, shft); } break; @@ -410,6 +411,7 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur void* ptr3; void** ptrptr[3] = { &ptr1, &ptr2, &ptr3 }; + static int fmtsz[] = { 1, 1, 2, 2, 4 }; union { @@ -425,19 +427,19 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur case VCD_NONE: // Skip attribute return; case VCD_INDX8: - ptr1 = GetArrayPtr(arrayId, fifo->Read8()); + ptr1 = GetArrayPtr(arrayId, fifo->Read8(), fmtsz[fmt]); if (count == 9 && nrmidx3) { - ptr2 = GetArrayPtr(arrayId, fifo->Read8()); - ptr3 = GetArrayPtr(arrayId, fifo->Read8()); + ptr2 = GetArrayPtr(arrayId, fifo->Read8(), fmtsz[fmt]); + ptr3 = GetArrayPtr(arrayId, fifo->Read8(), fmtsz[fmt]); } break; case VCD_INDX16: - ptr1 = GetArrayPtr(arrayId, fifo->Read16()); + ptr1 = GetArrayPtr(arrayId, fifo->Read16(), fmtsz[fmt]); if (count == 9 && nrmidx3) { - ptr2 = GetArrayPtr(arrayId, fifo->Read16()); - ptr3 = GetArrayPtr(arrayId, fifo->Read16()); + ptr2 = GetArrayPtr(arrayId, fifo->Read16(), fmtsz[fmt]); + ptr3 = GetArrayPtr(arrayId, fifo->Read16(), fmtsz[fmt]); } break; } @@ -456,14 +458,22 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur { for (int i = 0; i < count; i++) { - void* ptr = *ptrptr[i / 3]; + void* ptr; + if (count == 9 && nrmidx3) + { + ptr = *ptrptr[i / 3]; + } + else + { + ptr = ptr1; + } Comp.s8[i] = ((uint8_t*)ptr)[i]; } } for (int i = 0; i < count; i++) { - comp[i] = (float)(Comp.s8[i] >> shft); + comp[i] = (float)(Comp.s8[i]) / pow(2.0, shft); } break; @@ -479,14 +489,22 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur { for (int i = 0; i < count; i++) { - void* ptr = *ptrptr[i / 3]; + void* ptr; + if (count == 9 && nrmidx3) + { + ptr = *ptrptr[i / 3]; + } + else + { + ptr = ptr1; + } Comp.s16[i] = _byteswap_ushort(((uint16_t*)ptr)[i]); } } for (int i = 0; i < count; i++) { - comp[i] = (float)(Comp.s16[i] >> shft); + comp[i] = (float)(Comp.s16[i]) / pow(2.0, shft); } break; @@ -502,7 +520,15 @@ void FetchNorm(float* comp, int count, int type, int fmt, int shft, GX_FromFutur { for (int i = 0; i < count; i++) { - void* ptr = *ptrptr[i / 3]; + void* ptr; + if (count == 9 && nrmidx3) + { + ptr = *ptrptr[i / 3]; + } + else + { + ptr = ptr1; + } Comp.u32[i] = _byteswap_ulong(((uint32_t*)ptr)[i]); } } @@ -523,6 +549,7 @@ Color FetchColor(int type, int fmt, GX_FromFuture::FifoProcessor* fifo, ArrayId { void* ptr; Color col; + static int cfmtsz[] = { 2, 3, 4, 2, 4, 4 }; col.R = 0; col.G = 0; @@ -539,10 +566,10 @@ Color FetchColor(int type, int fmt, GX_FromFuture::FifoProcessor* fifo, ArrayId case VCD_NONE: // Skip attribute return col; case VCD_INDX8: - ptr = GetArrayPtr(arrayId, fifo->Read8()); + ptr = GetArrayPtr(arrayId, fifo->Read8(), cfmtsz[fmt]); break; case VCD_INDX16: - ptr = GetArrayPtr(arrayId, fifo->Read16()); + ptr = GetArrayPtr(arrayId, fifo->Read16(), cfmtsz[fmt]); break; default: ptr = nullptr; @@ -1107,7 +1134,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_QUAD: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_QUAD: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 1---2 tri1: 0-1-2 | /| tri2: 0-2-3 @@ -1144,7 +1171,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_TRIANGLE: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_TRIANGLE: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 1---2 tri: 0-1-2 | / @@ -1181,7 +1208,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_STRIP: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_STRIP: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 1---3---5 tri1: 0-1-2 /| /| / tri2: 1-2-3 @@ -1233,7 +1260,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_FAN: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_FAN: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 1---2---3 tri1: 0-1-2 | / _/ tri2: 0-2-3 @@ -1284,7 +1311,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_LINE: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_LINE: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 1 3 5 / / / @@ -1321,7 +1348,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_LINESTRIP: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_LINESTRIP: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 1 3 5 /| /| / @@ -1368,7 +1395,7 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - //DBReport2(DbgChannel::GP, "OP_CMD_DRAW_POINT: vtxnum: %i\n", vtxnum); + Report(Channel::GP, "OP_CMD_DRAW_POINT: vtxnum: %i, vat: %i\n", vtxnum, vatnum); /*/ 0---0 tri: 0-0-0 (1x1x1 tri) | / diff --git a/SRC/Backends/DolwinVideo/GX.cpp b/SRC/Backends/DolwinVideo/GX.cpp index b0b8eaa7..f50a5916 100644 --- a/SRC/Backends/DolwinVideo/GX.cpp +++ b/SRC/Backends/DolwinVideo/GX.cpp @@ -1,11 +1,79 @@ // External interface #include "pch.h" +using namespace Debug; + uint8_t* RAM; HINSTANCE hPlugin; HWND hwndMain; static bool gxOpened = false; +extern int VtxSize[8]; + +// Dump CommandProcessor VCD/VAT settings +static Json::Value* DumpVat(std::vector& args) +{ + // VCD + + static char* typname[] = { "NONE", "DIRECT", "INDEX8", "INDEX16" }; + + Report(Channel::Norm, "VCD:\n"); + Report(Channel::Norm, "pmidx: %i\n", cpRegs.vcdLo.pmidx); + Report(Channel::Norm, "t0midx: %i\n", cpRegs.vcdLo.t0midx); + Report(Channel::Norm, "t1midx: %i\n", cpRegs.vcdLo.t1midx); + Report(Channel::Norm, "t2midx: %i\n", cpRegs.vcdLo.t2midx); + Report(Channel::Norm, "t3midx: %i\n", cpRegs.vcdLo.t3midx); + Report(Channel::Norm, "t4midx: %i\n", cpRegs.vcdLo.t4midx); + Report(Channel::Norm, "t5midx: %i\n", cpRegs.vcdLo.t5midx); + Report(Channel::Norm, "t6midx: %i\n", cpRegs.vcdLo.t6midx); + Report(Channel::Norm, "t7midx: %i\n", cpRegs.vcdLo.t7midx); + Report(Channel::Norm, "pos: %s\n", typname[cpRegs.vcdLo.pos]); + Report(Channel::Norm, "nrm: %s\n", typname[cpRegs.vcdLo.nrm]); + Report(Channel::Norm, "col0: %s\n", typname[cpRegs.vcdLo.col0]); + Report(Channel::Norm, "col1: %s\n", typname[cpRegs.vcdLo.col1]); + Report(Channel::Norm, "tex0: %s\n", typname[cpRegs.vcdHi.tex0]); + Report(Channel::Norm, "tex1: %s\n", typname[cpRegs.vcdHi.tex1]); + Report(Channel::Norm, "tex2: %s\n", typname[cpRegs.vcdHi.tex2]); + Report(Channel::Norm, "tex3: %s\n", typname[cpRegs.vcdHi.tex3]); + Report(Channel::Norm, "tex4: %s\n", typname[cpRegs.vcdHi.tex4]); + Report(Channel::Norm, "tex5: %s\n", typname[cpRegs.vcdHi.tex5]); + Report(Channel::Norm, "tex6: %s\n", typname[cpRegs.vcdHi.tex6]); + Report(Channel::Norm, "tex7: %s\n", typname[cpRegs.vcdHi.tex7]); + + // VATs + + for (int i = 0; i < 8; i++) + { + static char* fmtname[] = { "U8", "S8", "U16", "S16", "F32", "Reserved5", "Reserved6", "Reserved7" }; + static char* colname[] = { "RGB565", "RGB8", "RGBX8", "RGBA4", "RGBA6", "RGBA8", "Reserved6", "Reserved7" }; + + Report(Channel::Norm, "\n"); + Report(Channel::Norm, "VAT[%i]:\n", i); + + Report(Channel::Norm, "pos: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatA[i].poscnt, fmtname[cpRegs.vatA[i].posfmt], cpRegs.vatA[i].posshft); + Report(Channel::Norm, "nrm: cnt:%i, fmt:%s\n", cpRegs.vatA[i].nrmcnt, fmtname[cpRegs.vatA[i].nrmfmt]); + Report(Channel::Norm, "col0: cnt:%i, fmt:%s\n", cpRegs.vatA[i].col0cnt, colname[cpRegs.vatA[i].col0fmt]); + Report(Channel::Norm, "col1: cnt:%i, fmt:%s\n", cpRegs.vatA[i].col1cnt, colname[cpRegs.vatA[i].col1fmt]); + Report(Channel::Norm, "tex0: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatA[i].tex0cnt, fmtname[cpRegs.vatA[i].tex0fmt], cpRegs.vatA[i].tex0shft); + Report(Channel::Norm, "tex1: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatB[i].tex1cnt, fmtname[cpRegs.vatB[i].tex1fmt], cpRegs.vatB[i].tex1shft); + Report(Channel::Norm, "tex2: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatB[i].tex2cnt, fmtname[cpRegs.vatB[i].tex2fmt], cpRegs.vatB[i].tex2shft); + Report(Channel::Norm, "tex3: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatB[i].tex3cnt, fmtname[cpRegs.vatB[i].tex3fmt], cpRegs.vatB[i].tex3shft); + Report(Channel::Norm, "tex4: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatB[i].tex4cnt, fmtname[cpRegs.vatB[i].tex4fmt], cpRegs.vatC[i].tex4shft); + Report(Channel::Norm, "tex5: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatC[i].tex5cnt, fmtname[cpRegs.vatC[i].tex5fmt], cpRegs.vatC[i].tex5shft); + Report(Channel::Norm, "tex6: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatC[i].tex6cnt, fmtname[cpRegs.vatC[i].tex6fmt], cpRegs.vatC[i].tex6shft); + Report(Channel::Norm, "tex7: cnt:%i, fmt:%s, shft:%i\n", cpRegs.vatC[i].tex7cnt, fmtname[cpRegs.vatC[i].tex7fmt], cpRegs.vatC[i].tex7shft); + + Report(Channel::Norm, "bytedeq: %i, nrmidx3: %i, vcacheEnch: %i\n", cpRegs.vatA[i].bytedeq, cpRegs.vatA[i].nrmidx3, cpRegs.vatB[i].vcache); + Report(Channel::Norm, "VertexSize (calculated): %i bytes\n", VtxSize[i]); + } + + return nullptr; +} + +void DolwinVideoReflector() +{ + JDI::Hub.AddCmd("DumpVat", DumpVat); +} long GXOpen(HWConfig* config, uint8_t * ramPtr) { @@ -34,6 +102,8 @@ long GXOpen(HWConfig* config, uint8_t * ramPtr) gxOpened = true; + JDI::Hub.AddNode(DOLWIN_VIDEO_JDI_JSON, DolwinVideoReflector); + return true; } @@ -46,5 +116,7 @@ void GXClose() TexFree(); + JDI::Hub.RemoveNode(DOLWIN_VIDEO_JDI_JSON); + gxOpened = false; } diff --git a/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj b/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj index 63c76742..7cc1c16b 100644 --- a/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj +++ b/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj @@ -180,6 +180,7 @@ + diff --git a/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj.filters b/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj.filters index 4eef5261..d9ea1bf4 100644 --- a/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj.filters +++ b/SRC/Backends/DolwinVideo/Scripts/VS2019/DolwinVideo.vcxproj.filters @@ -74,5 +74,6 @@ + \ No newline at end of file diff --git a/SRC/Backends/DolwinVideo/pch.h b/SRC/Backends/DolwinVideo/pch.h index c7dfce5b..707c3638 100644 --- a/SRC/Backends/DolwinVideo/pch.h +++ b/SRC/Backends/DolwinVideo/pch.h @@ -16,14 +16,18 @@ #include #include -#include "../../Common/Json.h" #include "../../Common/Spinlock.h" #include "../../Common/Thread.h" +#include "../../Common/Json.h" +#include "../../Common/Jdi.h" #include "../../Debugger/Debugger.h" #include "../../Hardware/HWConfig.h" +#define DOLWIN_VIDEO_JDI_JSON L"./Data/Json/DolwinVideoJdi.json" +void DolwinVideoReflector(); + #include "GL.h" #include "GX.h" #include "FifoProcessor.h" From 194546a0171b5900e940ca2ded645c6ff1ea32f0 Mon Sep 17 00:00:00 2001 From: ogamespec Date: Thu, 27 Aug 2020 22:01:45 +0300 Subject: [PATCH 3/5] Small improvements on console debugger --- Data/DefaultSettings.json | 24 +++++++------------ Data/Json/UIJdi.json | 20 ++++++++++++++++ SRC/GekkoCore/GekkoCommands.cpp | 7 +++--- SRC/Hardware/MI.cpp | 5 ++++ SRC/UI/Legacy/DebugConsole/GekkoDebugger.cpp | 2 +- SRC/UI/Legacy/DebugConsole/GekkoDisasm.cpp | 2 +- SRC/UI/Legacy/DebugConsole/GekkoRegs.cpp | 11 +++++++++ SRC/UI/Legacy/DebugConsole/ReportView.cpp | 5 ++++ .../Scripts/VS2019/DolwinLegacy.vcxproj | 1 + .../VS2019/DolwinLegacy.vcxproj.filters | 1 + SRC/UI/Legacy/DolwinLegacy/UserCommands.cpp | 20 ++++++++++++++++ SRC/UI/Legacy/DolwinLegacy/UserSelector.cpp | 4 ++++ SRC/UI/Legacy/DolwinLegacy/UserWindow.cpp | 17 ++++++++++++- SRC/UI/Legacy/DolwinLegacy/UserWindow.h | 3 +++ 14 files changed, 101 insertions(+), 21 deletions(-) diff --git a/Data/DefaultSettings.json b/Data/DefaultSettings.json index 658d19c7..ee038228 100644 --- a/Data/DefaultSettings.json +++ b/Data/DefaultSettings.json @@ -8,14 +8,13 @@ { "DOLDEBUG": false, "FILTER": 4294967295, - "LASTDIR_ALL": ".\\", - "LASTDIR_DVD": ".\\", - "LASTDIR_MAP": ".\\Data", - "LASTDIR_PATCH": ".\\Data", + "LASTDIR_ALL": "./", + "LASTDIR_DVD": "./", + "LASTDIR_MAP": "./Data", + "LASTDIR_PATCH": "./Data", "LASTFILE": "", "ONTOP": false, - "PATH": ".\\", - "PROFILE": true, + "PATH": "./", "RECENT0": "", "RECENT1": "", "RECENT2": "", @@ -24,25 +23,20 @@ "RECENTNUM": 0, "RUNONCE": true, "SELECTOR": true, - "SMALLICONS": false, + "SMALLICONS": true, "SORTVIEW": 1 }, "loader": { "BINORG": 12544, - "MAKEMAP": true, - "PATCH": true - }, - - "core": - { + "MAKEMAP": true }, "hardware": { - "ANSI": "Data\\AnsiFont.szp", - "SJIS": "Data\\SjisFont.szp", + "ANSI": "Data/AnsiFont.szp", + "SJIS": "Data/SjisFont.szp", "CONSOLE": 3, "EXI_LOG": true, "OS_REPORT": true, diff --git a/Data/Json/UIJdi.json b/Data/Json/UIJdi.json index 85527996..fb4a8ce4 100644 --- a/Data/Json/UIJdi.json +++ b/Data/Json/UIJdi.json @@ -30,6 +30,26 @@ "internal": true, "help": "Return UI Render Target object", "output": "Int" + }, + + "d": { + "help": "Set memory address to view in debugger", + "args": 1, + "hints": "
", + "usage": [ + "Syntax: d
\n", + "Example: d 0x80003000\n" + ] + }, + + "u": { + "help": "Set memory address for viewing disassembled Gekko code", + "args": 1, + "hints": "
", + "usage": [ + "Syntax: u
\n", + "Example: u 0x80003000\n" + ] } } diff --git a/SRC/GekkoCore/GekkoCommands.cpp b/SRC/GekkoCore/GekkoCommands.cpp index dc845902..c6ab96d9 100644 --- a/SRC/GekkoCore/GekkoCommands.cpp +++ b/SRC/GekkoCore/GekkoCommands.cpp @@ -560,7 +560,7 @@ namespace Gekko Json::Value* output = new Json::Value(); output->type = Json::ValueType::Int; - output->value.AsInt = pa < RAMSIZE ? (uint64_t)&mi.ram[pa] : 0; + output->value.AsInt = (uint64_t)MITranslatePhysicalAddress(pa, sizeof(uint32_t)); return output; } @@ -649,11 +649,12 @@ namespace Gekko std::string text = ""; - if (pa < RAMSIZE) + uint8_t* ptr = MITranslatePhysicalAddress(pa, sizeof(uint32_t)); + + if (ptr != nullptr) { AnalyzeInfo info = { 0 }; - uint8_t* ptr = &mi.ram[pa]; uint32_t instr = _BYTESWAP_UINT32(*(uint32_t*)ptr); Gekko::Analyzer::Analyze(addr, instr, &info); diff --git a/SRC/Hardware/MI.cpp b/SRC/Hardware/MI.cpp index f69e6bda..8770d7d5 100644 --- a/SRC/Hardware/MI.cpp +++ b/SRC/Hardware/MI.cpp @@ -575,6 +575,11 @@ uint8_t* MITranslatePhysicalAddress(uint32_t physAddr, size_t bytes) { return &mi.ram[physAddr]; } + + if (physAddr >= BOOTROM_START_ADDRESS && mi.BootromPresent) + { + return &mi.bootrom[physAddr - BOOTROM_START_ADDRESS]; + } return nullptr; } diff --git a/SRC/UI/Legacy/DebugConsole/GekkoDebugger.cpp b/SRC/UI/Legacy/DebugConsole/GekkoDebugger.cpp index 37f2bd4d..83dcfc02 100644 --- a/SRC/UI/Legacy/DebugConsole/GekkoDebugger.cpp +++ b/SRC/UI/Legacy/DebugConsole/GekkoDebugger.cpp @@ -149,7 +149,7 @@ namespace Debug if (Jdi.IsLoaded() && !Jdi.IsRunning()) { Jdi.GekkoStep(); - disasm->SetCursor(Jdi.GetPc() + 4); + disasm->SetCursor(Jdi.GetPc()); InvalidateAll(); } break; diff --git a/SRC/UI/Legacy/DebugConsole/GekkoDisasm.cpp b/SRC/UI/Legacy/DebugConsole/GekkoDisasm.cpp index 0fa64de9..b4db3320 100644 --- a/SRC/UI/Legacy/DebugConsole/GekkoDisasm.cpp +++ b/SRC/UI/Legacy/DebugConsole/GekkoDisasm.cpp @@ -59,7 +59,7 @@ namespace Debug switch (Vkey) { case VK_HOME: - SetCursor(cursor); + SetCursor(Jdi.GetPc()); break; case VK_END: diff --git a/SRC/UI/Legacy/DebugConsole/GekkoRegs.cpp b/SRC/UI/Legacy/DebugConsole/GekkoRegs.cpp index e95c1acb..330b3a8c 100644 --- a/SRC/UI/Legacy/DebugConsole/GekkoRegs.cpp +++ b/SRC/UI/Legacy/DebugConsole/GekkoRegs.cpp @@ -33,6 +33,17 @@ namespace Debug Print(CuiColor::Cyan, CuiColor::White, 2, 0, "*"); } + // Show status of Gekko and DSP + + std::string coreStatus; + + coreStatus += "Gekko: "; + coreStatus += Jdi.IsRunning() ? "Run " : "Halt"; + coreStatus += " DSP: "; + coreStatus += Jdi.DspIsRunning() ? "Run " : "Halt"; + + Print(CuiColor::Cyan, CuiColor::Black, (int)(width - coreStatus.size() - 2), 0, coreStatus); + std::string modeText; switch (mode) diff --git a/SRC/UI/Legacy/DebugConsole/ReportView.cpp b/SRC/UI/Legacy/DebugConsole/ReportView.cpp index 64e7392d..92d024d1 100644 --- a/SRC/UI/Legacy/DebugConsole/ReportView.cpp +++ b/SRC/UI/Legacy/DebugConsole/ReportView.cpp @@ -63,6 +63,11 @@ namespace Debug { textColor = wnd->ChannelNameToColor(channelName); + if (channelName == "Error") + { + channelName = "Break"; + } + if (!(channelName == "Info" || channelName == "Header")) { text += channelName + ": "; diff --git a/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj b/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj index db6716ed..aeca737d 100644 --- a/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj +++ b/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj @@ -214,6 +214,7 @@ + diff --git a/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj.filters b/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj.filters index e2896f65..3ec7bbd6 100644 --- a/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj.filters +++ b/SRC/UI/Legacy/DolwinLegacy/Scripts/VS2019/DolwinLegacy.vcxproj.filters @@ -107,6 +107,7 @@ + diff --git a/SRC/UI/Legacy/DolwinLegacy/UserCommands.cpp b/SRC/UI/Legacy/DolwinLegacy/UserCommands.cpp index 75693746..59c06321 100644 --- a/SRC/UI/Legacy/DolwinLegacy/UserCommands.cpp +++ b/SRC/UI/Legacy/DolwinLegacy/UserCommands.cpp @@ -48,9 +48,29 @@ Json::Value* CmdGetRenderTarget(std::vector& args) return value; } +Json::Value* CmdShowMemory(std::vector& args) +{ + if (gekkoDebug) + { + gekkoDebug->SetMemoryCursor(strtoul(args[1].c_str(), nullptr, 0)); + } + return nullptr; +} + +Json::Value* CmdShowDisassembly(std::vector& args) +{ + if (gekkoDebug) + { + gekkoDebug->SetDisasmCursor(strtoul(args[1].c_str(), nullptr, 0)); + } + return nullptr; +} + void UIReflector() { UI::Jdi.JdiAddCmd("UIError", CmdUIError); UI::Jdi.JdiAddCmd("UIReport", CmdUIReport); UI::Jdi.JdiAddCmd("GetRenderTarget", CmdGetRenderTarget); + UI::Jdi.JdiAddCmd("d", CmdShowMemory); + UI::Jdi.JdiAddCmd("u", CmdShowDisassembly); } diff --git a/SRC/UI/Legacy/DolwinLegacy/UserSelector.cpp b/SRC/UI/Legacy/DolwinLegacy/UserSelector.cpp index 1434e6b7..dded4fdc 100644 --- a/SRC/UI/Legacy/DolwinLegacy/UserSelector.cpp +++ b/SRC/UI/Legacy/DolwinLegacy/UserSelector.cpp @@ -902,6 +902,10 @@ static void doubleclick() UI::Jdi.Unload(); UI::Jdi.LoadFile(Util::WstringToString(path)); + if (gekkoDebug) + { + gekkoDebug->InvalidateAll(); + } OnMainWindowOpened(path.c_str()); UI::Jdi.Run(); } diff --git a/SRC/UI/Legacy/DolwinLegacy/UserWindow.cpp b/SRC/UI/Legacy/DolwinLegacy/UserWindow.cpp index 97ee3b3e..362e4bfe 100644 --- a/SRC/UI/Legacy/DolwinLegacy/UserWindow.cpp +++ b/SRC/UI/Legacy/DolwinLegacy/UserWindow.cpp @@ -244,6 +244,10 @@ void LoadRecentFile(int index) std::wstring path = GetRecentEntry((RecentNum+1) - index); UI::Jdi.Unload(); UI::Jdi.LoadFile(Util::WstringToString(path)); + if (gekkoDebug) + { + gekkoDebug->InvalidateAll(); + } OnMainWindowOpened(path.c_str()); UI::Jdi.Run(); } @@ -663,6 +667,10 @@ static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP loadFile: UI::Jdi.LoadFile(Util::WstringToString(name)); + if (gekkoDebug) + { + gekkoDebug->InvalidateAll(); + } OnMainWindowOpened(name.c_str()); UI::Jdi.Run(); } @@ -695,7 +703,14 @@ static LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lP { UI::Jdi.LoadFile("Bootrom"); OnMainWindowOpened(L"Bootrom"); - UI::Jdi.Run(); + if (gekkoDebug == nullptr) + { + UI::Jdi.Run(); + } + else + { + gekkoDebug->SetDisasmCursor(0xfff0'0100); + } return 0; } /* Open/close DVD lid */ diff --git a/SRC/UI/Legacy/DolwinLegacy/UserWindow.h b/SRC/UI/Legacy/DolwinLegacy/UserWindow.h index 54be4100..f39f34ee 100644 --- a/SRC/UI/Legacy/DolwinLegacy/UserWindow.h +++ b/SRC/UI/Legacy/DolwinLegacy/UserWindow.h @@ -48,3 +48,6 @@ struct UserWindow }; extern UserWindow wnd; + +extern Debug::DspDebug* dspDebug; +extern Debug::GekkoDebug* gekkoDebug; From 96a9fb321f022ba0662fd2a972549bf70c9f2254 Mon Sep 17 00:00:00 2001 From: ogamespec Date: Thu, 27 Aug 2020 23:12:08 +0300 Subject: [PATCH 4/5] Memcards fix --- SRC/Backends/DolwinVideo/Fifo.cpp | 42 +++++++++++++++---- SRC/Hardware/MC.cpp | 12 +++++- SRC/UI/Legacy/DolwinLegacy/UserMemcards.cpp | 45 +++++++++++++++++++-- 3 files changed, 86 insertions(+), 13 deletions(-) diff --git a/SRC/Backends/DolwinVideo/Fifo.cpp b/SRC/Backends/DolwinVideo/Fifo.cpp index 46fb0900..9b96da99 100644 --- a/SRC/Backends/DolwinVideo/Fifo.cpp +++ b/SRC/Backends/DolwinVideo/Fifo.cpp @@ -17,6 +17,8 @@ GX_FromFuture::FifoProcessor GxFifo; bool frame_done = true; +bool logDrawCommands = false; + // --------------------------------------------------------------------------- // stage callbacks @@ -975,7 +977,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) uint8_t* fifoPtr = &RAM[physAddress]; size_t size = fifo->Read32() & ~0x1f; - Report(Channel::GP, "OP_CMD_CALL_DL: addr: 0x%08X, size: %i\n", physAddress, size); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_CALL_DL: addr: 0x%08X, size: %i\n", physAddress, size); + } GX_FromFuture::FifoProcessor* callDlFifo = new GX_FromFuture::FifoProcessor(fifoPtr, size); @@ -1134,7 +1139,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_QUAD: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_QUAD: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 1---2 tri1: 0-1-2 | /| tri2: 0-2-3 @@ -1171,7 +1179,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_TRIANGLE: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_TRIANGLE: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 1---2 tri: 0-1-2 | / @@ -1208,7 +1219,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_STRIP: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_STRIP: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 1---3---5 tri1: 0-1-2 /| /| / tri2: 1-2-3 @@ -1260,7 +1274,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_FAN: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_FAN: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 1---2---3 tri1: 0-1-2 | / _/ tri2: 0-2-3 @@ -1311,7 +1328,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_LINE: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_LINE: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 1 3 5 / / / @@ -1348,7 +1368,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_LINESTRIP: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_LINESTRIP: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 1 3 5 /| /| / @@ -1395,7 +1418,10 @@ static void GxCommand(GX_FromFuture::FifoProcessor * fifo) unsigned vatnum = cmd & 7; unsigned vtxnum = fifo->Read16(); usevat = vatnum; - Report(Channel::GP, "OP_CMD_DRAW_POINT: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + if (logDrawCommands) + { + Report(Channel::GP, "OP_CMD_DRAW_POINT: vtxnum: %i, vat: %i\n", vtxnum, vatnum); + } /*/ 0---0 tri: 0-0-0 (1x1x1 tri) | / diff --git a/SRC/Hardware/MC.cpp b/SRC/Hardware/MC.cpp index c3962c41..260809e7 100644 --- a/SRC/Hardware/MC.cpp +++ b/SRC/Hardware/MC.cpp @@ -251,7 +251,7 @@ static void MCReadArrayProc (Memcard * memcard){ offset = MCCalculateOffset(auxdata); if (offset >= memcard->size + size) { - Halt("MC :: ReadArray offset is out of range\n"); + Report(Channel::MC, "ReadArray offset is out of range\n"); return; } @@ -530,6 +530,16 @@ void MCOpen (HWConfig * config) wcscpy(memcard[MEMCARD_SLOTB].filename, config->MemcardB_Filename); SyncSave = config->Memcard_SyncSave; + if (!Util::FileExists(memcard[MEMCARD_SLOTA].filename)) + { + Memcard_Connected[MEMCARD_SLOTA] = false; + } + + if (!Util::FileExists(memcard[MEMCARD_SLOTB].filename)) + { + Memcard_Connected[MEMCARD_SLOTB] = false; + } + MCConnect(); } diff --git a/SRC/UI/Legacy/DolwinLegacy/UserMemcards.cpp b/SRC/UI/Legacy/DolwinLegacy/UserMemcards.cpp index 91d589b0..b89c7e30 100644 --- a/SRC/UI/Legacy/DolwinLegacy/UserMemcards.cpp +++ b/SRC/UI/Legacy/DolwinLegacy/UserMemcards.cpp @@ -252,6 +252,7 @@ static INT_PTR CALLBACK MemcardSettingsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar { wchar_t buf[MAX_PATH] = { 0 }, buf2[MAX_PATH] = { 0 }, * filename; size_t newsize; + size_t fileSize; switch(uMsg) { @@ -264,6 +265,19 @@ static INT_PTR CALLBACK MemcardSettingsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar else if (um_num == 1) SendMessage(hwndDlg, WM_SETTEXT, (WPARAM)0, lParam = (LPARAM)L"Memcard B Settings"); + SyncSave = UI::Jdi.GetConfigBool(Memcard_SyncSave_Key, USER_MEMCARDS); + + if (um_num == 0) + { + Memcard_Connected[um_num] = UI::Jdi.GetConfigBool(MemcardA_Connected_Key, USER_MEMCARDS); + wcscpy_s(Memcard_filename[um_num], _countof(Memcard_filename[um_num]), Util::StringToWstring(UI::Jdi.GetConfigString(MemcardA_Filename_Key, USER_MEMCARDS)).c_str()); + } + else if (um_num == 1) + { + Memcard_Connected[um_num] = UI::Jdi.GetConfigBool(MemcardB_Connected_Key, USER_MEMCARDS); + wcscpy_s(Memcard_filename[um_num], _countof(Memcard_filename[um_num]), Util::StringToWstring(UI::Jdi.GetConfigString(MemcardB_Filename_Key, USER_MEMCARDS)).c_str()); + } + if (SyncSave) CheckRadioButton(hwndDlg, IDC_MEMCARD_SYNCSAVE_FALSE, IDC_MEMCARD_SYNCSAVE_TRUE, IDC_MEMCARD_SYNCSAVE_TRUE ); @@ -286,11 +300,20 @@ static INT_PTR CALLBACK MemcardSettingsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar SendDlgItemMessage(hwndDlg, IDC_MEMCARD_PATH, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCTSTR)buf); } + if (Util::FileExists(buf)) + { + fileSize = Util::FileSize(buf); + } + else + { + Memcard_Connected[um_num] = false; + fileSize = 0; + } + if (Memcard_Connected[um_num]) { - // TODO: Refactoring - //_stprintf_s (buf, _countof(buf) - 1, _T("Size: %d usable blocks (%d Kb)"), - // (int)(memcard[um_num].size / Memcard_BlockSize - 5), (int)(memcard[um_num].size / 1024)); - //SendDlgItemMessage(hwndDlg, IDC_MEMCARD_SIZEDESC, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCTSTR)buf); + swprintf_s (buf, _countof(buf) - 1, L"Size: %d usable blocks (%d Kb)", + (int)(fileSize / Memcard_BlockSize - 5), (int)(fileSize / 1024)); + SendDlgItemMessage(hwndDlg, IDC_MEMCARD_SIZEDESC, WM_SETTEXT, (WPARAM)0, (LPARAM)(LPCTSTR)buf); } else { SendDlgItemMessage(hwndDlg, IDC_MEMCARD_SIZEDESC, WM_SETTEXT, (WPARAM)0, (LPARAM)L"Not connected"); @@ -377,6 +400,18 @@ static INT_PTR CALLBACK MemcardSettingsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar wcscat_s(buf, _countof(buf) - 1, L"\\"); wcscat_s(buf, _countof(buf) - 1, buf2); } + else + { + size_t Fnsize, Pathsize; + Fnsize = SendDlgItemMessage(hwndDlg, IDC_MEMCARD_FILE, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0); + Pathsize = SendDlgItemMessage(hwndDlg, IDC_MEMCARD_PATH, WM_GETTEXTLENGTH, (WPARAM)0, (LPARAM)0); + + SendDlgItemMessage(hwndDlg, IDC_MEMCARD_PATH, WM_GETTEXT, (WPARAM)(Pathsize + 1), (LPARAM)(LPCTSTR)buf); + SendDlgItemMessage(hwndDlg, IDC_MEMCARD_FILE, WM_GETTEXT, (WPARAM)(Fnsize + 1), (LPARAM)(LPCTSTR)buf2); + + wcscat_s(buf, _countof(buf) - 1, L"\\"); + wcscat_s(buf, _countof(buf) - 1, buf2); + } if (IsDlgButtonChecked(hwndDlg, IDC_MEMCARD_SYNCSAVE_FALSE) == BST_CHECKED ) SyncSave = false; @@ -398,11 +433,13 @@ static INT_PTR CALLBACK MemcardSettingsProc(HWND hwndDlg, UINT uMsg, WPARAM wPar if (um_num == 0) { + wcscpy_s(Memcard_filename[0], _countof(Memcard_filename[0]), buf); UI::Jdi.SetConfigBool(MemcardA_Connected_Key, Memcard_Connected[0], USER_MEMCARDS); UI::Jdi.SetConfigString(MemcardA_Filename_Key, Util::WstringToString(Memcard_filename[0]), USER_MEMCARDS); } else { + wcscpy_s(Memcard_filename[1], _countof(Memcard_filename[1]), buf); UI::Jdi.SetConfigBool(MemcardB_Connected_Key, Memcard_Connected[1], USER_MEMCARDS); UI::Jdi.SetConfigString(MemcardB_Filename_Key, Util::WstringToString(Memcard_filename[1]), USER_MEMCARDS); } From c5f82be8807c20d74f6ea1c939f77585682e9246 Mon Sep 17 00:00:00 2001 From: ogamespec Date: Thu, 27 Aug 2020 23:56:27 +0300 Subject: [PATCH 5/5] Fixed BS1 hung --- Data/DefaultSettings.json | 6 ++--- SRC/GekkoCore/GekkoCommands.cpp | 2 +- SRC/GekkoCore/Interpreter/System.cpp | 37 ++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/Data/DefaultSettings.json b/Data/DefaultSettings.json index ee038228..dea1e1dc 100644 --- a/Data/DefaultSettings.json +++ b/Data/DefaultSettings.json @@ -43,9 +43,9 @@ "RSWHACK": true, "VI_LOG": false, "VI_XFB": true, - "BOOTROM": "", - "DSP_DROM": "", - "DSP_IROM": "", + "BOOTROM": "Data/gc-ntsc-10.bin", + "DSP_DROM": "Data/dsp_drom.bin", + "DSP_IROM": "Data/dsp_irom.bin", }, "hle": diff --git a/SRC/GekkoCore/GekkoCommands.cpp b/SRC/GekkoCore/GekkoCommands.cpp index c6ab96d9..c41d47dd 100644 --- a/SRC/GekkoCore/GekkoCommands.cpp +++ b/SRC/GekkoCore/GekkoCommands.cpp @@ -540,7 +540,7 @@ namespace Gekko Json::Value* output = new Json::Value(); output->type = Json::ValueType::Int; - output->value.AsInt = pa < RAMSIZE ? (uint64_t)&mi.ram[pa] : 0; + output->value.AsInt = (uint64_t)MITranslatePhysicalAddress(pa, sizeof(uint32_t)); return output; } diff --git a/SRC/GekkoCore/Interpreter/System.cpp b/SRC/GekkoCore/Interpreter/System.cpp index d5ca2377..66ee7157 100644 --- a/SRC/GekkoCore/Interpreter/System.cpp +++ b/SRC/GekkoCore/Interpreter/System.cpp @@ -115,7 +115,19 @@ namespace Gekko return; } + uint32_t oldMsr = Gekko->regs.msr; Gekko->regs.msr = RRS; + + if ((oldMsr & MSR_IR) != (Gekko->regs.msr & MSR_IR)) + { + Gekko->itlb.InvalidateAll(); + } + + if ((oldMsr & MSR_DR) != (Gekko->regs.msr & MSR_DR)) + { + Gekko->dtlb.InvalidateAll(); + } + Gekko->regs.pc += 4; } @@ -171,6 +183,9 @@ namespace Gekko Report(Channel::CPU, "SDR <- %08X (IR:%i DR:%i pc:%08X)\n", RRS, msr_ir, msr_dr, Gekko->regs.pc); + + Gekko->dtlb.InvalidateAll(); + Gekko->itlb.InvalidateAll(); } break; @@ -281,6 +296,28 @@ namespace Gekko } } break; + + case (int)SPR::IBAT0U: + case (int)SPR::IBAT0L: + case (int)SPR::IBAT1U: + case (int)SPR::IBAT1L: + case (int)SPR::IBAT2U: + case (int)SPR::IBAT2L: + case (int)SPR::IBAT3U: + case (int)SPR::IBAT3L: + Gekko->itlb.InvalidateAll(); + break; + + case (int)SPR::DBAT0U: + case (int)SPR::DBAT0L: + case (int)SPR::DBAT1U: + case (int)SPR::DBAT1L: + case (int)SPR::DBAT2U: + case (int)SPR::DBAT2L: + case (int)SPR::DBAT3U: + case (int)SPR::DBAT3L: + Gekko->dtlb.InvalidateAll(); + break; } // default