diff --git a/src/main.c b/src/main.c index cdc8530..8792a9a 100644 --- a/src/main.c +++ b/src/main.c @@ -120,10 +120,17 @@ poll_mouse(void) { printf("MOUSE REL EVENT\n"); if (mouse_event.code == REL_X) { in.mouse.x = CLAMP( - in.mouse.x + (s32)mouse_event.value, 0, (s32)screen_width); + in.mouse.x / zoom + (s32)mouse_event.value, 0, (s32)screen_width); } else if (mouse_event.code == REL_Y) { in.mouse.y = CLAMP( - in.mouse.y + (s32)mouse_event.value, 0, (s32)screen_height); + in.mouse.y / zoom + (s32)mouse_event.value, 0, (s32)screen_height); + } + } else if (mouse_event.type == EV_ABS) { + printf("MOUSE ABS EVENT\n"); + if (mouse_event.code == ABS_X) { + in.mouse.x = CLAMP((s32)mouse_event.value / zoom, 0, (s32)screen_width); + } else if (mouse_event.code == ABS_Y) { + in.mouse.y = CLAMP((s32)mouse_event.value / zoom, 0, (s32)screen_height); } } else if (mouse_event.type == EV_KEY) { printf("MOUSE KEY EVENT\n"); @@ -144,13 +151,6 @@ poll_mouse(void) { } break; default: break; } - } else if (mouse_event.type == EV_ABS) { - printf("MOUSE ABS EVENT\n"); - if (mouse_event.code == ABS_X) { - in.mouse.x = CLAMP((s32)mouse_event.value, 0, (s32)screen_width); - } else if (mouse_event.code == ABS_Y) { - in.mouse.y = CLAMP((s32)mouse_event.value, 0, (s32)screen_height); - } } in.mouse.update = true; } diff --git a/src/ppu.c b/src/ppu.c index 3afa533..38b27e6 100644 --- a/src/ppu.c +++ b/src/ppu.c @@ -27,6 +27,7 @@ static size_t screen_height = 0; static size_t bpp = 0; static int fb_file = 0; static int refresh_file = 0; +static int zoom = 2; static u8 *framebuffer = 0; @@ -175,6 +176,8 @@ ppu_init(void) { fprintf(stderr, "error: couldn't mmap the framebuffer\n"); exit(EXIT_FAILURE); } + screen_width /= zoom; + screen_height /= zoom; // Allocate intermediate buffers. pixels_fg = malloc(screen_width * screen_height); @@ -222,7 +225,12 @@ blit_framebuffer(void) { size_t idx = i + j * screen_width; if (bpp == 16) { u16 *p = framebuffer; - p[idx] = rgb565(palette[pixels_fg[idx] << 2 | pixels_bg[idx]]); + for (size_t zz = 0; zz < zoom; zz++) { + size_t fb_idx = (i * zoom + j * screen_width * zoom * zoom + zz * screen_width * zoom); + for (size_t z = 0; z < zoom; z++) { + p[fb_idx + z] = rgb565(palette[pixels_fg[idx] << 2 | pixels_bg[idx]]); + } + } } else if (bpp == 32) { u32 *p = framebuffer; p[idx] = palette[pixels_fg[idx] << 2 | pixels_bg[idx]];