Skip to content

Commit

Permalink
Rework init
Browse files Browse the repository at this point in the history
The sneaky framebuffer RAM usage did not play nicely with the new delayed mode changes
  • Loading branch information
Daft-Freak committed Nov 20, 2020
1 parent 04c3320 commit 416776e
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/blit/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ void add_appended_files()
#endif
}

bool init_wait = true, done_init = false;

void init()
{
blit::set_screen_mode(blit::ScreenMode::hires_palette);
blit::screen.pen = blit::Pen(1);
blit::screen.clear();

#ifdef ASSET_WAD
blit::File::add_buffer_file("doom-data/doom1.wad", doom1_wad, doom1_wad_length);
Expand Down Expand Up @@ -110,18 +110,19 @@ void init()
blit::File::add_buffer_file("doom-data/" + file.name, data, length);
}
#endif

if(setjmp(jump_buffer))
return;

D_DoomMain();
}

void update(uint32_t time)
{
if(!fatal_error.empty() || setjmp(jump_buffer))
if(!fatal_error.empty() || init_wait || setjmp(jump_buffer))
return;

if(!done_init) {
D_DoomMain();
done_init = true;
return;
}

TryRunTics();
S_UpdateSounds(players[consoleplayer].mo);
}
Expand Down Expand Up @@ -151,6 +152,15 @@ void render(uint32_t time)
return;
}

// wait for render before init, so we know that palette mode is in effect
// (since we're using bits of the framebuffer/LTDC memory for other stuff)
if(init_wait) {
init_wait = false;
blit::screen.pen = blit::Pen(1);
blit::screen.clear();
return;
}

if(setjmp(jump_buffer))
return;

Expand Down

0 comments on commit 416776e

Please sign in to comment.