diff --git a/config/RSPE01_01/splits.txt b/config/RSPE01_01/splits.txt index cef4f894..ef322a27 100644 --- a/config/RSPE01_01/splits.txt +++ b/config/RSPE01_01/splits.txt @@ -3307,13 +3307,14 @@ Pack/RPGraphics/RPGrpScreen.cpp: .text start:0x801B0268 end:0x801B046C .ctors start:0x80355130 end:0x80355134 .bss start:0x804A4538 end:0x804A45B0 + .sdata2 start:0x804C1898 end:0x804C18A0 Pack/RPGraphics/RPGrpView.cpp: .text start:0x801B046C end:0x801B1624 .ctors start:0x80355134 end:0x80355138 .data start:0x803BA5C0 end:0x803BA608 .bss start:0x804A45B0 end:0x804A4608 - .sdata2 start:0x804C1898 end:0x804C18D0 + .sdata2 start:0x804C18A0 end:0x804C18D0 Pack/RPGraphics/RPGrpViewRender2D.cpp: .text start:0x801B1624 end:0x801B1700 diff --git a/config/RSPE01_01/symbols.txt b/config/RSPE01_01/symbols.txt index 36958eef..7649b616 100644 --- a/config/RSPE01_01/symbols.txt +++ b/config/RSPE01_01/symbols.txt @@ -7029,7 +7029,7 @@ fn_80187C8C = .text:0x80187C8C; // type:function size:0x88 fn_80187D14 = .text:0x80187D14; // type:function size:0x64 fn_80187D78 = .text:0x80187D78; // type:function size:0x44 fn_80187DBC = .text:0x80187DBC; // type:function size:0x128 -fn_80187EE4 = .text:0x80187EE4; // type:function size:0x40 +__dt__11RPGrpScreenFv = .text:0x80187EE4; // type:function size:0x40 fn_80187F24 = .text:0x80187F24; // type:function size:0x40 __dt__14RPSysDvdStatusFv = .text:0x80187F64; // type:function size:0x40 draw__14RPSysDvdStatusFv = .text:0x80187FA4; // type:function size:0x1E8 @@ -7553,7 +7553,7 @@ fn_8019C744 = .text:0x8019C744; // type:function size:0x8 fn_8019C74C = .text:0x8019C74C; // type:function size:0x2F0 fn_8019CA3C = .text:0x8019CA3C; // type:function size:0x1A4 fn_8019CBE0 = .text:0x8019CBE0; // type:function size:0xB14 -fn_8019D6F4 = .text:0x8019D6F4; // type:function size:0x40 +__dt__12RPGrpTextureFv = .text:0x8019D6F4; // type:function size:0x40 fn_8019D734 = .text:0x8019D734; // type:function size:0x31C fn_8019DA50 = .text:0x8019DA50; // type:function size:0x280 fn_8019DCD0 = .text:0x8019DCD0; // type:function size:0x4 @@ -7811,7 +7811,7 @@ fn_801AA2D0 = .text:0x801AA2D0; // type:function size:0x20 fn_801AA2F0 = .text:0x801AA2F0; // type:function size:0xF4 fn_801AA3E4 = .text:0x801AA3E4; // type:function size:0x8C fn_801AA470 = .text:0x801AA470; // type:function size:0x150 -fn_801AA5C0 = .text:0x801AA5C0; // type:function size:0x10 +Calc__13RPGrpModelAnmFv = .text:0x801AA5C0; // type:function size:0x10 fn_801AA5D0 = .text:0x801AA5D0; // type:function size:0x27C fn_801AA84C = .text:0x801AA84C; // type:function size:0x8C fn_801AA8D8 = .text:0x801AA8D8; // type:function size:0x34 @@ -7964,12 +7964,12 @@ fn_801B004C = .text:0x801B004C; // type:function size:0x16C fn_801B01B8 = .text:0x801B01B8; // type:function size:0x40 fn_801B01F8 = .text:0x801B01F8; // type:function size:0x40 fn_801B0238 = .text:0x801B0238; // type:function size:0x30 -DrawQuadTexture__11RPGrpScreenFffffPCv8_GXColor = .text:0x801B0268; // type:function size:0xF4 +DrawQuadTexture__11RPGrpScreenFffffPQ23EGG7ResTIMG8_GXColor = .text:0x801B0268; // type:function size:0xF4 BeginDrawQuadTexture__11RPGrpScreenCFb = .text:0x801B035C; // type:function size:0x1C -fn_801B0378 = .text:0x801B0378; // type:function size:0x70 -fn_801B03E8 = .text:0x801B03E8; // type:function size:0x1C -fn_801B0404 = .text:0x801B0404; // type:function size:0xC -fn_801B0410 = .text:0x801B0410; // type:function size:0x5C +DrawQuad__11RPGrpScreenFffff8_GXColor = .text:0x801B0378; // type:function size:0x70 +BeginDrawQuad__11RPGrpScreenCFv = .text:0x801B03E8; // type:function size:0x1C +Initialize__11RPGrpScreenFPCUsPCUs = .text:0x801B0404; // type:function size:0xC +__sinit_\RPGrpScreen_cpp = .text:0x801B0410; // type:function size:0x5C fn_801B046C = .text:0x801B046C; // type:function size:0x734 fn_801B0BA0 = .text:0x801B0BA0; // type:function size:0x150 fn_801B0CF0 = .text:0x801B0CF0; // type:function size:0x184 @@ -8061,9 +8061,9 @@ fn_801B4A68 = .text:0x801B4A68; // type:function size:0x78 fn_801B4AE0 = .text:0x801B4AE0; // type:function size:0x4 fn_801B4AE4 = .text:0x801B4AE4; // type:function size:0x40 fn_801B4B24 = .text:0x801B4B24; // type:function size:0x40 -fn_801B4B64 = .text:0x801B4B64; // type:function size:0x80 +__ct__12RPGrpTextureFUsPCc = .text:0x801B4B64; // type:function size:0x80 fn_801B4BE4 = .text:0x801B4BE4; // type:function size:0x50 -fn_801B4C34 = .text:0x801B4C34; // type:function size:0x3C +__ct__12RPGrpTextureFPCQ23EGG7ResTIMG = .text:0x801B4C34; // type:function size:0x3C fn_801B4C70 = .text:0x801B4C70; // type:function size:0x50 fn_801B4CC0 = .text:0x801B4CC0; // type:function size:0x10C fn_801B4DCC = .text:0x801B4DCC; // type:function size:0x11C @@ -18693,7 +18693,7 @@ lbl_803BA730 = .data:0x803BA730; // type:object size:0x10 lbl_803BA740 = .data:0x803BA740; // type:object size:0x10 lbl_803BA750 = .data:0x803BA750; // type:object size:0x18 lbl_803BA768 = .data:0x803BA768; // type:object size:0x18 -lbl_803BA780 = .data:0x803BA780; // type:object size:0x10 +__vt__12RPGrpTexture = .data:0x803BA780; // type:object size:0x10 lbl_803BA790 = .data:0x803BA790; // type:object size:0x10 lbl_803BA7A0 = .data:0x803BA7A0; // type:object size:0x10 lbl_803BA7B0 = .data:0x803BA7B0; // type:object size:0xD0 @@ -19870,8 +19870,8 @@ lbl_804A43B8 = .bss:0x804A43B8; // type:object size:0x110 lbl_804A44C8 = .bss:0x804A44C8; // type:object size:0x30 lbl_804A44F8 = .bss:0x804A44F8; // type:object size:0x10 lbl_804A4508 = .bss:0x804A4508; // type:object size:0x30 data:4byte -lbl_804A4538 = .bss:0x804A4538; // type:object size:0x10 -lbl_804A4548 = .bss:0x804A4548; // type:object size:0x68 +@16447 = .bss:0x804A4538; // type:object size:0x10 scope:local +g_default_screen__11RPGrpScreen = .bss:0x804A4548; // type:object size:0x68 lbl_804A45B0 = .bss:0x804A45B0; // type:object size:0xC lbl_804A45BC = .bss:0x804A45BC; // type:object size:0x4C align:4 data:float lbl_804A4608 = .bss:0x804A4608; // type:object size:0x30 align:4 data:float @@ -23652,7 +23652,7 @@ lbl_804C188A = .sdata2:0x804C188A; // type:object size:0x1 data:byte lbl_804C188B = .sdata2:0x804C188B; // type:object size:0x1 data:byte lbl_804C188C = .sdata2:0x804C188C; // type:object size:0x4 align:4 data:float lbl_804C1890 = .sdata2:0x804C1890; // type:object size:0x8 align:4 data:float -lbl_804C1898 = .sdata2:0x804C1898; // type:object size:0x8 align:4 data:float +@16652 = .sdata2:0x804C1898; // type:object size:0x4 scope:local align:4 data:float lbl_804C18A0 = .sdata2:0x804C18A0; // type:object size:0x1 data:byte lbl_804C18A1 = .sdata2:0x804C18A1; // type:object size:0x1 data:byte lbl_804C18A2 = .sdata2:0x804C18A2; // type:object size:0x1 data:byte diff --git a/include/Pack/RPGraphics/RPGrpScreen.h b/include/Pack/RPGraphics/RPGrpScreen.h index e6fcffd6..9f690487 100644 --- a/include/Pack/RPGraphics/RPGrpScreen.h +++ b/include/Pack/RPGraphics/RPGrpScreen.h @@ -4,6 +4,9 @@ #include +//! @addtogroup rp_graphics +//! @{ + /** * @brief Screen extension */ @@ -37,8 +40,54 @@ class RPGrpScreen : public EGG::Screen { */ virtual ~RPGrpScreen() override; // at 0x8 + /** + * @brief Sets up the screen to draw a solid color quad. + */ + void BeginDrawQuad() const; + + /** + * @brief Draws a solid color quad to the screen + * + * @param x Quad X position + * @param y Quad Y position + * @param width Quad width + * @param height Quad height + * @param color Quad color + */ + void DrawQuad(f32 x, f32 y, f32 width, f32 height, GXColor color); + + /** + * @brief Sets up the screen to draw a texture quad. + * + * @param alpha Does the texture have an alpha channel + */ void BeginDrawQuadTexture(bool alpha) const; - void DrawQuadTexture(f32, f32, f32, f32, const void*, GXColor); + + /** + * @brief Draws a texture on a quad to the screen + * + * @param x Quad X position + * @param y Quad Y position + * @param width Quad width + * @param height Quad height + * @param pTextureRes Texture image resource + * @param color Quad color + */ + void DrawQuadTexture(f32 x, f32 y, f32 width, f32 height, + EGG::ResTIMG* pTextureRes, GXColor color); + + /** + * @brief Initalizes the default screen. + * + * @param maxX Maximum X + * @param maxY Maximun Y + */ + static void Initialize(const u16 maxX[TV_MODE_MAX], + const u16 maxY[TV_MODE_MAX]); + +public: + //! Default screen settings + static RPGrpScreen g_default_screen; }; #endif diff --git a/include/Pack/RPGraphics/RPGrpTexture.h b/include/Pack/RPGraphics/RPGrpTexture.h index 860b0d7e..f530c079 100644 --- a/include/Pack/RPGraphics/RPGrpTexture.h +++ b/include/Pack/RPGraphics/RPGrpTexture.h @@ -17,9 +17,23 @@ class RPGrpTexture { GXTexObj mGXTexObj; // at 0x0 public: - RPGrpTexture(); + /** + * @brief Constructor that uses a texture image resource. + * + * @param pRes Texture image resource + */ + RPGrpTexture(const EGG::ResTIMG* pRes); + + /** + * @brief Constructor that uses a texture resource from a resource file + * handle. + * + * @param handle Resource file handle + * @param pName File name. + */ RPGrpTexture(RPGrpHandle handle, const char* pName); - virtual ~RPGrpTexture(); + + virtual ~RPGrpTexture() {} const GXTexObj& GetTexObj() const { return mGXTexObj; diff --git a/src/Pack/RPGraphics/RPGrpScreen.cpp b/src/Pack/RPGraphics/RPGrpScreen.cpp new file mode 100644 index 00000000..4191fdcf --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpScreen.cpp @@ -0,0 +1,40 @@ +#include + +#include + +RPGrpScreen RPGrpScreen::g_default_screen; + +void RPGrpScreen::Initialize(const u16 maxX[TV_MODE_MAX], + const u16 maxY[TV_MODE_MAX]) { + EGG::Screen::Initialize(maxX, maxY, &g_default_screen); +} + +void RPGrpScreen::BeginDrawQuad() const { + EGG::DrawGX::BeginDrawScreen(GetCanvasMode() == CANVASMODE_LU, false, + false); +} + +void RPGrpScreen::DrawQuad(f32 x, f32 y, f32 width, f32 height, GXColor color) { + nw4r::math::MTX34 mtx; + + CalcMatrixForDrawQuad(&mtx, x, y, nw4r::math::FAbs(width - x), + nw4r::math::FAbs(height - y)); + EGG::DrawGX::DrawDL(EGG::DrawGX::DL_SCREEN, mtx, color); +} + +void RPGrpScreen::BeginDrawQuadTexture(bool alpha) const { + EGG::DrawGX::BeginDrawScreen(GetCanvasMode() == CANVASMODE_LU, true, alpha); +} + +void RPGrpScreen::DrawQuadTexture(f32 x, f32 y, f32 width, f32 height, + EGG::ResTIMG* pTextureRes, GXColor color) { + RPGrpTexture tex = RPGrpTexture(pTextureRes); + nw4r::math::MTX34 mtx; + + GXColor colorTemp = color; + + GXLoadTexObj(&tex.GetTexObj(), GX_TEXMAP0); + CalcMatrixForDrawQuad(&mtx, x, y, nw4r::math::FAbs(width - x), + nw4r::math::FAbs(height - y)); + EGG::DrawGX::DrawDL(EGG::DrawGX::DL_SCREEN_TEXTURE, mtx, colorTemp); +} diff --git a/src/Pack/RPGraphics/RPGrpTexture.cpp b/src/Pack/RPGraphics/RPGrpTexture.cpp new file mode 100644 index 00000000..094872f8 --- /dev/null +++ b/src/Pack/RPGraphics/RPGrpTexture.cpp @@ -0,0 +1,16 @@ +#include + +#include + +RPGrpTexture::RPGrpTexture(const EGG::ResTIMG* pRes) { + EGG::GXUtility::getTexObj(&mGXTexObj, *pRes); +} + +RPGrpTexture::RPGrpTexture(RPGrpHandle handle, const char* pName) { + nw4r::g3d::ResFile file = + RPGrpModelResManager::GetCurrent() + ->GetData(handle); + + EGG::GXUtility::getTexObj(&mGXTexObj, file.GetResTex(pName), GX_CLAMP, + GX_CLAMP, GX_LINEAR, GX_LINEAR); +}