From 52a69bc436febbbe657f2fcc272db7d3ec3bd54a Mon Sep 17 00:00:00 2001 From: N2614 Date: Thu, 20 Oct 2011 01:28:23 +0000 Subject: [PATCH] =?UTF-8?q?=E3=82=A8=E3=83=A9=E3=83=BC=E7=99=BA=E7=94=9F?= =?UTF-8?q?=E6=99=82=E3=81=AB=E8=A1=A8=E7=A4=BA=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@456 385bec56-5757-e545-9c3a-d8741f4650f1 --- trunk/Initializer2ndNUP/OMakefile | 6 +++ trunk/Initializer2ndNUP/main.cpp | 88 +++++++++++++++++++++++++++---- 2 files changed, 84 insertions(+), 10 deletions(-) diff --git a/trunk/Initializer2ndNUP/OMakefile b/trunk/Initializer2ndNUP/OMakefile index be7f2ab..049ad96 100644 --- a/trunk/Initializer2ndNUP/OMakefile +++ b/trunk/Initializer2ndNUP/OMakefile @@ -21,9 +21,15 @@ TARGET_PROGRAM = Initializer2ndNUP ROMFS_ROOT = romfiles CTR_BANNER_SPEC = AutoBoot.bsf +SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include) +INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \ + ../../common + SOURCES[] = main.cpp +LIBS += lib_demo + include $(ROOT_OMAKE)/modulerules build: $(DEFAULT_TARGETS) diff --git a/trunk/Initializer2ndNUP/main.cpp b/trunk/Initializer2ndNUP/main.cpp index be997ea..1c3e5bf 100644 --- a/trunk/Initializer2ndNUP/main.cpp +++ b/trunk/Initializer2ndNUP/main.cpp @@ -18,6 +18,24 @@ #include #include #include +#include +#include + +#include "demo.h" + +namespace +{ +demo::RenderSystemDrawing s_RenderSystem; +nn::os::StackBuffer<1024> s_StackBuffer; +std::vector s_DispMessage; + +} + +#define HANDLE_RESULT(result) \ + if(result.IsFailure()) \ + { \ + DrawResult(result); \ + } \ //========================================================================== // MSET ProgramId取得 @@ -59,25 +77,75 @@ nn::ProgramId GetProgramIdMsetWithRegion_() return nn::CTR::MakeProgramId(nn::CTR::PROGRAM_ID_CATEGORY_SYSTEM_APPLICATION, pid, nn::CTR::PROGRAM_ID_VERSION_APP); } -extern "C" void nnMain() +void DrawResult(nn::Result result) +{ + char buf[16]; + nn::nstd::TSNPrintf(buf, sizeof(buf), "%08X", result.GetPrintableBits()); + s_DispMessage.push_back(std::string(buf)); +} + +void JumpThreadFunc() { nn::Result result; - // os の初期化 - nn::os::Initialize(); - - nn::applet::Enable(); - - nn::cfg::Initialize(); - // 規定サイズの配列としてパラメータバッファを確保 u8 jumpParam[NN_APPLET_PARAM_BUF_SIZE]; *reinterpret_cast(jumpParam) = 124; // 本体初期化画面 + s_DispMessage.push_back(std::string("Prepare jump to mset")); // MSETにジャンプすることを宣言 - nn::applet::PrepareToJumpToOtherApplication(GetProgramIdMsetWithRegion_(), nn::fs::MEDIA_TYPE_NAND); + nn::Result rseult; + result = nn::applet::PrepareToJumpToOtherApplication(GetProgramIdMsetWithRegion_(), nn::fs::MEDIA_TYPE_NAND); + HANDLE_RESULT(result); + + s_DispMessage.push_back(std::string("Jump to mset")); // MSETにジャンプするためのパラメータを渡してジャンプ // この関数からは返ってこない - nn::applet::JumpToOtherApplication(jumpParam); + result = nn::applet::JumpToOtherApplication(jumpParam); + HANDLE_RESULT(result); +} + +extern "C" void nnMain() +{ + nn::applet::Enable(); + + nn::cfg::Initialize(); + + s_DispMessage.clear(); + // ジャンプ用スレッドの生成 + nn::os::Thread drawThread; + drawThread.Start(JumpThreadFunc, s_StackBuffer, nn::os::DEFAULT_THREAD_PRIORITY + 1); + + // RenderSystem の準備 + nn::fnd::ExpHeap appHeap; + appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize()); + const size_t s_GxHeapSize = 8 * 1024 * 1024; + uptr heapForGx = reinterpret_cast(appHeap.Allocate(s_GxHeapSize)); + s_RenderSystem.Initialize(heapForGx, s_GxHeapSize); + + s_RenderSystem.SetClearColor(NN_GX_DISPLAY_BOTH, 0, 0, 0, 1); + s_RenderSystem.SetColor(1, 1, 1); + + u32 counter = 0; + for (;;) + { + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.Clear(); + s_RenderSystem.DrawText(0, 0, "count = %d", counter++); + + s32 i = 0; + for(std::vector::iterator it = s_DispMessage.begin(); it != s_DispMessage.end(); it++) + { + s_RenderSystem.DrawText(0, (i + 1) * 10, "%s", it->c_str()); + } + + s_RenderSystem.SwapBuffers(); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1); + s_RenderSystem.Clear(); + s_RenderSystem.SwapBuffers(); + + s_RenderSystem.WaitVsync(NN_GX_DISPLAY_BOTH); + } }