diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp b/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp index 784db50..e4bb786 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp +++ b/trunk/ConsoleDataMigration/ConsoleBackup/ConsoleBackup.cpp @@ -53,6 +53,7 @@ #include "common_Types.h" #include "VersionDetect.h" #include "HardwareInfo.h" +#include "ResFont.h" // svnリビジョン埋め込み用 #include "version.h" @@ -200,6 +201,9 @@ extern "C" void nnMain(void) demo::RenderSystemDrawing s_RenderSystem; s_RenderSystem.Initialize(heapForGx, s_GxHeapSize); + // ResFontの初期化 + common::InitializeResFont(); + // サウンドスレッドの起動 common::InitializeSimplePlayer(); diff --git a/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile b/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile index 8b09b65..9c02e1f 100644 --- a/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile +++ b/trunk/ConsoleDataMigration/ConsoleBackup/OMakefile @@ -43,11 +43,17 @@ SOURCES[] = ../common/SdMountManager.cpp ../common/PlayHistoryManager.cpp ../common/VersionDetect.cpp + ../common/ResFont.cpp CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf ROMFS_ROOT = ../common/romfiles +SHADER_BIN = nnfont_RectDrawerShader.shbin +SHADER_PATH = $(ROMFS_ROOT)/$(SHADER_BIN) + +ROMFS_DEPENDENCIES = $(SHADER_PATH) + LIBS += libnn_cfg \ libnn_driversEeprom \ libnn_driversi2c \ diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp index 3970329..1648120 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp +++ b/trunk/ConsoleDataMigration/ConsoleRestore/ConsoleRestore.cpp @@ -47,6 +47,7 @@ #include "HeapManager.h" #include "VersionDetect.h" #include "HardwareInfo.h" +#include "ResFont.h" // svnリビジョン埋め込み用 #include "version.h" @@ -215,6 +216,9 @@ extern "C" void nnMain(void) uptr heapForGx = reinterpret_cast(common::HeapManager::GetHeap()->Allocate(s_GxHeapSize)); s_RenderSystem.Initialize(heapForGx, s_GxHeapSize); + // ResFontの初期化 + common::InitializeResFont(); + // サウンドスレッドの起動 common::InitializeSimplePlayer(); diff --git a/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile b/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile index 7a6ed08..b7779e0 100644 --- a/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile +++ b/trunk/ConsoleDataMigration/ConsoleRestore/OMakefile @@ -46,11 +46,17 @@ SOURCES[] = ../common/configLoader.cpp ../common/PlayHistoryManager.cpp ../common/VersionDetect.cpp + ../common/ResFont.cpp CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf ROMFS_ROOT = ../common/romfiles +SHADER_BIN = nnfont_RectDrawerShader.shbin +SHADER_PATH = $(ROMFS_ROOT)/$(SHADER_BIN) + +ROMFS_DEPENDENCIES = $(SHADER_PATH) + LIBS += libnn_cfg \ libnn_driversEeprom \ libnn_driversi2c \ diff --git a/trunk/ConsoleDataMigration/common/DrawSystemState.cpp b/trunk/ConsoleDataMigration/common/DrawSystemState.cpp index b0206a0..cf0d418 100644 --- a/trunk/ConsoleDataMigration/common/DrawSystemState.cpp +++ b/trunk/ConsoleDataMigration/common/DrawSystemState.cpp @@ -14,12 +14,33 @@ *---------------------------------------------------------------------------*/ #include "DrawSystemState.h" +#include "ResFont.h" + +#include const u16 PROGRESS_MAX_LINES = 129; namespace common { +namespace +{ +u8 s_CupMajor; +u8 s_CupMinor; +u8 s_CupMicro; +u8 s_NupMajor; +nn::cfg::CTR::CfgRegionCode s_Region; +u8 s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN + 1]; +bit64 s_DeviceId; +char8 s_MacAddress[nn::nwm::Mac::MAC_STRING_SIZE]; +u64 s_FriendCode; +u8 s_BatteryRemain; +std::string s_AdapterState; +u8 s_Progress; +::std::vector* s_OperationMessage; + +} + u32 GetRenderTarget(u32 target, bool flip) { if(flip) @@ -39,6 +60,33 @@ u32 GetRenderTarget(u32 target, bool flip) } } +void SetTextWriterCore() +{ + GetTextWriter()->Print("\n"); + + GetTextWriter()->Printf("System Ver. %d.%d.%d-%d\n", s_CupMajor, s_CupMinor, s_CupMicro, s_NupMajor); + GetTextWriter()->Printf("System Region %s\n", nn::cfg::CTR::GetRegionCodeA3(s_Region)); + GetTextWriter()->Printf("Serial No. %s\n", s_SerialNo); + GetTextWriter()->Printf("Device ID %llu\n", s_DeviceId); + GetTextWriter()->Printf("MAC Address %s\n", s_MacAddress); + GetTextWriter()->Printf("Friend Code %04u-%04u-%04u\n", static_cast (s_FriendCode + / 100000000ULL % 10000ULL), static_cast (s_FriendCode / 10000ULL % 10000ULL), + static_cast (s_FriendCode % 10000ULL)); + + GetTextWriter()->Printf("Battery %d%%\n", s_BatteryRemain); + GetTextWriter()->Printf("AC Adaper %s\n", s_AdapterState.c_str()); + GetTextWriter()->Printf("Progress %02d%%\n", s_Progress); + GetTextWriter()->Print("\n"); + + ::std::vector::iterator it; + for (it = s_OperationMessage->begin(); it != s_OperationMessage->end(); it++) + { + GetTextWriter()->Printf("%s\n", it->c_str()); + } + + +} + void DrawSystemState ( const char* toolName, @@ -55,9 +103,26 @@ void DrawSystemState char8* macAddress, ::std::vector& operationMessage, nn::cfg::CTR::CfgRegionCode region, - u8* s_SerialNo + u8* serialNo ) { + // パラメータ保存 + s_AdapterState = adapterState; + s_CupMajor = mVerData->cup.majorVersion; + s_CupMinor = mVerData->cup.minorVersion; + s_CupMicro = mVerData->cup.microVersion; + s_NupMajor = mVerData->nup.majorVersion; + s_BatteryRemain = batteryRemain; + s_DeviceId = deviceId; + s_FriendCode = friendCode; + s_Progress = progress; + std::memcpy(s_MacAddress, macAddress, sizeof(s_MacAddress)); + s_Region = region; + std::memcpy(s_SerialNo, serialNo, sizeof(s_SerialNo)); + s_SerialNo[nn::cfg::CTR::CFG_SECURE_INFO_SERIAL_NO_LEN] = '\0'; + s_OperationMessage = &operationMessage; + + // デフォルトで上画面に描画するもの renderSystem.SetRenderTarget(GetRenderTarget(NN_GX_DISPLAY0, flip)); renderSystem.SetClearColor(GetRenderTarget(NN_GX_DISPLAY0, flip), NORMAL_COLOR); @@ -67,54 +132,40 @@ void DrawSystemState renderSystem.SetColor(1.f, 1.f, 1.f); u32 line = 0; - size_t fontSize = 8; - size_t spaceSize = fontSize + 2; - renderSystem.SetFontSize(fontSize); + size_t fontwidth = 8; + size_t fontheight = fontwidth + 2; - renderSystem.DrawText(0, line++ * spaceSize, "%s %s Rev.%s", toolName, __DATE__, toolVersion); + SetDrawTextHandler(SetTextWriterCore); + DrawResFont(GetRenderTarget(NN_GX_DISPLAY0, flip)); + + renderSystem.SetFontSize(fontwidth); + + // ツール名、ハイライト + renderSystem.DrawText(0, line++ * fontheight, "%s %s Rev.%s", toolName, __DATE__, toolVersion); renderSystem.SetColor(titleColor.r, titleColor.g, titleColor.b); - renderSystem.FillRectangle(0, (line - 1) * spaceSize, 400, spaceSize); + renderSystem.FillRectangle(0, (line - 1) * fontheight, 400, fontheight); renderSystem.SetColor(1.f, 1.f, 1.f); - renderSystem.DrawText(0, line++ * spaceSize, ""); + renderSystem.DrawText(0, line++ * fontheight, ""); - fontSize += 2; - spaceSize = fontSize + 2; - renderSystem.SetFontSize(fontSize); - renderSystem.DrawText(0, line++ * spaceSize, "System Ver. %d.%d.%d-%d", mVerData->cup.majorVersion, mVerData->cup.minorVersion, mVerData->cup.microVersion, - mVerData->nup.majorVersion); - renderSystem.DrawText(0, line++ * spaceSize, "System Region %s", nn::cfg::CTR::GetRegionCodeA3(region)); - renderSystem.DrawText(0, line++ * spaceSize, "Serial No. %s", s_SerialNo); - renderSystem.DrawText(0, line++ * spaceSize, "Device ID %llu", deviceId); - renderSystem.DrawText(0, line++ * spaceSize, "MAC Address %s", macAddress); - renderSystem.DrawText(0, line++ * spaceSize, "Friend Code %04u-%04u-%04u", static_cast (friendCode - / 100000000ULL % 10000ULL), static_cast (friendCode / 10000ULL % 10000ULL), - static_cast (friendCode % 10000ULL)); - - renderSystem.DrawText(0, line++ * spaceSize, "Battery %d%%", batteryRemain); - renderSystem.DrawText(0, line++ * spaceSize, "AC Adaper %s", adapterState.c_str()); - renderSystem.DrawText(0, line++ * spaceSize, "Progress %02d%%", progress); + // プログレスバー + fontwidth = 8; + fontheight = 14; + line += 9; + const u8 offset = 19; + const u8 diff = 4; renderSystem.SetColor(0.f, 0.2f, 0.f); - renderSystem.DrawLine(19 * fontSize, (line - 1) * spaceSize, 19 * fontSize + PROGRESS_MAX_LINES, (line - 1) - * spaceSize); - renderSystem.DrawLine(19 * fontSize, (line - 1) * spaceSize, 19 * fontSize, (line) * spaceSize); - renderSystem.DrawLine(19 * fontSize, (line) * spaceSize, 19 * fontSize + PROGRESS_MAX_LINES, (line) * spaceSize); - renderSystem.DrawLine(19 * fontSize + PROGRESS_MAX_LINES, (line - 1) * spaceSize, 19 * fontSize - + PROGRESS_MAX_LINES, (line) * spaceSize + 1); + renderSystem.DrawLine(offset * fontwidth, (line - 1) * fontheight - diff, offset * fontwidth + PROGRESS_MAX_LINES, (line - 1) + * fontheight - diff); + renderSystem.DrawLine(offset * fontwidth, (line - 1) * fontheight - diff, offset * fontwidth, (line) * fontheight - diff); + renderSystem.DrawLine(offset * fontwidth, (line) * fontheight - diff, offset * fontwidth + PROGRESS_MAX_LINES, (line) * fontheight - diff); + renderSystem.DrawLine(offset * fontwidth + PROGRESS_MAX_LINES, (line - 1) * fontheight - diff, offset * fontwidth + + PROGRESS_MAX_LINES, (line) * fontheight + 1 - diff); renderSystem.SetColor(0.f, 0.5f, 0.f); - renderSystem.FillRectangle(19 * fontSize, (line - 1) * spaceSize, progress * PROGRESS_MAX_LINES / 100 + 1, - spaceSize); + renderSystem.FillRectangle(offset * fontwidth, (line - 1) * fontheight - diff, progress * PROGRESS_MAX_LINES / 100 + 1, + fontheight); renderSystem.SetColor(1.f, 1.f, 1.f); - renderSystem.DrawText(0, line++ * spaceSize, ""); - - ::std::vector::iterator it; - for (it = operationMessage.begin(); it != operationMessage.end(); it++) - { - renderSystem.DrawText(0, line++ * spaceSize, "%s", it->c_str()); - } - - fontSize -= 2; - renderSystem.SetFontSize(fontSize); + renderSystem.DrawText(0, line++ * fontheight, ""); } } diff --git a/trunk/ConsoleDataMigration/common/ResFont.cpp b/trunk/ConsoleDataMigration/common/ResFont.cpp new file mode 100644 index 0000000..b0183df --- /dev/null +++ b/trunk/ConsoleDataMigration/common/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/ConsoleDataMigration/common/ResFont.h b/trunk/ConsoleDataMigration/common/ResFont.h new file mode 100644 index 0000000..ca53420 --- /dev/null +++ b/trunk/ConsoleDataMigration/common/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/ConsoleDataMigration/common/romfiles/lc.bcfnt b/trunk/ConsoleDataMigration/common/romfiles/lc.bcfnt new file mode 100644 index 0000000..28d1db0 Binary files /dev/null and b/trunk/ConsoleDataMigration/common/romfiles/lc.bcfnt differ diff --git a/trunk/ConsoleDataMigration/common/romfiles/nnfont_RectDrawerShader.shbin b/trunk/ConsoleDataMigration/common/romfiles/nnfont_RectDrawerShader.shbin new file mode 100644 index 0000000..4290c2c Binary files /dev/null and b/trunk/ConsoleDataMigration/common/romfiles/nnfont_RectDrawerShader.shbin differ