From 3d5e1e343f5db5e7b6041fcfd444bf4216a36cd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sigrid=20Solveig=20Hafl=C3=ADnud=C3=B3ttir?= Date: Tue, 18 May 2021 15:28:47 +0200 Subject: [PATCH] call SDL_RenderSetLogicalSize to avoid manual coordinates adjustment based on zoom --- src/emulator.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/emulator.c b/src/emulator.c index 3767ef7..03541f4 100644 --- a/src/emulator.c +++ b/src/emulator.c @@ -113,6 +113,7 @@ init(void) gRenderer = SDL_CreateRenderer(gWindow, -1, 0); if(gRenderer == NULL) return error("Renderer", SDL_GetError()); + SDL_RenderSetLogicalSize(gRenderer, ppu.width, ppu.height); gTexture = SDL_CreateTexture(gRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STATIC, ppu.width, ppu.height); if(gTexture == NULL) return error("Texture", SDL_GetError()); @@ -136,8 +137,8 @@ void domouse(SDL_Event *event) { Uint8 flag = 0x00; - Uint16 x = clamp(event->motion.x / zoom - ppu.pad, 0, ppu.hor * 8 - 1); - Uint16 y = clamp(event->motion.y / zoom - ppu.pad, 0, ppu.ver * 8 - 1); + Uint16 x = clamp(event->motion.x - ppu.pad, 0, ppu.hor * 8 - 1); + Uint16 y = clamp(event->motion.y - ppu.pad, 0, ppu.ver * 8 - 1); mempoke16(devmouse->dat, 0x2, x); mempoke16(devmouse->dat, 0x4, y); devmouse->dat[7] = 0x00;