diff --git a/branches/CardCupForNBD/CardCup/OMakefile b/branches/CardCupForNBD/CardCup/OMakefile index 4e9b587..df3abc5 100644 --- a/branches/CardCupForNBD/CardCup/OMakefile +++ b/branches/CardCupForNBD/CardCup/OMakefile @@ -17,18 +17,33 @@ CTR_APPTYPE=CARD SUPPORTED_TARGETS = CTR-T*.Process.MPCore.* -SAMPLED_DEMOS_COMMON_INCLUDE_DIR = $(dir $(HORIZON_ROOT)/../CTR/SampleDemos/common/include) -INCLUDES += $(SAMPLED_DEMOS_COMMON_INCLUDE_DIR) +INCLUDES += $(NW4C_ROOT)/include SOURCES[] = main.cpp - scrollBuffer.cpp + Drawer.cpp LIBS += lib_demo \ libnn_am \ libnn_cup \ libnn_ns \ +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_demo) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_dev) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_lyt) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_ut) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_font) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_gfx) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_anim) +LIBFILES += $`(addprefix $(NW4C_ROOT)$(DIRSEP)libraries$(DIRSEP)$(config.getTargetSubDirectory true)$(DIRSEP), libnw_os) + +ROMFS_ROOT = romfiles +ROMFS_FILES[] = All.arc +ROMFS_FILES[] += + $(ROMFS_ROOT)/shaders/nwlyt_PaneShader.shbin + $(ROMFS_ROOT)/shaders/nwlyt_ConstColorShader.shbin + $(ROMFS_ROOT)/shaders/nwfont_TextWriterShader.shbin + $(ROMFS_ROOT)/shaders/nwfont_RectDrawerShader.shbin DESCRIPTOR = $(HORIZON_ROOT)/resources/specfiles/SelfCup.desc @@ -39,6 +54,8 @@ ROM_SPEC_FILE = CardCup.rsf CTR_BANNER_SPEC = $(TARGET_PROGRAM).bsf -include $(ROOT_OMAKE)/modulerules +include $(NW4C_ROOT)/build/omake/modulerules build: $(DEFAULT_TARGETS) + +DefineDefaultRules() diff --git a/branches/CardCupForNBD/CardCup/main.cpp b/branches/CardCupForNBD/CardCup/main.cpp index 2be4b2a..dd16091 100644 --- a/branches/CardCupForNBD/CardCup/main.cpp +++ b/branches/CardCupForNBD/CardCup/main.cpp @@ -30,19 +30,8 @@ #include -#include "demo.h" -#include "scrollBuffer.h" - namespace { - const int s_GxHeapSize=0x800000; - nn::fnd::ExpHeap s_appHeap; - uptr s_GxHeap; - - demo::RenderSystemDrawing s_RenderSystem; - ScrollBuffer s_scrollBufferInstance; - ScrollBuffer *s_scrollBuffer; - char s_updaterBuffer[1<<20] NN_ATTRIBUTE_ALIGN(4096); // デモの初期化 @@ -67,52 +56,9 @@ namespace nn::fs::Initialize(); // appletの初期化 - //nn::applet::InitializeForSystem( nn::applet::PHOME_MENU_APPLET_ID, nn::applet::TYPE_SYS ); - //nn::applet::Initialize( nn::applet::TEST2_APPLET_ID); - //nn::applet::SetAppletMode(); nn::applet::Enable(); nn::cfg::Initialize(); - - // デバイスメモリの設定 - const int DEVICE_MEMORY_SIZE = 12*1024 * 1024; - NN_UTIL_PANIC_IF_FAILED(nn::os::SetDeviceMemorySize(DEVICE_MEMORY_SIZE)); - - // ヒープの初期化 - s_appHeap.Initialize(nn::os::GetDeviceMemoryAddress(), nn::os::GetDeviceMemorySize(), nn::os::ALLOCATE_OPTION_LINEAR); - - // 描画インスタンスの初期化 - s_GxHeap = reinterpret_cast(s_appHeap.Allocate(s_GxHeapSize)); - s_RenderSystem.Initialize(s_GxHeap, s_GxHeapSize); - - // 描画インスタンスの初期化 - s_scrollBufferInstance.Initialize(&s_RenderSystem); - s_scrollBuffer=&s_scrollBufferInstance; - - // GPU利用宣言 - nn::applet::AssignGpuRight(); - } - - // 消費時間取得用関数群 - s64 s_StartTick; - void SetTick() - { - s_StartTick=nn::os::Tick::GetSystemCurrent(); - } - s64 GetConsumedMillisec() - { - s64 endTick=nn::os::Tick::GetSystemCurrent(); - nn::os::Tick consumed(endTick-s_StartTick); - return ((nn::fnd::TimeSpan)consumed).GetMilliSeconds(); - } - - // 動いていることを知らせるための、くるくる画面表示取得用メソッド - const char s_progress[]="-\\|/"; - int s_progressIndex=0; - char GetProgressChar() - { - s_progressIndex=(s_progressIndex+1)%(sizeof(s_progress)-1); - return s_progress[s_progressIndex]; } nn::Result UpdateCore() @@ -121,14 +67,10 @@ namespace nn::cup::ProgressInfo info; /********************** アップデート*******************/ - SetTick(); - s_scrollBuffer->AppendText("Start Card Update")->Render(); NN_UTIL_RETURN_IF_FAILED(nn::cup::CTR::DoUpdate()); // ステータスがStartedになるまで、プログレスは取得できない - s_scrollBuffer->AppendText(""); do{ - s_scrollBuffer->ReplaceText(" %c Initializing", GetProgressChar())->Render(); result = nn::cup::CTR::GetProgressInfo(&info); NN_UTIL_RETURN_IF_FAILED(result); nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(40)); @@ -138,18 +80,11 @@ namespace if(info.state==nn::cup::CTR::UPDATE_STATE_FAILED){ NN_UTIL_RETURN_IF_FAILED(info.lastResult); } - s_scrollBuffer->ReplaceText(" - Initialized (%lldmsec)", GetConsumedMillisec()); /********************* アップデート中 ******************/ - SetTick(); - s_scrollBuffer->AppendText("")->Render(); do{ result = nn::cup::CTR::GetProgressInfo(&info); NN_UTIL_RETURN_IF_FAILED(result); - s_scrollBuffer->ReplaceText(" %c Title %d/%d, size %lld/%lld", - GetProgressChar(), - info.numImportedTitles, info.numTotalTitles, - info.importedSize, info.totalSize)->Render(); nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(40)); }while(info.state==nn::cup::CTR::UPDATE_STATE_STARTED); @@ -157,15 +92,11 @@ namespace if(info.state==nn::cup::CTR::UPDATE_STATE_FAILED){ NN_UTIL_RETURN_IF_FAILED(info.lastResult); } - s_scrollBuffer->AppendText(" - Imported (%lldmsec)", GetConsumedMillisec())->Render(); /***************** アップデート終了中 ******************/ - SetTick(); - s_scrollBuffer->AppendText("")->Render(); do{ result = nn::cup::CTR::GetProgressInfo(&info); NN_UTIL_RETURN_IF_FAILED(result); - s_scrollBuffer->ReplaceText(" %c Update Finalizing", GetProgressChar())->Render(); nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(40)); }while(info.state==nn::cup::CTR::UPDATE_STATE_FINALIZING); // 抜けた際のstateがFAILEDかどうか確認 @@ -174,8 +105,6 @@ namespace } /******************* アップデート終了 *******************/ - s_scrollBuffer->AppendText(" - Finalized (%lldmsec)", GetConsumedMillisec())->Render(); - s_scrollBuffer->AppendText(""); return nn::ResultSuccess(); } @@ -186,40 +115,25 @@ namespace nn::Result lastResult=nn::ResultSuccess(); /********************* CUPの初期化 *******************/ - s_scrollBuffer->AppendText("Initializing Cup Library")->Render(); - SetTick(); // 初期化開始前の時間をセット result=nn::cup::CTR::Initialize(s_updaterBuffer,sizeof(s_updaterBuffer)); if(result==nn::cup::CTR::ResultUpdatePartitionNotFound()){ - s_scrollBuffer->AppendText(" - Update Partition Not Found (%lldmsec)", GetConsumedMillisec())->Render(); - s_scrollBuffer->AppendText("")->Render(); *isHandledError=true; return result; } if(result==nn::cup::CTR::ResultUpdateNotRequired()){ - s_scrollBuffer->AppendText(" - Already Updated (%lldmsec)", GetConsumedMillisec())->Render(); - s_scrollBuffer->AppendText("")->Render(); *isHandledError=true; return result; } if(result==nn::cup::CTR::ResultInvalidUpdatePartitionFormat()){ - s_scrollBuffer->AppendText(" - Invalid Update Partition (%lldmsec)", GetConsumedMillisec())->Render(); - s_scrollBuffer->AppendText("")->Render(); *isHandledError=true; return result; } NN_UTIL_RETURN_IF_FAILED(result); - s_scrollBuffer->AppendText(" - Need Update (%lldmsec)", GetConsumedMillisec())->Render(); - s_scrollBuffer->AppendText("")->Render(); - lastResult=UpdateCore(); // Initializeに成功した場合のみ、再びInitializeするためにFinalizeが必要 - SetTick(); - s_scrollBuffer->AppendText("Finalizing Cup Library")->Render(); NN_UTIL_RETURN_IF_FAILED(nn::cup::CTR::Finalize()); - s_scrollBuffer->AppendText(" - Complete (%lldmsec)", GetConsumedMillisec())->Render(); - s_scrollBuffer->AppendText("")->Render(); return lastResult; } @@ -256,31 +170,25 @@ extern "C" void nnMain() break; } - nn::am::ProgramInfo outInfos; result = nn::am::GetProgramInfos(&outInfos, nn::fs::MEDIA_TYPE_NAND, &MMEN_PROGRAM_ID, 1); if (result.IsSuccess()) { - /******************** CUPの実行 *******************/ bool isHandledError = false; result = UpdateSequence(&isHandledError); if (isHandledError == false && result.IsFailure()) { { - // それ以外の場合は、Resultを表示 - s_scrollBuffer->AppendText(" - Unhandled Error: 0x%08x", result.GetPrintableBits()); - s_scrollBuffer->AppendText("")->Render(); + // TODO:それ以外の場合は、エラーアプレットを表示 } } } else if(result == nn::am::ResultNotFound()) { - s_scrollBuffer->AppendText("Cannot find Home Menu"); + // TODO:HOMEメニューが無いエラーをエラーアプレットで表示する } - s_scrollBuffer->AppendText("")->Render(); - nn::os::Tick before = nn::os::Tick::GetSystemCurrent(); const u8 SHUTDOWN_WAIT_SECONDS = 2; for(;;) @@ -291,27 +199,16 @@ extern "C" void nnMain() break; } - s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY0); + // 画面描画 if(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired()) { - s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 0, 1, 0, 1); + // TODO:成功したので終了処理に入る + } else { - s_RenderSystem.SetClearColor(NN_GX_DISPLAY0, 1, 0, 0, 1); + // TODO:失敗したのでエラー表示を続ける } - s_RenderSystem.Clear(); - s_RenderSystem.SwapBuffers(); - s_RenderSystem.SetRenderTarget(NN_GX_DISPLAY1); - if(result.IsSuccess() || result == nn::cup::CTR::ResultUpdateNotRequired()) - { - s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 0, 1, 0, 1); - } - else - { - s_RenderSystem.SetClearColor(NN_GX_DISPLAY1, 1, 0, 0, 1); - } - s_scrollBuffer->ReplaceText("%c Finished", GetProgressChar())->Render(); if ( nn::applet::IsExpectedToCloseApplication() ) { diff --git a/branches/CardCupForNBD/CardCup/romfiles/All.arc b/branches/CardCupForNBD/CardCup/romfiles/All.arc new file mode 100644 index 0000000..bd36560 Binary files /dev/null and b/branches/CardCupForNBD/CardCup/romfiles/All.arc differ diff --git a/branches/CardCupForNBD/CardCup/romfiles/shaders/nwfont_RectDrawerShader.shbin b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwfont_RectDrawerShader.shbin new file mode 100644 index 0000000..19b4ea6 Binary files /dev/null and b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwfont_RectDrawerShader.shbin differ diff --git a/branches/CardCupForNBD/CardCup/romfiles/shaders/nwfont_TextWriterShader.shbin b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwfont_TextWriterShader.shbin new file mode 100644 index 0000000..629eacf Binary files /dev/null and b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwfont_TextWriterShader.shbin differ diff --git a/branches/CardCupForNBD/CardCup/romfiles/shaders/nwlyt_ConstColorShader.shbin b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwlyt_ConstColorShader.shbin new file mode 100644 index 0000000..093513c Binary files /dev/null and b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwlyt_ConstColorShader.shbin differ diff --git a/branches/CardCupForNBD/CardCup/romfiles/shaders/nwlyt_PaneShader.shbin b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwlyt_PaneShader.shbin new file mode 100644 index 0000000..788bce4 Binary files /dev/null and b/branches/CardCupForNBD/CardCup/romfiles/shaders/nwlyt_PaneShader.shbin differ diff --git a/branches/CardCupForNBD/CardCup/scrollBuffer.cpp b/branches/CardCupForNBD/CardCup/scrollBuffer.cpp deleted file mode 100644 index 54de11e..0000000 --- a/branches/CardCupForNBD/CardCup/scrollBuffer.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: Horizon - File: scrollBuffer.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. - - $Rev$ - *---------------------------------------------------------------------------*/ - -#include -#include "scrollBuffer.h" - -using namespace std; - -char ScrollBuffer::s_buffers[MAX_BUFFER_LINE][MAX_BUFFER_CHARS]; - -char *ScrollBuffer::GetFormattedString(const char *fmt, va_list arg) -{ - static char formattedBuffer[MAX_BUFFER_CHARS]; - vsnprintf(formattedBuffer, MAX_BUFFER_CHARS, fmt, arg); - return formattedBuffer; -} - -ScrollBuffer *ScrollBuffer::Update() -{ - return this; -} - -ScrollBuffer *ScrollBuffer::AppendText(const char *fmt, ...) -{ - va_list vlist; - va_start(vlist, fmt); - - int nextPosition=(m_tail+1)%MAX_BUFFER_LINE; - if(nextPosition==m_head){ - // ヘッドとビューの移動 - if(m_head==m_currentView){ - m_currentView=(m_head+1)%MAX_BUFFER_LINE; - } - m_head=(m_head+1)%MAX_BUFFER_LINE; - - } - strlcpy(s_buffers[m_tail], GetFormattedString(fmt, vlist), MAX_BUFFER_CHARS); - m_tail=nextPosition; - NN_LOG("cup: %s\n", GetFormattedString(fmt, vlist)); - - // ビューの移動 - if((m_currentView+MAX_DISPLAY_LINES)%MAX_BUFFER_LINE==m_tail){ - m_currentView=(m_currentView+1)%MAX_BUFFER_LINE; - } - - return this; -} -ScrollBuffer *ScrollBuffer::ReplaceText(const char *fmt, ...) -{ - va_list vlist; - va_start(vlist, fmt); - - NN_ASSERT(m_tail!=m_head); - strlcpy(s_buffers[(m_tail-1)%MAX_BUFFER_LINE], GetFormattedString(fmt, vlist), MAX_BUFFER_CHARS); - - return this; -} - -void ScrollBuffer::Render() -{ - // 描画前処理 - m_render->SetRenderTarget(NN_GX_DISPLAY1); - m_render->Clear(); - m_render->SetColor(1.0f, 1.0f, 1.0f, 1.0f); - - // リングバッファなので、終端条件を調整 - int tail=(m_tailDrawText(0, (i-m_currentView)*FONT_SIZE, s_buffers[i%MAX_BUFFER_LINE]); - } - } - - // 描画転送 - m_render->SwapBuffers(); -} diff --git a/branches/CardCupForNBD/CardCup/scrollBuffer.h b/branches/CardCupForNBD/CardCup/scrollBuffer.h deleted file mode 100644 index 1d3563a..0000000 --- a/branches/CardCupForNBD/CardCup/scrollBuffer.h +++ /dev/null @@ -1,55 +0,0 @@ -/*---------------------------------------------------------------------------* - Project: Horizon - File: scrollBuffer.h - - 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$ - *---------------------------------------------------------------------------*/ - -#ifndef SCROLL_BUFFER_H_ -#define SCROLL_BUFFER_H_ - -#include "demo.h" -class ScrollBuffer -{ -private: - enum - { - MAX_BUFFER_LINE=128, - MAX_BUFFER_CHARS=80, - MAX_DISPLAY_LINES=20, - FONT_SIZE=12 - }; - // 表示文字のバッファ (リングバッファ) - static char s_buffers[MAX_BUFFER_LINE][MAX_BUFFER_CHARS]; - int m_head; - int m_tail; - int m_currentView; - - demo::RenderSystemDrawing *m_render; - - char *GetFormattedString(const char *fmt, va_list arg); - -public: - ScrollBuffer() : - m_head(0), m_tail(0), m_currentView(0) - {} - void Initialize(demo::RenderSystemDrawing *render) - { - m_render=render; - } - - ScrollBuffer *Update(); // キー入力を参照して、スクロールする - ScrollBuffer *AppendText(const char *fmt, ...); // 文字列を追加する - ScrollBuffer *ReplaceText(const char *fmt, ...); // 最新の文字列を置換する - void Render(); // レンダリング -}; - -#endif // SCROLL_BUFFER_H