From ad02fbe88626d6373fa2f4bcca908d2d9fe90e49 Mon Sep 17 00:00:00 2001 From: shibbo Date: Sat, 2 Jul 2022 01:24:06 -0400 Subject: [PATCH] CaptureScreenDirector 100% --- csv/Screen.csv | 28 +++--- data/json/Screen.json | 2 +- data/percent.json | 2 +- docs/PROGRESS.md | 2 +- docs/lib/Screen.md | 30 +++---- include/Game/Screen/CaptureScreenDirector.h | 54 +++++++++++ include/Game/Util/MemoryUtil.h | 2 + include/Game/Util/ScreenUtil.h | 2 + include/JSystem/JUtility/JUTTexture.h | 2 +- include/JSystem/JUtility/JUTVideo.h | 31 +++++++ source/Game/Screen/CaptureScreenDirector.cpp | 95 ++++++++++++++++++++ source/Game/Screen/LayoutActor.cpp | 3 +- 12 files changed, 219 insertions(+), 34 deletions(-) create mode 100644 include/Game/Screen/CaptureScreenDirector.h create mode 100644 include/JSystem/JUtility/JUTVideo.h create mode 100644 source/Game/Screen/CaptureScreenDirector.cpp diff --git a/csv/Screen.csv b/csv/Screen.csv index 2859e83b..bcece30c 100644 --- a/csv/Screen.csv +++ b/csv/Screen.csv @@ -211,20 +211,20 @@ execute__Q213NrvCameraInfo24CameraInfoNrvFirstPersonCFP5Spine,CameraInfo.o,Scree execute__Q213NrvCameraInfo19CameraInfoNrvNormalCFP5Spine,CameraInfo.o,Screen.a,false execute__Q213NrvCameraInfo19CameraInfoNrvAppearCFP5Spine,CameraInfo.o,Screen.a,false execute__Q213NrvCameraInfo17CameraInfoNrvHideCFP5Spine,CameraInfo.o,Screen.a,false -__ct__21CaptureScreenDirectorFv,CaptureScreenDirector.o,Screen.a,false -captureIfAllow__21CaptureScreenDirectorFPCc,CaptureScreenDirector.o,Screen.a,false -capture__21CaptureScreenDirectorFv,CaptureScreenDirector.o,Screen.a,false -requestCaptureTiming__21CaptureScreenDirectorFPCc,CaptureScreenDirector.o,Screen.a,false -invalidateCaptureTiming__21CaptureScreenDirectorFPCc,CaptureScreenDirector.o,Screen.a,false -getResTIMG__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,false -getTexImage__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,false -getUsingTiming__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,false -getCurrentTiming__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,false -findFromName__21CaptureScreenDirectorCFPCc,CaptureScreenDirector.o,Screen.a,false -__ct__18CaptureScreenActorFUlPCc,CaptureScreenDirector.o,Screen.a,false -draw__18CaptureScreenActorCFv,CaptureScreenDirector.o,Screen.a,false -__dt__21CaptureScreenDirectorFv,CaptureScreenDirector.o,Screen.a,false -__dt__18CaptureScreenActorFv,CaptureScreenDirector.o,Screen.a,false +__ct__21CaptureScreenDirectorFv,CaptureScreenDirector.o,Screen.a,true +captureIfAllow__21CaptureScreenDirectorFPCc,CaptureScreenDirector.o,Screen.a,true +capture__21CaptureScreenDirectorFv,CaptureScreenDirector.o,Screen.a,true +requestCaptureTiming__21CaptureScreenDirectorFPCc,CaptureScreenDirector.o,Screen.a,true +invalidateCaptureTiming__21CaptureScreenDirectorFPCc,CaptureScreenDirector.o,Screen.a,true +getResTIMG__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,true +getTexImage__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,true +getUsingTiming__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,true +getCurrentTiming__21CaptureScreenDirectorCFv,CaptureScreenDirector.o,Screen.a,true +findFromName__21CaptureScreenDirectorCFPCc,CaptureScreenDirector.o,Screen.a,true +__ct__18CaptureScreenActorFUlPCc,CaptureScreenDirector.o,Screen.a,true +draw__18CaptureScreenActorCFv,CaptureScreenDirector.o,Screen.a,true +__dt__21CaptureScreenDirectorFv,CaptureScreenDirector.o,Screen.a,true +__dt__18CaptureScreenActorFv,CaptureScreenDirector.o,Screen.a,true __ct__16CenterScreenBlurFv,CenterScreenBlur.o,Screen.a,false init__16CenterScreenBlurFRC12JMapInfoIter,CenterScreenBlur.o,Screen.a,false appear__16CenterScreenBlurFv,CenterScreenBlur.o,Screen.a,false diff --git a/data/json/Screen.json b/data/json/Screen.json index 700acf32..904ea041 100644 --- a/data/json/Screen.json +++ b/data/json/Screen.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "label": "Screen", - "message": "2.55348%", + "message": "2.91154%", "color": "ff4040" } \ No newline at end of file diff --git a/data/percent.json b/data/percent.json index e8d8eb61..08b41de0 100644 --- a/data/percent.json +++ b/data/percent.json @@ -1,6 +1,6 @@ { "schemaVersion": 1, "label": "decompiled", - "message": "7.120582020095393%", + "message": "7.147069115853009%", "color": "blue" } \ No newline at end of file diff --git a/docs/PROGRESS.md b/docs/PROGRESS.md index 3c9cc80b..e7d73c57 100644 --- a/docs/PROGRESS.md +++ b/docs/PROGRESS.md @@ -19,7 +19,7 @@ | [RhythmLib](https://github.com/shibbo/Petari/blob/master/docs/lib/RhythmLib.md) | 0.0% | | [Ride](https://github.com/shibbo/Petari/blob/master/docs/lib/Ride.md) | 0.0% | | [Scene](https://github.com/shibbo/Petari/blob/master/docs/lib/Scene.md) | 7.59493670886076% | -| [Screen](https://github.com/shibbo/Petari/blob/master/docs/lib/Screen.md) | 2.553480652875606% | +| [Screen](https://github.com/shibbo/Petari/blob/master/docs/lib/Screen.md) | 2.911542934803915% | | [Speaker](https://github.com/shibbo/Petari/blob/master/docs/lib/Speaker.md) | 47.06886738759249% | | [System](https://github.com/shibbo/Petari/blob/master/docs/lib/System.md) | 7.724349605378544% | | [Util](https://github.com/shibbo/Petari/blob/master/docs/lib/Util.md) | 6.4024270638542715% | diff --git a/docs/lib/Screen.md b/docs/lib/Screen.md index 33d23e9c..4d361c08 100644 --- a/docs/lib/Screen.md +++ b/docs/lib/Screen.md @@ -17,7 +17,7 @@ | BrosButton.o | 0.0% | 0 / 21 | 0.0% | :x: | ButtonPaneController.o | 0.0% | 0 / 55 | 0.0% | :x: | CameraInfo.o | 0.0% | 0 / 30 | 0.0% | :x: -| CaptureScreenDirector.o | 0.0% | 0 / 14 | 0.0% | :x: +| CaptureScreenDirector.o | 100.0% | 14 / 14 | 100.0% | :white_check_mark: | CenterScreenBlur.o | 0.0% | 0 / 16 | 0.0% | :x: | CinemaFrame.o | 0.0% | 0 / 28 | 0.0% | :x: | CoinCounter.o | 100.0% | 22 / 22 | 100.0% | :white_check_mark: @@ -407,20 +407,20 @@ # CaptureScreenDirector.o | Symbol | Decompiled? | | ------------- | ------------- | -| __ct__21CaptureScreenDirectorFv | :x: | -| captureIfAllow__21CaptureScreenDirectorFPCc | :x: | -| capture__21CaptureScreenDirectorFv | :x: | -| requestCaptureTiming__21CaptureScreenDirectorFPCc | :x: | -| invalidateCaptureTiming__21CaptureScreenDirectorFPCc | :x: | -| getResTIMG__21CaptureScreenDirectorCFv | :x: | -| getTexImage__21CaptureScreenDirectorCFv | :x: | -| getUsingTiming__21CaptureScreenDirectorCFv | :x: | -| getCurrentTiming__21CaptureScreenDirectorCFv | :x: | -| findFromName__21CaptureScreenDirectorCFPCc | :x: | -| __ct__18CaptureScreenActorFUlPCc | :x: | -| draw__18CaptureScreenActorCFv | :x: | -| __dt__21CaptureScreenDirectorFv | :x: | -| __dt__18CaptureScreenActorFv | :x: | +| __ct__21CaptureScreenDirectorFv | :white_check_mark: | +| captureIfAllow__21CaptureScreenDirectorFPCc | :white_check_mark: | +| capture__21CaptureScreenDirectorFv | :white_check_mark: | +| requestCaptureTiming__21CaptureScreenDirectorFPCc | :white_check_mark: | +| invalidateCaptureTiming__21CaptureScreenDirectorFPCc | :white_check_mark: | +| getResTIMG__21CaptureScreenDirectorCFv | :white_check_mark: | +| getTexImage__21CaptureScreenDirectorCFv | :white_check_mark: | +| getUsingTiming__21CaptureScreenDirectorCFv | :white_check_mark: | +| getCurrentTiming__21CaptureScreenDirectorCFv | :white_check_mark: | +| findFromName__21CaptureScreenDirectorCFPCc | :white_check_mark: | +| __ct__18CaptureScreenActorFUlPCc | :white_check_mark: | +| draw__18CaptureScreenActorCFv | :white_check_mark: | +| __dt__21CaptureScreenDirectorFv | :white_check_mark: | +| __dt__18CaptureScreenActorFv | :white_check_mark: | # CenterScreenBlur.o diff --git a/include/Game/Screen/CaptureScreenDirector.h b/include/Game/Screen/CaptureScreenDirector.h new file mode 100644 index 00000000..208dbe4b --- /dev/null +++ b/include/Game/Screen/CaptureScreenDirector.h @@ -0,0 +1,54 @@ +#pragma once + +#include "Game/NameObj/NameObj.h" +#include "JSystem/JUtility/JUTTexture.h" + +struct TimingInfo { + const char* name; // _0 + s32 timing; // _4 + u32 _8; + u32 _C; +}; + +namespace { + const TimingInfo cTimingInfo[6] = { + { "GameScreen", 0x20, 0x1000000, 1 }, + { "Indirect", 1, 0, 0 }, + { "Camera", 4, 0x1000000, 1 }, + { "WipeMap", 5, 0x1000000, 1 }, + { "SystemWipe", 0x14, 0, 1 }, + { "Unused", 0x10, 0, 0 } + }; +}; + +class CaptureScreenDirector : public NameObj { +public: + CaptureScreenDirector(); + + virtual ~CaptureScreenDirector(); + + void captureIfAllow(const char *); + void capture(); + void requestCaptureTiming(const char *); + void invalidateCaptureTiming(const char *); + ResTIMG* getResTIMG() const; + ResTIMG* getTexImage() const; + const TimingInfo* getUsingTiming() const; + const TimingInfo* getCurrentTiming() const; + const TimingInfo* findFromName(const char *) const; + + const char* _C; + const char* mTimingType; // _10 + JUTTexture* mTexture; // _14 + u8 _18; +}; + +class CaptureScreenActor : public NameObj { +public: + CaptureScreenActor(u32, const char *); + + virtual ~CaptureScreenActor(); + virtual void draw() const; + + const char* mCameraName; // _C +}; \ No newline at end of file diff --git a/include/Game/Util/MemoryUtil.h b/include/Game/Util/MemoryUtil.h index b8925d43..276dda1f 100644 --- a/include/Game/Util/MemoryUtil.h +++ b/include/Game/Util/MemoryUtil.h @@ -21,6 +21,8 @@ namespace MR { JKRHeap* getAproposHeapForSceneArchive(f32); + JKRHeap* getStationedHeapGDDR3(); + void adjustHeapSize(JKRExpHeap *, const char *); class CurrentHeapRestorer { diff --git a/include/Game/Util/ScreenUtil.h b/include/Game/Util/ScreenUtil.h index 163395b2..bfdd7234 100644 --- a/include/Game/Util/ScreenUtil.h +++ b/include/Game/Util/ScreenUtil.h @@ -45,4 +45,6 @@ namespace MR { void forceToBlankCinemaFrame(); void requestOneUp(); + + void captureScreenIfAllow(const char *); }; diff --git a/include/JSystem/JUtility/JUTTexture.h b/include/JSystem/JUtility/JUTTexture.h index 5fd14937..7cb9485a 100644 --- a/include/JSystem/JUtility/JUTTexture.h +++ b/include/JSystem/JUtility/JUTTexture.h @@ -55,7 +55,7 @@ public: GXTexObj mTexObj; // _0 ResTIMG* _20; - u32* _24; + ResTIMG* _24; JUTPalette* _28; JUTPalette* mPalette; // _2C u8 mWrapS; // _30 diff --git a/include/JSystem/JUtility/JUTVideo.h b/include/JSystem/JUtility/JUTVideo.h new file mode 100644 index 00000000..0f027e84 --- /dev/null +++ b/include/JSystem/JUtility/JUTVideo.h @@ -0,0 +1,31 @@ +#pragma once + +#include +#include + +class JUTVideo { +public: + JUTVideo(const _GXRenderModeObj *); + + virtual ~JUTVideo(); + + _GXRenderModeObj* mRenderModeObj; // _4 + u32 _8; + u32 mRetraceCount; // _C + u32 _10; + u32 _14; + u32 _18; + VIRetraceCallback mPreRetractCb; // _1C + VIRetraceCallback mPostRetraceCb; // _20 + u32 _24; + u32 _28; + u8 _2C; + u8 _2D; + u8 _2E; + u8 _2F; + u32 _30; + OSMessage mMessage; // _34 + OSMessageQueue mMessageQueue; // _38 + + static JUTVideo* sManager; +}; \ No newline at end of file diff --git a/source/Game/Screen/CaptureScreenDirector.cpp b/source/Game/Screen/CaptureScreenDirector.cpp new file mode 100644 index 00000000..d1913d57 --- /dev/null +++ b/source/Game/Screen/CaptureScreenDirector.cpp @@ -0,0 +1,95 @@ +#include "Game/Screen/CaptureScreenDirector.h" +#include "JSystem/JUtility/JUTVideo.h" +#include + +CaptureScreenDirector::CaptureScreenDirector() : NameObj("画面キャプチャ") { + _C = NULL; + mTimingType = "Indirect"; + mTexture = NULL; + _18 = 0; + MR::CurrentHeapRestorer heap_restorer(MR::getStationedHeapGDDR3()); + mTexture = new JUTTexture(JUTVideo::sManager->mRenderModeObj->fbWidth, JUTVideo::sManager->mRenderModeObj->efbHeight, GX_TF_RGB565); +} + +void CaptureScreenDirector::captureIfAllow(const char *pName) { + const TimingInfo* info = findFromName(pName); + if (getUsingTiming() == info && (!getUsingTiming()->_C || _18)) { + capture(); + _18 = 0; + } +} + +void CaptureScreenDirector::capture() { + _GXRenderModeObj* renderObj = JUTVideo::sManager->mRenderModeObj; + GXSetCopyFilter(GX_FALSE, renderObj->sample_pattern, GX_FALSE, renderObj->vfilter); + mTexture->capture(0, 0, GX_TF_RGB565, false, 0); + GXSetCopyFilter(GX_FALSE, renderObj->sample_pattern, GX_TRUE, renderObj->vfilter); +} + +void CaptureScreenDirector::requestCaptureTiming(const char *pName) { + const TimingInfo* info = findFromName(pName); + if (!getCurrentTiming() || getCurrentTiming()->timing < info->timing) { + _C = pName; + _18 = 1; + } +} + +void CaptureScreenDirector::invalidateCaptureTiming(const char *pName) { + const TimingInfo* info = getCurrentTiming(); + if (info) { + if (strcmp(info->name, pName) == 0) { + _C = 0; + } + } +} + +ResTIMG* CaptureScreenDirector::getResTIMG() const { + return mTexture->_20; +} + +ResTIMG* CaptureScreenDirector::getTexImage() const { + return mTexture->_24; +} + +const TimingInfo* CaptureScreenDirector::getUsingTiming() const { + if (_C) { + return findFromName(_C); + } + + return findFromName(mTimingType); +} + +const TimingInfo* CaptureScreenDirector::getCurrentTiming() const { + if (_C) { + return findFromName(_C); + } + + return NULL; +} + +const TimingInfo* CaptureScreenDirector::findFromName(const char *pName) const { + for (u32 i = 0; i < 6; i++) { + if (strcmp(cTimingInfo[i].name, pName) == 0) { + return &cTimingInfo[i]; + } + } + + return NULL; +} + +CaptureScreenActor::CaptureScreenActor(u32 scene_arg, const char *pCameraName) : NameObj("画面キャプチャ") { + mCameraName = pCameraName; + MR::connectToScene(this, -1, -1, -1, scene_arg); +} + +void CaptureScreenActor::draw() const { + MR::captureScreenIfAllow(mCameraName); +} + +CaptureScreenDirector::~CaptureScreenDirector() { + +} + +CaptureScreenActor::~CaptureScreenActor() { + +} diff --git a/source/Game/Screen/LayoutActor.cpp b/source/Game/Screen/LayoutActor.cpp index c12934a4..2db6056d 100644 --- a/source/Game/Screen/LayoutActor.cpp +++ b/source/Game/Screen/LayoutActor.cpp @@ -1,5 +1,6 @@ #include "Game/Screen/LayoutActor.h" #include "Game/Screen/PaneEffectKeeper.h" +#include LayoutActor::LayoutActor(const char *pName, bool) : NameObj(pName), mManager(NULL), mSpine(NULL), mPaneEffectKeeper(NULL), mStarPointerTargetKeeper(NULL) { @@ -95,4 +96,4 @@ void LayoutActor::updateSpine() { if (mSpine) { mSpine->update(); } -} \ No newline at end of file +}