From b707a348459db73990f310c54f62ed14601da274 Mon Sep 17 00:00:00 2001 From: TheArtemMaps <91487356+TheArtemMaps@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:56:17 +0300 Subject: [PATCH] SA: CSprite revamp Added everything from the CSprite class (I think) --- plugin_sa/game_sa/CSprite.cpp | 47 +++++++++++++++++++++++++++++++++++ plugin_sa/game_sa/CSprite.h | 26 +++++++++++++++++++ 2 files changed, 73 insertions(+) diff --git a/plugin_sa/game_sa/CSprite.cpp b/plugin_sa/game_sa/CSprite.cpp index 01f49c8c..f82d26be 100644 --- a/plugin_sa/game_sa/CSprite.cpp +++ b/plugin_sa/game_sa/CSprite.cpp @@ -38,6 +38,53 @@ void CSprite::RenderOneXLUSprite(float x, float y, float z, float halfWidth, flo red, green, blue, alpha, rhw, intensity, udir, vdir); } + +void CSprite::RenderBufferedOneXLUSprite(CVector pos, CVector2D size, uint8_t r, uint8_t g, uint8_t b, int16_t intensity, float recipNearZ, uint8_t a11) { + plugin::Call<0x70E4A0>(pos, size, r, g, b, intensity, recipNearZ, a11); +} + +void CSprite::RenderBufferedOneXLUSprite_Rotate_Dimension(CVector pos, CVector2D size, uint8_t r, uint8_t g, uint8_t b, int16_t intensity, float rz, float rotation, uint8_t a) { + plugin::Call<0x70EAB0>(pos, size, r, g, b, intensity, rz, rotation, a); +} + + +void CSprite::RenderBufferedOneXLUSprite2D(float x, float y, float w, float h, const RwRGBA& colour, int16_t intens, float rotation, uint8_t alpha) { + plugin::Call<0x70F440>(x, y, w, h, colour, intens, rotation, alpha); +} + +void CSprite::RenderBufferedOneXLUSprite2D_Rotate_Dimension(float x, float y, float w, float h, const RwRGBA& colour, int16_t intens, float rotation, uint8_t alpha) { + plugin::Call<0x70F600>(x, y, w, h, colour, intens, rotation, alpha); +} + +void CSprite::RenderOneXLUSprite2D_Rotate_Dimension(float x, float y, float w, float h, const RwRGBA& colour, int16_t intens, float rotation, uint8_t alpha) { + plugin::Call<0x70F760>(x, y, w, h, colour, intens, rotation, alpha); +} + +void CSprite::Set4Vertices2D(RwIm2DVertex* verts, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, + const CRGBA& c0, const CRGBA& c1, const CRGBA& c2, const CRGBA& c3) { + plugin::Call<0x70E2D0>(verts, x1, y1, x2, y2, x3, y3, x4, y4, c0, c1, c2, c3); +} + +float CSprite::CalcHorizonCoors() { + return plugin::CallAndReturn(); +} + +void CSprite::Set4Vertices2D(RwIm2DVertex* verts, const CRect& rt, const CRGBA& topLeftColor, const CRGBA& topRightColor, const CRGBA& bottomLeftColor, const CRGBA& bottomRightColor) { + plugin::Call<0x70E1C0>(verts, rt, topLeftColor, topRightColor, bottomLeftColor, bottomRightColor); +} + +void CSprite::RenderOneXLUSprite2D(CVector2D screen, CVector2D size, const CRGBA& color, int16_t intensity, uint8_t alpha) { + plugin::Call<0x70F540>(screen, size, color, intensity, alpha); +} + +void CSprite::RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8_t r, uint8_t g, uint8_t b, int16_t intens, float recipz, float roll, uint8_t a) { + plugin::Call<0x70D490>(x, y, z, w, h, r, g, b, intens, recipz, roll, a); +} + +void CSprite::RenderOneXLUSprite_Triangle(float x, float y, float z, float w, float h, float unk1, float unk2, uint8_t r, uint8_t g, uint8_t b, int16_t intens, float recipz, uint8_t a) { + plugin::Call<0x70D320>(x, y, z, w, h, unk1, unk2, r, g, b, intens, recipz, a); +} + bool CSprite::CalcScreenCoors(RwV3d const &posn, RwV3d *out, float *w, float *h, bool checkMaxVisible, bool checkMinVisible) { return ((bool (__cdecl *)(RwV3d const &, RwV3d *, float *, float *, bool, bool))0x70CE30) diff --git a/plugin_sa/game_sa/CSprite.h b/plugin_sa/game_sa/CSprite.h index bc134f20..88f5cd0e 100644 --- a/plugin_sa/game_sa/CSprite.h +++ b/plugin_sa/game_sa/CSprite.h @@ -8,10 +8,19 @@ #include "PluginBase.h" #include "RenderWare.h" +#include "plugin.h" class PLUGIN_API CSprite { public: + static inline float& m_f2DNearScreenZ = *(float*)0xC4B8D8; + static inline float& m_f2DFarScreenZ = *(float*)0xC4B8D4; + static inline float& m_fRecipNearClipPlane = *(float*)0xC4B8D0; + static inline uint32_t& m_bFlushSpriteBufferSwitchZTest = *(uint32_t*)0xC6A15C; + + static float GetNearScreenZ(void) { return m_f2DNearScreenZ; } + static float GetFarScreenZ(void) { return m_f2DFarScreenZ; } + static void RenderOneXLUSprite(float x, float y, float z, float halfWidth, float halfHeight, unsigned char red, unsigned char green, unsigned char blue, short alpha, float rhw, unsigned char intensity, unsigned char udir, unsigned char vdir); @@ -20,4 +29,21 @@ class PLUGIN_API CSprite static void RenderBufferedOneXLUSprite_Rotate_2Colours(float x, float y, float z, float w, float h, uint8_t r1, uint8_t g1, uint8_t b1, uint8_t r2, uint8_t g2, uint8_t b2, float cx, float cy, float recipz, float rotation, uint8_t a); static void RenderBufferedOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8_t r, uint8_t g, uint8_t b, int16_t intens, float recipz, float roll, uint8_t a); static bool CalcScreenCoors(RwV3d const &posn, RwV3d *out, float *w, float *h, bool checkMaxVisible, bool checkMinVisible); + static void InitSpriteBuffer2D(); + + static float CalcHorizonCoors(); + + static void Set4Vertices2D(RwIm2DVertex* verts, const CRect& rt, const CRGBA& topLeftColor, const CRGBA& topRightColor, const CRGBA& bottomLeftColor, const CRGBA& bottomRightColor); + static void Set4Vertices2D(RwIm2DVertex* verts, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, + const CRGBA& c0, const CRGBA& c1, const CRGBA& c2, const CRGBA& c3); + + static void RenderOneXLUSprite_Triangle(float x, float y, float z, float w, float h, float unk1, float unk2, uint8_t r, uint8_t g, uint8_t b, int16_t intens, float recipz, uint8_t a); + static void RenderOneXLUSprite_Rotate_Aspect(float x, float y, float z, float w, float h, uint8_t r, uint8_t g, uint8_t b, int16_t intens, float recipz, float roll, uint8_t a); + static void RenderOneXLUSprite2D(CVector2D screen, CVector2D size, const CRGBA& color, int16_t intensity, uint8_t alpha); + static void RenderOneXLUSprite2D_Rotate_Dimension(float x, float y, float w, float h, const RwRGBA& colour, int16_t intens, float rotation, uint8_t alpha); + + static void RenderBufferedOneXLUSprite(CVector pos, CVector2D size, uint8_t r, uint8_t g, uint8_t b, int16_t intensity, float recipNearZ, uint8_t a11); + static void RenderBufferedOneXLUSprite_Rotate_Dimension(CVector pos, CVector2D size, uint8_t r, uint8_t g, uint8_t b, int16_t intensity, float rz, float rotation, uint8_t a); + static void RenderBufferedOneXLUSprite2D(float x, float y, float w, float h, const RwRGBA& colour, int16_t intens, float rotation, uint8_t alpha); + static void RenderBufferedOneXLUSprite2D_Rotate_Dimension(float x, float y, float w, float h, const RwRGBA& colour, int16_t intens, float rotation, uint8_t alpha); }; \ No newline at end of file