Commit a5d74677 authored by Bjorn Astrom's avatar Bjorn Astrom
Browse files

Graphics acceleration stuff for ScummVM

parent 7e1863f3
......@@ -78,6 +78,33 @@ void update_hw_sprite(uint8_t *data, uint32_t *colors, uint16_t w, uint16_t h)
}
}
void update_hw_sprite_clut(uint8_t *data_, uint8_t *colors, uint16_t w, uint16_t h, uint8_t keycolor)
{
uint8_t *data = data_;
uint8_t color[4];
for (int y = 0; y < h && y < 48; y++) {
for (int x = 0; x < w && x < 32; x++) {
if (data[x] == keycolor) {
*((int *)color) = 0x00ff00ff;
}
else {
//memcpy(&color, &colors[data[x]*3], 3);
color[0] = colors[(data[x] * 3)+2];
color[1] = colors[(data[x] * 3)+1];
color[2] = colors[(data[x] * 3)];
color[3] = 0x00;
if (*((int *)color) == 0x00FF00FF)
*((int *)color) = 0x00FE00FE;
}
sprite_buf[(y * 32) + x] = *((int *)color);
video_formatter_write((y * 32) + x, 14);
video_formatter_write(sprite_buf[(y * 32) + x] & 0x00ffffff, 15);
}
data += w;
}
}
void clip_hw_sprite(int16_t offset_x, int16_t offset_y)
{
uint16_t xo = 0, yo = 0;
......@@ -106,17 +133,6 @@ void clear_hw_sprite()
}
}
void horizline(uint16_t x1, uint16_t x2, uint16_t y, uint32_t color) {
uint32_t* p=fb+y*fb_pitch;
uint16_t tmp;
if (x2>x1) {
tmp=x1; x1=x2; x2=tmp;
}
while (x1>x2) {
p[x1--]=color;
}
}
void fill_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint32_t fg_color, uint32_t color_format, uint8_t mask)
{
uint32_t* dp = fb + (rect_y1 * fb_pitch);
......@@ -199,34 +215,6 @@ void invert_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uin
}
}
void fill_rect32(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint32_t rect_rgb) {
for (uint16_t y=rect_y1; y<=rect_y2; y++) {
uint32_t* p=fb+y*fb_pitch;
for (uint16_t x=rect_x1; x<=rect_x2; x++) {
p[x]=rect_rgb;
}
}
}
void fill_rect8(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint8_t rect_rgb) {
for (uint16_t y=rect_y1; y<=rect_y2; y++) {
uint8_t* p=(uint8_t*)(fb+y*fb_pitch);
//for (uint16_t x=rect_x1; x<=rect_x2; x++) {
// p[x]=rect_rgb;
//}
memset(p+rect_x1,rect_rgb,rect_x2-rect_x1+1);
}
}
void fill_rect16(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_rgb) {
for (uint16_t y=rect_y1; y<=rect_y2; y++) {
uint16_t* p=(uint16_t*)(fb+y*fb_pitch);
for (uint16_t x=rect_x1; x<=rect_x2; x++) {
p[x]=rect_rgb;
}
}
}
void copy_rect_nomask(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint16_t rect_sx, uint16_t rect_sy, uint32_t color_format, uint32_t* sp_src, uint32_t src_pitch, uint8_t draw_mode)
{
uint32_t* dp = fb + (rect_y1 * fb_pitch);
......@@ -352,84 +340,6 @@ void copy_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint1
}
}
void copy_rect32(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_sx, uint16_t rect_sy) {
int8_t ystep=1, xstep=1;
uint16_t tmp;
if (rect_sy < rect_y1) {
uint16_t h = rect_y2-rect_y1;
ystep=-1;
tmp=rect_y2; rect_y2=rect_y1; rect_y1=tmp;
rect_sy+=h;
}
if (rect_sx < rect_x1) {
uint16_t w = rect_x2-rect_x1;
xstep=-1;
tmp=rect_x2; rect_x2=rect_x1; rect_x1=tmp;
rect_sx+=w;
}
rect_y2+=ystep;
rect_x2+=xstep;
for (uint16_t sy=rect_sy, dy=rect_y1; dy!=rect_y2; sy+=ystep, dy+=ystep) {
uint32_t* dp=(uint32_t*)(fb+dy*fb_pitch);
uint32_t* sp=(uint32_t*)(fb+sy*fb_pitch);
for (uint16_t sx=rect_sx, dx=rect_x1; dx!=rect_x2; sx+=xstep, dx+=xstep) {
dp[dx]=sp[sx];
}
}
}
void copy_rect16(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_sx, uint16_t rect_sy) {
int8_t ystep=1, xstep=1;
uint16_t tmp;
if (rect_sy < rect_y1) {
uint16_t h = rect_y2-rect_y1;
ystep=-1;
tmp=rect_y2; rect_y2=rect_y1; rect_y1=tmp;
rect_sy+=h;
}
if (rect_sx < rect_x1) {
uint16_t w = rect_x2-rect_x1;
xstep=-1;
tmp=rect_x2; rect_x2=rect_x1; rect_x1=tmp;
rect_sx+=w;
}
rect_y2+=ystep;
rect_x2+=xstep;
for (uint16_t sy=rect_sy, dy=rect_y1; dy!=rect_y2; sy+=ystep, dy+=ystep) {
uint16_t* dp=(uint16_t*)(fb+dy*fb_pitch);
uint16_t* sp=(uint16_t*)(fb+sy*fb_pitch);
for (uint16_t sx=rect_sx, dx=rect_x1; dx!=rect_x2; sx+=xstep, dx+=xstep) {
dp[dx]=sp[sx];
}
}
}
void copy_rect8(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_sx, uint16_t rect_sy) {
int8_t ystep=1, xstep=1;
uint16_t tmp;
if (rect_sy < rect_y1) {
uint16_t h = rect_y2-rect_y1;
ystep=-1;
tmp=rect_y2; rect_y2=rect_y1; rect_y1=tmp;
rect_sy+=h;
}
if (rect_sx < rect_x1) {
uint16_t w = rect_x2-rect_x1;
xstep=-1;
tmp=rect_x2; rect_x2=rect_x1; rect_x1=tmp;
rect_sx+=w;
}
rect_y2+=ystep;
rect_x2+=xstep;
for (uint16_t sy=rect_sy, dy=rect_y1; dy!=rect_y2; sy+=ystep, dy+=ystep) {
uint8_t* dp=(uint8_t*)(fb+dy*fb_pitch);
uint8_t* sp=(uint8_t*)(fb+sy*fb_pitch);
for (uint16_t sx=rect_sx, dx=rect_x1; dx!=rect_x2; sx+=xstep, dx+=xstep) {
dp[dx]=sp[sx];
}
}
}
#define DRAW_LINE_PIXEL \
if (draw_mode == JAM1) { \
if(pattern & cur_bit) { \
......@@ -1021,127 +931,74 @@ void template_fill_rect(uint32_t color_format, uint16_t rect_x1, uint16_t rect_y
}
}
void fill_template(uint32_t bpp, uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2,
uint8_t draw_mode, uint8_t mask, uint32_t fg_color, uint32_t bg_color, uint16_t x_offset, uint16_t y_offset, uint8_t* tmpl_data, uint16_t tmpl_pitch, uint16_t loop_rows)
// Generic graphics acceleration functionality
void acc_clear_buffer(uint32_t addr, uint16_t w, uint16_t h, uint16_t pitch_, uint32_t fg_color, uint32_t color_format)
{
uint8_t inversion = 0;
uint16_t rows;
int bitoffset;
uint8_t* dp=(uint8_t*)(fb);
uint8_t* tmpl_base;
if (!w || !h || !addr)
return;
uint16_t width = rect_x2-rect_x1+1;
uint16_t pitch = pitch_;
uint8_t* dp = (uint8_t*)((uint32_t)addr);
uint8_t u8_fg = fg_color >> 24;
if (draw_mode & INVERSVID) inversion = 1;
draw_mode &= 0x03;
if (pitch == 0) {
switch (color_format) {
case MNTVA_COLOR_8BIT: pitch = w; break;
case MNTVA_COLOR_16BIT565: pitch = w * 2; break;
case MNTVA_COLOR_32BIT: pitch = w * 4; break;
default: return; break;
}
}
bitoffset = x_offset % 8;
tmpl_base = tmpl_data + x_offset / 8;
// starting position in destination
dp += rect_y1*fb_pitch + rect_x1*bpp;
// number of 8-bit blocks of source
uint16_t loop_x = x_offset;
uint16_t loop_y = y_offset;
for (rows = rect_y1; rows <= rect_y2; rows++, dp += fb_pitch, tmpl_base += tmpl_pitch) {
unsigned long cols;
uint8_t* dp2 = dp;
uint8_t* tmpl_mem;
unsigned int data;
tmpl_mem = tmpl_base;
data = *tmpl_mem;
for (cols = 0; cols < width; cols += 8, dp2 += bpp*8) {
unsigned int byte;
long bits;
long max = width - cols;
if (max > 8) max = 8;
// loop through 16-bit horizontal pattern
if (loop_rows>0) {
tmpl_mem = tmpl_data+(loop_y%loop_rows)*2;
byte = tmpl_mem[loop_x%2];
loop_x++;
} else {
data <<= 8;
data |= *++tmpl_mem;
byte = data >> (8 - bitoffset);
}
//printf("Clearing %dx%d pixels, %d bytes (%d).\n", w, h, h * pitch, pitch);
switch (draw_mode)
{
case JAM1:
{
for (bits = 0; bits < max; bits++) {
int bit_set = (byte & 0x80);
byte <<= 1;
if (inversion) bit_set = !bit_set;
if (bit_set) {
if (bpp == 1) {
dp2[bits] = fg_color>>24;
} else if (bpp == 2) {
((uint16_t*)dp2)[bits] = fg_color;
} else if (bpp == 4) {
((uint32_t*)dp2)[bits] = fg_color;
}
// TODO mask
//dp2[bits] = (fg_color & mask) | (dp2[bits] & ~mask);
}
}
break;
}
case JAM2:
{
for (bits = 0; bits < max; bits++) {
char bit_set = (byte & 0x80);
byte <<= 1;
if (inversion) bit_set = !bit_set;
uint32_t color = bit_set ? fg_color : bg_color;
//if (bit_set) printf("#");
//else printf(".");
if (bpp == 1) {
dp2[bits] = color>>24;
} else if (bpp == 2) {
((uint16_t*)dp2)[bits] = color;
} else if (bpp == 4) {
((uint32_t*)dp2)[bits] = color;
}
// NYI
// dp2[bits] = (color & mask) | (dp2[bits] & ~mask);
}
break;
}
case COMPLEMENT:
{
for (bits = 0; bits < max; bits++) {
int bit_set = (byte & 0x80);
byte <<= 1;
if (bit_set) {
if (bpp == 1) {
dp2[bits] ^= 0xff;
} else if (bpp == 2) {
((uint16_t*)dp2)[bits] ^= 0xffff;
} else if (bpp == 4) {
((uint32_t*)dp2)[bits] ^= 0xffffffff;
}
}
// TODO mask
}
break;
switch(color_format) {
case MNTVA_COLOR_8BIT:
memset(dp, u8_fg, h * pitch);
break;
case MNTVA_COLOR_16BIT565:
case MNTVA_COLOR_32BIT:
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; y++) {
SET_FG_PIXEL;
x++;
}
dp += pitch;
}
}
loop_y++;
break;
default:
// Unknown/unhandled color format.
break;
}
}
extern uint32_t framebuffer, framebuffer_pan_offset;
void acc_flip_to_fb(uint32_t src, uint32_t dest, uint16_t w, uint16_t h, uint16_t pitch_, uint32_t color_format)
{
// This function assumes a flip of a surface with the same dimensions as the frame buffer.
if (!w || !h || !src || !dest)
return;
uint16_t pitch = pitch_;
uint8_t* sp = (uint8_t*)((uint32_t)src);
uint8_t* dp = (uint8_t *)((uint32_t)dest);
//uint8_t* dp = (uint8_t*)((uint32_t)(framebuffer + framebuffer_pan_offset + 0x10000));
if (pitch == 0) {
switch (color_format) {
case MNTVA_COLOR_8BIT: pitch = w; break;
case MNTVA_COLOR_16BIT565: pitch = w * 2; break;
case MNTVA_COLOR_32BIT: pitch = w * 4; break;
default: return; break;
}
}
/*for (int i = 0; i < h; i++) {
memcpy(dp, sp, pitch);
sp += pitch;
dp += pitch;
}*/
memcpy (dp, sp, h * pitch);
//printf("Flipping %dx%d pixels, %d bytes (%d).\n", w, h, h * pitch, pitch);
}
......@@ -23,24 +23,17 @@ typedef struct Vec2 {
void set_fb(uint32_t* fb_, uint32_t pitch);
void update_hw_sprite(uint8_t *data, uint32_t *colors, uint16_t w, uint16_t h);
void update_hw_sprite_clut(uint8_t *data_, uint8_t *colors, uint16_t w, uint16_t h, uint8_t keycolor);
void update_hw_sprite_pos(int16_t x, int16_t y);
void clip_hw_sprite(int16_t offset_x, int16_t offset_y);
void clear_hw_sprite();
void horizline(uint16_t x1, uint16_t x2, uint16_t y, uint32_t color);
void fill_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint32_t rect_rgb, uint32_t color_format, uint8_t mask);
void fill_rect_solid(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint32_t rect_rgb, uint32_t color_format);
void fill_rect8(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint8_t rect_rgb);
void fill_rect16(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_rgb);
void fill_rect32(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint32_t rect_rgb);
void copy_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint16_t rect_sx, uint16_t rect_sy, uint32_t color_format, uint32_t* sp_src, uint32_t src_pitch, uint8_t mask);
void copy_rect_nomask(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint16_t rect_sx, uint16_t rect_sy, uint32_t color_format, uint32_t* sp_src, uint32_t src_pitch, uint8_t draw_mode);
void copy_rect8(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_sx, uint16_t rect_sy);
void copy_rect16(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_sx, uint16_t rect_sy);
void copy_rect32(uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2, uint16_t rect_sx, uint16_t rect_sy);
void fill_template(uint32_t bpp, uint16_t rect_x1, uint16_t rect_y1, uint16_t rect_x2, uint16_t rect_y2,
uint8_t draw_mode, uint8_t mask, uint32_t fg_color, uint32_t bg_color, uint16_t x_offset, uint16_t y_offset, uint8_t* tmpl_data, uint16_t templ_pitch, uint16_t loop_rows);
void template_fill_rect(uint32_t color_format, uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h,
uint8_t draw_mode, uint8_t mask, uint32_t fg_color, uint32_t bg_color,
uint16_t x_offset, uint16_t y_offset,
......@@ -57,6 +50,9 @@ void p2c_rect(int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t
void p2d_rect(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, uint32_t color_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src, uint32_t color_format);
void invert_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uint8_t mask, uint32_t color_format);
void acc_clear_buffer(uint32_t addr, uint16_t w, uint16_t h, uint16_t pitch_, uint32_t fg_color, uint32_t color_format);
void acc_flip_to_fb(uint32_t src, uint32_t dest, uint16_t w, uint16_t h, uint16_t pitch_, uint32_t color_format);
#define MNTVA_COLOR_8BIT 0
#define MNTVA_COLOR_16BIT565 1
#define MNTVA_COLOR_32BIT 2
......@@ -500,6 +496,10 @@ struct GFXData {
uint16_t pitch[4];
uint8_t u8_user[8];
uint8_t op, mask, minterm, u8offset;
uint8_t clut1[768];
uint8_t clut2[768];
uint8_t clut3[768];
uint8_t clut4[768];
};
enum gfx_dma_op {
......@@ -517,9 +517,18 @@ enum gfx_dma_op {
OP_SPRITE_XY,
OP_SPRITE_COLOR,
OP_SPRITE_BITMAP,
OP_SPRITE_CLUT_BITMAP,
OP_NUM,
};
enum gfx_acc_op {
ACC_OP_NONE,
ACC_OP_BUFFER_FLIP,
ACC_OP_BUFFER_CLEAR,
ACC_OP_BLIT_RECT,
ACC_OP_NUM,
};
enum gfxdata_offsets {
GFXDATA_DST,
GFXDATA_SRC,
......
......@@ -59,6 +59,7 @@ typedef u8 uint8_t;
#define I2C_PAUSE 10
#define Z3_SCRATCH_ADDR 0x33F0000
#define ADDR_ADJ 0x1F0000
// I2C controller instance
XIicPs Iic;
......@@ -195,8 +196,8 @@ void hdmi_ctrl_init() {
}
XAxiVdma vdma;
static u32* framebuffer = 0;
static u32 framebuffer_pan_offset = 0;
u32* framebuffer = 0;
u32 framebuffer_pan_offset = 0;
static u32 blitter_dst_offset = 0;
static u32 blitter_src_offset = 0;
static u32 vmode_hsize = 800, vmode_vsize = 600, vmode_hdiv = 1, vmode_vdiv = 2;
......@@ -610,6 +611,8 @@ void video_system_init_2(struct zz_video_mode *mode, int hdiv, int vdiv) {
#define REVISION_MAJOR 1
#define REVISION_MINOR 7
int scalemode = 0;
void video_mode_init(int mode, int scalemode, int colormode) {
int hdiv = 1, vdiv = 1;
......@@ -643,22 +646,21 @@ void video_mode_init(int mode, int scalemode, int colormode) {
vmode_hdiv = hdiv;
}
int16_t sprite_x = 0, sprite_x_adj = 0;
int16_t sprite_y = 0, sprite_y_adj = 0;
int16_t sprite_x = 0, sprite_x_adj = 0, sprite_x_base = 0;
int16_t sprite_y = 0, sprite_y_adj = 0, sprite_y_base = 0;
uint16_t sprite_enabled = 0;
uint32_t sprite_buf[32 * 48];
uint8_t sprite_clipped = 0;
int16_t sprite_clip_x = 0, sprite_clip_y = 0;
int8_t sprite_x_offset = 0;
int8_t sprite_y_offset = 0;
int16_t sprite_x_offset = 0;
int16_t sprite_y_offset = 0;
uint8_t sprite_width = 16;
uint8_t sprite_height = 16;
uint32_t sprite_colors[4] = { 0x00ff00ff, 0x00000000, 0x00000000, 0x00000000 };
uint8_t sprite_template[16*16] = {
0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,3,3,1,1,0,0,0,0,0,0,0,0,0,
......@@ -704,6 +706,38 @@ void sprite_reset() {
}
}
void update_hw_sprite_pos(int16_t x, int16_t y) {
sprite_x = x + sprite_x_offset + 3;
// horizontally doubled mode
if (scalemode & 1) sprite_x *=2;
sprite_x_adj = sprite_x;
sprite_y = y + sprite_y_offset + 1;
// vertically doubled mode
if (scalemode & 2) sprite_y *= 2;
sprite_y_adj = sprite_y;
if (sprite_x < 0 || sprite_y < 0) {
if (sprite_clip_x != sprite_x || sprite_clip_y != sprite_y) {
clip_hw_sprite((sprite_x < 0) ? sprite_x : 0, (sprite_y < 0) ? sprite_y : 0);
}
sprite_clipped = 1;
if (sprite_x < 0) {
sprite_x_adj = 0;
sprite_clip_x = sprite_x;
}
if (sprite_y < 0) {
sprite_y_adj = 0;
sprite_clip_y = sprite_y;
}
}
else if (sprite_clipped && sprite_x >= 0 && sprite_y >= 0) {
clip_hw_sprite(0, 0);
sprite_clipped = 0;
}
video_formatter_write((sprite_y_adj << 16) | sprite_x_adj, MNTVF_OP_SPRITE_XY);
}
// this mode can be changed by amiga software to select a different resolution / framerate for
// native video capture
//static int videocap_video_mode = ZZVMODE_720x576;
......@@ -1010,7 +1044,6 @@ int main() {
int cache_counter = 0;
int videocap_enabled_old = 1;
int scalemode = 0;
int colormode = 0;
uint32_t framebuffer_pan_offset_old = framebuffer_pan_offset;
video_mode = 0x2200;
......@@ -1215,6 +1248,7 @@ int main() {
sprite_height = rect_y2;
update_hw_sprite(bmp_data, sprite_colors, sprite_width, sprite_height);
update_hw_sprite_pos(sprite_x, sprite_y);
break;
}
case REG_ZZ_SPRITE_COLORS: {
......@@ -1281,6 +1315,41 @@ int main() {
#define SWAP16(a) a = __builtin_bswap16(a);
#define SWAP32(a) a = __builtin_bswap32(a);
// Generic graphics acceleration
case REG_ZZ_ACC_OP: {
struct GFXData *data = (struct GFXData*)((u32)Z3_SCRATCH_ADDR);
switch (zdata) {
case ACC_OP_BUFFER_CLEAR: {
SWAP16(data->x[0]);
SWAP16(data->y[0]);
SWAP16(data->pitch[0]);
SWAP32(data->offset[0]);
data->offset[0] += ADDR_ADJ;
//printf("clearbuf: %.8X, %dx%d, %d size: %d\n", data->offset[0], data->x[0], data->y[0], data->pitch[0], sizeof(struct GFXData));
acc_clear_buffer(data->offset[0], data->x[0], data->y[0], data->pitch[0], data->rgb[0], data->u8_user[GFXDATA_U8_COLORMODE]);
break;
}
case ACC_OP_BUFFER_FLIP:
SWAP16(data->x[0]);
SWAP16(data->y[0]);
SWAP16(data->pitch[0]);
SWAP32(data->offset[0]);
SWAP32(data->offset[1]);
data->offset[0] += ADDR_ADJ;
data->offset[1] += ADDR_ADJ;
//printf("flipbuf: %.8X to %.8X %dx%d, %d\n", data->offset[0], data->offset[1], data->x[0], data->y[0], data->pitch[0]);
acc_flip_to_fb(data->offset[0], data->offset[1], data->x[0], data->y[0], data->pitch[0], data->u8_user[GFXDATA_U8_COLORMODE]);
break;
default:
break;
}
break;
}
// DMA RTG rendering
case REG_ZZ_BITTER_DMA_OP: {
struct GFXData *data = (struct GFXData*)((u32)Z3_SCRATCH_ADDR);
......@@ -1461,53 +1530,41 @@ int main() {
SWAP16(data->x[0]);
SWAP16(data->y[0]);
sprite_x = (int16_t)data->x[0] + sprite_x_offset + 3;
// horizontally doubled mode
if (scalemode & 1) sprite_x *=2;
sprite_x_adj = sprite_x;
sprite_y = (int16_t)data->y[0] + sprite_y_offset + 1;
// vertically doubled mode
if (scalemode & 2) sprite_y *= 2;
sprite_y_adj = sprite_y;
sprite_x_base = (int16_t)data->x[0];
sprite_y_base = (int16_t)data->y[0];
if (sprite_x < 0 || sprite_y < 0) {
if (sprite_clip_x != sprite_x || sprite_clip_y != sprite_y) {
clip_hw_sprite((sprite_x < 0) ? sprite_x : 0, (sprite_y < 0) ? sprite_y : 0);
}
sprite_clipped = 1;