From: Toni Wilen Date: Sat, 24 Jan 2026 13:37:33 +0000 (+0200) Subject: WIP unified native and programmed mode handling X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=2313b18b4cab456ee705cb22b54fd88b00e21030;p=francis%2Fwinuae.git WIP unified native and programmed mode handling --- diff --git a/custom.cpp b/custom.cpp index 85e2f11a..c0beb809 100644 --- a/custom.cpp +++ b/custom.cpp @@ -75,8 +75,6 @@ #define SPRBORDER 0 -#define EXTRAHEIGHT_BROADCAST_TOP 0 -#define EXTRAHEIGHT_BROADCAST_BOTTOM 0 #define EXTRAHEIGHT_EXTREME 28 #define LORES_TO_SHRES_SHIFT 2 @@ -390,18 +388,24 @@ static bool lof_detect_vsync; static bool lol; static bool linetoggle; static int next_lineno; -int linear_vpos, linear_hpos, linear_vpos_prev[3], linear_hpos_prev[3]; +int linear_vpos, linear_vpos_vb_start, linear_vpos_vb_end, linear_hpos, linear_vpos_prev[3], linear_hpos_prev[3]; +static int linear_vb_offset; static int linear_vpos_vsync; -static int linear_display_vpos; +int linear_display_vpos; int current_linear_vpos, current_linear_hpos; static int current_linear_hblen, current_linear_hblen_temp; int current_linear_vpos_nom, current_linear_hpos_short; -static int linear_vpos_visible, current_linear_vpos_visible; +static int linear_vpos_visible; +static int linear_vpos_vblank_end, linear_vpos_vblank_start, linear_vpos_vblank_vsync; +static int linear_vpos_vblank_lines_cnt, linear_vpos_vblank_lines; +static int current_linear_vblank_lines; +static int current_linear_vpos_vb_start, current_linear_vpos_vb_end, current_linear_vpos_vb_vsync; static int current_linear_vpos_temp, current_linear_hpos_temp; static int current_linear_temp_change; static bool display_redraw; static int display_hstart_cyclewait, display_hstart_cyclewait_cnt, display_hstart_cyclewait_end; static int display_hstart_cyclewait_skip, display_hstart_cyclewait_skip2; +static int display_vblankstart_skip, display_vblankend_skip; static bool display_hstart_cyclewait_start; static int agnus_trigger_cck; static int linear_vpos_changes; @@ -619,6 +623,7 @@ uae_u16 beamcon0, new_beamcon0; static bool beamcon0_dual, beamcon0_pal; uae_u16 bemcon0_hsync_mask, bemcon0_vsync_mask; bool beamcon0_has_hsync, beamcon0_has_vsync, beamcon0_has_csync; +static bool beamcon0_has_vblank; static uae_u16 beamcon0_saved; static uae_u16 bplcon0_saved, bplcon1_saved, bplcon2_saved; static uae_u16 bplcon3_saved, bplcon4_saved; @@ -1676,15 +1681,29 @@ void compute_framesync(void) if (currprefs.gfx_overscanmode >= OVERSCANMODE_EXTREME) { vb->extrawidth = -1; } - int mfl = minfirstline_linear; - if (currprefs.gfx_overscanmode < OVERSCANMODE_ULTRA) { - mfl += 2; + int maxv = current_linear_vpos - (current_linear_vblank_lines - display_vblankstart_skip) + display_vblankend_skip + 1; + linear_vpos_vb_end = current_linear_vpos_vb_end - display_vblankstart_skip - 1; + if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) { + maxv = current_linear_vpos; + linear_vpos_vb_end = 0; } - int maxv = current_linear_vpos - mfl; vb->inheight = maxv << vres2; vb->inheight2 = vb->inheight; vb->inxoffset = 0; + if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) { + linear_vpos_vb_end = 0; + linear_vpos_vb_start = 0; + } else { + if (linear_vpos_vb_end < LINES_AFTER_VSYNC) { + linear_vpos_vb_end = LINES_AFTER_VSYNC; + } + linear_vpos_vb_start = current_linear_vpos_vb_start + display_vblankend_skip + 1; + if (linear_vpos_vb_start >= current_linear_vpos) { + linear_vpos_vb_start -= current_linear_vpos; + } + } + //write_log(_T("Width %d Height %d\n"), vb->inwidth, vb->inheight); if (vb->inwidth < 16) @@ -1784,6 +1803,7 @@ static void init_beamcon0(void) beamcon0_has_hsync = (beamcon0 & bemcon0_hsync_mask) != 0; beamcon0_has_vsync = (beamcon0 & bemcon0_vsync_mask) != 0; beamcon0_has_csync = (beamcon0 & BEAMCON0_VARCSYEN) != 0; + beamcon0_has_vblank = (beamcon0 & BEAMCON0_VARVBEN) != 0; beamcon0_dual = (new_beamcon0 & BEAMCON0_DUAL) != 0; agnus_equdis = ecs_agnus && ((beamcon0 & BEAMCON0_VARCSYEN) || (beamcon0 & BEAMCON0_BLANKEN)); @@ -1869,11 +1889,11 @@ static void init_beamcon0(void) } // after vsync, it seems earlier possible visible line is vsync+3. - vsync_startline = 3; + vsync_startline = LINES_AFTER_VSYNC; if ((beamcon0 & BEAMCON0_VARVBEN) && (beamcon0 & bemcon0_vsync_mask)) { vsync_startline += vsstrt; if (vsync_startline >= vsync_lines / 2) { - vsync_startline = 3; + vsync_startline = LINES_AFTER_VSYNC; } } @@ -1913,7 +1933,7 @@ static void init_beamcon0(void) if (display_hstart_cyclewait < 0) { display_hstart_cyclewait = 0; } - display_hstart_cyclewait_end = 7;// hblen / 2 - display_hstart_cyclewait + 1; + display_hstart_cyclewait_end = 10;// hblen / 2 - display_hstart_cyclewait + 1; if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) { display_hstart_cyclewait = 0; @@ -2076,22 +2096,37 @@ static void init_beamcon0(void) minfirstline = 0; } - int minfirstline_hw = minfirstline; + minfirstline_linear = linear_vpos_vblank_end; maxvpos_display_vsync = 0; + display_vblankstart_skip = 0; + display_vblankend_skip = 0; if (currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA) { + vsync_startline = 0; minfirstline = 0; - minfirstline_hw = 0; + minfirstline_linear = 0; maxvpos_display_vsync = vsync_startline; + display_vblankstart_skip = -3000; } else if (currprefs.gfx_overscanmode == OVERSCANMODE_EXTREME) { - minfirstline_hw -= EXTRAHEIGHT_EXTREME / 2; + minfirstline_linear -= EXTRAHEIGHT_EXTREME / 2; minfirstline -= EXTRAHEIGHT_EXTREME / 2; + display_vblankstart_skip = linear_vpos_vblank_end; + display_vblankend_skip = 3; maxvpos_display_vsync += 2; + display_hstart_cyclewait += 6; + display_hstart_cyclewait_end -= 6; } else if (currprefs.gfx_overscanmode == OVERSCANMODE_BROADCAST) { - minfirstline_hw -= EXTRAHEIGHT_BROADCAST_TOP; + minfirstline_linear -= 0; + maxvpos_display_vsync++; + display_vblankstart_skip = -1; + display_vblankend_skip = 2; + display_hstart_cyclewait_end--; + } else { maxvpos_display_vsync++; + display_vblankstart_skip = -1; + display_vblankend_skip = 2; } - if (beamcon0 & BEAMCON0_VARBEAMEN) { - minfirstline_hw = 0; + if (minfirstline_linear < 0) { + minfirstline_linear += current_linear_vpos_nom; } if ((beamcon0 & BEAMCON0_VARVBEN) && (beamcon0 & bemcon0_vsync_mask)) { @@ -2133,10 +2168,6 @@ static void init_beamcon0(void) minfirstline = vsync_lines - 1; } - if (minfirstline < minfirstline_hw) { - minfirstline = minfirstline_hw; - } - if (beamcon0 & bemcon0_vsync_mask) { if (minfirstline < vsync_startline) { minfirstline = vsync_startline; @@ -2186,8 +2217,6 @@ static void init_beamcon0(void) maxvpos_total = MAXVPOS; } - minfirstline_linear = minfirstline - (vsync_startline > 0 ? vsync_startline : 0); - int size = currprefs.gfx_overscanmode >= OVERSCANMODE_ULTRA ? 0 : 4; display_hstart_cyclewait_skip2 = display_hstart_cyclewait_end; display_hstart_cyclewait_skip = display_hstart_cyclewait - size; @@ -2214,8 +2243,10 @@ static void init_hz_reset(void) current_linear_hpos_short = linear_hpos; current_linear_hpos_temp = current_linear_hpos; current_linear_vpos_temp = current_linear_vpos; + current_linear_vblank_lines = minfirstline; + current_linear_vpos_vb_end = minfirstline - vsync_startline; + current_linear_vpos_vb_start = current_linear_vpos + 1; current_linear_temp_change = 0; - current_linear_vpos_visible = 0; hsync_cck = linear_hpos; vsync_lines = linear_vpos; vsync_linecnt = 0; @@ -3476,20 +3507,30 @@ static void update_agnus_vb(void) agnus_vb_active_end_line = agnus_pvb_end_line; agnus_vb_active_start_line = agnus_pvb_start_line; if (agnus_pvb_start_line) { - current_linear_vpos_visible = linear_vpos_visible; + if (linear_vpos_vblank_lines_cnt) { + linear_vpos_vblank_start = linear_vpos; + } + linear_vpos_vblank_lines_cnt = 0; } if (agnus_pvb_end_line) { linear_vpos_visible = 1; + linear_vpos_vblank_end = linear_vpos; + linear_vpos_vblank_lines = linear_vpos_vblank_lines_cnt; } } else { agnus_vb_active = agnus_vb == 1; agnus_vb_active_end_line = agnus_vb_end_line; agnus_vb_active_start_line = agnus_vb_start_line; if (agnus_vb_start_line) { - current_linear_vpos_visible = linear_vpos_visible; + if (linear_vpos_vblank_lines_cnt) { + linear_vpos_vblank_start = linear_vpos; + } + linear_vpos_vblank_lines_cnt = 0; } if (agnus_vb_end_line) { linear_vpos_visible = 1; + linear_vpos_vblank_end = linear_vpos; + linear_vpos_vblank_lines = linear_vpos_vblank_lines_cnt; } } } @@ -4176,6 +4217,7 @@ static uae_u16 CLXDAT(void) // draw line up to current horizontal position to get accurate collision state if (currprefs.cpu_memory_cycle_exact && currprefs.m68k_speed >= 0 && !doflickerfix_active()) { int ldvpos = linear_display_vpos + draw_line_next_line; + ldvpos -= linear_vb_offset; draw_line(ldvpos, false); } draw_denise_line_queue_flush(); @@ -4554,6 +4596,7 @@ static int calculate_linetype(int vp) nextline_how = currprefs.gfx_vresolution > VRES_NONDOUBLE && currprefs.gfx_pscanlines == 1 ? nln_nblack : nln_doubled; } } + return lineno; } @@ -5060,8 +5103,6 @@ static void vsync_check_vsyncmode(void) current_linear_hpos_temp = hp; current_linear_vpos_temp = vp; current_linear_temp_change = 2; - if (vp == 0) - write_log("x"); } } } @@ -5076,6 +5117,10 @@ static void vsync_check_vsyncmode(void) current_linear_vpos != current_linear_vpos_temp) { current_linear_hpos = current_linear_hpos_temp; current_linear_vpos = current_linear_vpos_temp; + current_linear_vblank_lines = linear_vpos_vblank_lines; + current_linear_vpos_vb_end = linear_vpos_vblank_end; + current_linear_vpos_vb_start = linear_vpos_vblank_start; + current_linear_vpos_vb_vsync = linear_vpos_vblank_vsync; current_linear_hpos_short = current_linear_hpos - maxhpos_lol; current_linear_vpos_nom = current_linear_vpos - lof_store; init_beamcon0(); @@ -9924,7 +9969,12 @@ STATIC_INLINE void vsync_mark(void) { if (vsync_linecnt) { vsync_lines = vsync_linecnt; + linear_vpos_vblank_vsync = linear_vpos_vblank_lines_cnt; vsync_linecnt = 0; + linear_vpos_prev[2] = linear_vpos_prev[1]; + linear_vpos_prev[1] = linear_vpos_prev[0]; + linear_vpos_prev[0] = vsync_lines; + linear_vpos = 0; } } @@ -9956,7 +10006,7 @@ static void check_vsyncs_fast(void) if (!beamcon0_has_vsync) { vsync_mark(); } - lof_detect = 1; + lof_detect = 0; update_lof_detect(); } if (vpos == 5 && !lof_store) { @@ -9967,7 +10017,7 @@ static void check_vsyncs_fast(void) if (!beamcon0_has_vsync) { vsync_mark(); } - lof_detect = 0; + lof_detect = 1; update_lof_detect(); } if (vpos == 5 && lof_store) { @@ -9981,7 +10031,7 @@ static void check_vsyncs_fast(void) if (beamcon0_has_vsync) { vsync_mark(); } - lof_pdetect = 0; + lof_pdetect = 1; } if (!lof_store && vpos == vsstop) { agnus_pvsync = false; @@ -9991,7 +10041,7 @@ static void check_vsyncs_fast(void) if (beamcon0_has_vsync) { vsync_mark(); } - lof_pdetect = 1; + lof_pdetect = 0; } if (lof_store && vpos == vsstop) { agnus_pvsync = false; @@ -10022,7 +10072,7 @@ static void check_vsyncs_fast(void) if (beamcon0_has_vsync) { vsync_mark(); } - lof_pdetect = 1; + lof_pdetect = 0; } if (lof_store && vpos == vsstop) { agnus_pvsync = false; @@ -10311,6 +10361,7 @@ static bool draw_blank_fast(struct linestate *l, int ldv) } start_draw_denise(); int dvp = calculate_linetype(ldv); + dvp -= linear_vb_offset; draw_denise_border_line_fast_queue(dvp, true, nextline_how, l); return true; } @@ -10326,6 +10377,7 @@ static bool draw_border_fast(struct linestate *l, int ldv) l->color0 = aga_mode ? agnus_colors.color_regs_aga[0] : agnus_colors.color_regs_ecs[0]; l->brdblank = brdblank; int dvp = calculate_linetype(ldv); + dvp -= linear_vb_offset; draw_denise_border_line_fast_queue(dvp, false, nextline_how, l); return true; } @@ -10391,6 +10443,7 @@ static bool draw_line_fast(struct linestate *l, int ldv, uaecptr bplptp[8], bool l->bplcon1 = bplcon1 & bc1mask; l->fetchmode_size = fetchmode_size; l->fetchstart_mask = fetchstart_mask; + dvp -= linear_vb_offset; draw_denise_bitplane_line_fast_queue(dvp, nextline_how, l); if (addbpl) { // advance bpl pointers @@ -10580,6 +10633,7 @@ static void draw_line(int ldvpos, bool finalseg) int cs = 0;// (beamcon0 & BEAMCON0_VARHSYEN) ? agnus_phsync_end - agnus_phsync_start : agnus_hsync_end - agnus_hsync_start; int cslen = 10; + dvp -= linear_vb_offset; draw_denise_line_queue(dvp, nextline_how, rga_denise_cycle_line, rga_denise_cycle_start, rga_denise_cycle, rga_denise_cycle_count_start, rga_denise_cycle_count_end, display_hstart_cyclewait_skip, display_hstart_cyclewait_skip2, wclks, cs, cslen, lof_store, lol, display_hstart_fastmode - display_hstart_cyclewait, nosignal_status != 0, finalseg, l); @@ -10906,28 +10960,29 @@ static void custom_trigger_start(void) if (!ecs_agnus) { vpos &= 511; } - linear_display_vpos = linear_vpos; + linear_display_vpos = linear_vpos; linear_vpos++; + linear_vpos_vblank_lines_cnt++; linear_vpos_visible++; draw_line_next_line = 0; linear_vpos_vsync++; + + if (linear_display_vpos == linear_vpos_vb_end) { + int dvp = calculate_linetype(linear_display_vpos); + linear_vb_offset = dvp; + } + #if 1 if (beamcon0_has_vsync) { if (vpos == vsstrt) { - //vsync_lines = vsync_linecnt; - //vsync_linecnt = 0; linear_vpos_vsync = 0; } } else { if (beamcon0_pal && (vpos == 3 && lof_store) || (vpos == 2 && !lof_store)) { - //vsync_lines = vsync_linecnt; - //vsync_linecnt = 0; linear_vpos_vsync = 0; } if (!beamcon0_pal && vpos == 3) { - //vsync_lines = vsync_linecnt; - //vsync_linecnt = 0; linear_vpos_vsync = 0; } } @@ -11084,13 +11139,6 @@ static void custom_trigger_start(void) if (vpos == vsync_startline) { - linear_vpos_prev[2] = linear_vpos_prev[1]; - linear_vpos_prev[1] = linear_vpos_prev[0]; - if (vsync_lines == 0 || vsync_lines > 800) - write_log("x"); - linear_vpos_prev[0] = vsync_lines; - linear_vpos = 0; - virtual_vsync_check(); last_vsync_evt = get_cycles() + (maxvpos * maxhpos * 3) * CYCLE_UNIT; @@ -11286,7 +11334,7 @@ static void check_hsyncs_hardwired(void) if (!beamcon0_has_vsync) { vsync_mark(); } - lof_detect = 1; + lof_detect = 0; update_lof_detect(); #ifdef DEBUGGER if (debug_dma) { @@ -11310,7 +11358,7 @@ static void check_hsyncs_hardwired(void) if (!beamcon0_has_vsync) { vsync_mark(); } - lof_detect = 0; + lof_detect = 1; update_lof_detect(); #ifdef DEBUGGER if (debug_dma) { @@ -11338,7 +11386,7 @@ static void check_hsyncs_hardwired(void) if (!beamcon0_has_vsync) { vsync_mark(); } - lof_detect = 1; + lof_detect = 0; update_lof_detect(); #ifdef DEBUGGER if (debug_dma) { @@ -11362,7 +11410,7 @@ static void check_hsyncs_hardwired(void) if (!beamcon0_has_vsync) { vsync_mark(); } - lof_detect = 0; + lof_detect = 1; update_lof_detect(); #ifdef DEBUGGER if (debug_dma) { @@ -11463,7 +11511,7 @@ static void check_hsyncs_programmed(void) if (beamcon0_has_vsync) { vsync_mark(); } - lof_pdetect = 0; + lof_pdetect = 1; #ifdef DEBUGGER if (debug_dma) { record_dma_event_agnus(AGNUS_EVENT_PRG_VS, true); @@ -11558,7 +11606,7 @@ static void check_hsyncs_programmed(void) if (beamcon0_has_vsync) { vsync_mark(); } - lof_pdetect = 1; + lof_pdetect = 0; #ifdef DEBUGGER if (debug_dma) { record_dma_event_agnus(AGNUS_EVENT_PRG_VS, true); @@ -12459,8 +12507,8 @@ bool isvga(void) bool ispal(int *lines) { if (lines) { - if (current_linear_vpos_visible) { - *lines = current_linear_vpos_visible; + if (maxvpos_display) { + *lines = maxvpos_display - linear_vpos_vblank_lines; } else { *lines = currprefs.ntscmode ? (MAXVPOS_NTSC + 1) - (VBLANK_ENDLINE_NTSC - 1) : (MAXVPOS_PAL + 1) - (VBLANK_ENDLINE_PAL - 1); } diff --git a/drawing.cpp b/drawing.cpp index 03cdb14e..2013d92d 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -85,7 +85,10 @@ static uae_sem_t write_sem, read_sem; struct denise_rga_queue { int type; - int vpos, linear_vpos; + int vpos; + int linear_vpos; + int linear_vpos_vb_start; + int linear_vpos_vb_end; int gfx_ypos; nln_how how; uae_u32 linecnt; @@ -118,7 +121,8 @@ static bool full_line_draw; static void denise_handle_quick_strobe(uae_u16 strobe, int offset, int vpos); static void draw_denise_vsync(int); static void denise_update_reg(uae_u16 reg, uae_u16 v, uae_u32 linecnt); -static void draw_denise_line(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls); +static void draw_denise_line(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, + int calib_start, int calib_len, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls); static void sprwrite(int reg, uae_u32 v); static void sprwrite_64(int reg, uae_u64 v); @@ -185,7 +189,8 @@ static void read_denise_line_queue(void) if (q->type == 0) { - draw_denise_line(q->gfx_ypos, q->how, q->linecnt, q->startpos, q->startcycle, q->endcycle, q->skip, q->skip2, q->dtotal, q->calib_start, q->calib_len, q->lol, q->hdelay, q->blanked, q->finalseg, q->ls); + draw_denise_line(q->gfx_ypos, q->how, q->linecnt, q->startpos, q->startcycle, q->endcycle, q->skip, q->skip2, q->dtotal, + q->calib_start, q->calib_len, q->lol, q->hdelay, q->blanked, q->finalseg, q->ls); next = q->finalseg; } else if (q->type == 1) { draw_denise_bitplane_line_fast(q->gfx_ypos, q->how, q->ls); @@ -544,6 +549,7 @@ static bool no_denise_lol, denise_strlong_seen; #define STRLONG_SEEN_DELAY 2 static int denise_strlong_seen_delay; static bool denise_vsync_bpl_detect; +static int linear_vb_offset; void set_inhibit_frame(int monid, int bit) { @@ -785,9 +791,9 @@ void check_custom_limits(void) if (doublescan == 1 && vshift > 0) { vshift--; } - int ydiff = minfirstline - minfirstline_linear; - denise_vblank_extra_top = (visible_top_start - ydiff) >> vshift; - denise_vblank_extra_bottom = (visible_bottom_stop - ydiff) >> vshift; + + denise_vblank_extra_top = visible_top_start >> vshift; + denise_vblank_extra_bottom = visible_bottom_stop >> vshift; denise_hblank_extra_left = visible_left_start; denise_hblank_extra_right = visible_right_stop; @@ -860,19 +866,15 @@ void set_custom_limits (int w, int h, int dx, int dy, bool blank) visible_top_start = 0; visible_bottom_stop = MAX_STOP; } else { - int startypos = min_ypos_for_screen; + int startypos = linear_vpos_vb_end << vshift; visible_top_start = startypos + dy; visible_bottom_stop = startypos + dy + h; - if (currprefs.gfx_overscanmode >= OVERSCANMODE_BROADCAST) { - visible_top_start -= 1 << currprefs.gfx_resolution; - visible_bottom_stop += 1 << currprefs.gfx_resolution; - } - if (visible_top_start < hhadd + startypos) { - visible_top_start = hhadd + startypos; - } - if ((current_linear_vpos << currprefs.gfx_vresolution) - hhadd2 < visible_bottom_stop) { - visible_bottom_stop = (current_linear_vpos << currprefs.gfx_vresolution) - hhadd2; + if (currprefs.gfx_overscanmode < OVERSCANMODE_BROADCAST) { + visible_top_start += 1 << vshift; + visible_bottom_stop -= 1 << vshift; } + visible_top_start += hhadd; + visible_bottom_stop -= hhadd; } check_custom_limits(); @@ -5617,7 +5619,6 @@ static void get_line(int monid, int gfx_ypos, enum nln_how how, int lol_shift_pr struct vidbuf_description *vidinfo = &adisplays[monid].gfxvidinfo; struct vidbuffer *vb = vidinfo->inbuffer; int eraselines = 0; - int yadjust = currprefs.gfx_overscanmode < OVERSCANMODE_ULTRA ? minfirstline_linear << currprefs.gfx_vresolution : 0; int xshift = 0; xlinebuffer = NULL; @@ -5644,8 +5645,6 @@ static void get_line(int monid, int gfx_ypos, enum nln_how how, int lol_shift_pr erase_next_draw = false; } - gfx_ypos -= yadjust; - if (how == nln_none) { return; } @@ -5823,7 +5822,7 @@ static void edgeblanking(int hbstrt_offset, int hbstop_offset, int internal_pixe } } int right = strlong_seen ? denise_hblank_extra_right - (1 << currprefs.gfx_resolution) : denise_hblank_extra_right; - if (!programmedmode && (denise_hblank_extra_left > visible_left_border || visible_right_border > right) && currprefs.gfx_overscanmode < OVERSCANMODE_EXTREME) { + if ((denise_hblank_extra_left > visible_left_border || visible_right_border > right) && currprefs.gfx_overscanmode < OVERSCANMODE_EXTREME) { int ww1 = denise_hblank_extra_left > visible_left_border ? (denise_hblank_extra_left - visible_left_border) << 0 : 0; int ww2 = visible_right_border > right ? (visible_right_border - right) << 0 : 0; for (int i = 0; i < 4; i++) { @@ -5912,7 +5911,8 @@ static void edgeblanking(int hbstrt_offset, int hbstop_offset, int internal_pixe } } -static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int startpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls) +static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, int startpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, + int calib_start, int calib_len, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls) { bool fullline = false; @@ -5960,10 +5960,10 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in bufg = gbuf; } - bool blankedline = (this_line->linear_vpos >= denise_vblank_extra_bottom || this_line->linear_vpos < denise_vblank_extra_top) && currprefs.gfx_overscanmode < OVERSCANMODE_EXTREME && !programmedmode; bool line_is_blanked = false; + bool hidden = this_line->linear_vpos >= denise_vblank_extra_bottom || this_line->linear_vpos < denise_vblank_extra_top; - if ((denise_pixtotal_max == -0x7fffffff && denise_vsync_bpl_detect) || blankedline || blanked) { + if ((denise_pixtotal_max == -0x7fffffff && denise_vsync_bpl_detect) || blanked) { // don't draw vertical blanking if not ultra extreme overscan internal_pixel_cnt = -1; @@ -6058,6 +6058,18 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in return; } + if (hidden) { + if (xlinebuffer) { + memset(xlinebuffer_start, DEBUG_TVOVERSCAN_V_GRAYSCALE, xlinebuffer_end - xlinebuffer_start); + if (xlinebuffer2 && xlinebuffer != xlinebuffer2) { + memset(xlinebuffer2_start, DEBUG_TVOVERSCAN_V_GRAYSCALE, xlinebuffer2_end - xlinebuffer2_start); + } + if (xlinebuffer_genlock) { + memset(xlinebuffer_genlock_start, 0, xlinebuffer_genlock_end - xlinebuffer_genlock_start); + } + } + } + #if 0 static int testtoggle[1000]; testtoggle[gfx_ypos]++; @@ -6090,7 +6102,7 @@ static void draw_denise_line(int gfx_ypos, enum nln_how how, uae_u32 linecnt, in ls->bpl1dat_trigger_offset = bpl1dat_trigger_offset; ls->internal_pixel_cnt = internal_pixel_cnt; ls->internal_pixel_start_cnt = internal_pixel_start_cnt; - ls->blankedline = blankedline; + ls->blankedline = 0; ls->strlong_seen = denise_strlong_seen; ls->lol_shift_prev = denise_lol_shift_prev; ls->vb = denise_vblank_active; @@ -7004,7 +7016,7 @@ static void pfield_doline_8(int planecnt, int wordcount, uae_u8 *datap, struct l static void tvadjust(int *hbstrt_offset, int *hbstop_offset, struct linestate *ls) { - if (!programmedmode && currprefs.gfx_overscanmode < OVERSCANMODE_EXTREME) { + if (currprefs.gfx_overscanmode < OVERSCANMODE_EXTREME) { int right = denise_strlong_seen ? denise_hblank_extra_right - (1 << currprefs.gfx_resolution) : denise_hblank_extra_right; int ww1 = denise_hblank_extra_left > visible_left_border ? (denise_hblank_extra_left - visible_left_border) << 0 : 0; int ww2 = visible_right_border > right ? (visible_right_border - right) << 0 : 0; @@ -7245,12 +7257,13 @@ void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines } lines_count++; - if (!buf1) { return; } - if (ls->blankedline) { + bool hidden = this_line->linear_vpos >= denise_vblank_extra_bottom || this_line->linear_vpos < denise_vblank_extra_top; + + if (ls->blankedline || hidden) { return; } @@ -7495,7 +7508,7 @@ void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct lines edgeblanking(ls->hbstrt_offset, ls->hbstop_offset, ls->internal_pixel_start_cnt, ls->strlong_seen, ls->lol, ls->lol_shift_prev); - if (!programmedmode && ham) { + if (ham) { int ww1 = visible_left_start > visible_left_border ? (visible_left_start - visible_left_border) << 0 : 0; if (ww1 > 0) { hbstop_offset += ww1; @@ -7698,7 +7711,9 @@ static void updatelinedata(void) this_line = &temp_line; this_line->vpos = vpos; this_line->lof = lof_store; - this_line->linear_vpos = linear_vpos; + this_line->linear_vpos = linear_display_vpos; + this_line->linear_vpos_vb_start = linear_vpos_vb_start; + this_line->linear_vpos_vb_end = linear_vpos_vb_end; } static bool waitqueue_nolock(void) @@ -7747,7 +7762,9 @@ void draw_denise_border_line_fast_queue(int gfx_ypos, bool blank, enum nln_how h q->ls = ls; q->type = 2; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; addtowritequeue(); @@ -7773,7 +7790,9 @@ void draw_denise_bitplane_line_fast_queue(int gfx_ypos, enum nln_how how, struct q->ls = ls; q->type = 1; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; addtowritequeue(); @@ -7799,7 +7818,9 @@ void quick_denise_rga_queue(uae_u32 linecnt, int startpos, int endpos) q->endpos = endpos; q->type = 3; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; addtowritequeue(); @@ -7825,7 +7846,9 @@ void denise_handle_quick_strobe_queue(uae_u16 strobe, int strobe_pos, int endpos q->endpos = endpos; q->type = 4; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; addtowritequeue(); @@ -7838,7 +7861,8 @@ void denise_handle_quick_strobe_queue(uae_u16 strobe, int strobe_pos, int endpos } } -void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int endpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lof, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls) +void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int endpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, + int calib_start, int calib_len, bool lof, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls) { if (multithread_denise_active()) { @@ -7867,7 +7891,9 @@ void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int star q->hdelay = hdelay; q->blanked = blanked; q->finalseg = finalseg; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; addtowritequeue(); @@ -7893,7 +7919,9 @@ void draw_denise_vsync_queue(int erase) q->type = 5; q->erase = erase; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; addtowritequeue(); @@ -7915,7 +7943,9 @@ void denise_update_reg_queue(uae_u16 reg, uae_u16 v, uae_u32 linecnt) struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK]; q->type = 6; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; q->reg = reg; q->val = v; q->linecnt = linecnt; @@ -7940,7 +7970,9 @@ void denise_store_restore_registers_queue(bool store, uae_u32 linecnt) struct denise_rga_queue *q = &rga_queue[rga_queue_write & DENISE_RGA_SLOT_CHUNKS_MASK]; q->type = 7; q->vpos = vpos; - q->linear_vpos = linear_vpos; + q->linear_vpos = linear_display_vpos; + q->linear_vpos_vb_start = linear_vpos_vb_start; + q->linear_vpos_vb_end = linear_vpos_vb_end; q->val = store ? 1 : 0; q->linecnt = linecnt; diff --git a/include/custom.h b/include/custom.h index a98361af..93ff8e26 100644 --- a/include/custom.h +++ b/include/custom.h @@ -76,7 +76,8 @@ extern uae_u32 hsync_counter, vsync_counter; extern uae_u16 dmacon; extern uae_u16 intena, intreq, intreqr; -extern int vpos, linear_vpos; +extern int vpos, linear_display_vpos; +extern int linear_vpos_vb_start, linear_vpos_vb_end; extern uae_u8 agnus_hpos; extern bool lof_store, lof_display; extern int scandoubled_line; @@ -130,6 +131,8 @@ extern uae_u16 INTREQR(void); #define EQU_ENDLINE_PAL 8 #define EQU_ENDLINE_NTSC 9 +#define LINES_AFTER_VSYNC 3 + #define OCS_DENISE_HBLANK_DISABLE_HPOS 0x2e extern int maxhpos, maxhposm0, maxhpos_short; diff --git a/include/drawing.h b/include/drawing.h index 55f93d44..3cfb2290 100644 --- a/include/drawing.h +++ b/include/drawing.h @@ -177,7 +177,8 @@ struct linestate }; extern struct color_entry denise_colors; -void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int endpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, int calib_start, int calib_len, bool lof, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls); +void draw_denise_line_queue(int gfx_ypos, nln_how how, uae_u32 linecnt, int startpos, int endpos, int startcycle, int endcycle, int skip, int skip2, int dtotal, + int calib_start, int calib_len, bool lof, bool lol, int hdelay, bool blanked, bool finalseg, struct linestate *ls); void draw_denise_bitplane_line_fast(int gfx_ypos, enum nln_how how, struct linestate *ls); void draw_denise_bitplane_line_fast_queue(int gfx_ypos, enum nln_how how, struct linestate *ls); void draw_denise_border_line_fast(int gfx_ypos, bool blank, enum nln_how how, struct linestate *ls); diff --git a/od-win32/win32_scaler.cpp b/od-win32/win32_scaler.cpp index 42efaa0b..f5fd87c1 100644 --- a/od-win32/win32_scaler.cpp +++ b/od-win32/win32_scaler.cpp @@ -54,6 +54,7 @@ static bool getmanualpos(int monid, int *cxp, int *cyp, int *cwp, int *chp) v = currprefs.gfx_xcenter_size; if (v <= 0) { +#if 0 if (programmedmode && native) { cw = maxhpos_display << (RES_MAX + (doublescan == 1)); } else { @@ -64,13 +65,16 @@ static bool getmanualpos(int monid, int *cxp, int *cyp, int *cwp, int *chp) cw = native ? maxhpos_display << RES_MAX : avidinfo->outbuffer->outwidth << 1; } } - } else { +#endif + cw = avidinfo->outbuffer->outwidth << 1; + } else { cw = v; } cw >>= (RES_MAX - currprefs.gfx_resolution); v = currprefs.gfx_ycenter_size; if (v <= 0) { +#if 0 if (programmedmode && native) { ch = (current_linear_vpos - minfirstline) << (VRES_MAX - (doublescan == 1 && !interlace_seen)); } else if (currprefs.gfx_overscanmode <= OVERSCANMODE_OVERSCAN) { @@ -79,6 +83,8 @@ static bool getmanualpos(int monid, int *cxp, int *cyp, int *cwp, int *chp) } else { ch = native ? (current_linear_vpos - minfirstline) << VRES_MAX : avidinfo->outbuffer->outheight; } +#endif + ch = avidinfo->outbuffer->outheight; } else { ch = v; } @@ -278,7 +284,7 @@ void getfilterdata(int monid, struct displayscale *ds) if (!specialmode && scalemode == AUTOSCALE_STATIC_AUTO) { filter_aspect = 0; keep_aspect = 0; - if (ds->dstwidth >= 640 && ds->dstwidth <= 800 && ds->dstheight >= 480 && ds->dstheight <= 600 && !programmedmode) { + if (ds->dstwidth >= 640 && ds->dstwidth <= 800 && ds->dstheight >= 480 && ds->dstheight <= 600) { autoselect = 1; scalemode = AUTOSCALE_NONE; int m = 1; @@ -328,13 +334,6 @@ void getfilterdata(int monid, struct displayscale *ds) if (scalemode == AUTOSCALE_STATIC_MAX || scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_INTEGER || scalemode == AUTOSCALE_INTEGER_AUTOSCALE) { - if (scalemode == AUTOSCALE_STATIC_NOMINAL || scalemode == AUTOSCALE_STATIC_MAX) { - // do not default/TV scale programmed modes - if (programmedmode) { - goto skipcont; - } - } - if (specialmode) { cx = 0; cy = 0; diff --git a/od-win32/writelog.cpp b/od-win32/writelog.cpp index f734ac04..863c948c 100644 --- a/od-win32/writelog.cpp +++ b/od-win32/writelog.cpp @@ -570,7 +570,7 @@ TCHAR *write_log_get_ts(void) _stprintf (p, _T("%03d"), tb.millitm); p += _tcslen (p); if (vsync_counter != 0xffffffff) - _stprintf (p, _T(" [%d %03d%s%03d/%03d]"), vsync_counter, current_hpos_safe(), lof_store ? _T("-") : _T("="), vpos, linear_vpos); + _stprintf (p, _T(" [%d %03d%s%03d/%03d]"), vsync_counter, current_hpos_safe(), lof_store ? _T("-") : _T("="), vpos, linear_display_vpos); _tcscat (p, _T(": ")); return out; }