mirror of
https://github.com/holub/mame
synced 2025-10-06 09:00:04 +03:00
merge some common code (nw)
This commit is contained in:
parent
35d0bc5b5f
commit
021457c27d
@ -1209,7 +1209,7 @@ static MACHINE_CONFIG_START( legionna, legionna_state )
|
||||
|
||||
SEIBU_SOUND_SYSTEM_CPU(14318180/4)
|
||||
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
/* video hardware */
|
||||
@ -1245,7 +1245,7 @@ static MACHINE_CONFIG_START( heatbrl, legionna_state )
|
||||
|
||||
SEIBU_SOUND_SYSTEM_CPU(14318180/4)
|
||||
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
/* video hardware */
|
||||
@ -1282,7 +1282,7 @@ static MACHINE_CONFIG_START( godzilla, legionna_state )
|
||||
|
||||
SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
|
||||
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
/* video hardware */
|
||||
@ -1320,7 +1320,7 @@ static MACHINE_CONFIG_START( denjinmk, legionna_state )
|
||||
|
||||
SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
|
||||
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
/* video hardware */
|
||||
@ -1357,7 +1357,7 @@ static MACHINE_CONFIG_START( grainbow, legionna_state )
|
||||
|
||||
SEIBU2_SOUND_SYSTEM_CPU(14318180/4)
|
||||
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
/* video hardware */
|
||||
@ -1395,7 +1395,7 @@ static MACHINE_CONFIG_START( cupsoc, legionna_state )
|
||||
|
||||
SEIBU_SOUND_SYSTEM_CPU(14318180/4)
|
||||
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
/* video hardware */
|
||||
@ -1436,7 +1436,7 @@ static MACHINE_CONFIG_START( cupsocbl, legionna_state )
|
||||
MCFG_CPU_VBLANK_INT_DRIVER("screen", legionna_state, irq4_line_hold) /* VBL */
|
||||
|
||||
MCFG_SEIBU_COP_ADD("seibucop_boot")
|
||||
MCFG_RAIDEN2COP_ADD("raiden2cop")
|
||||
MCFG_LEGIONNACOP_ADD("raiden2cop")
|
||||
MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(legionna_state, videowrite_cb_w))
|
||||
|
||||
|
||||
|
@ -62,6 +62,8 @@ raiden2cop_device::raiden2cop_device(const machine_config &mconfig, const char *
|
||||
m_LEGACY_r0(0),
|
||||
m_LEGACY_r1(0),
|
||||
|
||||
m_cpu_is_68k(0),
|
||||
|
||||
m_videoramout_cb(*this),
|
||||
m_palette(*this, ":palette")
|
||||
{
|
||||
@ -170,9 +172,16 @@ void raiden2cop_device::device_start()
|
||||
|
||||
}
|
||||
|
||||
UINT16 raiden2cop_device::cop_read_word(address_space &space, int address)
|
||||
{
|
||||
if (m_cpu_is_68k) return space.read_word(address ^ 2);
|
||||
else return space.read_word(address);
|
||||
}
|
||||
|
||||
/*** Command Table uploads ***/
|
||||
|
||||
|
||||
|
||||
WRITE16_MEMBER(raiden2cop_device::cop_pgm_data_w)
|
||||
{
|
||||
assert(ACCESSING_BITS_0_7 && ACCESSING_BITS_8_15);
|
||||
@ -789,11 +798,42 @@ READ16_MEMBER(raiden2cop_device::cop_itoa_digits_r)
|
||||
|
||||
0f - 7905 (7905 ) : (1a2, 2c2, 0a2, 000, 000, 000, 000, 000) 6 fffb (cupsoc, grainbow)
|
||||
0f - 7e05 (7e05 ) : (180, 282, 080, 180, 282, 000, 000, 000) 6 fffb (raidendx)
|
||||
*/
|
||||
|
||||
/*
|
||||
10 - 8100 (8100 ) : (b9a, b88, 888, 000, 000, 000, 000, 000) 7 fdfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae)
|
||||
*/
|
||||
|
||||
void raiden2cop_device::execute_8100(address_space &space, int offset, UINT16 data)
|
||||
{
|
||||
int raw_angle = (cop_read_word(space, cop_regs[0] + (0x34)) & 0xff);
|
||||
double angle = raw_angle * M_PI / 128;
|
||||
double amp = (65536 >> 5)*(cop_read_word(space, cop_regs[0] + (0x36)) & 0xff);
|
||||
int res;
|
||||
/* TODO: up direction needs double, why? */
|
||||
if (raw_angle == 0xc0)
|
||||
amp *= 2;
|
||||
res = int(amp*sin(angle)) << cop_scale;
|
||||
space.write_dword(cop_regs[0] + 16, res);
|
||||
}
|
||||
|
||||
/*
|
||||
11 - 8900 (8900 ) : (b9a, b8a, 88a, 000, 000, 000, 000, 000) 7 fdfb (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk, raiden2, raidendx, zeroteam, xsedae)
|
||||
*/
|
||||
void raiden2cop_device::execute_8900(address_space &space, int offset, UINT16 data)
|
||||
{
|
||||
int raw_angle = (cop_read_word(space, cop_regs[0] + (0x34)) & 0xff);
|
||||
double angle = raw_angle * M_PI / 128;
|
||||
double amp = (65536 >> 5)*(cop_read_word(space, cop_regs[0] + (0x36)) & 0xff);
|
||||
int res;
|
||||
/* TODO: up direction needs double, why? */
|
||||
if (raw_angle == 0x80)
|
||||
amp *= 2;
|
||||
res = int(amp*cos(angle)) << cop_scale;
|
||||
space.write_dword(cop_regs[0] + 20, res);
|
||||
}
|
||||
|
||||
/*
|
||||
12 - 9180 (9100 ) : (b80, b94, b94, 894, 000, 000, 000, 000) 7 f8f7 (heatbrl, legionna, cupsoc, godzilla, grainbow, denjinmk)
|
||||
12 - 9100 (9100 ) : (b80, b94, 894, 000, 000, 000, 000, 000) 7 fefb (raiden2, raidendx)
|
||||
12 - 9100 (9100 ) : (b80, b94, b94, 894, 000, 000, 000, 000) 7 f8f7 (zeroteam, xsedae)
|
||||
@ -1081,28 +1121,12 @@ WRITE16_MEMBER( raiden2cop_device::cop_cmd_w)
|
||||
}
|
||||
|
||||
case 0x8100: { // 8100 0007 fdfb 0080 - 0b9a 0b88 0888 0000 0000 0000 0000 0000
|
||||
int raw_angle = (space.read_word(cop_regs[0]+(0x34)) & 0xff);
|
||||
double angle = raw_angle * M_PI / 128;
|
||||
double amp = (65536 >> 5)*(space.read_word(cop_regs[0]+(0x36)) & 0xff);
|
||||
int res;
|
||||
/* TODO: up direction, why? (check machine/seicop.c) */
|
||||
if(raw_angle == 0xc0)
|
||||
amp*=2;
|
||||
res = int(amp*sin(angle)) << cop_scale;
|
||||
space.write_dword(cop_regs[0] + 16, res);
|
||||
execute_8100(space, offset, data); // SIN
|
||||
break;
|
||||
}
|
||||
|
||||
case 0x8900: { // 8900 0007 fdfb 0088 - 0b9a 0b8a 088a 0000 0000 0000 0000 0000
|
||||
int raw_angle = (space.read_word(cop_regs[0]+(0x34)) & 0xff);
|
||||
double angle = raw_angle * M_PI / 128;
|
||||
double amp = (65536 >> 5)*(space.read_word(cop_regs[0]+(0x36)) & 0xff);
|
||||
int res;
|
||||
/* TODO: left direction, why? (check machine/seicop.c) */
|
||||
if(raw_angle == 0x80)
|
||||
amp*=2;
|
||||
res = int(amp*cos(angle)) << cop_scale;
|
||||
space.write_dword(cop_regs[0] + 20, res);
|
||||
execute_8900(space, offset, data); // COS
|
||||
break;
|
||||
}
|
||||
|
||||
@ -1499,18 +1523,7 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w)
|
||||
if (check_command_matches(command, 0xb9a, 0xb88, 0x888, 0x000, 0x000, 0x000, 0x000, 0x000, 7, 0xfdfb))
|
||||
{
|
||||
executed = 1;
|
||||
int raw_angle = (space.read_word(cop_regs[0] + (0x34 ^ 2)) & 0xff);
|
||||
double angle = raw_angle * M_PI / 128;
|
||||
double amp = (65536 >> 5)*(space.read_word(cop_regs[0] + (0x36 ^ 2)) & 0xff);
|
||||
int res;
|
||||
|
||||
/* TODO: up direction, why? */
|
||||
if (raw_angle == 0xc0)
|
||||
amp *= 2;
|
||||
|
||||
res = int(amp*sin(angle)) << cop_scale;
|
||||
|
||||
space.write_dword(cop_regs[0] + 0x10, res);
|
||||
execute_8100(space, offset, data); // SIN
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1529,18 +1542,7 @@ WRITE16_MEMBER(raiden2cop_device::LEGACY_cop_cmd_w)
|
||||
if (check_command_matches(command, 0xb9a, 0xb8a, 0x88a, 0x000, 0x000, 0x000, 0x000, 0x000, 7, 0xfdfb))
|
||||
{
|
||||
executed = 1;
|
||||
int raw_angle = (space.read_word(cop_regs[0] + (0x34 ^ 2)) & 0xff);
|
||||
double angle = raw_angle * M_PI / 128;
|
||||
double amp = (65536 >> 5)*(space.read_word(cop_regs[0] + (0x36 ^ 2)) & 0xff);
|
||||
int res;
|
||||
|
||||
/* TODO: left direction, why? */
|
||||
if (raw_angle == 0x80)
|
||||
amp *= 2;
|
||||
|
||||
res = int(amp*cos(angle)) << cop_scale;
|
||||
|
||||
space.write_dword(cop_regs[0] + 20, res);
|
||||
execute_8900(space, offset, data); // COS
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -9,8 +9,7 @@
|
||||
#define RAIDEN2COP_H
|
||||
|
||||
|
||||
#define MCFG_RAIDEN2COP_ADD(_tag ) \
|
||||
MCFG_DEVICE_ADD(_tag, RAIDEN2COP, 0)
|
||||
|
||||
|
||||
#define MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(_devcb) \
|
||||
devcb = &raiden2cop_device::set_m_videoramout_cb(*device, DEVCB_##_devcb);
|
||||
@ -18,6 +17,17 @@
|
||||
#define MCFG_ITOA_UNUSED_DIGIT_VALUE(value) \
|
||||
raiden2cop_device::set_itoa_unused_digit_value(*device, value);
|
||||
|
||||
#define MCFG_CPU_IS_68K(value) \
|
||||
raiden2cop_device::set_cpu_is_68k(*device, value);
|
||||
|
||||
#define MCFG_RAIDEN2COP_ADD(_tag ) \
|
||||
MCFG_DEVICE_ADD(_tag, RAIDEN2COP, 0) \
|
||||
MCFG_CPU_IS_68K(0)
|
||||
|
||||
#define MCFG_LEGIONNACOP_ADD(_tag ) \
|
||||
MCFG_DEVICE_ADD(_tag, RAIDEN2COP, 0) \
|
||||
MCFG_CPU_IS_68K(1)
|
||||
|
||||
|
||||
class raiden2cop_device : public device_t
|
||||
{
|
||||
@ -136,6 +146,9 @@ public:
|
||||
void cop_collision_read_pos(address_space &space, int slot, UINT32 spradr, bool allow_swap);
|
||||
void cop_collision_update_hitbox(address_space &space, int slot, UINT32 hitadr);
|
||||
|
||||
void execute_8100(address_space &space, int offset, UINT16 data);
|
||||
void execute_8900(address_space &space, int offset, UINT16 data);
|
||||
|
||||
// Sort DMA (zeroteam, cupsoc)
|
||||
|
||||
UINT32 cop_sort_ram_addr, cop_sort_lookup;
|
||||
@ -203,7 +216,10 @@ public:
|
||||
void LEGACY_cop_take_hit_box_params(UINT8 offs);
|
||||
UINT8 LEGACY_cop_calculate_collsion_detection();
|
||||
|
||||
|
||||
// endian stuff?
|
||||
int m_cpu_is_68k;
|
||||
static void set_cpu_is_68k(device_t &device, int value) { downcast<raiden2cop_device &>(device).m_cpu_is_68k = value; }
|
||||
UINT16 cop_read_word(address_space &space, int address);
|
||||
|
||||
// DEBUG
|
||||
void dump_table();
|
||||
|
Loading…
Reference in New Issue
Block a user