// SPDX-License-Identifier: MIT
+#include "config_file/config_file.h"
#include "emulator.h"
#include "rtg.h"
PIXELFORMAT_UNCOMPRESSED_R5G5B5A1,
};
+uint32_t rtg_pixel_size[RTGFMT_NUM] = {
+ 1,
+ 2,
+ 4,
+ 2,
+};
+
void *rtgThread(void *args) {
printf("RTG thread running\n");
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;
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) {
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;
//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");