uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 3d5e1e343f5db5e7b6041fcfd444bf4216a36cd5
parent 5bcbb072621256f3ffe20976d9da51db349b7e9f
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Tue, 18 May 2021 15:28:47 +0200

call SDL_RenderSetLogicalSize to avoid manual coordinates adjustment based on zoom

Diffstat:
Msrc/emulator.c | 5+++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git 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;