Skip to content

Commit

Permalink
butano: core::init waits for v-blank before initializing all butano s…
Browse files Browse the repository at this point in the history
…ubsystems
  • Loading branch information
GValiente committed Sep 3, 2023
1 parent 2c1739a commit 746afa4
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
11 changes: 11 additions & 0 deletions butano/hw/include/bn_hw_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ extern "C"

namespace bn::hw::core
{
inline void init()
{
while(REG_VCOUNT != 160)
{
}

while(REG_VCOUNT != 161)
{
}
}

inline void wait_for_vblank()
{
if(REG_VCOUNT == 159)
Expand Down
1 change: 1 addition & 0 deletions butano/include/bn_documentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -2121,6 +2121,7 @@
* @section changelog_15_3_0 15.3.0 (next release)
*
* * bn::top_left_rect and bn::top_left_fixed_rect added.
* * bn::core::init waits for V-Blank before initializing all Butano subsystems.
* * Slow game pak detection fixed.
* * bn::rect issues with odd dimensions documented.
*
Expand Down
12 changes: 8 additions & 4 deletions butano/src/bn_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ void init()

void init(const string_view& keypad_commands)
{
// Initial wait:
hw::core::init();

// Init irq system:
hw::irq::init();
hw::irq::set_isr(hw::irq::id::HBLANK, hw::hblank_effects::_intr);
Expand Down Expand Up @@ -335,16 +338,17 @@ void init(const string_view& keypad_commands)
bg_blocks_manager::init();
keypad_manager::init(keypad_commands);

// Init timer system:
hw::timer::init();
data.cpu_usage_timer.restart();

// First update:
update();

// Keypad polling fix:
keypad_manager::update();

// Init timer system:
hw::timer::init();
data.cpu_usage_timer.restart();
data.last_ticks = ticks();

// Reset profiler:
BN_PROFILER_RESET();
}
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.html

Large diffs are not rendered by default.

0 comments on commit 746afa4

Please sign in to comment.