]> git.sesse.net Git - pistorm/commitdiff
Fix RTG panning, silence "Pitch" debug output.
authorbeeanyew <beeanyew@gmail.com>
Sat, 8 May 2021 18:31:19 +0000 (20:31 +0200)
committerbeeanyew <beeanyew@gmail.com>
Sat, 8 May 2021 18:31:19 +0000 (20:31 +0200)
platforms/amiga/rtg/rtg-output-raylib.c
platforms/amiga/rtg/rtg.c

index 7b78368aac43d43f95660ed7503443fb9deed512..cbcb52d259e462c87f52f37e5536323d319f0250 100644 (file)
@@ -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;
index e0a46816300e33626d1ae9a759ed140d27342bf7..2aeec270a52c1fe0581cd505f1727d493e11dfdc 100644 (file)
@@ -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");