Skip to content

Commit

Permalink
bugfix: Removed some buggy Fast copper experimental code
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Feb 29, 2024
1 parent 4ec67a1 commit 5ccdb84
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 95 deletions.
80 changes: 40 additions & 40 deletions src/blitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ static void check_channel_mods(int hpos, int ch)
return;
if (ch == bltptxc) {
bltptxpos = -1;
write_log(_T("BLITTER: %08X write to %cPT ignored! %08x\n"), bltptx, ch + 'A' - 1, m68k_getpc());
write_log (_T("BLITTER: %08X write to %cPT ignored! %08x\n"), bltptx, ch + 'A' - 1, m68k_getpc ());
//activate_debugger();
}
}
Expand Down Expand Up @@ -1058,22 +1058,22 @@ STATIC_INLINE void blitter_doddma (int hpos)
write_log (_T("BLITTER: D-channel without nothing to do?\n"));
}
return;
}
}
record_dma_blit (0x00, d, bltdpt, hpos);
//last_custom_value1 = d; blitter writes are not stored
chipmem_agnus_wput2 (bltdpt, d);
alloc_cycle_blitter(hpos, &bltdpt, 4);
bltdpt += blit_add;
bltdpt += blit_add;
blitter_hcounter2++;
if (blitter_hcounter2 == blt_info.hblitsize) {
blitter_hcounter2 = 0;
bltdpt += blit_modaddd;
bltdpt += blit_modaddd;
blitter_vcounter2++;
if (blit_dmacount2 == 0) // d-only
blitter_vcounter1++;
if (blitter_vcounter2 > blitter_vcounter1)
blitter_vcounter1 = blitter_vcounter2;
}
}
if (blit_ch == 1)
blitter_hcounter1 = blitter_hcounter2;
}
Expand Down Expand Up @@ -1174,12 +1174,12 @@ static void do_startcycles (int hpos)
if (blit_faulty)
blit_faulty = 1;
return;
}
}
} else {
markidlecycle (hpos);
}
}
}
}

void decide_blitter(int hpos)
{
Expand Down Expand Up @@ -1281,36 +1281,36 @@ void decide_blitter(int hpos)
}
markidlecycle (last_blitter_hpos);
break;
}
}

blitter_nasty++;

if (v <= 0) {
blit_misscyclecounter++;
break;
}
}

blt_info.got_cycle = 1;
if (c == 4) {
if (c == 4) {
blitter_doddma (last_blitter_hpos);
blit_cyclecounter++;
blit_totalcyclecounter++;
} else {
} else {
if (blitter_vcounter1 < blt_info.vblitsize) {
blitter_dodma (c, last_blitter_hpos);
}
}
blit_cyclecounter++;
blit_totalcyclecounter++;
}
}

if (blitter_vcounter1 >= blt_info.vblitsize && blitter_vcounter2 >= blt_info.vblitsize) {
if (!ddat1use && !ddat2use) {
blitter_done (last_blitter_hpos);
return;
}
}
// check this after end check because last D write won't cause any problems.
check_channel_mods(last_blitter_hpos, c);
// check this after end check because last D write won't cause any problems.
check_channel_mods (last_blitter_hpos, c);
break;
}

Expand All @@ -1337,29 +1337,29 @@ static void blitter_force_finish(bool state)
if (bltstate == BLT_done)
return;
if (bltstate != BLT_done) {
/* blitter is currently running
* force finish (no blitter state support yet)
*/
odmacon = dmacon;
dmacon |= DMA_MASTER | DMA_BLITTER;
if (state)
write_log(_T("forcing blitter finish\n"));
if (blitter_cycle_exact && !immediate_blits) {
int rounds = 10000;
/* blitter is currently running
* force finish (no blitter state support yet)
*/
odmacon = dmacon;
dmacon |= DMA_MASTER | DMA_BLITTER;
if (state)
write_log (_T("forcing blitter finish\n"));
if (blitter_cycle_exact && !immediate_blits) {
int rounds = 10000;
while (bltstate != BLT_done && rounds > 0) {
memset(cycle_line, 0, sizeof cycle_line);
decide_blitter(-1);
rounds--;
}
if (rounds == 0)
write_log(_T("blitter froze!?\n"));
memset (cycle_line, 0, sizeof cycle_line);
decide_blitter (-1);
rounds--;
}
if (rounds == 0)
write_log (_T("blitter froze!?\n"));
blit_startcycles = 0;
} else {
actually_do_blit();
} else {
actually_do_blit ();
}
blitter_done (current_hpos ());
dmacon = odmacon;
}
blitter_done(current_hpos());
dmacon = odmacon;
}
}

