From f8426f0bad75e946da5819a7aa0314620c5558ed Mon Sep 17 00:00:00 2001 From: beeanyew Date: Sat, 8 May 2021 20:31:19 +0200 Subject: [PATCH] Fix RTG panning, silence "Pitch" debug output. --- platforms/amiga/rtg/rtg-output-raylib.c | 28 ++++++++++++++++++------- platforms/amiga/rtg/rtg.c | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/platforms/amiga/rtg/rtg-output-raylib.c b/platforms/amiga/rtg/rtg-output-raylib.c index 7b78368..cbcb52d 100644 --- a/platforms/amiga/rtg/rtg-output-raylib.c +++ b/platforms/amiga/rtg/rtg-output-raylib.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: MIT +#include "config_file/config_file.h" #include "emulator.h" #include "rtg.h" @@ -49,6 +50,13 @@ uint32_t rtg_to_raylib[RTGFMT_NUM] = { PIXELFORMAT_UNCOMPRESSED_R5G5B5A1, }; +uint32_t rtg_pixel_size[RTGFMT_NUM] = { + 1, + 2, + 4, + 2, +}; + void *rtgThread(void *args) { printf("RTG thread running\n"); @@ -123,20 +131,22 @@ reinit_raylib:; printf("Setting up raylib framebuffer image.\n"); raylib_fb.format = rtg_to_raylib[format]; - raylib_fb.width = width; - raylib_fb.height = height; - raylib_fb.mipmaps = 1; - raylib_fb.data = &data->memory[*data->addr]; - - raylib_texture = LoadTextureFromImage(raylib_fb); switch (format) { case RTGFMT_RBG565: + raylib_fb.width = width; indexed_buf = calloc(1, width * height * 2); break; default: + raylib_fb.width = pitch / rtg_pixel_size[format]; break; } + raylib_fb.height = height; + raylib_fb.mipmaps = 1; + raylib_fb.data = &data->memory[*data->addr]; + printf("Width: %d\nPitch: %d\nBPP: %d\n", raylib_fb.width, pitch, rtg_pixel_size[format]); + + raylib_texture = LoadTextureFromImage(raylib_fb); srchax.x = srchax.y = 0; srchax.width = width; @@ -171,7 +181,9 @@ reinit_raylib:; DrawTexturePro(raylib_texture, srchax, dsthax, originhax, 0.0f, RAYWHITE); } else { - DrawTexture(raylib_texture, 0, 0, RAYWHITE); + Rectangle srcrect = { 0, 0, width, height }; + DrawTexturePro(raylib_texture, srcrect, srcrect, originhax, 0.0f, RAYWHITE); + //DrawTexture(raylib_texture, 0, 0, RAYWHITE); } switch (format) { @@ -203,7 +215,7 @@ reinit_raylib:; DrawText("RTG is currently sleeping.", 16, 16, 12, RAYWHITE); EndDrawing(); } - if (height != *data->height || width != *data->width || format != *data->format) { + if (pitch != *data->pitch || height != *data->height || width != *data->width || format != *data->format) { printf("Reinitializing due to something change.\n"); reinit = 1; goto shutdown_raylib; diff --git a/platforms/amiga/rtg/rtg.c b/platforms/amiga/rtg/rtg.c index e0a4681..2aeec27 100644 --- a/platforms/amiga/rtg/rtg.c +++ b/platforms/amiga/rtg/rtg.c @@ -230,7 +230,7 @@ static void handle_rtg_command(uint32_t cmd) { //printf("Set panning to $%.8X (%.8X)\n", framebuffer_addr, rtg_address[0]); //printf("(Panned: $%.8X)\n", framebuffer_addr_adj); //printf("Offset X/Y: %d/%d\n", rtg_offset_x, rtg_offset_y); - printf("Pitch: %d (%d bytes)\n", rtg_x[0], rtg_pitch); + //printf("Pitch: %d (%d bytes)\n", rtg_x[0], rtg_pitch); break; case RTGCMD_SETCLUT: { //printf("Command: SetCLUT.\n"); -- 2.39.2