]> git.sesse.net Git - pistorm/blobdiff - platforms/amiga/rtg/rtg.h
Fix iRTG BlitTemplate add iRTG BlitPattern support
[pistorm] / platforms / amiga / rtg / rtg.h
index dda431c097d6f13054c07b3e561e7b6473ba1a6a..63decc79211a1d06d52d58dbd5d0acf4b239ad2e 100644 (file)
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: MIT
+
 #define PIGFX_RTG_BASE     0x70000000
 #define PIGFX_REG_SIZE     0x00010000
 #define PIGFX_RTG_SIZE     0x02000000
@@ -7,13 +9,25 @@
 
 #define CARD_OFFSET 0
 
-#include "rtg_driver_amiga/rtg_enums.h"
+#include "rtg_enums.h"
 
 void rtg_write(uint32_t address, uint32_t value, uint8_t mode);
 unsigned int rtg_read(uint32_t address, uint8_t mode);
 void rtg_set_clut_entry(uint8_t index, uint32_t xrgb);
 void rtg_init_display();
 void rtg_shutdown_display();
+void rtg_enable_mouse_cursor();
+
+unsigned int rtg_get_fb();
+void rtg_set_mouse_cursor_pos(int16_t x, int16_t y);
+void rtg_set_cursor_clut_entry(uint8_t r, uint8_t g, uint8_t b, uint8_t idx);
+void rtg_set_mouse_cursor_image(uint8_t *src, uint8_t w, uint8_t h);
+
+void rtg_show_fps(uint8_t enable);
+void rtg_palette_debug(uint8_t enable);
+
+int init_rtg_data(struct emulator_config *cfg);
+void shutdown_rtg();
 
 void rtg_fillrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format, uint8_t mask);
 void rtg_fillrect_solid(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format);
@@ -27,25 +41,34 @@ void rtg_drawline_solid(int16_t x1_, int16_t y1_, int16_t x2_, int16_t y2_, uint
 void rtg_drawline (int16_t x1_, int16_t y1_, int16_t x2_, int16_t y2_, uint16_t len, uint16_t pattern, uint16_t pattern_offset, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t format, uint8_t mask, uint8_t draw_mode);
 
 void rtg_p2c (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h, uint8_t draw_mode, uint8_t planes, uint8_t mask, uint8_t layer_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src);
+void rtg_p2d (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h, uint8_t draw_mode, uint8_t planes, uint8_t mask, uint8_t layer_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src);
 
 #define PATTERN_LOOPX \
-    tmpl_x ^= 0x01; \
-    cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x]; \
+    if (sptr)   { cur_byte = sptr[tmpl_x]; } \
+    else        { cur_byte = m68k_read_memory_8(src_addr + tmpl_x); } \
+    if (invert) { cur_byte ^= 0xFF; } \
+    tmpl_x ^= 0x01;
 
 #define PATTERN_LOOPY \
        sptr += 2 ; \
-       if ((ys + offset_y + 1) % loop_rows == 0) \
-               sptr = sptr_base; \
+    src_addr += 2; \
+       if ((ys + offset_y + 1) % loop_rows == 0) { \
+               if (sptr) sptr = sptr_base; \
+        src_addr = src_addr_base; \
+    } \
        tmpl_x = (offset_x / 8) % 2; \
        cur_bit = base_bit; \
        dptr += pitch;
 
 #define TEMPLATE_LOOPX \
-    tmpl_x++; \
-    cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x]; \
+    if (sptr)   { cur_byte = sptr[tmpl_x]; } \
+    else        { cur_byte = m68k_read_memory_8(src_addr + tmpl_x); } \
+    if (invert) { cur_byte ^= 0xFF; } \
+    tmpl_x++;
 
 #define TEMPLATE_LOOPY \
-    sptr += t_pitch; \
+    if (sptr) sptr += t_pitch; \
+    src_addr += t_pitch; \
     dptr += pitch; \
     tmpl_x = offset_x / 8; \
     cur_bit = base_bit;
@@ -255,12 +278,19 @@ void rtg_p2c (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t
 #define DECODE_PLANAR_PIXEL(a) \
        switch (planes) { \
                case 8: if (layer_mask & 0x80 && bmp_data[(plane_size * 7) + cur_byte] & cur_bit) a |= 0x80; \
+        /* Fallthrough */ \
                case 7: if (layer_mask & 0x40 && bmp_data[(plane_size * 6) + cur_byte] & cur_bit) a |= 0x40; \
+        /* Fallthrough */ \
                case 6: if (layer_mask & 0x20 && bmp_data[(plane_size * 5) + cur_byte] & cur_bit) a |= 0x20; \
+        /* Fallthrough */ \
                case 5: if (layer_mask & 0x10 && bmp_data[(plane_size * 4) + cur_byte] & cur_bit) a |= 0x10; \
+        /* Fallthrough */ \
                case 4: if (layer_mask & 0x08 && bmp_data[(plane_size * 3) + cur_byte] & cur_bit) a |= 0x08; \
+        /* Fallthrough */ \
                case 3: if (layer_mask & 0x04 && bmp_data[(plane_size * 2) + cur_byte] & cur_bit) a |= 0x04; \
+        /* Fallthrough */ \
                case 2: if (layer_mask & 0x02 && bmp_data[plane_size + cur_byte] & cur_bit) a |= 0x02; \
+        /* Fallthrough */ \
                case 1: if (layer_mask & 0x01 && bmp_data[cur_byte] & cur_bit) a |= 0x01; \
                        break; \
        }
@@ -268,12 +298,19 @@ void rtg_p2c (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t
 #define DECODE_INVERTED_PLANAR_PIXEL(a) \
        switch (planes) { \
                case 8: if (layer_mask & 0x80 && (bmp_data[(plane_size * 7) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x80; \
+        /* Fallthrough */ \
                case 7: if (layer_mask & 0x40 && (bmp_data[(plane_size * 6) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x40; \
+        /* Fallthrough */ \
                case 6: if (layer_mask & 0x20 && (bmp_data[(plane_size * 5) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x20; \
+        /* Fallthrough */ \
                case 5: if (layer_mask & 0x10 && (bmp_data[(plane_size * 4) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x10; \
+        /* Fallthrough */ \
                case 4: if (layer_mask & 0x08 && (bmp_data[(plane_size * 3) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x08; \
+        /* Fallthrough */ \
                case 3: if (layer_mask & 0x04 && (bmp_data[(plane_size * 2) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x04; \
+        /* Fallthrough */ \
                case 2: if (layer_mask & 0x02 && (bmp_data[plane_size + cur_byte] ^ 0xFF) & cur_bit) a |= 0x02; \
+        /* Fallthrough */ \
                case 1: if (layer_mask & 0x01 && (bmp_data[cur_byte] ^ 0xFF) & cur_bit) a |= 0x01; \
                        break; \
        }