diff --git a/include/ps2s/core.h b/include/ps2s/core.h index 3e3b042..59efa4e 100644 --- a/include/ps2s/core.h +++ b/include/ps2s/core.h @@ -21,7 +21,7 @@ namespace Core { */ namespace MemMappings { - static const tU32 Normal = 0x00000000, + static const uint32_t Normal = 0x00000000, Uncached = 0x20000000, UncachedAccl = 0x30000000, @@ -36,19 +36,19 @@ namespace MemMappings { template inline ptrType MakePtrNormal(ptrType ptr) { - return reinterpret_cast((tU32)ptr & 0x0fffffff); + return reinterpret_cast((uint32_t)ptr & 0x0fffffff); } template inline ptrType MakePtrUncached(ptrType ptr) { - return reinterpret_cast((tU32)MakePtrNormal(ptr) | MemMappings::Uncached); + return reinterpret_cast((uint32_t)MakePtrNormal(ptr) | MemMappings::Uncached); } template inline ptrType MakePtrUncachedAccl(ptrType ptr) { - return reinterpret_cast((tU32)MakePtrNormal(ptr) | MemMappings::UncachedAccl); + return reinterpret_cast((uint32_t)MakePtrNormal(ptr) | MemMappings::UncachedAccl); } /******************************************** @@ -70,24 +70,24 @@ inline void Delete16(void* p) // cop0 counter inline void ZeroCount(void); -inline tU32 GetCount(void); +inline uint32_t GetCount(void); // fpu -inline tU32 FToI4(float flp); +inline uint32_t FToI4(float flp); // cop0 performance counter -static const tU32 COP0_NUM_PERF_COUNTERS = 2; -static const tU32 COP0_NUM_PERF_EVENTS = 17; +static const uint32_t COP0_NUM_PERF_COUNTERS = 2; +static const uint32_t COP0_NUM_PERF_EVENTS = 17; -void SetupPerfCounters(tU32 evt_0, tU32 evt_1); // set up,also zero + halt +void SetupPerfCounters(uint32_t evt_0, uint32_t evt_1); // set up,also zero + halt inline void HaltPerfCounters(); // stop both counters inline void ZeroStartPerfCounters(); // clear and start both counters -inline tU32 ReadPerfCounter0(); // read counter 0 -inline tU32 ReadPerfCounter1(); // read counter 1 +inline uint32_t ReadPerfCounter0(); // read counter 0 +inline uint32_t ReadPerfCounter1(); // read counter 1 // names of the events for people @@ -106,10 +106,10 @@ Core::ZeroCount(void) "sync.p "); } -inline tU32 +inline uint32_t Core::GetCount(void) { - tU32 ret; + uint32_t ret; asm __volatile__("mfc0 %0, $9 \n" "sync.p " @@ -118,10 +118,10 @@ Core::GetCount(void) return ret; } -inline tU32 +inline uint32_t Core::FToI4(float flp) { - tU32 fip; + uint32_t fip; asm __volatile__("qmtc2 %1, $vf1 \n" "vftoi4 $vf1, $vf1 \n" @@ -154,18 +154,18 @@ inline void Core::ZeroStartPerfCounters() : "v0"); }; -inline tU32 Core::ReadPerfCounter0() +inline uint32_t Core::ReadPerfCounter0() { - tU32 ret; + uint32_t ret; asm __volatile__(" mfpc %0,0 \n" " sync.p " : "=r"(ret)); return ret; } -inline tU32 Core::ReadPerfCounter1() +inline uint32_t Core::ReadPerfCounter1() { - tU32 ret; + uint32_t ret; asm __volatile__(" mfpc %0,1 \n" " sync.p " : "=r"(ret)); diff --git a/include/ps2s/displayenv.h b/include/ps2s/displayenv.h index c1b1641..7e73371 100644 --- a/include/ps2s/displayenv.h +++ b/include/ps2s/displayenv.h @@ -110,14 +110,14 @@ class CDisplayEnv { inline void BlendRC1WithBG(void) { gsrPMode.SLBG = 1; } inline void BlendRC1WithRC2(void) { gsrPMode.SLBG = 0; } inline void BlendUsingRC1Alpha(void) { gsrPMode.MMOD = 0; } - inline void BlendUsingConstAlpha(tU8 alpha) + inline void BlendUsingConstAlpha(uint8_t alpha) { gsrPMode.MMOD = 1; gsrPMode.ALP = alpha; } void DontBlend(void); - inline void SetBGColor(tU8 r, tU8 g, tU8 b) + inline void SetBGColor(uint8_t r, uint8_t g, uint8_t b) { gsrBGColor.R = r; gsrBGColor.G = g; diff --git a/include/ps2s/dmac.h b/include/ps2s/dmac.h index 43d622d..9d686b0 100644 --- a/include/ps2s/dmac.h +++ b/include/ps2s/dmac.h @@ -28,15 +28,15 @@ typedef struct tD_CHCR_t { } tD_CHCR; typedef struct tSourceChainTag_t { - tU64 QWC : 16; - tU64 pad : 10; - tU64 PCE : 2; - tU64 ID : 3; - tU64 IRQ : 1; - tU64 ADDR : 31; - tU64 SPR : 1; - tU32 opt1; - tU32 opt2; + uint64_t QWC : 16; + uint64_t pad : 10; + uint64_t PCE : 2; + uint64_t ID : 3; + uint64_t IRQ : 1; + uint64_t ADDR : 31; + uint64_t SPR : 1; + uint32_t opt1; + uint32_t opt2; } __attribute__((packed,aligned(16))) tSourceChainTag; typedef tSourceChainTag tDmaTag; diff --git a/include/ps2s/drawenv.h b/include/ps2s/drawenv.h index d97312c..8b4d4ba 100644 --- a/include/ps2s/drawenv.h +++ b/include/ps2s/drawenv.h @@ -99,7 +99,7 @@ class CDrawEnv { public: CDrawEnv(GS::tContext context); CDrawEnv(const CDrawEnv& rhs); - CDrawEnv(GS::tContext context, tU32 fbW, tU32 fbH, tU32 fbWordAddr, tU32 zbufWordAddr = NULL); + CDrawEnv(GS::tContext context, uint32_t fbW, uint32_t fbH, uint32_t fbWordAddr, uint32_t zbufWordAddr = NULL); void operator=(const CDrawEnv& otherDE); @@ -107,14 +107,14 @@ class CDrawEnv { inline void EnableAlphaTest(void) { gsrTest.atest_enable = 1; } inline void DisableAlphaTest(void) { gsrTest.atest_enable = 0; } - inline void SetAlphaTestPassMode(tAlphaTestPassMode mode) { gsrTest.atest_method = (tU64)mode; } - inline void SetAlphaTestFailAction(tAlphaTestFailAction action) { gsrTest.atest_fail_method = (tU64)action; } - inline void SetAlphaRefVal(tU8 refVal) { gsrTest.atest_reference = refVal; } + inline void SetAlphaTestPassMode(tAlphaTestPassMode mode) { gsrTest.atest_method = (uint64_t)mode; } + inline void SetAlphaTestFailAction(tAlphaTestFailAction action) { gsrTest.atest_fail_method = (uint64_t)action; } + inline void SetAlphaRefVal(uint8_t refVal) { gsrTest.atest_reference = refVal; } inline void EnableSelectiveAlphaBlend(void) { gsrPABE.enable = 1; } inline void DisableSelectiveAlphaBlend(void) { gsrPABE.enable = 0; } - inline void SetAlphaBlendFunc(tAlphaBlendVal a, tAlphaBlendVal b, tAlphaBlendVal c, tAlphaBlendVal d, tU32 fix); + inline void SetAlphaBlendFunc(tAlphaBlendVal a, tAlphaBlendVal b, tAlphaBlendVal c, tAlphaBlendVal d, uint32_t fix); inline void EnableColorClamp(void) { gsrColClamp.clamp = 1; } inline void DisableColorClamp(void) { gsrColClamp.clamp = 0; } @@ -126,11 +126,11 @@ class CDrawEnv { inline void SetDepthTestPassMode(tZTestPassMode passMode) { - gsrTest.ztest_method = (tU64)passMode; + gsrTest.ztest_method = (uint64_t)passMode; eZTestPassMode = passMode; } - inline void SetDepthBufferAddr(tU32 wordAddress) { gsrZBuf.fb_addr = wordAddress / 2048; } - inline void SetDepthBufferPSM(tU32 psm) { gsrZBuf.psm = (tU64)psm; } + inline void SetDepthBufferAddr(uint32_t wordAddress) { gsrZBuf.fb_addr = wordAddress / 2048; } + inline void SetDepthBufferPSM(uint32_t psm) { gsrZBuf.psm = (uint64_t)psm; } inline void EnableDepthTest(void) { gsrZBuf.update_mask = 0; @@ -139,34 +139,34 @@ class CDrawEnv { inline void DisableDepthTest(void) { gsrZBuf.update_mask = 1; - gsrTest.ztest_method = (tU64)ZTest::kAlways; + gsrTest.ztest_method = (uint64_t)ZTest::kAlways; } inline void SetDepthWriteEnabled(bool write) { gsrZBuf.update_mask = !write; } - inline void SetFrameBufferAddr(tU32 wordAddress) + inline void SetFrameBufferAddr(uint32_t wordAddress) { mAssert((wordAddress & 2047) == 0); gsrFrame.fb_addr = wordAddress / 2048; } - inline void SetFrameBufferDrawMask(tU32 drawMask) { gsrFrame.draw_mask = drawMask; } - void SetFrameBufferDim(tU32 pixelW, tU32 pixelH); - inline void SetFrameBufferPSM(tU32 psm) { gsrFrame.psm = psm; } + inline void SetFrameBufferDrawMask(uint32_t drawMask) { gsrFrame.draw_mask = drawMask; } + void SetFrameBufferDim(uint32_t pixelW, uint32_t pixelH); + inline void SetFrameBufferPSM(uint32_t psm) { gsrFrame.psm = psm; } float GetInterlacedPixelOffset() const { return InterlacedOffset; } void SetInterlacedPixelOffset(float offset) { InterlacedOffset = offset; } void CalculateClippedFBXYOffsets(bool addHalfPixel); - inline void SetXYOffsets(tU16 offsetX, tU16 offsetY) + inline void SetXYOffsets(uint16_t offsetX, uint16_t offsetY) { gsrXYOffset.offset_x = offsetX << 4; gsrXYOffset.offset_y = offsetY << 4; } - inline void SetXYOffsetsFix4(tU16 offsetX, tU16 offsetY) + inline void SetXYOffsetsFix4(uint16_t offsetX, uint16_t offsetY) { gsrXYOffset.offset_x = offsetX; gsrXYOffset.offset_y = offsetY; } - inline void SetFrameBufAlphaORMask(tU32 mask) { gsrFBA.alpha = mask; } - inline void SetFogColor(tU32 r, tU32 g, tU32 b) + inline void SetFrameBufAlphaORMask(uint32_t mask) { gsrFBA.alpha = mask; } + inline void SetFogColor(uint32_t r, uint32_t g, uint32_t b) { gsrFogCol.r = r; gsrFogCol.g = g; @@ -180,14 +180,14 @@ class CDrawEnv { tDitherVal dm20, tDitherVal dm21, tDitherVal dm22, tDitherVal dm23, tDitherVal dm30, tDitherVal dm31, tDitherVal dm32, tDitherVal dm33); - inline void SetScissorArea(tU32 scX, tU32 scY, tU32 scWidth, tU32 scHeight); // must be after SetFrameBufferDim() to have effect + inline void SetScissorArea(uint32_t scX, uint32_t scY, uint32_t scWidth, uint32_t scHeight); // must be after SetFrameBufferDim() to have effect void SendSettings(bool waitForEnd = false, bool flushCache = true); void SendSettings(CSCDmaPacket& packet); void SendSettings(CVifSCDmaPacket& packet); // accessors - tU32 GetFrameBufferAddr(void) { return gsrFrame.fb_addr * 2048; } + uint32_t GetFrameBufferAddr(void) { return gsrFrame.fb_addr * 2048; } inline void* operator new(size_t size) { return Core::New16(size); } inline void operator delete(void* p) { Core::Delete16(p); } @@ -198,38 +198,38 @@ class CDrawEnv { tSourceChainTag SettingsDmaTag; tGifTag SettingsGifTag; GS::tFrame gsrFrame; - tU64 FrameAddr; + uint64_t FrameAddr; GS::tZbuf gsrZBuf; - tU64 ZBufAddr; + uint64_t ZBufAddr; GS::tXyoffset gsrXYOffset; - tU64 XYOffsetAddr; + uint64_t XYOffsetAddr; GS::tPrmodecont gsrPrModeCont; - tU64 PrModeContAddr; + uint64_t PrModeContAddr; GS::tColclamp gsrColClamp; - tU64 ColClampAddr; + uint64_t ColClampAddr; GS::tTest gsrTest; - tU64 TestAddr; + uint64_t TestAddr; GS::tAlpha gsrAlpha; - tU64 AlphaAddr; + uint64_t AlphaAddr; GS::tPabe gsrPABE; - tU64 PABEAddr; + uint64_t PABEAddr; GS::tFba gsrFBA; - tU64 FBAAddr; + uint64_t FBAAddr; GS::tDthe gsrDTHE; - tU64 DTHEAddr; + uint64_t DTHEAddr; GS::tDimx gsrDIMX; - tU64 DIMXAddr; + uint64_t DIMXAddr; GS::tScissor gsrScissor; - tU64 ScissorAddr; + uint64_t ScissorAddr; GS::tFogcol gsrFogCol; - tU64 FogColAddr; + uint64_t FogColAddr; } __attribute__((packed,aligned(16))); - tU32 uiNumGSRegs; + uint32_t uiNumGSRegs; CSCDmaPacket GifPacket; tZTestPassMode eZTestPassMode; - tU32 uiFBWidth, uiFBHeight; + uint32_t uiFBWidth, uiFBHeight; float InterlacedOffset; private: @@ -242,7 +242,7 @@ class CDrawEnv { */ inline void -CDrawEnv::SetAlphaBlendFunc(tAlphaBlendVal a, tAlphaBlendVal b, tAlphaBlendVal c, tAlphaBlendVal d, tU32 fix) +CDrawEnv::SetAlphaBlendFunc(tAlphaBlendVal a, tAlphaBlendVal b, tAlphaBlendVal c, tAlphaBlendVal d, uint32_t fix) { gsrAlpha.a = a; gsrAlpha.b = b; @@ -257,26 +257,26 @@ CDrawEnv::SetDitherMatrix(tDitherVal dm00, tDitherVal dm01, tDitherVal dm02, tDi tDitherVal dm20, tDitherVal dm21, tDitherVal dm22, tDitherVal dm23, tDitherVal dm30, tDitherVal dm31, tDitherVal dm32, tDitherVal dm33) { - gsrDIMX.DIMX00 = (tU64)dm00; - gsrDIMX.DIMX01 = (tU64)dm01; - gsrDIMX.DIMX02 = (tU64)dm02; - gsrDIMX.DIMX03 = (tU64)dm03; - gsrDIMX.DIMX10 = (tU64)dm10; - gsrDIMX.DIMX11 = (tU64)dm11; - gsrDIMX.DIMX12 = (tU64)dm12; - gsrDIMX.DIMX13 = (tU64)dm13; - gsrDIMX.DIMX20 = (tU64)dm20; - gsrDIMX.DIMX21 = (tU64)dm21; - gsrDIMX.DIMX22 = (tU64)dm22; - gsrDIMX.DIMX23 = (tU64)dm23; - gsrDIMX.DIMX30 = (tU64)dm30; - gsrDIMX.DIMX31 = (tU64)dm31; - gsrDIMX.DIMX32 = (tU64)dm32; - gsrDIMX.DIMX33 = (tU64)dm33; + gsrDIMX.DIMX00 = (uint64_t)dm00; + gsrDIMX.DIMX01 = (uint64_t)dm01; + gsrDIMX.DIMX02 = (uint64_t)dm02; + gsrDIMX.DIMX03 = (uint64_t)dm03; + gsrDIMX.DIMX10 = (uint64_t)dm10; + gsrDIMX.DIMX11 = (uint64_t)dm11; + gsrDIMX.DIMX12 = (uint64_t)dm12; + gsrDIMX.DIMX13 = (uint64_t)dm13; + gsrDIMX.DIMX20 = (uint64_t)dm20; + gsrDIMX.DIMX21 = (uint64_t)dm21; + gsrDIMX.DIMX22 = (uint64_t)dm22; + gsrDIMX.DIMX23 = (uint64_t)dm23; + gsrDIMX.DIMX30 = (uint64_t)dm30; + gsrDIMX.DIMX31 = (uint64_t)dm31; + gsrDIMX.DIMX32 = (uint64_t)dm32; + gsrDIMX.DIMX33 = (uint64_t)dm33; } inline void -CDrawEnv::SetScissorArea(tU32 scX, tU32 scY, tU32 scWidth, tU32 scHeight) +CDrawEnv::SetScissorArea(uint32_t scX, uint32_t scY, uint32_t scWidth, uint32_t scHeight) { gsrScissor.clip_x0 = scX; gsrScissor.clip_y0 = scY; diff --git a/include/ps2s/eetimer.h b/include/ps2s/eetimer.h index a460184..22acc5a 100644 --- a/include/ps2s/eetimer.h +++ b/include/ps2s/eetimer.h @@ -133,7 +133,7 @@ class CEETimer { tMode.OVFF = 0; } - inline void SetCompareValue(tU16 val) + inline void SetCompareValue(uint16_t val) { tComp = val; *pComp = tComp; @@ -168,7 +168,7 @@ class CEETimer { protected: Timers::tMode tMode; Timers::tCount tCount; - tU16 tComp; + uint16_t tComp; tResolution Resolution; volatile unsigned int* pMode; diff --git a/include/ps2s/gs.h b/include/ps2s/gs.h index 08f76ea..94f03f9 100644 --- a/include/ps2s/gs.h +++ b/include/ps2s/gs.h @@ -150,13 +150,13 @@ namespace ControlRegs { * methods */ -inline tU32 PackRGB(tU8 r, tU8 g, tU8 b) +inline uint32_t PackRGB(uint8_t r, uint8_t g, uint8_t b) { - return (tU32)r | ((tU32)g << 8) | ((tU32)b << 16); + return (uint32_t)r | ((uint32_t)g << 8) | ((uint32_t)b << 16); } -inline tU32 PackRGBA(tU8 r, tU8 g, tU8 b, tU8 a) +inline uint32_t PackRGBA(uint8_t r, uint8_t g, uint8_t b, uint8_t a) { - return (tU32)r | ((tU32)g << 8) | ((tU32)b << 16) | ((tU32)a << 24); + return (uint32_t)r | ((uint32_t)g << 8) | ((uint32_t)b << 16) | ((uint32_t)a << 24); } void Init(void); @@ -165,14 +165,14 @@ void Flush(void); void Flush(CSCDmaPacket& packet); inline unsigned int GetBitsPerPixel(tPSM psm); -void ReorderClut(tU32* oldClut, tU32* newClut); +void ReorderClut(uint32_t* oldClut, uint32_t* newClut); } // namespace GS namespace GIF { namespace Registers { - static volatile tU32* const ctrl = (volatile tU32*)0x10003000; - static volatile tU128* const fifo = (volatile tU128*)0x10006000; + static volatile uint32_t* const ctrl = (volatile uint32_t*)0x10003000; + static volatile uint128_t* const fifo = (volatile uint128_t*)0x10006000; } } @@ -207,7 +207,7 @@ typedef struct tGifTag_t { inline unsigned int GS::GetBitsPerPixel(tPSM psm) { - tU32 bpp = 0; + uint32_t bpp = 0; switch (psm) { case kPsm32: diff --git a/include/ps2s/gs_reg_types.h b/include/ps2s/gs_reg_types.h index 8f78f7a..c941a19 100644 --- a/include/ps2s/gs_reg_types.h +++ b/include/ps2s/gs_reg_types.h @@ -13,38 +13,38 @@ namespace GS { typedef struct { - tU64 DIMX00 : 3; - tU64 pad03 : 1; - tU64 DIMX01 : 3; - tU64 pad07 : 1; - tU64 DIMX02 : 3; - tU64 pad11 : 1; - tU64 DIMX03 : 3; - tU64 pad15 : 1; - tU64 DIMX10 : 3; - tU64 pad19 : 1; - tU64 DIMX11 : 3; - tU64 pad23 : 1; - tU64 DIMX12 : 3; - tU64 pad27 : 1; - tU64 DIMX13 : 3; - tU64 pad31 : 1; - tU64 DIMX20 : 3; - tU64 pad35 : 1; - tU64 DIMX21 : 3; - tU64 pad39 : 1; - tU64 DIMX22 : 3; - tU64 pad43 : 1; - tU64 DIMX23 : 3; - tU64 pad47 : 1; - tU64 DIMX30 : 3; - tU64 pad51 : 1; - tU64 DIMX31 : 3; - tU64 pad55 : 1; - tU64 DIMX32 : 3; - tU64 pad59 : 1; - tU64 DIMX33 : 3; - tU64 pad63 : 1; + uint64_t DIMX00 : 3; + uint64_t pad03 : 1; + uint64_t DIMX01 : 3; + uint64_t pad07 : 1; + uint64_t DIMX02 : 3; + uint64_t pad11 : 1; + uint64_t DIMX03 : 3; + uint64_t pad15 : 1; + uint64_t DIMX10 : 3; + uint64_t pad19 : 1; + uint64_t DIMX11 : 3; + uint64_t pad23 : 1; + uint64_t DIMX12 : 3; + uint64_t pad27 : 1; + uint64_t DIMX13 : 3; + uint64_t pad31 : 1; + uint64_t DIMX20 : 3; + uint64_t pad35 : 1; + uint64_t DIMX21 : 3; + uint64_t pad39 : 1; + uint64_t DIMX22 : 3; + uint64_t pad43 : 1; + uint64_t DIMX23 : 3; + uint64_t pad47 : 1; + uint64_t DIMX30 : 3; + uint64_t pad51 : 1; + uint64_t DIMX31 : 3; + uint64_t pad55 : 1; + uint64_t DIMX32 : 3; + uint64_t pad59 : 1; + uint64_t DIMX33 : 3; + uint64_t pad63 : 1; } __attribute__((packed)) tDimx ; typedef GS_ALPHA tAlpha; diff --git a/include/ps2s/imagepackets.h b/include/ps2s/imagepackets.h index 2a38475..1f006e2 100644 --- a/include/ps2s/imagepackets.h +++ b/include/ps2s/imagepackets.h @@ -25,15 +25,15 @@ class CImageUploadPkt : protected CVifSCDmaPacket { friend class CTexture; public: - CImageUploadPkt(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm, tU32 gsBufWidth = 0, tU32 gsWordAddress = 0); + CImageUploadPkt(uint128_t* imagePtr, uint32_t w, uint32_t h, GS::tPSM psm, uint32_t gsBufWidth = 0, uint32_t gsWordAddress = 0); virtual ~CImageUploadPkt(void) {} // call these before trying to xfer the image! - virtual void SetGsAddr(tU32 gsMemWordAddress) + virtual void SetGsAddr(uint32_t gsMemWordAddress) { gsrBitBltBuf.dest_addr = gsMemWordAddress / 64; } - void SetGsBufferWidth(tU32 gsBufWidth) + void SetGsBufferWidth(uint32_t gsBufWidth) { mAssert(gsBufWidth >= 64); gsrBitBltBuf.dest_width = gsBufWidth / 64; @@ -49,9 +49,9 @@ class CImageUploadPkt : protected CVifSCDmaPacket { // trying to xfer the image: SetImage, SetGsBufferWidth, SetGsAddr CImageUploadPkt(void); - void SetImage(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm) + void SetImage(uint128_t* imagePtr, uint32_t w, uint32_t h, GS::tPSM psm) { - mAssert(((tU32)imagePtr & 0xf) == 0); + mAssert(((uint32_t)imagePtr & 0xf) == 0); pImage = imagePtr; gsrBitBltBuf.dest_pixmode = psm; gsrTrxReg.trans_w = w; @@ -78,21 +78,21 @@ class CImageUploadPkt : protected CVifSCDmaPacket { // gs packet to setup the texture image transfer struct { // DMA tag + GIF tag + 4 register settings (+ 15 rest ?) - tU128 FirstDmaTag; + uint128_t FirstDmaTag; tGifTag ImageXferSettingsGifTag; GS::tBitbltbuf gsrBitBltBuf; - tU64 BitBltBufAddr; + uint64_t BitBltBufAddr; GS::tTrxpos gsrTrxPos; - tU64 TrxPosAddr; + uint64_t TrxPosAddr; GS::tTrxreg gsrTrxReg; - tU64 TrxRegAddr; + uint64_t TrxRegAddr; GS::tTrxdir gsrTrxDir; - tU64 TrxDirAddr; - tU128 RestOfPacket[15]; + uint64_t TrxDirAddr; + uint128_t RestOfPacket[15]; } __attribute__((packed,aligned(16))); - tU32 uiNumXferGSRegs; - tU128* pImage; + uint32_t uiNumXferGSRegs; + uint128_t* pImage; void InitCommon(void); void BuildXferTags(void); @@ -106,7 +106,7 @@ class CClutUploadPkt : protected CImageUploadPkt { friend class CTexture; public: - CClutUploadPkt(tU32* clutPtr, tU32 gsMemWordAddr) + CClutUploadPkt(uint32_t* clutPtr, uint32_t gsMemWordAddr) { SetGsBufferWidth(64); SetGsAddr(gsMemWordAddr); @@ -119,13 +119,13 @@ class CClutUploadPkt : protected CImageUploadPkt { } virtual ~CClutUploadPkt(void) {} - void SetGsAddr(tU32 gsMemWordAddress) + void SetGsAddr(uint32_t gsMemWordAddress) { CImageUploadPkt::SetGsAddr(gsMemWordAddress); } - void SetClut(tU32* clutPtr) + void SetClut(uint32_t* clutPtr) { - SetImage((tU128*)clutPtr, 16, 16, GS::kPsm32); + SetImage((uint128_t*)clutPtr, 16, 16, GS::kPsm32); } void Reset() { CVifSCDmaPacket::Reset(); } void Send(bool waitForEnd = false, bool flushCache = true) diff --git a/include/ps2s/math.h b/include/ps2s/math.h index 2eb2e52..73445e0 100644 --- a/include/ps2s/math.h +++ b/include/ps2s/math.h @@ -60,8 +60,8 @@ DegToRad(float deg) return deg * (kPi / 180.0f); } -inline tU32 -DivUp(tU32 num, tU32 divisor) +inline uint32_t +DivUp(uint32_t num, uint32_t divisor) { return (num % divisor) ? num / divisor + 1 : num / divisor; } @@ -153,7 +153,7 @@ IsEven(int a) } inline bool -IsPow2(tU32 num) +IsPow2(uint32_t num) { return ((num & (num - 1)) == 0); } @@ -164,10 +164,10 @@ Lerp(float t, float f1, float f2) return (f1 + t * (f2 - f1)); } -inline tU32 -Log2(tU32 num) +inline uint32_t +Log2(uint32_t num) { - tU32 logNum = 0; + uint32_t logNum = 0; while (num > 1) { num = num >> 1; logNum++; @@ -199,6 +199,12 @@ Min(unsigned int a, unsigned int b) return (a < b) ? a : b; } +inline uint32_t +Min(uint32_t a, uint32_t b) +{ + return (a < b) ? a : b; +} + inline float Max(float a, float b) { diff --git a/include/ps2s/packet.h b/include/ps2s/packet.h index 0fc7127..b87dacc 100644 --- a/include/ps2s/packet.h +++ b/include/ps2s/packet.h @@ -59,8 +59,8 @@ static const bool kNotMasked = false; class CDmaPacket { public: // need to add support for different memory mappings - CDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, tU32 memMapping = Core::MemMappings::Normal); - CDmaPacket(tU128* buffer, tU32 bufferQWSize, tDmaChannelId channel, tU32 memMapping = Core::MemMappings::Normal, bool isFull = false); + CDmaPacket(uint32_t bufferQWSize, tDmaChannelId channel, uint32_t memMapping = Core::MemMappings::Normal); + CDmaPacket(uint128_t* buffer, uint32_t bufferQWSize, tDmaChannelId channel, uint32_t memMapping = Core::MemMappings::Normal, bool isFull = false); virtual ~CDmaPacket(void); @@ -71,14 +71,14 @@ class CDmaPacket { template inline dataType* Add(const dataType data); template - inline dataType* Add(const dataType* data, tU32 num); + inline dataType* Add(const dataType* data, uint32_t num); // to use these you MUST cast to CDmaPacket&!! (otherwise you'll get a compiler error.. I // could make inlines for all of CDmaPacket's descendants, but I will certainly forget to // update them at some point in the future, when I may not be lucky enough to have // the compiler catch it...) void operator+=(const CDmaPacket& otherPkt); - inline tU128* Add(const CDmaPacket& otherPkt); + inline uint128_t* Add(const CDmaPacket& otherPkt); inline void Reset(void) { pNext = pBase; } inline void SetDmaChannel(tDmaChannelId channel); @@ -86,22 +86,22 @@ class CDmaPacket { // accessors - tU128* GetBase(void) const { return (tU128*)pBase; } - tU8* GetNextPtr(void) const { return pNext; } - tU32 GetByteLength(void) const { return (tU32)pNext - (tU32)pBase; } + uint128_t* GetBase(void) const { return (uint128_t*)pBase; } + uint8_t* GetNextPtr(void) const { return pNext; } + uint32_t GetByteLength(void) const { return (uint32_t)pNext - (uint32_t)pBase; } static void* AllocBuffer(int numQwords, unsigned int memMapping); // be VERY careful using this.. it swaps its internal dma buffer with the new, // returning the old.. be aware of where memory is being deallocated.. void* SwapOutBuffer(void* newBuffer); - void HexDump(tU32 numQwords = 0); + void HexDump(uint32_t numQwords = 0); virtual void Print(void); protected: - tU8 *pBase, *pNext; + uint8_t *pBase, *pNext; tDmaChannelId dmaChannelId; - tU32 uiBufferQwordSize; + uint32_t uiBufferQwordSize; private: // And on the third day it was proclaimed: "Thou shalt not copy dma packets!" @@ -120,8 +120,8 @@ class CDmaPacket { class CSCDmaPacket : public CDmaPacket { public: - CSCDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping = Core::MemMappings::Normal); - CSCDmaPacket(tU128* buffer, tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping = Core::MemMappings::Normal, bool isFull = false); + CSCDmaPacket(uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping = Core::MemMappings::Normal); + CSCDmaPacket(uint128_t* buffer, uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping = Core::MemMappings::Normal, bool isFull = false); virtual ~CSCDmaPacket(void) {} template @@ -129,24 +129,24 @@ class CSCDmaPacket : public CDmaPacket { template inline dataType* Add(const dataType data); template - inline dataType* Add(const dataType* data, tU32 num); + inline dataType* Add(const dataType* data, uint32_t num); inline void operator+=(const CDmaPacket& otherPkt); - inline tU128* Add(const CDmaPacket& otherPkt); - - inline CSCDmaPacket& Cnt(bool irq = false, tU32 pce = 0, bool sp = false); - inline CSCDmaPacket& Next(const tDmaTag* nextTag, bool irq = false, bool sp = false, tU32 pce = 0); - inline CSCDmaPacket& Ref(const void* refData, tU32 dataQWLen, bool irq = false, bool sp = false, tU32 pce = 0); - inline CSCDmaPacket& Refs(const void* refData, tU32 dataQWLen, bool irq = false, bool sp = false, tU32 pce = 0); - inline CSCDmaPacket& Refe(const void* refData, tU32 dataQWLen, bool irq = false, bool sp = false, tU32 pce = 0); - inline CSCDmaPacket& Call(const void* nextTag, bool irq = false, bool sp = false, tU32 pce = 0); - inline CSCDmaPacket& Call(const CSCDmaPacket& pkt, bool irq = false, bool sp = false, tU32 pce = 0); - inline CSCDmaPacket& Ret(bool irq = false, tU32 pce = 0); - inline CSCDmaPacket& End(bool irq = false, tU32 pce = 0); + inline uint128_t* Add(const CDmaPacket& otherPkt); + + inline CSCDmaPacket& Cnt(bool irq = false, uint32_t pce = 0, bool sp = false); + inline CSCDmaPacket& Next(const tDmaTag* nextTag, bool irq = false, bool sp = false, uint32_t pce = 0); + inline CSCDmaPacket& Ref(const void* refData, uint32_t dataQWLen, bool irq = false, bool sp = false, uint32_t pce = 0); + inline CSCDmaPacket& Refs(const void* refData, uint32_t dataQWLen, bool irq = false, bool sp = false, uint32_t pce = 0); + inline CSCDmaPacket& Refe(const void* refData, uint32_t dataQWLen, bool irq = false, bool sp = false, uint32_t pce = 0); + inline CSCDmaPacket& Call(const void* nextTag, bool irq = false, bool sp = false, uint32_t pce = 0); + inline CSCDmaPacket& Call(const CSCDmaPacket& pkt, bool irq = false, bool sp = false, uint32_t pce = 0); + inline CSCDmaPacket& Ret(bool irq = false, uint32_t pce = 0); + inline CSCDmaPacket& End(bool irq = false, uint32_t pce = 0); inline CSCDmaPacket& CloseTag(void); - CSCDmaPacket& Pad96(tU32 padData); - CSCDmaPacket& Pad128(tU32 padData); + CSCDmaPacket& Pad96(uint32_t padData); + CSCDmaPacket& Pad128(uint32_t padData); virtual void Send(bool waitForEnd = false, bool flushCache = true); @@ -156,19 +156,19 @@ class CSCDmaPacket : public CDmaPacket { bool HasOpenTag() const { return pOpenTag != NULL; } protected: - void SetDmaTag(tDmaTag* tag, tU32 QWC, tU32 PCE, tU32 ID, tU32 IRQ, const tU128* ADDR, tU32 SPR); + void SetDmaTag(tDmaTag* tag, uint32_t QWC, uint32_t PCE, uint32_t ID, uint32_t IRQ, const uint128_t* ADDR, uint32_t SPR); bool bTTE; tDmaTag* pOpenTag; - tU32 uiTTEBytesLeft; + uint32_t uiTTEBytesLeft; private: // these will be passed as u32's as the QWC field, which is only 16 bits wide // so it should be ok to use the upper half-word - static const tU32 countQWC = 1 << 16; - static const tU32 dontCountQWC = 1 << 17; + static const uint32_t countQWC = 1 << 16; + static const uint32_t dontCountQWC = 1 << 17; - inline void AddDmaTag(tU32 QWC, tU32 PCE, tU32 ID, tU32 IRQ, const tU128* ADDR, tU32 SPR); + inline void AddDmaTag(uint32_t QWC, uint32_t PCE, uint32_t ID, uint32_t IRQ, const uint128_t* ADDR, uint32_t SPR); // see the note in CDmaPacket CSCDmaPacket(const CSCDmaPacket& pktToCopy); @@ -181,47 +181,47 @@ class CSCDmaPacket : public CDmaPacket { class CVifSCDmaPacket : public CSCDmaPacket { public: - CVifSCDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping = Core::MemMappings::Normal); - CVifSCDmaPacket(tU128* buffer, tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping = Core::MemMappings::Normal, bool isFull = false); + CVifSCDmaPacket(uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping = Core::MemMappings::Normal); + CVifSCDmaPacket(uint128_t* buffer, uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping = Core::MemMappings::Normal, bool isFull = false); virtual ~CVifSCDmaPacket(void) {} inline CVifSCDmaPacket& Nop(bool irq = false); - inline CVifSCDmaPacket& Stcycl(tU32 wl, tU32 cl, bool irq = false); - inline CVifSCDmaPacket& Offset(tU32 offset, bool irq = false); - inline CVifSCDmaPacket& Base(tU32 base, bool irq = false); - inline CVifSCDmaPacket& Itop(tU32 itops, bool irq = false); - inline CVifSCDmaPacket& Stmod(tU32 mode, bool irq = false); - inline CVifSCDmaPacket& Mskpath3(tU32 mask, bool irq = false); - inline CVifSCDmaPacket& Mark(tU32 value, bool irq = false); + inline CVifSCDmaPacket& Stcycl(uint32_t wl, uint32_t cl, bool irq = false); + inline CVifSCDmaPacket& Offset(uint32_t offset, bool irq = false); + inline CVifSCDmaPacket& Base(uint32_t base, bool irq = false); + inline CVifSCDmaPacket& Itop(uint32_t itops, bool irq = false); + inline CVifSCDmaPacket& Stmod(uint32_t mode, bool irq = false); + inline CVifSCDmaPacket& Mskpath3(uint32_t mask, bool irq = false); + inline CVifSCDmaPacket& Mark(uint32_t value, bool irq = false); inline CVifSCDmaPacket& Flushe(bool irq = false); inline CVifSCDmaPacket& Flush(bool irq = false); inline CVifSCDmaPacket& Flusha(bool irq = false); - inline CVifSCDmaPacket& Mscal(tU32 addr, bool irq = false); + inline CVifSCDmaPacket& Mscal(uint32_t addr, bool irq = false); inline CVifSCDmaPacket& Mscnt(bool irq = false); - inline CVifSCDmaPacket& Mscalf(tU32 addr, bool irq = false); + inline CVifSCDmaPacket& Mscalf(uint32_t addr, bool irq = false); inline CVifSCDmaPacket& Stmask(Vifs::tMask mask, bool irq = false); inline CVifSCDmaPacket& Strow(const void* rowArray, bool irq = false); inline CVifSCDmaPacket& Stcol(const void* colArray, bool irq = false); - inline CVifSCDmaPacket& Mpg(tU32 num, tU32 addr, bool irq = false); + inline CVifSCDmaPacket& Mpg(uint32_t num, uint32_t addr, bool irq = false); - inline CVifSCDmaPacket& OpenUnpack(tU32 mode, tU32 vuAddr, bool dblBuffered, + inline CVifSCDmaPacket& OpenUnpack(uint32_t mode, uint32_t vuAddr, bool dblBuffered, bool masked = false, bool usigned = true, bool irq = false); CVifSCDmaPacket& CloseUnpack(void); - inline CVifSCDmaPacket& CloseUnpack(tU32 wl, tU32 cl); - inline CVifSCDmaPacket& CloseUnpack(tU32 unpackNUM); + inline CVifSCDmaPacket& CloseUnpack(uint32_t wl, uint32_t cl); + inline CVifSCDmaPacket& CloseUnpack(uint32_t unpackNUM); inline CVifSCDmaPacket& OpenDirect(bool irq = false); inline CVifSCDmaPacket& CloseDirect(void); - inline CVifSCDmaPacket& CloseDirect(tU32 numQuads); + inline CVifSCDmaPacket& CloseDirect(uint32_t numQuads); inline CVifSCDmaPacket& Pad96(void); inline CVifSCDmaPacket& Pad128(void); private: - static const tU32 Unused = 0; + static const uint32_t Unused = 0; Vifs::tVifCode* pOpenVifCode; - tU32 uiWL, uiCL; + uint32_t uiWL, uiCL; }; /******************************************** @@ -235,7 +235,7 @@ class CVifSCDmaPacket : public CSCDmaPacket { #define mCheckPktAlignment(__type) \ mWarnIf(sizeof(__type) == 16 \ - && (tU32)pNext & (16 - 1), \ + && (uint32_t)pNext & (16 - 1), \ "You're trying to add 16-byte data to this packet on a non-16-byte boundary.. Are you sure this is right?") #define mAddData(__type, __data) \ @@ -266,16 +266,16 @@ CDmaPacket::Add(const dataType data) template inline dataType* -CDmaPacket::Add(const dataType* data, tU32 num) +CDmaPacket::Add(const dataType* data, uint32_t num) { mCheckFreeSpaceN(dataType, num); mCheckPktAlignment(dataType); dataType* dataStart = reinterpret_cast(pNext); dataType* nextStore = dataStart; - for (tU32 i = 0; i < num; i++) + for (uint32_t i = 0; i < num; i++) *nextStore++ = *data++; - pNext = reinterpret_cast(nextStore); + pNext = reinterpret_cast(nextStore); return dataStart; } @@ -283,17 +283,17 @@ CDmaPacket::Add(const dataType* data, tU32 num) inline void CDmaPacket::operator+=(const CDmaPacket& otherPkt) { - tU32 numBytes = otherPkt.GetByteLength(); + uint32_t numBytes = otherPkt.GetByteLength(); mErrorIf(numBytes & (16 - 1), "Can only add packets that are an even # of quads."); - tU32 numQuads = numBytes / 16; + uint32_t numQuads = numBytes / 16; Add(otherPkt.GetBase(), numQuads); } -inline tU128* +inline uint128_t* CDmaPacket::Add(const CDmaPacket& otherPkt) { - tU128* dataStart = reinterpret_cast(pNext); + uint128_t* dataStart = reinterpret_cast(pNext); operator+=(otherPkt); return dataStart; } @@ -319,7 +319,7 @@ class CDmaPacket::Helper { public: static inline void AddSize( CDmaPacket& packet, const dataType data ) { mErrorIf( packet.pNext+byteSize > (packet.pBase + packet.uiBufferQwordSize*16), "Not enough space in packet!" ); - mErrorIf( (tU32)packet.pNext & (byteSize - 1), "Free space in packet not properly aligned!" ); + mErrorIf( (uint32_t)packet.pNext & (byteSize - 1), "Free space in packet not properly aligned!" ); *(dataType*)packet.pNext = data; packet.pNext += byteSize; } @@ -330,10 +330,10 @@ class CDmaPacket::Helper < dataType, 16 > { public: static inline void AddSize( CDmaPacket& packet, const dataType data ) { mErrorIf( packet.pNext+sizeof(data) > (packet.pBase + packet.uiBufferQwordSize*16), "Not enough space in packet!" ); - mErrorIf( (tU32)packet.pNext & (sizeof(data) - 1), "Free space in packet not properly aligned!" ); + mErrorIf( (uint32_t)packet.pNext & (sizeof(data) - 1), "Free space in packet not properly aligned!" ); - union { dataType realData; tU128 qword; } uData = { data }; - *(tU128*)packet.pNext = uData.qword; packet.pNext += 16; + union { dataType realData; uint128_t qword; } uData = { data }; + *(uint128_t*)packet.pNext = uData.qword; packet.pNext += 16; // mAdd128( uData.qword ); } }; @@ -356,7 +356,7 @@ class CDmaPacket::Helper < dataType, 16 > { "Don't you think you should open a dma tag before adding data?") #define mCheckXferAddrAlign(_addr) \ - mErrorIf((tU32)(_addr) & (16 - 1), "I suggest you only point to qword-aligned memory..") + mErrorIf((uint32_t)(_addr) & (16 - 1), "I suggest you only point to qword-aligned memory..") template inline dataType* @@ -377,7 +377,7 @@ CSCDmaPacket::operator+=(const dataType data) template inline dataType* -CSCDmaPacket::Add(const dataType* data, tU32 num) +CSCDmaPacket::Add(const dataType* data, uint32_t num) { mCheckTTESpaceN(dataType, num); dataType* retValue = CDmaPacket::Add(data, num); @@ -393,7 +393,7 @@ CSCDmaPacket::operator+=(const CDmaPacket& otherPkt) { CDmaPacket::operator+=(otherPkt); } -inline tU128* +inline uint128_t* CSCDmaPacket::Add(const CDmaPacket& otherPkt) { return CDmaPacket::Add(otherPkt); @@ -402,13 +402,13 @@ CSCDmaPacket::Add(const CDmaPacket& otherPkt) // dma tags inline void -CSCDmaPacket::SetDmaTag(tDmaTag* tag, tU32 QWC, tU32 PCE, tU32 ID, tU32 IRQ, const tU128* ADDR, tU32 SPR) +CSCDmaPacket::SetDmaTag(tDmaTag* tag, uint32_t QWC, uint32_t PCE, uint32_t ID, uint32_t IRQ, const uint128_t* ADDR, uint32_t SPR) { tag->QWC = QWC; tag->PCE = PCE; tag->ID = ID; tag->IRQ = IRQ; - tag->ADDR = (tU64)((tU32)ADDR); + tag->ADDR = (uint64_t)((uint32_t)ADDR); tag->SPR = SPR; } @@ -416,20 +416,20 @@ inline CSCDmaPacket& CSCDmaPacket::CloseTag(void) { mErrorIf(!pOpenTag, "You called CloseTag(), but no dma tags are open!"); - mErrorIf(((tU32)pNext & (16 - 1)) != 0, "Packet is not qword aligned"); + mErrorIf(((uint32_t)pNext & (16 - 1)) != 0, "Packet is not qword aligned"); // set the qwc field of any open tags.. (- 1 is so that we don't count the qword // containing the *pOpenTag) if (pOpenTag) - pOpenTag->QWC = (((tU32)pNext - (tU32)pOpenTag) / 16 - 1); + pOpenTag->QWC = (((uint32_t)pNext - (uint32_t)pOpenTag) / 16 - 1); pOpenTag = NULL; return *this; } inline void -CSCDmaPacket::AddDmaTag(tU32 QWC, tU32 PCE, tU32 ID, tU32 IRQ, const tU128* ADDR, tU32 SPR) +CSCDmaPacket::AddDmaTag(uint32_t QWC, uint32_t PCE, uint32_t ID, uint32_t IRQ, const uint128_t* ADDR, uint32_t SPR) { - mErrorIf(((tU32)pNext & 0xf) != 0, "Free space in packet is not aligned properly."); + mErrorIf(((uint32_t)pNext & 0xf) != 0, "Free space in packet is not aligned properly."); mErrorIf(pOpenTag, "You need to close any open dma tags before opening another!"); if (QWC == countQWC) { @@ -452,92 +452,92 @@ CSCDmaPacket::AddDmaTag(tU32 QWC, tU32 PCE, tU32 ID, tU32 IRQ, const tU128* ADDR #define xlateAddr(__va) inline CSCDmaPacket& -CSCDmaPacket::Cnt(bool irq, tU32 pce, bool sp) +CSCDmaPacket::Cnt(bool irq, uint32_t pce, bool sp) { AddDmaTag(countQWC, pce, DMAC::kCnt, irq, 0, sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Next(const tDmaTag* nextTag, bool irq, bool sp, tU32 pce) +CSCDmaPacket::Next(const tDmaTag* nextTag, bool irq, bool sp, uint32_t pce) { mCheckXferAddrAlign(nextTag); xlateAddr(nextTag); - AddDmaTag(countQWC, pce, DMAC::kNext, irq, (tU128*)nextTag, sp); + AddDmaTag(countQWC, pce, DMAC::kNext, irq, (uint128_t*)nextTag, sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Ref(const void* refData, tU32 dataQWLen, bool irq, bool sp, tU32 pce) +CSCDmaPacket::Ref(const void* refData, uint32_t dataQWLen, bool irq, bool sp, uint32_t pce) { mCheckXferAddrAlign(refData); xlateAddr(refData); - AddDmaTag(dataQWLen, pce, DMAC::kRef, irq, (const tU128*)refData, sp); + AddDmaTag(dataQWLen, pce, DMAC::kRef, irq, (const uint128_t*)refData, sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Refs(const void* refData, tU32 dataQWLen, bool irq, bool sp, tU32 pce) +CSCDmaPacket::Refs(const void* refData, uint32_t dataQWLen, bool irq, bool sp, uint32_t pce) { mCheckXferAddrAlign(refData); xlateAddr(refData); - AddDmaTag(dataQWLen, pce, DMAC::kRefs, irq, (const tU128*)refData, sp); + AddDmaTag(dataQWLen, pce, DMAC::kRefs, irq, (const uint128_t*)refData, sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Refe(const void* refData, tU32 dataQWLen, bool irq, bool sp, tU32 pce) +CSCDmaPacket::Refe(const void* refData, uint32_t dataQWLen, bool irq, bool sp, uint32_t pce) { mCheckXferAddrAlign(refData); xlateAddr(refData); - AddDmaTag(dataQWLen, pce, DMAC::kRefe, irq, (const tU128*)refData, sp); + AddDmaTag(dataQWLen, pce, DMAC::kRefe, irq, (const uint128_t*)refData, sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Call(const void* nextTag, bool irq, bool sp, tU32 pce) +CSCDmaPacket::Call(const void* nextTag, bool irq, bool sp, uint32_t pce) { mCheckXferAddrAlign(nextTag); xlateAddr(nextTag); - AddDmaTag(countQWC, pce, DMAC::kCall, irq, (tU128*)nextTag, sp); + AddDmaTag(countQWC, pce, DMAC::kCall, irq, (uint128_t*)nextTag, sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Call(const CSCDmaPacket& pkt, bool irq, bool sp, tU32 pce) +CSCDmaPacket::Call(const CSCDmaPacket& pkt, bool irq, bool sp, uint32_t pce) { mCheckXferAddrAlign(pkt.pBase); AddDmaTag(countQWC, pce, DMAC::kCall, irq, - Core::MakePtrNormal((tU128*)pkt.pBase), sp); + Core::MakePtrNormal((uint128_t*)pkt.pBase), sp); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Ret(bool irq, tU32 pce) +CSCDmaPacket::Ret(bool irq, uint32_t pce) { AddDmaTag(countQWC, pce, DMAC::kRet, irq, 0, false); return *this; } inline CSCDmaPacket& -CSCDmaPacket::End(bool irq, tU32 pce) +CSCDmaPacket::End(bool irq, uint32_t pce) { AddDmaTag(countQWC, pce, DMAC::kEnd, irq, 0, false); return *this; } inline CSCDmaPacket& -CSCDmaPacket::Pad96(tU32 padData) +CSCDmaPacket::Pad96(uint32_t padData) { - while ((((tU32)pNext + 4) & 0xf) != 0) + while ((((uint32_t)pNext + 4) & 0xf) != 0) *this += padData; return *this; } inline CSCDmaPacket& -CSCDmaPacket::Pad128(tU32 padData) +CSCDmaPacket::Pad128(uint32_t padData) { - while (((tU32)pNext & 0xf) != 0) + while (((uint32_t)pNext & 0xf) != 0) *this += padData; return *this; } @@ -555,7 +555,7 @@ CSCDmaPacket::Pad128(tU32 padData) // VifCodes -#define mMakeVifCode(_immediate, _num, _cmd, _irq) ((tU32)(_immediate) | ((tU32)(_num) << 16) | ((tU32)(_cmd) << 24) | ((tU32)(_irq) << 31)) +#define mMakeVifCode(_immediate, _num, _cmd, _irq) ((uint32_t)(_immediate) | ((uint32_t)(_num) << 16) | ((uint32_t)(_cmd) << 24) | ((uint32_t)(_irq) << 31)) inline CVifSCDmaPacket& CVifSCDmaPacket::Nop(bool irq) @@ -565,7 +565,7 @@ CVifSCDmaPacket::Nop(bool irq) } inline CVifSCDmaPacket& -CVifSCDmaPacket::Stcycl(tU32 wl, tU32 cl, bool irq) +CVifSCDmaPacket::Stcycl(uint32_t wl, uint32_t cl, bool irq) { uiWL = wl; uiCL = cl; @@ -574,42 +574,42 @@ CVifSCDmaPacket::Stcycl(tU32 wl, tU32 cl, bool irq) } inline CVifSCDmaPacket& -CVifSCDmaPacket::Offset(tU32 offset, bool irq) +CVifSCDmaPacket::Offset(uint32_t offset, bool irq) { *this += mMakeVifCode(offset, Unused, Vifs::Opcodes::offset, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::Base(tU32 base, bool irq) +CVifSCDmaPacket::Base(uint32_t base, bool irq) { *this += mMakeVifCode(base, Unused, Vifs::Opcodes::base, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::Itop(tU32 itops, bool irq) +CVifSCDmaPacket::Itop(uint32_t itops, bool irq) { *this += mMakeVifCode(itops, Unused, Vifs::Opcodes::itop, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::Stmod(tU32 mode, bool irq) +CVifSCDmaPacket::Stmod(uint32_t mode, bool irq) { *this += mMakeVifCode(mode, Unused, Vifs::Opcodes::stmod, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::Mskpath3(tU32 mask, bool irq) +CVifSCDmaPacket::Mskpath3(uint32_t mask, bool irq) { *this += mMakeVifCode(mask, Unused, Vifs::Opcodes::mskpath3, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::Mark(tU32 value, bool irq) +CVifSCDmaPacket::Mark(uint32_t value, bool irq) { *this += mMakeVifCode(value, Unused, Vifs::Opcodes::mark, irq); return *this; @@ -637,7 +637,7 @@ CVifSCDmaPacket::Flusha(bool irq) } inline CVifSCDmaPacket& -CVifSCDmaPacket::Mscal(tU32 addr, bool irq) +CVifSCDmaPacket::Mscal(uint32_t addr, bool irq) { *this += mMakeVifCode(addr, Unused, Vifs::Opcodes::mscal, irq); return *this; @@ -651,7 +651,7 @@ CVifSCDmaPacket::Mscnt(bool irq) } inline CVifSCDmaPacket& -CVifSCDmaPacket::Mscalf(tU32 addr, bool irq) +CVifSCDmaPacket::Mscalf(uint32_t addr, bool irq) { *this += mMakeVifCode(addr, Unused, Vifs::Opcodes::mscalf, irq); return *this; @@ -668,7 +668,7 @@ CVifSCDmaPacket::Stmask(Vifs::tMask mask, bool irq) inline CVifSCDmaPacket& CVifSCDmaPacket::Strow(const void* rowArray, bool irq) { - const tU32* wordArray = (const tU32*)rowArray; + const uint32_t* wordArray = (const uint32_t*)rowArray; *this += mMakeVifCode(Unused, Unused, Vifs::Opcodes::strow, irq); *this += wordArray[0]; *this += wordArray[1]; @@ -680,7 +680,7 @@ CVifSCDmaPacket::Strow(const void* rowArray, bool irq) inline CVifSCDmaPacket& CVifSCDmaPacket::Stcol(const void* colArray, bool irq) { - const tU32* wordArray = (const tU32*)colArray; + const uint32_t* wordArray = (const uint32_t*)colArray; *this += mMakeVifCode(Unused, Unused, Vifs::Opcodes::stcol, irq); *this += wordArray[0]; *this += wordArray[1]; @@ -690,28 +690,28 @@ CVifSCDmaPacket::Stcol(const void* colArray, bool irq) } inline CVifSCDmaPacket& -CVifSCDmaPacket::Mpg(tU32 num, tU32 addr, bool irq) +CVifSCDmaPacket::Mpg(uint32_t num, uint32_t addr, bool irq) { *this += mMakeVifCode(addr, num, Vifs::Opcodes::mpg, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::OpenUnpack(tU32 mode, tU32 vuAddr, bool dblBuffered, bool masked, bool usigned, bool irq) +CVifSCDmaPacket::OpenUnpack(uint32_t mode, uint32_t vuAddr, bool dblBuffered, bool masked, bool usigned, bool irq) { mErrorIf(pOpenVifCode != NULL, "There is still another vifcode open."); pOpenVifCode = (Vifs::tVifCode*)pNext; - *this += mMakeVifCode(vuAddr | ((tU32)usigned << 14) | ((tU32)dblBuffered << 15), + *this += mMakeVifCode(vuAddr | ((uint32_t)usigned << 14) | ((uint32_t)dblBuffered << 15), 0, - mode | ((tU32)masked << 4) | 0x60, irq); + mode | ((uint32_t)masked << 4) | 0x60, irq); return *this; } inline CVifSCDmaPacket& -CVifSCDmaPacket::CloseUnpack(tU32 unpackNUM) +CVifSCDmaPacket::CloseUnpack(uint32_t unpackNUM) { // make sure we're u32 aligned and a vifcode is open and it's an unpack - mAssert(((tU32)pNext & 0x3) == 0 && pOpenVifCode && ((pOpenVifCode->cmd & 0x60) == 0x60)); + mAssert(((uint32_t)pNext & 0x3) == 0 && pOpenVifCode && ((pOpenVifCode->cmd & 0x60) == 0x60)); mAssert(unpackNUM <= 256); pOpenVifCode->num = (unpackNUM == 256) ? 0 : unpackNUM; pOpenVifCode = NULL; @@ -719,7 +719,7 @@ CVifSCDmaPacket::CloseUnpack(tU32 unpackNUM) } inline CVifSCDmaPacket& -CVifSCDmaPacket::CloseUnpack(tU32 wl, tU32 cl) +CVifSCDmaPacket::CloseUnpack(uint32_t wl, uint32_t cl) { uiWL = wl; uiCL = cl; @@ -736,9 +736,9 @@ CVifSCDmaPacket::OpenDirect(bool irq) } inline CVifSCDmaPacket& -CVifSCDmaPacket::CloseDirect(tU32 numQuads) +CVifSCDmaPacket::CloseDirect(uint32_t numQuads) { - mAssert(pOpenVifCode != NULL && (((tU32)pNext - ((tU32)pOpenVifCode + 4)) & 0xf) == 0); + mAssert(pOpenVifCode != NULL && (((uint32_t)pNext - ((uint32_t)pOpenVifCode + 4)) & 0xf) == 0); pOpenVifCode->immediate = numQuads; pOpenVifCode = NULL; return *this; @@ -747,7 +747,7 @@ CVifSCDmaPacket::CloseDirect(tU32 numQuads) inline CVifSCDmaPacket& CVifSCDmaPacket::CloseDirect(void) { - return CloseDirect(((tU32)pNext - ((tU32)pOpenVifCode + 4)) / 16); + return CloseDirect(((uint32_t)pNext - ((uint32_t)pOpenVifCode + 4)) / 16); } inline CVifSCDmaPacket& diff --git a/include/ps2s/perfmon.h b/include/ps2s/perfmon.h index 5e84130..4847cbd 100644 --- a/include/ps2s/perfmon.h +++ b/include/ps2s/perfmon.h @@ -41,11 +41,11 @@ class PerfTest { #define PERF_WBB_BURST_REQUEST_FULL 26 private: - static const tU32 NUM_PRF_TESTS = 27; + static const uint32_t NUM_PRF_TESTS = 27; typedef struct prfDef { - tU32 cnt_id; - tU32 cnt_val; + uint32_t cnt_id; + uint32_t cnt_val; } prfDef; public: @@ -93,7 +93,7 @@ class PerfTest { static prfDef prfTable[NUM_PRF_TESTS]; int m_Prev_testVals[NUM_PRF_TESTS]; int m_testVals[NUM_PRF_TESTS]; - int GetNextTestID(tU32 counter_id, tU32 ctest); + int GetNextTestID(uint32_t counter_id, uint32_t ctest); void StepTests(); }; diff --git a/include/ps2s/sprite.h b/include/ps2s/sprite.h index 794cecb..d4a33b3 100644 --- a/include/ps2s/sprite.h +++ b/include/ps2s/sprite.h @@ -21,7 +21,7 @@ */ typedef union { - tU32 uv[4]; + uint32_t uv[4]; float stq[4]; } tTexCoords; @@ -31,7 +31,7 @@ typedef union { class CSprite { public: - CSprite(GS::tContext context, tU32 minX, tU32 minY, tU32 width, tU32 height); + CSprite(GS::tContext context, uint32_t minX, uint32_t minY, uint32_t width, uint32_t height); void Draw(bool waitForEnd = false, bool flushCache = true) { @@ -40,15 +40,15 @@ class CSprite { void Draw(CSCDmaPacket& packet); void Draw(CVifSCDmaPacket& packet); - void SetColor(tU32 r, tU32 g, tU32 b, tU32 a, tU8 fog = 255) + void SetColor(uint32_t r, uint32_t g, uint32_t b, uint32_t a, uint8_t fog = 255) { Color[0] = r; Color[1] = g; Color[2] = b; Color[3] = a; - Vertex2[3] = (tU32)fog << 4; + Vertex2[3] = (uint32_t)fog << 4; } - void SetColor(tU32 rgba) + void SetColor(uint32_t rgba) { Color[0] = 0xff & rgba; Color[1] = (0xff00 & rgba) >> 8; @@ -56,19 +56,19 @@ class CSprite { Color[3] = (0xff000000 & rgba) >> 24; } - void SetDepth(tU32 depth) { Vertex1[2] = Vertex2[2] = depth; } + void SetDepth(uint32_t depth) { Vertex1[2] = Vertex2[2] = depth; } void SetSTQs(float minS, float minT, float width, float height); void SetUVs(float minU, float minV, float width, float height); - void SetUVs(tU16 minU, tU16 minV, tU16 width, tU16 height); - void SetUVs(t32 minU, t32 minV, t32 width, t32 height) + void SetUVs(uint16_t minU, uint16_t minV, uint16_t width, uint16_t height); + void SetUVs(int32_t minU, int32_t minV, int32_t width, int32_t height) { - SetUVs((tU16)minU, (tU16)minV, (tU16)width, (tU16)height); + SetUVs((uint16_t)minU, (uint16_t)minV, (uint16_t)width, (uint16_t)height); } - void SetUVsFix4(tU16 minU, tU16 minV, tU16 maxU, tU16 maxV); + void SetUVsFix4(uint16_t minU, uint16_t minV, uint16_t maxU, uint16_t maxV); - void SetVertices(tU32 minX, tU32 minY, tU32 width, tU32 height) + void SetVertices(uint32_t minX, uint32_t minY, uint32_t width, uint32_t height) { Vertex1[0] = minX << 4; Vertex1[1] = minY << 4; @@ -90,11 +90,11 @@ class CSprite { struct { // GIF tag + 5 qwords data tGifTag DrawGifTag; - tU32 Color[4]; + uint32_t Color[4]; tTexCoords TexCoords1; - tU32 Vertex1[4]; + uint32_t Vertex1[4]; tTexCoords TexCoords2; - tU32 Vertex2[4]; + uint32_t Vertex2[4]; } __attribute__((packed,aligned(16))); CDmaPacket GifPacket; @@ -109,9 +109,9 @@ inline CSprite& CSprite::SetUseAlphaBlend(bool useAlpha) { if (useAlpha) - DrawGifTag.PRIM |= (tU64)1 << 6; // abe + DrawGifTag.PRIM |= (uint64_t)1 << 6; // abe else - DrawGifTag.PRIM &= ~((tU64)1 << 6); + DrawGifTag.PRIM &= ~((uint64_t)1 << 6); return *this; } @@ -120,9 +120,9 @@ inline CSprite& CSprite::SetUseTexture(bool useTex) { if (useTex) - DrawGifTag.PRIM |= (tU64)1 << 4; // tme + DrawGifTag.PRIM |= (uint64_t)1 << 4; // tme else - DrawGifTag.PRIM &= ~((tU64)1 << 4); + DrawGifTag.PRIM &= ~((uint64_t)1 << 4); return *this; } @@ -131,9 +131,9 @@ inline CSprite& CSprite::SetUseFog(bool useFog) { if (useFog) - DrawGifTag.PRIM |= (tU64)1 << 5; // fge + DrawGifTag.PRIM |= (uint64_t)1 << 5; // fge else - DrawGifTag.PRIM &= ~((tU64)1 << 5); + DrawGifTag.PRIM &= ~((uint64_t)1 << 5); return *this; } diff --git a/include/ps2s/texture.h b/include/ps2s/texture.h index f57a962..b1d8ea8 100644 --- a/include/ps2s/texture.h +++ b/include/ps2s/texture.h @@ -75,32 +75,32 @@ class CTexEnv { public: // if you must use the short constructor, be sure to call SetDimensions() and SetPSM()!! CTexEnv(GS::tContext context = GS::kContext1); - CTexEnv(GS::tContext context, tU32 width, tU32 height, GS::tPSM psm); + CTexEnv(GS::tContext context, uint32_t width, uint32_t height, GS::tPSM psm); virtual ~CTexEnv(void) {} // accessors - inline tU32 GetImageGsAddr(void) const { return gsrTex0.tb_addr * 64; } - inline tU32 GetClutGsAddr(void) const { return gsrTex0.cb_addr * 64; } + inline uint32_t GetImageGsAddr(void) const { return gsrTex0.tb_addr * 64; } + inline uint32_t GetClutGsAddr(void) const { return gsrTex0.cb_addr * 64; } inline GS::tContext GetContext(void) const; inline GS::tPSM GetPSM(void) const { return (GS::tPSM)gsrTex0.psm; } - inline tU32 GetW(void) const { return uiTexPixelWidth; } - inline tU32 GetH(void) const { return uiTexPixelHeight; } + inline uint32_t GetW(void) const { return uiTexPixelWidth; } + inline uint32_t GetH(void) const { return uiTexPixelHeight; } // mutators inline void ClearRegion(void); inline void SetClutLoadConditions(int mode) { gsrTex0.clut_loadmode = mode; } - virtual void SetClutGsAddr(tU32 gsMemWordAddress); + virtual void SetClutGsAddr(uint32_t gsMemWordAddress); void SetContext(GS::tContext context); - virtual void SetDimensions(tU32 w, tU32 h); + virtual void SetDimensions(uint32_t w, uint32_t h); inline void SetFlush(bool flush); - virtual void SetImageGsAddr(tU32 gsMemWordAddress); - inline void SetMagMode(tMagMode newMode) { gsrTex1.mmag = (tU64)newMode; } - inline void SetMinMode(tMinMode newMode) { gsrTex1.mmin = (tU64)newMode; } + virtual void SetImageGsAddr(uint32_t gsMemWordAddress); + inline void SetMagMode(tMagMode newMode) { gsrTex1.mmag = (uint64_t)newMode; } + inline void SetMinMode(tMinMode newMode) { gsrTex1.mmin = (uint64_t)newMode; } void SetPSM(GS::tPSM newPSM); - void SetRegion(tU32 originU, tU32 originV, tU32 w, tU32 h); - inline void SetTexMode(tTexMode newMode) { gsrTex0.tex_funtion = (tU64)newMode; } + void SetRegion(uint32_t originU, uint32_t originV, uint32_t w, uint32_t h); + inline void SetTexMode(tTexMode newMode) { gsrTex0.tex_funtion = (uint64_t)newMode; } void SetWrapModeS(tTexWrapMode sMode); void SetWrapModeT(tTexWrapMode tMode); inline void SetWrapMode(tTexWrapMode sMode, tTexWrapMode tMode) @@ -130,19 +130,19 @@ class CTexEnv { tSourceChainTag SettingsDmaTag; tGifTag SettingsGifTag; GS::tTexflush gsrTexflush; - tU64 TexflushAddr; + uint64_t TexflushAddr; GS::tClamp gsrClamp; - tU64 ClampAddr; + uint64_t ClampAddr; GS::tTex1 gsrTex1; - tU64 Tex1Addr; + uint64_t Tex1Addr; GS::tTex0 gsrTex0; - tU64 Tex0Addr; + uint64_t Tex0Addr; GS::tTexa gsrTexA; - tU64 TexAAddr; + uint64_t TexAAddr; } __attribute__((packed,aligned(16))); - tU32 uiNumSettingsGSRegs; - tU32 uiTexPixelWidth, uiTexPixelHeight; + uint32_t uiNumSettingsGSRegs; + uint32_t uiTexPixelWidth, uiTexPixelHeight; CSCDmaPacket SettingsPacket; @@ -166,8 +166,8 @@ class CTexture : public CTexEnv { public: // mutators - virtual void SetImageGsAddr(tU32 gsMemWordAddress); - virtual void SetClutGsAddr(tU32 gsMemWordAddress); + virtual void SetImageGsAddr(uint32_t gsMemWordAddress); + virtual void SetClutGsAddr(uint32_t gsMemWordAddress); // other @@ -180,8 +180,8 @@ class CTexture : public CTexEnv { void SendClut(CVifSCDmaPacket& packet); protected: - tU128 *pImage, *pClut; - tU32 uiGsAddr; + uint128_t *pImage, *pClut; + uint32_t uiGsAddr; CImageUploadPkt* pImageUploadPkt; CClutUploadPkt* pClutUploadPkt; @@ -190,8 +190,8 @@ class CTexture : public CTexEnv { CTexture(GS::tContext context); virtual ~CTexture(void); - tU128* AllocMem(tU32 w, tU32 h, GS::tPSM psm); - virtual void SetImage(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm, tU32* clutPtr = NULL); + uint128_t* AllocMem(uint32_t w, uint32_t h, GS::tPSM psm); + virtual void SetImage(uint128_t* imagePtr, uint32_t w, uint32_t h, GS::tPSM psm, uint32_t* clutPtr = NULL); void Reset(); @@ -240,13 +240,13 @@ class CClut { class CCheckTex : public CTexture { public: CCheckTex(GS::tContext context, - tU32 width, tU32 height, - tU32 xCellSize, tU32 yCellSize, - tU32 color1, tU32 color2); + uint32_t width, uint32_t height, + uint32_t xCellSize, uint32_t yCellSize, + uint32_t color1, uint32_t color2); virtual ~CCheckTex(void) {} private: - void MakeCheckerboard(tU32 xCellSize, tU32 yCellSize, tU32 color1, tU32 color2); + void MakeCheckerboard(uint32_t xCellSize, uint32_t yCellSize, uint32_t color1, uint32_t color2); }; /******************************************** diff --git a/include/ps2s/types.h b/include/ps2s/types.h index d877740..9c33cb6 100644 --- a/include/ps2s/types.h +++ b/include/ps2s/types.h @@ -7,29 +7,15 @@ #ifndef ps2s_types_h #define ps2s_types_h -#ifdef __cplusplus - -typedef unsigned char tU8; -typedef unsigned short int tU16; -typedef unsigned int tU32; -typedef unsigned long long tU64; -// it doesn't really make sense to have a non-16-byte-aligned qword type... -typedef unsigned int tU128 __attribute__((mode(TI), aligned(16))); +#include +#include -typedef char t8; -typedef short int t16; -typedef int t32; -typedef long long t64; -typedef int t128 __attribute__((mode(TI), aligned(16))); +#ifdef __cplusplus -typedef struct { - tU16 whole : 12; - tU16 frac : 4; -} tFix12_4; +// Custom 128-bit types (16-byte aligned) - not available in stdint.h +typedef unsigned int uint128_t __attribute__((mode(TI), aligned(16))); +typedef int int128_t __attribute__((mode(TI), aligned(16))); #endif // __cplusplus -// this needs to stay outside of the namespace for C routines.. -typedef int tBool; - #endif // ps2s_types_h diff --git a/include/ps2s/utils.h b/include/ps2s/utils.h index 12051b3..6dcf98a 100644 --- a/include/ps2s/utils.h +++ b/include/ps2s/utils.h @@ -16,11 +16,11 @@ */ namespace Utils { -inline void MemCpy128(tU128* dest, const tU128* src, tU32 numQwords); +inline void MemCpy128(uint128_t* dest, const uint128_t* src, uint32_t numQwords); -inline void QwordHexDump(tU32* mem, tU32 numQwords); -inline void QwordDecDump(tU32* mem, tU32 numQwords); -inline void QwordFloatDump(float* mem, tU32 numQwords); +inline void QwordHexDump(uint32_t* mem, uint32_t numQwords); +inline void QwordDecDump(uint32_t* mem, uint32_t numQwords); +inline void QwordFloatDump(float* mem, uint32_t numQwords); } /******************************************** @@ -28,35 +28,35 @@ inline void QwordFloatDump(float* mem, tU32 numQwords); */ inline void -Utils::MemCpy128(tU128* dest, const tU128* src, tU32 numQwords) +Utils::MemCpy128(uint128_t* dest, const uint128_t* src, uint32_t numQwords) { - mAssert(((tU32)dest & 0xf) == 0 && ((tU32)src & 0xf) == 0); + mAssert(((uint32_t)dest & 0xf) == 0 && ((uint32_t)src & 0xf) == 0); while (numQwords-- > 0) *(dest++) = *(src++); } inline void -Utils::QwordHexDump(tU32* mem, tU32 numQwords) +Utils::QwordHexDump(uint32_t* mem, uint32_t numQwords) { - tU32 i; + uint32_t i; for (i = 0; i < numQwords; i++, mem += 4) - printf("%08x: 0x%08x 0x%08x 0x%08x 0x%08x\n", (tU32)mem, mem[0], mem[1], mem[2], mem[3]); + printf("%08lx: 0x%08lx 0x%08lx 0x%08lx 0x%08lx\n", (uint32_t)mem, mem[0], mem[1], mem[2], mem[3]); } inline void -Utils::QwordDecDump(tU32* mem, tU32 numQwords) +Utils::QwordDecDump(uint32_t* mem, uint32_t numQwords) { - tU32 i; + uint32_t i; for (i = 0; i < numQwords; i++, mem += 4) - printf("%08x: %d %d %d %d\n", (tU32)mem, mem[0], mem[1], mem[2], mem[3]); + printf("%08lx: %ld %ld %ld %ld\n", (uint32_t)mem, mem[0], mem[1], mem[2], mem[3]); } inline void -Utils::QwordFloatDump(float* mem, tU32 numQwords) +Utils::QwordFloatDump(float* mem, uint32_t numQwords) { - tU32 i; + uint32_t i; for (i = 0; i < numQwords; i++, mem += 4) - printf("%08x: %f %f %f %f\n", (tU32)mem, mem[0], mem[1], mem[2], mem[3]); + printf("%08lx: %f %f %f %f\n", (uint32_t)mem, mem[0], mem[1], mem[2], mem[3]); } #endif // ps2s_utils_h diff --git a/include/ps2s/vif.h b/include/ps2s/vif.h index f967994..4786c33 100644 --- a/include/ps2s/vif.h +++ b/include/ps2s/vif.h @@ -16,7 +16,7 @@ namespace Vifs { */ namespace Opcodes { - static const tU32 nop = 0, + static const uint32_t nop = 0, stcycl = 1, offset = 2, base = 3, @@ -39,7 +39,7 @@ namespace Opcodes { } namespace UnpackModes { - static const tU32 s_32 = 0, + static const uint32_t s_32 = 0, s_16 = 1, s_8 = 2, v2_32 = 4, @@ -55,7 +55,7 @@ namespace UnpackModes { } namespace AddModes { - static const tU32 kNone = 0, + static const uint32_t kNone = 0, kOffset = 1, kAccumulate = 2; } @@ -65,9 +65,9 @@ namespace AddModes { */ typedef struct { - tU32 immediate : 16; - tU32 num : 8; - tU32 cmd : 8; + uint32_t immediate : 16; + uint32_t num : 8; + uint32_t cmd : 8; } tVifCode; typedef struct { diff --git a/include/ps2s/vu.h b/include/ps2s/vu.h index e775854..460d4c9 100644 --- a/include/ps2s/vu.h +++ b/include/ps2s/vu.h @@ -22,10 +22,10 @@ namespace VUs { */ namespace VU0 { -inline void CopyQwordsToVU0(tU32 vu0QwordOffset, tU128* mainMemSrc, tU32 numQwords); -inline void CopyEvenQwordsToVU0(tU32 vu0QwordOffset, tU128* mainMemSrc, tU32 numQwords); -inline void CopyQwordsFromVU0(tU128* mainMemDest, tU32 vu0QwordOffset, tU32 numQwords); -inline void CopyEvenQwordsFromVU0(tU128* mainMemDest, tU32 vu0QwordOffset, tU32 numQwords); +inline void CopyQwordsToVU0(uint32_t vu0QwordOffset, uint128_t* mainMemSrc, uint32_t numQwords); +inline void CopyEvenQwordsToVU0(uint32_t vu0QwordOffset, uint128_t* mainMemSrc, uint32_t numQwords); +inline void CopyQwordsFromVU0(uint128_t* mainMemDest, uint32_t vu0QwordOffset, uint32_t numQwords); +inline void CopyEvenQwordsFromVU0(uint128_t* mainMemDest, uint32_t vu0QwordOffset, uint32_t numQwords); } /******************************************** @@ -39,9 +39,9 @@ namespace VU1 { * VU0 inlines */ -void VU0::CopyQwordsToVU0(tU32 vu0QwordOffset, tU128* mainMemSrc, tU32 numQwords) +void VU0::CopyQwordsToVU0(uint32_t vu0QwordOffset, uint128_t* mainMemSrc, uint32_t numQwords) { - mAssert(((tU32)mainMemSrc & 0xf) == 0); + mAssert(((uint32_t)mainMemSrc & 0xf) == 0); asm volatile(" .set noreorder @@ -59,9 +59,9 @@ void VU0::CopyQwordsToVU0(tU32 vu0QwordOffset, tU128* mainMemSrc, tU32 numQwords : "cc", "$8"); } -void VU0::CopyEvenQwordsToVU0(tU32 vu0QwordOffset, tU128* mainMemSrc, tU32 numQwords) +void VU0::CopyEvenQwordsToVU0(uint32_t vu0QwordOffset, uint128_t* mainMemSrc, uint32_t numQwords) { - mAssert(((tU32)mainMemSrc & 0xf) == 0); + mAssert(((uint32_t)mainMemSrc & 0xf) == 0); mErrorIf(numQwords & 1, "numQwords must be EVEN!"); asm volatile(" @@ -83,9 +83,9 @@ void VU0::CopyEvenQwordsToVU0(tU32 vu0QwordOffset, tU128* mainMemSrc, tU32 numQw : "cc", "$8"); } -void VU0::CopyQwordsFromVU0(tU128* mainMemDest, tU32 vu0QwordOffset, tU32 numQwords) +void VU0::CopyQwordsFromVU0(uint128_t* mainMemDest, uint32_t vu0QwordOffset, uint32_t numQwords) { - mAssert(((tU32)mainMemDest & 0xf) == 0); + mAssert(((uint32_t)mainMemDest & 0xf) == 0); asm volatile(" .set noreorder @@ -107,9 +107,9 @@ void VU0::CopyQwordsFromVU0(tU128* mainMemDest, tU32 vu0QwordOffset, tU32 numQwo : "$8", "cc", "memory"); } -void VU0::CopyEvenQwordsFromVU0(tU128* mainMemDest, tU32 vu0QwordOffset, tU32 numQwords) +void VU0::CopyEvenQwordsFromVU0(uint128_t* mainMemDest, uint32_t vu0QwordOffset, uint32_t numQwords) { - mAssert(((tU32)mainMemDest & 0xf) == 0); + mAssert(((uint32_t)mainMemDest & 0xf) == 0); mErrorIf(numQwords & 1, "numQwords must be EVEN!"); asm volatile(" diff --git a/src/core.cpp b/src/core.cpp index 041b25c..590cd20 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -48,7 +48,7 @@ const char* ev1_Name[COP0_NUM_PERF_EVENTS] = { "PRFEVT_1_NO_EVENT" }; -void SetupPerfCounters(tU32 evt_0, tU32 evt_1) +void SetupPerfCounters(uint32_t evt_0, uint32_t evt_1) { asm __volatile__( diff --git a/src/displayenv.cpp b/src/displayenv.cpp index 06836dc..e0ec908 100644 --- a/src/displayenv.cpp +++ b/src/displayenv.cpp @@ -21,7 +21,7 @@ namespace GS { CDisplayEnv::CDisplayEnv(void) { - *(tU64*)&gsrPMode = (tU64)0; + *(uint64_t*)&gsrPMode = (uint64_t)0; gsrPMode.CRTMD = 0; @@ -81,12 +81,12 @@ void CDisplayEnv::SetDisplay(tGsrDisplay* displayReg, void CDisplayEnv::SendSettings(void) { using namespace GS::ControlRegs; - *(tU64*)pmode = *(tU64*)&gsrPMode; - *(tU64*)dispfb1 = *(tU64*)&gsrDispFB1; - *(tU64*)dispfb2 = *(tU64*)&gsrDispFB2; - *(tU64*)display1 = *(tU64*)&gsrDisplay1; - *(tU64*)display2 = *(tU64*)&gsrDisplay2; - *(tU64*)bgcolor = *(tU64*)&gsrBGColor; + *(uint64_t*)pmode = *(uint64_t*)&gsrPMode; + *(uint64_t*)dispfb1 = *(uint64_t*)&gsrDispFB1; + *(uint64_t*)dispfb2 = *(uint64_t*)&gsrDispFB2; + *(uint64_t*)display1 = *(uint64_t*)&gsrDisplay1; + *(uint64_t*)display2 = *(uint64_t*)&gsrDisplay2; + *(uint64_t*)bgcolor = *(uint64_t*)&gsrBGColor; } } // namespace GS diff --git a/src/drawenv.cpp b/src/drawenv.cpp index 32b42a0..3dc9b5c 100644 --- a/src/drawenv.cpp +++ b/src/drawenv.cpp @@ -24,21 +24,21 @@ namespace GS { CDrawEnv::CDrawEnv(GS::tContext context) : uiNumGSRegs(13) - , GifPacket((tU128*)&SettingsDmaTag, uiNumGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) + , GifPacket((uint128_t*)&SettingsDmaTag, uiNumGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) { InitCommon(context); } CDrawEnv::CDrawEnv(const CDrawEnv& rhs) : uiNumGSRegs(13) - , GifPacket((tU128*)&SettingsDmaTag, uiNumGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) + , GifPacket((uint128_t*)&SettingsDmaTag, uiNumGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) { *this = rhs; } -CDrawEnv::CDrawEnv(GS::tContext context, tU32 fbW, tU32 fbH, tU32 fbWordAddr, tU32 zbufWordAddr) +CDrawEnv::CDrawEnv(GS::tContext context, uint32_t fbW, uint32_t fbH, uint32_t fbWordAddr, uint32_t zbufWordAddr) : uiNumGSRegs(13) - , GifPacket((tU128*)&SettingsDmaTag, uiNumGSRegs + 2, DMAC::Channels::gif, Core::MemMappings::Normal, Packet::kFull) + , GifPacket((uint128_t*)&SettingsDmaTag, uiNumGSRegs + 2, DMAC::Channels::gif, Core::MemMappings::Normal, Packet::kFull) { InitCommon(context); @@ -144,10 +144,10 @@ void CDrawEnv::InitCommon(GS::tContext context) gsrTest.datest_enable = 0; // disable destination alpha test gsrTest.datest_mode = 0; // 0 = pass gsrTest.ztest_enable = 1; // enable z-test - gsrTest.ztest_method = (tU64)eZTestPassMode; + gsrTest.ztest_method = (uint64_t)eZTestPassMode; // make sure things are qword aligned (I don't trust the compiler...) - mAssert(((tU32)&SettingsGifTag & 0xf) == 0); + mAssert(((uint32_t)&SettingsGifTag & 0xf) == 0); } void CDrawEnv::CalculateClippedFBXYOffsets(bool addHalfPixel) @@ -162,8 +162,8 @@ void CDrawEnv::CalculateClippedFBXYOffsets(bool addHalfPixel) if (addHalfPixel) gsOffsetY += InterlacedOffset; - gsrXYOffset.offset_x = (tU16)Core::FToI4(gsOffsetX); - gsrXYOffset.offset_y = (tU16)Core::FToI4(gsOffsetY); + gsrXYOffset.offset_x = (uint16_t)Core::FToI4(gsOffsetX); + gsrXYOffset.offset_y = (uint16_t)Core::FToI4(gsOffsetY); } void CDrawEnv::SendSettings(bool waitForEnd, bool flushCache) @@ -206,7 +206,7 @@ void CDrawEnv::SendSettings(CVifSCDmaPacket& packet) packet.CloseTag(); } -void CDrawEnv::SetFrameBufferDim(tU32 pixelW, tU32 pixelH) +void CDrawEnv::SetFrameBufferDim(uint32_t pixelW, uint32_t pixelH) { // width must be a multiple of 64 if (pixelW < 64) @@ -225,7 +225,7 @@ void CDrawEnv::SetFrameBufferDim(tU32 pixelW, tU32 pixelH) void CDrawEnv::operator=(const CDrawEnv& otherDE) { - Utils::MemCpy128((tU128*)&SettingsGifTag, (tU128*)&otherDE.SettingsGifTag, uiNumGSRegs + 2); + Utils::MemCpy128((uint128_t*)&SettingsGifTag, (uint128_t*)&otherDE.SettingsGifTag, uiNumGSRegs + 2); eZTestPassMode = otherDE.eZTestPassMode; uiFBWidth = otherDE.uiFBWidth; uiFBHeight = otherDE.uiFBHeight; diff --git a/src/gs.cpp b/src/gs.cpp index 6685ee9..d43b5ea 100644 --- a/src/gs.cpp +++ b/src/gs.cpp @@ -15,8 +15,8 @@ namespace GS { typedef struct { tGifTag gt; - tU64 texFlush; - tU64 texFlushAddr; + uint64_t texFlush; + uint64_t texFlushAddr; } __attribute__((packed,aligned(16))) tFlushPkt; static tFlushPkt FlushPkt; @@ -46,36 +46,36 @@ void Flush(void) gifTag.NREG = 1; gifTag.REGS0 = 0xe; // PLIN - *GIF::Registers::fifo = *(tU128*)&gifTag; + *GIF::Registers::fifo = *(uint128_t*)&gifTag; struct { - tU64 data; - tU64 addr; + uint64_t data; + uint64_t addr; } texFlush; texFlush.addr = GS::RegAddrs::texflush; // PLIN - *GIF::Registers::fifo = *(tU128*)&texFlush; + *GIF::Registers::fifo = *(uint128_t*)&texFlush; } void Flush(CSCDmaPacket& packet) { packet.Cnt(); - packet.Add((tU128*)&FlushPkt, 2); + packet.Add((uint128_t*)&FlushPkt, 2); packet.CloseTag(); } -void ReorderClut(tU32* oldClut, tU32* newClut) +void ReorderClut(uint32_t* oldClut, uint32_t* newClut) { // make sure both are qword aligned - mAssert(((tU32)oldClut & 0xf) == 0 && ((tU32)newClut & 0xf) == 0); + mAssert(((uint32_t)oldClut & 0xf) == 0 && ((uint32_t)newClut & 0xf) == 0); // oldClut and newClut can't be the same mAssert(oldClut != newClut); - tU128* curNewEntry = (tU128*)newClut; - tU128* oldEntry1 = (tU128*)oldClut; - tU128* oldEntry2 = (tU128*)oldClut + 4; + uint128_t* curNewEntry = (uint128_t*)newClut; + uint128_t* oldEntry1 = (uint128_t*)oldClut; + uint128_t* oldEntry2 = (uint128_t*)oldClut + 4; - tU32 i; + uint32_t i; for (i = 0; i < 8; i++) { *curNewEntry++ = *oldEntry1++; *curNewEntry++ = *oldEntry1++; diff --git a/src/imagepackets.cpp b/src/imagepackets.cpp index 8fc5f65..2d23030 100644 --- a/src/imagepackets.cpp +++ b/src/imagepackets.cpp @@ -21,7 +21,7 @@ CImageUploadPkt::CImageUploadPkt(void) InitCommon(); } -CImageUploadPkt::CImageUploadPkt(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm, tU32 gsBufWidth, tU32 gsWordAddress) +CImageUploadPkt::CImageUploadPkt(uint128_t* imagePtr, uint32_t w, uint32_t h, GS::tPSM psm, uint32_t gsBufWidth, uint32_t gsWordAddress) : CVifSCDmaPacket(&FirstDmaTag, kPacketLength, DMAC::Channels::gif, Packet::kDontXferTags) { InitCommon(); @@ -99,26 +99,26 @@ void CImageUploadPkt::BuildXferTags(void) imageDataGifTag.NLOOP = 0; mAssert(pImage != NULL); - tU128* image = pImage; + uint128_t* image = pImage; bool imageOnSP = false; // is the image on the scratchpad? - imageOnSP = ((tU32)pImage & 0x70000000); + imageOnSP = ((uint32_t)pImage & 0x70000000); if (imageOnSP) { - image = (tU128*)((tU32)image & 0x3ff0); + image = (uint128_t*)((uint32_t)image & 0x3ff0); } - tU32 width = gsrTrxReg.trans_w, height = gsrTrxReg.trans_h; - tU32 bytesInImage = width * height * GS::GetBitsPerPixel((GS::tPSM)gsrBitBltBuf.dest_pixmode) / 8; + uint32_t width = gsrTrxReg.trans_w, height = gsrTrxReg.trans_h; + uint32_t bytesInImage = width * height * GS::GetBitsPerPixel((GS::tPSM)gsrBitBltBuf.dest_pixmode) / 8; - tU32 numQuadsInImage = ((bytesInImage & 0xf) == 0) ? bytesInImage / 16 : bytesInImage / 16 + 1; - tU32 numQuadsLeft = numQuadsInImage; - const tU32 maxQuadsPerGT = (1 << 15) - 1; // limited by the NLOOP field + uint32_t numQuadsInImage = ((bytesInImage & 0xf) == 0) ? bytesInImage / 16 : bytesInImage / 16 + 1; + uint32_t numQuadsLeft = numQuadsInImage; + const uint32_t maxQuadsPerGT = (1 << 15) - 1; // limited by the NLOOP field while (numQuadsLeft > 0) { // set up giftag - tU32 numQuadsThisGT = Math::Min(numQuadsLeft, maxQuadsPerGT); + uint32_t numQuadsThisGT = Math::Min(numQuadsLeft, maxQuadsPerGT); imageDataGifTag.NLOOP = numQuadsThisGT; imageDataGifTag.EOP = (numQuadsThisGT == numQuadsLeft) ? 1 : 0; @@ -148,7 +148,7 @@ void CImageUploadPkt::Send(CSCDmaPacket& packet) { mErrorIf(packet.GetTTE(), "Only vif source chain packets can use this class to xfer images with tte on."); - tU128* thisPktCopy = packet.Add((CDmaPacket&)*this); + uint128_t* thisPktCopy = packet.Add((CDmaPacket&)*this); // change the last refe in the copy to a ref tSourceChainTag* lastRefe = reinterpret_cast(thisPktCopy + this->GetByteLength() / 16 - 1); @@ -160,7 +160,7 @@ void CImageUploadPkt::Send(CVifSCDmaPacket& packet) { mErrorIf(!packet.GetTTE(), "Vif source chains need to turn tte on to xfer images with this class."); - tU128* thisPktCopy = packet.Add((CDmaPacket&)*this); + uint128_t* thisPktCopy = packet.Add((CDmaPacket&)*this); // change the last refe in the copy to a ref tSourceChainTag* lastRefe = reinterpret_cast(thisPktCopy + this->GetByteLength() / 16 - 1); diff --git a/src/packet.cpp b/src/packet.cpp index a20060a..5c7cb1d 100644 --- a/src/packet.cpp +++ b/src/packet.cpp @@ -21,21 +21,21 @@ * DmaPacket */ -CDmaPacket::CDmaPacket(tU128* buffer, tU32 bufferQWSize, tDmaChannelId channel, tU32 memMapping, bool isFull) - : pBase((tU8*)buffer) - , pNext((tU8*)((isFull) ? buffer + bufferQWSize : buffer)) +CDmaPacket::CDmaPacket(uint128_t* buffer, uint32_t bufferQWSize, tDmaChannelId channel, uint32_t memMapping, bool isFull) + : pBase((uint8_t*)buffer) + , pNext((uint8_t*)((isFull) ? buffer + bufferQWSize : buffer)) , dmaChannelId(channel) , uiBufferQwordSize(bufferQWSize) , bDeallocateBuffer(false) { // PLIN - mErrorIf(memMapping == Core::MemMappings::Uncached || ((memMapping == Core::MemMappings::UncachedAccl) && ((tU32)buffer & (64 - 1))), + mErrorIf(memMapping == Core::MemMappings::Uncached || ((memMapping == Core::MemMappings::UncachedAccl) && ((uint32_t)buffer & (64 - 1))), "Dma buffer should be aligned on a cache line (64-byte boundary) when using the uncached mem mappings!"); mErrorIf((memMapping == Core::MemMappings::Uncached || memMapping == Core::MemMappings::UncachedAccl) && bufferQWSize & (4 - 1), "Dma buffer size should be a whole number of cache lines (64 bytes = 4 quads) when using the uncached mem mappings!"); } -CDmaPacket::CDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, tU32 memMapping) +CDmaPacket::CDmaPacket(uint32_t bufferQWSize, tDmaChannelId channel, uint32_t memMapping) : dmaChannelId(channel) , uiBufferQwordSize(bufferQWSize) , bDeallocateBuffer(true) @@ -44,7 +44,7 @@ CDmaPacket::CDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, tU32 memMapping mErrorIf((memMapping == Core::MemMappings::Uncached || memMapping == Core::MemMappings::UncachedAccl) && bufferQWSize & (4 - 1), "Dma buffer size should be a whole number of cache lines (64 bytes = 4 quads) when using the uncached mem mappings!"); - pBase = pNext = (tU8*)AllocBuffer(bufferQWSize, memMapping); + pBase = pNext = (uint8_t*)AllocBuffer(bufferQWSize, memMapping); mAssert(pBase != NULL); } @@ -58,8 +58,8 @@ void* CDmaPacket::AllocBuffer(int numQwords, unsigned int memMapping) { // an alignment of 64 bytes is strictly only necessary for uncached or uncached accl mem mappings, but // it ain't a bad idea in general.. - tU32 alignment = 64; - void* mem = (void*)((tU32)memalign(alignment, numQwords * 16) | memMapping); + uint32_t alignment = 64; + void* mem = (void*)((uint32_t)memalign(alignment, numQwords * 16) | memMapping); // I hate to do this, but I've wasted FAR too much time hunting down cache incoherency if (memMapping == Core::MemMappings::Uncached || memMapping == Core::MemMappings::UncachedAccl) { // PLIN @@ -71,17 +71,17 @@ void* CDmaPacket::AllocBuffer(int numQwords, unsigned int memMapping) void* CDmaPacket::SwapOutBuffer(void* newBuffer) { void* oldBuffer = (void*)pBase; - pBase = (tU8*)newBuffer; + pBase = (uint8_t*)newBuffer; return oldBuffer; } -#define mCheckPktLength() mErrorIf((tU32)pNext & 0xf, "You don't really want to send a packet that isn't an even number of quads, do you?") +#define mCheckPktLength() mErrorIf((uint32_t)pNext & 0xf, "You don't really want to send a packet that isn't an even number of quads, do you?") void CDmaPacket::Send(bool waitForEnd, bool flushCache) { mCheckPktLength(); - tU32 pktQWLength = ((tU32)pNext - (tU32)pBase) / 16; + uint32_t pktQWLength = ((uint32_t)pNext - (uint32_t)pBase) / 16; mAssert(pktQWLength != 0); // dma_channel_send_normal always flushes the data cache @@ -90,24 +90,24 @@ void CDmaPacket::Send(bool waitForEnd, bool flushCache) // clear any memory mappings (this won't work for sp) dma_channel_wait(dmaChannelId, 1000000); - dma_channel_send_normal(dmaChannelId, (void*)((tU32)pBase & 0x0fffffff), pktQWLength, 0, 0); + dma_channel_send_normal(dmaChannelId, (void*)((uint32_t)pBase & 0x0fffffff), pktQWLength, 0, 0); if (waitForEnd) dma_channel_wait(dmaChannelId, 1000000); } -void CDmaPacket::HexDump(tU32 numQwords) +void CDmaPacket::HexDump(uint32_t numQwords) { if (numQwords == 0) - numQwords = ((tU32)pNext - (tU32)pBase) / 16; + numQwords = ((uint32_t)pNext - (uint32_t)pBase) / 16; - printf("dumping %d words (%d qwords)\n", ((tU32)pNext - (tU32)pBase) / 4, numQwords); + printf("dumping %ld words (%ld qwords)\n", ((uint32_t)pNext - (uint32_t)pBase) / 4, numQwords); - tU32 i = 0; - for (tU32 *nextWord = (tU32*)pBase; nextWord != (tU32*)pNext; nextWord++, i++) { + uint32_t i = 0; + for (uint32_t *nextWord = (uint32_t*)pBase; nextWord != (uint32_t*)pNext; nextWord++, i++) { if ((i % 4) == 0) - printf("\n0x%08x: ", (tU32)nextWord); - printf("0x%08x ", *nextWord); + printf("\n0x%08lx: ", (uint32_t)nextWord); + printf("0x%08lx ", *nextWord); if (i / 4 == numQwords) break; } @@ -124,7 +124,7 @@ void CDmaPacket::Print(void) * Source Chain DmaPacket */ -CSCDmaPacket::CSCDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping) +CSCDmaPacket::CSCDmaPacket(uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping) : CDmaPacket(bufferQWSize, channel, memMapping) , bTTE(tte) , pOpenTag(NULL) @@ -132,7 +132,7 @@ CSCDmaPacket::CSCDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, bool tte, t { } -CSCDmaPacket::CSCDmaPacket(tU128* buffer, tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping, bool isFull) +CSCDmaPacket::CSCDmaPacket(uint128_t* buffer, uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping, bool isFull) : CDmaPacket(buffer, bufferQWSize, channel, memMapping, isFull) , bTTE(tte) , pOpenTag(NULL) @@ -153,7 +153,7 @@ void CSCDmaPacket::Send(bool waitForEnd, bool flushCache) // clear any memory mappings (this won't work for sp) dma_channel_wait(dmaChannelId, 1000000); - dma_channel_send_chain(dmaChannelId, (void*)((tU32)pBase & 0x0fffffff), 0, bTTE ? DMA_FLAG_TRANSFERTAG : 0, 0); + dma_channel_send_chain(dmaChannelId, (void*)((uint32_t)pBase & 0x0fffffff), 0, bTTE ? DMA_FLAG_TRANSFERTAG : 0, 0); if (waitForEnd) dma_channel_wait(dmaChannelId, 1000000); @@ -163,7 +163,7 @@ void CSCDmaPacket::Send(bool waitForEnd, bool flushCache) * Vif Source Chain DmaPacket */ -CVifSCDmaPacket::CVifSCDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, bool tte, tU32 memMapping) +CVifSCDmaPacket::CVifSCDmaPacket(uint32_t bufferQWSize, tDmaChannelId channel, bool tte, uint32_t memMapping) : CSCDmaPacket(bufferQWSize, channel, tte, memMapping) , pOpenVifCode(NULL) , uiWL(1) @@ -171,8 +171,8 @@ CVifSCDmaPacket::CVifSCDmaPacket(tU32 bufferQWSize, tDmaChannelId channel, bool { } -CVifSCDmaPacket::CVifSCDmaPacket(tU128* buffer, tU32 bufferQWSize, tDmaChannelId channel, bool tte, - tU32 memMapping, bool isFull) +CVifSCDmaPacket::CVifSCDmaPacket(uint128_t* buffer, uint32_t bufferQWSize, tDmaChannelId channel, bool tte, + uint32_t memMapping, bool isFull) : CSCDmaPacket(buffer, bufferQWSize, channel, tte, memMapping, isFull) , pOpenVifCode(NULL) { @@ -182,19 +182,19 @@ CVifSCDmaPacket& CVifSCDmaPacket::CloseUnpack(void) { mAssert(pOpenVifCode); - tU32 vn = (pOpenVifCode->cmd & 0xc) >> 2; - tU32 vl = pOpenVifCode->cmd & 0x3; + uint32_t vn = (pOpenVifCode->cmd & 0xc) >> 2; + uint32_t vl = pOpenVifCode->cmd & 0x3; // the goal here is to find the num field of the open unpack, which is the number of // qwords ACTUALLY WRITTEN to vu memory (it does not count quads that are skipped in // "skipping write" mode.) But first forget about skipping/filling writes and compute the number // of qwords that the data in this packet will expand to. - tU32 numBytes = (tU32)pNext - (tU32)pOpenVifCode - 4; - tU32 numBytesPerBlock = 4 >> vl; - tU32 numBlocksPerQuad = vn + 1; + uint32_t numBytes = (uint32_t)pNext - (uint32_t)pOpenVifCode - 4; + uint32_t numBytesPerBlock = 4 >> vl; + uint32_t numBlocksPerQuad = vn + 1; // make sure that the data length is a multiple of 8, 16, or 32 bits, whichever is appropriate mAssert((numBytes & (numBytesPerBlock - 1)) == 0); - tU32 numQuads = (numBytes / numBytesPerBlock) / numBlocksPerQuad; + uint32_t numQuads = (numBytes / numBytesPerBlock) / numBlocksPerQuad; // We have the number of quads our data will directly expand to, so now we need to account for // skipping/filling write modes. @@ -206,8 +206,8 @@ CVifSCDmaPacket::CloseUnpack(void) // with internal registers. If you want different behavior call CloseUnpack with a num field you've // computed yourself if (uiCL < uiWL) { - tU32 numWLBlocks = (numQuads / uiCL); - tU32 lastBlockQuads = numQuads - numWLBlocks * uiCL; + uint32_t numWLBlocks = (numQuads / uiCL); + uint32_t lastBlockQuads = numQuads - numWLBlocks * uiCL; if (lastBlockQuads == uiCL) lastBlockQuads = uiWL; numQuads = numWLBlocks * uiWL + lastBlockQuads; diff --git a/src/perfmon.cpp b/src/perfmon.cpp index 2bff544..0003208 100644 --- a/src/perfmon.cpp +++ b/src/perfmon.cpp @@ -93,7 +93,7 @@ PerfTest::prfDef PerfTest::prfTable[NUM_PRF_TESTS] = { PerfTest::PerfTest() { - tU32 n; + uint32_t n; int n0 = 0; int n1 = 0; @@ -123,7 +123,7 @@ PerfTest::~PerfTest() void PerfTest::StepTests() { - for (tU32 n = 0; n != Core::COP0_NUM_PERF_COUNTERS; n++) { + for (uint32_t n = 0; n != Core::COP0_NUM_PERF_COUNTERS; n++) { m_iCurrentTest[n] = GetNextTestID(n, m_iCurrentTest[n]); } } @@ -178,7 +178,7 @@ void PerfTest::DumpStats(int nLoops) } printf("\n"); - for (tU32 n = 0; n != NUM_PRF_TESTS; n++) { + for (uint32_t n = 0; n != NUM_PRF_TESTS; n++) { int lval = 0; if (m_testVals[n] == MPRF_NOT_READY) { printf("NOT_READY "); @@ -237,7 +237,7 @@ int PerfTest::sDumpStats(char* buffer, int nLoops) } nc += sprintf(buffer + nc, "\n"); - for (tU32 n = 0; n != NUM_PRF_TESTS; n++) { + for (uint32_t n = 0; n != NUM_PRF_TESTS; n++) { if (m_testVals[n] == MPRF_NOT_READY) { nc += sprintf(buffer + nc, "NOT_READY "); } else { @@ -272,7 +272,7 @@ int PerfTest::sDumpStats(char* buffer, int nLoops) return nc; } -int PerfTest::GetNextTestID(tU32 counter_id, tU32 ctest) +int PerfTest::GetNextTestID(uint32_t counter_id, uint32_t ctest) { if (counter_id >= 2) return 0; diff --git a/src/sprite.cpp b/src/sprite.cpp index fd8cbc6..210a954 100644 --- a/src/sprite.cpp +++ b/src/sprite.cpp @@ -16,8 +16,8 @@ * methods */ -CSprite::CSprite(GS::tContext context, tU32 minX, tU32 minY, tU32 width, tU32 height) - : GifPacket((tU128*)&DrawGifTag, 6, DMAC::Channels::gif, Core::MemMappings::Normal, Packet::kFull) +CSprite::CSprite(GS::tContext context, uint32_t minX, uint32_t minY, uint32_t width, uint32_t height) + : GifPacket((uint128_t*)&DrawGifTag, 6, DMAC::Channels::gif, Core::MemMappings::Normal, Packet::kFull) { GS::tPrim prim; @@ -38,21 +38,21 @@ CSprite::CSprite(GS::tContext context, tU32 minX, tU32 minY, tU32 width, tU32 he prim.abe = 0; // no alpha prim.aa1 = 0; // no aa prim.fst = 0; // stq coords - prim.ctxt = (tU64)context; + prim.ctxt = (uint64_t)context; prim.fix = 0; // what the hell does this do? - DrawGifTag.PRIM = *(tU64*)&prim; + DrawGifTag.PRIM = *(uint64_t*)&prim; SetVertices(minX, minY, width, height); - mAssert(((tU32)&DrawGifTag & 0xf) == 0); + mAssert(((uint32_t)&DrawGifTag & 0xf) == 0); } void CSprite::SetSTQs(float minS, float minT, float width, float height) { GS::tPrim prim; - *(tU64*)&prim = DrawGifTag.PRIM; + *(uint64_t*)&prim = DrawGifTag.PRIM; prim.fst = 0; // stq - DrawGifTag.PRIM = *(tU64*)&prim; + DrawGifTag.PRIM = *(uint64_t*)&prim; DrawGifTag.REGS1 = 0x2; DrawGifTag.REGS3 = 0x2; @@ -67,9 +67,9 @@ void CSprite::SetSTQs(float minS, float minT, float width, float height) void CSprite::SetUVs(float minU, float minV, float width, float height) { GS::tPrim prim; - *(tU64*)&prim = DrawGifTag.PRIM; + *(uint64_t*)&prim = DrawGifTag.PRIM; prim.fst = 1; // uv - DrawGifTag.PRIM = *(tU64*)&prim; + DrawGifTag.PRIM = *(uint64_t*)&prim; DrawGifTag.REGS1 = 0x3; DrawGifTag.REGS3 = 0x3; @@ -81,12 +81,12 @@ void CSprite::SetUVs(float minU, float minV, float width, float height) SetUseTexture(true); } -void CSprite::SetUVs(tU16 minU, tU16 minV, tU16 width, tU16 height) +void CSprite::SetUVs(uint16_t minU, uint16_t minV, uint16_t width, uint16_t height) { GS::tPrim prim; - *(tU64*)&prim = DrawGifTag.PRIM; + *(uint64_t*)&prim = DrawGifTag.PRIM; prim.fst = 1; // uv - DrawGifTag.PRIM = *(tU64*)&prim; + DrawGifTag.PRIM = *(uint64_t*)&prim; DrawGifTag.REGS1 = 0x3; DrawGifTag.REGS3 = 0x3; @@ -98,12 +98,12 @@ void CSprite::SetUVs(tU16 minU, tU16 minV, tU16 width, tU16 height) SetUseTexture(true); } -void CSprite::SetUVsFix4(tU16 minU, tU16 minV, tU16 maxU, tU16 maxV) +void CSprite::SetUVsFix4(uint16_t minU, uint16_t minV, uint16_t maxU, uint16_t maxV) { GS::tPrim prim; - *(tU64*)&prim = DrawGifTag.PRIM; + *(uint64_t*)&prim = DrawGifTag.PRIM; prim.fst = 1; // uv - DrawGifTag.PRIM = *(tU64*)&prim; + DrawGifTag.PRIM = *(uint64_t*)&prim; DrawGifTag.REGS1 = 0x3; DrawGifTag.REGS3 = 0x3; @@ -118,7 +118,7 @@ void CSprite::SetUVsFix4(tU16 minU, tU16 minV, tU16 maxU, tU16 maxV) void CSprite::Draw(CSCDmaPacket& packet) { packet.Cnt(); - packet.Add((tU128*)&DrawGifTag, 6); + packet.Add((uint128_t*)&DrawGifTag, 6); packet.CloseTag(); } @@ -134,7 +134,7 @@ void CSprite::Draw(CVifSCDmaPacket& packet) } packet.OpenDirect(); - packet.Add((tU128*)&DrawGifTag, 6); + packet.Add((uint128_t*)&DrawGifTag, 6); packet.CloseDirect(); } packet.CloseTag(); diff --git a/src/texture.cpp b/src/texture.cpp index 043834b..05f1fd6 100644 --- a/src/texture.cpp +++ b/src/texture.cpp @@ -26,9 +26,9 @@ namespace GS { * CTexEnv methods */ -CTexEnv::CTexEnv(GS::tContext context, tU32 width, tU32 height, GS::tPSM psm) +CTexEnv::CTexEnv(GS::tContext context, uint32_t width, uint32_t height, GS::tPSM psm) : uiNumSettingsGSRegs(5) - , SettingsPacket((tU128*)&SettingsDmaTag, uiNumSettingsGSRegs + 2, + , SettingsPacket((uint128_t*)&SettingsDmaTag, uiNumSettingsGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) { @@ -42,7 +42,7 @@ CTexEnv::CTexEnv(GS::tContext context) : uiNumSettingsGSRegs(5) , // gee, it's too bad c++ doesn't have a way of chaining constructors.... - SettingsPacket((tU128*)&SettingsDmaTag, uiNumSettingsGSRegs + 2, + SettingsPacket((uint128_t*)&SettingsDmaTag, uiNumSettingsGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) { @@ -53,7 +53,7 @@ CTexEnv::CTexEnv(const CTexEnv& rhs) : uiNumSettingsGSRegs(5) , // gee, it's too bad c++ doesn't have a way of chaining constructors.... - SettingsPacket((tU128*)&SettingsDmaTag, uiNumSettingsGSRegs + 2, + SettingsPacket((uint128_t*)&SettingsDmaTag, uiNumSettingsGSRegs + 2, DMAC::Channels::gif, Packet::kDontXferTags, Core::MemMappings::Normal, Packet::kFull) { @@ -128,24 +128,24 @@ void CTexEnv::InitCommon(GS::tContext context) gsrTex1.k = 0; // make sure things are qword aligned (I don't trust the compiler...) - mAssert(((tU32)&SettingsGifTag & 0xf) == 0); + mAssert(((uint32_t)&SettingsGifTag & 0xf) == 0); } CTexEnv& CTexEnv::operator=(const CTexEnv& rhs) { - Utils::MemCpy128(reinterpret_cast(&SettingsGifTag), reinterpret_cast(&rhs.SettingsGifTag), uiNumSettingsGSRegs + 1); + Utils::MemCpy128(reinterpret_cast(&SettingsGifTag), reinterpret_cast(&rhs.SettingsGifTag), uiNumSettingsGSRegs + 1); uiTexPixelHeight = rhs.uiTexPixelHeight; uiTexPixelWidth = rhs.uiTexPixelWidth; return *this; } -void CTexEnv::SetImageGsAddr(tU32 gsMemWordAddress) +void CTexEnv::SetImageGsAddr(uint32_t gsMemWordAddress) { gsrTex0.tb_addr = gsMemWordAddress / 64; } -void CTexEnv::SetClutGsAddr(tU32 gsMemWordAddress) +void CTexEnv::SetClutGsAddr(uint32_t gsMemWordAddress) { gsrTex0.cb_addr = gsMemWordAddress / 64; } @@ -172,7 +172,7 @@ void CTexEnv::SendSettings(bool waitForEnd, bool flushCache) void CTexEnv::SendSettings(CSCDmaPacket& packet) { packet.Cnt(); - packet.Add((tU128*)&SettingsGifTag, uiNumSettingsGSRegs + 1); + packet.Add((uint128_t*)&SettingsGifTag, uiNumSettingsGSRegs + 1); packet.CloseTag(); } @@ -188,26 +188,26 @@ void CTexEnv::SendSettings(CVifSCDmaPacket& packet) } packet.OpenDirect(); - packet.Add((tU128*)&SettingsGifTag, uiNumSettingsGSRegs + 1); + packet.Add((uint128_t*)&SettingsGifTag, uiNumSettingsGSRegs + 1); packet.CloseDirect(); } packet.CloseTag(); } -void CTexEnv::SetDimensions(tU32 w, tU32 h) +void CTexEnv::SetDimensions(uint32_t w, uint32_t h) { uiTexPixelWidth = w; uiTexPixelHeight = h; // get the log base 2 of the dimensions - tU32 logW = Math::Log2(w); - tU32 logH = Math::Log2(h); + uint32_t logW = Math::Log2(w); + uint32_t logH = Math::Log2(h); // if the texture dimensions are not powers of two, they need to be rounded up // to the next power of two - if (((tU32)1 << logW) != w) + if (((uint32_t)1 << logW) != w) logW++; - if (((tU32)1 << logH) != h) + if (((uint32_t)1 << logH) != h) logH++; gsrTex0.tex_width = logW; @@ -232,7 +232,7 @@ void CTexEnv::SetDimensions(tU32 w, tU32 h) // all pretty reasonable, but REGION_REPEAT uses the bitwise operations & and | instead of the % and + operations // that you would expect. RTM. -void CTexEnv::SetRegion(tU32 originU, tU32 originV, tU32 w, tU32 h) +void CTexEnv::SetRegion(uint32_t originU, uint32_t originV, uint32_t w, uint32_t h) { tTexWrapMode sMode, tMode; sMode = (gsrClamp.wrap_mode_s & 2) ? (tTexWrapMode)(3 - gsrClamp.wrap_mode_s) : (tTexWrapMode)gsrClamp.wrap_mode_s; @@ -257,8 +257,8 @@ void CTexEnv::SetRegion(tU32 originU, tU32 originV, tU32 w, tU32 h) gsrClamp.max_clamp_v = originV; } - gsrClamp.wrap_mode_s = 3 - (tU32)sMode; - gsrClamp.wrap_mode_t = 3 - (tU32)tMode; + gsrClamp.wrap_mode_s = 3 - (uint32_t)sMode; + gsrClamp.wrap_mode_t = 3 - (uint32_t)tMode; // see note above this method mAssert((sMode == kClamp) || (((gsrClamp.max_clamp_u & gsrClamp.min_clamp_u) == 0) && Math::IsPow2(gsrClamp.min_clamp_u + 1))); @@ -293,11 +293,11 @@ void CTexEnv::SetWrapModeS(tTexWrapMode sMode) tTexWrapMode oldMode = (gsrClamp.wrap_mode_s & 2) ? (tTexWrapMode)(3 - gsrClamp.wrap_mode_s) : (tTexWrapMode)sMode; if (oldMode != sMode) { if (oldMode == kRepeat) { - tU32 temp = gsrClamp.min_clamp_u; + uint32_t temp = gsrClamp.min_clamp_u; gsrClamp.min_clamp_u = gsrClamp.max_clamp_u; gsrClamp.max_clamp_u += temp; } else { - tU32 temp = gsrClamp.min_clamp_u; + uint32_t temp = gsrClamp.min_clamp_u; gsrClamp.min_clamp_u = gsrClamp.max_clamp_u - gsrClamp.min_clamp_u; gsrClamp.max_clamp_u = temp; } @@ -319,11 +319,11 @@ void CTexEnv::SetWrapModeT(tTexWrapMode tMode) tTexWrapMode oldMode = (gsrClamp.wrap_mode_t & 2) ? (tTexWrapMode)(3 - gsrClamp.wrap_mode_t) : (tTexWrapMode)tMode; if (oldMode != tMode) { if (oldMode == kRepeat) { - tU32 temp = gsrClamp.min_clamp_v; + uint32_t temp = gsrClamp.min_clamp_v; gsrClamp.min_clamp_v = gsrClamp.max_clamp_v; gsrClamp.max_clamp_v += temp; } else { - tU32 temp = gsrClamp.min_clamp_v; + uint32_t temp = gsrClamp.min_clamp_v; gsrClamp.min_clamp_v = gsrClamp.max_clamp_v - gsrClamp.min_clamp_v; gsrClamp.max_clamp_v = temp; } @@ -369,35 +369,35 @@ void CTexture::InitCommon(GS::tContext context) bFreeMemOnExit = false; } -void CTexture::SetImageGsAddr(tU32 gsMemWordAddress) +void CTexture::SetImageGsAddr(uint32_t gsMemWordAddress) { CTexEnv::SetImageGsAddr(gsMemWordAddress); // gsrBitBltBuf.DBP = gsMemWordAddress/64; pImageUploadPkt->SetGsAddr(gsMemWordAddress); } -void CTexture::SetClutGsAddr(tU32 gsMemWordAddress) +void CTexture::SetClutGsAddr(uint32_t gsMemWordAddress) { CTexEnv::SetClutGsAddr(gsMemWordAddress); pClutUploadPkt->SetGsAddr(gsMemWordAddress); } -tU128* -CTexture::AllocMem(tU32 w, tU32 h, GS::tPSM psm) +uint128_t* +CTexture::AllocMem(uint32_t w, uint32_t h, GS::tPSM psm) { mAssert(pImage == NULL); - tU128* image = (tU128*)malloc(h * w * GS::GetBitsPerPixel(psm) / 8); + uint128_t* image = (uint128_t*)malloc(h * w * GS::GetBitsPerPixel(psm) / 8); mAssert(image != NULL); bFreeMemOnExit = true; return image; } -void CTexture::SetImage(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm, tU32* clutPtr) +void CTexture::SetImage(uint128_t* imagePtr, uint32_t w, uint32_t h, GS::tPSM psm, uint32_t* clutPtr) { // make sure the image is qword aligned - mAssert(((tU32)imagePtr & 0xf) == 0); + mAssert(((uint32_t)imagePtr & 0xf) == 0); pImage = imagePtr; @@ -409,8 +409,8 @@ void CTexture::SetImage(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm, tU32* clu // I think this isn't necessary anymore... /* // width of the area in gs mem (64 pixel units) to use - tU32 gsBufWidth = ( (w % 64) != 0 ) ? w/64 + 1 : w/64; - gsBufWidth = Math::Max( ((tU32)1 << gsrTex0.tex_width) / 64, gsBufWidth ); + uint32_t gsBufWidth = ( (w % 64) != 0 ) ? w/64 + 1 : w/64; + gsBufWidth = Math::Max( ((uint32_t)1 << gsrTex0.tex_width) / 64, gsBufWidth ); gsrTex0.tb_width = gsBufWidth; */ @@ -420,7 +420,7 @@ void CTexture::SetImage(tU128* imagePtr, tU32 w, tU32 h, GS::tPSM psm, tU32* clu pImageUploadPkt->SetImage(imagePtr, w, h, psm); // clut - pClut = (tU128*)clutPtr; + pClut = (uint128_t*)clutPtr; if (clutPtr != NULL) { mAssert(pClutUploadPkt == NULL); pClutUploadPkt = new CClutUploadPkt; @@ -481,26 +481,26 @@ CClut::CClut(const void* table, int numEntries) : GsAddr(0) { UploadPkt = new CClutUploadPkt; - UploadPkt->SetClut((tU32*)table); + UploadPkt->SetClut((uint32_t*)table); } /******************************************** * CCheckTex methods */ -CCheckTex::CCheckTex(GS::tContext context, tU32 width, tU32 height, tU32 xCellSize, tU32 yCellSize, tU32 color1, tU32 color2) +CCheckTex::CCheckTex(GS::tContext context, uint32_t width, uint32_t height, uint32_t xCellSize, uint32_t yCellSize, uint32_t color1, uint32_t color2) : CTexture(context) { - tU128* image = AllocMem(width, height, GS::kPsm32); + uint128_t* image = AllocMem(width, height, GS::kPsm32); SetImage(image, width, height, GS::kPsm32); MakeCheckerboard(xCellSize, yCellSize, color1, color2); } -void CCheckTex::MakeCheckerboard(tU32 xCellSize, tU32 yCellSize, tU32 color1, tU32 color2) +void CCheckTex::MakeCheckerboard(uint32_t xCellSize, uint32_t yCellSize, uint32_t color1, uint32_t color2) { - tU32* curPixel = (tU32*)pImage; - tU32 row, col; + uint32_t* curPixel = (uint32_t*)pImage; + uint32_t row, col; for (row = 0; row < uiTexPixelHeight; row++) { for (col = 0; col < uiTexPixelWidth; col++) *curPixel++ = (Math::IsEven(row / yCellSize) ^ Math::IsEven(col / xCellSize)) ? color1 : color2;