uxn

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

commit 73c1ecccc0521ac257715da7d40bcc104ad5aebb
parent 2cf6da4a553186cbad04af095360b8bb0b1b8f95
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Thu, 16 Dec 2021 17:29:09 +0100

emu: handle files dropped by loading it as a ROM

Diffstat:
Msrc/uxnemu.c | 12+++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/uxnemu.c b/src/uxnemu.c @@ -226,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; } @@ -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)); } }