mirror of
https://github.com/rvtr/ctr_Repair.git
synced 2025-10-31 13:51:08 -04:00
164 lines
5.0 KiB
C++
164 lines
5.0 KiB
C++
/*---------------------------------------------------------------------------*
|
||
Project: Horizon
|
||
File: main.cpp
|
||
|
||
Copyright (C)2009 Nintendo Co., Ltd. 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.
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
|
||
//****************** 注意 *********************
|
||
// 作成者が手元でテストするためのインポータ
|
||
// シリアルチェックを省いているので
|
||
// 部外リリースに使ってはいけない
|
||
//***********************************************
|
||
|
||
#include <nn.h>
|
||
#include <nn/fs.h>
|
||
#include <nn/applet.h>
|
||
#include <nn/ndm.h>
|
||
//#include <nn/ndm/ndm_DebugControl.h>
|
||
#include <nn/ndm/ndm_UserControl.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#include "demo.h"
|
||
#include "../../body/ver.h"
|
||
#include "../../../common/sleep.h"
|
||
#include "../../../common/common.h"
|
||
#include "../../../common/shfnt.h"
|
||
#include "../../../common/test_data.h"
|
||
|
||
|
||
demo::RenderSystemDrawing s_RenderSystem;
|
||
nn::fnd::ExpHeap appHeap;
|
||
uptr heapForGx;
|
||
void ErrorStop(char *s);
|
||
void ErrorPOff(char *s);
|
||
|
||
nn::Result result;
|
||
|
||
//#define setColor(r,g,b,a) s_RenderSystem.SetColor(r,g,b,a)
|
||
void setColor(f32 r,f32 g,f32 b,f32 a){ shf_SetColor(r,g,b,a);}
|
||
//#define setText(x,y,s) s_RenderSystem.DrawText(x,y,s)
|
||
void drawText(u16 x,u16 y,char *s){ shf_DrawText_0( x,y,s);}
|
||
//上はASCIIのみ対応したTextWriterへのラッパ
|
||
//日本語表示の場合、WideTextWriterを使う(要sft_側の関数追加)
|
||
|
||
|
||
nn::hid::PadReader *hpr;
|
||
//入力待ち
|
||
nn::hid::PadStatus padStatus;
|
||
u32 WaitKey(u32 mask)
|
||
{
|
||
|
||
while(1){
|
||
hpr->ReadLatest(&padStatus);
|
||
if(padStatus.trigger & mask)return padStatus.trigger;
|
||
CheckSysBreak();
|
||
// int i = nn::ndm::GetDaemonStatus( nn::ndm::DN_CEC );
|
||
// if (i !=3 )NN_LOG("DN_CEC %d\n",i);
|
||
// i = nn::ndm::GetDaemonStatus( nn::ndm::DN_BOSS );
|
||
// if (i !=3 )NN_LOG("DN_BOSS %d\n",i);
|
||
//i = nn::ndm::GetDaemonStatus( nn::ndm::DN_NIM );
|
||
// if (i !=3 )NN_LOG("DN_NIM %d\n",i);
|
||
// i = nn::ndm::GetDaemonStatus( nn::ndm::DN_FRIENDS );
|
||
// if (i !=3 )NN_LOG("DN_FRIENDS %d\n",i);
|
||
}
|
||
}
|
||
|
||
//終了
|
||
void endfunc()
|
||
{
|
||
nn::hid::Finalize();
|
||
SharedFontFinalize();
|
||
nngxWaitVSync(NN_GX_DISPLAY_BOTH);//SDK2.0以降では不要?
|
||
s_RenderSystem.Finalize();
|
||
}
|
||
|
||
|
||
//エラー
|
||
void ErrorCommon(char *s,char *ss)
|
||
{
|
||
char str[128];
|
||
nn::fs::Unmount("rom:");
|
||
NN_LOG(s);
|
||
NN_LOG(" result = %d\n",result.GetDescription());
|
||
shf_SetScale(0.7,0.7);
|
||
setColor(1.0, 0.0, 0.0,1.0);
|
||
strcpy(str,"Error: ");
|
||
strcat(str,s);
|
||
drawText(10,100,str);
|
||
drawText(10,140,ss);
|
||
}
|
||
|
||
|
||
void ErrorStop(char *s)
|
||
{
|
||
ErrorCommon(s,"Push Home Button & end");
|
||
s_RenderSystem.SwapBuffers();
|
||
WaitKey(0);
|
||
}
|
||
|
||
void ErrorPoff(char *s)
|
||
{
|
||
ErrorCommon(s,"Push Power Button & Power Off");
|
||
drawText(10,160,"Home Button is invalid");
|
||
s_RenderSystem.SwapBuffers();
|
||
WaitKey(0);
|
||
}
|
||
|
||
void nnMain( void )
|
||
{
|
||
extern bool prohibitHome;// HOME ボタン禁止
|
||
|
||
nn::os::Initialize();
|
||
nn::fs::Initialize();
|
||
|
||
//DEA-SUPにて推奨のフリーズ暫定対策:無線デーモンを停止 (2011.3.1 現在)
|
||
//ただし、スリープ時の"いつのまに通信"は止まらない
|
||
//無線は使わないので本体横スイッチ切っとくのが確実
|
||
nn::ndm::Initialize();
|
||
result = nn::ndm::SuspendScheduler();
|
||
NN_LOG("%d",result.GetDescription());
|
||
|
||
//中断処理の準備
|
||
InitSysBreak((uptr)endfunc);
|
||
// グラフィックスライブラリの初期化は、以降で行わなければならない
|
||
// 他、アプリケーションの初期化処理
|
||
|
||
nn::hid::Initialize();
|
||
nn::hid::PadReader padReader;
|
||
hpr = &padReader;
|
||
|
||
nn::applet::DisableSleep();//スリープ非対応
|
||
|
||
// ヒープの確保
|
||
appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR);
|
||
|
||
const u32 s_GxHeapSize = 0x800000;
|
||
// RenderSystem の準備
|
||
heapForGx = reinterpret_cast<uptr>(appHeap.Allocate(s_GxHeapSize));
|
||
s_RenderSystem.Initialize(heapForGx, s_GxHeapSize);
|
||
SharedFontInit();
|
||
|
||
// スリープ要求に対する返答を有効にする
|
||
// また、蓋の状態チェックを行い蓋が閉じられているならスリープ要求が発生する
|
||
// nn::applet::EnableSleep(true);
|
||
|
||
s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0);
|
||
s_RenderSystem.Clear();
|
||
// s_RenderSystem.SetFontSize(12);
|
||
|
||
shf_SetScale(0.7,0.7);
|
||
if (result.IsFailure())ErrorStop("Initialize");//初期化に失敗
|
||
|
||
TestMain();//テストデータへ
|
||
|
||
}
|
||
|