From: Aladar [mailto:cicciopetito@alice.it]

Sent: Sunday, March 22, 2009 4:09 AM
To: submit@mamedev.org
Subject: KiKi KaiKai sprite collision fix (ref. mame 0.103u1).

KiKi KaiKai sprite collision fix (ref. mame 0.103u1).
This patch fixes the sprite collision code of the mcu simulation in 'machine\mexico86.c'.
This commit is contained in:
Aaron Giles 2009-03-27 13:39:17 +00:00
parent 9549910dbc
commit 8a8f56a9bd

View File

@ -132,19 +132,23 @@ logerror("initialising MCU\n");
// The following is missing from Knight Boy
// this should be equivalent to the obfuscated kiki_clogic() below
{
static const int db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
int sy = mexico86_protection_ram[0xa0] + ((0x18)>>1);
int sx = mexico86_protection_ram[0xa1] + ((0x18)>>1);
static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
UINT16 sy = mexico86_protection_ram[0xa0] + ((0x18)>>1);
UINT16 sx = mexico86_protection_ram[0xa1] + ((0x18)>>1);
for (i = 0; i < 0x38; i += 8)
{
int hw = db[mexico86_protection_ram[0x20 + i] & 0xf];
UINT8 hw = db[mexico86_protection_ram[0x20 + i] & 0xf];
if (hw)
{
if (abs(sx - (mexico86_protection_ram[0x20 + i+6] * 256 + mexico86_protection_ram[0x20 + i+7])) < hw &&
abs(sy - (mexico86_protection_ram[0x20 + i+4] * 256 + mexico86_protection_ram[0x20 + i+5])) < hw)
mexico86_protection_ram[0xa2] = 1; // we have a collision
UINT16 xdiff = sx - ((UINT16)mexico86_protection_ram[0x20 + i+6] << 8 | mexico86_protection_ram[0x20 + i+7]);
if (xdiff < hw)
{
UINT16 ydiff = sy - ((UINT16)mexico86_protection_ram[0x20 + i+4] << 8 | mexico86_protection_ram[0x20 + i+5]);
if (ydiff < hw)
mexico86_protection_ram[0xa2] = 1; // we have a collision
}
}
}
}