uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 256e597e48d7ab8feb0f236edf4a5f164cee3576
parent ca1d830055470c6a866c3d07c8a45bdeb5a9892e
Author: neauoire <aliceffekt@gmail.com>
Date:   Thu, 16 Dec 2021 10:48:21 -0800

Merge branch 'main' of git.sr.ht:~rabbits/uxn

Diffstat:
Msrc/uxnemu.c | 16+++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -193,7 +193,6 @@ quit(void) gRenderer = NULL; SDL_DestroyWindow(gWindow); SDL_Quit(); - exit(0); } static int @@ -227,6 +226,7 @@ init(void) SDL_CreateThread(stdin_handler, "stdin", NULL); SDL_StartTextInput(); SDL_ShowCursor(SDL_DISABLE); + SDL_EventState(SDL_DROPFILE, SDL_ENABLE); return 1; } @@ -489,7 +489,8 @@ doctrl(Uxn *u, SDL_Event *event, int z) case SDLK_F1: if(z) set_zoom(zoom > 2 ? 1 : zoom + 1); break; case SDLK_F2: if(z) devsystem->dat[0xe] = !devsystem->dat[0xe]; break; case SDLK_F3: if(z) capture_screen(); break; - case SDLK_F4: if(z) restart(u); break; + case SDLK_AC_BACK: + case SDLK_F4: if(z) restart(u); break; } /* clang-format on */ if(z) { @@ -524,11 +525,16 @@ run(Uxn *u) redraw(u); while(!devsystem->dat[0xf]) { SDL_Event event; - double elapsed, start = 0; + double elapsed, begin = 0; if(!BENCH) - start = SDL_GetPerformanceCounter(); + begin = SDL_GetPerformanceCounter(); while(SDL_PollEvent(&event) != 0) { switch(event.type) { + case SDL_DROPFILE: + set_size(WIDTH, HEIGHT, 0); + start(u, event.drop.file); + SDL_free(event.drop.file); + break; case SDL_QUIT: return error("Run", "Quit."); case SDL_TEXTINPUT: @@ -561,7 +567,7 @@ run(Uxn *u) if(ppu.reqdraw || devsystem->dat[0xe]) redraw(u); if(!BENCH) { - elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; + elapsed = (SDL_GetPerformanceCounter() - begin) / (double)SDL_GetPerformanceFrequency() * 1000.0f; SDL_Delay(clamp(16.666f - elapsed, 0, 1000)); } }