From ff7af208a198d18e985fb5316e32df88d39f9627 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Mon, 17 Mar 2025 18:47:00 +0200 Subject: [PATCH] Chipset updates --- custom.cpp | 166 +++++++++++++++++++++++++++++----------------- drawing.cpp | 106 ++++++++++++++++------------- events.cpp | 48 +++----------- include/drawing.h | 2 +- 4 files changed, 173 insertions(+), 149 deletions(-) diff --git a/custom.cpp b/custom.cpp index 17c02f80..74b0bf2e 100644 --- a/custom.cpp +++ b/custom.cpp @@ -182,10 +182,12 @@ static evt_t last_rga_cycle; #if CE_MODE_RGA_OPTIMIZATIONS static bool drga_written; static bool fast_mode_ce_not; -static bool drga_bpl, drga_spr; static int fast_mode_strobe_cnt; +#if CE_MODE_RGA_OPTIMIZATIONS > 1 +static bool drga_bpl, drga_spr; static uae_u8 bpl_line_store[256 * 8]; #endif +#endif static void write_drga_strobe(uae_u16 rga) { @@ -227,7 +229,7 @@ static void write_drga_dat_spr(uae_u16 rga, uaecptr pt, uae_u32 v) r->pt = pt; r->flags = 0; r->line = rga_denise_cycle_line; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 drga_spr = true; #endif }; @@ -239,12 +241,12 @@ static void write_drga_dat_spr_wide(uae_u16 rga, uaecptr pt, uae_u64 v) r->pt = pt; r->flags = 0; r->line = rga_denise_cycle_line; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 drga_spr = true; #endif }; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 static uae_u16 *fast_plane_store16[MAX_PLANES]; static uae_u32 *fast_plane_store32[MAX_PLANES]; static uae_u64 *fast_plane_store64[MAX_PLANES]; @@ -258,7 +260,7 @@ static void write_drga_dat_bpl16(uae_u16 rga, uaecptr pt, uae_u16 v, int plane) r->pt = pt; r->flags = 0; r->line = rga_denise_cycle_line; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 if (currprefs.cpu_memory_cycle_exact) { *fast_plane_store16[plane] = v; fast_plane_store16[plane]++; @@ -274,7 +276,7 @@ static void write_drga_dat_bpl32(uae_u16 rga, uaecptr pt, uae_u32 v, int plane) r->pt = pt; r->flags = 0; r->line = rga_denise_cycle_line; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 if (currprefs.cpu_memory_cycle_exact) { *fast_plane_store32[plane] = v; fast_plane_store32[plane]++; @@ -290,7 +292,7 @@ static void write_drga_dat_bpl64(uae_u16 rga, uaecptr pt, uae_u64 v, int plane) r->pt = pt; r->flags = 0; r->line = rga_denise_cycle_line; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 if (currprefs.cpu_memory_cycle_exact) { *fast_plane_store64[plane] = v; fast_plane_store64[plane]++; @@ -685,6 +687,10 @@ static uae_u32 refmask; static int line_disabled; static bool custom_disabled; static int display_hstart_fastmode; +static int color_table_index; +static bool color_table_changed; +#define COLOR_TABLE_ENTRIES 2 +static uae_u8 color_tables[COLOR_TABLE_ENTRIES * 256 * sizeof(uae_u32)]; #define HSYNCTIME (maxhpos * CYCLE_UNIT) @@ -904,22 +910,10 @@ static void setclr(uae_u16 *p, uae_u16 val) } } -STATIC_INLINE bool is_last_line(void) +// is last display line? +static bool is_last_line(void) { - return vpos + 1 == maxvpos + lof_store; -} - -STATIC_INLINE uae_u8 *pfield_xlateptr(uaecptr plpt, int bytecount) -{ - if (!chipmem_check_indirect(plpt, bytecount)) { - static int count = 0; - if (!count) { - count++; - write_log(_T("Warning: Bad playfield pointer %08x\n"), plpt); - } - return NULL; - } - return chipmem_xlate_indirect(plpt); + return vpos == vsync_startline || vpos + 1 == vsync_startline; } static void docols(struct color_entry *colentry) @@ -941,6 +935,7 @@ static void docols(struct color_entry *colentry) #endif } +// 141 is largest hardwired hpos comparison position. #define HW_HPOS_TABLE_MAX 142 static bool hw_hpos_table[HW_HPOS_TABLE_MAX]; static uae_u8 prg_hpos_table[256]; @@ -1260,6 +1255,7 @@ static void update_mirrors(void) } struct vidbuf_description *vidinfo = &adisplays[0].gfxvidinfo; lineoptimizations_allowed = vidinfo->inbuffer == vidinfo->outbuffer && !lightpen_active; + color_table_changed = true; } void notice_new_xcolors(void) @@ -2186,7 +2182,6 @@ void init_hz(void) isntsc = currprefs.ntscmode ? 1 : 0; } - if ((beamcon0 & (BEAMCON0_VARBEAMEN | BEAMCON0_PAL)) != (new_beamcon0 & (BEAMCON0_VARBEAMEN | BEAMCON0_PAL))) { hzc = 1; } @@ -3199,7 +3194,7 @@ static void DMACON(int hpos, uae_u16 v) if (changed & (DMA_MASTER | DMA_AUD3 | DMA_AUD2 | DMA_AUD1 | DMA_AUD0)) { audio_state_machine(); } -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 if (changed & (DMA_MASTER | DMA_BITPLANE | DMA_COPPER)) { fast_mode_ce_not = true; } @@ -3582,14 +3577,14 @@ void set_picasso_hack_rate(int hz) static void BPLxPTH(uae_u16 v, int num) { bplpt[num] = (bplpt[num] & 0x0000ffff) | ((uae_u32)v << 16); -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } static void BPLxPTL(uae_u16 v, int num) { bplpt[num] = (bplpt[num] & 0xffff0000) | (v & 0x0000fffe); -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3625,6 +3620,9 @@ static void BPLCON0_delayed(uae_u32 va) } checksyncstopped(va); + + color_table_changed = true; + #if CE_MODE_RGA_OPTIMIZATIONS fast_mode_ce_not = true; #endif @@ -3668,7 +3666,7 @@ static void BPLCON1(uae_u16 v) #endif bplcon1_saved = v; bplcon1 = v; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3676,7 +3674,7 @@ static void BPLCON2(uae_u16 v) { bplcon2_saved = v; bplcon2 = v; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3684,6 +3682,9 @@ static void BPLCON3(uae_u16 v) { bplcon3_saved = v; bplcon3 = v; + if (aga_mode) { + color_table_changed = true; + } #if CE_MODE_RGA_OPTIMIZATIONS fast_mode_ce_not = true; #endif @@ -3701,7 +3702,7 @@ static void BPL1MOD(uae_u16 v) { v &= ~1; bpl1mod = v; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3709,7 +3710,7 @@ static void BPL2MOD(uae_u16 v) { v &= ~1; bpl2mod = v; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3779,7 +3780,7 @@ static void DDFSTRT(uae_u16 v) v &= ddf_mask; ddfstrt = 0xffff; push_pipeline(&ddfstrt, v); -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3790,7 +3791,7 @@ static void DDFSTOP(uae_u16 v) ddfstop_saved = v; v &= ddf_mask; push_pipeline(&ddfstop, v); -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -3812,7 +3813,7 @@ static void FMODE(uae_u16 v) } set_chipset_mode(false); setup_fmodes(bplcon0); -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 fast_mode_ce_not = true; #endif } @@ -4252,8 +4253,8 @@ static uae_u16 COLOR_READ(int num) static void COLOR_WRITE(uae_u16 v, int num) { if (aga_mode) { - if (!aga_mode || (bplcon2 & 0x0100)) { - return; + if (bplcon2 & 0x0100) { + return; // RDRAM=1 } int colreg = ((bplcon3 >> 13) & 7) * 32 + num; @@ -4289,6 +4290,8 @@ static void COLOR_WRITE(uae_u16 v, int num) agnus_colors.color_regs_aga[num] = agnus_colors.acolors[num]; } + + color_table_changed = true; } #endif @@ -5228,6 +5231,15 @@ static void handle_nosignal(void) } } +static void virtual_vsync_check(void) +{ + check_display_mode_change(); + check_interlace(); + handle_nosignal(); + vsync_check_vsyncmode(); + color_table_changed = true; +} + // emulated hardware vsync static void vsync_handler_post(void) { @@ -5270,17 +5282,10 @@ static void vsync_handler_post(void) devices_vsync_post(); - check_display_mode_change(); - - check_interlace(); - vsync_check_vsyncmode(); - if (bogusframe > 0) { bogusframe--; } - handle_nosignal(); - config_check_vsync(); if (timehack_alive > 0) { timehack_alive--; @@ -6347,10 +6352,10 @@ static void hsync_handler_post(bool onvsync) events_reset_syncline(); if (vsync_isdone(NULL) <= 0 && !currprefs.turbo_emulation && (linecounter & (maxlc - 1)) == 0) { if (vsyncmaxtime - vsyncmintime > 0) { + frame_time_t rpt = read_processor_time(); if (vsyncwaittime - vsyncmintime > 0) { - frame_time_t rpt = read_processor_time(); /* Extra time left? Do some extra CPU emulation */ - if (vsyncmintime - rpt > 0) { + if (vsyncmintime > rpt) { if (regs.stopped && currprefs.cpu_idle && sleeps_remaining > 0) { // STOP STATE: sleep. cpu_sleep_millis(1); @@ -6360,9 +6365,18 @@ static void hsync_handler_post(bool onvsync) is_syncline = -11; /* limit extra time */ is_syncline_end = rpt + vsynctimeperline * maxlc; + linecounter = 0; } } } + if (!isvsync()) { + // extra cpu emulation time if previous 10 lines without extra time. + if (!is_syncline && linecounter >= 10 && (!regs.stopped || !currprefs.cpu_idle)) { + is_syncline = -10; + is_syncline_end = rpt + vsynctimeperline; + linecounter = 0; + } + } } } maybe_process_pull_audio(); @@ -6565,7 +6579,7 @@ void custom_reset(bool hardreset, bool keyboardreset) rga_denise_cycle_start = 0; rga_denise_cycle_count = 0; rga_denise_cycle_line = 1; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 for (int i = 0; i < MAX_PLANES; i++) { fast_plane_store16[i] = (uae_u16*)bpl_line_store; fast_plane_store32[i] = (uae_u32*)bpl_line_store; @@ -10465,15 +10479,18 @@ static int getlinetype(void) if (currprefs.cpu_memory_cycle_exact) { if (get_strobe_reg(0) != 0x3c) { type = LINETYPE_BLANK; - } else if (!drga_bpl) { + } else if (vdiwstate == diw_states::DIW_waiting_start || GET_PLANES(bplcon0) == 0 || !dmaen(DMA_BITPLANE)) { if ((bplcon0 & 1) && (bplcon3 & 0x20)) { type = LINETYPE_BLANK; } else { type = LINETYPE_BORDER; } - } else if (drga_bpl && ddfstop > ddfstrt && ddfstrt >= 0x14 && GET_RES_AGNUS(bplcon0) == GET_RES_DENISE(bplcon0) && dmaen(DMA_BITPLANE)) { + } +#if CE_MODE_RGA_OPTIMIZATIONS > 1 + else if (drga_bpl && ddfstop > ddfstrt && ddfstrt >= 0x14 && GET_RES_AGNUS(bplcon0) == GET_RES_DENISE(bplcon0) && dmaen(DMA_BITPLANE)) { type = LINETYPE_BPL; } +#endif } else #endif { @@ -10559,6 +10576,8 @@ static int checkprevfieldlinestateequalbpl(struct linestate *l, bool dontaddbpl) if (l->bplcon1 != (bplcon1 & bc1mask)) { return -1; } + return -1; +#if 0 // compare bpl data uae_u8 *dpt = l->linedatastate; int planes = GET_PLANES(bplcon0); @@ -10599,6 +10618,7 @@ static int checkprevfieldlinestateequalbpl(struct linestate *l, bool dontaddbpl) } } return 1; +#endif } return 0; } @@ -10636,7 +10656,7 @@ static bool draw_line_fast(struct linestate *l, int ldv) } int colors = getcolorcount(planes); int len = l->bpllen; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 if (currprefs.cpu_memory_cycle_exact) { for (int i = 0; i < planes; i++) { uae_u8 *pt = bpl_line_store + i * 256; @@ -10650,12 +10670,22 @@ static bool draw_line_fast(struct linestate *l, int ldv) l->bplpt[i] = get_real_address(pt); } } - l->colors = colors; - uae_u8 *dpt = l->linecolorstate; - if (aga_mode) { - memcpy(dpt, agnus_colors.color_regs_aga, colors * sizeof(uae_u32)); + if (color_table_changed) { + draw_denise_line_queue_flush(); + color_table_index++; + if (color_table_index >= COLOR_TABLE_ENTRIES) { + color_table_index = 0; + } + l->linecolorstate = color_tables + color_table_index * sizeof(uae_u32); + uae_u8 *dpt = l->linecolorstate; + if (aga_mode) { + memcpy(dpt, agnus_colors.color_regs_aga, colors * sizeof(uae_u32)); + } else { + memcpy(dpt, agnus_colors.color_regs_ecs, colors * sizeof(uae_u16)); + } + color_table_changed = false; } else { - memcpy(dpt, agnus_colors.color_regs_ecs, colors * sizeof(uae_u16)); + l->linecolorstate = color_tables + color_table_index * sizeof(uae_u32); } l->color0 = aga_mode ? agnus_colors.color_regs_aga[0] : agnus_colors.color_regs_ecs[0]; l->bplcon1 = bplcon1 & bc1mask; @@ -10665,7 +10695,6 @@ static bool draw_line_fast(struct linestate *l, int ldv) int dvp = calculate_linetype(ldv); draw_denise_bitplane_line_fast_queue(dvp, nextline_how, l); // advance bpl pointers - len = l->bpllen; for (int i = 0; i < planes; i++) { int mod = getbplmod(i); bplpt[i] += mod + len; @@ -10675,7 +10704,7 @@ static bool draw_line_fast(struct linestate *l, int ldv) static bool draw_always(void) { - if (nextline_how == nln_lower_black_always || nextline_how == nln_upper_black_always || nextline_how == nln_nblack) { + if (nextline_how == nln_lower_black_always || nextline_how == nln_upper_black_always) { return true; } return false; @@ -10760,16 +10789,20 @@ static void storelinestate(void) l->ltsidx = -1; if (l->type == LINETYPE_BPL) { +#if 0 if (!l->linedatastate) { l->linedatastate = xmalloc(uae_u8, MAX_STORED_BPL_DATA_BYTES + 256 * sizeof(uae_u32)); } + l->linecolorstate = l->linedatastate; +#endif int stop = !harddis_h && ddfstop > 0xd8 ? 0xd8 : ddfstop; int len = ((stop - ddfstrt) + fetchunit - 1) / fetchunit + 1; len = len * fetchunit / fetchstart; len <<= 1; - if (len < MAX_STORED_BPL_DATA && l->linedatastate) { + if (len < MAX_STORED_BPL_DATA) { len <<= fetchmode; l->bpllen = len; +#if 0 uae_u8 *dpt = l->linedatastate; int planes = GET_PLANES(bplcon0); for (int i = 0; i < planes; i++) { @@ -10795,6 +10828,7 @@ static void storelinestate(void) } else { memcpy(dpt, agnus_colors.color_regs_ecs, colors * sizeof(uae_u16)); } +#endif } } } @@ -10821,10 +10855,12 @@ static bool draw_line_ce_fast(void) if (c == l->color0) { ret = true; } else if (always|| currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL) { - //ret = draw_border_fast(l, linear_display_vpos); + ret = draw_border_fast(l, linear_display_vpos); } } - } else if (type == LINETYPE_BPL && !l->vb) { + } +#if CE_MODE_RGA_OPTIMIZATIONS > 1 + else if (type == LINETYPE_BPL && !l->vb) { if (1) { int r = checkprevfieldlinestateequalbpl(l, always); if (always || (r < 0 && currprefs.cs_optimizations == DISPLAY_OPTIMIZATIONS_FULL)) { @@ -10834,6 +10870,7 @@ static bool draw_line_ce_fast(void) ret = r > 0; } } +#endif } if (!ret) { l->type = 0; @@ -10846,8 +10883,10 @@ static void clear_fast_mode_ce(void) fast_mode_strobe_cnt = 0; drga_written = false; fast_mode_ce_not = false; +#if CE_MODE_RGA_OPTIMIZATIONS > 1 drga_bpl = false; drga_spr = false; +#endif } #endif @@ -10856,8 +10895,8 @@ static void draw_line(void) int dvp = calculate_linetype(linear_display_vpos); #if CE_MODE_RGA_OPTIMIZATIONS - bool can_fast_ce = 0 && currprefs.cpu_memory_cycle_exact && currprefs.cs_optimizations < DISPLAY_OPTIMIZATIONS_NONE; - if (can_fast_ce && !fast_mode_ce_not && !drga_spr) { + bool can_fast_ce = currprefs.cpu_memory_cycle_exact && currprefs.cs_optimizations < DISPLAY_OPTIMIZATIONS_NONE; + if (can_fast_ce && !fast_mode_ce_not) { if (draw_line_ce_fast()) { clear_fast_mode_ce(); fast_lines_cnt++; @@ -10882,7 +10921,7 @@ static void draw_line(void) l = &lines[linear_vpos][lof_display]; #if CE_MODE_RGA_OPTIMIZATIONS if (can_fast_ce) { - if (!fast_mode_ce_not && !drga_spr) { + if (!fast_mode_ce_not) { storelinestate(); } else { resetlinestate(); @@ -11107,7 +11146,7 @@ static void do_draw_line(void) decide_line_end(); end:; -#if CE_MODE_RGA_OPTIMIZATIONS +#if CE_MODE_RGA_OPTIMIZATIONS > 1 if (currprefs.cpu_memory_cycle_exact) { for (int i = 0; i < MAX_PLANES; i++) { fast_plane_store16[i] = (uae_u16*)(bpl_line_store + i * 256); @@ -11319,6 +11358,7 @@ static void custom_trigger_start_nosync(void) inputdevice_read_msg(true); vsync_display_render(); vsync_display_rendered = false; + virtual_vsync_check(); } } @@ -11363,6 +11403,8 @@ static void custom_trigger_start(void) linear_vpos_prev[0] = linear_vpos; linear_vpos = 0; + virtual_vsync_check(); + if (!custom_disabled) { start_draw_denise(); } diff --git a/drawing.cpp b/drawing.cpp index ef87494c..15567586 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -95,6 +95,8 @@ static volatile bool thread_debug_lock; static void quick_denise_rga(int linecnt, int startpos, int endpos) { int pos = startpos; + endpos++; + endpos &= DENISE_RGA_SLOT_MASK; while (pos != endpos) { struct denise_rga *rd = &rga_denise[pos]; if (rd->line == linecnt && rd->rga != 0x1fe && (rd->rga < 0x38 || rd->rga >= 0x40)) { @@ -5264,6 +5266,14 @@ static void get_line(int gfx_ypos, enum nln_how how) denise_y_end++; } break; + case nln_nblack: + if (gfx_ypos + 1 < vb->inheight) { + uae_u8 *buf = row_map[gfx_ypos + 1]; + buf -= linetoscr_x_adjust_pixbytes; + memset(buf, 0, vb->inwidth * vb->pixbytes); + denise_y_end++; + } + break; } xlinebuffer_genlock = row_map_genlock[gfx_ypos] - linetoscr_x_adjust_pixels; } @@ -5530,7 +5540,7 @@ void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int start ls->bpl1dat_trigger_offset = bpl1dat_trigger_offset; ls->internal_pixel_cnt = internal_pixel_cnt; ls->internal_pixel_start_cnt = internal_pixel_start_cnt; - ls->vb = denise_vblank; + ls->vb = denise_vblank_active; } resolution_count[denise_res]++; @@ -5731,6 +5741,7 @@ static void lts_unaligned_aga(int cnt, int cnt_next, int h) } if (h) { + bplcon4_denise_xor_val = bplcon4_denise_xor_val2; sbasecol[0] = sbasecol2[0]; sbasecol[1] = sbasecol2[1]; @@ -5741,12 +5752,6 @@ static void lts_unaligned_aga(int cnt, int cnt_next, int h) } - } else if (i == 0) { - - if (h) { - bplcon4_denise_xor_val = bplcon4_denise_xor_val2; - } - } if (cnt == denise_hstrt) { @@ -6237,6 +6242,7 @@ STATIC_INLINE void pfield_doline32_8(uae_u32 *pixels, int wordcount, int planes, } } +#if 0 STATIC_INLINE void pfield_doline32_16(uae_u32 *pixels, int wordcount, int planes, uae_u8 *real_bplpt[8]) { while (wordcount-- > 0) { @@ -6464,18 +6470,7 @@ STATIC_INLINE void pfield_doline32_64(uae_u32 *pixels, int wordcount, int planes pixels += 8; } } -/* See above for comments on inlining. These functions should _not_ -be inlined themselves. */ -static void NOINLINE pfield_doline32_n1_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 1, real_bplpt); } -static void NOINLINE pfield_doline32_n2_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 2, real_bplpt); } -static void NOINLINE pfield_doline32_n3_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 3, real_bplpt); } -static void NOINLINE pfield_doline32_n4_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 4, real_bplpt); } -static void NOINLINE pfield_doline32_n5_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 5, real_bplpt); } -static void NOINLINE pfield_doline32_n6_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 6, real_bplpt); } -#ifdef AGA -static void NOINLINE pfield_doline32_n7_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 7, real_bplpt); } -static void NOINLINE pfield_doline32_n8_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 8, real_bplpt); } -#endif + static void NOINLINE pfield_doline32_n1_16(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_16(data, count, 1, real_bplpt); } static void NOINLINE pfield_doline32_n2_16(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_16(data, count, 2, real_bplpt); } static void NOINLINE pfield_doline32_n3_16(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_16(data, count, 3, real_bplpt); } @@ -6505,31 +6500,7 @@ static void NOINLINE pfield_doline32_n7_64(uae_u32 *data, int count, uae_u8 *rea static void NOINLINE pfield_doline32_n8_64(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_64(data, count, 8, real_bplpt); } #endif -static void pfield_doline_8(int planecnt, int wordcount, uae_u8 *datap, struct linestate *ls) -{ - uae_u8 **real_bplpt = ls->bplpt; - uae_u32 *data = (uae_u32*)datap; - uae_u8 *dpt = ls->linedatastate; - int len = ls->bpllen; - for (int i = 0; i < planecnt; i++) { - memcpy(dpt, ls->bplpt[i], len); - dpt += len; - } - switch (planecnt) { - default: break; - case 0: memset(data, 0, wordcount * 32); break; - case 1: pfield_doline32_n1_8(data, wordcount, real_bplpt); break; - case 2: pfield_doline32_n2_8(data, wordcount, real_bplpt); break; - case 3: pfield_doline32_n3_8(data, wordcount, real_bplpt); break; - case 4: pfield_doline32_n4_8(data, wordcount, real_bplpt); break; - case 5: pfield_doline32_n5_8(data, wordcount, real_bplpt); break; - case 6: pfield_doline32_n6_8(data, wordcount, real_bplpt); break; -#ifdef AGA - case 7: pfield_doline32_n7_8(data, wordcount, real_bplpt); break; - case 8: pfield_doline32_n8_8(data, wordcount, real_bplpt); break; -#endif - } -}static void pfield_doline_16(int planecnt, int wordcount, uae_u8 *datap, struct linestate *ls) +static void pfield_doline_16(int planecnt, int wordcount, uae_u8 *datap, struct linestate *ls) { uae_u8 **real_bplpt = ls->bplpt; uae_u32 *data = (uae_u32*)datap; @@ -6605,7 +6576,6 @@ static void pfield_doline_64(int planecnt, int wordcount, uae_u8 *datap, struct } } -#if 0 static void pfield_doline_not_fast_enough_yet(int planecnt, int wordcount, uae_u8 *data, struct linestate *ls) { wordcount *= 4; @@ -6636,6 +6606,46 @@ static void pfield_doline_not_fast_enough_yet(int planecnt, int wordcount, uae_u } #endif +/* See above for comments on inlining. These functions should _not_ +be inlined themselves. */ +static void NOINLINE pfield_doline32_n1_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 1, real_bplpt); } +static void NOINLINE pfield_doline32_n2_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 2, real_bplpt); } +static void NOINLINE pfield_doline32_n3_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 3, real_bplpt); } +static void NOINLINE pfield_doline32_n4_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 4, real_bplpt); } +static void NOINLINE pfield_doline32_n5_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 5, real_bplpt); } +static void NOINLINE pfield_doline32_n6_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 6, real_bplpt); } +#ifdef AGA +static void NOINLINE pfield_doline32_n7_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 7, real_bplpt); } +static void NOINLINE pfield_doline32_n8_8(uae_u32 *data, int count, uae_u8 *real_bplpt[8]) { pfield_doline32_8(data, count, 8, real_bplpt); } +#endif +static void pfield_doline_8(int planecnt, int wordcount, uae_u8 *datap, struct linestate *ls) +{ + uae_u8 **real_bplpt = ls->bplpt; + uae_u32 *data = (uae_u32 *)datap; +#if 0 + uae_u8 *dpt = ls->linedatastate; + int len = ls->bpllen; + for (int i = 0; i < planecnt; i++) { + memcpy(dpt, ls->bplpt[i], len); + dpt += len; + } +#endif + switch (planecnt) { + default: break; + case 0: memset(data, 0, wordcount * 32); break; + case 1: pfield_doline32_n1_8(data, wordcount, real_bplpt); break; + case 2: pfield_doline32_n2_8(data, wordcount, real_bplpt); break; + case 3: pfield_doline32_n3_8(data, wordcount, real_bplpt); break; + case 4: pfield_doline32_n4_8(data, wordcount, real_bplpt); break; + case 5: pfield_doline32_n5_8(data, wordcount, real_bplpt); break; + case 6: pfield_doline32_n6_8(data, wordcount, real_bplpt); break; +#ifdef AGA + case 7: pfield_doline32_n7_8(data, wordcount, real_bplpt); break; + case 8: pfield_doline32_n8_8(data, wordcount, real_bplpt); break; +#endif + } +} + static void tvadjust(int *hbstrt_offset, int *hbstop_offset) { if (currprefs.gfx_overscanmode < OVERSCANMODE_OVERSCAN) { @@ -6812,7 +6822,8 @@ void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines uae_u32 *cstart = chunky_out + 1024; int len = (ls->bpllen + 3) / 4; - if (0 && currprefs.cpu_memory_cycle_exact) { +#if 0 + if (currprefs.cpu_memory_cycle_exact) { if (fmode == 16) { pfield_doline_16(planecnt, len, (uae_u8*)cstart, ls); } else if (fmode == 32) { @@ -6821,8 +6832,11 @@ void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines pfield_doline_64(planecnt, len, (uae_u8*)cstart, ls); } } else { +#endif pfield_doline_8(planecnt, len, (uae_u8*)cstart, ls); +#if 0 } +#endif bool ecsena = ecs_denise && (ls->bplcon0 & 1) != 0; bool brdblank = (ls->bplcon3 & 0x20) && ecsena; diff --git a/events.cpp b/events.cpp index 6ced8f54..209d5383 100644 --- a/events.cpp +++ b/events.cpp @@ -297,20 +297,22 @@ void do_cycles_slow(int cycles_to_add) #endif #endif - if (syncline_cnt > 0) { - syncline_cnt--; - return; - } - if (is_syncline) { + if (syncline_cnt > 0) { + syncline_cnt--; + return; + } // runs CPU emulation with chipset stopped // when there is free time to do so. if (event_check_vsync()) { - syncline_cnt = 8; + syncline_cnt = currprefs.cachesize ? 2 : 32; return; } } + cycles_to_add += cycles_to_add_remain; + cycles_to_add_remain = 0; + if (!currprefs.cpu_thread) { if ((pissoff -= cycles_to_add) >= 0) { return; @@ -321,9 +323,6 @@ void do_cycles_slow(int cycles_to_add) pissoff = 0x40000000; } - cycles_to_add += cycles_to_add_remain; - cycles_to_add_remain = 0; - while (cycles_to_add >= CYCLE_UNIT) { if (!eventtab[ev_sync].active) { @@ -335,37 +334,6 @@ void do_cycles_slow(int cycles_to_add) cycles_to_add = 0; } -#if 0 - - while (custom_fastmode && cycles_to_add >= CYCLE_UNIT) { - int max = -1; - if (agnus_hpos == 2) { - custom_trigger_start_fast(); - } else if (agnus_hpos == 1) { - custom_trigger_start_fast(); - if (!custom_fastmode) { - max = 1; - } - } - if (max < 0) { - max = maxhpos - agnus_hpos + 1; - } - if (agnus_hpos == 0 || agnus_hpos == 1) { - max = 1; - } - if (max * CYCLE_UNIT > cycles_to_add) { - max = cycles_to_add / CYCLE_UNIT; - } - do_cycles_normal(max * CYCLE_UNIT); - cycles_to_add -= max * CYCLE_UNIT; - agnus_hpos += max; - linear_hpos += max; - currcycle_cck += max; - if (agnus_hpos >= maxhpos) { - agnus_hpos -= maxhpos; - } - } -#endif } int remain = cycles_to_add; diff --git a/include/drawing.h b/include/drawing.h index 0af015b4..7ce53836 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -161,7 +161,7 @@ struct linestate uae_u16 bplcon0, bplcon1, bplcon2, bplcon3, bplcon4; uae_u16 fmode; uae_u32 color0; - uae_u8 *linedatastate, *linecolorstate; + uae_u8 *linecolorstate; int bpllen; int colors; uae_u8 *bplpt[MAX_PLANES]; -- 2.47.3