diff --git a/build.sh b/build.sh index 6b9323c..75e5f41 100755 --- a/build.sh +++ b/build.sh @@ -28,7 +28,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.controller.usm bin/boot.rom +./bin/assembler projects/software/nasu.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/dev.keys.usm b/projects/examples/dev.keys.usm index b432c69..d86c7d8 100644 --- a/projects/examples/dev.keys.usm +++ b/projects/examples/dev.keys.usm @@ -6,7 +6,6 @@ ;cursor { x 2 y 2 blink 1 } - |0100 ;Console { pad 8 char 1 byte 1 short 2 } |0110 ;Screen { width 2 height 2 pad 4 y 2 x 2 color 1 } |0120 ;Sprite { pad 8 x 2 y 2 addr 2 color 1 } @@ -28,7 +27,7 @@ BRK ( theme ) #0daf =System.r #02ff =System.g #035f =System.b ( update cursor ) - #02 ~cursor.blink #01 EQU ADD =Sprite.color + #02 =Sprite.color ,cursor_icn =Sprite.addr ~cursor.blink MOD2 #00 EQU =cursor.blink diff --git a/src/emulator.c b/src/emulator.c index 71b43f8..36e5883 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -579,41 +579,34 @@ ppnil(Uxn *u, Uint16 ptr, Uint8 b0, Uint8 b1) #pragma mark - Generics -void -runevents(Uxn *u) -{ - SDL_Event event; - while(SDL_PollEvent(&event) != 0) { - switch(event.type) { - case SDL_QUIT: quit(); break; - case SDL_MOUSEBUTTONUP: - case SDL_MOUSEBUTTONDOWN: - case SDL_MOUSEMOTION: domouse(u, &event); break; - case SDL_TEXTINPUT: dotext(u, &event); break; - case SDL_KEYDOWN: doctrl(u, &event, 1); break; - case SDL_KEYUP: doctrl(u, &event, 0); break; - case SDL_WINDOWEVENT: - if(event.window.event == SDL_WINDOWEVENT_EXPOSED) - redraw(pixels, u); - break; - } - } -} - int start(Uxn *u) { evaluxn(u, PAGE_VECTORS); redraw(pixels, u); while(1) { - float elapsed; - double start = SDL_GetPerformanceCounter(); - runevents(u); + SDL_Event event; + double elapsed, start = SDL_GetPerformanceCounter(); + while(SDL_PollEvent(&event) != 0) { + switch(event.type) { + case SDL_QUIT: quit(); break; + case SDL_MOUSEBUTTONUP: + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEMOTION: domouse(u, &event); break; + case SDL_TEXTINPUT: dotext(u, &event); break; + case SDL_KEYDOWN: doctrl(u, &event, 1); break; + case SDL_KEYUP: doctrl(u, &event, 0); break; + case SDL_WINDOWEVENT: + if(event.window.event == SDL_WINDOWEVENT_EXPOSED) + redraw(pixels, u); + break; + } + } evaluxn(u, PAGE_VECTORS + 0x08); if(screen.reqdraw) redraw(pixels, u); elapsed = (SDL_GetPerformanceCounter() - start) / (double)SDL_GetPerformanceFrequency() * 1000.0f; - SDL_Delay((int)(16.666f - elapsed)); + SDL_Delay(clamp(16.666f - elapsed, 0, 1000)); } } diff --git a/src/uxn.c b/src/uxn.c index aaff2d6..53d0d22 100644 --- a/src/uxn.c +++ b/src/uxn.c @@ -145,10 +145,9 @@ evaluxn(Uxn *u, Uint16 vec) u->ram.ptr = vec; u->wst.error = 0; u->rst.error = 0; - while(u->ram.ptr) { + while(u->ram.ptr) if(!stepuxn(u, u->ram.dat[u->ram.ptr++])) return 0; - } return 1; }