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;
}
}
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;
+ }
+}
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 {
RTGCMD_SETDISPLAY,
RTGCMD_SETSWITCH,
RTGCMD_FILLRECT,
+ RTGCMD_BLITRECT,
};
enum rtg_formats {
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);
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;
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);
+}