Skip to content
Permalink
Browse files

NDS version has pleasant reading speed

  • Loading branch information...
richelbilderbeek committed Dec 30, 2017
1 parent 549529d commit ff5b574dc081dcdbf16684a38e18465181926532
Showing with 10 additions and 40 deletions.
  1. +3 −3 Nds/source/main.cpp
  2. +7 −37 Nds/source/ndsgamedialog.cpp
@@ -13,20 +13,20 @@ extern "C" void __sync_synchronize() {}

int main(int argc, char* argv[0])
{
// argc will always be one
#ifndef NDEBUG
NO DEBUG MODE IN NDS
#endif
assert(1==2);


try
{
NdsGameDialog d(argc,argv);
d.Start();
}
catch (std::exception& e)
{
fprintf(stderr, "debug message in no$gba window %s", e.what());
fprintf(stderr, "Error: %s\n", e.what());
std::cout << "Error: " << e.what() << '\n';
std::clog << "Error: " << e.what() << '\n';
std::cerr << "Error: " << e.what() << '\n';
@@ -36,7 +36,7 @@ int main(int argc, char* argv[0])
}
catch (...)
{
fprintf(stderr, "Unknown error");
fprintf(stderr, "Unknown error\n");
std::cout << "Unknown error\n";
std::clog << "Unknown error\n";
std::cerr << "Unknown error\n";
@@ -26,7 +26,6 @@ NdsGameDialog::NdsGameDialog(const int argc, char* argv[])
m_screen_bottom{}
{
consoleDemoInit();
//consoleDebugInit(DebugDevice_NOCASH);
consoleDebugInit(DebugDevice_CONSOLE);

videoSetMode(MODE_FB0);
@@ -48,13 +47,6 @@ NdsGameDialog::NdsGameDialog(const int argc, char* argv[])
h.Wait(1.0, m_verbose);
}

if (m_verbose)
{
h.Cout("Displaying the character x:"); h.Cout('x'); h.Cout('\n');
h.Cout("Displaying the character Y:"); h.Cout('Y'); h.Cout('\n');
h.Cout("Displaying the character 0:"); h.Cout('0'); h.Cout('\n');
}

if (m_verbose)
{
std::stringstream s;
@@ -160,11 +152,15 @@ Option NdsGameDialog::RequestOption(const std::vector<Option>& options)

void NdsGameDialog::ShowText(const std::string& text)
{
if (m_verbose) { Helper().CoutNl(__func__); }

consoleSelect(&m_screen_bottom);

double wait_character_msec{0.01};
// From https://en.wikipedia.org/wiki/Words_per_minute#Reading_and_comprehension:
// the number of characters per minute tends to be around 1000 for all the tested languages
// Human:
double wait_character_msec{2500.0};

//Debug
//double wait_character_msec{0.01};

const std::string lines = Helper().StrToLines(text,GetNumberOfCharsPerLine());
for (const char c: lines)
@@ -180,41 +176,17 @@ void NdsGameDialog::ShowText(const std::string& text)

void NdsGameDialog::Start()
{
//if (m_verbose) { Helper().CoutNl("MOD_69008_EXPERIENCE"); }
//if (m_verbose) { Helper().CoutNl("MOD_69008_EXPERIENCE"); }
//if (m_verbose) { Helper().CoutNl(std::to_string(MOD_69008_EXPERIENCE)); }
//if (m_verbose) { Helper().CoutNl(std::to_string(MOD_69008_EXPERIENCE)); }
if (m_verbose) { Helper().CoutNl("Before disabled mmLoad"); }

//mmLoad(MOD_69008_EXPERIENCE); //Causes a freeze
mmLoad(MOD_MY_MUSIC); //Causes a freeze

if (m_verbose) { Helper().CoutNl("Before disabled mmStart"); }

mmStart(MOD_MY_MUSIC,MM_PLAY_LOOP);
//mmStart(MOD_69008_EXPERIENCE,MM_PLAY_LOOP);

if (m_verbose) { Helper().Cout(__func__); Helper().CoutNl(": 1"); }

Dice::Get()->SetSeed(42);

if (m_verbose) { Helper().CoutNl(__func__); Helper().CoutNl(": 2"); }

MenuDialog menu;

if (m_verbose) { Helper().CoutNl(__func__); Helper().CoutNl(": 3"); }

menu.SetObserver(this);

if (m_verbose) { Helper().CoutNl(__func__); Helper().CoutNl(": 4"); }

menu.Execute();
}

void NdsGameDialog::ProcessEvents()
{
if (m_verbose) { static int n = 0; Helper().Cout(std::to_string(n++)); Helper().CoutNl(__func__); }

scanKeys(); //Don't forget!
const int keys_down = keysDown();
if (keys_down)
@@ -239,7 +211,6 @@ void NdsGameDialog::ProcessEvents()

void NdsGameDialog::Wait()
{
if (m_verbose) { Helper().CoutNl(__func__); }
const double n_secs{1.0};
const int n{static_cast<int>(n_secs * 200.0)};
for (int i=0; i!=n; ++i)
@@ -248,5 +219,4 @@ void NdsGameDialog::Wait()
scanKeys(); //Don't forget!
if (keysDown()) break;
}
if (m_verbose) { Helper().Cout("End of: "); Helper().CoutNl(__func__); }
}

0 comments on commit ff5b574

Please sign in to comment.
You can’t perform that action at this time.