Skip to content

Commit 252fba2

Browse files
committed
amiga/agnus_copper: delay MOVE writes regardless of what register it triggers
1 parent 999a9a2 commit 252fba2

File tree

5 files changed

+21
-44
lines changed

5 files changed

+21
-44
lines changed

hash/amigaocs_flop.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -49337,7 +49337,7 @@ ATK test: OK
4933749337
<publisher>Team 17</publisher>
4933849338
<notes><![CDATA[
4933949339
Red screen [FDC] dsksync (fixed?)
49340-
a500: no main sprite (works with a500p, a1200)
49340+
Main sprite randomly don't show up, [Copper]?
4934149341
[Copper] cuts bottom part of screen badly during gameplay, may use SKIP
4934249342
ATK test: failed
4934349343
]]></notes>

src/mame/amiga/agnus_copper.cpp

+12-17
Original file line numberDiff line numberDiff line change
@@ -309,22 +309,14 @@ int agnus_copper_device::execute_next(int xpos, int ypos, bool is_blitter_busy,
309309
word0 = (word0 >> 1) & 0xff;
310310
if (word0 >= m_cdang_setting)
311311
{
312-
if (delay[word0] == 0)
313-
{
314-
//LOGCHIPSET("%02X.%02X: Write to %s = %04x\n", ypos, xpos / 2, s_custom_reg_names[word0 & 0xff], word1);
315-
LOGCHIPSET("%02X.%02X: MOVE $dff%03x = %04x\n",
316-
ypos,
317-
xpos / 2,
318-
word0 << 1,
319-
word1
320-
);
321-
m_host_space->write_word(0xdff000 | (word0 << 1), word1);
322-
}
323-
else // additional 2 cycles needed for non-Agnus registers
324-
{
325-
m_pending_offset = word0;
326-
m_pending_data = word1;
327-
}
312+
// delay write to the next available DMA slot if not in blanking area
313+
// - bchvolly (title), suprfrog & abreed (bottom playfield rows)
314+
const bool horizontal_blank = xpos < 0x47;
315+
const int move_offset = horizontal_blank ? 0 : std::max(num_planes - 4, 0);
316+
317+
m_pending_offset = word0;
318+
m_pending_data = word1;
319+
xpos += COPPER_CYCLES_TO_PIXELS(move_offset);
328320
}
329321

330322
/* illegal writes suspend until next frame */
@@ -351,7 +343,8 @@ int agnus_copper_device::execute_next(int xpos, int ypos, bool is_blitter_busy,
351343
/* handle a wait */
352344
if ((word1 & 1) == 0)
353345
{
354-
const int wait_offset = std::max(num_planes - 4, 0) + 1;
346+
const bool horizontal_blank = xpos < 0x47;
347+
const int wait_offset = horizontal_blank ? 0 : std::max(num_planes - 4, 0) + 1;
355348

356349
LOGINST(" WAIT %04x & %04x (currently %04x, num planes %d +%d)\n",
357350
m_waitval,
@@ -383,6 +376,8 @@ int agnus_copper_device::execute_next(int xpos, int ypos, bool is_blitter_busy,
383376
LOGINST(" Skipped\n");
384377

385378
/* count the cycles it out have taken to fetch the next instruction */
379+
// TODO: look ahead, check if next instruction is a valid MOVE
380+
// SKIP/WAIT and illegal instructions aren't skipped.
386381
m_pc += 4;
387382
xpos += COPPER_CYCLES_TO_PIXELS(2);
388383
}

src/mame/amiga/agnus_copper.h

-24
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,6 @@ class agnus_copper_device : public device_t
6868
u16 m_waitmask;
6969
u16 m_pending_offset;
7070
u16 m_pending_data;
71-
72-
// waitstate delays for copper
73-
// basically anything that doesn't belong to Angus has a penalty for Copper
74-
static constexpr u16 delay[256] =
75-
{
76-
1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,0,0,0,0, /* 0x000 - 0x03e */
77-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x040 - 0x05e */
78-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x060 - 0x07e */
79-
0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0, /* 0x080 - 0x09e */
80-
1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0,1,1,0,0,0,0,0,0, /* 0x0a0 - 0x0de */
81-
/* BPLxPTH/BPLxPTL */
82-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x0e0 - 0x0fe */
83-
/* BPLCON0-3,BPLMOD1-2 */
84-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x100 - 0x11e */
85-
/* SPRxPTH/SPRxPTL */
86-
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0x120 - 0x13e */
87-
/* SPRxPOS/SPRxCTL/SPRxDATA/SPRxDATB */
88-
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, /* 0x140 - 0x17e */
89-
/* COLORxx */
90-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* 0x180 - 0x1be */
91-
/* RESERVED */
92-
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* 0x1c0 - 0x1fe */
93-
};
94-
9571
};
9672

9773

src/mame/amiga/amiga_m.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1700,6 +1700,9 @@ void amiga_state::custom_chip_w(offs_t offset, uint16_t data)
17001700
{
17011701
CUSTOM_REG(REG_BEAMCON0) = data;
17021702
update_screenmode();
1703+
// TODO: variable beam counter, disables hard display stops, enables HTOTAL/VTOTAL programming
1704+
if (BIT(data, 7))
1705+
popmessage("BEAMCON0: VARBEAMEN enabled");
17031706
}
17041707
break;
17051708

src/mame/amiga/amigaaga.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -623,10 +623,13 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
623623

624624
if ((raw_scanline & 1) == 0)
625625
{
626+
const int min_x = 0x18 << 1;
627+
const int max_x = 0x34 << 1;
628+
626629
// TODO: refine, merge with OCS version
627-
if (x >= 0x18 && x <= 0x34 && (x & 3) == 0)
630+
if (x >= min_x && x <= max_x && (x & 7) == 0)
628631
{
629-
int num = (x - 0x18) >> 2;
632+
int num = (x - min_x) >> 3;
630633
//printf("%d %02x\n", num, x);
631634
aga_update_sprite_dma(raw_scanline >> 1, num);
632635
}

0 commit comments

Comments
 (0)