From df3bd366e2d2e239b087d89058a0fd95cf388705 Mon Sep 17 00:00:00 2001 From: Dimitris Panokostas Date: Fri, 16 Dec 2016 16:53:22 +0100 Subject: [PATCH] Fixed framerate problem with vsyc --- Amiberry/Amiberry/Amiberry-Debug.vgdbsettings | 4 +- src/drawing.cpp | 2485 +++++++++-------- src/include/drawing.h | 135 +- src/od-rasp/rasp_gfx.cpp | 372 ++- 4 files changed, 1530 insertions(+), 1466 deletions(-) diff --git a/Amiberry/Amiberry/Amiberry-Debug.vgdbsettings b/Amiberry/Amiberry/Amiberry-Debug.vgdbsettings index 6ec79c45..46519a15 100644 --- a/Amiberry/Amiberry/Amiberry-Debug.vgdbsettings +++ b/Amiberry/Amiberry/Amiberry-Debug.vgdbsettings @@ -10,9 +10,9 @@ None - 192.168.1.155 + 172.16.2.42 SSH - root + pi false diff --git a/src/drawing.cpp b/src/drawing.cpp index 0c73f340..2220dc58 100644 --- a/src/drawing.cpp +++ b/src/drawing.cpp @@ -49,11 +49,11 @@ extern int sprite_buffer_res; -static void lores_reset (void) +static void lores_reset(void) { - sprite_buffer_res = (aga_mode) ? RES_SUPERHIRES : RES_LORES; - if (sprite_buffer_res > currprefs.gfx_resolution) - sprite_buffer_res = currprefs.gfx_resolution; + sprite_buffer_res = (aga_mode) ? RES_SUPERHIRES : RES_LORES; + if (sprite_buffer_res > currprefs.gfx_resolution) + sprite_buffer_res = currprefs.gfx_resolution; } bool aga_mode; /* mirror of chipset_mask & CSMASK_AGA */ @@ -111,9 +111,9 @@ struct color_entry colors_for_drawing; than enough". The coordinates used for indexing into these arrays are almost, but not quite, Amiga coordinates (there's a constant offset). */ static union pixdata_u { - uae_u8 apixels[MAX_PIXELS_PER_LINE * 2]; - uae_u16 apixels_w[MAX_PIXELS_PER_LINE * 2 / sizeof (uae_u16)]; - uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / sizeof (uae_u32)]; + uae_u8 apixels[MAX_PIXELS_PER_LINE * 2]; + uae_u16 apixels_w[MAX_PIXELS_PER_LINE * 2 / sizeof(uae_u16)]; + uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / sizeof(uae_u32)]; } pixdata; uae_u16 spixels[MAX_SPR_PIXELS]; @@ -130,7 +130,7 @@ static uae_u8 *row_map[MAX_VIDHEIGHT + 1]; static uae_u8 row_tmp[MAX_PIXELS_PER_LINE * 32 / 8]; /* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */ -typedef void (*line_draw_func)(int, int); +typedef void(*line_draw_func)(int, int); #define LINE_UNDECIDED 1 #define LINE_DECIDED 2 @@ -175,7 +175,7 @@ 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 @@ -185,88 +185,88 @@ void adjust_idletime(long ms_waited) { if (ms_waited == -1) { - // Frame miss... + // Frame miss... idletime_percent = 0; ms_waited = 0; } - - idletime_frames++; - idletime_time += ms_waited; - if(idletime_frames >= IDLETIME_FRAMES) - { - unsigned long ms_for_frames = time_per_frame * idletime_frames * (1 + currprefs.gfx_framerate); - idletime_percent = idletime_time * 100 / ms_for_frames; - if(idletime_percent < 0) - idletime_percent = 0; - else if(idletime_percent > 100) - idletime_percent = 100; - idletime_time = 0; - idletime_frames = 0; - } - if(currprefs.m68k_speed < 0) { - if(ms_waited < (500 + OFFSET_FREE_CPU_CYCLES) && speedup_timelimit > -10000) - speedup_timelimit -= STEP_CYCLES; - else -if(ms_waited > (1400 + OFFSET_FREE_CPU_CYCLES) && speedup_timelimit < -1000) - speedup_timelimit += STEP_CYCLES; - } + idletime_frames++; + idletime_time += ms_waited; + if (idletime_frames >= IDLETIME_FRAMES) + { + unsigned long ms_for_frames = time_per_frame * idletime_frames * (1 + currprefs.gfx_framerate); + idletime_percent = idletime_time * 100 / ms_for_frames; + if (idletime_percent < 0) + idletime_percent = 0; + else if (idletime_percent > 100) + idletime_percent = 100; + idletime_time = 0; + idletime_frames = 0; + } + + if (currprefs.m68k_speed < 0) { + if (ms_waited < (500 + OFFSET_FREE_CPU_CYCLES) && speedup_timelimit > -10000) + speedup_timelimit -= STEP_CYCLES; + else + if (ms_waited > (1400 + OFFSET_FREE_CPU_CYCLES) && speedup_timelimit < -1000) + speedup_timelimit += STEP_CYCLES; + } } -void reset_decision_table (void) +void reset_decision_table(void) { linestate_first_undecided = 0; } -STATIC_INLINE void count_frame (void) +STATIC_INLINE void count_frame(void) { - framecnt++; - if(framecnt > currprefs.gfx_framerate) + framecnt++; + if (framecnt > currprefs.gfx_framerate) framecnt = 0; - if (inhibit_frame) - framecnt = 1; + if (inhibit_frame) + framecnt = 1; } -STATIC_INLINE int xshift (int x, int shift) +STATIC_INLINE int xshift(int x, int shift) { - if (shift < 0) - return x >> (-shift); - else - return x << shift; + if (shift < 0) + return x >> (-shift); + else + return x << shift; } -int coord_native_to_amiga_x (int x) +int coord_native_to_amiga_x(int x) { - if(gfxvidinfo.outwidth > 600) - { - x += (visible_left_border << 1); - return x + 2*DISPLAY_LEFT_SHIFT - 2*DIW_DDF_OFFSET; - } - else - { - x += visible_left_border; - x <<= (1 - lores_shift); - return x + 2*DISPLAY_LEFT_SHIFT - 2*DIW_DDF_OFFSET; - } + if (gfxvidinfo.outwidth > 600) + { + x += (visible_left_border << 1); + return x + 2*DISPLAY_LEFT_SHIFT - 2*DIW_DDF_OFFSET; + } + else + { + x += visible_left_border; + x <<= (1 - lores_shift); + return x + 2*DISPLAY_LEFT_SHIFT - 2*DIW_DDF_OFFSET; + } } -int coord_native_to_amiga_y (int y) +int coord_native_to_amiga_y(int y) { - return native2amiga_line_map[y]; + return native2amiga_line_map[y]; } -STATIC_INLINE int res_shift_from_window (int x) +STATIC_INLINE int res_shift_from_window(int x) { - if (res_shift >= 0) + if (res_shift >= 0) return x >> res_shift; - return x << -res_shift; + return x << -res_shift; } -STATIC_INLINE int res_shift_from_amiga (int x) +STATIC_INLINE int res_shift_from_amiga(int x) { - if (res_shift >= 0) + if (res_shift >= 0) return x >> res_shift; - return x << -res_shift; + return x << -res_shift; } static struct decision *dp_for_drawing; @@ -288,55 +288,55 @@ static int unpainted; #include "linetoscr.c" -static void pfield_do_linetoscr_0_640 (int start, int stop) +static void pfield_do_linetoscr_0_640(int start, int stop) { int local_res_shift = 1 - bplres; // stretch LORES, nothing for HIRES, shrink for SUPERHIRES start = start << 1; stop = stop << 1; if (local_res_shift == 0) - src_pixel = linetoscr_16 (src_pixel, start, stop); + src_pixel = linetoscr_16(src_pixel, start, stop); else if (local_res_shift == 1) - src_pixel = linetoscr_16_stretch1 (src_pixel, start, stop); + src_pixel = linetoscr_16_stretch1(src_pixel, start, stop); else //if (local_res_shift == -1) - src_pixel = linetoscr_16_shrink1 (src_pixel, start, stop); + src_pixel = linetoscr_16_shrink1(src_pixel, start, stop); } -static void pfield_do_linetoscr_0_640_AGA (int start, int stop) +static void pfield_do_linetoscr_0_640_AGA(int start, int stop) { int local_res_shift = 1 - bplres; // stretch LORES, nothing for HIRES, shrink for SUPERHIRES start = start << 1; stop = stop << 1; - if (local_res_shift == 0) - src_pixel = linetoscr_16_aga (src_pixel, start, stop); - else if (local_res_shift == 1) - src_pixel = linetoscr_16_stretch1_aga (src_pixel, start, stop); - else //if (local_res_shift == -1) - src_pixel = linetoscr_16_shrink1_aga (src_pixel, start, stop); + if (local_res_shift == 0) + src_pixel = linetoscr_16_aga(src_pixel, start, stop); + else if (local_res_shift == 1) + src_pixel = linetoscr_16_stretch1_aga(src_pixel, start, stop); + else //if (local_res_shift == -1) + src_pixel = linetoscr_16_shrink1_aga(src_pixel, start, stop); } -static void pfield_do_linetoscr_0 (int start, int stop) +static void pfield_do_linetoscr_0(int start, int stop) { if (res_shift == 0) - src_pixel = linetoscr_16 (src_pixel, start, stop); + src_pixel = linetoscr_16(src_pixel, start, stop); //else if (res_shift == 1) //can't happen, target is lores // src_pixel = linetoscr_16_stretch1 (src_pixel, start, stop); else //if (res_shift == -1) - src_pixel = linetoscr_16_shrink1 (src_pixel, start, stop); + src_pixel = linetoscr_16_shrink1(src_pixel, start, stop); } -static void pfield_do_linetoscr_0_AGA (int start, int stop) +static void pfield_do_linetoscr_0_AGA(int start, int stop) { - if (res_shift == 0) - src_pixel = linetoscr_16_aga (src_pixel, start, stop); - //else if (res_shift == 1) //can't happen, target is lores - // src_pixel = linetoscr_16_stretch1_aga (src_pixel, start, stop); - else //if (res_shift == -1) - src_pixel = linetoscr_16_shrink1_aga (src_pixel, start, stop); + if (res_shift == 0) + src_pixel = linetoscr_16_aga(src_pixel, start, stop); + //else if (res_shift == 1) //can't happen, target is lores + // src_pixel = linetoscr_16_stretch1_aga (src_pixel, start, stop); + else //if (res_shift == -1) + src_pixel = linetoscr_16_shrink1_aga(src_pixel, start, stop); } -STATIC_INLINE xcolnr getbgc (bool blank) +STATIC_INLINE xcolnr getbgc(bool blank) { return (blank || colors_for_drawing.borderblank) ? 0 : colors_for_drawing.acolors[0]; } @@ -346,8 +346,8 @@ static void pfield_do_fill_line_0_640(int start, int stop) register uae_u16 *b = &(((uae_u16 *)xlinebuffer)[start << 1]); register xcolnr col = getbgc(false); register int i; - register int max=(stop-start) << 1; - for (i = 0; i < max; i++,b++) + register int max = (stop - start) << 1; + for (i = 0; i < max; i++, b++) *b = col; } @@ -356,8 +356,8 @@ static void pfield_do_fill_line_0(int start, int stop) register uae_u16 *b = &(((uae_u16 *)xlinebuffer)[start]); register xcolnr col = getbgc(false); register int i; - register int max=(stop-start); - for (i = 0; i < max; i++,b++) + register int max = (stop - start); + for (i = 0; i < max; i++, b++) *b = col; } @@ -367,7 +367,7 @@ static line_draw_func pfield_do_fill_line = (line_draw_func)pfield_do_fill_line_ /* Initialize the variables necessary for drawing a line. * This involves setting up start/stop positions and display window * borders. */ -static void pfield_init_linetoscr (void) +static void pfield_init_linetoscr(void) { /* First, get data fetch start/stop in DIW coordinates. */ int ddf_left = dp_for_drawing->plfleft * 2 + DIW_DDF_OFFSET; @@ -375,8 +375,8 @@ static void pfield_init_linetoscr (void) int leftborderhidden; /* Compute datafetch start/stop in pixels; native display coordinates. */ - int native_ddf_left = coord_hw_to_window_x (ddf_left); - int native_ddf_right = coord_hw_to_window_x (ddf_right); + int native_ddf_left = coord_hw_to_window_x(ddf_left); + int native_ddf_right = coord_hw_to_window_x(ddf_right); int linetoscr_diw_start = dp_for_drawing->diwfirstword; int linetoscr_diw_end = dp_for_drawing->diwlastword; @@ -392,7 +392,7 @@ static void pfield_init_linetoscr (void) if (linetoscr_diw_end < linetoscr_diw_start) linetoscr_diw_end = linetoscr_diw_start; - res_shift = lores_shift - bplres; + res_shift = lores_shift - bplres; playfield_start = linetoscr_diw_start; playfield_end = linetoscr_diw_end; @@ -417,8 +417,8 @@ static void pfield_init_linetoscr (void) if (x > max) max = x; } - min = coord_hw_to_window_x (min >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift); - max = coord_hw_to_window_x (max >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift); + min = coord_hw_to_window_x(min >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift); + max = coord_hw_to_window_x(max >> sprite_buffer_res) + (DIW_DDF_OFFSET << lores_shift); if (min < playfield_start) playfield_start = min; @@ -431,124 +431,130 @@ static void pfield_init_linetoscr (void) } unpainted = visible_left_border < playfield_start ? 0 : visible_left_border - playfield_start; - ham_src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window (playfield_start - native_ddf_left); - unpainted = res_shift_from_window (unpainted); + ham_src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window(playfield_start - native_ddf_left); + unpainted = res_shift_from_window(unpainted); - if (sprite_first_x < sprite_last_x) { - uae_u8 *p = spritepixels + sprite_first_x; - int len = sprite_last_x - sprite_first_x + 1; - int i; - /* clear previous sprite data storage line */ - memset (p, 0, len); + if (sprite_first_x < sprite_last_x) { + uae_u8 *p = spritepixels + sprite_first_x; + int len = sprite_last_x - sprite_first_x + 1; + int i; + /* clear previous sprite data storage line */ + memset(p, 0, len); - sprite_last_x = 0; - sprite_first_x = MAX_PIXELS_PER_LINE - 1; - } + sprite_last_x = 0; + sprite_first_x = MAX_PIXELS_PER_LINE - 1; + } - /* Now, compute some offsets. */ + /* Now, compute some offsets. */ ddf_left -= DISPLAY_LEFT_SHIFT; ddf_left <<= bplres; pixels_offset = MAX_PIXELS_PER_LINE - ddf_left; - leftborderhidden = playfield_start - native_ddf_left; - src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window (leftborderhidden); + leftborderhidden = playfield_start - native_ddf_left; + src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window(leftborderhidden); if (dip_for_drawing->nr_sprites == 0) return; /* We need to clear parts of apixels. */ if (linetoscr_diw_start < native_ddf_left) { - int size = res_shift_from_window (native_ddf_left - linetoscr_diw_start); + int size = res_shift_from_window(native_ddf_left - linetoscr_diw_start); linetoscr_diw_start = native_ddf_left; - memset (pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size); + memset(pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size); } if (linetoscr_diw_end > native_ddf_right) { - int pos = res_shift_from_window (native_ddf_right - native_ddf_left); - int size = res_shift_from_window (linetoscr_diw_end - native_ddf_right); + int pos = res_shift_from_window(native_ddf_right - native_ddf_left); + int size = res_shift_from_window(linetoscr_diw_end - native_ddf_right); linetoscr_diw_start = native_ddf_left; - memset (pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size); + memset(pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size); } } -STATIC_INLINE void fill_line (void) +STATIC_INLINE void fill_line(void) { int nints; - int *start; - xcolnr val; + int *start; + xcolnr val; nints = gfxvidinfo.outwidth >> 1; - if(gfxvidinfo.outwidth > 600) + if (gfxvidinfo.outwidth > 600) start = (int *)(((uae_u8*)xlinebuffer) + (visible_left_border << 2)); else start = (int *)(((uae_u8*)xlinebuffer) + (visible_left_border << 1)); - val = getbgc (false); + val = getbgc(false); val |= val << 16; for (; nints > 0; nints -= 8, start += 8) { *start = val; - *(start+1) = val; - *(start+2) = val; - *(start+3) = val; - *(start+4) = val; - *(start+5) = val; - *(start+6) = val; - *(start+7) = val; + *(start + 1) = val; + *(start + 2) = val; + *(start + 3) = val; + *(start + 4) = val; + *(start + 5) = val; + *(start + 6) = val; + *(start + 7) = val; } } -static void dummy_worker (int start, int stop) +static void dummy_worker(int start, int stop) { } #ifdef ARMV6T2 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) ); - return col; + __asm__( + "ubfx %[pv], %[pv], #3, #5 \n\t" + "bfi %[col], %[pv], #0, #5 \n\t" + : [col] "+r" (col), + [pv] "+r" (pv)); + return col; } 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) ); - return col; + __asm__( + "ubfx %[pv], %[pv], #3, #5 \n\t" + "bfi %[col], %[pv], #11, #5 \n\t" + : [col] "+r" (col), + [pv] "+r" (pv)); + return col; } 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) ); - return col; + __asm__( + "ubfx %[pv], %[pv], #2, #6 \n\t" + "bfi %[col], %[pv], #5, #6 \n\t" + : [col] "+r" (col), + [pv] "+r" (pv)); + return col; } 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) ); - return (col); + __asm__( + "lsl %[pv], %[pv], #1 \n\t" + "bfi %[col], %[pv], #0, #5 \n\t" + : [col] "+r" (col), + [pv] "+r" (pv)); + return (col); } 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) ); - return (col); + __asm__( + "lsl %[pv], %[pv], #1 \n\t" + "bfi %[col], %[pv], #11, #5 \n\t" + : [col] "+r" (col), + [pv] "+r" (pv)); + return (col); } 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) ); - return (col); + __asm__( + "lsl %[pv], %[pv], #2 \n\t" + "bfi %[col], %[pv], #5, #6 \n\t" + : [col] "+r" (col), + [pv] "+r" (pv)); + return (col); } #endif @@ -560,11 +566,11 @@ static uae_u16 ham_lastcolor; * when decode_ham runs. * */ -static void init_ham_decoding (void) +static void init_ham_decoding(void) { - int unpainted_amiga = unpainted; + int unpainted_amiga = unpainted; - ham_decode_pixel = ham_src_pixel; + ham_decode_pixel = ham_src_pixel; ham_lastcolor = colors_for_drawing.acolors[0]; if (!bplham) { @@ -575,66 +581,69 @@ 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; switch (pv & 0x3) - { - case 0x0: ham_lastcolor = colors_for_drawing.acolors[pv >> 2]; break; + { + case 0x0: ham_lastcolor = colors_for_drawing.acolors[pv >> 2]; break; #ifdef ARMV6T2 - case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv); break; - case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv); break; - case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv); break; + case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv); break; + case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv); break; + case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv); break; #else - case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break; - case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break; - case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break; -#endif - } - } - } else { /* AGA mode HAM6 */ - while (unpainted_amiga-- > 0) { - int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor; - switch (pv & 0x30) - { - case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break; -#ifdef ARMV6T2 - case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break; - case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break; - case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break; -#else - case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break; - case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break; - case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break; + case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break; + case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break; + case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break; #endif } } } - } else { - /* OCS/ECS mode HAM6 */ - while (unpainted_amiga-- > 0) { - int pv = pixdata.apixels[ham_decode_pixel++]; - switch (pv & 0x30) - { + else { /* AGA mode HAM6 */ + while (unpainted_amiga-- > 0) { + int pv = pixdata.apixels[ham_decode_pixel++] ^ bplxor; + switch (pv & 0x30) + { case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break; #ifdef ARMV6T2 case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break; case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break; case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break; #else - case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break; - case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break; - case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break; + case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break; + case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break; + case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break; +#endif + } + } + } + } + else { + /* OCS/ECS mode HAM6 */ + while (unpainted_amiga-- > 0) { + int pv = pixdata.apixels[ham_decode_pixel++]; + switch (pv & 0x30) + { + case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break; +#ifdef ARMV6T2 + case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break; + case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break; + case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break; +#else + case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break; + case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break; + case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break; #endif } } } } -static void decode_ham (int pix, int stoppos) +static void decode_ham(int pix, int stoppos) { - int todraw_amiga = res_shift_from_window (stoppos - pix); + int todraw_amiga = res_shift_from_window(stoppos - pix); if (!bplham) { while (todraw_amiga-- > 0) { @@ -646,59 +655,62 @@ 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; switch (pv & 0x3) - { - case 0x0: ham_lastcolor = colors_for_drawing.acolors[pv >> 2]; break; + { + case 0x0: ham_lastcolor = colors_for_drawing.acolors[pv >> 2]; break; #ifdef ARMV6T2 - case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv); break; - case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv); break; - case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv); break; + case 0x1: ham_lastcolor = DECODE_HAM8_1(ham_lastcolor, pv); break; + case 0x2: ham_lastcolor = DECODE_HAM8_2(ham_lastcolor, pv); break; + case 0x3: ham_lastcolor = DECODE_HAM8_3(ham_lastcolor, pv); break; #else - case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break; - case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break; - case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break; -#endif - } - ham_linebuf[ham_decode_pixel++] = ham_lastcolor; - } - } else { /* AGA mode HAM6 */ - while (todraw_amiga-- > 0) { - int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor; - switch (pv & 0x30) - { - case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break; -#ifdef ARMV6T2 - case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break; - case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break; - case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break; -#else - case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break; - case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break; - case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break; + case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break; + case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break; + case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break; #endif } ham_linebuf[ham_decode_pixel++] = ham_lastcolor; } } - } else { - /* OCS/ECS mode HAM6 */ - while (todraw_amiga-- > 0) { - int pv = pixdata.apixels[ham_decode_pixel]; - switch (pv & 0x30) - { + else { /* AGA mode HAM6 */ + while (todraw_amiga-- > 0) { + int pv = pixdata.apixels[ham_decode_pixel] ^ bplxor; + switch (pv & 0x30) + { case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break; #ifdef ARMV6T2 case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break; case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break; case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break; #else - case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break; - case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break; - case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break; + case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break; + case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break; + case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break; +#endif + } + ham_linebuf[ham_decode_pixel++] = ham_lastcolor; + } + } + } + else { + /* OCS/ECS mode HAM6 */ + while (todraw_amiga-- > 0) { + int pv = pixdata.apixels[ham_decode_pixel]; + switch (pv & 0x30) + { + case 0x00: ham_lastcolor = colors_for_drawing.acolors[pv]; break; +#ifdef ARMV6T2 + case 0x10: ham_lastcolor = DECODE_HAM6_1(ham_lastcolor, pv); break; + case 0x20: ham_lastcolor = DECODE_HAM6_2(ham_lastcolor, pv); break; + case 0x30: ham_lastcolor = DECODE_HAM6_3(ham_lastcolor, pv); break; +#else + case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break; + case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break; + case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break; #endif } ham_linebuf[ham_decode_pixel++] = ham_lastcolor; @@ -706,7 +718,7 @@ static void decode_ham (int pix, int stoppos) } } -static void gen_pfield_tables (void) +static void gen_pfield_tables(void) { int i; @@ -735,406 +747,424 @@ static void gen_pfield_tables (void) | (((i & 48) && (i & 192)) << 14)); } - for(i=0; i<65536; ++i) - { - sprite_col_nat[i] = - (i & 0x0003) ? ((i >> 0) & 3) + 0 : - (i & 0x000C) ? ((i >> 2) & 3) + 0 : - (i & 0x0030) ? ((i >> 4) & 3) + 4 : - (i & 0x00C0) ? ((i >> 6) & 3) + 4 : - (i & 0x0300) ? ((i >> 8) & 3) + 8 : - (i & 0x0C00) ? ((i >> 10) & 3) + 8 : - (i & 0x3000) ? ((i >> 12) & 3) + 12 : - (i & 0xC000) ? ((i >> 14) & 3) + 12 : 0; - sprite_col_at[i] = - (i & 0x000F) ? ((i >> 0) & 0x000F) : - (i & 0x00F0) ? ((i >> 4) & 0x000F) : - (i & 0x0F00) ? ((i >> 8) & 0x000F) : - (i & 0xF000) ? ((i >> 12) & 0x000F) : 0; - sprite_bit[i] = - (i & 0x0003) ? 0x01 : - (i & 0x000C) ? 0x02 : - (i & 0x0030) ? 0x04 : - (i & 0x00C0) ? 0x08 : - (i & 0x0300) ? 0x10 : - (i & 0x0C00) ? 0x20 : - (i & 0x3000) ? 0x40 : - (i & 0xC000) ? 0x80 : 0; - } + for (i = 0; i < 65536; ++i) + { + sprite_col_nat[i] = + (i & 0x0003) ? ((i >> 0) & 3) + 0 : + (i & 0x000C) ? ((i >> 2) & 3) + 0 : + (i & 0x0030) ? ((i >> 4) & 3) + 4 : + (i & 0x00C0) ? ((i >> 6) & 3) + 4 : + (i & 0x0300) ? ((i >> 8) & 3) + 8 : + (i & 0x0C00) ? ((i >> 10) & 3) + 8 : + (i & 0x3000) ? ((i >> 12) & 3) + 12 : + (i & 0xC000) ? ((i >> 14) & 3) + 12 : 0; + sprite_col_at[i] = + (i & 0x000F) ? ((i >> 0) & 0x000F) : + (i & 0x00F0) ? ((i >> 4) & 0x000F) : + (i & 0x0F00) ? ((i >> 8) & 0x000F) : + (i & 0xF000) ? ((i >> 12) & 0x000F) : 0; + sprite_bit[i] = + (i & 0x0003) ? 0x01 : + (i & 0x000C) ? 0x02 : + (i & 0x0030) ? 0x04 : + (i & 0x00C0) ? 0x08 : + (i & 0x0300) ? 0x10 : + (i & 0x0C00) ? 0x20 : + (i & 0x3000) ? 0x40 : + (i & 0xC000) ? 0x80 : 0; + } } static void draw_sprites_normal_sp_lo_nat(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + int pos, window_pos; - buf -= e->pos; + buf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - col = sprite_col_nat[v] + 16; - pixdata.apixels[window_pos] = col; - } - window_pos++; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + col = sprite_col_nat[v] + 16; + pixdata.apixels[window_pos] = col; + } + window_pos++; + } } static void draw_sprites_normal_ham_lo_nat(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + int pos, window_pos; - buf -= e->pos; + buf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - col = sprite_col_nat[v] + 16; - ham_linebuf[window_pos] = colors_for_drawing.acolors[col]; - } - window_pos++; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + col = sprite_col_nat[v] + 16; + ham_linebuf[window_pos] = colors_for_drawing.acolors[col]; + } + window_pos++; + } } static void draw_sprites_normal_dp_lo_nat(struct sprite_entry *e) { - int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); - uae_u16 *buf = spixels + e->first_pixel; - int pos, window_pos; + int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); + uae_u16 *buf = spixels + e->first_pixel; + int pos, window_pos; - buf -= e->pos; + buf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - int maskshift, plfmask; - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + int maskshift, plfmask; + unsigned int v = buf[pos]; - maskshift = shift_lookup[pixdata.apixels[window_pos]]; - plfmask = (plf_sprite_mask >> maskshift) >> maskshift; - v &= ~plfmask; - if (v != 0) { - unsigned int col; - col = sprite_col_nat[v] + 16 + 128; - pixdata.apixels[window_pos] = col; - } - window_pos++; - } + maskshift = shift_lookup[pixdata.apixels[window_pos]]; + plfmask = (plf_sprite_mask >> maskshift) >> maskshift; + v &= ~plfmask; + if (v != 0) { + unsigned int col; + col = sprite_col_nat[v] + 16 + 128; + pixdata.apixels[window_pos] = col; + } + window_pos++; + } } static void draw_sprites_normal_sp_lo_at(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (stbuf[pos] & offs) { - col = sprite_col_at[v] + 16; - } else { - col = sprite_col_nat[v] + 16; - } - pixdata.apixels[window_pos] = col; - } - window_pos++; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (stbuf[pos] & offs) { + col = sprite_col_at[v] + 16; + } + else { + col = sprite_col_nat[v] + 16; + } + pixdata.apixels[window_pos] = col; + } + window_pos++; + } } static void draw_sprites_normal_ham_lo_at(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (stbuf[pos] & offs) { - col = sprite_col_at[v] + 16; - } else { - col = sprite_col_nat[v] + 16; - } - ham_linebuf[window_pos] = colors_for_drawing.acolors[col]; - } - window_pos++; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (stbuf[pos] & offs) { + col = sprite_col_at[v] + 16; + } + else { + col = sprite_col_nat[v] + 16; + } + ham_linebuf[window_pos] = colors_for_drawing.acolors[col]; + } + window_pos++; + } } static void draw_sprites_normal_dp_lo_at(struct sprite_entry *e) { - int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - int maskshift, plfmask; - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + int maskshift, plfmask; + unsigned int v = buf[pos]; - maskshift = shift_lookup[pixdata.apixels[window_pos]]; - plfmask = (plf_sprite_mask >> maskshift) >> maskshift; - v &= ~plfmask; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (stbuf[pos] & offs) { - col = sprite_col_at[v] + 16 + 128; - } else { - col = sprite_col_nat[v] + 16 + 128; - } - pixdata.apixels[window_pos] = col; - } - window_pos++; - } + maskshift = shift_lookup[pixdata.apixels[window_pos]]; + plfmask = (plf_sprite_mask >> maskshift) >> maskshift; + v &= ~plfmask; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (stbuf[pos] & offs) { + col = sprite_col_at[v] + 16 + 128; + } + else { + col = sprite_col_nat[v] + 16 + 128; + } + pixdata.apixels[window_pos] = col; + } + window_pos++; + } } static void draw_sprites_normal_sp_hi_nat(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + int pos, window_pos; - buf -= e->pos; + buf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos <<= 1; - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos ++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos <<= 1; + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - col = sprite_col_nat[v] + 16; - pixdata.apixels_w[window_pos >> 1] = col | (col << 8); - } - window_pos += 2; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + col = sprite_col_nat[v] + 16; + pixdata.apixels_w[window_pos >> 1] = col | (col << 8); + } + window_pos += 2; + } } static void draw_sprites_normal_ham_hi_nat(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + int pos, window_pos; - buf -= e->pos; + buf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos <<= 1; - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos ++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos <<= 1; + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - col = sprite_col_nat[v] + 16; - col = col | (col << 8); - ham_linebuf[window_pos >> 1] = colors_for_drawing.acolors[col]; - } - window_pos += 2; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + col = sprite_col_nat[v] + 16; + col = col | (col << 8); + ham_linebuf[window_pos >> 1] = colors_for_drawing.acolors[col]; + } + window_pos += 2; + } } static void draw_sprites_normal_dp_hi_nat(struct sprite_entry *e) { - int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); - uae_u16 *buf = spixels + e->first_pixel; - int pos, window_pos; + int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); + uae_u16 *buf = spixels + e->first_pixel; + int pos, window_pos; - buf -= e->pos; + buf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos <<= 1; - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos ++) { - int maskshift, plfmask; - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos <<= 1; + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + int maskshift, plfmask; + unsigned int v = buf[pos]; - maskshift = shift_lookup[pixdata.apixels[window_pos]]; - plfmask = (plf_sprite_mask >> maskshift) >> maskshift; - v &= ~plfmask; - if (v != 0) { - unsigned int col; - col = sprite_col_nat[v] + 16 + 128; - pixdata.apixels_w[window_pos >> 1] = col | (col << 8); - } - window_pos += 2; - } + maskshift = shift_lookup[pixdata.apixels[window_pos]]; + plfmask = (plf_sprite_mask >> maskshift) >> maskshift; + v &= ~plfmask; + if (v != 0) { + unsigned int col; + col = sprite_col_nat[v] + 16 + 128; + pixdata.apixels_w[window_pos >> 1] = col | (col << 8); + } + window_pos += 2; + } } static void draw_sprites_normal_sp_hi_at(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos <<= 1; - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos <<= 1; + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (stbuf[pos] & offs) { - col = sprite_col_at[v] + 16; - } else { - col = sprite_col_nat[v] + 16; - } - pixdata.apixels_w[window_pos >> 1] = col | (col << 8); - } - window_pos += 2; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (stbuf[pos] & offs) { + col = sprite_col_at[v] + 16; + } + else { + col = sprite_col_nat[v] + 16; + } + pixdata.apixels_w[window_pos >> 1] = col | (col << 8); + } + window_pos += 2; + } } static void draw_sprites_normal_ham_hi_at(struct sprite_entry *e) { - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos <<= 1; - window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - unsigned int v = buf[pos]; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos <<= 1; + window_pos += pixels_offset; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + unsigned int v = buf[pos]; - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (stbuf[pos] & offs) { - col = sprite_col_at[v] + 16; - } else { - col = sprite_col_nat[v] + 16; - } - col = col | (col << 8); - ham_linebuf[window_pos >> 1] = colors_for_drawing.acolors[col]; - } - window_pos += 2; - } + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (stbuf[pos] & offs) { + col = sprite_col_at[v] + 16; + } + else { + col = sprite_col_nat[v] + 16; + } + col = col | (col << 8); + ham_linebuf[window_pos >> 1] = colors_for_drawing.acolors[col]; + } + window_pos += 2; + } } static void draw_sprites_normal_dp_hi_at(struct sprite_entry *e) { - int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) ); - window_pos <<= 1; - window_pos += pixels_offset; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT)); + window_pos <<= 1; + window_pos += pixels_offset; - unsigned max=e->max; - for (pos = e->pos; pos < max; pos++) { - int maskshift, plfmask; - unsigned int v = buf[pos]; + unsigned max = e->max; + for (pos = e->pos; pos < max; pos++) { + int maskshift, plfmask; + unsigned int v = buf[pos]; - maskshift = shift_lookup[pixdata.apixels[window_pos]]; - plfmask = (plf_sprite_mask >> maskshift) >> maskshift; - v &= ~plfmask; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (stbuf[pos] & offs) { - col = sprite_col_at[v] + 16 + 128; - } else { - col = sprite_col_nat[v] + 16 + 128; - } - pixdata.apixels_w[window_pos >> 1] = col | (col << 8); - } - window_pos += 2; - } + maskshift = shift_lookup[pixdata.apixels[window_pos]]; + plfmask = (plf_sprite_mask >> maskshift) >> maskshift; + v &= ~plfmask; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (stbuf[pos] & offs) { + col = sprite_col_at[v] + 16 + 128; + } + else { + col = sprite_col_nat[v] + 16 + 128; + } + pixdata.apixels_w[window_pos >> 1] = col | (col << 8); + } + window_pos += 2; + } } -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 }; -static draw_sprites_func draw_sprites_sp_hi[2]={ - 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 }; -static draw_sprites_func draw_sprites_dp_lo[2]={ - 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 }; -static draw_sprites_func draw_sprites_ham_lo[2]={ - draw_sprites_normal_ham_lo_nat, draw_sprites_normal_ham_lo_at }; +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 +}; +static draw_sprites_func draw_sprites_sp_hi[2] = { + 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 +}; +static draw_sprites_func draw_sprites_dp_lo[2] = { + 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 +}; +static draw_sprites_func draw_sprites_ham_lo[2] = { + draw_sprites_normal_ham_lo_nat, + draw_sprites_normal_ham_lo_at +}; static draw_sprites_func *draw_sprites_punt = draw_sprites_sp_lo; @@ -1144,267 +1174,288 @@ static draw_sprites_func *draw_sprites_punt = draw_sprites_sp_lo; that many of the if statements will go away completely after inlining. */ /* NOTE: This function is called for AGA modes *only* */ -STATIC_INLINE void draw_sprites_aga_ham (struct sprite_entry *e, const int doubling, const int skip, const int has_attach) +STATIC_INLINE void draw_sprites_aga_ham(struct sprite_entry *e, const int doubling, const int skip, const int has_attach) { - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res); - if (skip) - window_pos >>= 1; - else if (doubling) - window_pos <<= 1; - window_pos += pixels_offset; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res); + if (skip) + window_pos >>= 1; + else if (doubling) + window_pos <<= 1; + window_pos += pixels_offset; - for (pos = e->pos; pos < e->max; pos += 1 << skip) { - unsigned int v = buf[pos]; + for (pos = e->pos; pos < e->max; pos += 1 << skip) { + unsigned int v = buf[pos]; - if(v) { - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (has_attach && (stbuf[pos] & offs)) { - col = sprite_col_at[v] + sbasecol[1]; - } else { - if(offs & 0x55) - col = sprite_col_nat[v] + sbasecol[0]; - else - col = sprite_col_nat[v] + sbasecol[1]; - } + if (v) { + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (has_attach && (stbuf[pos] & offs)) { + col = sprite_col_at[v] + sbasecol[1]; + } + else { + if (offs & 0x55) + col = sprite_col_nat[v] + sbasecol[0]; + else + col = sprite_col_nat[v] + sbasecol[1]; + } - col = colors_for_drawing.acolors[col ^ bplxor]; - ham_linebuf[window_pos] = col; - if (doubling) - ham_linebuf[window_pos + 1] = col; - } - } + col = colors_for_drawing.acolors[col ^ bplxor]; + ham_linebuf[window_pos] = col; + if (doubling) + ham_linebuf[window_pos + 1] = col; + } + } window_pos += 1 << doubling; } } -STATIC_INLINE void draw_sprites_aga_dp (struct sprite_entry *e, const int doubling, const int skip, const int has_attach) +STATIC_INLINE void draw_sprites_aga_dp(struct sprite_entry *e, const int doubling, const int skip, const int has_attach) { - int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + int *shift_lookup = (bpldualpfpri ? dblpf_ms2 : dblpf_ms1); + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res); - if (skip) - window_pos >>= 1; - else if (doubling) - window_pos <<= 1; - window_pos += pixels_offset; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res); + if (skip) + window_pos >>= 1; + else if (doubling) + window_pos <<= 1; + window_pos += pixels_offset; - if (window_pos < sprite_first_x) - sprite_first_x = window_pos; + if (window_pos < sprite_first_x) + sprite_first_x = window_pos; - for (pos = e->pos; pos < e->max; pos += 1 << skip) { - int maskshift, plfmask; - unsigned int v = buf[pos]; + for (pos = e->pos; pos < e->max; pos += 1 << skip) { + int maskshift, plfmask; + unsigned int v = buf[pos]; - if(v) { - /* The value in the shift lookup table is _half_ the shift count we - need. This is because we can't shift 32 bits at once (undefined - behaviour in C). */ - maskshift = shift_lookup[pixdata.apixels[window_pos]]; - plfmask = (plf_sprite_mask >> maskshift) >> maskshift; - v &= ~plfmask; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (has_attach && (stbuf[pos] & offs)) { - col = sprite_col_at[v] + sbasecol[1]; - } else { - if(offs & 0x55) - col = sprite_col_nat[v] + sbasecol[0]; - else - col = sprite_col_nat[v] + sbasecol[1]; - } + if (v) { + /* The value in the shift lookup table is _half_ the shift count we + need. This is because we can't shift 32 bits at once (undefined + behaviour in C). */ + maskshift = shift_lookup[pixdata.apixels[window_pos]]; + plfmask = (plf_sprite_mask >> maskshift) >> maskshift; + v &= ~plfmask; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (has_attach && (stbuf[pos] & offs)) { + col = sprite_col_at[v] + sbasecol[1]; + } + else { + if (offs & 0x55) + col = sprite_col_nat[v] + sbasecol[0]; + else + col = sprite_col_nat[v] + sbasecol[1]; + } - spritepixels[window_pos] = col; - if (doubling) - spritepixels[window_pos + 1] = col; - } - } + spritepixels[window_pos] = col; + if (doubling) + spritepixels[window_pos + 1] = col; + } + } window_pos += 1 << doubling; } if (window_pos > sprite_last_x) - sprite_last_x = window_pos; + sprite_last_x = window_pos; } -STATIC_INLINE void draw_sprites_aga_sp (struct sprite_entry *e, const int doubling, const int skip, const int has_attach) +STATIC_INLINE void draw_sprites_aga_sp(struct sprite_entry *e, const int doubling, const int skip, const int has_attach) { - uae_u16 *buf = spixels + e->first_pixel; - uae_u8 *stbuf = spixstate.bytes + e->first_pixel; - int pos, window_pos; + uae_u16 *buf = spixels + e->first_pixel; + uae_u8 *stbuf = spixstate.bytes + e->first_pixel; + int pos, window_pos; - buf -= e->pos; - stbuf -= e->pos; + buf -= e->pos; + stbuf -= e->pos; - window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res); - if (skip) - window_pos >>= 1; - else if (doubling) - window_pos <<= 1; - window_pos += pixels_offset; + window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << sprite_buffer_res); + if (skip) + window_pos >>= 1; + else if (doubling) + window_pos <<= 1; + window_pos += pixels_offset; - for (pos = e->pos; pos < e->max; pos += 1 << skip) { - unsigned int v = buf[pos]; + for (pos = e->pos; pos < e->max; pos += 1 << skip) { + unsigned int v = buf[pos]; - if(v) { - if(pixdata.apixels[window_pos]) - v &= plf_sprite_mask_n16; - if (v != 0) { - unsigned int col; - int offs; - offs = sprite_bit[v]; - if (has_attach && (stbuf[pos] & offs)) { - col = sprite_col_at[v] + sbasecol[1]; - } else { - if(offs & 0x55) - col = sprite_col_nat[v] + sbasecol[0]; - else - col = sprite_col_nat[v] + sbasecol[1]; - } + if (v) { + if (pixdata.apixels[window_pos]) + v &= plf_sprite_mask_n16; + if (v != 0) { + unsigned int col; + int offs; + offs = sprite_bit[v]; + if (has_attach && (stbuf[pos] & offs)) { + col = sprite_col_at[v] + sbasecol[1]; + } + else { + if (offs & 0x55) + col = sprite_col_nat[v] + sbasecol[0]; + else + col = sprite_col_nat[v] + sbasecol[1]; + } - col ^= bplxor; - if (doubling) - pixdata.apixels_w[window_pos >> 1] = col | (col << 8); - else - pixdata.apixels[window_pos] = col; - } - } + col ^= bplxor; + if (doubling) + pixdata.apixels_w[window_pos >> 1] = col | (col << 8); + else + pixdata.apixels[window_pos] = col; + } + } window_pos += 1 << doubling; } } // ENTRY, doubling, skip, has_attach -static void draw_sprites_aga_sp_lo_nat(struct sprite_entry *e) { draw_sprites_aga_sp (e, 0, 1, 0); } -static void draw_sprites_aga_dp_lo_nat(struct sprite_entry *e) { draw_sprites_aga_dp (e, 0, 1, 0); } -static void draw_sprites_aga_ham_lo_nat(struct sprite_entry *e) { draw_sprites_aga_ham (e, 0, 1, 0); } +static void draw_sprites_aga_sp_lo_nat(struct sprite_entry *e) { draw_sprites_aga_sp(e, 0, 1, 0); } +static void draw_sprites_aga_dp_lo_nat(struct sprite_entry *e) { draw_sprites_aga_dp(e, 0, 1, 0); } +static void draw_sprites_aga_ham_lo_nat(struct sprite_entry *e) { draw_sprites_aga_ham(e, 0, 1, 0); } -static void draw_sprites_aga_sp_lo_at(struct sprite_entry *e) { draw_sprites_aga_sp (e, 0, 1, 1); } -static void draw_sprites_aga_dp_lo_at(struct sprite_entry *e) { draw_sprites_aga_dp (e, 0, 1, 1); } -static void draw_sprites_aga_ham_lo_at(struct sprite_entry *e) { draw_sprites_aga_ham (e, 0, 1, 1); } +static void draw_sprites_aga_sp_lo_at(struct sprite_entry *e) { draw_sprites_aga_sp(e, 0, 1, 1); } +static void draw_sprites_aga_dp_lo_at(struct sprite_entry *e) { draw_sprites_aga_dp(e, 0, 1, 1); } +static void draw_sprites_aga_ham_lo_at(struct sprite_entry *e) { draw_sprites_aga_ham(e, 0, 1, 1); } -static void draw_sprites_aga_sp_hi_nat(struct sprite_entry *e) { draw_sprites_aga_sp (e, 0, 0, 0); } -static void draw_sprites_aga_dp_hi_nat(struct sprite_entry *e) { draw_sprites_aga_dp (e, 0, 0, 0); } -static void draw_sprites_aga_ham_hi_nat(struct sprite_entry *e) { draw_sprites_aga_ham (e, 0, 0, 0); } +static void draw_sprites_aga_sp_hi_nat(struct sprite_entry *e) { draw_sprites_aga_sp(e, 0, 0, 0); } +static void draw_sprites_aga_dp_hi_nat(struct sprite_entry *e) { draw_sprites_aga_dp(e, 0, 0, 0); } +static void draw_sprites_aga_ham_hi_nat(struct sprite_entry *e) { draw_sprites_aga_ham(e, 0, 0, 0); } -static void draw_sprites_aga_sp_hi_at(struct sprite_entry *e) { draw_sprites_aga_sp (e, 0, 0, 1); } -static void draw_sprites_aga_dp_hi_at(struct sprite_entry *e) { draw_sprites_aga_dp (e, 0, 0, 1); } -static void draw_sprites_aga_ham_hi_at(struct sprite_entry *e) { draw_sprites_aga_ham (e, 0, 0, 1); } +static void draw_sprites_aga_sp_hi_at(struct sprite_entry *e) { draw_sprites_aga_sp(e, 0, 0, 1); } +static void draw_sprites_aga_dp_hi_at(struct sprite_entry *e) { draw_sprites_aga_dp(e, 0, 0, 1); } +static void draw_sprites_aga_ham_hi_at(struct sprite_entry *e) { draw_sprites_aga_ham(e, 0, 0, 1); } -static void draw_sprites_aga_sp_shi_nat(struct sprite_entry *e) { draw_sprites_aga_sp (e, 1, 0, 0); } -static void draw_sprites_aga_dp_shi_nat(struct sprite_entry *e) { draw_sprites_aga_dp (e, 1, 0, 0); } -static void draw_sprites_aga_ham_shi_nat(struct sprite_entry *e) { draw_sprites_aga_ham (e, 1, 0, 0); } +static void draw_sprites_aga_sp_shi_nat(struct sprite_entry *e) { draw_sprites_aga_sp(e, 1, 0, 0); } +static void draw_sprites_aga_dp_shi_nat(struct sprite_entry *e) { draw_sprites_aga_dp(e, 1, 0, 0); } +static void draw_sprites_aga_ham_shi_nat(struct sprite_entry *e) { draw_sprites_aga_ham(e, 1, 0, 0); } -static void draw_sprites_aga_sp_shi_at(struct sprite_entry *e) { draw_sprites_aga_sp (e, 1, 0, 1); } -static void draw_sprites_aga_dp_shi_at(struct sprite_entry *e) { draw_sprites_aga_dp (e, 1, 0, 1); } -static void draw_sprites_aga_ham_shi_at(struct sprite_entry *e) { draw_sprites_aga_ham (e, 1, 0, 1); } +static void draw_sprites_aga_sp_shi_at(struct sprite_entry *e) { draw_sprites_aga_sp(e, 1, 0, 1); } +static void draw_sprites_aga_dp_shi_at(struct sprite_entry *e) { draw_sprites_aga_dp(e, 1, 0, 1); } +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 }; -static draw_sprites_func draw_sprites_aga_sp_hi[2]={ - 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 }; +static draw_sprites_func draw_sprites_aga_sp_lo[2] = { + 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 +}; +static draw_sprites_func draw_sprites_aga_sp_shi[2] = { + 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 }; -static draw_sprites_func draw_sprites_aga_dp_hi[2]={ - 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 }; +static draw_sprites_func draw_sprites_aga_dp_lo[2] = { + 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 +}; +static draw_sprites_func draw_sprites_aga_dp_shi[2] = { + 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 }; -static draw_sprites_func draw_sprites_aga_ham_hi[2]={ - 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 }; +static draw_sprites_func draw_sprites_aga_ham_lo[2] = { + 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 +}; +static draw_sprites_func draw_sprites_aga_ham_shi[2] = { + draw_sprites_aga_ham_shi_nat, + draw_sprites_aga_ham_shi_at +}; static __inline__ void decide_draw_sprites(void) { - if (aga_mode) - { - int diff = sprite_buffer_res - bplres; - if (diff > 0) - { // doubling = 0, skip = 1 - if(bpldualpf) - { // ham = 0, dualpf = 1 - draw_sprites_punt = draw_sprites_aga_dp_lo; - } - else if(dp_for_drawing->ham_seen) - { // ham = 1, dualpf = 0 - draw_sprites_punt = draw_sprites_aga_ham_lo; - } - else - { // ham = 0, dualpf = 0 - draw_sprites_punt = draw_sprites_aga_sp_lo; - } - } - else if(diff == 0) - { // doubling = 0, skip = 0 - if(bpldualpf) - { // ham = 0, dualpf = 1 - draw_sprites_punt = draw_sprites_aga_dp_hi; - } - else if(dp_for_drawing->ham_seen) - { // ham = 1, dualpf = 0 - draw_sprites_punt = draw_sprites_aga_ham_hi; - } - else - { // ham = 0, dualpf = 0 - draw_sprites_punt = draw_sprites_aga_sp_hi; - } - } - else - { // doubling = 1, skip = 0 - if(bpldualpf) - { // ham = 0, dualpf = 1 - draw_sprites_punt = draw_sprites_aga_dp_shi; - } - else if(dp_for_drawing->ham_seen) - { // ham = 1, dualpf = 0 - draw_sprites_punt = draw_sprites_aga_ham_shi; - } - else - { // ham = 0, dualpf = 0 - draw_sprites_punt = draw_sprites_aga_sp_shi; - } - } - } - else - { - if (bplres == RES_LORES) - if (bpldualpf) - draw_sprites_punt=draw_sprites_dp_lo; - else if(dp_for_drawing->ham_seen) - draw_sprites_punt=draw_sprites_ham_lo; - else - draw_sprites_punt=draw_sprites_sp_lo; - else - if (bpldualpf) - draw_sprites_punt=draw_sprites_dp_hi; - else if(dp_for_drawing->ham_seen) - draw_sprites_punt=draw_sprites_ham_hi; - else - draw_sprites_punt=draw_sprites_sp_hi; + if (aga_mode) + { + int diff = sprite_buffer_res - bplres; + if (diff > 0) + { // doubling = 0, skip = 1 + if (bpldualpf) + { // ham = 0, dualpf = 1 + draw_sprites_punt = draw_sprites_aga_dp_lo; + } + else if (dp_for_drawing->ham_seen) + { // ham = 1, dualpf = 0 + draw_sprites_punt = draw_sprites_aga_ham_lo; + } + else + { // ham = 0, dualpf = 0 + draw_sprites_punt = draw_sprites_aga_sp_lo; + } + } + else if (diff == 0) + { // doubling = 0, skip = 0 + if (bpldualpf) + { // ham = 0, dualpf = 1 + draw_sprites_punt = draw_sprites_aga_dp_hi; + } + else if (dp_for_drawing->ham_seen) + { // ham = 1, dualpf = 0 + draw_sprites_punt = draw_sprites_aga_ham_hi; + } + else + { // ham = 0, dualpf = 0 + draw_sprites_punt = draw_sprites_aga_sp_hi; + } + } + else + { // doubling = 1, skip = 0 + if (bpldualpf) + { // ham = 0, dualpf = 1 + draw_sprites_punt = draw_sprites_aga_dp_shi; + } + else if (dp_for_drawing->ham_seen) + { // ham = 1, dualpf = 0 + draw_sprites_punt = draw_sprites_aga_ham_shi; + } + else + { // ham = 0, dualpf = 0 + draw_sprites_punt = draw_sprites_aga_sp_shi; + } + } + } + else + { + if (bplres == RES_LORES) + if (bpldualpf) + draw_sprites_punt = draw_sprites_dp_lo; + else if (dp_for_drawing->ham_seen) + draw_sprites_punt = draw_sprites_ham_lo; + else + draw_sprites_punt = draw_sprites_sp_lo; + else + if (bpldualpf) + draw_sprites_punt = draw_sprites_dp_hi; + else if (dp_for_drawing->ham_seen) + draw_sprites_punt = draw_sprites_ham_hi; + else + draw_sprites_punt = draw_sprites_sp_hi; } } @@ -1421,19 +1472,19 @@ static __inline__ void decide_draw_sprites(void) #ifdef USE_ARMNEON #ifdef __cplusplus - extern "C" { +extern "C" { #endif - void ARM_doline_n1(uae_u32 *pixels, int wordcount, int lineno); - void NEON_doline_n2(uae_u32 *pixels, int wordcount, int lineno); - void NEON_doline_n3(uae_u32 *pixels, int wordcount, int lineno); - void NEON_doline_n4(uae_u32 *pixels, int wordcount, int lineno); - void NEON_doline_n6(uae_u32 *pixels, int wordcount, int lineno); - void NEON_doline_n8(uae_u32 *pixels, int wordcount, int lineno); + void ARM_doline_n1(uae_u32 *pixels, int wordcount, int lineno); + void NEON_doline_n2(uae_u32 *pixels, int wordcount, int lineno); + void NEON_doline_n3(uae_u32 *pixels, int wordcount, int lineno); + void NEON_doline_n4(uae_u32 *pixels, int wordcount, int lineno); + void NEON_doline_n6(uae_u32 *pixels, int wordcount, int lineno); + void NEON_doline_n8(uae_u32 *pixels, int wordcount, int lineno); #ifdef __cplusplus - } +} #endif -static void pfield_doline_n0 (uae_u32 *pixels, int wordcount, int lineno) +static void pfield_doline_n0(uae_u32 *pixels, int wordcount, int lineno) { memset(pixels, 0, wordcount << 5); } @@ -1444,121 +1495,127 @@ static void pfield_doline_n0 (uae_u32 *pixels, int wordcount, int lineno) b ^= (tmp << shift); \ } -static void pfield_doline_n5 (uae_u32 *pixels, int wordcount, int lineno) +static void pfield_doline_n5(uae_u32 *pixels, int wordcount, int lineno) { - uae_u8 *real_bplpt[5]; + uae_u8 *real_bplpt[5]; - real_bplpt[0] = DATA_POINTER (0); - real_bplpt[1] = DATA_POINTER (1); - real_bplpt[2] = DATA_POINTER (2); - real_bplpt[3] = DATA_POINTER (3); - real_bplpt[4] = DATA_POINTER (4); + real_bplpt[0] = DATA_POINTER(0); + real_bplpt[1] = DATA_POINTER(1); + real_bplpt[2] = DATA_POINTER(2); + real_bplpt[3] = DATA_POINTER(3); + real_bplpt[4] = DATA_POINTER(4); - while (wordcount-- > 0) { - uae_u32 b0,b1,b2,b3,b4,b5,b6,b7; - b3 = GETLONG ((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4; - b4 = GETLONG ((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4; - b5 = GETLONG ((uae_u32 *)real_bplpt[2]); real_bplpt[2] += 4; - b6 = GETLONG ((uae_u32 *)real_bplpt[1]); real_bplpt[1] += 4; - b7 = GETLONG ((uae_u32 *)real_bplpt[0]); real_bplpt[0] += 4; + while (wordcount-- > 0) { + uae_u32 b0, b1, b2, b3, b4, b5, b6, b7; + b3 = GETLONG((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4; + b4 = GETLONG((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4; + b5 = GETLONG((uae_u32 *)real_bplpt[2]); real_bplpt[2] += 4; + b6 = GETLONG((uae_u32 *)real_bplpt[1]); real_bplpt[1] += 4; + b7 = GETLONG((uae_u32 *)real_bplpt[0]); real_bplpt[0] += 4; - MERGE_0(b2, b3, 0x55555555, 1); - MERGE (b4, b5, 0x55555555, 1); - MERGE (b6, b7, 0x55555555, 1); + MERGE_0(b2, b3, 0x55555555, 1); + MERGE(b4, b5, 0x55555555, 1); + MERGE(b6, b7, 0x55555555, 1); - MERGE_0(b0, b2, 0x33333333, 2); - MERGE_0(b1, b3, 0x33333333, 2); - MERGE (b4, b6, 0x33333333, 2); - MERGE (b5, b7, 0x33333333, 2); + MERGE_0(b0, b2, 0x33333333, 2); + MERGE_0(b1, b3, 0x33333333, 2); + MERGE(b4, b6, 0x33333333, 2); + MERGE(b5, b7, 0x33333333, 2); - MERGE (b0, b4, 0x0f0f0f0f, 4); - MERGE (b1, b5, 0x0f0f0f0f, 4); - MERGE (b2, b6, 0x0f0f0f0f, 4); - MERGE (b3, b7, 0x0f0f0f0f, 4); + MERGE(b0, b4, 0x0f0f0f0f, 4); + MERGE(b1, b5, 0x0f0f0f0f, 4); + MERGE(b2, b6, 0x0f0f0f0f, 4); + MERGE(b3, b7, 0x0f0f0f0f, 4); - MERGE (b0, b1, 0x00ff00ff, 8); - MERGE (b2, b3, 0x00ff00ff, 8); - MERGE (b4, b5, 0x00ff00ff, 8); - MERGE (b6, b7, 0x00ff00ff, 8); + MERGE(b0, b1, 0x00ff00ff, 8); + MERGE(b2, b3, 0x00ff00ff, 8); + MERGE(b4, b5, 0x00ff00ff, 8); + MERGE(b6, b7, 0x00ff00ff, 8); - MERGE (b0, b2, 0x0000ffff, 16); - do_put_mem_long(pixels, b0); - do_put_mem_long(pixels + 4, b2); - MERGE (b1, b3, 0x0000ffff, 16); - do_put_mem_long(pixels + 2, b1); - do_put_mem_long(pixels + 6, b3); - MERGE (b4, b6, 0x0000ffff, 16); - do_put_mem_long(pixels + 1, b4); - do_put_mem_long(pixels + 5, b6); - MERGE (b5, b7, 0x0000ffff, 16); - do_put_mem_long(pixels + 3, b5); - do_put_mem_long(pixels + 7, b7); - pixels += 8; - } + MERGE(b0, b2, 0x0000ffff, 16); + do_put_mem_long(pixels, b0); + do_put_mem_long(pixels + 4, b2); + MERGE(b1, b3, 0x0000ffff, 16); + do_put_mem_long(pixels + 2, b1); + do_put_mem_long(pixels + 6, b3); + MERGE(b4, b6, 0x0000ffff, 16); + do_put_mem_long(pixels + 1, b4); + do_put_mem_long(pixels + 5, b6); + MERGE(b5, b7, 0x0000ffff, 16); + do_put_mem_long(pixels + 3, b5); + do_put_mem_long(pixels + 7, b7); + pixels += 8; + } } -static void pfield_doline_n7 (uae_u32 *pixels, int wordcount, int lineno) +static void pfield_doline_n7(uae_u32 *pixels, int wordcount, int lineno) { - uae_u8 *real_bplpt[7]; - real_bplpt[0] = DATA_POINTER (0); - real_bplpt[1] = DATA_POINTER (1); - real_bplpt[2] = DATA_POINTER (2); - real_bplpt[3] = DATA_POINTER (3); - real_bplpt[4] = DATA_POINTER (4); - real_bplpt[5] = DATA_POINTER (5); - real_bplpt[6] = DATA_POINTER (6); + uae_u8 *real_bplpt[7]; + real_bplpt[0] = DATA_POINTER(0); + real_bplpt[1] = DATA_POINTER(1); + real_bplpt[2] = DATA_POINTER(2); + real_bplpt[3] = DATA_POINTER(3); + real_bplpt[4] = DATA_POINTER(4); + real_bplpt[5] = DATA_POINTER(5); + real_bplpt[6] = DATA_POINTER(6); - while (wordcount-- > 0) { - uae_u32 b0,b1,b2,b3,b4,b5,b6,b7; - b1 = GETLONG ((uae_u32 *)real_bplpt[6]); real_bplpt[6] += 4; - b2 = GETLONG ((uae_u32 *)real_bplpt[5]); real_bplpt[5] += 4; - b3 = GETLONG ((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4; - b4 = GETLONG ((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4; - b5 = GETLONG ((uae_u32 *)real_bplpt[2]); real_bplpt[2] += 4; - b6 = GETLONG ((uae_u32 *)real_bplpt[1]); real_bplpt[1] += 4; - b7 = GETLONG ((uae_u32 *)real_bplpt[0]); real_bplpt[0] += 4; + while (wordcount-- > 0) { + uae_u32 b0, b1, b2, b3, b4, b5, b6, b7; + b1 = GETLONG((uae_u32 *)real_bplpt[6]); real_bplpt[6] += 4; + b2 = GETLONG((uae_u32 *)real_bplpt[5]); real_bplpt[5] += 4; + b3 = GETLONG((uae_u32 *)real_bplpt[4]); real_bplpt[4] += 4; + b4 = GETLONG((uae_u32 *)real_bplpt[3]); real_bplpt[3] += 4; + b5 = GETLONG((uae_u32 *)real_bplpt[2]); real_bplpt[2] += 4; + b6 = GETLONG((uae_u32 *)real_bplpt[1]); real_bplpt[1] += 4; + b7 = GETLONG((uae_u32 *)real_bplpt[0]); real_bplpt[0] += 4; - MERGE_0(b0, b1, 0x55555555, 1); - MERGE (b2, b3, 0x55555555, 1); - MERGE (b4, b5, 0x55555555, 1); - MERGE (b6, b7, 0x55555555, 1); + MERGE_0(b0, b1, 0x55555555, 1); + MERGE(b2, b3, 0x55555555, 1); + MERGE(b4, b5, 0x55555555, 1); + MERGE(b6, b7, 0x55555555, 1); - MERGE (b0, b2, 0x33333333, 2); - MERGE (b1, b3, 0x33333333, 2); - MERGE (b4, b6, 0x33333333, 2); - MERGE (b5, b7, 0x33333333, 2); + MERGE(b0, b2, 0x33333333, 2); + MERGE(b1, b3, 0x33333333, 2); + MERGE(b4, b6, 0x33333333, 2); + MERGE(b5, b7, 0x33333333, 2); - MERGE (b0, b4, 0x0f0f0f0f, 4); - MERGE (b1, b5, 0x0f0f0f0f, 4); - MERGE (b2, b6, 0x0f0f0f0f, 4); - MERGE (b3, b7, 0x0f0f0f0f, 4); + MERGE(b0, b4, 0x0f0f0f0f, 4); + MERGE(b1, b5, 0x0f0f0f0f, 4); + MERGE(b2, b6, 0x0f0f0f0f, 4); + MERGE(b3, b7, 0x0f0f0f0f, 4); - MERGE (b0, b1, 0x00ff00ff, 8); - MERGE (b2, b3, 0x00ff00ff, 8); - MERGE (b4, b5, 0x00ff00ff, 8); - MERGE (b6, b7, 0x00ff00ff, 8); + MERGE(b0, b1, 0x00ff00ff, 8); + MERGE(b2, b3, 0x00ff00ff, 8); + MERGE(b4, b5, 0x00ff00ff, 8); + MERGE(b6, b7, 0x00ff00ff, 8); - MERGE (b0, b2, 0x0000ffff, 16); - do_put_mem_long(pixels, b0); - do_put_mem_long(pixels + 4, b2); - MERGE (b1, b3, 0x0000ffff, 16); - do_put_mem_long(pixels + 2, b1); - do_put_mem_long(pixels + 6, b3); - MERGE (b4, b6, 0x0000ffff, 16); - do_put_mem_long(pixels + 1, b4); - do_put_mem_long(pixels + 5, b6); - MERGE (b5, b7, 0x0000ffff, 16); - do_put_mem_long(pixels + 3, b5); - do_put_mem_long(pixels + 7, b7); - pixels += 8; - } + MERGE(b0, b2, 0x0000ffff, 16); + do_put_mem_long(pixels, b0); + do_put_mem_long(pixels + 4, b2); + MERGE(b1, b3, 0x0000ffff, 16); + do_put_mem_long(pixels + 2, b1); + do_put_mem_long(pixels + 6, b3); + MERGE(b4, b6, 0x0000ffff, 16); + do_put_mem_long(pixels + 1, b4); + do_put_mem_long(pixels + 5, b6); + MERGE(b5, b7, 0x0000ffff, 16); + do_put_mem_long(pixels + 3, b5); + do_put_mem_long(pixels + 7, b7); + pixels += 8; + } } -typedef void (*pfield_doline_func)(uae_u32 *, int, int); +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, +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, NEON_doline_n8 }; @@ -1569,221 +1626,223 @@ static uae_u8 *real_bplpt[8]; /* We use the compiler's inlining ability to ensure that PLANES is in effect a compile time constant. That will cause some unnecessary code to be optimized away. Don't touch this if you don't know what you are doing. */ -STATIC_INLINE void pfield_doline_1 (uae_u32 *pixels, int wordcount, int planes) +STATIC_INLINE void pfield_doline_1(uae_u32 *pixels, int wordcount, int planes) { - while (wordcount-- > 0) { - uae_u32 b0,b1,b2,b3,b4,b5,b6,b7; + while (wordcount-- > 0) { + uae_u32 b0, b1, b2, b3, b4, b5, b6, b7; - b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0; - switch (planes) { - case 8: b0 = GETLONG (real_bplpt[7]); real_bplpt[7] += 4; - case 7: b1 = GETLONG (real_bplpt[6]); real_bplpt[6] += 4; - case 6: b2 = GETLONG (real_bplpt[5]); real_bplpt[5] += 4; - case 5: b3 = GETLONG (real_bplpt[4]); real_bplpt[4] += 4; - case 4: b4 = GETLONG (real_bplpt[3]); real_bplpt[3] += 4; - case 3: b5 = GETLONG (real_bplpt[2]); real_bplpt[2] += 4; - case 2: b6 = GETLONG (real_bplpt[1]); real_bplpt[1] += 4; - case 1: b7 = GETLONG (real_bplpt[0]); real_bplpt[0] += 4; - } + b0 = 0, b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, b6 = 0, b7 = 0; + switch (planes) { + case 8: b0 = GETLONG(real_bplpt[7]); real_bplpt[7] += 4; + case 7: b1 = GETLONG(real_bplpt[6]); real_bplpt[6] += 4; + case 6: b2 = GETLONG(real_bplpt[5]); real_bplpt[5] += 4; + case 5: b3 = GETLONG(real_bplpt[4]); real_bplpt[4] += 4; + case 4: b4 = GETLONG(real_bplpt[3]); real_bplpt[3] += 4; + case 3: b5 = GETLONG(real_bplpt[2]); real_bplpt[2] += 4; + case 2: b6 = GETLONG(real_bplpt[1]); real_bplpt[1] += 4; + case 1: b7 = GETLONG(real_bplpt[0]); real_bplpt[0] += 4; + } - MERGE (b0, b1, 0x55555555, 1); - MERGE (b2, b3, 0x55555555, 1); - MERGE (b4, b5, 0x55555555, 1); - MERGE (b6, b7, 0x55555555, 1); + MERGE(b0, b1, 0x55555555, 1); + MERGE(b2, b3, 0x55555555, 1); + MERGE(b4, b5, 0x55555555, 1); + MERGE(b6, b7, 0x55555555, 1); - MERGE (b0, b2, 0x33333333, 2); - MERGE (b1, b3, 0x33333333, 2); - MERGE (b4, b6, 0x33333333, 2); - MERGE (b5, b7, 0x33333333, 2); + MERGE(b0, b2, 0x33333333, 2); + MERGE(b1, b3, 0x33333333, 2); + MERGE(b4, b6, 0x33333333, 2); + MERGE(b5, b7, 0x33333333, 2); - MERGE (b0, b4, 0x0f0f0f0f, 4); - MERGE (b1, b5, 0x0f0f0f0f, 4); - MERGE (b2, b6, 0x0f0f0f0f, 4); - MERGE (b3, b7, 0x0f0f0f0f, 4); + MERGE(b0, b4, 0x0f0f0f0f, 4); + MERGE(b1, b5, 0x0f0f0f0f, 4); + MERGE(b2, b6, 0x0f0f0f0f, 4); + MERGE(b3, b7, 0x0f0f0f0f, 4); - MERGE (b0, b1, 0x00ff00ff, 8); - MERGE (b2, b3, 0x00ff00ff, 8); - MERGE (b4, b5, 0x00ff00ff, 8); - MERGE (b6, b7, 0x00ff00ff, 8); + MERGE(b0, b1, 0x00ff00ff, 8); + MERGE(b2, b3, 0x00ff00ff, 8); + MERGE(b4, b5, 0x00ff00ff, 8); + MERGE(b6, b7, 0x00ff00ff, 8); - MERGE (b0, b2, 0x0000ffff, 16); - do_put_mem_long (pixels, b0); - do_put_mem_long (pixels + 4, b2); - MERGE (b1, b3, 0x0000ffff, 16); - do_put_mem_long (pixels + 2, b1); - do_put_mem_long (pixels + 6, b3); - MERGE (b4, b6, 0x0000ffff, 16); - do_put_mem_long (pixels + 1, b4); - do_put_mem_long (pixels + 5, b6); - MERGE (b5, b7, 0x0000ffff, 16); - do_put_mem_long (pixels + 3, b5); - do_put_mem_long (pixels + 7, b7); - pixels += 8; - } + MERGE(b0, b2, 0x0000ffff, 16); + do_put_mem_long(pixels, b0); + do_put_mem_long(pixels + 4, b2); + MERGE(b1, b3, 0x0000ffff, 16); + do_put_mem_long(pixels + 2, b1); + do_put_mem_long(pixels + 6, b3); + MERGE(b4, b6, 0x0000ffff, 16); + do_put_mem_long(pixels + 1, b4); + do_put_mem_long(pixels + 5, b6); + MERGE(b5, b7, 0x0000ffff, 16); + do_put_mem_long(pixels + 3, b5); + do_put_mem_long(pixels + 7, b7); + pixels += 8; + } } /* See above for comments on inlining. These functions should _not_ be inlined themselves. */ -static void NOINLINE pfield_doline_n1 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 1); } -static void NOINLINE pfield_doline_n2 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 2); } -static void NOINLINE pfield_doline_n3 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 3); } -static void NOINLINE pfield_doline_n4 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 4); } -static void NOINLINE pfield_doline_n5 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 5); } -static void NOINLINE pfield_doline_n6 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 6); } -static void NOINLINE pfield_doline_n7 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 7); } -static void NOINLINE pfield_doline_n8 (uae_u32 *data, int count) { pfield_doline_1 (data, count, 8); } +static void NOINLINE pfield_doline_n1(uae_u32 *data, int count) { pfield_doline_1(data, count, 1); } +static void NOINLINE pfield_doline_n2(uae_u32 *data, int count) { pfield_doline_1(data, count, 2); } +static void NOINLINE pfield_doline_n3(uae_u32 *data, int count) { pfield_doline_1(data, count, 3); } +static void NOINLINE pfield_doline_n4(uae_u32 *data, int count) { pfield_doline_1(data, count, 4); } +static void NOINLINE pfield_doline_n5(uae_u32 *data, int count) { pfield_doline_1(data, count, 5); } +static void NOINLINE pfield_doline_n6(uae_u32 *data, int count) { pfield_doline_1(data, count, 6); } +static void NOINLINE pfield_doline_n7(uae_u32 *data, int count) { pfield_doline_1(data, count, 7); } +static void NOINLINE pfield_doline_n8(uae_u32 *data, int count) { pfield_doline_1(data, count, 8); } #endif /* USE_ARMNEON */ -static void pfield_doline (int lineno) +static void pfield_doline(int lineno) { - int wordcount = dp_for_drawing->plflinelen; - uae_u32 *data = pixdata.apixels_l + MAX_PIXELS_PER_LINE / 4; + int wordcount = dp_for_drawing->plflinelen; + uae_u32 *data = pixdata.apixels_l + MAX_PIXELS_PER_LINE / 4; #ifdef USE_ARMNEON - pfield_doline_n[bplplanecnt](data, wordcount, lineno); + pfield_doline_n[bplplanecnt](data, wordcount, lineno); #else - real_bplpt[0] = DATA_POINTER (0); - real_bplpt[1] = DATA_POINTER (1); - real_bplpt[2] = DATA_POINTER (2); - real_bplpt[3] = DATA_POINTER (3); - real_bplpt[4] = DATA_POINTER (4); - real_bplpt[5] = DATA_POINTER (5); - real_bplpt[6] = DATA_POINTER (6); - real_bplpt[7] = DATA_POINTER (7); + real_bplpt[0] = DATA_POINTER(0); + real_bplpt[1] = DATA_POINTER(1); + real_bplpt[2] = DATA_POINTER(2); + real_bplpt[3] = DATA_POINTER(3); + real_bplpt[4] = DATA_POINTER(4); + real_bplpt[5] = DATA_POINTER(5); + real_bplpt[6] = DATA_POINTER(6); + real_bplpt[7] = DATA_POINTER(7); - switch (bplplanecnt) { - default: break; - case 0: memset (data, 0, wordcount * 32); break; - case 1: pfield_doline_n1 (data, wordcount); break; - case 2: pfield_doline_n2 (data, wordcount); break; - case 3: pfield_doline_n3 (data, wordcount); break; - case 4: pfield_doline_n4 (data, wordcount); break; - case 5: pfield_doline_n5 (data, wordcount); break; - case 6: pfield_doline_n6 (data, wordcount); break; - case 7: pfield_doline_n7 (data, wordcount); break; - case 8: pfield_doline_n8 (data, wordcount); break; - } + switch (bplplanecnt) { + default: break; + case 0: memset(data, 0, wordcount * 32); break; + case 1: pfield_doline_n1(data, wordcount); break; + case 2: pfield_doline_n2(data, wordcount); break; + case 3: pfield_doline_n3(data, wordcount); break; + case 4: pfield_doline_n4(data, wordcount); break; + case 5: pfield_doline_n5(data, wordcount); break; + case 6: pfield_doline_n6(data, wordcount); break; + case 7: pfield_doline_n7(data, wordcount); break; + case 8: pfield_doline_n8(data, wordcount); break; + } #endif /* USE_ARMNEON */ } -void init_row_map (void) +void init_row_map(void) { - int i, j; + int i, j; - j = 0; - for (i = gfxvidinfo.outheight; i < MAX_VIDHEIGHT + 1; i++) - row_map[i] = row_tmp; - for (i = 0; i < gfxvidinfo.outheight; i++, j += gfxvidinfo.rowbytes) + j = 0; + for (i = gfxvidinfo.outheight; i < MAX_VIDHEIGHT + 1; i++) + row_map[i] = row_tmp; + for (i = 0; i < gfxvidinfo.outheight; i++, j += gfxvidinfo.rowbytes) row_map[i] = gfxvidinfo.bufmem + j; } -static void init_aspect_maps (void) +static void init_aspect_maps(void) { - int i, maxl, h; + int i, maxl, h; - h = gfxvidinfo.outheight; + h = gfxvidinfo.outheight; - if (h == 0) - /* Do nothing if the gfx driver hasn't initialized the screen yet */ - return; + if (h == 0) + /* Do nothing if the gfx driver hasn't initialized the screen yet */ + return; - if (native2amiga_line_map) - xfree (native2amiga_line_map); + if (native2amiga_line_map) + xfree(native2amiga_line_map); - native2amiga_line_map = xmalloc (int, h); + native2amiga_line_map = xmalloc(int, h); - maxl = (MAXVPOS + 1); + maxl = (MAXVPOS + 1); - for (i = 0; i < h; i++) - native2amiga_line_map[i] = -1; + for (i = 0; i < h; i++) + native2amiga_line_map[i] = -1; - for (i = maxl - 1; i >= minfirstline; i--) { - int j; - for (j = i - minfirstline; j < h && native2amiga_line_map[j] == -1; j++) - native2amiga_line_map[j] = i + currprefs.pandora_vertical_offset + OFFSET_Y_ADJUST; - } + for (i = maxl - 1; i >= minfirstline; i--) { + int j; + for (j = i - minfirstline; j < h && native2amiga_line_map[j] == -1; j++) + native2amiga_line_map[j] = i + currprefs.pandora_vertical_offset + OFFSET_Y_ADJUST; + } } /* * One drawing frame has been finished. Tell the graphics code about it. */ -STATIC_INLINE void do_flush_screen () +STATIC_INLINE void do_flush_screen() { - unlockscr (); - flush_screen (); /* vsync mode */ + unlockscr(); + flush_screen(); /* vsync mode */ } /* We only save hardware registers during the hardware frame. Now, when * drawing the frame, we expand the data into a slightly more useful * form. */ -static void pfield_expand_dp_bplcon (void) +static void pfield_expand_dp_bplcon(void) { - bplres = dp_for_drawing->bplres; - bplplanecnt = dp_for_drawing->nr_planes; - bplham = dp_for_drawing->ham_seen; - if (aga_mode) { - bplehb = (dp_for_drawing->bplcon0 & 0x7010) == 0x6000; - bpldualpf2of = (dp_for_drawing->bplcon3 >> 10) & 7; - 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 - bplehb = (dp_for_drawing->bplcon0 & 0xFC00) == 0x6000 || (dp_for_drawing->bplcon0 & 0xFC00) == 0x7000; + bplres = dp_for_drawing->bplres; + bplplanecnt = dp_for_drawing->nr_planes; + bplham = dp_for_drawing->ham_seen; + if (aga_mode) { + bplehb = (dp_for_drawing->bplcon0 & 0x7010) == 0x6000; + bpldualpf2of = (dp_for_drawing->bplcon3 >> 10) & 7; + 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 + 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; - plf1pri = dp_for_drawing->bplcon2 & 7; - plf2pri = (dp_for_drawing->bplcon2 >> 3) & 7; - plf_sprite_mask = 0xFFFF0000 << (4 * plf2pri); - plf_sprite_mask |= (0x0000FFFF << (4 * plf1pri)) & 0xFFFF; - plf_sprite_mask_n16 = ~(plf_sprite_mask >> 16); - bpldualpf = (dp_for_drawing->bplcon0 & 0x400) == 0x400; - bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40; + plf1pri = dp_for_drawing->bplcon2 & 7; + plf2pri = (dp_for_drawing->bplcon2 >> 3) & 7; + plf_sprite_mask = 0xFFFF0000 << (4 * plf2pri); + plf_sprite_mask |= (0x0000FFFF << (4 * plf1pri)) & 0xFFFF; + plf_sprite_mask_n16 = ~(plf_sprite_mask >> 16); + bpldualpf = (dp_for_drawing->bplcon0 & 0x400) == 0x400; + bpldualpfpri = (dp_for_drawing->bplcon2 & 0x40) == 0x40; } -static bool isham (uae_u16 bplcon0) +static bool isham(uae_u16 bplcon0) { - int p = GET_PLANES (bplcon0); - if (!(bplcon0 & 0x800)) - return 0; - if (aga_mode) { - // AGA only has 6 or 8 plane HAM - if (p == 6 || p == 8) - return 1; - } else { - // OCS/ECS also supports 5 plane HAM - if (GET_RES_DENISE (bplcon0) > 0) - return 0; - if (p >= 5) - return 1; - } - return 0; + int p = GET_PLANES(bplcon0); + if (!(bplcon0 & 0x800)) + return 0; + if (aga_mode) { + // AGA only has 6 or 8 plane HAM + if (p == 6 || p == 8) + return 1; + } + else { + // OCS/ECS also supports 5 plane HAM + if (GET_RES_DENISE(bplcon0) > 0) + return 0; + if (p >= 5) + return 1; + } + return 0; } -static void pfield_expand_dp_bplconx (int regno, int v) +static void pfield_expand_dp_bplconx(int regno, int v) { - regno -= 0x1000; - switch (regno) - { - case 0x100: // BPLCON0 - dp_for_drawing->bplcon0 = v; - dp_for_drawing->bplres = GET_RES_DENISE(v); - dp_for_drawing->nr_planes = GET_PLANES(v); - dp_for_drawing->ham_seen = isham (v); - break; - case 0x104: // BPLCON2 - dp_for_drawing->bplcon2 = v; - break; - case 0x106: // BPLCON3 - dp_for_drawing->bplcon3 = v; - break; - case 0x10c: // BPLCON4 - dp_for_drawing->bplcon4 = v; - break; - } - pfield_expand_dp_bplcon(); -// res_shift = lores_shift - bplres; + regno -= 0x1000; + switch (regno) + { + case 0x100: // BPLCON0 + dp_for_drawing->bplcon0 = v; + dp_for_drawing->bplres = GET_RES_DENISE(v); + dp_for_drawing->nr_planes = GET_PLANES(v); + dp_for_drawing->ham_seen = isham(v); + break; + case 0x104: // BPLCON2 + dp_for_drawing->bplcon2 = v; + break; + case 0x106: // BPLCON3 + dp_for_drawing->bplcon3 = v; + break; + case 0x10c: // BPLCON4 + dp_for_drawing->bplcon4 = v; + break; + } + pfield_expand_dp_bplcon(); + // res_shift = lores_shift - bplres; } static int drawing_color_matches; @@ -1791,163 +1850,171 @@ static enum { color_match_acolors, color_match_full } color_match_type; /* Set up colors_for_drawing to the state at the beginning of the currently drawn line. Try to avoid copying color tables around whenever possible. */ -static void adjust_drawing_colors (int ctable, int need_full) +static void adjust_drawing_colors(int ctable, int need_full) { if (drawing_color_matches != ctable || need_full < 0) { - if (need_full) { - color_reg_cpy (&colors_for_drawing, curr_color_tables + ctable); + 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, - sizeof colors_for_drawing.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) { - color_reg_cpy (&colors_for_drawing, &curr_color_tables[ctable]); + } + 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; - } + } } -STATIC_INLINE void do_color_changes (line_draw_func worker_border, line_draw_func worker_pfield) +STATIC_INLINE void do_color_changes(line_draw_func worker_border, line_draw_func worker_pfield) { - int i; - int lastpos = visible_left_border; - int endpos = visible_right_border; + int i; + int lastpos = visible_left_border; + int endpos = visible_right_border; - for (i = dip_for_drawing->first_color_change; i <= dip_for_drawing->last_color_change; i++) { - int nextpos, nextpos_in_range; - if (i == dip_for_drawing->last_color_change) - nextpos = endpos; - else - nextpos = coord_hw_to_window_x (curr_color_changes[i].linepos); + for (i = dip_for_drawing->first_color_change; i <= dip_for_drawing->last_color_change; i++) { + int nextpos, nextpos_in_range; + if (i == dip_for_drawing->last_color_change) + nextpos = endpos; + else + nextpos = coord_hw_to_window_x(curr_color_changes[i].linepos); - nextpos_in_range = nextpos; - if (nextpos > endpos) - nextpos_in_range = endpos; + nextpos_in_range = nextpos; + if (nextpos > endpos) + nextpos_in_range = endpos; - // left border (hblank end to playfield start) - if (nextpos_in_range > lastpos && lastpos < playfield_start) { - int t = nextpos_in_range <= playfield_start ? nextpos_in_range : playfield_start; - (*worker_border) (lastpos, t); - lastpos = t; - } + // left border (hblank end to playfield start) + if (nextpos_in_range > lastpos && lastpos < playfield_start) { + int t = nextpos_in_range <= playfield_start ? nextpos_in_range : playfield_start; + (*worker_border)(lastpos, t); + lastpos = t; + } - // playfield - if (nextpos_in_range > lastpos && lastpos >= playfield_start && lastpos < playfield_end) { - int t = nextpos_in_range <= playfield_end ? nextpos_in_range : playfield_end; - (*worker_pfield) (lastpos, t); - lastpos = t; - } + // playfield + if (nextpos_in_range > lastpos && lastpos >= playfield_start && lastpos < playfield_end) { + int t = nextpos_in_range <= playfield_end ? nextpos_in_range : playfield_end; + (*worker_pfield)(lastpos, t); + lastpos = t; + } - // right border (playfield end to hblank start) - if (nextpos_in_range > lastpos && lastpos >= playfield_end) { - (*worker_border) (lastpos, nextpos_in_range); - lastpos = nextpos_in_range; - } + // right border (playfield end to hblank start) + if (nextpos_in_range > lastpos && lastpos >= playfield_end) { + (*worker_border)(lastpos, nextpos_in_range); + lastpos = nextpos_in_range; + } - if (i != dip_for_drawing->last_color_change) { - int regno = curr_color_changes[i].regno; - unsigned int value = curr_color_changes[i].value; - if (regno >= 0x1000) { - pfield_expand_dp_bplconx (regno, value); - } 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 { - color_reg_set (&colors_for_drawing, regno, value); - colors_for_drawing.acolors[regno] = getxcolor (value); - } - } - } - if (lastpos >= endpos) - break; - } + if (i != dip_for_drawing->last_color_change) { + int regno = curr_color_changes[i].regno; + unsigned int value = curr_color_changes[i].value; + if (regno >= 0x1000) { + pfield_expand_dp_bplconx(regno, value); + } + 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 { + color_reg_set(&colors_for_drawing, regno, value); + colors_for_drawing.acolors[regno] = getxcolor(value); + } + } + } + if (lastpos >= endpos) + break; + } } -static void pfield_draw_line (int lineno, int gfx_ypos) +static void pfield_draw_line(int lineno, int gfx_ypos) { int border = 0; - dp_for_drawing = line_decisions + lineno; - dip_for_drawing = curr_drawinfo + lineno; + dp_for_drawing = line_decisions + lineno; + dip_for_drawing = curr_drawinfo + lineno; if (dp_for_drawing->plfleft < 0) border = 1; - xlinebuffer = row_map[gfx_ypos]; + xlinebuffer = row_map[gfx_ypos]; xlinebuffer -= linetoscr_x_adjust_bytes; if (border == 0) { - pfield_expand_dp_bplcon (); - pfield_init_linetoscr (); - pfield_doline (lineno); + pfield_expand_dp_bplcon(); + pfield_init_linetoscr(); + pfield_doline(lineno); - adjust_drawing_colors (dp_for_drawing->ctable, dp_for_drawing->ham_seen || bplehb); + adjust_drawing_colors(dp_for_drawing->ctable, dp_for_drawing->ham_seen || bplehb); - /* The problem is that we must call decode_ham() BEFORE we do the sprites. */ - if (dp_for_drawing->ham_seen) { - init_ham_decoding (); - if (dip_for_drawing->nr_color_changes == 0) { - /* The easy case: need to do HAM decoding only once for the - * full line. */ - decode_ham (visible_left_border, visible_right_border); - } 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); - pfield_expand_dp_bplcon (); - } - bplham = dp_for_drawing->ham_at_start; - } + /* The problem is that we must call decode_ham() BEFORE we do the sprites. */ + if (dp_for_drawing->ham_seen) { + init_ham_decoding(); + if (dip_for_drawing->nr_color_changes == 0) { + /* The easy case: need to do HAM decoding only once for the + * full line. */ + decode_ham(visible_left_border, visible_right_border); + } + 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); + pfield_expand_dp_bplcon(); + } + bplham = dp_for_drawing->ham_at_start; + } if (dip_for_drawing->nr_sprites) { int i; decide_draw_sprites(); for (i = 0; i < dip_for_drawing->nr_sprites; i++) { - struct sprite_entry *e = curr_sprite_entries + dip_for_drawing->first_sprite_entry + i; - draw_sprites_punt[e->has_attached](e); + struct sprite_entry *e = curr_sprite_entries + dip_for_drawing->first_sprite_entry + i; + draw_sprites_punt[e->has_attached](e); } } - do_color_changes (pfield_do_fill_line, pfield_do_linetoscr); - } else { // border > 0: top or bottom border + do_color_changes(pfield_do_fill_line, pfield_do_linetoscr); + } + else { // border > 0: top or bottom border bool dosprites = false; - adjust_drawing_colors (dp_for_drawing->ctable, 0); + adjust_drawing_colors(dp_for_drawing->ctable, 0); /* this makes things complex.. */ if (dp_for_drawing->bordersprite_seen && !colors_for_drawing.borderblank && dip_for_drawing->nr_sprites) { dosprites = true; - pfield_expand_dp_bplcon (); - pfield_init_linetoscr (); + pfield_expand_dp_bplcon(); + pfield_init_linetoscr(); } - if (!dosprites && dip_for_drawing->nr_color_changes == 0) { - fill_line (); + if (!dosprites && dip_for_drawing->nr_color_changes == 0) { + fill_line(); return; } if (dosprites) { int i; uae_u16 oxor = bplxor; - memset (pixdata.apixels, 0, sizeof pixdata); + memset(pixdata.apixels, 0, sizeof pixdata); decide_draw_sprites(); for (i = 0; i < dip_for_drawing->nr_sprites; i++) { - struct sprite_entry *e = curr_sprite_entries + dip_for_drawing->first_sprite_entry + i; - draw_sprites_punt[e->has_attached](e); - } - if (dp_for_drawing->ham_seen) { - int todraw_amiga = res_shift_from_window (visible_right_border - visible_left_border); - init_ham_decoding (); - memset (ham_linebuf + ham_decode_pixel, 0, todraw_amiga * sizeof (uae_u32)); + struct sprite_entry *e = curr_sprite_entries + dip_for_drawing->first_sprite_entry + i; + draw_sprites_punt[e->has_attached](e); } - bplxor = 0; - do_color_changes (pfield_do_fill_line, pfield_do_linetoscr); - bplxor = oxor; - } else { + if (dp_for_drawing->ham_seen) { + int todraw_amiga = res_shift_from_window(visible_right_border - visible_left_border); + init_ham_decoding(); + memset(ham_linebuf + ham_decode_pixel, 0, todraw_amiga * sizeof(uae_u32)); + } + bplxor = 0; + do_color_changes(pfield_do_fill_line, pfield_do_linetoscr); + bplxor = oxor; + } + else { playfield_start = visible_right_border; playfield_end = visible_right_border; @@ -1956,178 +2023,178 @@ static void pfield_draw_line (int lineno, int gfx_ypos) } } -static void center_image (void) +static void center_image(void) { int deltaToBorder; - deltaToBorder = (gfxvidinfo.outwidth >> currprefs.gfx_resolution) - 320; + deltaToBorder = (gfxvidinfo.outwidth >> currprefs.gfx_resolution) - 320; visible_left_border = 73 - (deltaToBorder >> 1); visible_right_border = 393 + (deltaToBorder >> 1); - if(gfxvidinfo.outwidth > 600) - linetoscr_x_adjust_bytes = (visible_left_border * gfxvidinfo.pixbytes) << 1; + if (gfxvidinfo.outwidth > 600) + linetoscr_x_adjust_bytes = (visible_left_border * gfxvidinfo.pixbytes) << 1; else - linetoscr_x_adjust_bytes = visible_left_border * gfxvidinfo.pixbytes; + linetoscr_x_adjust_bytes = visible_left_border * gfxvidinfo.pixbytes; - thisframe_y_adjust = minfirstline; + thisframe_y_adjust = minfirstline; - thisframe_y_adjust_real = thisframe_y_adjust + currprefs.pandora_vertical_offset + OFFSET_Y_ADJUST; - max_ypos_thisframe = (maxvpos_display - thisframe_y_adjust); + thisframe_y_adjust_real = thisframe_y_adjust + currprefs.pandora_vertical_offset + OFFSET_Y_ADJUST; + max_ypos_thisframe = (maxvpos_display - thisframe_y_adjust); } -static void init_drawing_frame (void) +static void init_drawing_frame(void) { - init_hardware_for_drawing_frame (); + init_hardware_for_drawing_frame(); - linestate_first_undecided = 0; + linestate_first_undecided = 0; - center_image (); + center_image(); - drawing_color_matches = -1; + drawing_color_matches = -1; } -static void draw_status_line (int line, int statusy) +static void draw_status_line(int line, int statusy) { - uae_u8 *buf; + uae_u8 *buf; - xlinebuffer = row_map[line]; - buf = xlinebuffer; - draw_status_line_single (buf, statusy, gfxvidinfo.outwidth); + xlinebuffer = row_map[line]; + buf = xlinebuffer; + draw_status_line_single(buf, statusy, gfxvidinfo.outwidth); } -static void finish_drawing_frame (void) +static void finish_drawing_frame(void) { int i; lockscr(); - if(gfxvidinfo.outwidth > 600) + if (gfxvidinfo.outwidth > 600) { - if(aga_mode) - pfield_do_linetoscr=(line_draw_func)pfield_do_linetoscr_0_640_AGA; - else - pfield_do_linetoscr=(line_draw_func)pfield_do_linetoscr_0_640; - pfield_do_fill_line=(line_draw_func)pfield_do_fill_line_0_640; + if (aga_mode) + pfield_do_linetoscr = (line_draw_func)pfield_do_linetoscr_0_640_AGA; + else + pfield_do_linetoscr = (line_draw_func)pfield_do_linetoscr_0_640; + pfield_do_fill_line = (line_draw_func)pfield_do_fill_line_0_640; } else { - if(aga_mode) - pfield_do_linetoscr=(line_draw_func)pfield_do_linetoscr_0_AGA; - else - pfield_do_linetoscr=(line_draw_func)pfield_do_linetoscr_0; - pfield_do_fill_line=(line_draw_func)pfield_do_fill_line_0; + if (aga_mode) + pfield_do_linetoscr = (line_draw_func)pfield_do_linetoscr_0_AGA; + else + pfield_do_linetoscr = (line_draw_func)pfield_do_linetoscr_0; + pfield_do_fill_line = (line_draw_func)pfield_do_fill_line_0; } for (i = 0; i < max_ypos_thisframe && i < gfxvidinfo.outheight; i++) { int line = i + thisframe_y_adjust_real; - if(line >= linestate_first_undecided) + if (line >= linestate_first_undecided) break; - pfield_draw_line (line, i); + pfield_draw_line(line, i); } if (currprefs.leds_on_screen) { for (i = 0; i < TD_TOTAL_HEIGHT; i++) { int line = gfxvidinfo.outheight - TD_TOTAL_HEIGHT + i; - draw_status_line (line, i); + draw_status_line(line, i); } } - do_flush_screen (); + do_flush_screen(); } -STATIC_INLINE void check_picasso (void) +STATIC_INLINE void check_picasso(void) { #ifdef PICASSO96 - if (picasso_requested_on == picasso_on) - return; - picasso_on = picasso_requested_on; + if (picasso_requested_on == picasso_on) + return; + picasso_on = picasso_requested_on; - if (!picasso_on) - clear_inhibit_frame (IHF_PICASSO); - else - set_inhibit_frame (IHF_PICASSO); + if (!picasso_on) + clear_inhibit_frame(IHF_PICASSO); + else + set_inhibit_frame(IHF_PICASSO); - gfx_set_picasso_state (picasso_on); - picasso_enablescreen (picasso_requested_on); + gfx_set_picasso_state(picasso_on); + picasso_enablescreen(picasso_requested_on); - notice_new_xcolors (); - count_frame (); + notice_new_xcolors(); + count_frame(); #endif } -void vsync_handle_check (void) +void vsync_handle_check(void) { - int changed = check_prefs_changed_gfx (); - if (changed) { - reset_drawing (); - notice_new_xcolors (); - } - check_prefs_changed_cd (); - check_prefs_changed_audio (); - check_prefs_changed_custom (); - check_prefs_changed_cpu (); - check_picasso (); + int changed = check_prefs_changed_gfx(); + if (changed) { + reset_drawing(); + notice_new_xcolors(); + } + check_prefs_changed_cd(); + check_prefs_changed_audio(); + check_prefs_changed_custom(); + check_prefs_changed_cpu(); + check_picasso(); } -void vsync_handle_redraw (void) +void vsync_handle_redraw(void) { if (framecnt == 0) { - finish_drawing_frame (); + finish_drawing_frame(); } if (quit_program < 0) { quit_program = -quit_program; - set_inhibit_frame (IHF_QUIT_PROGRAM); + set_inhibit_frame(IHF_QUIT_PROGRAM); set_special(SPCFLAG_BRK | SPCFLAG_MODE_CHANGE); return; } - count_frame (); + count_frame(); if (framecnt == 0) - init_drawing_frame (); + init_drawing_frame(); - gui_flicker_led (-1, 0, 0); + gui_flicker_led(-1, 0, 0); } -void hsync_record_line_state (int lineno) +void hsync_record_line_state(int lineno) { - if (framecnt != 0) - return; + if (framecnt != 0) + return; - linestate_first_undecided = lineno + 1; + linestate_first_undecided = lineno + 1; } -void reset_drawing (void) +void reset_drawing(void) { - lores_reset (); + lores_reset(); - linestate_first_undecided = 0; + linestate_first_undecided = 0; - init_aspect_maps (); + init_aspect_maps(); - init_row_map(); + init_row_map(); - memset(spixels, 0, sizeof spixels); - memset(&spixstate, 0, sizeof spixstate); + memset(spixels, 0, sizeof spixels); + memset(&spixstate, 0, sizeof spixstate); - init_drawing_frame (); + init_drawing_frame(); } -void drawing_init (void) +void drawing_init(void) { - gen_pfield_tables(); + gen_pfield_tables(); #ifdef PICASSO96 - if (!isrestore ()) { - picasso_on = 0; - picasso_requested_on = 0; - gfx_set_picasso_state (0); - } + if (!isrestore()) { + picasso_on = 0; + picasso_requested_on = 0; + gfx_set_picasso_state(0); + } #endif - xlinebuffer = gfxvidinfo.bufmem; - inhibit_frame = 0; + xlinebuffer = gfxvidinfo.bufmem; + inhibit_frame = 0; - reset_drawing (); + reset_drawing(); } diff --git a/src/include/drawing.h b/src/include/drawing.h index 4d0912ee..b9219e67 100644 --- a/src/include/drawing.h +++ b/src/include/drawing.h @@ -23,26 +23,26 @@ #define lores_shift 0 extern bool aga_mode; -STATIC_INLINE int coord_hw_to_window_x (int x) +STATIC_INLINE int coord_hw_to_window_x(int x) { - x -= DISPLAY_LEFT_SHIFT; + x -= DISPLAY_LEFT_SHIFT; return x; } -STATIC_INLINE int coord_window_to_hw_x (int x) +STATIC_INLINE int coord_window_to_hw_x(int x) { - return x + DISPLAY_LEFT_SHIFT; + return x + DISPLAY_LEFT_SHIFT; } -STATIC_INLINE int coord_diw_to_window_x (int x) +STATIC_INLINE int coord_diw_to_window_x(int x) { return (x - DISPLAY_LEFT_SHIFT + DIW_DDF_OFFSET - 1); } -STATIC_INLINE int coord_window_to_diw_x (int x) +STATIC_INLINE int coord_window_to_diw_x(int x) { - x = coord_window_to_hw_x (x); - return x - DIW_DDF_OFFSET; + x = coord_window_to_hw_x(x); + return x - DIW_DDF_OFFSET; } extern int framecnt; @@ -54,9 +54,9 @@ extern int framecnt; * !!! See color_reg_xxx functions below before touching !!! */ struct color_entry { - uae_u16 color_regs_ecs[32]; - xcolnr acolors[256]; - uae_u32 color_regs_aga[256]; + uae_u16 color_regs_ecs[32]; + xcolnr acolors[256]; + uae_u32 color_regs_aga[256]; bool borderblank, bordersprite; }; @@ -68,19 +68,20 @@ struct color_entry { #else STATIC_INLINE uae_u16 CONVERT_RGB(uae_u32 c) { - uae_u16 ret; - __asm__ ( - "ubfx r1, %[c], #19, #5 \n\t" - "ubfx r2, %[c], #10, #6 \n\t" - "ubfx %[v], %[c], #3, #5 \n\t" - "orr %[v], %[v], r1, lsl #11 \n\t" - "orr %[v], %[v], r2, lsl #5 \n\t" - : [v] "=r" (ret) : [c] "r" (c) : "r1", "r2" ); - return ret; + uae_u16 ret; + __asm__( + "ubfx r1, %[c], #19, #5 \n\t" + "ubfx r2, %[c], #10, #6 \n\t" + "ubfx %[v], %[c], #3, #5 \n\t" + "orr %[v], %[v], r1, lsl #11 \n\t" + "orr %[v], %[v], r2, lsl #5 \n\t" + : [v] "=r" (ret) : [c] "r" (c) : "r1", + "r2"); + return ret; } #endif -STATIC_INLINE xcolnr getxcolor (int c) +STATIC_INLINE xcolnr getxcolor(int c) { if (aga_mode) return CONVERT_RGB(c); @@ -89,7 +90,7 @@ STATIC_INLINE xcolnr getxcolor (int c) } /* functions for reading, writing, copying and comparing struct color_entry */ -STATIC_INLINE int color_reg_get (struct color_entry *ce, int c) +STATIC_INLINE int color_reg_get(struct color_entry *ce, int c) { if (aga_mode) return ce->color_regs_aga[c]; @@ -97,7 +98,7 @@ STATIC_INLINE int color_reg_get (struct color_entry *ce, int c) return ce->color_regs_ecs[c]; } -STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v) +STATIC_INLINE void color_reg_set(struct color_entry *ce, int c, int v) { if (aga_mode) ce->color_regs_aga[c] = v; @@ -106,15 +107,15 @@ STATIC_INLINE void color_reg_set (struct color_entry *ce, int c, int v) } /* ugly copy hack, is there better solution? */ -STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *src) +STATIC_INLINE void color_reg_cpy(struct color_entry *dst, struct color_entry *src) { dst->borderblank = src->borderblank; - if (aga_mode) - /* copy acolors and color_regs_aga */ - memcpy (dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32); - else - /* copy first 32 acolors and color_regs_ecs */ - memcpy(dst->color_regs_ecs, src->color_regs_ecs, sizeof(uae_u16) * 32 + sizeof(xcolnr) * 32); + if (aga_mode) + /* copy acolors and color_regs_aga */ + memcpy(dst->acolors, src->acolors, sizeof(struct color_entry) - sizeof(uae_u16) * 32); + else + /* copy first 32 acolors and color_regs_ecs */ + memcpy(dst->color_regs_ecs, src->color_regs_ecs, sizeof(uae_u16) * 32 + sizeof(xcolnr) * 32); } /* @@ -128,9 +129,9 @@ STATIC_INLINE void color_reg_cpy (struct color_entry *dst, struct color_entry *s #define COLOR_CHANGE_BRDBLANK 0x80000000 struct color_change { - int linepos; - int regno; - unsigned int value; + int linepos; + int regno; + unsigned int value; }; /* 440 rather than 880, since sprites are always lores. */ @@ -143,15 +144,15 @@ struct color_change { struct sprite_entry { - unsigned short pos; - unsigned short max; - unsigned int first_pixel; - bool has_attached; + unsigned short pos; + unsigned short max; + unsigned int first_pixel; + bool has_attached; }; union sps_union { - uae_u8 bytes[MAX_SPR_PIXELS]; - uae_u32 words[MAX_SPR_PIXELS / 4]; + uae_u8 bytes[MAX_SPR_PIXELS]; + uae_u32 words[MAX_SPR_PIXELS / 4]; }; extern union sps_union spixstate; @@ -170,26 +171,26 @@ extern struct draw_info curr_drawinfo[2 * (MAXVPOS + 2) + 1]; * comparison (smart update stuff). */ struct decision { /* Records the leftmost access of BPL1DAT. */ - int plfleft, plfright, plflinelen; - /* Display window: native coordinates, depend on lores state. */ - int diwfirstword, diwlastword; - int ctable; + int plfleft, plfright, plflinelen; + /* Display window: native coordinates, depend on lores state. */ + int diwfirstword, diwlastword; + int ctable; - uae_u16 bplcon0, bplcon2; - uae_u16 bplcon3, bplcon4; - uae_u8 nr_planes; - uae_u8 bplres; - bool ham_seen; - bool ham_at_start; + uae_u16 bplcon0, bplcon2; + uae_u16 bplcon3, bplcon4; + uae_u8 nr_planes; + uae_u8 bplres; + bool ham_seen; + bool ham_at_start; bool bordersprite_seen; }; /* Anything related to changes in hw registers during the DDF for one * line. */ struct draw_info { - int first_sprite_entry, last_sprite_entry; - int first_color_change, last_color_change; - int nr_color_changes, nr_sprites; + int first_sprite_entry, last_sprite_entry; + int first_color_change, last_color_change; + int nr_color_changes, nr_sprites; }; extern struct decision line_decisions[2 * (MAXVPOS + 2) + 1]; @@ -197,17 +198,17 @@ extern struct decision line_decisions[2 * (MAXVPOS + 2) + 1]; extern uae_u8 line_data[(MAXVPOS + 2) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2]; /* Functions in drawing.c. */ -extern int coord_native_to_amiga_y (int); -extern int coord_native_to_amiga_x (int); +extern int coord_native_to_amiga_y(int); +extern int coord_native_to_amiga_x(int); -extern void hsync_record_line_state (int lineno); -extern void vsync_handle_redraw (void); -extern void vsync_handle_check (void); -extern void init_hardware_for_drawing_frame (void); -extern void reset_drawing (void); -extern void drawing_init (void); +extern void hsync_record_line_state(int lineno); +extern void vsync_handle_redraw(void); +extern void vsync_handle_check(void); +extern void init_hardware_for_drawing_frame(void); +extern void reset_drawing(void); +extern void drawing_init(void); -extern unsigned long time_per_frame; +extern long time_per_frame; extern void adjust_idletime(long ns_waited); /* Finally, stuff that shouldn't really be shared. */ @@ -218,15 +219,15 @@ extern void adjust_idletime(long ns_waited); extern int inhibit_frame; -STATIC_INLINE void set_inhibit_frame (int bit) +STATIC_INLINE void set_inhibit_frame(int bit) { - inhibit_frame |= 1 << bit; + inhibit_frame |= 1 << bit; } -STATIC_INLINE void clear_inhibit_frame (int bit) +STATIC_INLINE void clear_inhibit_frame(int bit) { - inhibit_frame &= ~(1 << bit); + inhibit_frame &= ~(1 << bit); } -STATIC_INLINE void toggle_inhibit_frame (int bit) +STATIC_INLINE void toggle_inhibit_frame(int bit) { - inhibit_frame ^= 1 << bit; + inhibit_frame ^= 1 << bit; } diff --git a/src/od-rasp/rasp_gfx.cpp b/src/od-rasp/rasp_gfx.cpp index dac4aed2..180152f7 100644 --- a/src/od-rasp/rasp_gfx.cpp +++ b/src/od-rasp/rasp_gfx.cpp @@ -4,7 +4,7 @@ #include "uae.h" #include "options.h" #include "gui.h" -#include "include/memory.h" +#include "memory.h" #include "newcpu.h" #include "inputdevice.h" #include "custom.h" @@ -42,7 +42,7 @@ int screen_is_picasso = 0; static int curr_layer_width = 0; -static char screenshot_filename_default[255] = { +static char screenshot_filename_default[255] = { '/', 't', 'm', @@ -65,10 +65,12 @@ static int save_thumb(char *path); int delay_savestate_frame = 0; int DispManXElementpresent = 0; + static long next_synctime = 0; uae_sem_t vsync_wait_sem; + DISPMANX_DISPLAY_HANDLE_T dispmanxdisplay; DISPMANX_MODEINFO_T dispmanxdinfo; DISPMANX_RESOURCE_HANDLE_T dispmanxresource_amigafb_1; @@ -80,26 +82,28 @@ VC_RECT_T dst_rect; VC_RECT_T blit_rect; unsigned char current_resource_amigafb = 0; + unsigned char need_wait_dispmanx_semaphore = 0; long start; + void vsync_callback(unsigned int a, void* b) { - uae_sem_post(&vsync_wait_sem); - // Here we are synchronized with VSync - // next_synctime is what we were expected as sync time. + // Here we are synchronized with VSync + // next_synctime is what we were expected as sync time. last_synctime = read_processor_time(); - // check if we miss a frame (with a margin of 1000 cycles) + // Check if we miss a frame (with a margin of 1000 cycles) if (last_synctime - next_synctime > time_per_frame * (1 + currprefs.gfx_framerate) - (long)1000) adjust_idletime(-1); else adjust_idletime(last_synctime - start); - // Update next synctime with current sync + // Update next synctime with current sync. next_synctime = last_synctime + time_per_frame * (1 + currprefs.gfx_framerate); - + uae_sem_post(&vsync_wait_sem); } + int graphics_setup(void) { #ifdef PICASSO96 @@ -110,9 +114,10 @@ int graphics_setup(void) return 1; } + void InitAmigaVidMode(struct uae_prefs *p) { - /* Initialize structure for Amiga video modes */ + /* Initialize structure for Amiga video modes */ gfxvidinfo.pixbytes = 2; gfxvidinfo.bufmem = (uae_u8 *)prSDLScreen->pixels; gfxvidinfo.outwidth = p->gfx_size.width; @@ -124,7 +129,7 @@ void InitAmigaVidMode(struct uae_prefs *p) //gfxvidinfo.outheight = picasso_vidinfo.height; } #endif - //gfxvidinfo.rowbytes = prSDLScreen->pitch; + //gfxvidinfo.rowbytes = prSDLScreen->pitch; gfxvidinfo.rowbytes = blit_rect.width * 2; } @@ -139,23 +144,30 @@ void graphics_dispmanshutdown(void) } } + void graphics_subshutdown(void) { if (dispmanxresource_amigafb_1 != 0) graphics_dispmanshutdown(); - // Dunno if below lines are usefull for Rpi... - //SDL_FreeSurface(prSDLScreen); - //prSDLScreen = NULL; + // Dunno if below lines are usefull for Rpi... + //SDL_FreeSurface(prSDLScreen); + //prSDLScreen = NULL; } + + + + static void open_screen(struct uae_prefs *p) { + VC_DISPMANX_ALPHA_T alpha = { - (DISPMANX_FLAGS_ALPHA_T)(DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), + (DISPMANX_FLAGS_ALPHA_T)(DISPMANX_FLAGS_ALPHA_FROM_SOURCE | DISPMANX_FLAGS_ALPHA_FIXED_ALL_PIXELS), 255, /*alpha 0->255*/ 0 }; + uint32_t vc_image_ptr; int width; int height; @@ -174,33 +186,30 @@ static void open_screen(struct uae_prefs *p) height = p->gfx_size.height; } - //if(prSDLScreen != NULL) - //{ - // SDL_FreeSurface(prSDLScreen); - // prSDLScreen = NULL; - //} + + //if(prSDLScreen != NULL) + //{ + // SDL_FreeSurface(prSDLScreen); + // prSDLScreen = NULL; + //} if (Dummy_prSDLScreen == NULL) { const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo(); -#ifdef DEBUG printf("DispmanX: Current resolution: %d x %d %d bpp\n", videoInfo->current_w, videoInfo->current_h, videoInfo->vfmt->BitsPerPixel); -#endif - // For debug, in order to avoid full screen. + // For debug, in order to avoid full screen. Dummy_prSDLScreen = SDL_SetVideoMode(videoInfo->current_w, videoInfo->current_h, 16, SDL_SWSURFACE | SDL_FULLSCREEN); //Dummy_prSDLScreen = SDL_SetVideoMode(800,480,16,SDL_SWSURFACE ); } SDL_ShowCursor(SDL_DISABLE); - // check if resolution hasn't change in menu. otherwise free the resources so that they will be re-generated with new resolution. - if ((dispmanxresource_amigafb_1 != 0) && - ((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect) || - (currprefs.gfx_fullscreen_ratio != changed_prefs.gfx_fullscreen_ratio))) + // check if resolution hasn't change in menu. otherwise free the resources so that they will be re-generated with new resolution. + if ((dispmanxresource_amigafb_1 != 0) && + ((blit_rect.width != width) || (blit_rect.height != height) || (currprefs.gfx_correct_aspect != changed_prefs.gfx_correct_aspect) || + (currprefs.gfx_fullscreen_ratio != changed_prefs.gfx_fullscreen_ratio))) { -#ifdef DEBUG printf("Emulation resolution change detected.\n"); -#endif if (prSDLScreen != NULL) { SDL_FreeSurface(prSDLScreen); @@ -215,9 +224,7 @@ static void open_screen(struct uae_prefs *p) if (dispmanxresource_amigafb_1 == 0) { -#ifdef DEBUG printf("Emulation resolution: Width %i Height: %i\n", width, height); -#endif currprefs.gfx_correct_aspect = changed_prefs.gfx_correct_aspect; currprefs.gfx_fullscreen_ratio = changed_prefs.gfx_fullscreen_ratio; prSDLScreen = SDL_CreateRGBSurface(SDL_SWSURFACE, @@ -246,7 +253,7 @@ static void open_screen(struct uae_prefs *p) // 16/9 to 4/3 ratio adaptation. if (currprefs.gfx_correct_aspect == 0) { - // Fullscreen. + // Fullscreen. int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio / 100; int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio / 100; vc_dispmanx_rect_set( &dst_rect, @@ -257,7 +264,7 @@ static void open_screen(struct uae_prefs *p) } else { - // 4/3 shrink. + // 4/3 shrink. int scaled_width = dispmanxdinfo.width * currprefs.gfx_fullscreen_ratio / 100; int scaled_height = dispmanxdinfo.height * currprefs.gfx_fullscreen_ratio / 100; vc_dispmanx_rect_set( &dst_rect, @@ -267,11 +274,11 @@ static void open_screen(struct uae_prefs *p) scaled_height); } - // For debug, in order to avoid full screen. - //vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width /2.7), - // 0 , - // (dispmanxdinfo.width - (dispmanxdinfo.width * 6)/100 )/1.5, - // (dispmanxdinfo.height - (dispmanxdinfo.height * 7)/100 )/1.5); + // For debug, in order to avoid full screen. + //vc_dispmanx_rect_set( &dst_rect, (dispmanxdinfo.width /2.7), + // 0 , + // (dispmanxdinfo.width - (dispmanxdinfo.width * 6)/100 )/1.5, + // (dispmanxdinfo.height - (dispmanxdinfo.height * 7)/100 )/1.5); if (DispManXElementpresent == 0) @@ -297,27 +304,29 @@ static void open_screen(struct uae_prefs *p) { InitAmigaVidMode(p); init_row_map(); - } + } //framecnt = 1; // Don't draw frame before reset done } + void update_display(struct uae_prefs *p) { open_screen(p); - + SDL_ShowCursor(SDL_DISABLE); framecnt = 1; // Don't draw frame before reset done } + int check_prefs_changed_gfx(void) { int changed = 0; - + if (currprefs.gfx_size.height != changed_prefs.gfx_size.height || - currprefs.gfx_size.width != changed_prefs.gfx_size.width || - currprefs.gfx_size_fs.width != changed_prefs.gfx_size_fs.width || - currprefs.gfx_resolution != changed_prefs.gfx_resolution) + currprefs.gfx_size.width != changed_prefs.gfx_size.width || + currprefs.gfx_size_fs.width != changed_prefs.gfx_size_fs.width || + currprefs.gfx_resolution != changed_prefs.gfx_resolution) { cfgfile_configuration_change(1); currprefs.gfx_size.height = changed_prefs.gfx_size.height; @@ -328,21 +337,21 @@ int check_prefs_changed_gfx(void) changed = 1; } if (currprefs.leds_on_screen != changed_prefs.leds_on_screen || - currprefs.pandora_hide_idle_led != changed_prefs.pandora_hide_idle_led || - currprefs.pandora_vertical_offset != changed_prefs.pandora_vertical_offset) + currprefs.pandora_hide_idle_led != changed_prefs.pandora_hide_idle_led || + currprefs.pandora_vertical_offset != changed_prefs.pandora_vertical_offset) { currprefs.leds_on_screen = changed_prefs.leds_on_screen; currprefs.pandora_hide_idle_led = changed_prefs.pandora_hide_idle_led; currprefs.pandora_vertical_offset = changed_prefs.pandora_vertical_offset; changed = 1; } - if (currprefs.chipset_refreshrate != changed_prefs.chipset_refreshrate) + if (currprefs.chipset_refreshrate != changed_prefs.chipset_refreshrate) { currprefs.chipset_refreshrate = changed_prefs.chipset_refreshrate; init_hz_full(); changed = 1; } - + return changed; } @@ -361,11 +370,13 @@ void unlockscr(void) void wait_for_vsync(void) { - // Temporary + // Temporary } + void flush_screen() { + //SDL_UnlockSurface (prSDLScreen); if (savestate_state == STATE_DOSAVE) { @@ -379,13 +390,19 @@ void flush_screen() } } + //start = read_processor_time(); + //if(start < next_synctime && next_synctime - start > time_per_frame - 1000) + // usleep((next_synctime - start) - 1000); + //SDL_Flip(prSDLScreen); + if (need_wait_dispmanx_semaphore == 1) { need_wait_dispmanx_semaphore = 0; start = read_processor_time(); - uae_sem_wait(&vsync_wait_sem); + uae_sem_wait(&vsync_wait_sem); } + if (current_resource_amigafb == 1) { current_resource_amigafb = 0; @@ -414,13 +431,13 @@ void flush_screen() vc_dispmanx_update_submit(dispmanxupdate, vsync_callback, NULL); } - need_wait_dispmanx_semaphore = 1; init_row_map(); } + void black_screen_now(void) { SDL_FillRect(prSDLScreen, NULL, 0); @@ -428,6 +445,7 @@ void black_screen_now(void) flush_screen(); } + static void graphics_subinit(void) { if (prSDLScreen == NULL) @@ -445,7 +463,7 @@ static void graphics_subinit(void) STATIC_INLINE int bitsInMask(unsigned long mask) { - /* count bits in mask */ + /* count bits in mask */ int n = 0; while (mask) { @@ -455,9 +473,10 @@ STATIC_INLINE int bitsInMask(unsigned long mask) return n; } + STATIC_INLINE int maskShift(unsigned long mask) { - /* determine how far mask is shifted */ + /* determine how far mask is shifted */ int n = 0; while (!(mask & 1)) { @@ -467,13 +486,14 @@ STATIC_INLINE int maskShift(unsigned long mask) return n; } + static int init_colors(void) { int i; int red_bits, green_bits, blue_bits; int red_shift, green_shift, blue_shift; - /* Truecolor: */ + /* Truecolor: */ red_bits = bitsInMask(prSDLScreen->format->Rmask); green_bits = bitsInMask(prSDLScreen->format->Gmask); blue_bits = bitsInMask(prSDLScreen->format->Bmask); @@ -488,6 +508,7 @@ static int init_colors(void) return 1; } + /* * Find the colour depth of the display */ @@ -496,13 +517,12 @@ static int get_display_depth(void) const SDL_VideoInfo *vid_info; int depth = 0; - if ((vid_info = SDL_GetVideoInfo())) - { + if ((vid_info = SDL_GetVideoInfo())) { depth = vid_info->vfmt->BitsPerPixel; - /* Don't trust the answer if it's 16 bits; the display - * could actually be 15 bits deep. We'll count the bits - * ourselves */ + /* Don't trust the answer if it's 16 bits; the display + * could actually be 15 bits deep. We'll count the bits + * ourselves */ if (depth == 16) depth = bitsInMask(vid_info->vfmt->Rmask) + bitsInMask(vid_info->vfmt->Gmask) + bitsInMask(vid_info->vfmt->Bmask); } @@ -515,13 +535,14 @@ int GetSurfacePixelFormat(void) int unit = (depth + 1) & 0xF8; return (unit == 8 ? RGBFB_CHUNKY - : depth == 15 && unit == 16 ? RGBFB_R5G5B5 - : depth == 16 && unit == 16 ? RGBFB_R5G6B5 - : unit == 24 ? RGBFB_B8G8R8 - : unit == 32 ? RGBFB_R8G8B8A8 - : RGBFB_NONE); + : depth == 15 && unit == 16 ? RGBFB_R5G5B5 + : depth == 16 && unit == 16 ? RGBFB_R5G6B5 + : unit == 24 ? RGBFB_B8G8R8 + : unit == 32 ? RGBFB_R8G8B8A8 + : RGBFB_NONE); } + int graphics_init(bool mousecapture) { int i, j; @@ -530,12 +551,13 @@ int graphics_init(bool mousecapture) graphics_subinit(); + if (!init_colors()) return 0; - //buttonstate[0] = buttonstate[1] = buttonstate[2] = 0; - //keyboard_init(); - + //buttonstate[0] = buttonstate[1] = buttonstate[2] = 0; + //keyboard_init(); + return 1; } @@ -547,6 +569,7 @@ void graphics_leave(void) SDL_VideoQuit(); } + #define systemRedShift (prSDLScreen->format->Rshift) #define systemGreenShift (prSDLScreen->format->Gshift) #define systemBlueShift (prSDLScreen->format->Bshift) @@ -566,16 +589,14 @@ static int save_png(SDL_Surface* surface, char *path) NULL, NULL, NULL); - if (!png_ptr) - { + if (!png_ptr) { fclose(f); return 0; } png_infop info_ptr = png_create_info_struct(png_ptr); - if (!info_ptr) - { + if (!info_ptr) { png_destroy_write_struct(&png_ptr, NULL); fclose(f); return 0; @@ -603,14 +624,14 @@ static int save_png(SDL_Surface* surface, char *path) int x; unsigned short *p = (unsigned short *)pix; - for (y = 0; y < sizeY; y++) + for (y = 0; y < sizeY; y++) { - for (x = 0; x < sizeX; x++) + for (x = 0; x < sizeX; x++) { unsigned short v = p[x]; - + *b++ = ((v & systemRedMask) >> systemRedShift) << 3; // R - *b++ = ((v & systemGreenMask) >> systemGreenShift) << 2; // G + *b++ = ((v & systemGreenMask) >> systemGreenShift) << 2; // G *b++ = ((v & systemBlueMask) >> systemBlueShift) << 3; // B } p += surface->pitch / 2; @@ -626,6 +647,7 @@ static int save_png(SDL_Surface* surface, char *path) return 1; } + static void CreateScreenshot(void) { int w, h; @@ -649,6 +671,7 @@ static void CreateScreenshot(void) prSDLScreen->format->Amask); } + static int save_thumb(char *path) { int ret = 0; @@ -661,114 +684,25 @@ static int save_thumb(char *path) return ret; } -bool vsync_switchmode(int hz) -{ - int changed_height = changed_prefs.gfx_size.height; - - if (hz >= 55) - hz = 60; - else - hz = 50; - - if (hz == 50 && currVSyncRate == 60) - { - // Switch from NTSC -> PAL - switch (changed_height) - { - case 200: - changed_height = 240; - break; - case 216: - changed_height = 262; - break; - case 240: - changed_height = 270; - break; - case 256: - changed_height = 270; - break; - case 262: - changed_height = 270; - break; - case 270: - changed_height = 270; - break; - } - } - else if (hz == 60 && currVSyncRate == 50) - { - // Switch from PAL -> NTSC - switch (changed_height) - { - case 200: - changed_height = 200; - break; - case 216: - changed_height = 200; - break; - case 240: - changed_height = 200; - break; - case 256: - changed_height = 216; - break; - case 262: - changed_height = 216; - break; - case 270: - changed_height = 240; - break; - } - } - - if (changed_height == currprefs.gfx_size.height && hz == currprefs.chipset_refreshrate) - return true; - - changed_prefs.gfx_size.height = changed_height; - - return true; -} - -bool target_graphics_buffer_update(void) -{ - bool rate_changed = 0; - //bool rate_changed = SetVSyncRate(currprefs.chipset_refreshrate); - - if (currprefs.gfx_size.height != changed_prefs.gfx_size.height) - { - update_display(&changed_prefs); - rate_changed = true; - } - - if (rate_changed) - { - black_screen_now(); - fpscounter_reset(); - time_per_frame = 1000 * 1000 / (currprefs.chipset_refreshrate); - } - - return true; -} #ifdef PICASSO96 + int picasso_palette(void) { int i, changed; changed = 0; - for (i = 0; i < 256; i++) - { + for (i = 0; i < 256; i++) { int r = picasso96_state.CLUT[i].Red; int g = picasso96_state.CLUT[i].Green; int b = picasso96_state.CLUT[i].Blue; int value = (r << 16 | g << 8 | b); uae_u32 v = CONVERT_RGB(value); - if (v != picasso_vidinfo.clut[i]) - { + if (v != picasso_vidinfo.clut[i]) { picasso_vidinfo.clut[i] = v; changed = 1; - } + } } return changed; } @@ -794,10 +728,8 @@ static void sortmodes(void) while (DisplayModes[i].depth >= 0) i++; qsort(DisplayModes, i, sizeof(struct PicassoResolution), resolution_compare); - for (i = 0; DisplayModes[i].depth >= 0; i++) - { - if (DisplayModes[i].res.height != ph || DisplayModes[i].res.width != pw) - { + for (i = 0; DisplayModes[i].depth >= 0; i++) { + if (DisplayModes[i].res.height != ph || DisplayModes[i].res.width != pw) { ph = DisplayModes[i].res.height; pw = DisplayModes[i].res.width; idx++; @@ -811,12 +743,10 @@ static void modesList(void) int i, j; i = 0; - while (DisplayModes[i].depth >= 0) - { + while (DisplayModes[i].depth >= 0) { write_log("%d: %s (", i, DisplayModes[i].name); j = 0; - while (DisplayModes[i].refresh[j] > 0) - { + while (DisplayModes[i].refresh[j] > 0) { if (j > 0) write_log(","); write_log("%d", DisplayModes[i].refresh[j]); @@ -834,7 +764,7 @@ void picasso_InitResolutions(void) char tmp[200]; int bit_idx; int bits[] = { 8, 16, 32 }; - + Displays[0].primary = 1; Displays[0].disabled = 0; Displays[0].rect.left = 0; @@ -847,17 +777,15 @@ void picasso_InitResolutions(void) md1 = Displays; DisplayModes = md1->DisplayModes = xmalloc(struct PicassoResolution, MAX_PICASSO_MODES); - for (i = 0; i < MAX_SCREEN_MODES && count < MAX_PICASSO_MODES; i++) - { - for (bit_idx = 0; bit_idx < 3; ++bit_idx) - { + for (i = 0; i < MAX_SCREEN_MODES && count < MAX_PICASSO_MODES; i++) { + for (bit_idx = 0; bit_idx < 3; ++bit_idx) { int bitdepth = bits[bit_idx]; int bit_unit = (bitdepth + 1) & 0xF8; int rgbFormat = (bitdepth == 8 ? RGBFB_CLUT : (bitdepth == 16 ? RGBFB_R5G6B5 : RGBFB_R8G8B8A8)); int pixelFormat = 1 << rgbFormat; pixelFormat |= RGBFF_CHUNKY; - - //if (SDL_VideoModeOK (x_size_table[i], y_size_table[i], 16, SDL_SWSURFACE)) + + //if (SDL_VideoModeOK (x_size_table[i], y_size_table[i], 16, SDL_SWSURFACE)) { DisplayModes[count].res.width = x_size_table[i]; DisplayModes[count].res.height = y_size_table[i]; @@ -871,7 +799,7 @@ void picasso_InitResolutions(void) DisplayModes[count].res.width, DisplayModes[count].res.height, DisplayModes[count].depth * 8); - + count++; } } @@ -882,6 +810,74 @@ void picasso_InitResolutions(void) DisplayModes = Displays[0].DisplayModes; } +#endif + +bool vsync_switchmode(int hz) +{ + int changed_height = changed_prefs.gfx_size.height; + + if (hz >= 55) + hz = 60; + else + hz = 50; + + if (hz == 50 && currVSyncRate == 60) + { + // Switch from NTSC -> PAL + switch (changed_height) { + case 200: changed_height = 240; break; + case 216: changed_height = 262; break; + case 240: changed_height = 270; break; + case 256: changed_height = 270; break; + case 262: changed_height = 270; break; + case 270: changed_height = 270; break; + } + } + else if (hz == 60 && currVSyncRate == 50) + { + // Switch from PAL -> NTSC + switch (changed_height) { + case 200: changed_height = 200; break; + case 216: changed_height = 200; break; + case 240: changed_height = 200; break; + case 256: changed_height = 216; break; + case 262: changed_height = 216; break; + case 270: changed_height = 240; break; + } + } + + if (changed_height == currprefs.gfx_size.height && hz == currprefs.chipset_refreshrate) + return true; + + changed_prefs.gfx_size.height = changed_height; + + return true; +} + +bool target_graphics_buffer_update(void) +{ + bool rate_changed = 0; + //bool rate_changed = SetVSyncRate(currprefs.chipset_refreshrate); + + if (currprefs.gfx_size.height != changed_prefs.gfx_size.height) + { + update_display(&changed_prefs); + rate_changed = true; + } + + if (rate_changed) + { + black_screen_now(); + fpscounter_reset(); + time_per_frame = 1000 * 1000 / (currprefs.chipset_refreshrate); + } + + return true; +} + +#ifdef PICASSO96 + + void gfx_set_picasso_state(int on) { if (on == screen_is_picasso) @@ -896,9 +892,9 @@ void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbf { depth >>= 3; if (((unsigned)picasso_vidinfo.width == w) && - ((unsigned)picasso_vidinfo.height == h) && - ((unsigned)picasso_vidinfo.depth == depth) && - (picasso_vidinfo.selected_rgbformat == rgbfmt)) + ((unsigned)picasso_vidinfo.height == h) && + ((unsigned)picasso_vidinfo.depth == depth) && + (picasso_vidinfo.selected_rgbformat == rgbfmt)) return; picasso_vidinfo.selected_rgbformat = rgbfmt; @@ -918,14 +914,14 @@ void gfx_set_picasso_modeinfo(uae_u32 w, uae_u32 h, uae_u32 depth, RGBFTYPE rgbf uae_u8 *gfx_lock_picasso(void) { - // We lock the surface directly after create and flip + // We lock the surface directly after create and flip picasso_vidinfo.rowbytes = prSDLScreen->pitch; return (uae_u8 *)prSDLScreen->pixels; } void gfx_unlock_picasso(void) { - // We lock the surface directly after create and flip, so no unlock here + // We lock the surface directly after create and flip, so no unlock here } #endif // PICASSO96