diff --git a/trunk/BoxyardEraser/BoxyardEraser.bsf b/trunk/BoxyardEraser/BoxyardEraser.bsf new file mode 100644 index 0000000..104a94d Binary files /dev/null and b/trunk/BoxyardEraser/BoxyardEraser.bsf differ diff --git a/trunk/BoxyardEraser/BoxyardEraser.rsf b/trunk/BoxyardEraser/BoxyardEraser.rsf new file mode 100644 index 0000000..272b2af --- /dev/null +++ b/trunk/BoxyardEraser/BoxyardEraser.rsf @@ -0,0 +1,45 @@ +BasicInfo: + Title : TitleEraser + ProductCode: TitleEraser + BackupMemoryType: None + +TitleInfo: + Use: Evaluation + Category: Application + UniqueId: 0xf8021 + Version: 0 + +SystemControlInfo: + AppType : Application + StackSize : 0x4000 + Dependency : + - gpio + - pdn + - spi + - i2c + - mcu + - ptm + - codec + - cfg + - hid + - gsp + +AccessControlInfo: + Priority : 16 + DisableDebug : true + + FileSystemAccess: + - Debug + - Core + - CategoryFileSystemTool + + IoAccessControl: + - FsMountNand + +Option: + FreeProductCode: true + + +Rom: + # ROM に含めるファイルシステムのルートパスを指定します。 + HostRoot: "$(ROMFS_ROOT)" \ No newline at end of file diff --git a/trunk/BoxyardEraser/HeapManager.cpp b/trunk/BoxyardEraser/HeapManager.cpp new file mode 100644 index 0000000..29f4367 --- /dev/null +++ b/trunk/BoxyardEraser/HeapManager.cpp @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: HeapManager.cpp + + Copyright 2009 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 "HeapManager.h" + +namespace common +{ + +nn::fnd::ThreadSafeExpHeap HeapManager::s_AppHeap; + +HeapManager::HeapManager() +{ + // TODO 自動生成されたコンストラクター・スタブ + +} + +HeapManager::~HeapManager() +{ + // TODO Auto-generated destructor stub +} + +nn::fnd::ThreadSafeExpHeap* HeapManager::GetHeap() +{ + return &s_AppHeap; +} + +} diff --git a/trunk/BoxyardEraser/HeapManager.h b/trunk/BoxyardEraser/HeapManager.h new file mode 100644 index 0000000..b9fc469 --- /dev/null +++ b/trunk/BoxyardEraser/HeapManager.h @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: HeapManager.h + + Copyright 2009 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$ + *---------------------------------------------------------------------------*/ + +#ifndef HEAPMANAGER_H_ +#define HEAPMANAGER_H_ + +#include + +namespace common +{ + +class HeapManager +{ +public: + HeapManager(); + virtual ~HeapManager(); + + static nn::fnd::ThreadSafeExpHeap* GetHeap(); + +private: + // デバイスメモリ管理用拡張ヒープ + static nn::fnd::ThreadSafeExpHeap s_AppHeap; + +}; + +} // namespace common + +#endif /* HEAPMANAGER_H_ */ diff --git a/trunk/BoxyardEraser/OMakefile b/trunk/BoxyardEraser/OMakefile new file mode 100644 index 0000000..9a3ef58 --- /dev/null +++ b/trunk/BoxyardEraser/OMakefile @@ -0,0 +1,71 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: Horizon +# File: OMakefile +# +# 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. +# +# $Rev$ +#---------------------------------------------------------------------------- +SUPPORTED_TARGETS = CTR-T*.Process.MPCore.* +CTR_APPTYPE = BOTH +CTR_MAKE_DEVELOPMENT_IMAGE = true + +TARGET_PROGRAM = BoxyardEraser + +SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include) +INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) \ + +SOURCES[] = + main.cpp + ResFont.cpp + HeapManager.cpp + VersionDetect.cpp + +CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf + +ROMFS_ROOT = romfiles + +SHADER_BIN = nnfont_RectDrawerShader.shbin +SHADER_PATH = $(ROMFS_ROOT)/$(SHADER_BIN) + +ROMFS_DEPENDENCIES = $(SHADER_PATH) + +LIBS += libnn_cfg \ + libnn_driversEeprom \ + libnn_driversi2c \ + libnn_driversCal \ + libnn_crypto \ + libnn_driversCodec \ + libnn_spi \ + libnn_gpio \ + libnn_pdn \ + libnn_mcu \ + libnn_i2c \ + libnn_driversCamera \ + libnn_ps \ + libnn_driversRsa \ + lib_demo \ + libnn_nwm \ + libnn_friends \ + libnn_ns \ + libnn_am \ + libnn_nim_2_x \ + +INSTALL_SDK_TOOL = true + +ROM_SPEC_FILE = $(TARGET_PROGRAM).rsf +#DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/_private/RepairTool.desc +DESCRIPTOR = RepairTool.desc + +include $(ROOT_OMAKE)/modulerules + +VERSION_H = $(file version.h) + +build: $(DEFAULT_TARGETS) diff --git a/trunk/BoxyardEraser/OMakeroot b/trunk/BoxyardEraser/OMakeroot new file mode 100644 index 0000000..7ee1cb5 --- /dev/null +++ b/trunk/BoxyardEraser/OMakeroot @@ -0,0 +1,73 @@ +#!/usr/bin/env omake +#---------------------------------------------------------------------------- +# Project: Horizon +# File: OMakeroot +# +# 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. +# +# $Rev:$ +#---------------------------------------------------------------------------- + +# fBNgCAEgɂ‚Ă̐ +# +# a) \[XR[h[gfBNgɔzuꍇ +# : +# /OMakeroot +# /foo/bar/OMakefile +# +# : +# OMakefile ƓfBNgȉ objects images ܂B +# +# /foo/bar/objects/... +# /foo/bar/images/.. +# +# +# b) \[XR[h sources ȉɔzuꍇ +# : +# /OMakeroot +# /sources/foo/bar/OMakefile +# +# : +# [gfBNgȉ objects images ܂B +# +# /objects/foo/bar/... +# /images/foo/bar/... +# +# + +# [g‹ϐ̎擾 +public.HORIZON_ROOT = +if $(defined-env HORIZON_ROOT) + HORIZON_ROOT = $(absname $(getenv HORIZON_ROOT)) + export + +if $(defined-env CTRSDK_ROOT) + CTRSDK_ROOT = $(absname $(getenv CTRSDK_ROOT)) + if $(and $(defined-env HORIZON_ROOT), $(not $(equal $(HORIZON_ROOT), $(CTRSDK_ROOT)))) + eprintln(HORIZON_ROOT CTRSDK_ROOT v܂BpXݒ肷邩Aǂ炩`ĉB) + exit(1) + HORIZON_ROOT = $(CTRSDK_ROOT) + export + +if $(not $(HORIZON_ROOT)) + eprintln($"$$CTRSDK_ROOT `Ă܂") + exit(1) + +include $(HORIZON_ROOT)/build/omake/commondefs + +DefineCommandVars() + +.PHONY: all build clean clobber +.PHONY: run run-scripts run-emumem + +# +# OMakefile ̓ǂݍ +# +.SUBDIRS: . + diff --git a/trunk/BoxyardEraser/RepairTool.desc b/trunk/BoxyardEraser/RepairTool.desc new file mode 100644 index 0000000..d3d0e19 --- /dev/null +++ b/trunk/BoxyardEraser/RepairTool.desc @@ -0,0 +1,232 @@ +AccessControlDescriptor: + AffinityMask: 1 + AutoGen: true + CoreVersion: 2 + DescVersion: 2 + Descriptor: | + AP///wAABAACAAAAAAAFGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjIEAAAAAAABBUFQ6VQAAACRo + aW9GSU8AJGhvc3RpbzAkaG9zdGlvMWFjOnUAAAAAYm9zczpVAABkc3A6OkRT + UGZyZDp1AAAAZnM6VVNFUgBnc3A6OkdwdWhpZDpVU0VSaHR0cDpDAABuZG06 + dQAAAG53bTo6VURTcHRtOnUAAABweGk6ZGV2AHNvYzpVAAAAc3NsOkMAAABs + ZHI6cm8AAHBzOnBzAAAAY2ZnOm5vcgBtY3U6OkhXQ2FtOnUAAAAAY2ZnOmkA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA + AAAAAAAAAAD+//vw/7//8ec/APIA8JH/APaR/1D/gf9Y/4H/cP+B/3j/gf8B + AQD/AAIA/v////////////////////////////////////////////////// + ////////////////////////////////////////AAAAAAAAAAAAAAAAAAAA + ABUAAAAAAAAAAAAAAAAAAAI= + DisableDebug: false + EnableInterruptNumbers: [] + EnableSystemCalls: + ArbitrateAddress: 34 + Break: 60 + CancelTimer: 28 + ClearEvent: 25 + ClearTimer: 29 + CloseHandle: 35 + ConnectToPort: 45 + ControlMemory: 1 + CreateAddressArbiter: 33 + CreateEvent: 23 + CreateMemoryBlock: 30 + CreateMutex: 19 + CreateSemaphore: 21 + CreateThread: 8 + CreateTimer: 26 + DuplicateHandle: 39 + ExitProcess: 3 + ExitThread: 9 + GetCurrentProcessorNumber: 17 + GetHandleInfo: 41 + GetProcessAffinityMask: 4 + GetProcessId: 53 + GetProcessIdOfThread: 54 + GetProcessIdealProcessor: 6 + GetProcessInfo: 43 + GetResourceLimit: 56 + GetResourceLimitCurrentValues: 58 + GetResourceLimitLimitValues: 57 + GetSystemInfo: 42 + GetSystemTick: 40 + GetThreadAffinityMask: 13 + GetThreadContext: 59 + GetThreadId: 55 + GetThreadIdealProcessor: 15 + GetThreadInfo: 44 + GetThreadPriority: 11 + MapMemoryBlock: 31 + OutputDebugString: 61 + QueryMemory: 2 + ReleaseMutex: 20 + ReleaseSemaphore: 22 + SendSyncRequest1: 46 + SendSyncRequest2: 47 + SendSyncRequest3: 48 + SendSyncRequest4: 49 + SendSyncRequest: 50 + SetProcessAffinityMask: 5 + SetProcessIdealProcessor: 7 + SetThreadAffinityMask: 14 + SetThreadIdealProcessor: 16 + SetThreadPriority: 12 + SetTimer: 27 + SignalEvent: 24 + SleepThread: 10 + UnmapMemoryBlock: 32 + WaitSynchronization1: 36 + WaitSynchronizationN: 37 + FileSystemAccess: + - Debug + - DirectSdmc + - DirectSdmcWrite + - Core + - CategoryFileSystemTool + HandleTableSize: 512 + IORegisterMapping: + - 1ff50000-1ff57fff + - 1ff70000-1ff77fff + IdealProcessor: 1 + IoAccessControl: + - FsMountCardSpi + - FsMountNand + - FsMountTwln + MemoryMapping: + - 1f000000-1f5fffff:r + MemoryType: Application + Priority: 24 + ProgramId: 0x00040000ffffff00L + ServiceAccessControl: + - APT:U + - $hioFIO + - $hostio0 + - $hostio1 + - ac:u + - boss:U + - dsp::DSP + - frd:u + - fs:USER + - gsp::Gpu + - hid:USER + - http:C + - ndm:u + - nwm::UDS + - ptm:u + - pxi:dev + - soc:U + - ssl:C + - ldr:ro + - ps:ps + - cfg:nor + - mcu::HWC + - am:u + - cfg:i + Signature: | + aktZ4eHHc/0DJOO0+J0yS+OCTUDkOocI441pzjNa56jmsr3CsVoD5IGi9K+R + m+3gVcMc6DJHlflrsjGaEAg7a2s2b/yQ9kZAx8mwHgqihlD33eU73kOo0xV1 + hVLn2kWDDpweFKxPfjyfalqtwZLFAAnaz8HS852tokldYDVU6bchxCvF28aJ + vrVN0hHAvaJ2rVv/OMjgYIGwARPS7z5yDs2DxGbcJH55Q8KetUG0QFuXJZIC + g4eOXC2soHSnve1jKKvPfcaIJyBH+3fUVt1FQX88b8t8H51j5uSMbzTmskJY + rsMv6W6bler0T0zs8tHOS9aXCd75QTvpijFFgLQ14Q== + StorageId: + - 0 +CommonHeaderKey: + D: | + kVlG6tIpWOE416smaUI8k/v3soWJXEmzahOtNDHwHUyIKG/U7TWu2RsPHT+q + PvXaLZ6Rt34GqvZzVTpS0595/hqdkQEvFNQZyWTgi1XZJclnNFztAp4cje+l + c9rYm27XiqN01c4z/mJFf9EOFGDKuVTxS9YgOywWHCiOzsLMLc3bV09LGhGX + pMMtWk8CkubDU03onDLvIXT60Z0wJL2D65+cEtf2bt2CqBtIqBqwf7SYToNq + RnlPTohUQp0pXslnMllZ++PoWMOZhENAY6eA/ddwX43e3oHKDsAQPUtf8aX2 + nPf5fMKohI0SjqpFhsSh8mbBm+Bah02Xtd1OiF0XgQ== + DP: | + KRRQMwUuh9j3rsFqFXmkVfci7cnOObNolT5mISNLjOVyb5oBZSnjQGtwAGy3 + F3uUcdykCQi4ZZq1k+mzfuRr+tkKMfQbt9TJ2hHCUfmH5m7CSVr6uTlHaHmX + qXYgsknFDMEOHbwNFrI+89mAlyXwg0M2J9y5hHD3TYp3OfViHZE= + DQ: | + DsFfTFpoPFZYh5Hkb5apEE2WeS29NBt5wxhbqQ838TYeATtnFRKZJzbrVQ4G + TrNy8/pmaoZIUbK+xVCbO/FTid28jGVBOWQVig1KNrdk5nFjlvw3OHCwLIL7 + FyugGwkS7CTM0z+oNorMF71FRapRX0REE9FaCwmi4SNzi9UK2FM= + Exponent: | + AQAB + InverseQ: | + VhhJpDTD3EGpkm8BsN/SCBYOh9ozOVeMig81EjfFctH0u7TLwlMLVEJ96Z8h + 7oVh2c9ZQqWSBO8t/xhrQKdNjKo781rySHWDBjAewzULhUutV0QKUx1IG0wx + WeR3KdKWEURIsArdxT6dacyqOyb7xWdO40N/awZ+9Jv5G+RjCN4= + Modulus: | + 0DQPmbjwh2wztNIEgD/0To/vEjP93JCVQt71+OwxrsfxQYh3xPjcUSqGsZzv + vknSF68QjS5otNOhWMCGubCqn4+1wiFky5mp84xjSSJE0ji+JBomOaCmaC/q + WrEQGuZHIwWAvuMA68Hj/XC/FEV3nmol37j72CPoO3Aac39pgowuMiY4eshZ + TYmJL9K9mUMOXsJq++KoZl1mXEQmQIHfSQalG93yJwybdQs+TUJZy9LEEdGS + CL7Ei7i0bXb7HzS39AOC+g4OHhdCSGyRzutGkm7HoiiZdlK6ShpmBRUerAIl + ED9SuU+SQi9sjnsq3qTVNKbRF/Gzlr+7WrjWBCaxDw== + P: | + /UQWt9VELddu6yu01cCPt3MvdyGSXP+3xHFd3RDsNWQ3amiLFQf1EuXCiZQA + SzPfYOMZInTiVnvctanE9psQ43ZeMAdD3SPsg3uN11g8fr1O2YvTmKMB67K+ + 59DZhpX4vVdkr1/3NCW0ht/iWH4vhSvREH5rb/LL5aXaP5feKZk= + Q: | + 0nNwlIODzVV0tqZbySDZ4/UDG13lse24DQshAVSSb9/dpQs3POBP4bJBZ8HJ + /8N6CODEYhfkXYuWJi8p3vAXzNC5FcXQkZg0CxPK9jp6HPyadN/dfqFEUJ/8 + G8jqXVQt+aIfUDKOorzKRGE4J6UF8ChMqlZ1WkrfkAkszw+xaOc= +DefaultSpec: + AccessControlInfo: + AffinityMask: 1 + FirmwareVersion: 2 + HandleTableSize: 512 + IORegisterMapping: + - 1ff50000-1ff57fff + - 1ff70000-1ff77fff + IdealProcessor: 0 + MemoryMapping: + - 1f000000-1f5fffff:r + Priority: 16 + BasicInfo: + CompanyCode: "00" + Logo: Nintendo + Title: default + ExeFs: + ReadOnly: + - RO + ReadWrite: + - RW + Text: + - STUP_ENTRY + Media: + MediaType: Card + PlainRegion: + - .module_id + Rom: + DefaultReject: + - .* + File: + - "*" + SystemControlInfo: + Dependency: + ac: 0x0004013000002402L + am: 0x0004013000001502L + boss: 0x0004013000003402L + camera: 0x0004013000001602L + cecd: 0x0004013000002602L + cfg: 0x0004013000001702L + codec: 0x0004013000001802L + csnd: 0x0004013000002702L + dlp: 0x0004013000002802L + dsp: 0x0004013000001a02L + friends: 0x0004013000003202L + gpio: 0x0004013000001b02L + gsp: 0x0004013000001c02L + hid: 0x0004013000001d02L + http: 0x0004013000002902L + i2c: 0x0004013000001e02L + mcu: 0x0004013000001f02L + mic: 0x0004013000002002L + ndm: 0x0004013000002b02L + news: 0x0004013000003502L + nim: 0x0004013000002c02L + nwm: 0x0004013000002d02L + pdn: 0x0004013000002102L + ps: 0x0004013000003102L + ptm: 0x0004013000002202L + socket: 0x0004013000002e02L + spi: 0x0004013000002302L + ssl: 0x0004013000002f02L + StackSize: 16384 diff --git a/trunk/BoxyardEraser/ResFont.cpp b/trunk/BoxyardEraser/ResFont.cpp new file mode 100644 index 0000000..b0183df --- /dev/null +++ b/trunk/BoxyardEraser/ResFont.cpp @@ -0,0 +1,417 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: ResFont.cpp + + Copyright 2009 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$ + *---------------------------------------------------------------------------*/ + +//------------------------------------------------------------------ +// デモ: ResFont +// +// 概要 +// nn::font::ResFont の構築と破棄のサンプルです。 +// +// 操作 +// なし。 +// +//------------------------------------------------------------------ + +#include +#include +#include +#include +#include + +#include "ResFont.h" +#include "demo.h" +#include "HeapManager.h" + +namespace common +{ + +namespace +{ +const char s_ShaderBinaryFilePath[] = "rom:/nnfont_RectDrawerShader.shbin"; +const char s_FontFilePath[] = "rom:/lc.bcfnt"; + +const u8 s_Color = 255; + +nn::font::RectDrawer s_Drawer; +void* s_DrawerBuf; +nn::font::ResFont s_Font; +nn::font::DispStringBuffer *s_pDrawStringBuf0; +nn::font::TextWriter s_TextWriter; +void (*s_DrawTextFunc)() = NULL; + +//--------------------------------------------------------------------------- +//! @brief シェーダの初期化を行います。 +//! +//! @param[in,out] pResource 描画用リソースを管理するオブジェクトへのポインタ。 +//--------------------------------------------------------------------------- +void* +InitShaders(nn::font::RectDrawer* pDrawer) +{ + nn::fs::FileReader shaderReader(s_ShaderBinaryFilePath); + + const u32 fileSize = (u32)shaderReader.GetSize(); + + void* shaderBinary = HeapManager::GetHeap()->Allocate(fileSize); + NN_NULL_ASSERT(shaderBinary); + +#ifndef NN_BUILD_RELEASE + s32 read = +#endif // NN_BUILD_RELEASE + shaderReader.Read(shaderBinary, fileSize); + NN_ASSERT(read == fileSize); + + const u32 vtxBufCmdBufSize = + nn::font::RectDrawer::GetVertexBufferCommandBufferSize(shaderBinary, fileSize); + void *const vtxBufCmdBuf = HeapManager::GetHeap()->Allocate(vtxBufCmdBufSize); + NN_NULL_ASSERT(vtxBufCmdBuf); + pDrawer->Initialize(vtxBufCmdBuf, shaderBinary, fileSize); + + HeapManager::GetHeap()->Free(shaderBinary); + + return vtxBufCmdBuf; + +} + +//--------------------------------------------------------------------------- +//! @brief 描画の初期設定を行います。 +//! +//! @param[in] width 画面の幅。 +//! @param[in] height 画面の高さ。 +//--------------------------------------------------------------------------- +void +InitDraw( + s32 width, + s32 height +) +{ + // カラーバッファ情報 + // LCDの向きに合わせて、幅と高さを入れ替えています。 + const nn::font::ColorBufferInfo colBufInfo = { width, height, PICA_DATA_DEPTH24_STENCIL8_EXT }; + + const u32 screenSettingCommands[] = + { + + // ビューポートの設定 + NN_FONT_CMD_SET_VIEWPORT( 0, 0, colBufInfo.width, colBufInfo.height ), + + // シザー処理を無効 + NN_FONT_CMD_SET_DISABLE_SCISSOR( colBufInfo ), + + // wバッファの無効化 + // デプスレンジの設定 + // ポリゴンオフセットの無効化 + NN_FONT_CMD_SET_WBUFFER_DEPTHRANGE_POLYGONOFFSET( + 0.0f, // wScale : 0.0 でWバッファが無効 + 0.0f, // depth range near + 1.0f, // depth range far + 0, // polygon offset units : 0.0 で ポリゴンオフセットが無効 + colBufInfo), + }; + + nngxAdd3DCommand(screenSettingCommands, sizeof(screenSettingCommands), true); + + static const u32 s_InitCommands[] = + { + // カリングを無効 + NN_FONT_CMD_SET_CULL_FACE( NN_FONT_CMD_CULL_FACE_DISABLE ), + + // ステンシルテストを無効 + NN_FONT_CMD_SET_DISABLE_STENCIL_TEST(), + + // デプステストを無効 + // カラーバッファの全ての成分を書き込み可 + NN_FONT_CMD_SET_DEPTH_FUNC_COLOR_MASK( + false, // isDepthTestEnabled + 0, // depthFunc + true, // depthMask + true, // red + true, // green + true, // blue + true), // alpha + + // アーリーデプステストを無効 + NN_FONT_CMD_SET_ENABLE_EARLY_DEPTH_TEST( false ), + + // フレームバッファアクセス制御 + NN_FONT_CMD_SET_FBACCESS( + true, // colorRead + true, // colorWrite + false, // depthRead + false, // depthWrite + false, // stencilRead + false), // stencilWrite + }; + + nngxAdd3DCommand(s_InitCommands, sizeof(s_InitCommands), true); +} + +//--------------------------------------------------------------------------- +//! @brief ResFontを構築します。 +//! +//! @param[out] pFont 構築するフォントへのポインタ。 +//! @param[in] filePath ロードするフォントリソースファイル名。 +//! +//! @return ResFont構築の成否を返します。 +//--------------------------------------------------------------------------- +bool +InitFont( + nn::font::ResFont* pFont, + const char* filePath +) +{ + // フォントリソースをロードします + nn::fs::FileReader fontReader(filePath); + + s32 fileSize = (s32)fontReader.GetSize(); + if ( fileSize <= 0 ) + { + return false; + } + + void* buffer = HeapManager::GetHeap()->Allocate(fileSize, nn::font::GlyphDataAlignment); + if (buffer == NULL) + { + return false; + } + + s32 readSize = fontReader.Read(buffer, fileSize); + if (readSize != fileSize) + { + HeapManager::GetHeap()->Free(buffer); + return false; + } + + // フォントリソースをセットします + bool bSuccess = pFont->SetResource(buffer); + NN_ASSERT(bSuccess); + + //--- 既にリソースをセット済みであるか,ロード済みであるか、リソースが不正な場合に失敗します。 + if (! bSuccess) + { + HeapManager::GetHeap()->Free(buffer); + } + + // 描画用バッファを設定します。 + const u32 drawBufferSize = nn::font::ResFont::GetDrawBufferSize(buffer); + void* drawBuffer = HeapManager::GetHeap()->Allocate(drawBufferSize, 4); + NN_NULL_ASSERT(drawBuffer); + pFont->SetDrawBuffer(drawBuffer); + + return bSuccess; +} + +//--------------------------------------------------------------------------- +//! @brief ResFontを破棄します。 +//! +//! @param[in] pFont 破棄するフォントへのポインタ。 +//--------------------------------------------------------------------------- +void +CleanupFont(nn::font::ResFont* pFont) +{ + // 描画用バッファの無効化 + // 描画用バッファがセットされているなら 構築時に SetDrawBuffer に渡したバッファへの + // ポインタが返ってきます。 + void *const drawBuffer = pFont->SetDrawBuffer(NULL); + if (drawBuffer != NULL) + { + HeapManager::GetHeap()->Free(drawBuffer); + } + + // フォントがセットされているなら SetResource 時に渡したリソースへの + // ポインタが返ってきます。 + void *const resource = pFont->RemoveResource(); + if (resource != NULL) + { + HeapManager::GetHeap()->Free(resource); + } + + // RemoveResource 後は再度 SetResource するまでフォントとして使用できません。 +} + +//--------------------------------------------------------------------------- +//! @brief 表示文字列用バッファを確保します。 +//! +//! @param[in] charMax 表示する文字列の最大文字数。 +//! +//! @return 確保した表示文字列用バッファへのポインタを返します。 +//--------------------------------------------------------------------------- +nn::font::DispStringBuffer* +AllocDispStringBuffer(s32 charMax) +{ + const u32 DrawBufferSize = nn::font::CharWriter::GetDispStringBufferSize(charMax); + void *const bufMem = HeapManager::GetHeap()->Allocate(DrawBufferSize); + NN_NULL_ASSERT(bufMem); + + return nn::font::CharWriter::InitDispStringBuffer(bufMem, charMax); +} + +//--------------------------------------------------------------------------- +//! @brief 文字列表示用にモデルビュー行列と射影行列を設定します。 +//! +//! @param[in] pDrawer RectDrawerオブジェクトへのポインタ。 +//! @param[in] width 画面の幅。 +//! @param[in] height 画面の高さ。 +//--------------------------------------------------------------------------- +void +SetupTextCamera( + nn::font::RectDrawer* pDrawer, + s32 width, + s32 height +) +{ + // 射影行列を正射影に設定 + { + // 左上原点とし、Y軸とZ軸の向きが逆になるように設定します。 + nn::math::MTX44 proj; + f32 znear = 0.0f; + f32 zfar = -1.0f; + f32 t = 0; + f32 b = static_cast(width); + f32 l = 0; + f32 r = static_cast(height); + nn::math::MTX44OrthoPivot(&proj, l, r, b, t, znear, zfar, nn::math::PIVOT_UPSIDE_TO_TOP); + pDrawer->SetProjectionMtx(proj); + } + + // モデルビュー行列を単位行列に設定 + { + nn::math::MTX34 mv; + nn::math::MTX34Identity(&mv); + pDrawer->SetViewMtxForText(mv); + } +} + +//--------------------------------------------------------------------------- +//! @brief ASCII文字列を描画します。 +//! +//! @param[in] pDrawer RectDrawerオブジェクトへのポインタ。 +//! @param[in] pDrawStringBuf DispStringBufferオブジェクトへのポインタ。 +//! @param[in] pFont フォントへのポインタ。 +//! @param[in] width 画面の幅。 +//! @param[in] height 画面の高さ。 +//--------------------------------------------------------------------------- +void +DrawAscii( + nn::font::RectDrawer* pDrawer, + nn::font::DispStringBuffer* pDrawStringBuf, + nn::font::ResFont* pFont, + s32 width, + s32 height +) +{ + s_TextWriter.SetDispStringBuffer(pDrawStringBuf); + s_TextWriter.SetFont(pFont); + + s_TextWriter.SetCursor(0, 0, 1.f); + + s_TextWriter.StartPrint(); + if(s_DrawTextFunc != NULL) + { + s_DrawTextFunc(); + } + + s_TextWriter.EndPrint(); + pDrawer->BuildTextCommand(&s_TextWriter); + + + // 文字の色は、文字列の描画コマンドを再作成しなくても変更できます。 + s_TextWriter.SetTextColor(nn::util::Color8(s_Color, s_Color, s_Color, s_Color)); + + pDrawer->DrawBegin(); + + SetupTextCamera(pDrawer, width, height); + s_TextWriter.UseCommandBuffer(); + + pDrawer->DrawEnd(); +} + +} // namespace + +void SetDrawTextHandler(void (*func)()) +{ + s_DrawTextFunc = func; +} + + +//--------------------------------------------------------------------------- +//! @brief サンプルのメイン関数です。 +//--------------------------------------------------------------------------- +void +InitializeResFont() +{ + const size_t ROMFS_BUFFER_SIZE = 1024 * 64; + static char buffer[ROMFS_BUFFER_SIZE]; + NN_UTIL_PANIC_IF_FAILED( + nn::fs::MountRom(16, 16, buffer, ROMFS_BUFFER_SIZE)); + + // フォントの構築 + { +#ifndef NN_BUILD_RELEASE + bool bSuccess = +#endif // NN_BUILD_RELEASE + InitFont(&s_Font, s_FontFilePath); + NN_ASSERTMSG(bSuccess, "Fail to load ResFont."); + } + + // 描画リソースの構築 + s_DrawerBuf = InitShaders(&s_Drawer); + + // 描画文字列用バッファの確保 + s_pDrawStringBuf0 = AllocDispStringBuffer(512); + + nn::fs::Unmount("rom:"); + +} + +void DrawResFont(s32 display) +{ + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + if(display == NN_GX_DISPLAY0) + { + InitDraw(NN_GX_DISPLAY0_WIDTH, NN_GX_DISPLAY0_HEIGHT); + + DrawAscii(&s_Drawer, s_pDrawStringBuf0, &s_Font, NN_GX_DISPLAY0_WIDTH, NN_GX_DISPLAY0_HEIGHT); + } + else if(display == NN_GX_DISPLAY1) + { + InitDraw(NN_GX_DISPLAY1_WIDTH, NN_GX_DISPLAY1_HEIGHT); + + DrawAscii(&s_Drawer, s_pDrawStringBuf0, &s_Font, NN_GX_DISPLAY1_WIDTH, NN_GX_DISPLAY1_HEIGHT); + } + + nngxUpdateState(NN_GX_STATE_ALL); +} + +void FinalizeResFont() +{ + s_Drawer.Finalize(); + + // 描画リソースの破棄 + HeapManager::GetHeap()->Free(s_DrawerBuf); + + // フォントの破棄 + CleanupFont(&s_Font); + + // 描画文字列用バッファの解放 + HeapManager::GetHeap()->Free(s_pDrawStringBuf0); +} + +nn::font::TextWriter* GetTextWriter() +{ + return &s_TextWriter; +} + +} diff --git a/trunk/BoxyardEraser/ResFont.h b/trunk/BoxyardEraser/ResFont.h new file mode 100644 index 0000000..ca53420 --- /dev/null +++ b/trunk/BoxyardEraser/ResFont.h @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: ResFont.h + + Copyright 2009 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$ + *---------------------------------------------------------------------------*/ + +#ifndef RESFONT_H_ +#define RESFONT_H_ + +#include + +namespace common +{ + +void InitializeResFont(); +void DrawResFont(s32 display); +void SetDrawTextHandler(void (*func)()); +nn::font::TextWriter* GetTextWriter(); + + +} + + +#endif /* RESFONT_H_ */ diff --git a/trunk/BoxyardEraser/VersionDetect.cpp b/trunk/BoxyardEraser/VersionDetect.cpp new file mode 100644 index 0000000..21352ab --- /dev/null +++ b/trunk/BoxyardEraser/VersionDetect.cpp @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: VersionDetect.cpp + + Copyright 2009 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 +#include +#include + +#include "VersionDetect.h" +#include "HeapManager.h" + +namespace common +{ + +nn::Result GetCupVersion(nn::pl::CTR::CardUpdateVersion* cup, nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result; + const size_t BUF_SIZE = 1024; + u8 buf[BUF_SIZE]; + // CUPバージョン + { + result = nn::fs::MountContent("cver:", nn::fs::MEDIA_TYPE_NAND, common::cCupVerId[region], 0, 1, 1, buf, + BUF_SIZE); + NN_UTIL_RETURN_IF_FAILED(result); + + nn::fs::FileInputStream fis; + + result = fis.TryInitialize(L"cver:/version.bin"); + NN_UTIL_RETURN_IF_FAILED(result); + if (result.IsSuccess()) + { + s64 fileSize = fis.GetSize(); + NN_LOG("version.bin size = %lld\n", fileSize); + s32 ret; + void* addr = NULL; + addr = common::HeapManager::GetHeap()->Allocate(fileSize); + if (addr != NULL) + { + result = fis.TryRead(&ret, addr, fileSize); + NN_UTIL_RETURN_IF_FAILED(result); + if (result.IsSuccess()) + { + nn::pl::CTR::CardUpdateVersion* ver_buf = reinterpret_cast (addr); + + std::memcpy(cup, ver_buf, sizeof(nn::pl::CTR::CardUpdateVersion)); + } + common::HeapManager::GetHeap()->Free(addr); + } + } + fis.Finalize(); + + nn::fs::Unmount("cver:"); + } + + return result; +} + +nn::Result GetNupVersion(nn::pl::CTR::NetworkUpdateVersion* nup, nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result; + const size_t BUF_SIZE = 1024; + u8 buf[BUF_SIZE]; + + // NUPバージョン + { + result = nn::fs::MountContent("nver:", nn::fs::MEDIA_TYPE_NAND, common::cNupVerId[region], 0, 1, 1, buf, + BUF_SIZE); + NN_UTIL_RETURN_IF_FAILED(result); + + nn::fs::FileInputStream fis; + + result = fis.TryInitialize(L"nver:/version.bin"); + NN_UTIL_RETURN_IF_FAILED(result); + if (result.IsSuccess()) + { + s64 fileSize = fis.GetSize(); + NN_LOG("version.bin size = %lld\n", fileSize); + s32 ret; + void* addr = NULL; + addr = common::HeapManager::GetHeap()->Allocate(fileSize); + if (addr != NULL) + { + result = fis.TryRead(&ret, addr, fileSize); + NN_UTIL_RETURN_IF_FAILED(result); + if (result.IsSuccess()) + { + nn::pl::CTR::NetworkUpdateVersion* ver_buf = + reinterpret_cast (addr); + + std::memcpy(nup, ver_buf, sizeof(nn::pl::CTR::NetworkUpdateVersion)); + } + common::HeapManager::GetHeap()->Free(addr); + } + } + + fis.Finalize(); + nn::fs::Unmount("nver:"); + } + + return result; +} + +nn::Result GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result; + result = GetCupVersion(&mVerData->cup, region); + NN_UTIL_RETURN_IF_FAILED(result); + result = GetNupVersion(&mVerData->nup, region); + NN_UTIL_RETURN_IF_FAILED(result); +} + +} + diff --git a/trunk/BoxyardEraser/VersionDetect.h b/trunk/BoxyardEraser/VersionDetect.h new file mode 100644 index 0000000..e9f3b28 --- /dev/null +++ b/trunk/BoxyardEraser/VersionDetect.h @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: VersionDetect.h + + Copyright 2009 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$ + *---------------------------------------------------------------------------*/ + +#ifndef VERSIONDETECT_H_ +#define VERSIONDETECT_H_ + +#include +#include +#include + +namespace common +{ + +// TODO:リージョン追加時に範囲外アクセスにならないよう注意 +const nn::ProgramId cCupVerId[] = +{ + nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_JP, + nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_US, + nn::pl::CTR::SHAREDDATA_TITLEID_CUP_VERSION_EU, +}; + +const nn::ProgramId cNupVerId[] = +{ + nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_JP, + nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_US, + nn::pl::CTR::SHAREDDATA_TITLEID_NUP_VERSION_EU, +}; + + +struct VerDef +{ + nn::pl::CTR::CardUpdateVersion cup; + nn::pl::CTR::NetworkUpdateVersion nup; +}; + +nn::Result GetSystemVersion(common::VerDef* mVerData, nn::cfg::CTR::CfgRegionCode region); + +} + + +#endif /* VERSIONDETECT_H_ */ diff --git a/trunk/BoxyardEraser/banner/model.cbmd b/trunk/BoxyardEraser/banner/model.cbmd new file mode 100644 index 0000000..f1c7b62 Binary files /dev/null and b/trunk/BoxyardEraser/banner/model.cbmd differ diff --git a/trunk/BoxyardEraser/banner/sound.cbsd b/trunk/BoxyardEraser/banner/sound.cbsd new file mode 100644 index 0000000..f1c7b62 Binary files /dev/null and b/trunk/BoxyardEraser/banner/sound.cbsd differ diff --git a/trunk/BoxyardEraser/banner/unknown24x24.ctpk b/trunk/BoxyardEraser/banner/unknown24x24.ctpk new file mode 100644 index 0000000..794b136 --- /dev/null +++ b/trunk/BoxyardEraser/banner/unknown24x24.ctpk @@ -0,0 +1 @@ +888yyYyYyyyYyyYyyyyYyYy8 \ No newline at end of file diff --git a/trunk/BoxyardEraser/banner/unknown48x48.ctpk b/trunk/BoxyardEraser/banner/unknown48x48.ctpk new file mode 100644 index 0000000..8c7da16 --- /dev/null +++ b/trunk/BoxyardEraser/banner/unknown48x48.ctpk @@ -0,0 +1 @@ +Y8888ƺ8888YYyyYYޚ޺yY8YyYYޚyY8ޚ8 \ No newline at end of file diff --git a/trunk/BoxyardEraser/main.cpp b/trunk/BoxyardEraser/main.cpp new file mode 100644 index 0000000..5af0782 --- /dev/null +++ b/trunk/BoxyardEraser/main.cpp @@ -0,0 +1,311 @@ +/*---------------------------------------------------------------------------* + Project: Horizon + File: main.cpp + + Copyright 2009 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 +#include +#include +#include +#include +#include +#include + +#include +#include + +#include "demo.h" +#include "ResFont.h" +#include "HeapManager.h" +#include "VersionDetect.h" + +#define UTIL_RETURN_IF_NOT_AM_NOT_FOUND(result) \ + if(result.IsFailure()) \ + { \ + if(result != nn::am::ResultNotFound()) \ + { \ + return result; \ + } \ + nn::dbg::PrintResult(result); \ +} \ + +namespace { + +nn::Result DeleteBoxyard(nn::ProgramId programId); +nn::Result DownGradeNupVersion(nn::cfg::CTR::CfgRegionCode region); +void FatalDrawing(nn::Result result); + +const size_t ERASE_THREAD_STACK_SIZE = 0x1000; +nn::os::Thread s_EraseThread; +nn::os::StackBuffer s_EraseThreadStack; + +demo::RenderSystemDrawing s_RenderSystem; + +// バージョン情報 +common::VerDef s_VerData; + +// グラフィックスに割り当てるメモリ +const size_t s_GxHeapSize = 0x800000; + +::std::vector* s_pOperationMessage; + +// インポートする +bit8 s_ReadBuf[64 * 1024]; + +const nn::ProgramId BOXYARD_PROGRAM_ID[] = +{ + 0x0004001000023000ULL, // JP + 0x0004001000024000ULL, // US + 0x0004001000025000ULL // EU +}; + +const nn::ProgramId NUP_VERSION_PROGRAM_ID[] = +{ + 0x000400DB00016202ULL, // JP + 0x000400DB00016302ULL, // US + 0x000400DB00016102ULL // EU +}; + +const wchar_t* ROM_NUP_VERSION_PATH[] = +{ +#ifndef USE_PROD_CIA + L"rom:/000400DB00016202-0_0_0-nup.version.JP-UnfixedKey.cia", // JP + L"rom:/000400DB00016302-0_0_0-nup.version.US-UnfixedKey.cia", // US + L"rom:/000400DB00016102-0_0_0-nup.version.EU-UnfixedKey.cia" // EU +#else + L"rom:/000400DB00016202-0_0_0-nup.version.JP.master.ols.cia", // JP + L"rom:/000400DB00016302-0_0_0-nup.version.US.master.ols.cia", // US + L"rom:/000400DB00016102-0_0_0-nup.version.EU.master.ols.cia" // EU +#endif +}; + +void EraseThreadFunc(nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result; + + s_pOperationMessage->push_back(std::string("")); + s_pOperationMessage->push_back(std::string("Deleting...")); + // BOXYARDを消去する + result = DeleteBoxyard(BOXYARD_PROGRAM_ID[region]); + if(result.IsFailure()) + { + nn::dbg::PrintResult(result); + s_pOperationMessage->push_back(std::string("Failed Delete Program")); + FatalDrawing(result); + } + s_pOperationMessage->push_back(std::string("Done.")); + s_pOperationMessage->push_back(std::string("")); + + s_pOperationMessage->push_back(std::string("Updating System...")); + // NUPバージョンを更新する + result = DownGradeNupVersion(region); + if (result.IsFailure()) + { + nn::dbg::PrintResult(result); + s_pOperationMessage->push_back(std::string("Failed DownGrade NUP Version")); + FatalDrawing(result); + } + + + s_pOperationMessage->push_back(std::string("Done.")); + s_pOperationMessage->push_back(std::string("")); + + s_pOperationMessage->push_back(std::string("Finished.")); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 1, 0, 0); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 0, 1, 0, 0); +} + +nn::Result DownGradeNupVersion(nn::cfg::CTR::CfgRegionCode region) +{ + nn::Result result = nn::ResultSuccess(); + + if(region > sizeof(NUP_VERSION_PROGRAM_ID) / sizeof(NUP_VERSION_PROGRAM_ID[0]) - 1) + { + return nn::Result(nn::Result::LEVEL_STATUS, nn::Result::SUMMARY_INVALID_ARGUMENT, nn::Result::MODULE_COMMON, + nn::Result::DESCRIPTION_INVALID_ENUM_VALUE); + } + nn::ProgramID programId = NUP_VERSION_PROGRAM_ID[region]; + + // リージョンに合わせて削除する + result = nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, programId); + UTIL_RETURN_IF_NOT_AM_NOT_FOUND(result); + + nn::fs::FileOutputStream* stream; + result = nn::am::BeginImportProgram(&stream, nn::fs::MEDIA_TYPE_NAND); + NN_UTIL_RETURN_IF_FAILED(result); + + NN_LOG("Importing: %ls...", ROM_NUP_VERSION_PATH[region]); + nn::fs::FileInputStream in; + + const size_t ROMFS_BUFFER_SIZE = 1024 * 64; + static char buffer[ROMFS_BUFFER_SIZE]; + NN_UTIL_PANIC_IF_FAILED( + nn::fs::MountRom(16, 16, buffer, ROMFS_BUFFER_SIZE)); + + result = in.TryInitialize(ROM_NUP_VERSION_PATH[region]); + NN_UTIL_RETURN_IF_FAILED(result); + + s64 fileSize = in.GetSize(); + s32 totalRead = 0; + s32 readSize = 0; + do + { + result = in.TryRead(&readSize, s_ReadBuf, sizeof(s_ReadBuf)); + stream->Write(s_ReadBuf, readSize); + totalRead += readSize; + } while (totalRead < fileSize); + + in.Finalize(); + nn::fs::Unmount("rom:"); + + result = nn::am::EndImportProgram(stream); + NN_UTIL_RETURN_IF_FAILED(result); + NN_LOG(" done.\n"); + + return result; +} + +nn::Result DeleteBoxyard(nn::ProgramId programId) +{ + nn::Result result; + + NN_LOG("Deleting Boxyard Program..."); + // リージョンに合わせて削除する + result = nn::am::DeleteProgram(nn::fs::MEDIA_TYPE_NAND, programId); + UTIL_RETURN_IF_NOT_AM_NOT_FOUND(result); + NN_LOG("Done\n"); + + NN_LOG("Deleting Boxyard eTicket..."); + // チケットを削除する + result = nn::am::DeleteTicket(programId); + UTIL_RETURN_IF_NOT_AM_NOT_FOUND(result); + NN_LOG("Done\n"); + + return result; +} + +void SetTextWriterCore() +{ + using namespace common; + + GetTextWriter()->Print("3DMovie Eraser\n\n"); + ::std::vector::iterator it; + for (it = s_pOperationMessage->begin(); it != s_pOperationMessage->end(); it++) + { + GetTextWriter()->Printf("%s\n", it->c_str()); + } + +} + +void FatalDrawing(nn::Result result) +{ + char resultStr[32]; + std::snprintf(resultStr, sizeof(resultStr), result.GetPrintableBits()); + s_pOperationMessage->push_back(resultStr); + + for(;;) + { + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 1.f, 0, 0, 0); + s_RenderSystem.Clear(); + + common::SetDrawTextHandler(SetTextWriterCore); + common::DrawResFont(NN_GX_DISPLAY0); + s_RenderSystem.SwapBuffers(); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 1.f, 0, 0, 0); + s_RenderSystem.Clear(); + + s_RenderSystem.SwapBuffers(); + } +} + +} + +extern "C" void nnMain(void) +{ + // os の初期化 + nn::os::Initialize(); + + // fs の初期化 + nn::fs::Initialize(); + + // appletの初期化 + nn::applet::Enable( false ); + + // hid の初期化 + nn::Result result = nn::hid::Initialize(); + NN_UTIL_PANIC_IF_FAILED(result); + + // cfg の初期化 + nn::cfg::CTR::init::Initialize(); + nn::cfg::CTR::system::Initialize(); + + // リージョンの取得 + nn::cfg::CTR::CfgRegionCode region; + region = nn::cfg::CTR::GetRegion(); + + // am の初期化 + nn::am::InitializeForLocalImporter(); + + // ヒープの確保 + common::HeapManager::GetHeap()->Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR); + + // RenderSystem の準備 + uptr heapForGx = reinterpret_cast(common::HeapManager::GetHeap()->Allocate(s_GxHeapSize)); + s_RenderSystem.Initialize(heapForGx, s_GxHeapSize); + + // ResFontの初期化 + common::InitializeResFont(); + + std::vector operationMessage; + s_pOperationMessage = &operationMessage; + + // バージョンの取得 + result = common::GetSystemVersion(&s_VerData, region); + if(result.IsFailure()) + { + nn::dbg::PrintResult(result); + operationMessage.push_back(std::string("Failed Get Version Data")); + FatalDrawing(result); + } + + operationMessage.push_back(std::string("Region: ") + std::string(nn::cfg::CTR::GetRegionCodeA3(region))); + + s_EraseThread.Start(EraseThreadFunc, region, s_EraseThreadStack); + + // ボタン入力 + nn::hid::PadReader padReader; + nn::hid::PadStatus padStatus; + + s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 0, 0, 0); + s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 0, 0, 0, 0); + + for(;;) + { + padReader.ReadLatest(&padStatus); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + s_RenderSystem.Clear(); + + common::SetDrawTextHandler(SetTextWriterCore); + common::DrawResFont(NN_GX_DISPLAY0); + s_RenderSystem.SwapBuffers(); + + s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1); + s_RenderSystem.Clear(); + s_RenderSystem.SwapBuffers(); + nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(10)); + } +} diff --git a/trunk/BoxyardEraser/romfiles/000400DB00016102-0_0_0-nup.version.EU-UnfixedKey.cia b/trunk/BoxyardEraser/romfiles/000400DB00016102-0_0_0-nup.version.EU-UnfixedKey.cia new file mode 100644 index 0000000..e00a27f Binary files /dev/null and b/trunk/BoxyardEraser/romfiles/000400DB00016102-0_0_0-nup.version.EU-UnfixedKey.cia differ diff --git a/trunk/BoxyardEraser/romfiles/000400DB00016202-0_0_0-nup.version.JP-UnfixedKey.cia b/trunk/BoxyardEraser/romfiles/000400DB00016202-0_0_0-nup.version.JP-UnfixedKey.cia new file mode 100644 index 0000000..466972a Binary files /dev/null and b/trunk/BoxyardEraser/romfiles/000400DB00016202-0_0_0-nup.version.JP-UnfixedKey.cia differ diff --git a/trunk/BoxyardEraser/romfiles/000400DB00016302-0_0_0-nup.version.US-UnfixedKey.cia b/trunk/BoxyardEraser/romfiles/000400DB00016302-0_0_0-nup.version.US-UnfixedKey.cia new file mode 100644 index 0000000..a061dce Binary files /dev/null and b/trunk/BoxyardEraser/romfiles/000400DB00016302-0_0_0-nup.version.US-UnfixedKey.cia differ diff --git a/trunk/BoxyardEraser/romfiles/lc.bcfnt b/trunk/BoxyardEraser/romfiles/lc.bcfnt new file mode 100644 index 0000000..28d1db0 Binary files /dev/null and b/trunk/BoxyardEraser/romfiles/lc.bcfnt differ diff --git a/trunk/BoxyardEraser/romfiles/nnfont_RectDrawerShader.shbin b/trunk/BoxyardEraser/romfiles/nnfont_RectDrawerShader.shbin new file mode 100644 index 0000000..4290c2c Binary files /dev/null and b/trunk/BoxyardEraser/romfiles/nnfont_RectDrawerShader.shbin differ