Skip to content

Commit

Permalink
konami/thunderx.cpp: Simplified 052591 PMC emulation code a little. (#…
Browse files Browse the repository at this point in the history
…11759)

Removed some redundant variables, and removed complementary division/multiplication.
  • Loading branch information
jotego committed Nov 19, 2023
1 parent 8cb834b commit e4d59f2
Showing 1 changed file with 15 additions and 26 deletions.
41 changes: 15 additions & 26 deletions src/mame/konami/thunderx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,12 +365,7 @@ this is the data written to internal ram on startup:

void thunderx_state::run_collisions( int s0, int e0, int s1, int e1, int cm, int hm )
{
uint8_t* p0;
uint8_t* p1;
int ii, jj;

p0 = &m_pmcram[16 + 5 * s0];
for (ii = s0; ii < e0; ii++, p0 += 5)
for (uint8_t* p0 = &m_pmcram[s0]; p0 < &m_pmcram[e0]; p0 += 5)
{
int l0, r0, b0, t0;

Expand All @@ -384,8 +379,7 @@ void thunderx_state::run_collisions( int s0, int e0, int s1, int e1, int cm, int
t0 = p0[4] - p0[2];
b0 = p0[4] + p0[2];

p1 = &m_pmcram[16 + 5 * s1];
for (jj = s1; jj < e1; jj++,p1 += 5)
for (uint8_t* p1 = &m_pmcram[s1]; p1 < &m_pmcram[e1]; p1 += 5)
{
int l1,r1,b1,t1;

Expand All @@ -406,8 +400,8 @@ void thunderx_state::run_collisions( int s0, int e0, int s1, int e1, int cm, int
if (t0 >= b1) continue;

// set flags
p0[0] = (p0[0] & 0x9f) | (p1[0] & 0x04) | 0x10;
p1[0] = (p1[0] & 0x9f) | 0x10;
p0[0] = (p0[0] & 0x8f) | (p1[0] & 0x04) | 0x10;
p1[0] = (p1[0] & 0x8f) | 0x10;
}
}
}
Expand All @@ -418,9 +412,7 @@ void thunderx_state::run_collisions( int s0, int e0, int s1, int e1, int cm, int

void thunderx_state::calculate_collisions()
{
int X0,Y0;
int X1,Y1;
int CM,HM;
int s0, s1;

// the data at 0x00 to 0x06 defines the operation
//
Expand All @@ -441,30 +433,27 @@ void thunderx_state::calculate_collisions()
// hit mask is 40 to set bit on object 0 and object 1
// hit mask is 20 to set bit on object 1 only

Y0 = m_pmcram[0];
Y0 = (Y0 << 8) + m_pmcram[1];
Y0 = (Y0 - 15) / 5;
Y1 = (m_pmcram[2] - 15) / 5;
const int e0 = (m_pmcram[0]<<8) | m_pmcram[1];
const int e1 = m_pmcram[2];

if (m_pmcram[5] < 16)
{
// US Thunder Cross uses this form
X0 = m_pmcram[5];
X0 = (X0 << 8) + m_pmcram[6];
X0 = (X0 - 16) / 5;
X1 = (m_pmcram[7] - 16) / 5;
s0 = m_pmcram[5];
s0 = (s0 << 8) + m_pmcram[6];
s1 = m_pmcram[7];
}
else
{
// Japan Thunder Cross uses this form
X0 = (m_pmcram[5] - 16) / 5;
X1 = (m_pmcram[6] - 16) / 5;
s0 = m_pmcram[5];
s1 = m_pmcram[6];
}

CM = m_pmcram[3];
HM = m_pmcram[4];
const int cm = m_pmcram[3];
const int hm = m_pmcram[4];

run_collisions(X0, Y0, X1, Y1, CM, HM);
run_collisions(s0, e0, s1, e1, cm, hm);
}

void thunderx_state_base::scontra_1f98_w(uint8_t data)
Expand Down

0 comments on commit e4d59f2

Please sign in to comment.