diff --git a/src/mame/drivers/legionna.c b/src/mame/drivers/legionna.c index e7d0b45cef7..484f9268eb4 100644 --- a/src/mame/drivers/legionna.c +++ b/src/mame/drivers/legionna.c @@ -92,9 +92,9 @@ WRITE16_MEMBER(legionna_state::sound_comms_w) static ADDRESS_MAP_START( legionna_cop_mem, AS_PROGRAM, 16, legionna_state ) // AM_RANGE(0x10041c, 0x10041d) AM_WRITE(cop_angle_target_w) // angle target (for 0x6200 COP macro) // AM_RANGE(0x10041e, 0x10041f) AM_WRITE(cop_angle_step_w) // angle step (for 0x6200 COP macro) -// AM_RANGE(0x100420, 0x100421) AM_WRITE(cop_itoa_low_w) -// AM_RANGE(0x100422, 0x100423) AM_WRITE(cop_itoa_high_w) -// AM_RANGE(0x100424, 0x100425) AM_WRITE(cop_itoa_digit_count_w) + AM_RANGE(0x100420, 0x100421) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_low_w) + AM_RANGE(0x100422, 0x100423) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_high_w) + AM_RANGE(0x100424, 0x100425) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_digit_count_w) AM_RANGE(0x100428, 0x100429) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v1_w) AM_RANGE(0x10042a, 0x10042b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v2_w) AM_RANGE(0x100432, 0x100433) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_data_w) @@ -124,7 +124,7 @@ static ADDRESS_MAP_START( legionna_cop_mem, AS_PROGRAM, 16, legionna_state ) // AM_RANGE(0x100580, 0x100581) AM_READ(cop_collision_status_r) // AM_RANGE(0x100582, 0x100587) AM_READ(cop_collision_status_val_r) // AM_RANGE(0x100588, 0x100589) AM_READ(cop_collision_status_stat_r) -// AM_RANGE(0x100590, 0x100599) AM_READ(cop_itoa_digits_r) + AM_RANGE(0x100590, 0x100599) AM_DEVREAD("raiden2cop", raiden2cop_device, cop_itoa_digits_r) // AM_RANGE(0x1005b0, 0x1005b1) AM_READ(cop_status_r) // AM_RANGE(0x1005b2, 0x1005b3) AM_READ(cop_dist_r) // AM_RANGE(0x1005b4, 0x1005b5) AM_READ(cop_angle_r) diff --git a/src/mame/drivers/raiden2.c b/src/mame/drivers/raiden2.c index 89b62d78c52..9d545f2486b 100644 --- a/src/mame/drivers/raiden2.c +++ b/src/mame/drivers/raiden2.c @@ -173,10 +173,9 @@ void raiden2_state::machine_start() save_item(NAME(raiden2_tilemap_enable)); save_item(NAME(prg_bank)); save_item(NAME(cop_bank)); - save_item(NAME(cop_itoa)); save_item(NAME(cop_status)); save_item(NAME(cop_scale)); - save_item(NAME(cop_itoa_digit_count)); + save_item(NAME(cop_angle)); save_item(NAME(cop_dist)); @@ -197,7 +196,8 @@ void raiden2_state::machine_start() save_item(NAME(scrollvals)); save_item(NAME(cop_regs)); - save_item(NAME(cop_itoa_digits)); + + save_item(NAME(sprite_prot_src_addr)); @@ -257,39 +257,6 @@ WRITE16_MEMBER(raiden2_state::m_videoram_private_w) } } -WRITE16_MEMBER(raiden2_state::cop_itoa_low_w) -{ - cop_itoa = (cop_itoa & ~UINT32(mem_mask)) | (data & mem_mask); - - int digits = 1 << cop_itoa_digit_count*2; - UINT32 val = cop_itoa; - - if(digits > 9) - digits = 9; - for(int i=0; i m_gfxdecode; required_device m_palette; - DECLARE_WRITE16_MEMBER( cop_itoa_low_w ); - DECLARE_WRITE16_MEMBER( cop_itoa_high_w ); - DECLARE_WRITE16_MEMBER( cop_itoa_digit_count_w ); + DECLARE_WRITE16_MEMBER( cop_scale_w ); DECLARE_WRITE16_MEMBER( cop_angle_target_w ); DECLARE_WRITE16_MEMBER( cop_angle_step_w ); @@ -77,7 +74,6 @@ public: DECLARE_WRITE16_MEMBER( cop_reg_low_w ); DECLARE_WRITE16_MEMBER( cop_cmd_w ); - DECLARE_READ16_MEMBER ( cop_itoa_digits_r ); DECLARE_READ16_MEMBER ( cop_collision_status_r ); DECLARE_READ16_MEMBER (cop_collision_status_val_r); DECLARE_READ16_MEMBER (cop_collision_status_stat_r); @@ -135,14 +131,16 @@ public: UINT16 cop_bank; UINT16 scrollvals[6]; - UINT32 cop_regs[8], cop_itoa; - UINT16 cop_status, cop_scale, cop_itoa_digit_count, cop_angle, cop_dist; - UINT8 cop_itoa_digits[10]; + UINT32 cop_regs[8]; + UINT16 cop_status, cop_scale, cop_angle, cop_dist; + UINT16 cop_angle_target; UINT16 cop_angle_step; + + DECLARE_WRITE16_MEMBER( sprite_prot_x_w ); DECLARE_WRITE16_MEMBER( sprite_prot_y_w ); DECLARE_WRITE16_MEMBER( sprite_prot_src_seg_w ); diff --git a/src/mame/machine/raiden2cop.c b/src/mame/machine/raiden2cop.c index 8ec0dd78abe..52fdd061898 100644 --- a/src/mame/machine/raiden2cop.c +++ b/src/mame/machine/raiden2cop.c @@ -22,6 +22,9 @@ raiden2cop_device::raiden2cop_device(const machine_config &mconfig, const char * cop_dma_adr_rel(0), pal_brightness_val(0), pal_brightness_mode(0), + cop_itoa(0), + cop_itoa_digit_count(0), + m_cop_itoa_unused_digit_value(0x30), m_videoramout_cb(*this), m_palette(*this, ":palette") { @@ -33,6 +36,8 @@ raiden2cop_device::raiden2cop_device(const machine_config &mconfig, const char * memset(cop_dma_src, 0, sizeof(UINT16)*(0x200)); memset(cop_dma_dst, 0, sizeof(UINT16)*(0x200)); memset(cop_dma_size, 0, sizeof(UINT16)*(0x200)); + + memset(cop_itoa_digits, 0, sizeof(UINT8)*10); } @@ -62,7 +67,14 @@ void raiden2cop_device::device_start() save_item(NAME(cop_dma_dst)); save_item(NAME(cop_dma_size)); + save_item(NAME(cop_itoa)); + save_item(NAME(cop_itoa_digit_count)); + save_item(NAME(cop_itoa_digits)); + m_videoramout_cb.resolve_safe(); + + cop_itoa_digit_count = 4; //TODO: Raiden 2 never inits the BCD register, value here is a guess (8 digits, as WR is 10.000.000 + a) + } /*** Command Table uploads ***/ @@ -547,3 +559,49 @@ WRITE16_MEMBER(raiden2cop_device::cop_dma_trigger_w) } } + +/* Number Conversion */ + +// according to score display in https://www.youtube.com/watch?v=T1M8sxYgt9A +// we should return 0x30 for unused digits? according to Raiden 2 and Zero +// Team the value should be 0x20, can this be configured? +WRITE16_MEMBER(raiden2cop_device::cop_itoa_low_w) +{ + cop_itoa = (cop_itoa & ~UINT32(mem_mask)) | (data & mem_mask); + + int digits = 1 << cop_itoa_digit_count*2; + UINT32 val = cop_itoa; + + if(digits > 9) + digits = 9; + + for (int i = 0; i < digits; i++) + { + if (!val && i) + { + cop_itoa_digits[i] = m_cop_itoa_unused_digit_value; + } + else + { + cop_itoa_digits[i] = 0x30 | (val % 10); + val = val / 10; + } + } + + cop_itoa_digits[9] = 0; +} + +WRITE16_MEMBER(raiden2cop_device::cop_itoa_high_w) +{ + cop_itoa = (cop_itoa & ~(mem_mask << 16)) | ((data & mem_mask) << 16); +} + +WRITE16_MEMBER(raiden2cop_device::cop_itoa_digit_count_w) +{ + COMBINE_DATA(&cop_itoa_digit_count); +} + +READ16_MEMBER(raiden2cop_device::cop_itoa_digits_r) +{ + return cop_itoa_digits[offset*2] | (cop_itoa_digits[offset*2+1] << 8); +} diff --git a/src/mame/machine/raiden2cop.h b/src/mame/machine/raiden2cop.h index 280b25a873e..f79d71c08a8 100644 --- a/src/mame/machine/raiden2cop.h +++ b/src/mame/machine/raiden2cop.h @@ -15,6 +15,9 @@ #define MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(_devcb) \ devcb = &raiden2cop_device::set_m_videoramout_cb(*device, DEVCB_##_devcb); +#define MCFG_ITOA_UNUSED_DIGIT_VALUE(value) \ + raiden2cop_device::set_itoa_unused_digit_value(*device, value); + class raiden2cop_device : public device_t { @@ -67,6 +70,20 @@ public: const UINT8 fade_table(int v); template static devcb_base &set_m_videoramout_cb(device_t &device, _Object object) { return downcast(device).m_videoramout_cb.set_callback(object); } + + // Number Conversion + + DECLARE_WRITE16_MEMBER( cop_itoa_low_w ); + DECLARE_WRITE16_MEMBER( cop_itoa_high_w ); + DECLARE_WRITE16_MEMBER( cop_itoa_digit_count_w ); + DECLARE_READ16_MEMBER ( cop_itoa_digits_r ); + + UINT32 cop_itoa; + UINT16 cop_itoa_digit_count; + UINT8 cop_itoa_digits[10]; + UINT8 m_cop_itoa_unused_digit_value; + + static void set_itoa_unused_digit_value(device_t &device, int value) { downcast(device).m_cop_itoa_unused_digit_value = value; } protected: // device-level overrides virtual void device_start(); diff --git a/src/mame/machine/seicop.c b/src/mame/machine/seicop.c index 97cba1e314c..847213b6308 100644 --- a/src/mame/machine/seicop.c +++ b/src/mame/machine/seicop.c @@ -1685,7 +1685,8 @@ void seibu_cop_legacy_device::device_start() } //------------------------------------------------- -// device_reset - device-specific startup +// device_ +// device-specific startup //------------------------------------------------- void seibu_cop_legacy_device::device_reset() @@ -2112,13 +2113,6 @@ READ16_MEMBER( seibu_cop_legacy_device::generic_cop_r ) case 0x188/2: return m_cop_hit_val_unk; - /* BCD */ - case 0x190/2: - case 0x192/2: - case 0x194/2: - case 0x196/2: - case 0x198/2: - return retvalue; /* RNG, trusted */ case 0x1a0/2: @@ -2144,7 +2138,6 @@ READ16_MEMBER( seibu_cop_legacy_device::generic_cop_r ) WRITE16_MEMBER( seibu_cop_legacy_device::generic_cop_w ) { - UINT32 temp32; switch (offset) { @@ -2189,24 +2182,7 @@ WRITE16_MEMBER( seibu_cop_legacy_device::generic_cop_w ) case (0x01c/2): m_cop_angle_compare = UINT16(m_cop_mcu_ram[0x1c/2]); break; case (0x01e/2): m_cop_angle_mod_val = UINT16(m_cop_mcu_ram[0x1e/2]); break; - /* BCD Protection */ - case (0x020/2): - case (0x022/2): - temp32 = (m_cop_mcu_ram[0x020/2]) | (m_cop_mcu_ram[0x022/2] << 16); - m_cop_mcu_ram[0x190/2] = (((temp32 / 1) % 10) + (((temp32 / 10) % 10) << 8) + 0x3030); - m_cop_mcu_ram[0x192/2] = (((temp32 / 100) % 10) + (((temp32 / 1000) % 10) << 8) + 0x3030); - m_cop_mcu_ram[0x194/2] = (((temp32 / 10000) % 10) + (((temp32 / 100000) % 10) << 8) + 0x3030); - m_cop_mcu_ram[0x196/2] = (((temp32 / 1000000) % 10) + (((temp32 / 10000000) % 10) << 8) + 0x3030); - m_cop_mcu_ram[0x198/2] = (((temp32 / 100000000) % 10) + (((temp32 / 1000000000) % 10) << 8) + 0x3030); - break; - case (0x024/2): - /* - This looks like a register for the BCD... - Godzilla and Heated Barrel sets 3 - Denjin Makai sets 3 at start-up and toggles between 2 and 3 during gameplay on the BCD subroutine - SD Gundam sets 0 - */ - break; +