From b6af82efa8fd150f0f6e9ba5a60c7d8610d92239 Mon Sep 17 00:00:00 2001 From: "Jake.Stine" Date: Mon, 19 Jul 2010 15:49:30 +0000 Subject: [PATCH] GSdx / zzogl-pg / pcsx2: * Implemented support for legacy GS plugins (considered anything prior to the Reordering merge). * Added a lot of 'const' qualifiers to the GSgifTransfer functions in both GSdx and zzogl. DevNote: GS plugins shouldn't be modifying the data provided to them from PCSX2 -- zzogl wasn't, GSdx was. I had to do a little bit of juggling to remove the mem modifications from GSdx's TEX0/TEX2 handlers. With luck, nothing's broken. ;) git-svn-id: http://pcsx2.googlecode.com/svn/trunk@3536 96395faa-99c1-11dd-bbfe-3dabce05a288 --- common/include/PS2Edefs.h | 4 +- pcsx2/PluginManager.cpp | 49 +++++- plugins/GSdx/GS.cpp | 10 +- plugins/GSdx/GSDump.cpp | 2 +- plugins/GSdx/GSDump.h | 2 +- plugins/GSdx/GSLocalMemory.cpp | 30 ++-- plugins/GSdx/GSLocalMemory.h | 24 +-- plugins/GSdx/GSState.cpp | 206 +++++++++++++----------- plugins/GSdx/GSState.h | 124 +++++++------- plugins/GSdx/GSdx.def | 2 +- plugins/zzogl-pg/opengl/GS.h | 6 +- plugins/zzogl-pg/opengl/GifTransfer.cpp | 16 +- plugins/zzogl-pg/opengl/GifTransfer.h | 10 +- plugins/zzogl-pg/opengl/Regs.cpp | 156 +++++++++--------- plugins/zzogl-pg/opengl/Regs.h | 150 ++++++++--------- 15 files changed, 432 insertions(+), 359 deletions(-) diff --git a/common/include/PS2Edefs.h b/common/include/PS2Edefs.h index 64a98e1016..a456d57800 100644 --- a/common/include/PS2Edefs.h +++ b/common/include/PS2Edefs.h @@ -248,7 +248,7 @@ void CALLBACK GSsetSettingsDir( const char* dir ); void CALLBACK GSsetLogDir( const char* dir ); void CALLBACK GSvsync(int field); -void CALLBACK GSgifTransfer(u32 *pMem, u32 addr); +void CALLBACK GSgifTransfer(const u32 *pMem, u32 addr); void CALLBACK GSgifTransfer1(u32 *pMem, u32 addr); void CALLBACK GSgifTransfer2(u32 *pMem, u32 size); void CALLBACK GSgifTransfer3(u32 *pMem, u32 size); @@ -565,7 +565,7 @@ typedef void (CALLBACK* _PS2EsetEmuVersion)(const char* emuId, u32 version); // typedef s32 (CALLBACK* _GSopen)(void *pDsp, char *Title, int multithread); typedef s32 (CALLBACK* _GSopen2)( void *pDsp, u32 flags ); typedef void (CALLBACK* _GSvsync)(int field); -typedef void (CALLBACK* _GSgifTransfer)(u32 *pMem, u32 size); +typedef void (CALLBACK* _GSgifTransfer)(const u32 *pMem, u32 size); typedef void (CALLBACK* _GSgifTransfer1)(u32 *pMem, u32 addr); typedef void (CALLBACK* _GSgifTransfer2)(u32 *pMem, u32 size); typedef void (CALLBACK* _GSgifTransfer3)(u32 *pMem, u32 size); diff --git a/pcsx2/PluginManager.cpp b/pcsx2/PluginManager.cpp index 558a12180f..0baa516f55 100644 --- a/pcsx2/PluginManager.cpp +++ b/pcsx2/PluginManager.cpp @@ -192,6 +192,51 @@ void CALLBACK GS_getTitleInfo( char dest[128] ) dest[2] = 0; } +// This legacy passthrough function is needed because the old GS plugins tended to assume that +// a PATH1 transfer that didn't EOP needed an automatic EOP (which was needed to avoid a crash +// in the BIOS when it starts an XGKICK prior to having an EOP written to VU1 memory). The new +// MTGS wraps data around the end of the MTGS buffer, so it often splits PATH1 data into two +// transfers now. +static void CALLBACK GS_gifTransferLegacy( const u32* src, u32 data ) +{ + static __aligned16 u128 path1queue[0x400]; + static uint path1size = 0; + + const u128* src128 = (u128*)src; + + if( (src128 + data) >= &RingBuffer.m_Ring[RingBufferSize] ) + { + // the transfer is most likely wrapped/partial. We need to queue it into a linear buffer + // and then send it on its way on the next copy. + + memcpy_qwc( path1queue, src128, data ); + path1size = data; + } + else + { + if (path1size != 0) + { + // Previous transfer check. *Most* likely this one should be added to it, but to know for + // sure we need to check to see if src points to the head of RingBuffer. If its pointing + // to like Ringbuffer[1] instead it means the last transfer finished and this transfer is + // a new one. + + if (src128 == RingBuffer.m_Ring) + { + pxAssume( (data+path1size) <= 0x400 ); + memcpy_qwc( &path1queue[path1size], src128, data ); + path1size += data; + } + GSgifTransfer1( (u32*)path1queue, 0 ); + path1size = 0; + } + else + { + GSgifTransfer1( (u32*)src128, 0 ); + } + } +} + // PAD _PADinit PADinit; @@ -310,8 +355,7 @@ static const LegacyApi_ReqMethod s_MethMessReq_GS[] = { { "GSopen", (vMeth**)&GSopen, NULL }, { "GSvsync", (vMeth**)&GSvsync, NULL }, - { "GSgifTransfer", (vMeth**)&GSgifTransfer, NULL }, - //{ "GSgifTransfer1", (vMeth**)&GSgifTransfer1, NULL }, + { "GSgifTransfer", (vMeth**)&GSgifTransfer, (vMeth*)GS_gifTransferLegacy }, { "GSgifTransfer2", (vMeth**)&GSgifTransfer2, NULL }, { "GSgifTransfer3", (vMeth**)&GSgifTransfer3, NULL }, { "GSreadFIFO2", (vMeth**)&GSreadFIFO2, NULL }, @@ -339,6 +383,7 @@ static const LegacyApi_OptMethod s_MethMessOpt_GS[] = { "GSmakeSnapshot2", (vMeth**)&GSmakeSnapshot2 }, { "GSgifSoftReset", (vMeth**)&GSgifSoftReset }, { "GSreadFIFO", (vMeth**)&GSreadFIFO }, + { "GSgifTransfer1", (vMeth**)&GSgifTransfer1 }, { NULL } }; diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 359c9f004e..43c9c57a09 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -319,24 +319,24 @@ EXPORT_C GSreadFIFO2(uint8* mem, uint32 size) s_gs->ReadFIFO(mem, size); } -EXPORT_C GSgifTransfer(uint8* mem, uint32 size) +EXPORT_C GSgifTransfer(const uint8* mem, uint32 size) { - s_gs->Transfer<3>(mem , size); + s_gs->Transfer<3>(mem, size); } EXPORT_C GSgifTransfer1(uint8* mem, uint32 addr) { - s_gs->Transfer<0>(mem + addr, (0x4000 - addr) / 16); + s_gs->Transfer<0>(const_cast(mem) + addr, (0x4000 - addr) / 16); } EXPORT_C GSgifTransfer2(uint8* mem, uint32 size) { - s_gs->Transfer<1>(mem, size); + s_gs->Transfer<1>(const_cast(mem), size); } EXPORT_C GSgifTransfer3(uint8* mem, uint32 size) { - s_gs->Transfer<2>(mem, size); + s_gs->Transfer<2>(const_cast(mem), size); } EXPORT_C GSvsync(int field) diff --git a/plugins/GSdx/GSDump.cpp b/plugins/GSdx/GSDump.cpp index 04a09e595d..594e90a197 100644 --- a/plugins/GSdx/GSDump.cpp +++ b/plugins/GSdx/GSDump.cpp @@ -60,7 +60,7 @@ void GSDump::Close() if(m_obj) {fclose(m_obj); m_obj = NULL;} } -void GSDump::Transfer(int index, uint8* mem, size_t size) +void GSDump::Transfer(int index, const uint8* mem, size_t size) { if(m_gs && size > 0) { diff --git a/plugins/GSdx/GSDump.h b/plugins/GSdx/GSDump.h index f90b4c7833..57059da247 100644 --- a/plugins/GSdx/GSDump.h +++ b/plugins/GSdx/GSDump.h @@ -58,7 +58,7 @@ public: void Open(const string& fn, uint32 crc, const GSFreezeData& fd, const GSPrivRegSet* regs); void Close(); void ReadFIFO(uint32 size); - void Transfer(int index, uint8* mem, size_t size); + void Transfer(int index, const uint8* mem, size_t size); void VSync(int field, bool last, const GSPrivRegSet* regs); void Object(GSVertexSW* vertices, int count, GS_PRIM_CLASS primclass); operator bool() {return m_gs != NULL;} diff --git a/plugins/GSdx/GSLocalMemory.cpp b/plugins/GSdx/GSLocalMemory.cpp index 9ff7a2fde1..6947c8d44e 100644 --- a/plugins/GSdx/GSLocalMemory.cpp +++ b/plugins/GSdx/GSLocalMemory.cpp @@ -543,7 +543,7 @@ GSPixelOffset4* GSLocalMemory::GetPixelOffset4(const GIFRegFRAME& FRAME, const G //////////////////// template -void GSLocalMemory::WriteImageColumn(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageColumn(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { uint32 bp = BITBLTBUF.DBP; uint32 bw = BITBLTBUF.DBW; @@ -572,7 +572,7 @@ void GSLocalMemory::WriteImageColumn(int l, int r, int y, int h, uint8* src, int } template -void GSLocalMemory::WriteImageBlock(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageBlock(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { uint32 bp = BITBLTBUF.DBP; uint32 bw = BITBLTBUF.DBW; @@ -599,7 +599,7 @@ void GSLocalMemory::WriteImageBlock(int l, int r, int y, int h, uint8* src, int } template -void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { uint32 bp = BITBLTBUF.DBP; uint32 bw = BITBLTBUF.DBW; @@ -626,7 +626,7 @@ void GSLocalMemory::WriteImageLeftRight(int l, int r, int y, int h, uint8* src, } template -void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) +void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF) { __aligned16 uint8 buff[64]; // merge buffer for one column @@ -777,7 +777,7 @@ void GSLocalMemory::WriteImageTopBottom(int l, int r, int y, int h, uint8* src, } template -void GSLocalMemory::WriteImage(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -801,7 +801,7 @@ void GSLocalMemory::WriteImage(int& tx, int& ty, uint8* src, int len, GIFRegBITB if(ra - la >= bsx && h > 0) // "transfer width" >= "block width" && there is at least one full row { - uint8* s = &src[-l * trbpp >> 3]; + const uint8* s = &src[-l * trbpp >> 3]; src += srcpitch * h; len -= srcpitch * h; @@ -886,7 +886,7 @@ void GSLocalMemory::WriteImage(int& tx, int& ty, uint8* src, int len, GIFRegBITB #define IsTopLeftAligned(dsax, tx, ty, bw, bh) \ ((((int)dsax) & ((bw)-1)) == 0 && ((tx) & ((bw)-1)) == 0 && ((int)dsax) == (tx) && ((ty) & ((bh)-1)) == 0) -void GSLocalMemory::WriteImage24(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage24(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -920,7 +920,7 @@ void GSLocalMemory::WriteImage24(int& tx, int& ty, uint8* src, int len, GIFRegBI } } -void GSLocalMemory::WriteImage8H(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage8H(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -954,7 +954,7 @@ void GSLocalMemory::WriteImage8H(int& tx, int& ty, uint8* src, int len, GIFRegBI } } -void GSLocalMemory::WriteImage4HL(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage4HL(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -988,7 +988,7 @@ void GSLocalMemory::WriteImage4HL(int& tx, int& ty, uint8* src, int len, GIFRegB } } -void GSLocalMemory::WriteImage4HH(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage4HH(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -1021,7 +1021,7 @@ void GSLocalMemory::WriteImage4HH(int& tx, int& ty, uint8* src, int len, GIFRegB ty = th; } } -void GSLocalMemory::WriteImage24Z(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImage24Z(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(TRXREG.RRW == 0) return; @@ -1054,13 +1054,13 @@ void GSLocalMemory::WriteImage24Z(int& tx, int& ty, uint8* src, int len, GIFRegB ty = th; } } -void GSLocalMemory::WriteImageX(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) +void GSLocalMemory::WriteImageX(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) { if(len <= 0) return; - uint8* pb = (uint8*)src; - uint16* pw = (uint16*)src; - uint32* pd = (uint32*)src; + const uint8* pb = (uint8*)src; + const uint16* pw = (uint16*)src; + const uint32* pd = (uint32*)src; uint32 bp = BITBLTBUF.DBP; uint32 bw = BITBLTBUF.DBW; diff --git a/plugins/GSdx/GSLocalMemory.h b/plugins/GSdx/GSLocalMemory.h index 1a67dd9c6d..4b52190cd9 100644 --- a/plugins/GSdx/GSLocalMemory.h +++ b/plugins/GSdx/GSLocalMemory.h @@ -67,7 +67,7 @@ public: typedef void (GSLocalMemory::*writeFrameAddr)(uint32 addr, uint32 c); typedef uint32 (GSLocalMemory::*readPixelAddr)(uint32 addr) const; typedef uint32 (GSLocalMemory::*readTexelAddr)(uint32 addr, const GIFRegTEXA& TEXA) const; - typedef void (GSLocalMemory::*writeImage)(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + typedef void (GSLocalMemory::*writeImage)(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); typedef void (GSLocalMemory::*readImage)(int& tx, int& ty, uint8* dst, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG) const; typedef void (GSLocalMemory::*readTexture)(const GSOffset* RESTRICT o, const GSVector4i& r, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA); typedef void (GSLocalMemory::*readTextureBlock)(uint32 bp, uint8* dst, int dstpitch, const GIFRegTEXA& TEXA) const; @@ -814,26 +814,26 @@ public: // template - void WriteImageColumn(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageColumn(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImageBlock(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageBlock(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImageLeftRight(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageLeftRight(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImageTopBottom(int l, int r, int y, int h, uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); + void WriteImageTopBottom(int l, int r, int y, int h, const uint8* src, int srcpitch, const GIFRegBITBLTBUF& BITBLTBUF); template - void WriteImage(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage24(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage8H(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage4HL(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage4HH(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImage24Z(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); - void WriteImageX(int& tx, int& ty, uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage24(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage8H(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage4HL(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage4HH(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImage24Z(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); + void WriteImageX(int& tx, int& ty, const uint8* src, int len, GIFRegBITBLTBUF& BITBLTBUF, GIFRegTRXPOS& TRXPOS, GIFRegTRXREG& TRXREG); // TODO: ReadImage32/24/... diff --git a/plugins/GSdx/GSState.cpp b/plugins/GSdx/GSState.cpp index c75e3a477a..c2835ea85f 100644 --- a/plugins/GSdx/GSState.cpp +++ b/plugins/GSdx/GSState.cpp @@ -321,19 +321,19 @@ int GSState::GetFPS() // GIFPackedRegHandler* -void GSState::GIFPackedRegHandlerNull(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerNull(const GIFPackedReg* r) { // ASSERT(0); } -void GSState::GIFPackedRegHandlerPRIM(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerPRIM(const GIFPackedReg* r) { // ASSERT(r->r.PRIM.PRIM < 7); GIFRegHandlerPRIM(&r->r); } -void GSState::GIFPackedRegHandlerRGBA(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerRGBA(const GIFPackedReg* r) { #if _M_SSE >= 0x301 @@ -358,7 +358,7 @@ void GSState::GIFPackedRegHandlerRGBA(GIFPackedReg* r) m_v.RGBAQ.Q = m_q; } -void GSState::GIFPackedRegHandlerSTQ(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerSTQ(const GIFPackedReg* r) { #if defined(_M_AMD64) @@ -379,7 +379,7 @@ void GSState::GIFPackedRegHandlerSTQ(GIFPackedReg* r) m_q = r->STQ.Q; } -void GSState::GIFPackedRegHandlerUV(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerUV(const GIFPackedReg* r) { #if _M_SSE >= 0x200 @@ -394,7 +394,7 @@ void GSState::GIFPackedRegHandlerUV(GIFPackedReg* r) #endif } -void GSState::GIFPackedRegHandlerXYZF2(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerXYZF2(const GIFPackedReg* r) { m_v.XYZ.X = r->XYZF2.X; m_v.XYZ.Y = r->XYZF2.Y; @@ -404,7 +404,7 @@ void GSState::GIFPackedRegHandlerXYZF2(GIFPackedReg* r) VertexKick(r->XYZF2.ADC); } -void GSState::GIFPackedRegHandlerXYZ2(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerXYZ2(const GIFPackedReg* r) { m_v.XYZ.X = r->XYZ2.X; m_v.XYZ.Y = r->XYZ2.Y; @@ -413,48 +413,48 @@ void GSState::GIFPackedRegHandlerXYZ2(GIFPackedReg* r) VertexKick(r->XYZ2.ADC); } -template void GSState::GIFPackedRegHandlerTEX0(GIFPackedReg* r) +template void GSState::GIFPackedRegHandlerTEX0(const GIFPackedReg* r) { GIFRegHandlerTEX0((GIFReg*)&r->u64[0]); } -template void GSState::GIFPackedRegHandlerCLAMP(GIFPackedReg* r) +template void GSState::GIFPackedRegHandlerCLAMP(const GIFPackedReg* r) { GIFRegHandlerCLAMP((GIFReg*)&r->u64[0]); } -void GSState::GIFPackedRegHandlerFOG(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerFOG(const GIFPackedReg* r) { m_v.FOG.F = r->FOG.F; } -void GSState::GIFPackedRegHandlerXYZF3(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerXYZF3(const GIFPackedReg* r) { GIFRegHandlerXYZF3((GIFReg*)&r->u64[0]); } -void GSState::GIFPackedRegHandlerXYZ3(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerXYZ3(const GIFPackedReg* r) { GIFRegHandlerXYZ3((GIFReg*)&r->u64[0]); } -void GSState::GIFPackedRegHandlerA_D(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerA_D(const GIFPackedReg* r) { (this->*m_fpGIFRegHandlers[r->A_D.ADDR])(&r->r); } -void GSState::GIFPackedRegHandlerNOP(GIFPackedReg* r) +void GSState::GIFPackedRegHandlerNOP(const GIFPackedReg* r) { } // GIFRegHandler* -void GSState::GIFRegHandlerNull(GIFReg* r) +void GSState::GIFRegHandlerNull(const GIFReg* r) { // ASSERT(0); } -void GSState::GIFRegHandlerPRIM(GIFReg* r) +void GSState::GIFRegHandlerPRIM(const GIFReg* r) { // ASSERT(r->PRIM.PRIM < 7); @@ -480,22 +480,22 @@ void GSState::GIFRegHandlerPRIM(GIFReg* r) ResetPrim(); } -void GSState::GIFRegHandlerRGBAQ(GIFReg* r) +void GSState::GIFRegHandlerRGBAQ(const GIFReg* r) { m_v.RGBAQ = (GSVector4i)r->RGBAQ; } -void GSState::GIFRegHandlerST(GIFReg* r) +void GSState::GIFRegHandlerST(const GIFReg* r) { m_v.ST = (GSVector4i)r->ST; } -void GSState::GIFRegHandlerUV(GIFReg* r) +void GSState::GIFRegHandlerUV(const GIFReg* r) { m_v.UV.u32[0] = r->UV.u32[0] & 0x3fff3fff; } -void GSState::GIFRegHandlerXYZF2(GIFReg* r) +void GSState::GIFRegHandlerXYZF2(const GIFReg* r) { /* m_v.XYZ.X = r->XYZF.X; @@ -510,40 +510,37 @@ void GSState::GIFRegHandlerXYZF2(GIFReg* r) VertexKick(false); } -void GSState::GIFRegHandlerXYZ2(GIFReg* r) +void GSState::GIFRegHandlerXYZ2(const GIFReg* r) { m_v.XYZ = (GSVector4i)r->XYZ; VertexKick(false); } -template void GSState::GIFRegHandlerTEX0(GIFReg* r) +__forceinline void GSState::ApplyTEX0( uint i, GIFRegTEX0& TEX0 ) { // even if TEX0 did not change, a new palette may have been uploaded and will overwrite the currently queued for drawing - bool wt = m_mem.m_clut.WriteTest(r->TEX0, m_env.TEXCLUT); + bool wt = m_mem.m_clut.WriteTest(TEX0, m_env.TEXCLUT); - if(wt || PRIM->CTXT == i && r->TEX0 != m_env.CTXT[i].TEX0) + if(wt || PRIM->CTXT == i && TEX0 != m_env.CTXT[i].TEX0) { Flush(); } - if(r->TEX0.TW > 10) r->TEX0.TW = 10; - if(r->TEX0.TH > 10) r->TEX0.TH = 10; + TEX0.CPSM &= 0xa; // 1010b - r->TEX0.CPSM &= 0xa; // 1010b - - if((r->TEX0.TBW & 1) && (r->TEX0.PSM == PSM_PSMT8 || r->TEX0.PSM == PSM_PSMT4)) + if((TEX0.TBW & 1) && (TEX0.PSM == PSM_PSMT8 || TEX0.PSM == PSM_PSMT4)) { - r->TEX0.TBW &= ~1; // GS User 2.6 + TEX0.TBW &= ~1; // GS User 2.6 } - if((r->TEX0.u32[0] ^ m_env.CTXT[i].TEX0.u32[0]) & 0x3ffffff) // TBP0 TBW PSM + if((TEX0.u32[0] ^ m_env.CTXT[i].TEX0.u32[0]) & 0x3ffffff) // TBP0 TBW PSM { - m_env.CTXT[i].offset.tex = m_mem.GetOffset(r->TEX0.TBP0, r->TEX0.TBW, r->TEX0.PSM); + m_env.CTXT[i].offset.tex = m_mem.GetOffset(TEX0.TBP0, TEX0.TBW, TEX0.PSM); } - m_env.CTXT[i].TEX0 = (GSVector4i)r->TEX0; + m_env.CTXT[i].TEX0 = TEX0; if(wt) { @@ -551,7 +548,17 @@ template void GSState::GIFRegHandlerTEX0(GIFReg* r) } } -template void GSState::GIFRegHandlerCLAMP(GIFReg* r) +template void GSState::GIFRegHandlerTEX0(const GIFReg* r) +{ + GIFRegTEX0 TEX0 = r->TEX0; + + if(TEX0.TW > 10) TEX0.TW = 10; + if(TEX0.TH > 10) TEX0.TH = 10; + + ApplyTEX0( i, TEX0 ); +} + +template void GSState::GIFRegHandlerCLAMP(const GIFReg* r) { if(PRIM->CTXT == i && r->CLAMP != m_env.CTXT[i].CLAMP) { @@ -561,12 +568,12 @@ template void GSState::GIFRegHandlerCLAMP(GIFReg* r) m_env.CTXT[i].CLAMP = (GSVector4i)r->CLAMP; } -void GSState::GIFRegHandlerFOG(GIFReg* r) +void GSState::GIFRegHandlerFOG(const GIFReg* r) { m_v.FOG = (GSVector4i)r->FOG; } -void GSState::GIFRegHandlerXYZF3(GIFReg* r) +void GSState::GIFRegHandlerXYZF3(const GIFReg* r) { /* m_v.XYZ.X = r->XYZF.X; @@ -581,18 +588,18 @@ void GSState::GIFRegHandlerXYZF3(GIFReg* r) VertexKick(true); } -void GSState::GIFRegHandlerXYZ3(GIFReg* r) +void GSState::GIFRegHandlerXYZ3(const GIFReg* r) { m_v.XYZ = (GSVector4i)r->XYZ; VertexKick(true); } -void GSState::GIFRegHandlerNOP(GIFReg* r) +void GSState::GIFRegHandlerNOP(const GIFReg* r) { } -template void GSState::GIFRegHandlerTEX1(GIFReg* r) +template void GSState::GIFRegHandlerTEX1(const GIFReg* r) { if(PRIM->CTXT == i && r->TEX1 != m_env.CTXT[i].TEX1) { @@ -602,18 +609,24 @@ template void GSState::GIFRegHandlerTEX1(GIFReg* r) m_env.CTXT[i].TEX1 = (GSVector4i)r->TEX1; } -template void GSState::GIFRegHandlerTEX2(GIFReg* r) +template void GSState::GIFRegHandlerTEX2(const GIFReg* r) { // m_env.CTXT[i].TEX2 = r->TEX2; // not used + // TEX2 is a masked write to TEX0, for performing CLUT swaps (palette swaps). + // It only applies the following fields: + // CLD, CSA, CSM, CPSM, CBP, PSM. + // It ignores these fields (uses existing values in the context): + // TFX, TCC, TH, TW, TBW, and TBP0 + uint64 mask = 0xFFFFFFE003F00000ui64; // TEX2 bits + GIFRegTEX0 TEX0; + TEX0.u64 = (m_env.CTXT[i].TEX0.u64 & ~mask) | (r->u64 & mask); - r->u64 = (r->u64 & mask) | (m_env.CTXT[i].TEX0.u64 & ~mask); - - GIFRegHandlerTEX0(r); + ApplyTEX0(i, TEX0); } -template void GSState::GIFRegHandlerXYOFFSET(GIFReg* r) +template void GSState::GIFRegHandlerXYOFFSET(const GIFReg* r) { GSVector4i o = (GSVector4i)r->XYOFFSET & GSVector4i::x0000ffff(); @@ -627,7 +640,7 @@ template void GSState::GIFRegHandlerXYOFFSET(GIFReg* r) m_env.CTXT[i].UpdateScissor(); } -void GSState::GIFRegHandlerPRMODECONT(GIFReg* r) +void GSState::GIFRegHandlerPRMODECONT(const GIFReg* r) { if(r->PRMODECONT != m_env.PRMODECONT) { @@ -645,7 +658,7 @@ void GSState::GIFRegHandlerPRMODECONT(GIFReg* r) UpdateVertexKick(); } -void GSState::GIFRegHandlerPRMODE(GIFReg* r) +void GSState::GIFRegHandlerPRMODE(const GIFReg* r) { if(!m_env.PRMODECONT.AC) { @@ -661,7 +674,7 @@ void GSState::GIFRegHandlerPRMODE(GIFReg* r) UpdateVertexKick(); } -void GSState::GIFRegHandlerTEXCLUT(GIFReg* r) +void GSState::GIFRegHandlerTEXCLUT(const GIFReg* r) { if(r->TEXCLUT != m_env.TEXCLUT) { @@ -671,7 +684,7 @@ void GSState::GIFRegHandlerTEXCLUT(GIFReg* r) m_env.TEXCLUT = (GSVector4i)r->TEXCLUT; } -void GSState::GIFRegHandlerSCANMSK(GIFReg* r) +void GSState::GIFRegHandlerSCANMSK(const GIFReg* r) { if(r->SCANMSK != m_env.SCANMSK) { @@ -681,7 +694,7 @@ void GSState::GIFRegHandlerSCANMSK(GIFReg* r) m_env.SCANMSK = (GSVector4i)r->SCANMSK; } -template void GSState::GIFRegHandlerMIPTBP1(GIFReg* r) +template void GSState::GIFRegHandlerMIPTBP1(const GIFReg* r) { if(PRIM->CTXT == i && r->MIPTBP1 != m_env.CTXT[i].MIPTBP1) { @@ -691,7 +704,7 @@ template void GSState::GIFRegHandlerMIPTBP1(GIFReg* r) m_env.CTXT[i].MIPTBP1 = (GSVector4i)r->MIPTBP1; } -template void GSState::GIFRegHandlerMIPTBP2(GIFReg* r) +template void GSState::GIFRegHandlerMIPTBP2(const GIFReg* r) { if(PRIM->CTXT == i && r->MIPTBP2 != m_env.CTXT[i].MIPTBP2) { @@ -701,7 +714,7 @@ template void GSState::GIFRegHandlerMIPTBP2(GIFReg* r) m_env.CTXT[i].MIPTBP2 = (GSVector4i)r->MIPTBP2; } -void GSState::GIFRegHandlerTEXA(GIFReg* r) +void GSState::GIFRegHandlerTEXA(const GIFReg* r) { if(r->TEXA != m_env.TEXA) { @@ -711,7 +724,7 @@ void GSState::GIFRegHandlerTEXA(GIFReg* r) m_env.TEXA = (GSVector4i)r->TEXA; } -void GSState::GIFRegHandlerFOGCOL(GIFReg* r) +void GSState::GIFRegHandlerFOGCOL(const GIFReg* r) { if(r->FOGCOL != m_env.FOGCOL) { @@ -721,14 +734,14 @@ void GSState::GIFRegHandlerFOGCOL(GIFReg* r) m_env.FOGCOL = (GSVector4i)r->FOGCOL; } -void GSState::GIFRegHandlerTEXFLUSH(GIFReg* r) +void GSState::GIFRegHandlerTEXFLUSH(const GIFReg* r) { // TRACE(_T("TEXFLUSH\n")); // InvalidateTextureCache(); } -template void GSState::GIFRegHandlerSCISSOR(GIFReg* r) +template void GSState::GIFRegHandlerSCISSOR(const GIFReg* r) { if(PRIM->CTXT == i && r->SCISSOR != m_env.CTXT[i].SCISSOR) { @@ -740,7 +753,7 @@ template void GSState::GIFRegHandlerSCISSOR(GIFReg* r) m_env.CTXT[i].UpdateScissor(); } -template void GSState::GIFRegHandlerALPHA(GIFReg* r) +template void GSState::GIFRegHandlerALPHA(const GIFReg* r) { ASSERT(r->ALPHA.A != 3); ASSERT(r->ALPHA.B != 3); @@ -759,7 +772,7 @@ template void GSState::GIFRegHandlerALPHA(GIFReg* r) m_env.CTXT[i].ALPHA.u32[0] = ((~m_env.CTXT[i].ALPHA.u32[0] >> 1) | 0xAA) & m_env.CTXT[i].ALPHA.u32[0]; } -void GSState::GIFRegHandlerDIMX(GIFReg* r) +void GSState::GIFRegHandlerDIMX(const GIFReg* r) { bool update = false; @@ -778,7 +791,7 @@ void GSState::GIFRegHandlerDIMX(GIFReg* r) } } -void GSState::GIFRegHandlerDTHE(GIFReg* r) +void GSState::GIFRegHandlerDTHE(const GIFReg* r) { if(r->DTHE != m_env.DTHE) { @@ -788,7 +801,7 @@ void GSState::GIFRegHandlerDTHE(GIFReg* r) m_env.DTHE = (GSVector4i)r->DTHE; } -void GSState::GIFRegHandlerCOLCLAMP(GIFReg* r) +void GSState::GIFRegHandlerCOLCLAMP(const GIFReg* r) { if(r->COLCLAMP != m_env.COLCLAMP) { @@ -801,7 +814,7 @@ void GSState::GIFRegHandlerCOLCLAMP(GIFReg* r) #endif } -template void GSState::GIFRegHandlerTEST(GIFReg* r) +template void GSState::GIFRegHandlerTEST(const GIFReg* r) { if(PRIM->CTXT == i && r->TEST != m_env.CTXT[i].TEST) { @@ -814,7 +827,7 @@ template void GSState::GIFRegHandlerTEST(GIFReg* r) #endif } -void GSState::GIFRegHandlerPABE(GIFReg* r) +void GSState::GIFRegHandlerPABE(const GIFReg* r) { if(r->PABE != m_env.PABE) { @@ -824,7 +837,7 @@ void GSState::GIFRegHandlerPABE(GIFReg* r) m_env.PABE = (GSVector4i)r->PABE; } -template void GSState::GIFRegHandlerFBA(GIFReg* r) +template void GSState::GIFRegHandlerFBA(const GIFReg* r) { if(PRIM->CTXT == i && r->FBA != m_env.CTXT[i].FBA) { @@ -834,7 +847,7 @@ template void GSState::GIFRegHandlerFBA(GIFReg* r) m_env.CTXT[i].FBA = (GSVector4i)r->FBA; } -template void GSState::GIFRegHandlerFRAME(GIFReg* r) +template void GSState::GIFRegHandlerFRAME(const GIFReg* r) { if(PRIM->CTXT == i && r->FRAME != m_env.CTXT[i].FRAME) { @@ -854,40 +867,41 @@ template void GSState::GIFRegHandlerFRAME(GIFReg* r) #endif } -template void GSState::GIFRegHandlerZBUF(GIFReg* r) +template void GSState::GIFRegHandlerZBUF(const GIFReg* r) { - if(r->ZBUF.u32[0] == 0) + GIFRegZBUF ZBUF = r->ZBUF; + if(ZBUF.u32[0] == 0) { // during startup all regs are cleared to 0 (by the bios or something), so we mask z until this register becomes valid - r->ZBUF.ZMSK = 1; + ZBUF.ZMSK = 1; } - r->ZBUF.PSM |= 0x30; + ZBUF.PSM |= 0x30; - if(r->ZBUF.PSM != PSM_PSMZ32 - && r->ZBUF.PSM != PSM_PSMZ24 - && r->ZBUF.PSM != PSM_PSMZ16 - && r->ZBUF.PSM != PSM_PSMZ16S) + if(ZBUF.PSM != PSM_PSMZ32 + && ZBUF.PSM != PSM_PSMZ24 + && ZBUF.PSM != PSM_PSMZ16 + && ZBUF.PSM != PSM_PSMZ16S) { - r->ZBUF.PSM = PSM_PSMZ32; + ZBUF.PSM = PSM_PSMZ32; } - if(PRIM->CTXT == i && r->ZBUF != m_env.CTXT[i].ZBUF) + if(PRIM->CTXT == i && ZBUF != m_env.CTXT[i].ZBUF) { Flush(); } - if((m_env.CTXT[i].ZBUF.u32[0] ^ r->ZBUF.u32[0]) & 0x3f0001ff) // ZBP PSM + if((m_env.CTXT[i].ZBUF.u32[0] ^ ZBUF.u32[0]) & 0x3f0001ff) // ZBP PSM { - m_env.CTXT[i].offset.zb = m_mem.GetOffset(r->ZBUF.Block(), m_env.CTXT[i].FRAME.FBW, r->ZBUF.PSM); - m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset4(m_env.CTXT[i].FRAME, r->ZBUF); + m_env.CTXT[i].offset.zb = m_mem.GetOffset(ZBUF.Block(), m_env.CTXT[i].FRAME.FBW, ZBUF.PSM); + m_env.CTXT[i].offset.fzb = m_mem.GetPixelOffset4(m_env.CTXT[i].FRAME, ZBUF); } - m_env.CTXT[i].ZBUF = (GSVector4i)r->ZBUF; + m_env.CTXT[i].ZBUF = (GSVector4i)ZBUF; } -void GSState::GIFRegHandlerBITBLTBUF(GIFReg* r) +void GSState::GIFRegHandlerBITBLTBUF(const GIFReg* r) { if(r->BITBLTBUF != m_env.BITBLTBUF) { @@ -907,7 +921,7 @@ void GSState::GIFRegHandlerBITBLTBUF(GIFReg* r) } } -void GSState::GIFRegHandlerTRXPOS(GIFReg* r) +void GSState::GIFRegHandlerTRXPOS(const GIFReg* r) { if(r->TRXPOS != m_env.TRXPOS) { @@ -917,7 +931,7 @@ void GSState::GIFRegHandlerTRXPOS(GIFReg* r) m_env.TRXPOS = (GSVector4i)r->TRXPOS; } -void GSState::GIFRegHandlerTRXREG(GIFReg* r) +void GSState::GIFRegHandlerTRXREG(const GIFReg* r) { if(r->TRXREG != m_env.TRXREG) { @@ -927,7 +941,7 @@ void GSState::GIFRegHandlerTRXREG(GIFReg* r) m_env.TRXREG = (GSVector4i)r->TRXREG; } -void GSState::GIFRegHandlerTRXDIR(GIFReg* r) +void GSState::GIFRegHandlerTRXDIR(const GIFReg* r) { Flush(); @@ -950,14 +964,14 @@ void GSState::GIFRegHandlerTRXDIR(GIFReg* r) } } -void GSState::GIFRegHandlerHWREG(GIFReg* r) +void GSState::GIFRegHandlerHWREG(const GIFReg* r) { ASSERT(m_env.TRXDIR.XDIR == 0); // host => local Write((uint8*)r, 8); // haunting ground } -void GSState::GIFRegHandlerSIGNAL(GIFReg* r) +void GSState::GIFRegHandlerSIGNAL(const GIFReg* r) { m_regs->SIGLBLID.SIGID = (m_regs->SIGLBLID.SIGID & ~r->SIGNAL.IDMSK) | (r->SIGNAL.ID & r->SIGNAL.IDMSK); @@ -965,13 +979,13 @@ void GSState::GIFRegHandlerSIGNAL(GIFReg* r) if(!m_regs->IMR.SIGMSK && m_irq) m_irq(); } -void GSState::GIFRegHandlerFINISH(GIFReg* r) +void GSState::GIFRegHandlerFINISH(const GIFReg* r) { if(m_regs->CSR.wFINISH) m_regs->CSR.rFINISH = 1; if(!m_regs->IMR.FINISHMSK && m_irq) m_irq(); } -void GSState::GIFRegHandlerLABEL(GIFReg* r) +void GSState::GIFRegHandlerLABEL(const GIFReg* r) { m_regs->SIGLBLID.LBLID = (m_regs->SIGLBLID.LBLID & ~r->LABEL.IDMSK) | (r->LABEL.ID & r->LABEL.IDMSK); } @@ -1021,7 +1035,7 @@ void GSState::FlushWrite() // -void GSState::Write(uint8* mem, int len) +void GSState::Write(const uint8* mem, int len) { int w = m_env.TRXREG.RRW; int h = m_env.TRXREG.RRH; @@ -1405,16 +1419,16 @@ void GSState::ReadFIFO(uint8* mem, int size) } } -template void GSState::Transfer<0>(uint8* mem, uint32 size); -template void GSState::Transfer<1>(uint8* mem, uint32 size); -template void GSState::Transfer<2>(uint8* mem, uint32 size); -template void GSState::Transfer<3>(uint8* mem, uint32 size); +template void GSState::Transfer<0>(const uint8* mem, uint32 size); +template void GSState::Transfer<1>(const uint8* mem, uint32 size); +template void GSState::Transfer<2>(const uint8* mem, uint32 size); +template void GSState::Transfer<3>(const uint8* mem, uint32 size); -template void GSState::Transfer(uint8* mem, uint32 size) +template void GSState::Transfer(const uint8* mem, uint32 size) { GSPerfMonAutoTimer pmat(m_perfmon); - uint8* start = mem; + const uint8* start = mem; GIFPath& path = m_path[index]; @@ -1531,7 +1545,11 @@ template void GSState::Transfer(uint8* mem, uint32 size) Write(mem, len * 16); break; case 1: - Read(mem, len * 16); + // This can't happen; downloads can not be started or performed as part of + // a GIFtag operation. They're an entirely separate process that can only be + // done through the ReverseFIFO transfer (aka ReadFIFO). --air + ASSERT(false); + //Read(mem, len * 16); break; case 2: Move(); @@ -1555,13 +1573,13 @@ template void GSState::Transfer(uint8* mem, uint32 size) } } - /*if(index == 0) + if(index == 0) { if(path.tag.EOP && path.nloop == 0) { break; } - }*/ + } } if(m_dump && mem > start) diff --git a/plugins/GSdx/GSState.h b/plugins/GSdx/GSState.h index 00b7f003b6..51e28da939 100644 --- a/plugins/GSdx/GSState.h +++ b/plugins/GSdx/GSState.h @@ -38,72 +38,74 @@ class GSState : public GSAlignedClass<16> { - typedef void (GSState::*GIFPackedRegHandler)(GIFPackedReg* r); + typedef void (GSState::*GIFPackedRegHandler)(const GIFPackedReg* r); GIFPackedRegHandler m_fpGIFPackedRegHandlers[16]; - void GIFPackedRegHandlerNull(GIFPackedReg* r); - void GIFPackedRegHandlerPRIM(GIFPackedReg* r); - void GIFPackedRegHandlerRGBA(GIFPackedReg* r); - void GIFPackedRegHandlerSTQ(GIFPackedReg* r); - void GIFPackedRegHandlerUV(GIFPackedReg* r); - void GIFPackedRegHandlerXYZF2(GIFPackedReg* r); - void GIFPackedRegHandlerXYZ2(GIFPackedReg* r); - template void GIFPackedRegHandlerTEX0(GIFPackedReg* r); - template void GIFPackedRegHandlerCLAMP(GIFPackedReg* r); - void GIFPackedRegHandlerFOG(GIFPackedReg* r); - void GIFPackedRegHandlerXYZF3(GIFPackedReg* r); - void GIFPackedRegHandlerXYZ3(GIFPackedReg* r); - void GIFPackedRegHandlerA_D(GIFPackedReg* r); - void GIFPackedRegHandlerNOP(GIFPackedReg* r); + void GIFPackedRegHandlerNull(const GIFPackedReg* r); + void GIFPackedRegHandlerPRIM(const GIFPackedReg* r); + void GIFPackedRegHandlerRGBA(const GIFPackedReg* r); + void GIFPackedRegHandlerSTQ(const GIFPackedReg* r); + void GIFPackedRegHandlerUV(const GIFPackedReg* r); + void GIFPackedRegHandlerXYZF2(const GIFPackedReg* r); + void GIFPackedRegHandlerXYZ2(const GIFPackedReg* r); + template void GIFPackedRegHandlerTEX0(const GIFPackedReg* r); + template void GIFPackedRegHandlerCLAMP(const GIFPackedReg* r); + void GIFPackedRegHandlerFOG(const GIFPackedReg* r); + void GIFPackedRegHandlerXYZF3(const GIFPackedReg* r); + void GIFPackedRegHandlerXYZ3(const GIFPackedReg* r); + void GIFPackedRegHandlerA_D(const GIFPackedReg* r); + void GIFPackedRegHandlerNOP(const GIFPackedReg* r); - typedef void (GSState::*GIFRegHandler)(GIFReg* r); + typedef void (GSState::*GIFRegHandler)(const GIFReg* r); GIFRegHandler m_fpGIFRegHandlers[256]; - void GIFRegHandlerNull(GIFReg* r); - void GIFRegHandlerPRIM(GIFReg* r); - void GIFRegHandlerRGBAQ(GIFReg* r); - void GIFRegHandlerST(GIFReg* r); - void GIFRegHandlerUV(GIFReg* r); - void GIFRegHandlerXYZF2(GIFReg* r); - void GIFRegHandlerXYZ2(GIFReg* r); - template void GIFRegHandlerTEX0(GIFReg* r); - template void GIFRegHandlerCLAMP(GIFReg* r); - void GIFRegHandlerFOG(GIFReg* r); - void GIFRegHandlerXYZF3(GIFReg* r); - void GIFRegHandlerXYZ3(GIFReg* r); - void GIFRegHandlerNOP(GIFReg* r); - template void GIFRegHandlerTEX1(GIFReg* r); - template void GIFRegHandlerTEX2(GIFReg* r); - template void GIFRegHandlerXYOFFSET(GIFReg* r); - void GIFRegHandlerPRMODECONT(GIFReg* r); - void GIFRegHandlerPRMODE(GIFReg* r); - void GIFRegHandlerTEXCLUT(GIFReg* r); - void GIFRegHandlerSCANMSK(GIFReg* r); - template void GIFRegHandlerMIPTBP1(GIFReg* r); - template void GIFRegHandlerMIPTBP2(GIFReg* r); - void GIFRegHandlerTEXA(GIFReg* r); - void GIFRegHandlerFOGCOL(GIFReg* r); - void GIFRegHandlerTEXFLUSH(GIFReg* r); - template void GIFRegHandlerSCISSOR(GIFReg* r); - template void GIFRegHandlerALPHA(GIFReg* r); - void GIFRegHandlerDIMX(GIFReg* r); - void GIFRegHandlerDTHE(GIFReg* r); - void GIFRegHandlerCOLCLAMP(GIFReg* r); - template void GIFRegHandlerTEST(GIFReg* r); - void GIFRegHandlerPABE(GIFReg* r); - template void GIFRegHandlerFBA(GIFReg* r); - template void GIFRegHandlerFRAME(GIFReg* r); - template void GIFRegHandlerZBUF(GIFReg* r); - void GIFRegHandlerBITBLTBUF(GIFReg* r); - void GIFRegHandlerTRXPOS(GIFReg* r); - void GIFRegHandlerTRXREG(GIFReg* r); - void GIFRegHandlerTRXDIR(GIFReg* r); - void GIFRegHandlerHWREG(GIFReg* r); - void GIFRegHandlerSIGNAL(GIFReg* r); - void GIFRegHandlerFINISH(GIFReg* r); - void GIFRegHandlerLABEL(GIFReg* r); + void ApplyTEX0( uint i, GIFRegTEX0& TEX0 ); + + void GIFRegHandlerNull(const GIFReg* r); + void GIFRegHandlerPRIM(const GIFReg* r); + void GIFRegHandlerRGBAQ(const GIFReg* r); + void GIFRegHandlerST(const GIFReg* r); + void GIFRegHandlerUV(const GIFReg* r); + void GIFRegHandlerXYZF2(const GIFReg* r); + void GIFRegHandlerXYZ2(const GIFReg* r); + template void GIFRegHandlerTEX0(const GIFReg* r); + template void GIFRegHandlerCLAMP(const GIFReg* r); + void GIFRegHandlerFOG(const GIFReg* r); + void GIFRegHandlerXYZF3(const GIFReg* r); + void GIFRegHandlerXYZ3(const GIFReg* r); + void GIFRegHandlerNOP(const GIFReg* r); + template void GIFRegHandlerTEX1(const GIFReg* r); + template void GIFRegHandlerTEX2(const GIFReg* r); + template void GIFRegHandlerXYOFFSET(const GIFReg* r); + void GIFRegHandlerPRMODECONT(const GIFReg* r); + void GIFRegHandlerPRMODE(const GIFReg* r); + void GIFRegHandlerTEXCLUT(const GIFReg* r); + void GIFRegHandlerSCANMSK(const GIFReg* r); + template void GIFRegHandlerMIPTBP1(const GIFReg* r); + template void GIFRegHandlerMIPTBP2(const GIFReg* r); + void GIFRegHandlerTEXA(const GIFReg* r); + void GIFRegHandlerFOGCOL(const GIFReg* r); + void GIFRegHandlerTEXFLUSH(const GIFReg* r); + template void GIFRegHandlerSCISSOR(const GIFReg* r); + template void GIFRegHandlerALPHA(const GIFReg* r); + void GIFRegHandlerDIMX(const GIFReg* r); + void GIFRegHandlerDTHE(const GIFReg* r); + void GIFRegHandlerCOLCLAMP(const GIFReg* r); + template void GIFRegHandlerTEST(const GIFReg* r); + void GIFRegHandlerPABE(const GIFReg* r); + template void GIFRegHandlerFBA(const GIFReg* r); + template void GIFRegHandlerFRAME(const GIFReg* r); + template void GIFRegHandlerZBUF(const GIFReg* r); + void GIFRegHandlerBITBLTBUF(const GIFReg* r); + void GIFRegHandlerTRXPOS(const GIFReg* r); + void GIFRegHandlerTRXREG(const GIFReg* r); + void GIFRegHandlerTRXDIR(const GIFReg* r); + void GIFRegHandlerHWREG(const GIFReg* r); + void GIFRegHandlerSIGNAL(const GIFReg* r); + void GIFRegHandlerFINISH(const GIFReg* r); + void GIFRegHandlerLABEL(const GIFReg* r); int m_version; int m_sssize; @@ -237,13 +239,13 @@ public: virtual void InvalidateTextureCache() {} void Move(); - void Write(uint8* mem, int len); + void Write(const uint8* mem, int len); void Read(uint8* mem, int len); void SoftReset(uint32 mask); void WriteCSR(uint32 csr) {m_regs->CSR.u32[1] = csr;} void ReadFIFO(uint8* mem, int size); - template void Transfer(uint8* mem, uint32 size); + template void Transfer(const uint8* mem, uint32 size); int Freeze(GSFreezeData* fd, bool sizeonly); int Defrost(const GSFreezeData* fd); void GetLastTag(uint32* tag) {*tag = m_path3hack; m_path3hack = 0;} diff --git a/plugins/GSdx/GSdx.def b/plugins/GSdx/GSdx.def index 086cedfedc..8dfa08f709 100644 --- a/plugins/GSdx/GSdx.def +++ b/plugins/GSdx/GSdx.def @@ -18,7 +18,7 @@ EXPORTS GSreset GSwriteCSR GSgifSoftReset - GSgifTransfer + GSgifTransfer GSgifTransfer1 GSgifTransfer2 GSgifTransfer3 diff --git a/plugins/zzogl-pg/opengl/GS.h b/plugins/zzogl-pg/opengl/GS.h index 8ef2d0175b..2fab72c3b5 100644 --- a/plugins/zzogl-pg/opengl/GS.h +++ b/plugins/zzogl-pg/opengl/GS.h @@ -1010,19 +1010,19 @@ inline u32 ZZOglGet_fbmHighByte(u32 data) //-------------------------- tex0 comparison // Check if old and new tex0 registers have only clut difference -inline bool ZZOglAllExceptClutIsSame(u32* oldtex, u32* newtex) +inline bool ZZOglAllExceptClutIsSame(const u32* oldtex, const u32* newtex) { return ((oldtex[0] == newtex[0]) && ((oldtex[1] & 0x1f) == (newtex[1] & 0x1f))); } // Check if the CLUT registers are same, except CLD -inline bool ZZOglClutMinusCLDunchanged(u32* oldtex, u32* newtex) +inline bool ZZOglClutMinusCLDunchanged(const u32* oldtex, const u32* newtex) { return ((oldtex[1] & 0x1fffffe0) == (newtex[1] & 0x1fffffe0)); } // Check if CLUT storage mode is not changed (CSA, CSM and CSPM) -inline bool ZZOglClutStorageUnchanged(u32* oldtex, u32* newtex) +inline bool ZZOglClutStorageUnchanged(const u32* oldtex, const u32* newtex) { return ((oldtex[1] & 0x1ff10000) == (newtex[1] & 0x1ff10000)); } diff --git a/plugins/zzogl-pg/opengl/GifTransfer.cpp b/plugins/zzogl-pg/opengl/GifTransfer.cpp index 4939f53dd9..dff38b219a 100644 --- a/plugins/zzogl-pg/opengl/GifTransfer.cpp +++ b/plugins/zzogl-pg/opengl/GifTransfer.cpp @@ -41,7 +41,7 @@ void CALLBACK GSgetLastTag(u64* ptag) extern HANDLE g_hCurrentThread; #endif -__forceinline void gifTransferLog(int index, u32 *pMem, u32 size) +__forceinline void gifTransferLog(int index, const u32 *pMem, u32 size) { #ifdef DEBUG_TRANSFER @@ -65,7 +65,7 @@ __forceinline void gifTransferLog(int index, u32 *pMem, u32 size) extern int g_GSMultiThreaded; -template void _GSgifTransfer(u32 *pMem, u32 size) +template void _GSgifTransfer(const u32 *pMem, u32 size) { FUNCLOG @@ -174,7 +174,11 @@ template void _GSgifTransfer(u32 *pMem, u32 size) break; case 1: - ZeroGS::TransferLocalHost(pMem, len); + // This can't happen; downloads can not be started or performed as part of + // a GIFtag operation. They're an entirely separate process that can only be + // done through the ReverseFIFO transfer (aka ReadFIFO). --air + assert(0); + //ZeroGS::TransferLocalHost(pMem, len); break; case 2: @@ -253,7 +257,7 @@ void CALLBACK GSgifTransfer2(u32 *pMem, u32 size) //ZZLog::GS_Log("GSgifTransfer2 size = %lx (mode %d, gs.path2.tag.nloop = %d).", size, gs.path[1].mode, gs.path[1].tag.nloop); - _GSgifTransfer<1>(pMem, size); + _GSgifTransfer<1>(const_cast(pMem), size); } void CALLBACK GSgifTransfer3(u32 *pMem, u32 size) @@ -262,10 +266,10 @@ void CALLBACK GSgifTransfer3(u32 *pMem, u32 size) //ZZLog::GS_Log("GSgifTransfer3 size = %lx (mode %d, gs.path3.tag.nloop = %d).", size, gs.path[2].mode, gs.path[2].tag.nloop); - _GSgifTransfer<2>(pMem, size); + _GSgifTransfer<2>(const_cast(pMem), size); } -void CALLBACK GSgifTransfer(u32 *pMem, u32 size) +void CALLBACK GSgifTransfer(const u32 *pMem, u32 size) { FUNCLOG diff --git a/plugins/zzogl-pg/opengl/GifTransfer.h b/plugins/zzogl-pg/opengl/GifTransfer.h index a3decfa3a4..4326da4693 100644 --- a/plugins/zzogl-pg/opengl/GifTransfer.h +++ b/plugins/zzogl-pg/opengl/GifTransfer.h @@ -52,7 +52,7 @@ union GIFTag u64 REGS : 64; }; - void set(u32 *data) + void set(const u32 *data) { for (int i = 0; i <= 3; i++) { @@ -81,7 +81,7 @@ typedef struct u32 adonly; GIFTag tag; - void setTag(u32 *data) + void setTag(const u32 *data) { tag.set(data); @@ -124,9 +124,9 @@ typedef struct } pathInfo; -void _GSgifPacket(pathInfo *path, u32 *pMem); -void _GSgifRegList(pathInfo *path, u32 *pMem); -void _GSgifTransfer(pathInfo *path, u32 *pMem, u32 size); +extern void _GSgifPacket(pathInfo *path, const u32 *pMem); +extern void _GSgifRegList(pathInfo *path, const u32 *pMem); +extern void _GSgifTransfer(pathInfo *path, const u32 *pMem, u32 size); extern GIFRegHandler g_GIFPackedRegHandlers[]; extern GIFRegHandler g_GIFRegHandlers[]; diff --git a/plugins/zzogl-pg/opengl/Regs.cpp b/plugins/zzogl-pg/opengl/Regs.cpp index 3dd019242b..0c302429a8 100644 --- a/plugins/zzogl-pg/opengl/Regs.cpp +++ b/plugins/zzogl-pg/opengl/Regs.cpp @@ -88,22 +88,22 @@ inline bool NoHighlights(int i) return (!(conf.settings().xenosaga_spec) || !ZeroGS::vb[i].zbuf.zmsk || prim->iip) ; } -void __fastcall GIFPackedRegHandlerNull(u32* data) +void __gifCall GIFPackedRegHandlerNull(const u32* data) { FUNCLOG ZZLog::Debug_Log("Unexpected packed reg handler %8.8lx_%8.8lx %x.", data[0], data[1], data[2]); } // All these just call their non-packed equivalent. -void __fastcall GIFPackedRegHandlerPRIM(u32* data) { GIFRegHandlerPRIM(data); } -void __fastcall GIFPackedRegHandlerTEX0_1(u32* data) { GIFRegHandlerTEX0_1(data); } -void __fastcall GIFPackedRegHandlerTEX0_2(u32* data) { GIFRegHandlerTEX0_2(data); } -void __fastcall GIFPackedRegHandlerCLAMP_1(u32* data) { GIFRegHandlerCLAMP_1(data); } -void __fastcall GIFPackedRegHandlerCLAMP_2(u32* data) { GIFRegHandlerCLAMP_2(data); } -void __fastcall GIFPackedRegHandlerXYZF3(u32* data) { GIFRegHandlerXYZF3(data); } -void __fastcall GIFPackedRegHandlerXYZ3(u32* data) { GIFRegHandlerXYZ3(data); } +void __gifCall GIFPackedRegHandlerPRIM(const u32* data) { GIFRegHandlerPRIM(data); } +void __gifCall GIFPackedRegHandlerTEX0_1(const u32* data) { GIFRegHandlerTEX0_1(data); } +void __gifCall GIFPackedRegHandlerTEX0_2(const u32* data) { GIFRegHandlerTEX0_2(data); } +void __gifCall GIFPackedRegHandlerCLAMP_1(const u32* data) { GIFRegHandlerCLAMP_1(data); } +void __gifCall GIFPackedRegHandlerCLAMP_2(const u32* data) { GIFRegHandlerCLAMP_2(data); } +void __gifCall GIFPackedRegHandlerXYZF3(const u32* data) { GIFRegHandlerXYZF3(data); } +void __gifCall GIFPackedRegHandlerXYZ3(const u32* data) { GIFRegHandlerXYZ3(data); } -void __fastcall GIFPackedRegHandlerRGBA(u32* data) +void __gifCall GIFPackedRegHandlerRGBA(const u32* data) { FUNCLOG gs.rgba = (data[0] & 0xff) | @@ -114,7 +114,7 @@ void __fastcall GIFPackedRegHandlerRGBA(u32* data) gs.vertexregs.q = gs.q; } -void __fastcall GIFPackedRegHandlerSTQ(u32* data) +void __gifCall GIFPackedRegHandlerSTQ(const u32* data) { FUNCLOG *(u32*)&gs.vertexregs.s = data[0] & 0xffffff00; @@ -122,7 +122,7 @@ void __fastcall GIFPackedRegHandlerSTQ(u32* data) *(u32*)&gs.q = data[2]; } -void __fastcall GIFPackedRegHandlerUV(u32* data) +void __gifCall GIFPackedRegHandlerUV(const u32* data) { FUNCLOG gs.vertexregs.u = data[0] & 0x3fff; @@ -158,7 +158,7 @@ void __forceinline KICK_VERTEX3() } } -void __fastcall GIFPackedRegHandlerXYZF2(u32* data) +void __gifCall GIFPackedRegHandlerXYZF2(const u32* data) { FUNCLOG gs.vertexregs.x = (data[0] >> 0) & 0xffff; @@ -178,7 +178,7 @@ void __fastcall GIFPackedRegHandlerXYZF2(u32* data) } } -void __fastcall GIFPackedRegHandlerXYZ2(u32* data) +void __gifCall GIFPackedRegHandlerXYZ2(const u32* data) { FUNCLOG gs.vertexregs.x = (data[0] >> 0) & 0xffff; @@ -197,13 +197,13 @@ void __fastcall GIFPackedRegHandlerXYZ2(u32* data) } } -void __fastcall GIFPackedRegHandlerFOG(u32* data) +void __gifCall GIFPackedRegHandlerFOG(const u32* data) { FUNCLOG gs.vertexregs.f = (data[3] & 0xff0) >> 4; } -void __fastcall GIFPackedRegHandlerA_D(u32* data) +void __gifCall GIFPackedRegHandlerA_D(const u32* data) { FUNCLOG @@ -213,12 +213,12 @@ void __fastcall GIFPackedRegHandlerA_D(u32* data) GIFRegHandlerNull(data); } -void __fastcall GIFPackedRegHandlerNOP(u32* data) +void __gifCall GIFPackedRegHandlerNOP(const u32* data) { FUNCLOG } -void tex0Write(int i, u32 *data) +void tex0Write(int i, const u32 *data) { FUNCLOG u32 psm = ZZOglGet_psm_TexBitsFix(data[0]); @@ -251,7 +251,7 @@ void tex0Write(int i, u32 *data) } } -void tex2Write(int i, u32 *data) +void tex2Write(int i, const u32 *data) { FUNCLOG tex0Info& tex0 = ZeroGS::vb[i].tex0; @@ -297,7 +297,7 @@ void tex2Write(int i, u32 *data) if (PSMT_ISCLUT(tex0.psm)) ZeroGS::CluttingForFlushedTex(&tex0, data[1], i); } -__forceinline void frameWrite(int i, u32 *data) +__forceinline void frameWrite(int i, const u32 *data) { FUNCLOG frameInfo& gsfb = ZeroGS::vb[i].gsfb; @@ -322,7 +322,7 @@ __forceinline void frameWrite(int i, u32 *data) ZeroGS::vb[i].bNeedFrameCheck = 1; } -__forceinline void testWrite(int i, u32 *data) +__forceinline void testWrite(int i, const u32 *data) { FUNCLOG pixTest* test = &ZeroGS::vb[i].test; @@ -346,7 +346,7 @@ __forceinline void testWrite(int i, u32 *data) #ifndef __LINUX__ __forceinline #endif -void clampWrite(int i, u32 *data) +void clampWrite(int i, const u32 *data) { FUNCLOG clampInfo& clamp = ZeroGS::vb[i].clamp; @@ -367,7 +367,7 @@ void clampWrite(int i, u32 *data) } } -void __fastcall GIFRegHandlerNull(u32* data) +void __gifCall GIFRegHandlerNull(const u32* data) { FUNCLOG #ifdef _DEBUG @@ -383,7 +383,7 @@ void __fastcall GIFRegHandlerNull(u32* data) #endif } -void __fastcall GIFRegHandlerPRIM(u32 *data) +void __gifCall GIFRegHandlerPRIM(const u32 *data) { FUNCLOG @@ -403,7 +403,7 @@ void __fastcall GIFRegHandlerPRIM(u32 *data) ZeroGS::Prim(); } -void __fastcall GIFRegHandlerRGBAQ(u32* data) +void __gifCall GIFRegHandlerRGBAQ(const u32* data) { FUNCLOG gs.rgba = data[0]; @@ -411,7 +411,7 @@ void __fastcall GIFRegHandlerRGBAQ(u32* data) *(u32*)&gs.vertexregs.q = data[1]; } -void __fastcall GIFRegHandlerST(u32* data) +void __gifCall GIFRegHandlerST(const u32* data) { FUNCLOG *(u32*)&gs.vertexregs.s = data[0] & 0xffffff00; @@ -419,14 +419,14 @@ void __fastcall GIFRegHandlerST(u32* data) //*(u32*)&gs.q = data[2]; } -void __fastcall GIFRegHandlerUV(u32* data) +void __gifCall GIFRegHandlerUV(const u32* data) { FUNCLOG gs.vertexregs.u = (data[0]) & 0x3fff; gs.vertexregs.v = (data[0] >> 16) & 0x3fff; } -void __fastcall GIFRegHandlerXYZF2(u32* data) +void __gifCall GIFRegHandlerXYZF2(const u32* data) { FUNCLOG gs.vertexregs.x = (data[0]) & 0xffff; @@ -439,7 +439,7 @@ void __fastcall GIFRegHandlerXYZF2(u32* data) KICK_VERTEX2(); } -void __fastcall GIFRegHandlerXYZ2(u32* data) +void __gifCall GIFRegHandlerXYZ2(const u32* data) { FUNCLOG gs.vertexregs.x = (data[0]) & 0xffff; @@ -451,7 +451,7 @@ void __fastcall GIFRegHandlerXYZ2(u32* data) KICK_VERTEX2(); } -void __fastcall GIFRegHandlerTEX0_1(u32* data) +void __gifCall GIFRegHandlerTEX0_1(const u32* data) { FUNCLOG @@ -460,7 +460,7 @@ void __fastcall GIFRegHandlerTEX0_1(u32* data) tex0Write(0, data); } -void __fastcall GIFRegHandlerTEX0_2(u32* data) +void __gifCall GIFRegHandlerTEX0_2(const u32* data) { FUNCLOG @@ -469,7 +469,7 @@ void __fastcall GIFRegHandlerTEX0_2(u32* data) tex0Write(1, data); } -void __fastcall GIFRegHandlerCLAMP_1(u32* data) +void __gifCall GIFRegHandlerCLAMP_1(const u32* data) { FUNCLOG @@ -478,7 +478,7 @@ void __fastcall GIFRegHandlerCLAMP_1(u32* data) clampWrite(0, data); } -void __fastcall GIFRegHandlerCLAMP_2(u32* data) +void __gifCall GIFRegHandlerCLAMP_2(const u32* data) { FUNCLOG @@ -487,14 +487,14 @@ void __fastcall GIFRegHandlerCLAMP_2(u32* data) clampWrite(1, data); } -void __fastcall GIFRegHandlerFOG(u32* data) +void __gifCall GIFRegHandlerFOG(const u32* data) { FUNCLOG //gs.gsvertex[gs.primIndex].f = (data[1] >> 24); // shift to upper bits gs.vertexregs.f = data[1] >> 24; } -void __fastcall GIFRegHandlerXYZF3(u32* data) +void __gifCall GIFRegHandlerXYZF3(const u32* data) { FUNCLOG gs.vertexregs.x = (data[0]) & 0xffff; @@ -507,7 +507,7 @@ void __fastcall GIFRegHandlerXYZF3(u32* data) KICK_VERTEX3(); } -void __fastcall GIFRegHandlerXYZ3(u32* data) +void __gifCall GIFRegHandlerXYZ3(const u32* data) { FUNCLOG gs.vertexregs.x = (data[0]) & 0xffff; @@ -519,12 +519,12 @@ void __fastcall GIFRegHandlerXYZ3(u32* data) KICK_VERTEX3(); } -void __fastcall GIFRegHandlerNOP(u32* data) +void __gifCall GIFRegHandlerNOP(const u32* data) { FUNCLOG } -void tex1Write(int i, u32* data) +void tex1Write(int i, const u32* data) { FUNCLOG tex1Info& tex1 = ZeroGS::vb[i].tex1; @@ -545,7 +545,7 @@ void tex1Write(int i, u32* data) tex1.k = (data[1] >> 4) & 0xff; } -void __fastcall GIFRegHandlerTEX1_1(u32* data) +void __gifCall GIFRegHandlerTEX1_1(const u32* data) { FUNCLOG @@ -554,7 +554,7 @@ void __fastcall GIFRegHandlerTEX1_1(u32* data) tex1Write(0, data); } -void __fastcall GIFRegHandlerTEX1_2(u32* data) +void __gifCall GIFRegHandlerTEX1_2(const u32* data) { FUNCLOG @@ -563,19 +563,19 @@ void __fastcall GIFRegHandlerTEX1_2(u32* data) tex1Write(1, data); } -void __fastcall GIFRegHandlerTEX2_1(u32* data) +void __gifCall GIFRegHandlerTEX2_1(const u32* data) { FUNCLOG tex2Write(0, data); } -void __fastcall GIFRegHandlerTEX2_2(u32* data) +void __gifCall GIFRegHandlerTEX2_2(const u32* data) { FUNCLOG tex2Write(1, data); } -void __fastcall GIFRegHandlerXYOFFSET_1(u32* data) +void __gifCall GIFRegHandlerXYOFFSET_1(const u32* data) { FUNCLOG // eliminator low 4 bits for now @@ -588,7 +588,7 @@ void __fastcall GIFRegHandlerXYOFFSET_1(u32* data) // } } -void __fastcall GIFRegHandlerXYOFFSET_2(u32* data) +void __gifCall GIFRegHandlerXYOFFSET_2(const u32* data) { FUNCLOG ZeroGS::vb[1].offset.x = (data[0]) & 0xffff; @@ -600,7 +600,7 @@ void __fastcall GIFRegHandlerXYOFFSET_2(u32* data) // } } -void __fastcall GIFRegHandlerPRMODECONT(u32* data) +void __gifCall GIFRegHandlerPRMODECONT(const u32* data) { FUNCLOG gs.prac = data[0] & 0x1; @@ -609,7 +609,7 @@ void __fastcall GIFRegHandlerPRMODECONT(u32* data) ZeroGS::Prim(); } -void __fastcall GIFRegHandlerPRMODE(u32* data) +void __gifCall GIFRegHandlerPRMODE(const u32* data) { FUNCLOG gs._prim[0]._val = (data[0] >> 3) & 0xff; @@ -617,7 +617,7 @@ void __fastcall GIFRegHandlerPRMODE(u32* data) if (gs.prac == 0) ZeroGS::Prim(); } -void __fastcall GIFRegHandlerTEXCLUT(u32* data) +void __gifCall GIFRegHandlerTEXCLUT(const u32* data) { FUNCLOG @@ -629,7 +629,7 @@ void __fastcall GIFRegHandlerTEXCLUT(u32* data) gs.clut.cov = (data[0] >> 12) & 0x3ff; } -void __fastcall GIFRegHandlerSCANMSK(u32* data) +void __gifCall GIFRegHandlerSCANMSK(const u32* data) { FUNCLOG // ZeroGS::FlushBoth(); @@ -639,7 +639,7 @@ void __fastcall GIFRegHandlerSCANMSK(u32* data) gs.smask = data[0] & 0x3; } -void __fastcall GIFRegHandlerMIPTBP1_1(u32* data) +void __gifCall GIFRegHandlerMIPTBP1_1(const u32* data) { FUNCLOG miptbpInfo& miptbp0 = ZeroGS::vb[0].miptbp0; @@ -651,7 +651,7 @@ void __fastcall GIFRegHandlerMIPTBP1_1(u32* data) miptbp0.tbw[2] = (data[1] >> 22) & 0x3f; } -void __fastcall GIFRegHandlerMIPTBP1_2(u32* data) +void __gifCall GIFRegHandlerMIPTBP1_2(const u32* data) { FUNCLOG miptbpInfo& miptbp0 = ZeroGS::vb[1].miptbp0; @@ -663,7 +663,7 @@ void __fastcall GIFRegHandlerMIPTBP1_2(u32* data) miptbp0.tbw[2] = (data[1] >> 22) & 0x3f; } -void __fastcall GIFRegHandlerMIPTBP2_1(u32* data) +void __gifCall GIFRegHandlerMIPTBP2_1(const u32* data) { FUNCLOG miptbpInfo& miptbp1 = ZeroGS::vb[0].miptbp1; @@ -675,7 +675,7 @@ void __fastcall GIFRegHandlerMIPTBP2_1(u32* data) miptbp1.tbw[2] = (data[1] >> 22) & 0x3f; } -void __fastcall GIFRegHandlerMIPTBP2_2(u32* data) +void __gifCall GIFRegHandlerMIPTBP2_2(const u32* data) { FUNCLOG miptbpInfo& miptbp1 = ZeroGS::vb[1].miptbp1; @@ -687,7 +687,7 @@ void __fastcall GIFRegHandlerMIPTBP2_2(u32* data) miptbp1.tbw[2] = (data[1] >> 22) & 0x3f; } -void __fastcall GIFRegHandlerTEXA(u32* data) +void __gifCall GIFRegHandlerTEXA(const u32* data) { FUNCLOG texaInfo newinfo; @@ -709,19 +709,19 @@ void __fastcall GIFRegHandlerTEXA(u32* data) } } -void __fastcall GIFRegHandlerFOGCOL(u32* data) +void __gifCall GIFRegHandlerFOGCOL(const u32* data) { FUNCLOG ZeroGS::SetFogColor(data[0]&0xffffff); } -void __fastcall GIFRegHandlerTEXFLUSH(u32* data) +void __gifCall GIFRegHandlerTEXFLUSH(const u32* data) { FUNCLOG ZeroGS::SetTexFlush(); } -void __fastcall GIFRegHandlerSCISSOR_1(u32* data) +void __gifCall GIFRegHandlerSCISSOR_1(const u32* data) { FUNCLOG Rect2& scissor = ZeroGS::vb[0].scissor; @@ -742,7 +742,7 @@ void __fastcall GIFRegHandlerSCISSOR_1(u32* data) } } -void __fastcall GIFRegHandlerSCISSOR_2(u32* data) +void __gifCall GIFRegHandlerSCISSOR_2(const u32* data) { FUNCLOG Rect2& scissor = ZeroGS::vb[1].scissor; @@ -765,7 +765,7 @@ void __fastcall GIFRegHandlerSCISSOR_2(u32* data) } } -void __fastcall GIFRegHandlerALPHA_1(u32* data) +void __gifCall GIFRegHandlerALPHA_1(const u32* data) { FUNCLOG alphaInfo newalpha; @@ -785,7 +785,7 @@ void __fastcall GIFRegHandlerALPHA_1(u32* data) } } -void __fastcall GIFRegHandlerALPHA_2(u32* data) +void __gifCall GIFRegHandlerALPHA_2(const u32* data) { FUNCLOG alphaInfo newalpha; @@ -805,36 +805,36 @@ void __fastcall GIFRegHandlerALPHA_2(u32* data) } } -void __fastcall GIFRegHandlerDIMX(u32* data) +void __gifCall GIFRegHandlerDIMX(const u32* data) { FUNCLOG } -void __fastcall GIFRegHandlerDTHE(u32* data) +void __gifCall GIFRegHandlerDTHE(const u32* data) { FUNCLOG gs.dthe = data[0] & 0x1; } -void __fastcall GIFRegHandlerCOLCLAMP(u32* data) +void __gifCall GIFRegHandlerCOLCLAMP(const u32* data) { FUNCLOG gs.colclamp = data[0] & 0x1; } -void __fastcall GIFRegHandlerTEST_1(u32* data) +void __gifCall GIFRegHandlerTEST_1(const u32* data) { FUNCLOG testWrite(0, data); } -void __fastcall GIFRegHandlerTEST_2(u32* data) +void __gifCall GIFRegHandlerTEST_2(const u32* data) { FUNCLOG testWrite(1, data); } -void __fastcall GIFRegHandlerPABE(u32* data) +void __gifCall GIFRegHandlerPABE(const u32* data) { FUNCLOG //ZeroGS::SetAlphaChanged(0, GPUREG_PABE); @@ -844,7 +844,7 @@ void __fastcall GIFRegHandlerPABE(u32* data) gs.pabe = *data & 0x1; } -void __fastcall GIFRegHandlerFBA_1(u32* data) +void __gifCall GIFRegHandlerFBA_1(const u32* data) { FUNCLOG @@ -852,7 +852,7 @@ void __fastcall GIFRegHandlerFBA_1(u32* data) ZeroGS::vb[0].fba.fba = *data & 0x1; } -void __fastcall GIFRegHandlerFBA_2(u32* data) +void __gifCall GIFRegHandlerFBA_2(const u32* data) { FUNCLOG @@ -861,19 +861,19 @@ void __fastcall GIFRegHandlerFBA_2(u32* data) ZeroGS::vb[1].fba.fba = *data & 0x1; } -void __fastcall GIFRegHandlerFRAME_1(u32* data) +void __gifCall GIFRegHandlerFRAME_1(const u32* data) { FUNCLOG frameWrite(0, data); } -void __fastcall GIFRegHandlerFRAME_2(u32* data) +void __gifCall GIFRegHandlerFRAME_2(const u32* data) { FUNCLOG frameWrite(1, data); } -void __fastcall GIFRegHandlerZBUF_1(u32* data) +void __gifCall GIFRegHandlerZBUF_1(const u32* data) { FUNCLOG zbufInfo& zbuf = ZeroGS::vb[0].zbuf; @@ -903,7 +903,7 @@ void __fastcall GIFRegHandlerZBUF_1(u32* data) ZeroGS::vb[0].bNeedZCheck = 1; } -void __fastcall GIFRegHandlerZBUF_2(u32* data) +void __gifCall GIFRegHandlerZBUF_2(const u32* data) { FUNCLOG zbufInfo& zbuf = ZeroGS::vb[1].zbuf; @@ -934,7 +934,7 @@ void __fastcall GIFRegHandlerZBUF_2(u32* data) if (zbuf.psm > 0x31) ZeroGS::vb[1].zprimmask = 0xffff; } -void __fastcall GIFRegHandlerBITBLTBUF(u32* data) +void __gifCall GIFRegHandlerBITBLTBUF(const u32* data) { FUNCLOG gs.srcbufnew.bp = ((data[0]) & 0x3fff); // * 64; @@ -947,7 +947,7 @@ void __fastcall GIFRegHandlerBITBLTBUF(u32* data) if (gs.dstbufnew.bw == 0) gs.dstbufnew.bw = 64; } -void __fastcall GIFRegHandlerTRXPOS(u32* data) +void __gifCall GIFRegHandlerTRXPOS(const u32* data) { FUNCLOG @@ -958,14 +958,14 @@ void __fastcall GIFRegHandlerTRXPOS(u32* data) gs.trxposnew.dir = (data[1] >> 27) & 0x3; } -void __fastcall GIFRegHandlerTRXREG(u32* data) +void __gifCall GIFRegHandlerTRXREG(const u32* data) { FUNCLOG gs.imageWtemp = data[0] & 0xfff; gs.imageHtemp = data[1] & 0xfff; } -void __fastcall GIFRegHandlerTRXDIR(u32* data) +void __gifCall GIFRegHandlerTRXDIR(const u32* data) { FUNCLOG // terminate any previous transfers @@ -1023,7 +1023,7 @@ void __fastcall GIFRegHandlerTRXDIR(u32* data) } } -void __fastcall GIFRegHandlerHWREG(u32* data) +void __gifCall GIFRegHandlerHWREG(const u32* data) { FUNCLOG @@ -1042,7 +1042,7 @@ void __fastcall GIFRegHandlerHWREG(u32* data) extern int g_GSMultiThreaded; -void __fastcall GIFRegHandlerSIGNAL(u32* data) +void __gifCall GIFRegHandlerSIGNAL(const u32* data) { FUNCLOG @@ -1064,7 +1064,7 @@ void __fastcall GIFRegHandlerSIGNAL(u32* data) } } -void __fastcall GIFRegHandlerFINISH(u32* data) +void __gifCall GIFRegHandlerFINISH(const u32* data) { FUNCLOG @@ -1087,7 +1087,7 @@ void __fastcall GIFRegHandlerFINISH(u32* data) } } -void __fastcall GIFRegHandlerLABEL(u32* data) +void __gifCall GIFRegHandlerLABEL(const u32* data) { FUNCLOG diff --git a/plugins/zzogl-pg/opengl/Regs.h b/plugins/zzogl-pg/opengl/Regs.h index 839c789660..4cb988b20b 100644 --- a/plugins/zzogl-pg/opengl/Regs.h +++ b/plugins/zzogl-pg/opengl/Regs.h @@ -101,83 +101,87 @@ enum GIF_A_D_REG GIF_A_D_REG_LABEL = 0x62, }; -typedef void (__fastcall *GIFRegHandler)(u32* data); +// In case we want to change to/from __fastcall for GIF register handlers: +#define __gifCall __fastcall -void __fastcall GIFPackedRegHandlerNull(u32* data); -void __fastcall GIFPackedRegHandlerRGBA(u32* data); -void __fastcall GIFPackedRegHandlerSTQ(u32* data); -void __fastcall GIFPackedRegHandlerUV(u32* data); -void __fastcall GIFPackedRegHandlerXYZF2(u32* data); -void __fastcall GIFPackedRegHandlerXYZ2(u32* data); -void __fastcall GIFPackedRegHandlerFOG(u32* data); -void __fastcall GIFPackedRegHandlerA_D(u32* data); -void __fastcall GIFPackedRegHandlerNOP(u32* data); +typedef void __gifCall FnType_GIFRegHandler(const u32* data); +typedef FnType_GIFRegHandler* GIFRegHandler; + +extern FnType_GIFRegHandler GIFPackedRegHandlerNull; +extern FnType_GIFRegHandler GIFPackedRegHandlerRGBA; +extern FnType_GIFRegHandler GIFPackedRegHandlerSTQ; +extern FnType_GIFRegHandler GIFPackedRegHandlerUV; +extern FnType_GIFRegHandler GIFPackedRegHandlerXYZF2; +extern FnType_GIFRegHandler GIFPackedRegHandlerXYZ2; +extern FnType_GIFRegHandler GIFPackedRegHandlerFOG; +extern FnType_GIFRegHandler GIFPackedRegHandlerA_D; +extern FnType_GIFRegHandler GIFPackedRegHandlerNOP; // These are unimplemented, and fall back on the non-packed versions. -void __fastcall GIFPackedRegHandlerPRIM(u32* data); -void __fastcall GIFPackedRegHandlerTEX0_1(u32* data); -void __fastcall GIFPackedRegHandlerTEX0_2(u32* data); -void __fastcall GIFPackedRegHandlerCLAMP_1(u32* data); -void __fastcall GIFPackedRegHandlerCLAMP_2(u32* data); -void __fastcall GIFPackedRegHandlerXYZF3(u32* data); -void __fastcall GIFPackedRegHandlerXYZ3(u32* data); +extern FnType_GIFRegHandler GIFPackedRegHandlerPRIM; +extern FnType_GIFRegHandler GIFPackedRegHandlerTEX0_1; +extern FnType_GIFRegHandler GIFPackedRegHandlerTEX0_2; +extern FnType_GIFRegHandler GIFPackedRegHandlerCLAMP_1; +extern FnType_GIFRegHandler GIFPackedRegHandlerCLAMP_2; +extern FnType_GIFRegHandler GIFPackedRegHandlerXYZF3; +extern FnType_GIFRegHandler GIFPackedRegHandlerXYZ3; -void __fastcall GIFRegHandlerNull(u32* data); -void __fastcall GIFRegHandlerPRIM(u32* data); -void __fastcall GIFRegHandlerRGBAQ(u32* data); -void __fastcall GIFRegHandlerST(u32* data); -void __fastcall GIFRegHandlerUV(u32* data); -void __fastcall GIFRegHandlerXYZF2(u32* data); -void __fastcall GIFRegHandlerXYZ2(u32* data); -void __fastcall GIFRegHandlerTEX0_1(u32* data); -void __fastcall GIFRegHandlerTEX0_2(u32* data); -void __fastcall GIFRegHandlerCLAMP_1(u32* data); -void __fastcall GIFRegHandlerCLAMP_2(u32* data); -void __fastcall GIFRegHandlerFOG(u32* data); -void __fastcall GIFRegHandlerXYZF3(u32* data); -void __fastcall GIFRegHandlerXYZ3(u32* data); -void __fastcall GIFRegHandlerNOP(u32* data); -void __fastcall GIFRegHandlerTEX1_1(u32* data); -void __fastcall GIFRegHandlerTEX1_2(u32* data); -void __fastcall GIFRegHandlerTEX2_1(u32* data); -void __fastcall GIFRegHandlerTEX2_2(u32* data); -void __fastcall GIFRegHandlerXYOFFSET_1(u32* data); -void __fastcall GIFRegHandlerXYOFFSET_2(u32* data); -void __fastcall GIFRegHandlerPRMODECONT(u32* data); -void __fastcall GIFRegHandlerPRMODE(u32* data); -void __fastcall GIFRegHandlerTEXCLUT(u32* data); -void __fastcall GIFRegHandlerSCANMSK(u32* data); -void __fastcall GIFRegHandlerMIPTBP1_1(u32* data); -void __fastcall GIFRegHandlerMIPTBP1_2(u32* data); -void __fastcall GIFRegHandlerMIPTBP2_1(u32* data); -void __fastcall GIFRegHandlerMIPTBP2_2(u32* data); -void __fastcall GIFRegHandlerTEXA(u32* data); -void __fastcall GIFRegHandlerFOGCOL(u32* data); -void __fastcall GIFRegHandlerTEXFLUSH(u32* data); -void __fastcall GIFRegHandlerSCISSOR_1(u32* data); -void __fastcall GIFRegHandlerSCISSOR_2(u32* data); -void __fastcall GIFRegHandlerALPHA_1(u32* data); -void __fastcall GIFRegHandlerALPHA_2(u32* data); -void __fastcall GIFRegHandlerDIMX(u32* data); -void __fastcall GIFRegHandlerDTHE(u32* data); -void __fastcall GIFRegHandlerCOLCLAMP(u32* data); -void __fastcall GIFRegHandlerTEST_1(u32* data); -void __fastcall GIFRegHandlerTEST_2(u32* data); -void __fastcall GIFRegHandlerPABE(u32* data); -void __fastcall GIFRegHandlerFBA_1(u32* data); -void __fastcall GIFRegHandlerFBA_2(u32* data); -void __fastcall GIFRegHandlerFRAME_1(u32* data); -void __fastcall GIFRegHandlerFRAME_2(u32* data); -void __fastcall GIFRegHandlerZBUF_1(u32* data); -void __fastcall GIFRegHandlerZBUF_2(u32* data); -void __fastcall GIFRegHandlerBITBLTBUF(u32* data); -void __fastcall GIFRegHandlerTRXPOS(u32* data); -void __fastcall GIFRegHandlerTRXREG(u32* data); -void __fastcall GIFRegHandlerTRXDIR(u32* data); -void __fastcall GIFRegHandlerHWREG(u32* data); -void __fastcall GIFRegHandlerSIGNAL(u32* data); -void __fastcall GIFRegHandlerFINISH(u32* data); -void __fastcall GIFRegHandlerLABEL(u32* data); +extern FnType_GIFRegHandler GIFRegHandlerNull; +extern FnType_GIFRegHandler GIFRegHandlerPRIM; +extern FnType_GIFRegHandler GIFRegHandlerRGBAQ; +extern FnType_GIFRegHandler GIFRegHandlerST; +extern FnType_GIFRegHandler GIFRegHandlerUV; +extern FnType_GIFRegHandler GIFRegHandlerXYZF2; +extern FnType_GIFRegHandler GIFRegHandlerXYZ2; +extern FnType_GIFRegHandler GIFRegHandlerTEX0_1; +extern FnType_GIFRegHandler GIFRegHandlerTEX0_2; +extern FnType_GIFRegHandler GIFRegHandlerCLAMP_1; +extern FnType_GIFRegHandler GIFRegHandlerCLAMP_2; +extern FnType_GIFRegHandler GIFRegHandlerFOG; +extern FnType_GIFRegHandler GIFRegHandlerXYZF3; +extern FnType_GIFRegHandler GIFRegHandlerXYZ3; +extern FnType_GIFRegHandler GIFRegHandlerNOP; +extern FnType_GIFRegHandler GIFRegHandlerTEX1_1; +extern FnType_GIFRegHandler GIFRegHandlerTEX1_2; +extern FnType_GIFRegHandler GIFRegHandlerTEX2_1; +extern FnType_GIFRegHandler GIFRegHandlerTEX2_2; +extern FnType_GIFRegHandler GIFRegHandlerXYOFFSET_1; +extern FnType_GIFRegHandler GIFRegHandlerXYOFFSET_2; +extern FnType_GIFRegHandler GIFRegHandlerPRMODECONT; +extern FnType_GIFRegHandler GIFRegHandlerPRMODE; +extern FnType_GIFRegHandler GIFRegHandlerTEXCLUT; +extern FnType_GIFRegHandler GIFRegHandlerSCANMSK; +extern FnType_GIFRegHandler GIFRegHandlerMIPTBP1_1; +extern FnType_GIFRegHandler GIFRegHandlerMIPTBP1_2; +extern FnType_GIFRegHandler GIFRegHandlerMIPTBP2_1; +extern FnType_GIFRegHandler GIFRegHandlerMIPTBP2_2; +extern FnType_GIFRegHandler GIFRegHandlerTEXA; +extern FnType_GIFRegHandler GIFRegHandlerFOGCOL; +extern FnType_GIFRegHandler GIFRegHandlerTEXFLUSH; +extern FnType_GIFRegHandler GIFRegHandlerSCISSOR_1; +extern FnType_GIFRegHandler GIFRegHandlerSCISSOR_2; +extern FnType_GIFRegHandler GIFRegHandlerALPHA_1; +extern FnType_GIFRegHandler GIFRegHandlerALPHA_2; +extern FnType_GIFRegHandler GIFRegHandlerDIMX; +extern FnType_GIFRegHandler GIFRegHandlerDTHE; +extern FnType_GIFRegHandler GIFRegHandlerCOLCLAMP; +extern FnType_GIFRegHandler GIFRegHandlerTEST_1; +extern FnType_GIFRegHandler GIFRegHandlerTEST_2; +extern FnType_GIFRegHandler GIFRegHandlerPABE; +extern FnType_GIFRegHandler GIFRegHandlerFBA_1; +extern FnType_GIFRegHandler GIFRegHandlerFBA_2; +extern FnType_GIFRegHandler GIFRegHandlerFRAME_1; +extern FnType_GIFRegHandler GIFRegHandlerFRAME_2; +extern FnType_GIFRegHandler GIFRegHandlerZBUF_1; +extern FnType_GIFRegHandler GIFRegHandlerZBUF_2; +extern FnType_GIFRegHandler GIFRegHandlerBITBLTBUF; +extern FnType_GIFRegHandler GIFRegHandlerTRXPOS; +extern FnType_GIFRegHandler GIFRegHandlerTRXREG; +extern FnType_GIFRegHandler GIFRegHandlerTRXDIR; +extern FnType_GIFRegHandler GIFRegHandlerHWREG; +extern FnType_GIFRegHandler GIFRegHandlerSIGNAL; +extern FnType_GIFRegHandler GIFRegHandlerFINISH; +extern FnType_GIFRegHandler GIFRegHandlerLABEL; // GifReg & GifPackedReg structs from GSdx, slightly modified