]> git.sesse.net Git - pistorm/commitdiff
Accelerate BlitRect
authorbeeanyew <beeanyew@gmail.com>
Wed, 6 Jan 2021 12:59:48 +0000 (13:59 +0100)
committerbeeanyew <beeanyew@gmail.com>
Wed, 6 Jan 2021 12:59:48 +0000 (13:59 +0100)
platforms/amiga/rtg/rtg.c
platforms/amiga/rtg/rtg_driver_amiga/pigfx.c
platforms/amiga/rtg/rtg_driver_amiga/pigfx020.card
platforms/amiga/rtg/rtg_driver_amiga/pigfx030.card

index 7918098de9fda049987fa52f49bcd76078572787..8bd437d2f8b2d1f9be8049f8dc9d4c1ff2f37d4e 100644 (file)
@@ -231,6 +231,7 @@ static void handle_rtg_command(uint32_t cmd) {
             break;
         case RTGCMD_BLITRECT:
             rtg_blitrect(rtg_x[0], rtg_y[0], rtg_x[1], rtg_y[1], rtg_x[2], rtg_y[2], rtg_x[3], rtg_format, 0xFF);
+            break;
     }
 }
 
@@ -275,6 +276,27 @@ void rtg_fillrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color
 
 void rtg_blitrect(uint16_t x, uint16_t y, uint16_t dx, uint16_t dy, uint16_t w, uint16_t h, uint16_t pitch, uint16_t format, uint8_t mask) {
     if (mask) {}
+    //printf("BlitRect: %d,%d to %d,%d (%dx%d) p:%d dp: %d\n", x, y, dx, dy, w, h, pitch, rtg_pitch);
     uint8_t *sptr = &rtg_mem[framebuffer_addr + (x << format) + (y * pitch)];
     uint8_t *dptr = &rtg_mem[framebuffer_addr + (dx << format) + (dy * pitch)];
-}
\ No newline at end of file
+
+    uint32_t xdir = 1, pitchstep = pitch;
+
+    if (y < dy) {
+        pitchstep = -pitch;
+        sptr += ((h - 1) * pitch);
+        dptr += ((h - 1) * pitch);
+    }
+    if (x < dx) {
+        xdir = 0;
+    }
+
+    for (int ys = 0; ys < h; ys++) {
+        if (xdir)
+            memcpy(dptr, sptr, w << format);
+        else
+            memmove(dptr, sptr, w << format);
+        sptr += pitchstep;
+        dptr += pitchstep;
+    }
+}
index e1cb772311c86fd1ca6dfbd09e8d4d566fa08f68..1835c00af8cf3ca5ec1df4f341b4f0f4f875acd0 100644 (file)
@@ -43,6 +43,12 @@ enum pi_regs {
   RTG_U82     = 0x21,
   RTG_U83     = 0x22,
   RTG_U84     = 0x23,
+  RTG_X4      = 0x24,
+  RTG_X5      = 0x26,
+  RTG_Y4      = 0x28,
+  RTG_Y5      = 0x2A,
+  RTG_U1      = 0x2C,
+  RTG_U2      = 0x2E,
 };
 
 enum rtg_cmds {
@@ -53,6 +59,7 @@ enum rtg_cmds {
   RTGCMD_SETDISPLAY,
   RTGCMD_SETSWITCH,
   RTGCMD_FILLRECT,
+  RTGCMD_BLITRECT,
 };
 
 enum rtg_formats {
@@ -114,6 +121,7 @@ void SetReadPlane (__REGA0(struct BoardInfo *b), __REGD0(UBYTE plane));
 void WaitVerticalSync (__REGA0(struct BoardInfo *b), __REGD0(BOOL toggle));
 
 void FillRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(ULONG color), __REGD5(UBYTE mask), __REGD7(RGBFTYPE format));
+void BlitRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD dx), __REGD3(WORD dy), __REGD4(WORD w), __REGD5(WORD h), __REGD6(UBYTE mask), __REGD7(RGBFTYPE format));
 
 static ULONG LibStart(void) {
   return(-1);
@@ -338,7 +346,7 @@ int InitCard(__REGA0(struct BoardInfo* b)) {
 
   b->FillRect = (void *)FillRect;
   //b->InvertRect = (void *)NULL;
-  //b->BlitRect = (void *)NULL;
+  b->BlitRect = (void *)BlitRect;
   //b->BlitTemplate = (void *)NULL;
   //b->BlitPattern = (void *)NULL;
   //b->DrawLine = (void *)NULL;
@@ -519,4 +527,21 @@ void FillRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __RE
   WRITELONG(RTG_RGB1, color);
   WRITESHORT(RTG_X3, r->BytesPerRow);
   WRITESHORT(RTG_COMMAND, RTGCMD_FILLRECT);
-}
\ No newline at end of file
+}
+
+void BlitRect (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD dx), __REGD3(WORD dy), __REGD4(WORD w), __REGD5(WORD h), __REGD6(UBYTE mask), __REGD7(RGBFTYPE format)) {
+  if (!r)
+    return;
+  if (mask != 0xFF)
+    b->BlitRectDefault(b, r, x, y, dx, dy, w, h, mask, format);
+
+  WRITESHORT(RTG_FORMAT, rgbf_to_rtg[format]);
+  WRITESHORT(RTG_X1, x);
+  WRITESHORT(RTG_X2, dx);
+  WRITESHORT(RTG_X3, w);
+  WRITESHORT(RTG_Y1, y);
+  WRITESHORT(RTG_Y2, dy);
+  WRITESHORT(RTG_Y3, h);
+  WRITESHORT(RTG_X4, r->BytesPerRow);
+  WRITESHORT(RTG_COMMAND, RTGCMD_BLITRECT);
+}
index d21ded34dcc6b21047118f16efc446d50a8d4c52..791667bff7acea1a89d08bcecc8c4f99a4bac7a8 100644 (file)
Binary files a/platforms/amiga/rtg/rtg_driver_amiga/pigfx020.card and b/platforms/amiga/rtg/rtg_driver_amiga/pigfx020.card differ
index d21ded34dcc6b21047118f16efc446d50a8d4c52..791667bff7acea1a89d08bcecc8c4f99a4bac7a8 100644 (file)
Binary files a/platforms/amiga/rtg/rtg_driver_amiga/pigfx030.card and b/platforms/amiga/rtg/rtg_driver_amiga/pigfx030.card differ