diff --git a/src/main.cpp b/src/main.cpp index 92bfabb..bdbaf25 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -9,11 +9,17 @@ using namespace mtl; using namespace fractal; +namespace mlog = mtl::log; + +GBA_EWRAM_DATA ruleset_t rules; +GBA_EWRAM_DATA generator_t gen; +GBA_EWRAM_DATA etl::vector output; int main(void) { REG_DISPCNT = DCNT_MODE3 | DCNT_BG2; - log::debug << "Hello world!" << mtl::endl; + mlog::debug << "Hello world!" << mtl::flush; + constexpr float cos_PI_2 = std::cos(M_PI_2); constexpr float cos_PI_4 = std::cos(M_PI_4); constexpr float sin_PI_2 = std::sin(M_PI_2); @@ -24,8 +30,6 @@ int main(void) { fixed sin_PI_2_fx = sin_PI_2; fixed sin_PI_4_fx = sin_PI_4; - ruleset_t rules; - try { fixed branch_angle = M_PI_4; @@ -41,7 +45,7 @@ int main(void) { token_id_t petal = rules.add_token(token_type_e::empty); token_id_t mark = rules.add_token(token_type_e::empty, 0, 0, 1); - log::info << "Added tokens" << endl; + mlog::info << "Added tokens" << endl; uint32_t axiom_factor = 4; @@ -54,29 +58,40 @@ int main(void) { etl::vector petal_chr{ mark, walk_petal_length, mark, rotate_petal, walk_petal_side, mark }; group_id_t petal_grp = rules.add_group_characteristic(petal_chr); - log::info << "Added group characteristics" << endl; + mlog::info << "Added group characteristics" << endl; rules.add_branch_rule(branch, branch_grp); rules.add_branch_rule(petal, petal_grp); - log::info << "Added rules" << endl; - log::info << "Finished configuring ruleset" << endl; + mlog::info << "Added rules" << endl; + mlog::info << "Finished configuring ruleset" << endl; } catch(const mtl::exception&) { - log::info << "Failed to configure ruleset, caught exception" << endl; + mlog::info << "Failed to configure ruleset, caught exception" << endl; return 0; } - generator_t gen(rules); - etl::vector output; + size_t gen_num = 0; - while (gen.step_generation(output)) { - log::debug << "Stepped generation" << gen.generation_num() << endl; + try { + gen.parse_ruleset(rules); - for (const marker_t& m : output) { - log::debug << ' ' << m.m_id << ", " << m.m_pos << endl; + while (gen.step_generation(output)) { + mlog::debug << "Stepped generation" << gen.generation_num() << endl; + gen_num = gen.generation_num(); + + for (const marker_t& m : output) { + mlog::debug << ' ' << m.m_id << ", " << m.m_pos << endl; + } } + } catch (etl::exception& e) { + mlog::error << "Caught ETL exception: " << e.what() << endl; + } catch (mtl::exception& e) { + mlog::error << "Caught MTL exception: " << e.id() << endl; } + mlog::info << "Stepped " << gen.generation_num() << " generations" << mtl::endl; + mlog::debug << "End" << mtl::flush; + while (true) { vid_vsync(); }