static bool invstate (void)
Expand Down Expand Up @@ -1601,7 +1601,7 @@ static void do_blitter2(int hpos, int copper, uaecptr pc)
if ((log_blitter & 2)) {
if (bltstate != BLT_done) {
if (blit_final) {
write_log (_T("blitter was already active! PC=%08x\n"), M68K_GETPC);
write_log (_T("blitter was already active! PC=%08x\n"), M68K_GETPC);
//activate_debugger();
}
}
Expand Down Expand Up @@ -1742,12 +1742,12 @@ void blitter_check_start (void)
{
if (bltstate != BLT_init)
return;
blitter_start_init();
blitter_start_init ();
bltstate = BLT_work;
if (immediate_blits) {
blitter_doit();
}
if (immediate_blits) {
blitter_doit ();
}
}

void do_blitter(int hpos, int copper, uaecptr pc)
{
Expand Down
29 changes: 4 additions & 25 deletions src/custom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3086,12 +3086,12 @@ STATIC_INLINE int one_fetch_cycle(int pos, int dma, int fm)

static void update_fetch_x(int until, int fm)
{
#ifdef AMIBERRY
int pos;

if (nodraw())
return;
#endif

int pos = last_fetch_hpos;
pos = last_fetch_hpos;
update_toscr_planes(fm);

// not optimized, update_fetch_x() is extremely rarely used.
Expand Down Expand Up @@ -3493,7 +3493,7 @@ static void decide_line(int hpos)
// if ECS: pre-set plf_end_hpos if we have already passed virtual ddfstop
if (ecs) {
// DDFSTRT=$18: always skip this condition. For some unknown reason.
if (last_decide_line_hpos < hstart && hstart >= plfstop && hstart - plfstop <= DDF_OFFSET) {
if (last_decide_line_hpos < hstart && hstart >= plfstop && hstart - plfstop <= DDF_OFFSET && hstart != HARD_DDF_START_REAL + DDF_OFFSET) {
plf_end_hpos = plfstop + DDF_OFFSET;
nextstate = plf_passed_stop;
}
Expand Down Expand Up @@ -6842,9 +6842,6 @@ static int copper_cant_read(int hpos, int alloc)
it subtly wrong; and it would also be more expensive - we want this code
to be fast. */

static uaecptr fc_ip_start = 0;
static uaecptr fc_ip_end = 0;

static void predict_copper(void)
{
uaecptr ip = cop_state.ip;
Expand All @@ -6855,8 +6852,6 @@ static void predict_copper(void)
unsigned int vcmp;
int vp;

fc_ip_end = 0;

if (cop_state.ignore_next || cop_state.movedelay)
return;

Expand Down Expand Up @@ -6889,8 +6884,6 @@ static void predict_copper(void)
break;
}

fc_ip_start = ip;

while (c_hpos < until_hpos && !force_exit) {

switch (state) {
Expand Down Expand Up @@ -6921,7 +6914,6 @@ static void predict_copper(void)
ip = cop1lc;
else
ip = cop2lc;
fc_ip_start = ip;
break;

case COP_start_delay:
Expand Down Expand Up @@ -7011,7 +7003,6 @@ static void predict_copper(void)
eventtab[ev_copper].active = 1;
eventtab[ev_copper].evtime = get_cycles() + cycle_count * CYCLE_UNIT;
events_schedule();
fc_ip_end = ip;
}
}
#endif
Expand Down Expand Up @@ -7472,18 +7463,6 @@ static void update_copper(int until_hpos)
#endif //AMIBERRY
}

#ifdef AMIBERRY
void check_copperlist_write(uaecptr addr)
{
if (addr >= fc_ip_start && addr < fc_ip_end) {
// Write to copperlist area detected
eventtab[ev_copper].active = 0;
if (copper_enabled_thisline)
update_copper(current_hpos());
}
}
#endif

static void compute_spcflag_copper(int hpos)
{
int wasenabled = copper_enabled_thisline;
Expand Down
44 changes: 22 additions & 22 deletions src/drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2119,15 +2119,15 @@ static void init_ham_decoding(void)
}
#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.color_regs_ecs[pv] & 0xfff; break;
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;
/* 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.color_regs_ecs[pv] & 0xfff; break;
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;
}
}
}
Expand Down Expand Up @@ -2182,17 +2182,17 @@ static void decode_ham(int pix, int stoppos, int blank)
}
#endif
} 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.color_regs_ecs[pv] & 0xfff; break;
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;
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
/* 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.color_regs_ecs[pv] & 0xfff; break;
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;
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
}
}
Expand Down Expand Up @@ -2780,9 +2780,9 @@ static void pfield_expand_dp_bplcon(void)
bplham = dp_for_drawing->ham_seen;
bplehb = dp_for_drawing->ehb_seen;
if ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && (dp_for_drawing->bplcon2 & 0x0200)) {
bplehb = 0;
bplehb = 0;
if (!(currprefs.chipset_mask & CSMASK_AGA))
bplehb = -1;
bplehb = -1;
}
issprites = dip_for_drawing->nr_sprites > 0;
bplcolorburst = (dp_for_drawing->bplcon0 & 0x200) != 0;
Expand Down
4 changes: 0 additions & 4 deletions src/include/custom.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ extern void dumpcustom (void);

extern void do_copper (void);

#ifdef AMIBERRY
extern void check_copperlist_write(uaecptr addr);
#endif

extern void notice_new_xcolors (void);
extern void notice_screen_contents_lost(int monid);
extern void init_row_map (void);
Expand Down
4 changes: 0 additions & 4 deletions src/memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -852,10 +852,6 @@ void REGPARAM2 chipmem_agnus_wput (uaecptr addr, uae_u32 w)
uae_u16 *m;

addr &= chipmem_full_mask;
#ifdef AMIBERRY
if (eventtab[ev_copper].active)
check_copperlist_write(addr);
#endif
if (addr >= chipmem_full_size - 1)
return;
m = (uae_u16 *)(chipmem_bank.baseaddr + addr);
Expand Down

0 comments on commit 5ccdb84

Please sign in to comment.