mirror of
https://github.com/rvtr/ctr_card_test.git
synced 2025-06-18 14:45:42 -04:00

git-svn-id: file:///Volumes/Transfer/gigaleak_20231201/2020-09-30%20-%20paladin.7z/paladin/ctr_card_test@10 ff8ce827-af98-4349-adb5-4c00699b5328
1812 lines
38 KiB
C++
1812 lines
38 KiB
C++
/*---------------------------------------------------------------------------*
|
||
Project: $project_name
|
||
File: $name
|
||
|
||
Copyright (C)$copyright_year 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 "nakayama.h"
|
||
|
||
namespace nn{
|
||
namespace red{
|
||
namespace nakayama{
|
||
|
||
|
||
settingInfo CardTestProgram::setting;
|
||
detailInfo CardTestProgram::detail;
|
||
void* CardTestProgram::card_test_buffer;
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::Display
|
||
|
||
@brief コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Display::Display(Position position)
|
||
{
|
||
this->position = position;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::Clear
|
||
|
||
@brief 画面をクリアします。(SwapBufferを呼び出す必要があります。)
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Display::Clear()
|
||
{
|
||
GetTextDrawFramework()->ClearDisplay(position);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::Draw
|
||
|
||
@brief 文字を描画します。(SwapBufferを呼び出す必要があります。)
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Display::Draw(int X, int Y, string text, bool lf)
|
||
{
|
||
GetTextDrawFramework()->SetRenderingTarget(position);
|
||
GetTextDrawFramework()->DrawText2d(X, Y, text.c_str());
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::Draw
|
||
|
||
@brief サイズ指定して文字を描画します。(SwapBufferを呼び出す必要があります。)
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Display::Draw(int X, int Y, string text, int size, bool lf)
|
||
{
|
||
GetTextDrawFramework()->SetFontSize(size);
|
||
GetTextDrawFramework()->SetRenderingTarget(position);
|
||
GetTextDrawFramework()->DrawText2d(X, Y, text.c_str());
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::SwapBuffer
|
||
|
||
@brief バッファをスワップします。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Display::SwapBuffer()
|
||
{
|
||
GetTextDrawFramework()->SwapBuffer(position);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::GetInstance
|
||
|
||
@brief インスタンスを取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Display& Display::GetInstance(Display::Position pos)
|
||
{
|
||
static Display upperDisplay(Display::Upper);
|
||
static Display lowerDisplay(Display::Lower);
|
||
static Display bothDisplay(Display::Both);
|
||
|
||
if(pos == Display::Upper)
|
||
{
|
||
return upperDisplay;
|
||
}
|
||
else if(pos == Display::Lower)
|
||
{
|
||
return lowerDisplay;
|
||
}
|
||
else if(pos == Display::Both)
|
||
{
|
||
}
|
||
|
||
return bothDisplay;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Display::GetInstance
|
||
|
||
@brief TextDrawFrameworkインスタンスを取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
nn::demo::DrawFrameworkEx* Display::GetTextDrawFramework()
|
||
{
|
||
static bool initialized = false;
|
||
static nn::demo::DrawFrameworkEx textFramework;
|
||
|
||
if(!initialized)
|
||
{
|
||
nn::os::InitializeDeviceMemory();
|
||
static nn::fnd::ExpHeap appHeap(nn::os::GetDeviceMemoryAddress(), NN_OS_DEVICE_MEMORY_SIZE, nn::os::ALLOCATE_OPTION_LINEAR);
|
||
static uptr addrForGx = reinterpret_cast<uptr>(appHeap.Allocate(0x800000));
|
||
textFramework.Initialize(addrForGx, 0x800000);
|
||
initialized = true;
|
||
|
||
// 画面クリア
|
||
textFramework.SetClearColor(NN_GX_DISPLAY0, 0.0f, 0.0f, 0.0f, 1.0f);
|
||
textFramework.SetClearColor(NN_GX_DISPLAY1, 0.0f, 0.0f, 0.0f, 1.0f);
|
||
textFramework.ClearDisplay(NN_GX_DISPLAY_BOTH);
|
||
textFramework.SwapBuffer(NN_GX_DISPLAY_BOTH);
|
||
|
||
// 色セット
|
||
textFramework.SetColor(1.0f, 1.0f, 1.0f);
|
||
}
|
||
return &textFramework;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugDisplay::Clear
|
||
|
||
@brief 画面をクリアします。(SwapBufferを呼び出す必要があります。)
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void DebugDisplay::Clear()
|
||
{
|
||
NN_LOG("\n\n\n\n\n\n\n\n\n\n");
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugDisplay::Draw
|
||
|
||
@brief 文字を描画します。(SwapBufferを呼び出す必要があります。)
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void DebugDisplay::Draw(int X, int Y, string text, bool lf)
|
||
{
|
||
NN_LOG("%s",text.c_str());
|
||
if(lf)
|
||
NN_LOG("\n");
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugDisplay::Draw
|
||
|
||
@brief サイズ指定して文字を描画します。(SwapBufferを呼び出す必要があります。)
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void DebugDisplay::Draw(int X, int Y, string text, int size, bool lf)
|
||
{
|
||
NN_LOG("%s",text.c_str());
|
||
if(lf)
|
||
NN_LOG("\n");
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugDisplay::SwapBuffer
|
||
|
||
@brief バッファをスワップします。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void DebugDisplay::SwapBuffer()
|
||
{
|
||
NN_LOG("\n\n\n\n\n\n\n\n\n\n");
|
||
|
||
// 連続で描画させないため、キー変化があるまでここで待機する
|
||
KeyPad::GetInstance().WaitForChange();
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugDisplay::GetInstance
|
||
|
||
@brief インスタンスを取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Display& DebugDisplay::GetInstance(Display::Position pos)
|
||
{
|
||
static DebugDisplay debugDisplay(pos);
|
||
return debugDisplay;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyPad::KeyPad
|
||
|
||
@brief コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
KeyPad::KeyPad() {
|
||
m_DetectionTime = 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyPad::GetInstance
|
||
|
||
@brief インスタンスを取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
KeyPad& KeyPad::GetInstance()
|
||
{
|
||
static KeyPad keypad;
|
||
return keypad;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyPad::ReadKey
|
||
|
||
@brief キーを読み取ります。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void KeyPad::ReadKey()
|
||
{
|
||
m_KeyPrevious = m_KeyCurrent;
|
||
m_KeyCurrent = ~reg_PAD_KEYINPUT;
|
||
|
||
if(m_KeyPrevious != m_KeyCurrent)
|
||
{
|
||
m_PressTime = nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyPad::waitForChange
|
||
|
||
@brief キー変化を待ちます
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void KeyPad::WaitForChange(KeyPad::KeyMask mask)
|
||
{
|
||
while( (m_KeyCurrent & mask) == (~reg_PAD_KEYINPUT & mask) )
|
||
{}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyPad::IsTrigger
|
||
|
||
@brief トリガされたか否か
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
bool KeyPad::IsTrigger(KeyPad::KeyMask mask)
|
||
{
|
||
if((m_KeyCurrent ^ m_KeyPrevious) & m_KeyCurrent & mask)
|
||
{
|
||
m_DetectionTime = nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
return true;
|
||
}
|
||
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyPad::IsPress
|
||
|
||
@brief 押されているか否か
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
bool KeyPad::IsPress(KeyPad::KeyMask mask)
|
||
{
|
||
nn::fnd::TimeSpan now = nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
|
||
if((now - m_PressTime) < PressDetectionDelay)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if((now - m_DetectionTime) < PressDetectionInterval)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if(m_KeyCurrent & mask)
|
||
{
|
||
m_DetectionTime = now;
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Page::Show
|
||
|
||
@brief 表示します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Page::Show(Display& display)
|
||
{
|
||
if(Parent == NULL)
|
||
{
|
||
display.Clear();
|
||
}
|
||
|
||
list<UIControl*>::iterator p = controls.begin();
|
||
KeyPad &key = KeyPad::GetInstance();
|
||
|
||
while(p!= controls.end())
|
||
{
|
||
(*p)->Show(display);
|
||
(*p)->KeyIn(key);
|
||
p++;
|
||
}
|
||
|
||
if(Parent == NULL)
|
||
{
|
||
display.SwapBuffer();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Page::Add
|
||
|
||
@brief UIControlを追加します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Page::Add(UIControl& ui)
|
||
{
|
||
ui.Parent = this;
|
||
controls.push_back(&ui);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Label::Show
|
||
|
||
@brief 表示します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Label::Show(Display& display)
|
||
{
|
||
display.Draw(Parent->X + X, Parent->Y + Y, Text);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Clock::Show
|
||
|
||
@brief 表示します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Clock::Show(Display& display)
|
||
{
|
||
ostringstream oss;
|
||
nn::fnd::TimeSpan now = nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
nn::fnd::TimeSpan time = now - start;
|
||
oss << time.GetSeconds() << endl;
|
||
display.Draw(Parent->X + X, Parent->Y + Y, oss.str());
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: operator<<
|
||
|
||
@breif ISelectableValue用<<演算子
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
ostream& operator<<(ostream& stream, ISelectableValue* svalue)
|
||
{
|
||
stream << svalue->ToString();
|
||
return stream;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: ValueSelector::Register
|
||
|
||
@breif 選択可能値を登録します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void ValueSelector::Register(string name, ISelectableValue& value)
|
||
{
|
||
selector::Register(name, value);
|
||
|
||
if(max_name_length < name.length())
|
||
{
|
||
max_name_length = name.length();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: ValueSelector::GetItemName
|
||
|
||
@breif アイテムの名前を取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
string ValueSelector::GetItemName(int index)
|
||
{
|
||
ostringstream oss;
|
||
oss << left << setw(max_name_length) << selector::names[index] << " : " << selector::items[index];
|
||
|
||
return oss.str();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: ValueSelector::KeyIn
|
||
|
||
@breif キー入力を受け付けます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void ValueSelector::KeyIn(KeyPad& key)
|
||
{
|
||
selector::KeyIn(key);
|
||
|
||
if( !selector::items[selector::current_item]->Editable )
|
||
{
|
||
if(key.IsTrigger(KeyPad::RIGHT))
|
||
{
|
||
selector::items[selector::current_item]->Next(true);
|
||
}
|
||
else if(key.IsPress(KeyPad::RIGHT))
|
||
{
|
||
selector::items[selector::current_item]->Next();
|
||
}
|
||
else if(key.IsTrigger(KeyPad::LEFT))
|
||
{
|
||
selector::items[selector::current_item]->Previous(true);
|
||
}
|
||
else if(key.IsPress(KeyPad::LEFT))
|
||
{
|
||
selector::items[selector::current_item]->Previous();
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: ValueSelector::KeyIn
|
||
|
||
@breif
|
||
|
||
@return
|
||
|
||
edit : Akabane
|
||
*---------------------------------------------------------------------------*/
|
||
void VariableSelector::KeyIn(KeyPad& key)
|
||
{
|
||
|
||
if( !EditMode )
|
||
{
|
||
ValueSelector::KeyIn(key);
|
||
|
||
// 選択中のアイテムが編集可能オブジェクト
|
||
if( items[current_item]->Editable )
|
||
{
|
||
// 右ボタンが押された場合
|
||
if( key.IsTrigger(KeyPad::RIGHT) )
|
||
{
|
||
EditMode = true;
|
||
return;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
key.ReadKey();
|
||
key.PressDetectionDelay = nn::fnd::TimeSpan::FromMilliSeconds(500);
|
||
key.PressDetectionInterval = nn::fnd::TimeSpan::FromMilliSeconds(100);
|
||
|
||
if(key.IsTrigger(KeyPad::UP) || key.IsPress(KeyPad::UP))
|
||
{
|
||
selector::items[selector::current_item]->Increment();
|
||
}
|
||
else if(key.IsTrigger(KeyPad::DOWN) || key.IsPress(KeyPad::DOWN))
|
||
{
|
||
selector::items[selector::current_item]->Decrement();
|
||
}
|
||
else if(key.IsTrigger(KeyPad::RIGHT) || key.IsPress(KeyPad::RIGHT))
|
||
{
|
||
selector::items[selector::current_item]->ShiftRight();
|
||
}
|
||
else if(key.IsTrigger(KeyPad::LEFT) || key.IsPress(KeyPad::LEFT))
|
||
{
|
||
selector::items[selector::current_item]->ShiftLeft();
|
||
}
|
||
else if(key.IsTrigger(KeyPad::B))
|
||
{
|
||
EditMode = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
void VariableSelector::Show(Display& display)
|
||
{
|
||
for(int i=0; i<items.size(); i++)
|
||
{
|
||
int x = GetX(); //Parent->X + X;
|
||
int y = GetY(); //Parent->Y + Y;
|
||
|
||
if(i == current_item)
|
||
{
|
||
double difference = abs(current_item * LineHeight * 2 - cursor_position);
|
||
int sign = current_item * LineHeight * 2 < cursor_position ? -1 : 1;
|
||
cursor_position += sign * ceil(difference / CursorSmoothness);
|
||
display.Draw(x, y + cursor_position, cursor, FontSize, false); // とりあえず、
|
||
|
||
// 編集可能リストで、編集モードの場合は下にカーソルを表示する
|
||
if( EditMode )
|
||
{
|
||
int label_width = (GetItemName(i).size() - 1) * FontSize; // カーソル分の -1
|
||
int cursor_width_from_right = selector::items[selector::current_item]->GetFigure() * FontSize;
|
||
display.Draw(x + Offset + label_width - cursor_width_from_right , y + cursor_position + LineHeight, "^");
|
||
}
|
||
}
|
||
display.Draw(x + Offset, y + (i * LineHeight * 2), GetItemName(i) );
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugWriter::Write
|
||
|
||
@breif 書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void DebugWriter::Write(string text)
|
||
{
|
||
NN_LOG(text.c_str());
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugWriter::WriteLine
|
||
|
||
@breif 一行書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void DebugWriter::WriteLine(string text)
|
||
{
|
||
NN_LOG(text.c_str());
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugWriter::Write
|
||
|
||
@breif 書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
NameWriter::NameWriter(string name, TextWriter* writer)
|
||
{
|
||
m_Name = name;
|
||
m_Writer = writer;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugWriter::Write
|
||
|
||
@breif 書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void NameWriter::Write(string text)
|
||
{
|
||
m_Writer->Write( m_Name + " : " + text);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: DebugWriter::WriteLine
|
||
|
||
@breif 一行書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void NameWriter::WriteLine(string text)
|
||
{
|
||
m_Writer->WriteLine( m_Name + " : " + text);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Console::Console
|
||
|
||
@breif コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Console::Console() {
|
||
m_Buffer = new RingBuffer<string>(23);
|
||
Width = 40;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Console::Console
|
||
|
||
@breif デストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Console::~Console() {
|
||
delete m_Buffer;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Console::Write
|
||
|
||
@breif 書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Console::Write(string text)
|
||
{
|
||
if(text == "")
|
||
{
|
||
return;
|
||
}
|
||
|
||
int position = text.find("\n");
|
||
|
||
if(position == string::npos)
|
||
{
|
||
position = text.size() - 1;
|
||
}
|
||
|
||
if(m_Line.size() + position > Width)
|
||
{
|
||
position = (Width - m_Line.size());
|
||
string splitted, splitted2;
|
||
splitted.assign(text, 0, position);
|
||
splitted2.assign(text, position + 1, text.size());
|
||
m_Line+=splitted;
|
||
m_Buffer->SetValue(m_Line);
|
||
m_Line="";
|
||
Write(splitted2);
|
||
}
|
||
else
|
||
{
|
||
string splitted, splitted2;
|
||
splitted.assign(text, 0, position);
|
||
splitted2.assign(text, position + 1, text.size());
|
||
m_Line+=splitted;
|
||
if(text[position] == '\n')
|
||
{
|
||
m_Buffer->SetValue(m_Line);
|
||
m_Line="";
|
||
Write(splitted2);
|
||
}
|
||
}
|
||
// else
|
||
// {
|
||
// m_Line += text;
|
||
// }
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Console::WriteLine
|
||
|
||
@breif 一行書き込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Console::WriteLine(string text)
|
||
{
|
||
text += "\n";
|
||
Write(text);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Console::Clear
|
||
|
||
@breif 消去します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Console::Clear()
|
||
{
|
||
m_Line="";
|
||
delete m_Buffer;
|
||
m_Buffer = new RingBuffer<string>(23);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Console::Show
|
||
|
||
@breif 表示します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Console::Show(Display& display)
|
||
{
|
||
for(int i=0;i<m_Buffer->GetSize();i++)
|
||
{
|
||
display.Draw(X, Y + i*10, (*m_Buffer)[i]);
|
||
}
|
||
display.Draw(X, Y + m_Buffer->GetSize()*10, m_Line);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: TestReader::TestReader
|
||
|
||
@breif コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
TestReader::TestReader() : TextReader()
|
||
{
|
||
eof = false;
|
||
|
||
line = new char*[100];
|
||
for(int i=0;i<100;i++)
|
||
{
|
||
line[i] = new char[50];
|
||
}
|
||
|
||
int i = 0;
|
||
strcpy(line[i], "@set1");i++;
|
||
strcpy(line[i], "a:3"); i++;
|
||
strcpy(line[i], "b:2,9,5"); i++;
|
||
strcpy(line[i], "c:3,7 # aiueo"); i++;
|
||
strcpy(line[i], ""); i++;
|
||
strcpy(line[i], "@set2 #-----"); i++;
|
||
strcpy(line[i], "a: 3, 5"); i++;
|
||
strcpy(line[i], "b: 5"); i++;
|
||
strcpy(line[i], "cde: 2,5,1,9,15,234,43 # akasatana"); i++;
|
||
strcpy(line[i], "@set3 #----------"); i++;
|
||
strcpy(line[i], "c: 3 #----------"); i++;
|
||
strcpy(line[i], "@set4 #----------"); i++;
|
||
strcpy(line[i], "a:3"); i++;
|
||
strcpy(line[i], "#c:95"); i++;
|
||
strcpy(line[i], "b:2,9,5"); i++;
|
||
strcpy(line[i], "abc"); i++;
|
||
strcpy(line[i], "c:3,7 # komento"); i++;
|
||
strcpy(line[i], ""); i++;
|
||
strcpy(line[i], "@set5 #----------"); i++;
|
||
strcpy(line[i], "c: 3 #----------"); i++;
|
||
strcpy(line[i], "d: 0x3 #----------"); i++;
|
||
strcpy(line[i], "e: 0xa #----------"); i++;
|
||
lineSize = i;
|
||
|
||
current_line = 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: TestReader::TestReader
|
||
|
||
@breif デストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
TestReader::~TestReader()
|
||
{
|
||
for(int i=0;i<100;i++)
|
||
{
|
||
delete[] line[i];
|
||
}
|
||
delete[] line;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: TestReader::Read
|
||
|
||
@breif 読み込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
char* TestReader::Read()
|
||
{
|
||
return NULL;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: TestReader::ReadLine
|
||
|
||
@breif 一行読み込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
char* TestReader::ReadLine()
|
||
{
|
||
if(!EndOfFile())
|
||
{
|
||
char* buffer = new char[strlen(line[current_line] + 1)];
|
||
strcpy(buffer, line[current_line]);
|
||
current_line++;
|
||
if( current_line == lineSize )
|
||
{
|
||
eof = true;
|
||
}
|
||
return buffer;
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
bool TestReader::EndOfFile()
|
||
{
|
||
return eof;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::Parser
|
||
|
||
@breif コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Parser::Parser(TextReader* reader) {
|
||
m_Reader = reader;
|
||
|
||
// 初期化する
|
||
ReadNextLine(); // 最初の一行を読み出す
|
||
MoveSet(); // 最初のセットへ移動する
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::~Parser
|
||
|
||
@breif デストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Parser::~Parser() {
|
||
// パース前データを削除
|
||
if(m_CurrentLine != NULL)
|
||
{
|
||
delete[] m_CurrentLine;
|
||
m_CurrentLine = NULL;
|
||
}
|
||
|
||
// パース後データを削除
|
||
if(m_MaxIndex != 0)
|
||
{
|
||
for(int i=0;i<m_MaxIndex;i++)
|
||
{
|
||
delete m_Values[i];
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::GetValue
|
||
|
||
@breif 一つ値を取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
int Parser::GetValue()
|
||
{
|
||
if(m_CurrentIndex < m_MaxIndex)
|
||
{
|
||
m_CurrentIndex++;
|
||
return m_Values[m_CurrentIndex - 1]->GetValue();
|
||
}
|
||
else
|
||
{
|
||
return NULL;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::GetValue
|
||
|
||
@breif キーを指定して一つ値を取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
int Parser::GetValue(char* key)
|
||
{
|
||
for(;m_CurrentIndex < m_MaxIndex; m_CurrentIndex++)
|
||
{
|
||
if(strcmp(key, m_Values[m_CurrentIndex]->GetKey()) == 0)
|
||
{
|
||
m_CurrentIndex++;
|
||
return m_Values[m_CurrentIndex - 1]->GetValue();
|
||
}
|
||
}
|
||
|
||
return NULL;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::MoveSet
|
||
|
||
@breif 次のセットに移動します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Parser::MoveSet()
|
||
{
|
||
while(m_CurrentLine != NULL && !IsSetLine())
|
||
{
|
||
ReadNextLine();
|
||
}
|
||
|
||
ReadNextLine();
|
||
ParseValues();
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::MoveSet
|
||
|
||
@breif 指定のセットに移動します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Parser::MoveSet(char* key)
|
||
{
|
||
while(m_CurrentLine != NULL && !IsSetLine())
|
||
{
|
||
ReadNextLine();
|
||
}
|
||
|
||
if(IsSetLine())
|
||
{
|
||
char* token = strtok(m_CurrentLine, "@ ");
|
||
if(strcmp(token, key) == 0)
|
||
{
|
||
ReadNextLine();
|
||
ParseValues();
|
||
}
|
||
else
|
||
{
|
||
ReadNextLine();
|
||
MoveSet(key);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::ParseValues
|
||
|
||
@breif パースします
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Parser::ParseValues()
|
||
{
|
||
// 初期化する
|
||
if(m_MaxIndex != 0)
|
||
{
|
||
for(int i=0;i<m_MaxIndex;i++)
|
||
{
|
||
delete m_Values[i];
|
||
}
|
||
m_CurrentIndex = 0;
|
||
m_MaxIndex = 0;
|
||
}
|
||
|
||
while(m_CurrentLine != NULL && !IsSetLine())
|
||
{
|
||
if(IsValueLine())
|
||
{
|
||
char* key = strtok(m_CurrentLine, ": ");
|
||
|
||
while(1)
|
||
{
|
||
char* value = strtok(NULL, ", ");
|
||
if(value == NULL)
|
||
{
|
||
break;
|
||
}
|
||
if(strncmp(value, "0x", 2) == 0)
|
||
{
|
||
// 16進表記を数値に変換
|
||
m_Values[m_MaxIndex] = new KeyValuePair(key, strtol(value, NULL, 16));
|
||
m_MaxIndex++;
|
||
}
|
||
else
|
||
{
|
||
// 10進表記を数値に変換
|
||
m_Values[m_MaxIndex] = new KeyValuePair(key, atoi(value));
|
||
m_MaxIndex++;
|
||
}
|
||
}
|
||
}
|
||
|
||
ReadNextLine();
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::ReadNextLine
|
||
|
||
@breif 次の行を読み込みます。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Parser::ReadNextLine()
|
||
{
|
||
if(m_CurrentLine != NULL)
|
||
{
|
||
delete[] m_CurrentLine;
|
||
m_CurrentLine = NULL;
|
||
}
|
||
|
||
char* line = m_Reader->ReadLine();
|
||
|
||
if(line == NULL)
|
||
{
|
||
// NULL(つまり、終端に達していた)ならば、何もしない。
|
||
}
|
||
else
|
||
{
|
||
m_CurrentLine = new char[strlen(line) + 1];
|
||
strcpy(m_CurrentLine, line);
|
||
|
||
// コメント開始時点を文字列末にする。
|
||
char* p = strpbrk(m_CurrentLine, "#");
|
||
if(p != NULL)
|
||
{
|
||
*p = '\0';
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::IsValueLine
|
||
|
||
@breif 値行か否か
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
bool Parser::IsValueLine()
|
||
{
|
||
if( m_CurrentLine != NULL && strpbrk(m_CurrentLine, ":")!=NULL )
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Parser::IsSetLine
|
||
|
||
@breif セット行か否か
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
bool Parser::IsSetLine()
|
||
{
|
||
if( m_CurrentLine != NULL && (strpbrk(m_CurrentLine, "@")!=NULL) )
|
||
{
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::KeyValuePair
|
||
|
||
@breif コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
KeyValuePair::KeyValuePair()
|
||
{
|
||
m_Key = NULL;
|
||
m_Value = 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::KeyValuePair
|
||
|
||
@breif コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
KeyValuePair::KeyValuePair(char* key, int value)
|
||
{
|
||
m_Key = new char[strlen(key) + 1];
|
||
strcpy(m_Key, key);
|
||
m_Value = value;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::~KeyValuePair
|
||
|
||
@breif デストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
KeyValuePair::~KeyValuePair()
|
||
{
|
||
delete[] m_Key;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::GetKey
|
||
|
||
@breif キーを取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
const char* KeyValuePair::GetKey()
|
||
{
|
||
return m_Key;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::GetValue()
|
||
|
||
@breif 値を取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
int KeyValuePair::GetValue()
|
||
{
|
||
return m_Value;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::SetKey
|
||
|
||
@breif キーをセットします。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void KeyValuePair::SetKey(char* key)
|
||
{
|
||
m_Key = new char[strlen(key) + 1];
|
||
strcpy(m_Key, key);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: KeyValuePair::SetValue
|
||
|
||
@breif 値をセットします。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void KeyValuePair::SetValue(int value)
|
||
{
|
||
m_Value = value;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Average::Average
|
||
|
||
@brief コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
Average::Average()
|
||
{
|
||
total = 0;
|
||
count = 0;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Average::Add
|
||
|
||
@brief 値を追加します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void Average::Add(double value)
|
||
{
|
||
total += value;
|
||
count ++;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: Average::GetValue
|
||
|
||
@brief 平均値を取得します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
double Average::GetValue()
|
||
{
|
||
return total / count;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: LastAverage::LastAverage
|
||
|
||
@brief コンストラクタです。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
LastAverage::LastAverage(int size)
|
||
{
|
||
this->size = size;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
/*!--------------------------------------------------------------------------*
|
||
Name: LastAverage::Add
|
||
|
||
@brief 値を追加します。
|
||
|
||
@return
|
||
|
||
*---------------------------------------------------------------------------*/
|
||
void LastAverage::Add(double value)
|
||
{
|
||
Average::Add(value);
|
||
lastValues.push_back(value);
|
||
|
||
if(count > size)
|
||
{
|
||
total -= lastValues.front();
|
||
lastValues.pop_front();
|
||
count--;
|
||
}
|
||
}
|
||
|
||
|
||
|
||
//// TimerHandler2の静的変数の初期化
|
||
//bool TimerHandler2::initialized = false;
|
||
|
||
|
||
|
||
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: TimerHnadler::TimerHandler
|
||
//
|
||
// @brief タイマーハンドラのコンストラクタ
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//TimerHandler::TimerHandler()
|
||
//{
|
||
// Interval = 0;
|
||
// NextTime = 0;
|
||
//}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: Timer::Start
|
||
//
|
||
// @brief タイマーを開始する
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//void Timer::Start()
|
||
//{
|
||
// // 全ハンドラの次回実行時間を求める
|
||
// for (int i=0;i<handlers.size();i++)
|
||
// {
|
||
// nn::fnd::TimeSpan t = nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
// handlers[i]->NextTime = t + handlers[i]->Interval;
|
||
// }
|
||
//
|
||
// thread.StartUsingAutoStack(ThreadFunc, NULL, 4096);
|
||
//
|
||
// Timer::stopTime = nn::fnd::TimeSpan::FromSeconds(0);
|
||
// Timer::stop = false;
|
||
//}
|
||
//
|
||
//
|
||
//
|
||
//
|
||
//
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: Timer::Start
|
||
//
|
||
// @brief 実行時間を指定してタイマーを開始する
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//void Timer::Start(nn::fnd::TimeSpan time)
|
||
//{
|
||
// Start();
|
||
// Timer::stopTime = time + nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
// Timer::stop = true;
|
||
//}
|
||
//
|
||
//
|
||
//
|
||
//
|
||
//
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: Timer::Stop
|
||
//
|
||
// @brief タイマーを停止する
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//void Timer::Stop()
|
||
//{
|
||
// // TODO : 停止後再開できるようにする。
|
||
// Timer::stop = true;
|
||
// thread.Join();
|
||
//}
|
||
//
|
||
//
|
||
//
|
||
//
|
||
//
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: Timer::RegisterHandler
|
||
//
|
||
// @brief ハンドラを登録する
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//void Timer::RegisterHandler(TimerHandler& timerHandler)
|
||
//{
|
||
// timerHandler.NextTime = nn::os::Tick::GetSystemCurrent().ToTimeSpan() + timerHandler.Interval;
|
||
// Timer::handlers.push_back(&timerHandler);
|
||
//}
|
||
//
|
||
//
|
||
//
|
||
//
|
||
//
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: Timer::UnregisterHandler
|
||
//
|
||
// @brief ハンドラを登録解除する
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//void Timer::UnregisterHandler(TimerHandler& timerHandler)
|
||
//{
|
||
// vector<TimerHandler*>::iterator p = handlers.begin();
|
||
// for(;p<handlers.end();p++)
|
||
// {
|
||
// if(*p == &timerHandler)
|
||
// {
|
||
// handlers.erase(p);
|
||
// break;
|
||
// }
|
||
// }
|
||
//}
|
||
//
|
||
//
|
||
//
|
||
//
|
||
///*!--------------------------------------------------------------------------*
|
||
// Name: Timer::ThreadFunc
|
||
//
|
||
// @brief タイマースレッド
|
||
//
|
||
// @return なし
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//void Timer::ThreadFunc(uptr param)
|
||
//{
|
||
// nn::fnd::TimeSpan now;
|
||
//
|
||
// while(1)
|
||
// {
|
||
// now = nn::os::Tick::GetSystemCurrent().ToTimeSpan();
|
||
//
|
||
// if(Timer::stop && Timer::stopTime <= now)
|
||
// {
|
||
// break;
|
||
// }
|
||
//
|
||
// for (int i=0;i<handlers.size();i++)
|
||
// {
|
||
// if(handlers[i]->NextTime <= now)
|
||
// {
|
||
// handlers[i]->Execute();
|
||
// handlers[i]->NextTime = now + handlers[i]->Interval;
|
||
// }
|
||
// }
|
||
//
|
||
// //nn::os::Thread::Yield();
|
||
// nn::os::Thread::Sleep(nn::fnd::TimeSpan::FromMilliSeconds(1));
|
||
// }
|
||
//}
|
||
//
|
||
//
|
||
//
|
||
//
|
||
//
|
||
///*!--------------------------------------------------------------------------*
|
||
// @brief staticメンバの取得
|
||
//
|
||
// *---------------------------------------------------------------------------*/
|
||
//nn::os::Thread Timer::thread;
|
||
//vector<TimerHandler*> Timer::handlers;
|
||
//bool Timer::stop = false;
|
||
//nn::fnd::TimeSpan Timer::stopTime = nn::fnd::TimeSpan::FromSeconds(0);
|
||
//
|
||
|
||
|
||
#define DUMP_NUM 0x10
|
||
#define DUMP_MAP_BASE_X 0
|
||
#define DUMP_MUP_BASE_Y 70
|
||
|
||
#define ADR_INDEX_LABEL_NUM 0
|
||
#define ADR_LINE_LABEL_NUM 1
|
||
#define DUMP_DATA_LABEL_START_NUM 2
|
||
|
||
|
||
void ShowMemDump( Page *page, Label *lb, u64 address, u8* buffer, size_t size)
|
||
{
|
||
NN_TLOG_("-- showMemDump\n");
|
||
// NN_TLOG_("start adr:0x%08x\n", address);
|
||
// NN_TLOG_("buffer:0x%08x\n", buffer);
|
||
NN_TLOG_("size:0x%08x\n\n", size);
|
||
|
||
lb[ADR_INDEX_LABEL_NUM].X = DUMP_MAP_BASE_X;
|
||
lb[ADR_INDEX_LABEL_NUM].Y = DUMP_MUP_BASE_Y;
|
||
lb[ADR_INDEX_LABEL_NUM].Text = " |00 01 02 03 04 05 06 07";
|
||
page->Add(lb[ADR_INDEX_LABEL_NUM]);
|
||
|
||
lb[ADR_LINE_LABEL_NUM].X = DUMP_MAP_BASE_X;
|
||
lb[ADR_LINE_LABEL_NUM].Y = DUMP_MUP_BASE_Y + 5;
|
||
lb[ADR_LINE_LABEL_NUM].Text = "---------------------------------------";
|
||
page->Add(lb[ADR_LINE_LABEL_NUM]);
|
||
|
||
u32 current_size = 0;
|
||
for(int i=DUMP_DATA_LABEL_START_NUM, j=0; i<DUMP_DATA_LABEL_START_NUM+DUMP_NUM; i++, j++)
|
||
{
|
||
ostringstream adr;
|
||
|
||
lb[i].X = 0;
|
||
lb[i].Y = DUMP_MUP_BASE_Y + 10 + 10 * j;
|
||
|
||
// アドレス表示部分
|
||
adr << "0x";
|
||
adr.fill('0');
|
||
adr << setw(12) << right << hex << address + (0x8 * j) << "|";
|
||
|
||
// dump部分
|
||
for(int k=0; k<0x8; k++)
|
||
{
|
||
if( size > current_size )
|
||
{
|
||
// u32 にキャストしないとだめ(u8だと文字として扱われる?)
|
||
adr << setw(2) << right << hex << (u32)buffer[current_size] << " ";
|
||
current_size++;
|
||
}
|
||
}
|
||
|
||
lb[i].Text = adr.str();
|
||
|
||
page->Add(lb[i]);
|
||
}
|
||
}
|
||
|
||
|
||
} /* nakayama */
|
||
} /* red */
|
||
} /* nn */
|