commit c93972cae22be2300d1cade49142546cf162da50
parent c0d5f6820cd38bf4dabab35c02b026dc466c3abf
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date: Wed, 25 Dec 2024 10:16:21 -0800
Cache screen vector
Diffstat:
3 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/devices/screen.c b/src/devices/screen.c
@@ -167,6 +167,7 @@ void
screen_deo(Uint8 addr)
{
switch(addr) {
+ case 0x21: uxn_screen.vector = PEEK2(&uxn.dev[0x20]); return;
case 0x23: screen_resize(PEEK2(&uxn.dev[0x22]), uxn_screen.height, uxn_screen.scale); return;
case 0x25: screen_resize(uxn_screen.width, PEEK2(&uxn.dev[0x24]), uxn_screen.scale); return;
case 0x26: rMX = uxn.dev[0x26] & 0x1, rMY = uxn.dev[0x26] & 0x2, rMA = uxn.dev[0x26] & 0x4, rML = uxn.dev[0x26] >> 4, rDX = rMX << 3, rDY = rMY << 2; return;
diff --git a/src/devices/screen.h b/src/devices/screen.h
@@ -10,7 +10,7 @@ WITH REGARD TO THIS SOFTWARE.
*/
typedef struct UxnScreen {
- int width, height, x1, y1, x2, y2, scale;
+ int width, height, vector, x1, y1, x2, y2, scale;
Uint32 palette[4], *pixels;
Uint8 *fg, *bg;
} UxnScreen;
diff --git a/src/uxnemu.c b/src/uxnemu.c
@@ -424,7 +424,6 @@ emu_run(char *rom)
emu_resize(uxn_screen.width, uxn_screen.height);
/* game loop */
for(;;) {
- Uint16 screen_vector;
Uint64 now = SDL_GetPerformanceCounter();
/* .System/halt */
if(uxn.dev[0x0f])
@@ -432,15 +431,14 @@ emu_run(char *rom)
exec_deadline = now + deadline_interval;
if(!handle_events())
return 0;
- screen_vector = uxn.dev[0x20] << 8 | uxn.dev[0x21];
if(now >= next_refresh) {
now = SDL_GetPerformanceCounter();
next_refresh = now + frame_interval;
- uxn_eval(&uxn, screen_vector);
+ uxn_eval(&uxn, uxn_screen.vector);
if(screen_changed())
emu_redraw();
}
- if(screen_vector) {
+ if(uxn_screen.vector) {
Uint64 delay_ms = (next_refresh - now) / ms_interval;
if(delay_ms > 0) SDL_Delay(delay_ms);
} else
@@ -472,7 +470,7 @@ main(int argc, char **argv)
/* flags */
if(argc > 1 && argv[i][0] == '-') {
if(!strcmp(argv[i], "-v"))
- return system_error("Uxn(gui) - Varvara Emulator", "23 Dec 2024.");
+ return system_error("Uxn(gui) - Varvara Emulator", "25 Dec 2024.");
else if(!strcmp(argv[i], "-2x"))
set_zoom(2, 0);
else if(!strcmp(argv[i], "-3x"))