int scandoubled_line;
static bool lof_lastline, lof_prev_lastline;
static int lol, lol_prev;
+static bool linetoggle;
static int next_lineno;
static int linear_vpos;
static enum nln_how nextline_how;
static int estimate_cycles_empty_index = -1;
static uae_u16 estimated_bplcon0, estimated_fm, estimated_plfstrt, estimated_plfstop;
static uae_s8 *estimated_cycles = estimated_cycles_empty;
+static uae_s8 *estimated_cycles_next = estimated_cycles_empty;
static bool estimated_empty;
static int estimated_maxhpos[2];
}
if (estimated_cycles_empty != estimated_cycles) {
estimated_cycles = estimated_cycles_empty;
+ estimated_cycles_next = estimated_cycles_empty;
estimate_cycles_empty_index = hpos;
- uae_s8 *est = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0;
- if (maxhpos == estimated_maxhpos[0]) {
- est = estimated_cycles_buf0;
- } else if (maxhpos == estimated_maxhpos[1]) {
- est = estimated_cycles_buf1;
- }
- for (int i = 0; i < RGA_PIPELINE_ADJUST; i++) {
- int pos = (hpos + i) % maxhpos;
- estimated_cycles_empty[pos] = est[pos];
+ if (linetoggle) {
+ uae_s8 *est = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0;
+ uae_s8 *est_n = maxhposeven ? estimated_cycles_buf0 : estimated_cycles_buf1;
+ if (maxhpos == estimated_maxhpos[0]) {
+ est = estimated_cycles_buf0;
+ est_n = estimated_cycles_buf1;
+ } else if (maxhpos == estimated_maxhpos[1]) {
+ est = estimated_cycles_buf1;
+ est_n = estimated_cycles_buf0;
+ }
+ for (int i = 0; i < RGA_PIPELINE_ADJUST; i++) {
+ int pos = hpos + i;
+ if (pos >= maxhpos) {
+ pos -= maxhpos;
+ estimated_cycles_empty[pos] = est_n[pos];
+ } else {
+ estimated_cycles_empty[pos] = est[pos];
+ }
+ }
+ } else {
+ uae_s8 *est = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0;
+ if (maxhpos == estimated_maxhpos[0]) {
+ est = estimated_cycles_buf0;
+ } else if (maxhpos == estimated_maxhpos[1]) {
+ est = estimated_cycles_buf1;
+ }
+ for (int i = 0; i < RGA_PIPELINE_ADJUST; i++) {
+ int pos = hpos + i;
+ if (pos >= maxhpos) {
+ pos -= maxhpos;
+ }
+ estimated_cycles_empty[pos] = est[pos];
+ }
}
}
#else
#if OPTIMIZED_ESTIMATE
if (estimated_bplcon0 == bplcon0 && bpl_hstart == hpos && estimated_plfstrt == bpl_hstart && estimated_plfstop == plfstop && estimated_fm == fetchmode) {
- if (maxhpos == estimated_maxhpos[0]) {
- estimated_cycles = estimated_cycles_buf0;
- return;
- }
- if (maxhpos == estimated_maxhpos[1]) {
- estimated_cycles = estimated_cycles_buf1;
- return;
+ if (linetoggle) {
+ if (maxhpos == estimated_maxhpos[0]) {
+ estimated_cycles = estimated_cycles_buf0;
+ estimated_cycles_next = estimated_cycles_buf1;
+ return;
+ }
+ if (maxhpos == estimated_maxhpos[1]) {
+ estimated_cycles = estimated_cycles_buf1;
+ estimated_cycles_next = estimated_cycles_buf0;
+ return;
+ }
+ } else {
+ if (maxhpos == estimated_maxhpos[0]) {
+ estimated_cycles = estimated_cycles_buf0;
+ estimated_cycles_next = estimated_cycles;
+ return;
+ }
+ if (maxhpos == estimated_maxhpos[1]) {
+ estimated_cycles = estimated_cycles_buf1;
+ estimated_cycles_next = estimated_cycles;
+ return;
+ }
}
} else {
estimated_maxhpos[0] = estimated_maxhpos[1] = -1;
#if OPTIMIZED_ESTIMATE
estimated_cycles = maxhposeven ? estimated_cycles_buf1 : estimated_cycles_buf0;
+ if (linetoggle) {
+ estimated_cycles_next = maxhposeven ? estimated_cycles_buf0 : estimated_cycles_buf1;
+ } else {
+ estimated_cycles_next = estimated_cycles;
+ }
#else
estimated_cycles = estimated_cycles_buf0;
+ estimated_cycles_next = estimated_cycles;
#endif
uae_s8 *ecycs = estimated_cycles;
// bitplane DMA end can wrap around, even in non-overrun cases
start_pos++;
if (start_pos >= maxhpos) {
start_pos = 0;
- if (islinetoggle()) {
- ecycs = maxhposeven ? estimated_cycles_buf0 : estimated_cycles_buf1;
+ if (linetoggle) {
+ ecycs = estimated_cycles_next;
}
}
if (start_pos == REFRESH_FIRST_HPOS) {
{
delay_lastcycle[0] = (((maxhpos + 0) * 2) + 2) << LORES_TO_SHRES_SHIFT;
delay_lastcycle[1] = delay_lastcycle[0];
- if (islinetoggle()) {
+ if (linetoggle) {
delay_lastcycle[1] += 1 << LORES_TO_SHRES_SHIFT;
}
delay_hsynccycle = (((maxhpos + hsyncstartpos_start_cycles) * 2) - DDF_OFFSET) << LORES_TO_SHRES_SHIFT;
}
vsynctimebase_orig = vsynctimebase;
- if (islinetoggle()) {
+ if (linetoggle) {
shpos += 0.5f;
}
if (interlace_seen) {
compute_vsynctime();
- hblank_hz = (currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (islinetoggle() ? 0.5f : 0.0f));
+ hblank_hz = (currprefs.ntscmode ? CHIPSET_CLOCK_NTSC : CHIPSET_CLOCK_PAL) / (maxhpos + (linetoggle ? 0.5f : 0.0f));
write_log(_T("%s mode%s%s V=%.4fHz H=%0.4fHz (%dx%d+%d) IDX=%d (%s) D=%d RTG=%d/%d\n"),
isntsc ? _T("NTSC") : _T("PAL"),
lofr = lofr ? 0 : 1;
}
}
- if (islinetoggle()) {
+ if (linetoggle) {
lolr = lolr ? 0 : 1;
}
}
hpos += coffset;
if (hpos >= maxhpos) {
hpos -= maxhpos;
- }
- if (estimated_cycles[hpos] > 0) {
- return true;
+ if (estimated_cycles_next[hpos] > 0) {
+ return true;
+ }
+ } else {
+ if (estimated_cycles[hpos] > 0) {
+ return true;
+ }
}
}
return false;
lol_prev = lol;
if (islinetoggle()) {
lol = lol ? 0 : 1;
+ estimated_cycles_next = estimated_cycles;
+ if (maxhpos == estimated_maxhpos[0]) {
+ estimated_cycles = estimated_cycles_buf0;
+ estimated_cycles_next = estimated_cycles_buf1;
+ } else if (maxhpos == estimated_maxhpos[1]) {
+ estimated_cycles = estimated_cycles_buf1;
+ estimated_cycles_next = estimated_cycles_buf0;
+ }
+ linetoggle = true;
} else {
lol = 0;
+ linetoggle = false;
}
memset(cycle_line_slot, 0, maxhposm1 + 1);
if (cia_hsync < maxhpos) {
int newcount;
CIAA_tod_handler(cia_hsync);
- newcount = (int)((vblank_hz * (2 * maxvpos + (interlace_seen ? 1 : 0)) * (2 * maxhpos + (islinetoggle () ? 1 : 0))) / ((currprefs.cs_ciaatod == 2 ? 60 : 50) * 4));
+ newcount = (int)((vblank_hz * (2 * maxvpos + (interlace_seen ? 1 : 0)) * (2 * maxhpos + (linetoggle ? 1 : 0))) / ((currprefs.cs_ciaatod == 2 ? 60 : 50) * 4));
cia_hsync += newcount;
} else {
cia_hsync -= maxhpos;