Accelerate BlitRect

This commit is contained in:
beeanyew
2021-01-06 13:59:48 +01:00
parent b896610573
commit 72d25e469d
4 changed files with 50 additions and 3 deletions

View 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)];
}
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;
}
}

View 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);
}
}
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);
}