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

More things related to ScummVM work

parent a5d74677
......@@ -1002,3 +1002,19 @@ void acc_flip_to_fb(uint32_t src, uint32_t dest, uint16_t w, uint16_t h, uint16_
memcpy (dp, sp, h * pitch);
//printf("Flipping %dx%d pixels, %d bytes (%d).\n", w, h, h * pitch, pitch);
}
void acc_blit_rect(uint32_t src, uint32_t dest, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t src_pitch, uint16_t dest_pitch)
{
if (!w || !h || !src || !dest)
return;
uint8_t* sp = (uint8_t*)((uint32_t)src);
uint8_t* dp = (uint8_t *)((uint32_t)dest);
dp += (x + (y * dest_pitch));
for (int i = 0; i < h; i++) {
memcpy(dp, sp, src_pitch);
dp += dest_pitch;
sp += src_pitch;
}
}
......@@ -52,12 +52,22 @@ void invert_rect(uint16_t rect_x1, uint16_t rect_y1, uint16_t w, uint16_t h, uin
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);
void acc_blit_rect(uint32_t src, uint32_t dest, uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t src_pitch, uint16_t dest_pitch);
#define MNTVA_COLOR_8BIT 0
/*#define MNTVA_COLOR_8BIT 0
#define MNTVA_COLOR_16BIT565 1
#define MNTVA_COLOR_32BIT 2
#define MNTVA_COLOR_1BIT 3
#define MNTVA_COLOR_15BIT 4
#define MNTVA_COLOR_15BIT 4*/
enum color_formats {
MNTVA_COLOR_8BIT,
MNTVA_COLOR_16BIT565,
MNTVA_COLOR_32BIT,
MNTVA_COLOR_1BIT,
MNTVA_COLOR_15BIT,
MNTVA_COLOR_NUM,
};
// see http://amigadev.elowar.com/read/ADCD_2.1/Libraries_Manual_guide/node0351.html
#define JAM1 0 /* jam 1 color into raster */
......@@ -526,6 +536,8 @@ enum gfx_acc_op {
ACC_OP_BUFFER_FLIP,
ACC_OP_BUFFER_CLEAR,
ACC_OP_BLIT_RECT,
ACC_OP_ALLOC_SURFACE,
ACC_OP_FREE_SURFACE,
ACC_OP_NUM,
};
......
......@@ -1023,6 +1023,7 @@ int main() {
u32 zstate_raw;
int interlace_old = 0;
int videocap_ntsc_old = 0;
u32 *crab;
handle_amiga_reset();
......@@ -1062,6 +1063,8 @@ int main() {
uint8_t debug_dma_op[OP_NUM];
memset(debug_dma_op, 0x00, OP_NUM);
crab = malloc(0x3410000);
crab[0x3400000] = 'a';
while (1) {
u32 zstate = mntzorro_read(MNTZ_BASE_ADDR, MNTZORRO_REG3);
......@@ -1318,6 +1321,8 @@ int main() {
// Generic graphics acceleration
case REG_ZZ_ACC_OP: {
struct GFXData *data = (struct GFXData*)((u32)Z3_SCRATCH_ADDR);
int8_t cf_bpp[MNTVA_COLOR_NUM] = { 1, 2, 4, -8, 2, };
switch (zdata) {
case ACC_OP_BUFFER_CLEAR: {
SWAP16(data->x[0]);
......@@ -1344,6 +1349,41 @@ int main() {
//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;
case ACC_OP_BLIT_RECT:
SWAP16(data->x[0]); SWAP16(data->y[0]);
SWAP16(data->x[1]); SWAP16(data->y[1]);
SWAP16(data->pitch[0]);
SWAP16(data->pitch[1]);
SWAP32(data->offset[0]);
SWAP32(data->offset[1]);
data->offset[0] += ADDR_ADJ;
data->offset[1] += ADDR_ADJ;
acc_blit_rect(data->offset[0], data->offset[1], data->x[0], data->y[0], data->x[1], data->y[1], data->pitch[0], data->pitch[1]);
break;
case ACC_OP_ALLOC_SURFACE: {
SWAP16(data->x[0]); SWAP16(data->y[0]);
data->offset[0] = 0;
size_t sfc_size = ((data->x[0] * cf_bpp[data->u8_user[GFXDATA_U8_COLORMODE]]) * data->y[0]);
printf ("Allocating %dx%d surface, %d bytes per pixel.\n", data->x[0], data->y[0], data->u8_user[GFXDATA_U8_COLORMODE]);
uint8_t *p = malloc(sfc_size);
printf ("Surface allocated at offset %p, or %p on the Amiga side.\n", p, p - ADDR_ADJ);
data->offset[0] = (uint32_t)(p - ADDR_ADJ);
SWAP32(data->offset[0]);
break;
}
case ACC_OP_FREE_SURFACE: {
SWAP32(data->offset[0]);
data->offset[0] += ADDR_ADJ;
printf("Freeing surface at %.8X... maybe.\n", data->offset[0]);
free((void *)data->offset[0]);
data->offset[0] = 0;
break;
}
default:
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment