Fixed emulator frame bug
This commit is contained in:
parent
3dafa868cb
commit
818ade6db1
2
build.sh
2
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' ];
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue