Skip to content

Commit

Permalink
amiga/agnus_copper.cpp: add vblank line mechanism for penalties
Browse files Browse the repository at this point in the history
  • Loading branch information
angelosa committed Jan 26, 2025
1 parent 3c0a92e commit c95c4f5
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 24 deletions.
5 changes: 3 additions & 2 deletions hash/amiga_cd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ cd32: unsupported [Akiko] close tray after CD32 BIOS plays back music, will othe
<!-- Packaging Design: Epic Marketing -->
<publisher>APC &amp; TCP</publisher>
<notes><![CDATA[
Intro and main menu use [Denise] BPLCON3 SPRESx
Optional [Denise] SHRES mode in gameplay
Intro and main menu use [Lisa] BPLCON3 SPRESx
Optional [Lisa] SHRES mode in gameplay
Very easy to ball stuck in table 2 (verify, https://forums.bannister.org/ubbthreads.php?ubb=showflat&Number=124163#Post124163)
Editor and HD Install untested
]]></notes>
<!-- TODO: verify assign BrainDamage: "Brain Damage:" before install as Erratum note -->
Expand Down
11 changes: 7 additions & 4 deletions hash/amigaaga_flop.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ license:CC0-1.0
The software listed here is not designed for use on systems without the AGA chipset and
will not function.
Note:
- Please use [Lisa] / [Alice] tag where issues are specifically for amiga/amigaaga.cpp
-->

<softwarelist name="amigaaga_flop" description="Commodore Amiga AGA disk images">
Expand Down Expand Up @@ -2529,7 +2532,7 @@ Red screen when "Out to lunch is loading" displays, [FDC]
<year>1995</year>
<publisher>21st Century Entertainment</publisher>
<notes><![CDATA[
[Denise] Bitplane overlay is offset on title screen
[Lisa] Bitplane overlay is offset on title screen
Doesn't draw left bumper during gameplay [Copper]?
]]></notes>
<info name="usage" value="Requires AGA" />
Expand Down Expand Up @@ -3638,7 +3641,7 @@ ATK test: C:0 H:U Bad
<year>1996</year>
<publisher>21st Century</publisher>
<notes><![CDATA[
Has no cursor on main menu
[Denise] has no cursor on main menu, should output with plane 0x10 (pfxpri 0x3f), amigaocs_flop:swiv related trick?
On gameplay unthrottle emulation causes idle vertical scroll to be slower
]]></notes>
<info name="usage" value="Requires AGA" />
Expand Down Expand Up @@ -4990,8 +4993,8 @@ Pressing TAB key will switch to NTSC mode (?), which cuts off bottom of screen
<publisher>Edgar Vigdal</publisher>
<notes><![CDATA[
Guru Meditation when run stand-alone (fixed)
[Denise] bonus items don't collide in gameplay
Throws "file is missing" when installed to HDD
[Denise] bonus items and enemy to player bullets don't collide in gameplay, CLXCON even mask
TODO: Throws "file is missing" when installed to HDD
]]></notes>
<info name="usage" value="Requires AGA" />

Expand Down
14 changes: 9 additions & 5 deletions src/mame/amiga/agnus_copper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,14 @@ void agnus_copper_device::copins_w(u16 data)
//**************************************************************************

// executed on scanline == 0
void agnus_copper_device::vblank_sync()
void agnus_copper_device::vblank_sync(bool state)
{
set_pc(0, true);
m_xpos_state = 0;
if (state)
{
set_pc(0, true);
m_xpos_state = 0;
}
m_vertical_blank = state;
}

// check current copper cycle at end of scanline
Expand Down Expand Up @@ -343,7 +347,7 @@ int agnus_copper_device::execute_next(int xpos, int ypos, bool is_blitter_busy,
// - suprfrog & abreed (bottom playfield rows).
// - beast, biochall and cd32 bios wants this to be 0x5c
const bool horizontal_blank = xpos <= 0x5c;
const int move_offset = horizontal_blank ? 0 : std::max(num_planes - 4, 0);
const int move_offset = horizontal_blank || m_vertical_blank ? 0 : std::max(num_planes - 4, 0);

m_pending_offset = word0;
m_pending_data = word1;
Expand Down Expand Up @@ -376,7 +380,7 @@ int agnus_copper_device::execute_next(int xpos, int ypos, bool is_blitter_busy,
if ((word1 & 1) == 0)
{
const bool horizontal_blank = xpos <= 0x5c;
const int wait_offset = horizontal_blank ? 0 : std::max(num_planes - 4, 0) + 1;
const int wait_offset = horizontal_blank || m_vertical_blank ? 0 : std::max(num_planes - 4, 0) + 1;

LOGINST(" WAIT %04x & %04x (currently %04x, num planes %d +%d)\n",
m_waitval,
Expand Down
3 changes: 2 additions & 1 deletion src/mame/amiga/agnus_copper.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class agnus_copper_device : public device_t
void copcon_w(u16 data);

// getters/setters
void vblank_sync();
void vblank_sync(bool state);
int execute_next(int xpos, int ypos, bool is_blitter_busy, int num_planes);
void suspend_offset(int xpos, int hblank_width);
int restore_offset();
Expand Down Expand Up @@ -72,6 +72,7 @@ class agnus_copper_device : public device_t
u16 m_pending_offset;
u16 m_pending_data;
u16 m_xpos_state;
bool m_vertical_blank;
};


Expand Down
3 changes: 3 additions & 0 deletions src/mame/amiga/amiga.h
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ class amiga_state : public driver_device
void amiga_palette(palette_device &palette) const;

uint32_t screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);

bool get_screen_standard();
int get_screen_vblank_line();
void update_screenmode();

TIMER_CALLBACK_MEMBER( scanline_callback );
Expand Down
31 changes: 21 additions & 10 deletions src/mame/amiga/amiga_v.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ void amiga_state::render_scanline(bitmap_rgb32 &bitmap, int scanline)
CUSTOM_REG(REG_VPOSR) ^= VPOSR_LOF;

// reset copper and ham color
m_copper->vblank_sync();
m_copper->vblank_sync(true);
m_ham_color = CUSTOM_REG(REG_COLOR00);
}

Expand Down Expand Up @@ -526,6 +526,10 @@ void amiga_state::render_scanline(bitmap_rgb32 &bitmap, int scanline)

scanline /= 2;

// notify copper that we are not in vblank anymore
if (scanline == get_screen_vblank_line())
m_copper->vblank_sync(false);

m_last_scanline = scanline;

/* all sprites off at the start of the line */
Expand Down Expand Up @@ -904,17 +908,24 @@ uint32_t amiga_state::screen_update(screen_device &screen, bitmap_rgb32 &bitmap,
return 0;
}

void amiga_state::update_screenmode()
bool amiga_state::get_screen_standard()
{
bool pal;

// first let's see if we're PAL or NTSC
// we support dynamic switching between PAL and NTSC, determine mode from register
if (m_agnus_id >= AGNUS_HR_PAL)
// we support dynamic switching between PAL and NTSC, determine mode from register
pal = CUSTOM_REG(REG_BEAMCON0) & 0x20;
else
// old agnus, agnus id determines PAL or NTSC
pal = !(m_agnus_id & 0x10);
return CUSTOM_REG(REG_BEAMCON0) & 0x20;

// old agnus, agnus id determines PAL or NTSC
return !(m_agnus_id & 0x10);
}

int amiga_state::get_screen_vblank_line()
{
return get_screen_standard() ? amiga_state::VBLANK_PAL : amiga_state::VBLANK_NTSC;
}

void amiga_state::update_screenmode()
{
bool pal = get_screen_standard();

// basic height & vblank length
int height = pal ? SCREEN_HEIGHT_PAL : SCREEN_HEIGHT_NTSC;
Expand Down
7 changes: 5 additions & 2 deletions src/mame/amiga/amigaaga.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
if (CUSTOM_REG(REG_BPLCON0) & BPLCON0_LACE)
CUSTOM_REG(REG_VPOSR) ^= VPOSR_LOF;

m_copper->vblank_sync();
m_copper->vblank_sync(true);
m_ham_color = CUSTOM_REG(REG_COLOR00);
}

Expand Down Expand Up @@ -519,6 +519,9 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)

scanline /= 2;

if (scanline == get_screen_vblank_line())
m_copper->vblank_sync(false);

m_last_scanline = scanline;

/* all sprites off at the start of the line */
Expand Down Expand Up @@ -608,7 +611,7 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
x,
m_last_scanline & 0xff,
bool(BIT(CUSTOM_REG(REG_DMACON), 14)), // BBUSY
planes
bitplane_fmode ? 0 : planes
);
save_color0 = CUSTOM_REG(REG_COLOR00);
if (m_genlock_color != 0xffff)
Expand Down

0 comments on commit c95c4f5

Please sign in to comment.