Skip to content

Commit

Permalink
[platform/sdl2-c] Use some C23 features
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellocordeiro committed Jan 2, 2024
1 parent 6a1507f commit 97bba19
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
8 changes: 4 additions & 4 deletions platform/eframe-rust/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ impl App {
}

impl eframe::App for App {
fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) {
save_battery(&self.gb, &self.rom_path);
}

fn update(&mut self, egui_ctx: &egui::Context, _eframe_frame: &mut eframe::Frame) {
if !self.gui.control.manual_control && self.gb.cartridge_inserted() {
self.gb.run_frame();
Expand All @@ -78,4 +74,8 @@ impl eframe::App for App {
self.handle_input(egui_ctx);
self.gui.render(egui_ctx, &mut self.gb);
}

fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) {
save_battery(&self.gb, &self.rom_path);
}
}
10 changes: 5 additions & 5 deletions platform/sdl2-c/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ int main(int argc, char* argv[]) {
SCREEN_HEIGHT
);

int quit = 0;
bool quit = false;

while (!quit) {
SDL_Event event;

while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
quit = 1;
quit = true;
break;

default:
Expand All @@ -72,8 +72,8 @@ int main(int argc, char* argv[]) {
gameboy_run_frame(gb);
gameboy_draw_into_frame_rgba8888(gb, framebuffer);

SDL_UpdateTexture(texture, NULL, framebuffer, SCREEN_WIDTH * sizeof(uint32_t));
SDL_RenderCopy(renderer, texture, NULL, NULL);
SDL_UpdateTexture(texture, nullptr, framebuffer, SCREEN_WIDTH * sizeof(uint32_t));
SDL_RenderCopy(renderer, texture, nullptr, nullptr);
SDL_RenderPresent(renderer);
}

Expand All @@ -84,4 +84,4 @@ int main(int argc, char* argv[]) {
gameboy_destroy(gb);

return 0;
}
}

0 comments on commit 97bba19

Please sign in to comment.