mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-05-23%20-%20ctr.7z%20+%20svn_v1.068.zip/ctr/svn/ctr_Repair@432 385bec56-5757-e545-9c3a-d8741f4650f1
124 lines
3.9 KiB
C++
124 lines
3.9 KiB
C++
/*---------------------------------------------------------------------------*
|
|
Project: Horizon
|
|
File: main.cpp
|
|
|
|
Copyright 2011 Nintendo. All rights reserved.
|
|
|
|
These coded instructions, statements, and computer programs contain
|
|
proprietary information of Nintendo of America Inc. and/or Nintendo
|
|
Company Ltd., and are protected by Federal copyright law. They may
|
|
not be disclosed to third parties or copied or duplicated in any form,
|
|
in whole or in part, without the prior written consent of Nintendo.
|
|
|
|
$Rev$
|
|
*---------------------------------------------------------------------------*/
|
|
|
|
#include <nn.h>
|
|
#include <nn/applet.h>
|
|
#include <nn/cfg.h>
|
|
#include <nn/cfg/CTR/cfg_ApiInit.h>
|
|
#include <nn/cfg/CTR/detail/cfg_Keys.h>
|
|
#include <nn/ns.h>
|
|
|
|
#include "demo.h"
|
|
|
|
#define HANDLE_ERROR(result) \
|
|
if(result.IsFailure()) \
|
|
{ \
|
|
DrawError(result); \
|
|
} \
|
|
|
|
namespace
|
|
{
|
|
demo::RenderSystemDrawing s_RenderSystem;
|
|
}
|
|
|
|
extern "C" void nninitSetupDaemons(void)
|
|
{
|
|
}
|
|
|
|
void DrawError(nn::Result result)
|
|
{
|
|
s_RenderSystem.SetClearColor(NN_GX_DISPLAY_BOTH, 1, 0, 0, 1);
|
|
s_RenderSystem.SetColor(1, 1, 1);
|
|
|
|
for(;;)
|
|
{
|
|
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0);
|
|
s_RenderSystem.Clear();
|
|
s_RenderSystem.DrawText(0, 0, "Error: %08X", result.GetPrintableBits());
|
|
|
|
s_RenderSystem.SwapBuffers();
|
|
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1);
|
|
s_RenderSystem.Clear();
|
|
s_RenderSystem.SwapBuffers();
|
|
s_RenderSystem.WaitVsync(NN_GX_DISPLAY_BOTH);
|
|
}
|
|
}
|
|
|
|
extern "C" void nnMain()
|
|
{
|
|
nn::Result result;
|
|
nn::applet::Enable();
|
|
nn::cfg::CTR::init::Initialize();
|
|
|
|
// RenderSystem の準備
|
|
nn::fnd::ExpHeap appHeap;
|
|
appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize());
|
|
const size_t s_GxHeapSize = 8 * 1024 * 1024;
|
|
void* heapForGx = appHeap.Allocate(s_GxHeapSize);
|
|
s_RenderSystem.Initialize(reinterpret_cast<uptr>(heapForGx), s_GxHeapSize);
|
|
s_RenderSystem.SetClearColor(NN_GX_DISPLAY_BOTH, 0, 1, 0, 1);
|
|
|
|
result = nn::ns::InitializeForShell();
|
|
HANDLE_ERROR(result);
|
|
|
|
nn::cfg::detail::FirstLaunchInfoCfgData firstLaunch;
|
|
|
|
firstLaunch.mmen = 1;
|
|
firstLaunch.internet = 0;
|
|
firstLaunch.rsv = 0;
|
|
|
|
result = nn::cfg::CTR::init::SetConfig(
|
|
GET_CFG_KEY(nn::cfg::CTR::detail::NN_CFG_MENU, nn::cfg::CTR::detail::NN_CFG_MENU_FIRST_LAUNCH), &firstLaunch,
|
|
sizeof(firstLaunch));
|
|
HANDLE_ERROR(result);
|
|
result = nn::cfg::CTR::init::FlushConfig();
|
|
HANDLE_ERROR(result);
|
|
nn::cfg::CTR::init::Finalize();
|
|
|
|
|
|
for(;;)
|
|
{
|
|
// 電源ボタン短押しでシステムにシャットダウン通知を投げる
|
|
if( nn::applet::IsExpectedToProcessPowerButton())
|
|
{
|
|
result = nn::ns::ShutdownAsync();
|
|
HANDLE_ERROR(result);
|
|
}
|
|
|
|
// シャットダウンが始まったらアプリを終了させる
|
|
if ( nn::applet::IsExpectedToCloseApplication())
|
|
{
|
|
NN_LOG("Close Application\n");
|
|
result = nn::ns::FinalizeForShell();
|
|
HANDLE_ERROR(result);
|
|
s_RenderSystem.Finalize();
|
|
appHeap.Free(heapForGx);
|
|
appHeap.Finalize();
|
|
result = nn::applet::PrepareToCloseApplication();
|
|
HANDLE_ERROR(result);
|
|
result = nn::applet::CloseApplication();
|
|
HANDLE_ERROR(result);
|
|
}
|
|
|
|
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0);
|
|
s_RenderSystem.Clear();
|
|
s_RenderSystem.SwapBuffers();
|
|
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1);
|
|
s_RenderSystem.Clear();
|
|
s_RenderSystem.SwapBuffers();
|
|
s_RenderSystem.WaitVsync(NN_GX_DISPLAY_BOTH);
|
|
}
|
|
}
|