Sync drawing.cpp from Master branch

This commit is contained in:
Dimitris Panokostas 2017-01-23 15:45:57 +01:00
parent 0246221a8b
commit 1289917651

View file

@ -114,7 +114,7 @@ static union pixdata_u {
uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / sizeof(uae_u32)];
} pixdata;
uae_u16 spixels[MAX_SPR_PIXELS];
uae_u16 spixels[2 * MAX_SPR_PIXELS];
/* Eight bits for every pixel. */
union sps_union spixstate;
@ -124,7 +124,7 @@ static uae_u16 ham_linebuf[MAX_PIXELS_PER_LINE * 2];
static uae_u8 *xlinebuffer;
static int *native2amiga_line_map;
static uae_u8 *row_map[MAX_VIDHEIGHT + 1];
static uae_u8 **row_map;
static uae_u8 row_tmp[MAX_PIXELS_PER_LINE * 32 / 8];
/* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */
@ -173,14 +173,21 @@ int idletime_frames = 0;
unsigned long idletime_time = 0;
int idletime_percent = 0;
#define IDLETIME_FRAMES 20
unsigned long time_per_frame = 20000; // Default for PAL (50 Hz): 20000 microsecs
long time_per_frame = 20000; // Default for PAL (50 Hz): 20000 microsecs
// Temporary define
#define OFFSET_FREE_CPU_CYCLES 1500
#define STEP_CYCLES 250
void adjust_idletime(unsigned long ms_waited)
void adjust_idletime(long ms_waited)
{
if (ms_waited == -1)
{
// Frame miss...
idletime_percent = 0;
ms_waited = 0;
}
idletime_frames++;
idletime_time += ms_waited;
if (idletime_frames >= IDLETIME_FRAMES)
@ -497,7 +504,8 @@ STATIC_INLINE int DECODE_HAM8_1(int col, int pv)
__asm__(
"ubfx %[pv], %[pv], #3, #5 \n\t"
"bfi %[col], %[pv], #0, #5 \n\t"
: [col] "+r" (col) , [pv] "+r" (pv) );
: [col] "+r" (col),
[pv] "+r" (pv));
return col;
}
STATIC_INLINE int DECODE_HAM8_2(int col, int pv)
@ -505,7 +513,8 @@ STATIC_INLINE int DECODE_HAM8_2(int col, int pv)
__asm__(
"ubfx %[pv], %[pv], #3, #5 \n\t"
"bfi %[col], %[pv], #11, #5 \n\t"
: [col] "+r" (col) , [pv] "+r" (pv) );
: [col] "+r" (col),
[pv] "+r" (pv));
return col;
}
STATIC_INLINE int DECODE_HAM8_3(int col, int pv)
@ -513,7 +522,8 @@ STATIC_INLINE int DECODE_HAM8_3(int col, int pv)
__asm__(
"ubfx %[pv], %[pv], #2, #6 \n\t"
"bfi %[col], %[pv], #5, #6 \n\t"
: [col] "+r" (col) , [pv] "+r" (pv) );
: [col] "+r" (col),
[pv] "+r" (pv));
return col;
}
@ -522,7 +532,8 @@ STATIC_INLINE int DECODE_HAM6_1(int col, int pv)
__asm__(
"lsl %[pv], %[pv], #1 \n\t"
"bfi %[col], %[pv], #0, #5 \n\t"
: [col] "+r" (col) , [pv] "+r" (pv) );
: [col] "+r" (col),
[pv] "+r" (pv));
return (col);
}
STATIC_INLINE int DECODE_HAM6_2(int col, int pv)
@ -530,7 +541,8 @@ STATIC_INLINE int DECODE_HAM6_2(int col, int pv)
__asm__(
"lsl %[pv], %[pv], #1 \n\t"
"bfi %[col], %[pv], #11, #5 \n\t"
: [col] "+r" (col) , [pv] "+r" (pv) );
: [col] "+r" (col),
[pv] "+r" (pv));
return (col);
}
STATIC_INLINE int DECODE_HAM6_3(int col, int pv)
@ -538,7 +550,8 @@ STATIC_INLINE int DECODE_HAM6_3(int col, int pv)
__asm__(
"lsl %[pv], %[pv], #2 \n\t"
"bfi %[col], %[pv], #5, #6 \n\t"
: [col] "+r" (col) , [pv] "+r" (pv) );
: [col] "+r" (col),
[pv] "+r" (pv));
return (col);
}
#endif
@ -566,7 +579,8 @@ static void init_ham_decoding (void)
else
ham_lastcolor = colors_for_drawing.acolors[pv];
}
} else if (aga_mode) {
}
else if (aga_mode) {
if (bplplanecnt >= 7) { /* AGA mode HAM8 */
while (unpainted_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor;
@ -584,7 +598,8 @@ static void init_ham_decoding (void)
#endif
}
}
} else { /* AGA mode HAM6 */
}
else { /* AGA mode HAM6 */
while (unpainted_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor;
switch (pv & 0x30)
@ -602,7 +617,8 @@ static void init_ham_decoding (void)
}
}
}
} else {
}
else {
/* OCS/ECS mode HAM6 */
while (unpainted_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel++];
@ -637,7 +653,8 @@ static void decode_ham (int pix, int stoppos)
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
} else if (aga_mode) {
}
else if (aga_mode) {
if (bplplanecnt >= 7) { /* AGA mode HAM8 */
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor;
@ -656,7 +673,8 @@ static void decode_ham (int pix, int stoppos)
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
} else { /* AGA mode HAM6 */
}
else { /* AGA mode HAM6 */
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor;
switch (pv & 0x30)
@ -675,7 +693,8 @@ static void decode_ham (int pix, int stoppos)
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
}
} else {
}
else {
/* OCS/ECS mode HAM6 */
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel];
@ -853,7 +872,8 @@ static void draw_sprites_normal_sp_lo_at(struct sprite_entry *e)
offs = sprite_bit[v];
if (stbuf[pos] & offs) {
col = sprite_col_at[v] + 16;
} else {
}
else {
col = sprite_col_nat[v] + 16;
}
pixdata.apixels[window_pos] = col;
@ -885,7 +905,8 @@ static void draw_sprites_normal_ham_lo_at(struct sprite_entry *e)
offs = sprite_bit[v];
if (stbuf[pos] & offs) {
col = sprite_col_at[v] + 16;
} else {
}
else {
col = sprite_col_nat[v] + 16;
}
ham_linebuf[window_pos] = colors_for_drawing.acolors[col];
@ -920,7 +941,8 @@ static void draw_sprites_normal_dp_lo_at(struct sprite_entry *e)
offs = sprite_bit[v];
if (stbuf[pos] & offs) {
col = sprite_col_at[v] + 16 + 128;
} else {
}
else {
col = sprite_col_nat[v] + 16 + 128;
}
pixdata.apixels[window_pos] = col;
@ -1033,7 +1055,8 @@ static void draw_sprites_normal_sp_hi_at(struct sprite_entry *e)
offs = sprite_bit[v];
if (stbuf[pos] & offs) {
col = sprite_col_at[v] + 16;
} else {
}
else {
col = sprite_col_nat[v] + 16;
}
pixdata.apixels_w[window_pos >> 1] = col | (col << 8);
@ -1066,7 +1089,8 @@ static void draw_sprites_normal_ham_hi_at(struct sprite_entry *e)
offs = sprite_bit[v];
if (stbuf[pos] & offs) {
col = sprite_col_at[v] + 16;
} else {
}
else {
col = sprite_col_nat[v] + 16;
}
col = col | (col << 8);
@ -1104,7 +1128,8 @@ static void draw_sprites_normal_dp_hi_at(struct sprite_entry *e)
offs = sprite_bit[v];
if (stbuf[pos] & offs) {
col = sprite_col_at[v] + 16 + 128;
} else {
}
else {
col = sprite_col_nat[v] + 16 + 128;
}
pixdata.apixels_w[window_pos >> 1] = col | (col << 8);
@ -1115,17 +1140,29 @@ static void draw_sprites_normal_dp_hi_at(struct sprite_entry *e)
typedef void(*draw_sprites_func)(struct sprite_entry *e);
static draw_sprites_func draw_sprites_dp_hi[2] = {
draw_sprites_normal_dp_hi_nat, draw_sprites_normal_dp_hi_at };
draw_sprites_normal_dp_hi_nat,
draw_sprites_normal_dp_hi_at
};
static draw_sprites_func draw_sprites_sp_hi[2] = {
draw_sprites_normal_sp_hi_nat, draw_sprites_normal_sp_hi_at };
draw_sprites_normal_sp_hi_nat,
draw_sprites_normal_sp_hi_at
};
static draw_sprites_func draw_sprites_ham_hi[2] = {
draw_sprites_normal_ham_hi_nat, draw_sprites_normal_ham_hi_at };
draw_sprites_normal_ham_hi_nat,
draw_sprites_normal_ham_hi_at
};
static draw_sprites_func draw_sprites_dp_lo[2] = {
draw_sprites_normal_dp_lo_nat, draw_sprites_normal_dp_lo_at };
draw_sprites_normal_dp_lo_nat,
draw_sprites_normal_dp_lo_at
};
static draw_sprites_func draw_sprites_sp_lo[2] = {
draw_sprites_normal_sp_lo_nat, draw_sprites_normal_sp_lo_at };
draw_sprites_normal_sp_lo_nat,
draw_sprites_normal_sp_lo_at
};
static draw_sprites_func draw_sprites_ham_lo[2] = {
draw_sprites_normal_ham_lo_nat, draw_sprites_normal_ham_lo_at };
draw_sprites_normal_ham_lo_nat,
draw_sprites_normal_ham_lo_at
};
static draw_sprites_func *draw_sprites_punt = draw_sprites_sp_lo;
@ -1163,7 +1200,8 @@ STATIC_INLINE void draw_sprites_aga_ham (struct sprite_entry *e, const int doubl
offs = sprite_bit[v];
if (has_attach && (stbuf[pos] & offs)) {
col = sprite_col_at[v] + sbasecol[1];
} else {
}
else {
if (offs & 0x55)
col = sprite_col_nat[v] + sbasecol[0];
else
@ -1217,7 +1255,8 @@ STATIC_INLINE void draw_sprites_aga_dp (struct sprite_entry *e, const int doubli
offs = sprite_bit[v];
if (has_attach && (stbuf[pos] & offs)) {
col = sprite_col_at[v] + sbasecol[1];
} else {
}
else {
if (offs & 0x55)
col = sprite_col_nat[v] + sbasecol[0];
else
@ -1265,7 +1304,8 @@ STATIC_INLINE void draw_sprites_aga_sp (struct sprite_entry *e, const int doubli
offs = sprite_bit[v];
if (has_attach && (stbuf[pos] & offs)) {
col = sprite_col_at[v] + sbasecol[1];
} else {
}
else {
if (offs & 0x55)
col = sprite_col_nat[v] + sbasecol[0];
else
@ -1309,25 +1349,43 @@ static void draw_sprites_aga_dp_shi_at(struct sprite_entry *e) { draw_sprites_
static void draw_sprites_aga_ham_shi_at(struct sprite_entry *e) { draw_sprites_aga_ham(e, 1, 0, 1); }
static draw_sprites_func draw_sprites_aga_sp_lo[2] = {
draw_sprites_aga_sp_lo_nat, draw_sprites_aga_sp_lo_at };
draw_sprites_aga_sp_lo_nat,
draw_sprites_aga_sp_lo_at
};
static draw_sprites_func draw_sprites_aga_sp_hi[2] = {
draw_sprites_aga_sp_hi_nat, draw_sprites_aga_sp_hi_at };
draw_sprites_aga_sp_hi_nat,
draw_sprites_aga_sp_hi_at
};
static draw_sprites_func draw_sprites_aga_sp_shi[2] = {
draw_sprites_aga_sp_shi_nat, draw_sprites_aga_sp_shi_at };
draw_sprites_aga_sp_shi_nat,
draw_sprites_aga_sp_shi_at
};
static draw_sprites_func draw_sprites_aga_dp_lo[2] = {
draw_sprites_aga_dp_lo_nat, draw_sprites_aga_dp_lo_at };
draw_sprites_aga_dp_lo_nat,
draw_sprites_aga_dp_lo_at
};
static draw_sprites_func draw_sprites_aga_dp_hi[2] = {
draw_sprites_aga_dp_hi_nat, draw_sprites_aga_dp_hi_at };
draw_sprites_aga_dp_hi_nat,
draw_sprites_aga_dp_hi_at
};
static draw_sprites_func draw_sprites_aga_dp_shi[2] = {
draw_sprites_aga_dp_shi_nat, draw_sprites_aga_dp_shi_at };
draw_sprites_aga_dp_shi_nat,
draw_sprites_aga_dp_shi_at
};
static draw_sprites_func draw_sprites_aga_ham_lo[2] = {
draw_sprites_aga_ham_lo_nat, draw_sprites_aga_ham_lo_at };
draw_sprites_aga_ham_lo_nat,
draw_sprites_aga_ham_lo_at
};
static draw_sprites_func draw_sprites_aga_ham_hi[2] = {
draw_sprites_aga_ham_hi_nat, draw_sprites_aga_ham_hi_at };
draw_sprites_aga_ham_hi_nat,
draw_sprites_aga_ham_hi_at
};
static draw_sprites_func draw_sprites_aga_ham_shi[2] = {
draw_sprites_aga_ham_shi_nat, draw_sprites_aga_ham_shi_at };
draw_sprites_aga_ham_shi_nat,
draw_sprites_aga_ham_shi_at
};
static __inline__ void decide_draw_sprites(void)
{
@ -1548,8 +1606,14 @@ static void pfield_doline_n7 (uae_u32 *pixels, int wordcount, int lineno)
typedef void(*pfield_doline_func)(uae_u32 *, int, int);
static pfield_doline_func pfield_doline_n[9] = {
pfield_doline_n0, ARM_doline_n1, NEON_doline_n2, NEON_doline_n3,
NEON_doline_n4, pfield_doline_n5, NEON_doline_n6, pfield_doline_n7,
pfield_doline_n0,
ARM_doline_n1,
NEON_doline_n2,
NEON_doline_n3,
NEON_doline_n4,
pfield_doline_n5,
NEON_doline_n6,
pfield_doline_n7,
NEON_doline_n8
};
@ -1662,28 +1726,27 @@ void init_row_map (void)
{
static uae_u8 *oldbufmem;
static int oldheight, oldpitch;
static bool oldgenlock;
int i, j;
// if (gfxvidinfo.outheight > MAX_VIDHEIGHT)
// {
// write_log(_T("Resolution too hight, aborting\n"));
// abort();
// }
if (gfxvidinfo.outheight > max_uae_height) {
write_log(_T("Resolution too high, aborting\n"));
abort();
}
if (!row_map) {
row_map = xmalloc(uae_u8*, max_uae_height + 1);
}
if (oldbufmem && oldbufmem == gfxvidinfo.bufmem &&
oldheight == gfxvidinfo.outheight &&
oldpitch == gfxvidinfo.rowbytes)
return;
j = oldheight == 0 ? MAX_VIDHEIGHT : oldheight;
for (i = gfxvidinfo.outheight; i < MAX_VIDHEIGHT + 1 && i < j + 1; i++)
j = oldheight == 0 ? max_uae_height : oldheight;
for (i = gfxvidinfo.outheight; i < max_uae_height + 1 && i < j + 1; i++)
row_map[i] = row_tmp;
for (i = 0, j = 0; i < gfxvidinfo.outheight; i++, j += gfxvidinfo.rowbytes)
row_map[i] = gfxvidinfo.bufmem + j;
oldbufmem = gfxvidinfo.bufmem;
oldheight = gfxvidinfo.outheight;
oldpitch = gfxvidinfo.rowbytes;
}
static void init_aspect_maps(void)
@ -1736,7 +1799,8 @@ static void pfield_expand_dp_bplcon (void)
sbasecol[0] = ((dp_for_drawing->bplcon4 >> 4) & 15) << 4;
sbasecol[1] = ((dp_for_drawing->bplcon4 >> 0) & 15) << 4;
bplxor = dp_for_drawing->bplcon4 >> 8;
} else
}
else
bplehb = (dp_for_drawing->bplcon0 & 0xFC00) == 0x6000 || (dp_for_drawing->bplcon0 & 0xFC00) == 0x7000;
if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && (dp_for_drawing->bplcon2 & 0x0200))
bplehb = 0;
@ -1759,7 +1823,8 @@ static bool isham (uae_u16 bplcon0)
// AGA only has 6 or 8 plane HAM
if (p == 6 || p == 8)
return 1;
} else {
}
else {
// OCS/ECS also supports 5 plane HAM
if (GET_RES_DENISE(bplcon0) > 0)
return 0;
@ -1805,15 +1870,18 @@ static void adjust_drawing_colors (int ctable, int need_full)
if (need_full) {
color_reg_cpy(&colors_for_drawing, curr_color_tables + ctable);
color_match_type = color_match_full;
} else {
memcpy (colors_for_drawing.acolors, curr_color_tables[ctable].acolors,
}
else {
memcpy(colors_for_drawing.acolors,
curr_color_tables[ctable].acolors,
sizeof colors_for_drawing.acolors);
colors_for_drawing.borderblank = curr_color_tables[ctable].borderblank;
colors_for_drawing.bordersprite = curr_color_tables[ctable].bordersprite;
color_match_type = color_match_acolors;
}
drawing_color_matches = ctable;
} else if (need_full && color_match_type != color_match_full) {
}
else if (need_full && color_match_type != color_match_full) {
color_reg_cpy(&colors_for_drawing, &curr_color_tables[ctable]);
color_match_type = color_match_full;
}
@ -1861,11 +1929,13 @@ STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_fun
unsigned int value = curr_color_changes[i].value;
if (regno >= 0x1000) {
pfield_expand_dp_bplconx(regno, value);
} else if (regno >= 0) {
}
else if (regno >= 0) {
if (regno == 0 && (value & COLOR_CHANGE_BRDBLANK)) {
colors_for_drawing.borderblank = (value & 1) != 0;
colors_for_drawing.bordersprite = (value & 3) == 2;
} else {
}
else {
color_reg_set(&colors_for_drawing, regno, value);
colors_for_drawing.acolors[regno] = getxcolor(value);
}
@ -1902,7 +1972,8 @@ static void pfield_draw_line (int lineno, int gfx_ypos)
/* The easy case: need to do HAM decoding only once for the
* full line. */
decode_ham(visible_left_border, visible_right_border);
} else /* Argh. */ {
}
else /* Argh. */ {
do_color_changes(dummy_worker, decode_ham);
// reset colors to state before above do_color_changes()
adjust_drawing_colors(dp_for_drawing->ctable, (dp_for_drawing->ham_seen || bplehb) ? -1 : 0);
@ -1921,7 +1992,8 @@ static void pfield_draw_line (int lineno, int gfx_ypos)
}
do_color_changes(pfield_do_fill_line, pfield_do_linetoscr);
} else { // border > 0: top or bottom border
}
else { // border > 0: top or bottom border
bool dosprites = false;
adjust_drawing_colors(dp_for_drawing->ctable, 0);
@ -1955,7 +2027,8 @@ static void pfield_draw_line (int lineno, int gfx_ypos)
bplxor = 0;
do_color_changes(pfield_do_fill_line, pfield_do_linetoscr);
bplxor = oxor;
} else {
}
else {
playfield_start = visible_right_border;
playfield_end = visible_right_border;
@ -2095,8 +2168,6 @@ void vsync_handle_redraw (void)
if (framecnt == 0)
init_drawing_frame();
gui_flicker_led (-1, 0, 0);
}
void hsync_record_line_state(int lineno)