trunk/src/mame/machine/raiden2cop.c
| r32310 | r32311 | |
| 22 | 22 | cop_dma_adr_rel(0), |
| 23 | 23 | pal_brightness_val(0), |
| 24 | 24 | pal_brightness_mode(0), |
| 25 | cop_itoa(0), |
| 26 | cop_itoa_digit_count(0), |
| 27 | m_cop_itoa_unused_digit_value(0x30), |
| 25 | 28 | m_videoramout_cb(*this), |
| 26 | 29 | m_palette(*this, ":palette") |
| 27 | 30 | { |
| r32310 | r32311 | |
| 33 | 36 | memset(cop_dma_src, 0, sizeof(UINT16)*(0x200)); |
| 34 | 37 | memset(cop_dma_dst, 0, sizeof(UINT16)*(0x200)); |
| 35 | 38 | memset(cop_dma_size, 0, sizeof(UINT16)*(0x200)); |
| 39 | |
| 40 | memset(cop_itoa_digits, 0, sizeof(UINT8)*10); |
| 36 | 41 | } |
| 37 | 42 | |
| 38 | 43 | |
| r32310 | r32311 | |
| 62 | 67 | save_item(NAME(cop_dma_dst)); |
| 63 | 68 | save_item(NAME(cop_dma_size)); |
| 64 | 69 | |
| 70 | save_item(NAME(cop_itoa)); |
| 71 | save_item(NAME(cop_itoa_digit_count)); |
| 72 | save_item(NAME(cop_itoa_digits)); |
| 73 | |
| 65 | 74 | m_videoramout_cb.resolve_safe(); |
| 75 | |
| 76 | 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) |
| 77 | |
| 66 | 78 | } |
| 67 | 79 | |
| 68 | 80 | /*** Command Table uploads ***/ |
| r32310 | r32311 | |
| 547 | 559 | } |
| 548 | 560 | |
| 549 | 561 | } |
| 562 | |
| 563 | /* Number Conversion */ |
| 564 | |
| 565 | // according to score display in https://www.youtube.com/watch?v=T1M8sxYgt9A |
| 566 | // we should return 0x30 for unused digits? according to Raiden 2 and Zero |
| 567 | // Team the value should be 0x20, can this be configured? |
| 568 | WRITE16_MEMBER(raiden2cop_device::cop_itoa_low_w) |
| 569 | { |
| 570 | cop_itoa = (cop_itoa & ~UINT32(mem_mask)) | (data & mem_mask); |
| 571 | |
| 572 | int digits = 1 << cop_itoa_digit_count*2; |
| 573 | UINT32 val = cop_itoa; |
| 574 | |
| 575 | if(digits > 9) |
| 576 | digits = 9; |
| 577 | |
| 578 | for (int i = 0; i < digits; i++) |
| 579 | { |
| 580 | if (!val && i) |
| 581 | { |
| 582 | cop_itoa_digits[i] = m_cop_itoa_unused_digit_value; |
| 583 | } |
| 584 | else |
| 585 | { |
| 586 | cop_itoa_digits[i] = 0x30 | (val % 10); |
| 587 | val = val / 10; |
| 588 | } |
| 589 | } |
| 590 | |
| 591 | cop_itoa_digits[9] = 0; |
| 592 | } |
| 593 | |
| 594 | WRITE16_MEMBER(raiden2cop_device::cop_itoa_high_w) |
| 595 | { |
| 596 | cop_itoa = (cop_itoa & ~(mem_mask << 16)) | ((data & mem_mask) << 16); |
| 597 | } |
| 598 | |
| 599 | WRITE16_MEMBER(raiden2cop_device::cop_itoa_digit_count_w) |
| 600 | { |
| 601 | COMBINE_DATA(&cop_itoa_digit_count); |
| 602 | } |
| 603 | |
| 604 | READ16_MEMBER(raiden2cop_device::cop_itoa_digits_r) |
| 605 | { |
| 606 | return cop_itoa_digits[offset*2] | (cop_itoa_digits[offset*2+1] << 8); |
| 607 | } |
trunk/src/mame/machine/raiden2cop.h
| r32310 | r32311 | |
| 15 | 15 | #define MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(_devcb) \ |
| 16 | 16 | devcb = &raiden2cop_device::set_m_videoramout_cb(*device, DEVCB_##_devcb); |
| 17 | 17 | |
| 18 | #define MCFG_ITOA_UNUSED_DIGIT_VALUE(value) \ |
| 19 | raiden2cop_device::set_itoa_unused_digit_value(*device, value); |
| 18 | 20 | |
| 21 | |
| 19 | 22 | class raiden2cop_device : public device_t |
| 20 | 23 | { |
| 21 | 24 | public: |
| r32310 | r32311 | |
| 67 | 70 | const UINT8 fade_table(int v); |
| 68 | 71 | |
| 69 | 72 | template<class _Object> static devcb_base &set_m_videoramout_cb(device_t &device, _Object object) { return downcast<raiden2cop_device &>(device).m_videoramout_cb.set_callback(object); } |
| 73 | |
| 74 | // Number Conversion |
| 75 | |
| 76 | DECLARE_WRITE16_MEMBER( cop_itoa_low_w ); |
| 77 | DECLARE_WRITE16_MEMBER( cop_itoa_high_w ); |
| 78 | DECLARE_WRITE16_MEMBER( cop_itoa_digit_count_w ); |
| 79 | DECLARE_READ16_MEMBER ( cop_itoa_digits_r ); |
| 80 | |
| 81 | UINT32 cop_itoa; |
| 82 | UINT16 cop_itoa_digit_count; |
| 83 | UINT8 cop_itoa_digits[10]; |
| 84 | UINT8 m_cop_itoa_unused_digit_value; |
| 85 | |
| 86 | static void set_itoa_unused_digit_value(device_t &device, int value) { downcast<raiden2cop_device &>(device).m_cop_itoa_unused_digit_value = value; } |
| 70 | 87 | protected: |
| 71 | 88 | // device-level overrides |
| 72 | 89 | virtual void device_start(); |
trunk/src/mame/machine/seicop.c
| r32310 | r32311 | |
| 1685 | 1685 | } |
| 1686 | 1686 | |
| 1687 | 1687 | //------------------------------------------------- |
| 1688 | | // device_reset - device-specific startup |
| 1688 | // device_ |
| 1689 | // device-specific startup |
| 1689 | 1690 | //------------------------------------------------- |
| 1690 | 1691 | |
| 1691 | 1692 | void seibu_cop_legacy_device::device_reset() |
| r32310 | r32311 | |
| 2112 | 2113 | case 0x188/2: |
| 2113 | 2114 | return m_cop_hit_val_unk; |
| 2114 | 2115 | |
| 2115 | | /* BCD */ |
| 2116 | | case 0x190/2: |
| 2117 | | case 0x192/2: |
| 2118 | | case 0x194/2: |
| 2119 | | case 0x196/2: |
| 2120 | | case 0x198/2: |
| 2121 | | return retvalue; |
| 2122 | 2116 | |
| 2123 | 2117 | /* RNG, trusted */ |
| 2124 | 2118 | case 0x1a0/2: |
| r32310 | r32311 | |
| 2144 | 2138 | |
| 2145 | 2139 | WRITE16_MEMBER( seibu_cop_legacy_device::generic_cop_w ) |
| 2146 | 2140 | { |
| 2147 | | UINT32 temp32; |
| 2148 | 2141 | |
| 2149 | 2142 | switch (offset) |
| 2150 | 2143 | { |
| r32310 | r32311 | |
| 2189 | 2182 | case (0x01c/2): m_cop_angle_compare = UINT16(m_cop_mcu_ram[0x1c/2]); break; |
| 2190 | 2183 | case (0x01e/2): m_cop_angle_mod_val = UINT16(m_cop_mcu_ram[0x1e/2]); break; |
| 2191 | 2184 | |
| 2192 | | /* BCD Protection */ |
| 2193 | | case (0x020/2): |
| 2194 | | case (0x022/2): |
| 2195 | | temp32 = (m_cop_mcu_ram[0x020/2]) | (m_cop_mcu_ram[0x022/2] << 16); |
| 2196 | | m_cop_mcu_ram[0x190/2] = (((temp32 / 1) % 10) + (((temp32 / 10) % 10) << 8) + 0x3030); |
| 2197 | | m_cop_mcu_ram[0x192/2] = (((temp32 / 100) % 10) + (((temp32 / 1000) % 10) << 8) + 0x3030); |
| 2198 | | m_cop_mcu_ram[0x194/2] = (((temp32 / 10000) % 10) + (((temp32 / 100000) % 10) << 8) + 0x3030); |
| 2199 | | m_cop_mcu_ram[0x196/2] = (((temp32 / 1000000) % 10) + (((temp32 / 10000000) % 10) << 8) + 0x3030); |
| 2200 | | m_cop_mcu_ram[0x198/2] = (((temp32 / 100000000) % 10) + (((temp32 / 1000000000) % 10) << 8) + 0x3030); |
| 2201 | | break; |
| 2202 | | case (0x024/2): |
| 2203 | | /* |
| 2204 | | This looks like a register for the BCD... |
| 2205 | | Godzilla and Heated Barrel sets 3 |
| 2206 | | Denjin Makai sets 3 at start-up and toggles between 2 and 3 during gameplay on the BCD subroutine |
| 2207 | | SD Gundam sets 0 |
| 2208 | | */ |
| 2209 | | break; |
| 2210 | 2185 | |
| 2211 | 2186 | |
| 2187 | |
| 2212 | 2188 | |
| 2213 | 2189 | |
| 2214 | 2190 | |
trunk/src/mame/includes/raiden2.h
| r32310 | r32311 | |
| 26 | 26 | raiden2_tilemap_enable(0), |
| 27 | 27 | prg_bank(0), |
| 28 | 28 | cop_bank(0), |
| 29 | | cop_itoa(0), |
| 30 | 29 | cop_status(0), |
| 31 | 30 | cop_scale(0), |
| 32 | | cop_itoa_digit_count(0), |
| 31 | |
| 33 | 32 | cop_angle(0), |
| 34 | 33 | cop_dist(0), |
| 35 | 34 | |
| r32310 | r32311 | |
| 51 | 50 | { |
| 52 | 51 | memset(scrollvals, 0, sizeof(UINT16)*6); |
| 53 | 52 | memset(cop_regs, 0, sizeof(UINT32)*8); |
| 54 | | memset(cop_itoa_digits, 0, sizeof(UINT8)*10); |
| 55 | 53 | |
| 54 | |
| 56 | 55 | memset(sprite_prot_src_addr, 0, sizeof(UINT16)*2); |
| 57 | 56 | memset(cop_collision_info, 0, sizeof(colinfo)*2); |
| 58 | 57 | } |
| r32310 | r32311 | |
| 64 | 63 | required_device<gfxdecode_device> m_gfxdecode; |
| 65 | 64 | required_device<palette_device> m_palette; |
| 66 | 65 | |
| 67 | | DECLARE_WRITE16_MEMBER( cop_itoa_low_w ); |
| 68 | | DECLARE_WRITE16_MEMBER( cop_itoa_high_w ); |
| 69 | | DECLARE_WRITE16_MEMBER( cop_itoa_digit_count_w ); |
| 66 | |
| 70 | 67 | DECLARE_WRITE16_MEMBER( cop_scale_w ); |
| 71 | 68 | DECLARE_WRITE16_MEMBER( cop_angle_target_w ); |
| 72 | 69 | DECLARE_WRITE16_MEMBER( cop_angle_step_w ); |
| r32310 | r32311 | |
| 77 | 74 | DECLARE_WRITE16_MEMBER( cop_reg_low_w ); |
| 78 | 75 | |
| 79 | 76 | DECLARE_WRITE16_MEMBER( cop_cmd_w ); |
| 80 | | DECLARE_READ16_MEMBER ( cop_itoa_digits_r ); |
| 81 | 77 | DECLARE_READ16_MEMBER ( cop_collision_status_r ); |
| 82 | 78 | DECLARE_READ16_MEMBER (cop_collision_status_val_r); |
| 83 | 79 | DECLARE_READ16_MEMBER (cop_collision_status_stat_r); |
| r32310 | r32311 | |
| 135 | 131 | UINT16 cop_bank; |
| 136 | 132 | |
| 137 | 133 | UINT16 scrollvals[6]; |
| 138 | | UINT32 cop_regs[8], cop_itoa; |
| 139 | | UINT16 cop_status, cop_scale, cop_itoa_digit_count, cop_angle, cop_dist; |
| 140 | | UINT8 cop_itoa_digits[10]; |
| 134 | UINT32 cop_regs[8]; |
| 135 | UINT16 cop_status, cop_scale, cop_angle, cop_dist; |
| 136 | |
| 141 | 137 | |
| 142 | 138 | UINT16 cop_angle_target; |
| 143 | 139 | UINT16 cop_angle_step; |
| 144 | 140 | |
| 145 | 141 | |
| 142 | |
| 143 | |
| 146 | 144 | DECLARE_WRITE16_MEMBER( sprite_prot_x_w ); |
| 147 | 145 | DECLARE_WRITE16_MEMBER( sprite_prot_y_w ); |
| 148 | 146 | DECLARE_WRITE16_MEMBER( sprite_prot_src_seg_w ); |
trunk/src/mame/drivers/legionna.c
| r32310 | r32311 | |
| 92 | 92 | static ADDRESS_MAP_START( legionna_cop_mem, AS_PROGRAM, 16, legionna_state ) |
| 93 | 93 | // AM_RANGE(0x10041c, 0x10041d) AM_WRITE(cop_angle_target_w) // angle target (for 0x6200 COP macro) |
| 94 | 94 | // AM_RANGE(0x10041e, 0x10041f) AM_WRITE(cop_angle_step_w) // angle step (for 0x6200 COP macro) |
| 95 | | // AM_RANGE(0x100420, 0x100421) AM_WRITE(cop_itoa_low_w) |
| 96 | | // AM_RANGE(0x100422, 0x100423) AM_WRITE(cop_itoa_high_w) |
| 97 | | // AM_RANGE(0x100424, 0x100425) AM_WRITE(cop_itoa_digit_count_w) |
| 95 | AM_RANGE(0x100420, 0x100421) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_low_w) |
| 96 | AM_RANGE(0x100422, 0x100423) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_high_w) |
| 97 | AM_RANGE(0x100424, 0x100425) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_digit_count_w) |
| 98 | 98 | AM_RANGE(0x100428, 0x100429) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v1_w) |
| 99 | 99 | AM_RANGE(0x10042a, 0x10042b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v2_w) |
| 100 | 100 | AM_RANGE(0x100432, 0x100433) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_data_w) |
| r32310 | r32311 | |
| 124 | 124 | // AM_RANGE(0x100580, 0x100581) AM_READ(cop_collision_status_r) |
| 125 | 125 | // AM_RANGE(0x100582, 0x100587) AM_READ(cop_collision_status_val_r) |
| 126 | 126 | // AM_RANGE(0x100588, 0x100589) AM_READ(cop_collision_status_stat_r) |
| 127 | | // AM_RANGE(0x100590, 0x100599) AM_READ(cop_itoa_digits_r) |
| 127 | AM_RANGE(0x100590, 0x100599) AM_DEVREAD("raiden2cop", raiden2cop_device, cop_itoa_digits_r) |
| 128 | 128 | // AM_RANGE(0x1005b0, 0x1005b1) AM_READ(cop_status_r) |
| 129 | 129 | // AM_RANGE(0x1005b2, 0x1005b3) AM_READ(cop_dist_r) |
| 130 | 130 | // AM_RANGE(0x1005b4, 0x1005b5) AM_READ(cop_angle_r) |
trunk/src/mame/drivers/raiden2.c
| r32310 | r32311 | |
| 173 | 173 | save_item(NAME(raiden2_tilemap_enable)); |
| 174 | 174 | save_item(NAME(prg_bank)); |
| 175 | 175 | save_item(NAME(cop_bank)); |
| 176 | | save_item(NAME(cop_itoa)); |
| 177 | 176 | save_item(NAME(cop_status)); |
| 178 | 177 | save_item(NAME(cop_scale)); |
| 179 | | save_item(NAME(cop_itoa_digit_count)); |
| 178 | |
| 180 | 179 | save_item(NAME(cop_angle)); |
| 181 | 180 | save_item(NAME(cop_dist)); |
| 182 | 181 | |
| r32310 | r32311 | |
| 197 | 196 | |
| 198 | 197 | save_item(NAME(scrollvals)); |
| 199 | 198 | save_item(NAME(cop_regs)); |
| 200 | | save_item(NAME(cop_itoa_digits)); |
| 201 | 199 | |
| 200 | |
| 201 | |
| 202 | 202 | save_item(NAME(sprite_prot_src_addr)); |
| 203 | 203 | |
| 204 | 204 | save_item(NAME(cop_collision_info[0].pos)); |
| r32310 | r32311 | |
| 257 | 257 | } |
| 258 | 258 | } |
| 259 | 259 | |
| 260 | | WRITE16_MEMBER(raiden2_state::cop_itoa_low_w) |
| 261 | | { |
| 262 | | cop_itoa = (cop_itoa & ~UINT32(mem_mask)) | (data & mem_mask); |
| 263 | 260 | |
| 264 | | int digits = 1 << cop_itoa_digit_count*2; |
| 265 | | UINT32 val = cop_itoa; |
| 266 | | |
| 267 | | if(digits > 9) |
| 268 | | digits = 9; |
| 269 | | for(int i=0; i<digits; i++) |
| 270 | | if(!val && i) |
| 271 | | cop_itoa_digits[i] = 0x20; |
| 272 | | else { |
| 273 | | cop_itoa_digits[i] = 0x30 | (val % 10); |
| 274 | | val = val / 10; |
| 275 | | } |
| 276 | | cop_itoa_digits[9] = 0; |
| 277 | | } |
| 278 | | |
| 279 | | WRITE16_MEMBER(raiden2_state::cop_itoa_high_w) |
| 280 | | { |
| 281 | | cop_itoa = (cop_itoa & ~(mem_mask << 16)) | ((data & mem_mask) << 16); |
| 282 | | } |
| 283 | | |
| 284 | | WRITE16_MEMBER(raiden2_state::cop_itoa_digit_count_w) |
| 285 | | { |
| 286 | | COMBINE_DATA(&cop_itoa_digit_count); |
| 287 | | } |
| 288 | | |
| 289 | | READ16_MEMBER(raiden2_state::cop_itoa_digits_r) |
| 290 | | { |
| 291 | | return cop_itoa_digits[offset*2] | (cop_itoa_digits[offset*2+1] << 8); |
| 292 | | } |
| 293 | | |
| 294 | 261 | READ16_MEMBER(raiden2_state::cop_status_r) |
| 295 | 262 | { |
| 296 | 263 | return cop_status; |
| r32310 | r32311 | |
| 1084 | 1051 | fg_bank=6; |
| 1085 | 1052 | mid_bank=1; |
| 1086 | 1053 | tx_bank = 0; |
| 1087 | | 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) |
| 1088 | 1054 | } |
| 1089 | 1055 | |
| 1090 | 1056 | MACHINE_RESET_MEMBER(raiden2_state,raiden2) |
| r32310 | r32311 | |
| 1332 | 1298 | static ADDRESS_MAP_START( raiden2_cop_mem, AS_PROGRAM, 16, raiden2_state ) |
| 1333 | 1299 | AM_RANGE(0x0041c, 0x0041d) AM_WRITE(cop_angle_target_w) // angle target (for 0x6200 COP macro) |
| 1334 | 1300 | AM_RANGE(0x0041e, 0x0041f) AM_WRITE(cop_angle_step_w) // angle step (for 0x6200 COP macro) |
| 1335 | | AM_RANGE(0x00420, 0x00421) AM_WRITE(cop_itoa_low_w) |
| 1336 | | AM_RANGE(0x00422, 0x00423) AM_WRITE(cop_itoa_high_w) |
| 1337 | | AM_RANGE(0x00424, 0x00425) AM_WRITE(cop_itoa_digit_count_w) |
| 1301 | AM_RANGE(0x00420, 0x00421) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_low_w) |
| 1302 | AM_RANGE(0x00422, 0x00423) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_high_w) |
| 1303 | AM_RANGE(0x00424, 0x00425) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_itoa_digit_count_w) |
| 1338 | 1304 | AM_RANGE(0x00428, 0x00429) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v1_w) |
| 1339 | 1305 | AM_RANGE(0x0042a, 0x0042b) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_dma_v2_w) |
| 1340 | 1306 | AM_RANGE(0x00432, 0x00433) AM_DEVWRITE("raiden2cop", raiden2cop_device, cop_pgm_data_w) |
| r32310 | r32311 | |
| 1364 | 1330 | AM_RANGE(0x00580, 0x00581) AM_READ(cop_collision_status_r) |
| 1365 | 1331 | AM_RANGE(0x00582, 0x00587) AM_READ(cop_collision_status_val_r) |
| 1366 | 1332 | AM_RANGE(0x00588, 0x00589) AM_READ(cop_collision_status_stat_r) |
| 1367 | | AM_RANGE(0x00590, 0x00599) AM_READ(cop_itoa_digits_r) |
| 1333 | AM_RANGE(0x00590, 0x00599) AM_DEVREAD("raiden2cop", raiden2cop_device, cop_itoa_digits_r) |
| 1368 | 1334 | AM_RANGE(0x005b0, 0x005b1) AM_READ(cop_status_r) |
| 1369 | 1335 | AM_RANGE(0x005b2, 0x005b3) AM_READ(cop_dist_r) |
| 1370 | 1336 | AM_RANGE(0x005b4, 0x005b5) AM_READ(cop_angle_r) |
| r32310 | r32311 | |
| 1833 | 1799 | |
| 1834 | 1800 | MCFG_RAIDEN2COP_ADD("raiden2cop") |
| 1835 | 1801 | MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(raiden2_state, m_videoram_private_w)) |
| 1802 | MCFG_ITOA_UNUSED_DIGIT_VALUE(0x20) |
| 1836 | 1803 | |
| 1837 | 1804 | MCFG_VIDEO_START_OVERRIDE(raiden2_state,raiden2) |
| 1838 | 1805 | |
| r32310 | r32311 | |
| 1893 | 1860 | |
| 1894 | 1861 | MCFG_RAIDEN2COP_ADD("raiden2cop") |
| 1895 | 1862 | MCFG_RAIDEN2COP_VIDEORAM_OUT_CB(WRITE16(raiden2_state, m_videoram_private_w)) |
| 1863 | MCFG_ITOA_UNUSED_DIGIT_VALUE(0x20) |
| 1896 | 1864 | |
| 1897 | 1865 | MCFG_VIDEO_START_OVERRIDE(raiden2_state,raiden2) |
| 1898 | 1866 | |