amiga/amigaaga.cpp: implement CLXCON2

This commit is contained in:
angelosa 2025-02-04 10:09:39 +01:00
parent 9ba5d7019e
commit 6b7c4bd9e2
3 changed files with 22 additions and 6 deletions

View File

@ -428,6 +428,7 @@ public:
uint16_t m_aga_sprdatb[8][4]{};
int m_aga_sprite_fetched_words = 0;
int m_aga_sprite_dma_used_words[8]{};
uint16_t m_aga_clxcon2;
void video_start_common();
DECLARE_VIDEO_START( amiga );

View File

@ -1317,11 +1317,12 @@ void amiga_state::aga_bplcon0_w(u16 data)
/*
* http://amiga-dev.wikidot.com/hardware:clxcon2
* ---- ---- xx-- ---- ENBPx enable bitplanes 8 and 7
* ---- ---- ---- --xx MVBPx match value for bitplanes 8 and 7
*/
void amiga_state::clxcon2_w(u16 data)
{
// TODO: enables bitplane 7-8 collision detection, resets to 0 if CLXCON write happens
popmessage("CLXCON2 %04x", data);
m_aga_clxcon2 = data;
}
// TODO: progressively remove functions from here
@ -1626,6 +1627,14 @@ void amiga_state::custom_chip_w(offs_t offset, uint16_t data)
break;
case REG_CLXCON:
if (IS_AGA())
{
// reset to zero on CLXCON writes
m_aga_clxcon2 = 0;
}
break;
case REG_INTENA:
temp = data;

View File

@ -670,8 +670,9 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
// - https://github.com/dirkwhoffmann/vAmigaTS/blob/master/Agnus/DDF/DDF/ddf1/ddf1_A500_ECS.JPG
// - turbojam (gameplay) fmode 3 18 9a lores, particularly when scrolling left (+15 isn't enough).
// - aladdin 38 ca fmode 3 lores
// - amigames:burnout 34 b8 fmode 3 hires
// - fbglory (main menu) 28 a4 lores
// - amigames:Burnout.lha 34 b8 fmode 3 hires
// - amigames:Wendetta.lha 28 d4 fmode 1 lores
if ( (CUSTOM_REG(REG_DDFSTRT) & 6) != (CUSTOM_REG(REG_DDFSTOP) & 6))
{
ddf_stop_pixel += defbitoffs;
@ -686,7 +687,9 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
/* extract collision masks */
ocolmask = (CUSTOM_REG(REG_CLXCON) >> 6) & 0x15;
ocolmask |= m_aga_clxcon2 & 0x40;
ecolmask = (CUSTOM_REG(REG_CLXCON) >> 6) & 0x2a;
ecolmask |= m_aga_clxcon2 & 0x80;
}
//if ((raw_scanline & 1) == 0)
@ -858,7 +861,11 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
/* compute playfield/sprite collisions for first pixel */
// NOTE: need to << 2 to please the upgraded get_sprite_pixel bitmask
// - dxgalaga player sprite collisions
collide = pfpix0 ^ CUSTOM_REG(REG_CLXCON);
// TODO: verify CLXCON2 match semantics
// - roadkill writes 0xc0
// - amigames:Wendetta*.lha writes 0x41 (planes offset below)
const u16 clxcon_match = (CUSTOM_REG(REG_CLXCON) | (m_aga_clxcon2 & 0x3) << 6);
collide = pfpix0 ^ clxcon_match;
if ((collide & ocolmask) == 0)
CUSTOM_REG(REG_CLXDAT) |= (sprpix >> (5 + 2)) & 0x01e;
if ((collide & ecolmask) == 0)
@ -867,14 +874,13 @@ void amiga_state::aga_render_scanline(bitmap_rgb32 &bitmap, int scanline)
CUSTOM_REG(REG_CLXDAT) |= 0x001;
/* compute playfield/sprite collisions for second pixel */
collide = pfpix1 ^ CUSTOM_REG(REG_CLXCON);
collide = pfpix1 ^ clxcon_match;
if ((collide & ocolmask) == 0)
CUSTOM_REG(REG_CLXDAT) |= (sprpix >> (5 + 2)) & 0x01e;
if ((collide & ecolmask) == 0)
CUSTOM_REG(REG_CLXDAT) |= (sprpix >> (1 + 2)) & 0x1e0;
if ((collide & (ecolmask | ocolmask)) == 0)
CUSTOM_REG(REG_CLXDAT) |= 0x001;
// TODO: CLXCON2
/* if we are within the display region, render */
if (dst != nullptr && x >= m_diw.left() && x < m_diw.right() && !out_of_beam)