uint16_t Xorigin, Yorigin;
};
+#pragma pack(2)
struct P96Template {
uint32_t _p_Memory;
uint16_t BytesPerRow;
uint32_t BgPen;
};
+#pragma pack(2)
struct P96Pattern {
uint32_t _p_Memory;
uint16_t XOffset, YOffset;
sptr = get_mapped_data_pointer_by_address(cfg, src_addr);
if (!sptr) {
if (realtime_graphics_debug) {
- printf("BlitTemplate pattern data NOT available in mapped range, source address: $%.8X\n", src_addr);
+ printf("BlitTemplate data NOT available in mapped range, source address: $%.8X\n", src_addr);
}
} else {
if (realtime_graphics_debug) {
- printf("BlitTemplate pattern data available in mapped range at $%.8X\n", src_addr);
+ printf("BlitTemplate data available in mapped range at $%.8X\n", src_addr);
}
}
return;
case DRAWMODE_JAM2:
for (uint16_t ys = 0; ys < h; ys++) {
- cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x];
-
for (int xs = 0; xs < w; xs++) {
TEMPLATE_LOOPX;
if (w >= 8 && cur_bit == 0x80 && xs < w - 8) {
return;
case DRAWMODE_COMPLEMENT:
for (uint16_t ys = 0; ys < h; ys++) {
- cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x];
-
for (int xs = 0; xs < w; xs++) {
TEMPLATE_LOOPX;
if (w >= 8 && cur_bit == 0x80 && xs < w - 8) {
}
}
-void rtg_blitpattern(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t src_addr, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t format, uint16_t offset_x, uint16_t offset_y, uint8_t mask, uint8_t draw_mode, uint8_t loop_rows) {
+void rtg_blitpattern(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t src_addr_, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t format, uint16_t offset_x, uint16_t offset_y, uint8_t mask, uint8_t draw_mode, uint8_t loop_rows) {
if (mask) {}
uint8_t *dptr = &rtg_mem[rtg_address_adj[1] + (x << format) + (y * pitch)];
uint8_t cur_bit = 0, base_bit = 0, cur_byte = 0;
uint8_t invert = (draw_mode & DRAWMODE_INVERSVID);
uint16_t tmpl_x = 0;
+ uint32_t src_addr = src_addr_;
+ uint32_t src_addr_base = src_addr;
draw_mode &= 0x03;
};
- if (src_addr >= (PIGFX_RTG_BASE + PIGFX_REG_SIZE))
- sptr = &rtg_mem[src_addr - (PIGFX_RTG_BASE + PIGFX_REG_SIZE)];
- else {
- int i = get_mapped_item_by_address(cfg, src_addr);
- if (i != -1) {
- sptr = &cfg->map_data[i][src_addr - cfg->map_offset[i]];
+ sptr = get_mapped_data_pointer_by_address(cfg, src_addr);
+ if (!sptr) {
+ if (realtime_graphics_debug) {
+ printf("BlitPattern data NOT available in mapped range, source address: $%.8X\n", src_addr);
+ src_addr += (offset_y % loop_rows) * 2;
}
- else {
- printf("BlitPattern: Failed to find mapped range for address %.8X\n", src_addr);
- return;
+ } else {
+ if (realtime_graphics_debug) {
+ printf("BlitPattern data available in mapped range at $%.8X\n", src_addr);
}
+ sptr_base = sptr;
+ sptr += (offset_y % loop_rows) * 2;
}
- sptr_base = sptr;
- sptr += (offset_y % loop_rows) * 2;
-
switch (draw_mode) {
case DRAWMODE_JAM1:
for (uint16_t ys = 0; ys < h; ys++) {
- cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x];
-
for (int xs = 0; xs < w; xs++) {
+ PATTERN_LOOPX;
if (w >= 8 && cur_bit == 0x80 && xs < w - 8) {
if (mask == 0xFF || format != RTGFMT_8BIT) {
SET_RTG_PIXELS(&dptr[xs << format], fg_color[format], format);
xs--;
cur_bit = 0x80;
}
- PATTERN_LOOPX;
}
PATTERN_LOOPY;
}
return;
case DRAWMODE_JAM2:
for (uint16_t ys = 0; ys < h; ys++) {
- cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x];
-
for (int xs = 0; xs < w; xs++) {
+ PATTERN_LOOPX;
if (w >= 8 && cur_bit == 0x80 && xs < w - 8) {
if (mask == 0xFF || format != RTGFMT_8BIT) {
SET_RTG_PIXELS2_COND(&dptr[xs << format], fg_color[format], bg_color[format], format);
xs--;
cur_bit = 0x80;
}
- PATTERN_LOOPX;
}
PATTERN_LOOPY;
}
return;
case DRAWMODE_COMPLEMENT:
for (uint16_t ys = 0; ys < h; ys++) {
- cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x];
-
for (int xs = 0; xs < w; xs++) {
+ PATTERN_LOOPX;
if (w >= 8 && cur_bit == 0x80 && xs < w - 8) {
INVERT_RTG_PIXELS(&dptr[xs << format], format)
xs += 7;
xs--;
cur_bit = 0x80;
}
- PATTERN_LOOPX;
}
PATTERN_LOOPY;
}
break;
}
case RTGCMD_BLITTEMPLATE: {
- // A0: BoardInfo *b, A1: RenderInfo *r, A2 Template *t
+ // A0: BoardInfo *b, A1: RenderInfo *r, A2: Template *t
// D0: WORD x, D1: WORD y, D2: WORD w, D3: WORD h
// D4: UBYTE mask, D7: RGBFTYPE format
- if (!r)
+ if (!r || !M68KR(M68K_REG_A2))
break;
+ gdebug("iBlitTemplate begin\n");
uint16_t t_pitch = 0, x_offset = 0;
uint32_t src_addr = M68KR(M68K_REG_A2);
t_pitch = be16toh(t->BytesPerRow);
fgcol = be32toh(t->FgPen);
bgcol = be32toh(t->BgPen);
- x_offset = be16toh(t->XOffset);
+ x_offset = t->XOffset;
draw_mode = t->DrawMode;
src_addr = be32toh(t->_p_Memory);
} else {
t_pitch = be16toh(ps_read_16(src_addr + (uint32_t)&t->BytesPerRow));
fgcol = be32toh(ps_read_32(src_addr + (uint32_t)&t->FgPen));
bgcol = be32toh(ps_read_32(src_addr + (uint32_t)&t->BgPen));
- x_offset = be16toh(ps_read_16(src_addr + (uint32_t)&t->XOffset));
+ x_offset = ps_read_8(src_addr + (uint32_t)&t->XOffset);
draw_mode = ps_read_8(src_addr + (uint32_t)&t->DrawMode);
src_addr = be32toh(ps_read_32(src_addr + (uint32_t)&t->_p_Memory));
}
rtg_address_adj[1] = rtg_address[1] - (PIGFX_RTG_BASE + PIGFX_REG_SIZE);
rtg_blittemplate(M68KR(M68K_REG_D0), M68KR(M68K_REG_D1), M68KR(M68K_REG_D2), M68KR(M68K_REG_D3), src_addr, fgcol, bgcol, CMD_PITCH, t_pitch, RGBF_D7, x_offset, cmd_mask, draw_mode);
+ gdebug("iBlitTemplate end\n");
+ break;
+ }
+ case RTGCMD_BLITPATTERN: {
+ // A0: BoardInfo *b, A1: RenderInfo *r, A2: Pattern *p
+ // D0: WORD x, D1: WORD y, D2: WORD w, D3: WORD h
+ // D4: UBYTE mask, D7: RGBFTYPE format
+ if (!r || !M68KR(M68K_REG_A2))
+ break;
+ gdebug("iBlitPattern begin\n");
+
+ uint16_t x_offset = 0, y_offset = 0;
+ uint32_t src_addr = M68KR(M68K_REG_A2);
+ uint32_t fgcol = 0, bgcol = 0;
+ uint8_t draw_mode = 0, loop_rows = 0;
+
+ struct P96Pattern *p = (struct P96Pattern *)get_mapped_data_pointer_by_address(cfg, M68KR(M68K_REG_A2));
+ if (p) {
+ fgcol = be32toh(p->FgPen);
+ bgcol = be32toh(p->BgPen);
+ x_offset = be16toh(p->XOffset);
+ y_offset = be16toh(p->YOffset);
+ draw_mode = p->DrawMode;
+ loop_rows = 1 << p->Size;
+ src_addr = be32toh(p->_p_Memory);
+ } else {
+ fgcol = be32toh(ps_read_32(src_addr + (uint32_t)&p->FgPen));
+ bgcol = be32toh(ps_read_32(src_addr + (uint32_t)&p->BgPen));
+ x_offset = be16toh(ps_read_16(src_addr + (uint32_t)&p->XOffset));
+ y_offset = be16toh(ps_read_16(src_addr + (uint32_t)&p->YOffset));
+ draw_mode = ps_read_8(src_addr + (uint32_t)&p->DrawMode);
+ loop_rows = 1 << ps_read_8(src_addr + (uint32_t)&p->Size);
+ src_addr = be32toh(p->_p_Memory);
+ }
+
+ cmd_mask = (uint8_t)M68KR(M68K_REG_D4);
+ rtg_address[1] = be32toh(r->_p_Memory);
+ rtg_address_adj[1] = rtg_address[1] - (PIGFX_RTG_BASE + PIGFX_REG_SIZE);
+
+ rtg_blitpattern(M68KR(M68K_REG_D0), M68KR(M68K_REG_D1), M68KR(M68K_REG_D2), M68KR(M68K_REG_D3), src_addr, fgcol, bgcol, CMD_PITCH, RGBF_D7, x_offset, y_offset, cmd_mask, draw_mode, loop_rows);
+ gdebug("iBlitPattern end\n");
break;
}
default:
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 \
if (sptr) { cur_byte = sptr[tmpl_x]; } \
- else { cur_byte = ps_read_8(src_addr + 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; \
}
void BlitTemplate (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGA2(struct Template *t), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format)) {
-#ifndef IRTG
+#ifndef IRTG
if (!r || !t) return;
if (w < 1 || h < 1) return;
}
void BlitPattern (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGA2(struct Pattern *p), __REGD0(WORD x), __REGD1(WORD y), __REGD2(WORD w), __REGD3(WORD h), __REGD4(UBYTE mask), __REGD7(RGBFTYPE format)) {
+#ifndef IRTG
if (!r || !p) return;
if (w < 1 || h < 1) return;
WRITEBYTE(RTG_U82, p->DrawMode);
WRITEBYTE(RTG_U83, (1 << p->Size));
WRITESHORT(RTG_COMMAND, RTGCMD_BLITPATTERN);
+#else
+ IWRITECMD(RTGCMD_BLITPATTERN);
+#endif
}
void DrawLine (__REGA0(struct BoardInfo *b), __REGA1(struct RenderInfo *r), __REGA2(struct Line *l), __REGD0(UBYTE mask), __REGD7(RGBFTYPE format)) {