trunk/src/mame/drivers/kenseim.c
| r30823 | r30824 | |
| 139 | 139 | public: |
| 140 | 140 | kenseim_state(const machine_config &mconfig, device_type type, const char *tag) |
| 141 | 141 | : cps_state(mconfig, type, tag), |
| 142 | | m_to_68k_cmd(0) |
| 142 | m_to_68k_cmd_low(0), |
| 143 | m_to_68k_cmd_d9(0), |
| 144 | m_to_68k_cmd_req(0), |
| 145 | m_to_68k_cmd_LVm(0), |
| 146 | m_from68k_ack(0), |
| 147 | m_from68k_st4(0), |
| 148 | m_from68k_st3(0), |
| 149 | m_from68k_st2(0) |
| 150 | |
| 143 | 151 | { } |
| 144 | 152 | |
| 145 | 153 | /* kenseim */ |
| 146 | 154 | DECLARE_WRITE16_MEMBER(cps1_kensei_w); |
| 147 | | DECLARE_READ16_MEMBER(kensei_dsw_r); |
| 148 | 155 | DECLARE_DRIVER_INIT(kenseim); |
| 149 | 156 | |
| 150 | 157 | // certain |
| r30823 | r30824 | |
| 161 | 168 | DECLARE_READ8_MEMBER(portc_r); // 4 bit in - coins + start btns |
| 162 | 169 | |
| 163 | 170 | // uncertain |
| 164 | | DECLARE_WRITE8_MEMBER(portc_w); // 4 bit out |
| 165 | | DECLARE_WRITE8_MEMBER(portd_w); // 4 bit out |
| 166 | | DECLARE_READ8_MEMBER(portd_r); // 4 bit in |
| 167 | | DECLARE_WRITE8_MEMBER(porte_w); // 8 bit out |
| 171 | DECLARE_WRITE8_MEMBER(portc_w); // 4 bit out (lamps, coinlock etc.?) |
| 168 | 172 | |
| 173 | DECLARE_READ8_MEMBER(portd_r); // 4 bit in (comms flags from 68k) |
| 174 | |
| 175 | DECLARE_WRITE8_MEMBER(portd_w); // 4 bit out (command flags to 68k?) |
| 176 | DECLARE_WRITE8_MEMBER(porte_w); // 8 bit out (command to 68k?) |
| 177 | |
| 169 | 178 | WRITE8_MEMBER(i8255_porta_w); // maybe molesa output? (6-bits?) |
| 170 | 179 | WRITE8_MEMBER(i8255_portb_w); // maybe molesb output? (6-bits?) |
| 171 | 180 | WRITE8_MEMBER(i8255_portf_w); // maybe strobe output? |
| r30823 | r30824 | |
| 187 | 196 | //DECLARE_WRITE8_MEMBER(porta_default_w) { logerror("%s write %02x to port A but no handler assigned\n", machine().describe_context(), data); } |
| 188 | 197 | //DECLARE_WRITE8_MEMBER(portb_default_w) { logerror("%s write %02x to port B but no handler assigned\n", machine().describe_context(), data); } |
| 189 | 198 | |
| 190 | | int m_to_68k_cmd; |
| 199 | UINT8 m_to_68k_cmd_low; |
| 200 | UINT8 m_to_68k_cmd_d9; |
| 201 | UINT8 m_to_68k_cmd_req; |
| 202 | UINT8 m_to_68k_cmd_LVm; |
| 203 | |
| 204 | int m_from68k_ack; |
| 205 | int m_from68k_st4; |
| 206 | int m_from68k_st3; |
| 207 | int m_from68k_st2; |
| 208 | |
| 209 | |
| 191 | 210 | DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_1234_r); |
| 192 | 211 | DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_5678_r); |
| 193 | 212 | DECLARE_CUSTOM_INPUT_MEMBER(kenseim_cmd_9_r); |
| r30823 | r30824 | |
| 294 | 313 | WRITE8_MEMBER(kenseim_state::portd_w) |
| 295 | 314 | { |
| 296 | 315 | // port direction is set to 4-in 4-out |
| 297 | | logerror("%s write %01x to port D (%02x unmasked)\n", machine().describe_context(), data & 0x0f, data) ; |
| 316 | printf("%s write %01x to port D (%02x unmasked) (to 68k command flags?)\n", machine().describe_context(), data & 0x0f, data) ; |
| 298 | 317 | } |
| 299 | 318 | |
| 300 | 319 | WRITE8_MEMBER(kenseim_state::porte_w) |
| 301 | 320 | { |
| 302 | 321 | // only access is at 0ABE, surrounded by port D reads / writes |
| 303 | | logerror("%s write %02x to port E\n", machine().describe_context(), data); |
| 322 | m_to_68k_cmd_low = data; |
| 323 | printf("%s write %02x to port E (to 68k command bits?)\n", machine().describe_context(), data); |
| 304 | 324 | } |
| 305 | 325 | |
| 306 | 326 | READ8_MEMBER(kenseim_state::portd_r) |
| r30823 | r30824 | |
| 308 | 328 | // port direction is set to 4-in 4-out |
| 309 | 329 | // int ret = rand() & 0xf0; |
| 310 | 330 | |
| 311 | | int ret = 0xf0; |
| 331 | int ret; |
| 312 | 332 | |
| 333 | int in10 = m_from68k_ack; // loop at 0x929 - 0x92e waits for this to be 0 |
| 334 | int in80 = m_from68k_st4; // loop at 0x931 - 0x936 then waits for this to be 1 |
| 335 | |
| 336 | int in20 = m_from68k_st3; |
| 337 | int in40 = m_from68k_st2; |
| 338 | |
| 339 | ret = (in10 << 4) | (in20 << 5) | (in40 << 6) | (in80 << 7); |
| 340 | |
| 313 | 341 | // comms port maybe? checks for 0x10 (bit 4,a) to be clear in a tight loop (092B) then for bit 0x80 to be set in another tight loop (0933) then at (0947) it checks that bits 0xe0 aren't set. |
| 314 | | logerror("%s read port D\n", machine().describe_context()); |
| 342 | logerror("%s read port D (returning %02x)\n", machine().describe_context(), ret); |
| 315 | 343 | return ret; |
| 316 | 344 | } |
| 317 | 345 | |
| 346 | |
| 318 | 347 | READ8_MEMBER(kenseim_state::portc_r) |
| 319 | 348 | { |
| 320 | 349 | // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons |
| r30823 | r30824 | |
| 342 | 371 | |
| 343 | 372 | WRITE16_MEMBER(kenseim_state::cps1_kensei_w) |
| 344 | 373 | { |
| 345 | | if (mem_mask == 0xff00) |
| 374 | |
| 375 | if (ACCESSING_BITS_8_15) |
| 346 | 376 | { |
| 377 | // coin_counter_w(machine(), 0, data & 0x0100); |
| 378 | // coin_counter_w(machine(), 1, data & 0x0200); |
| 379 | // coin_lockout_w(machine(), 0, ~data & 0x0400); |
| 380 | // coin_lockout_w(machine(), 1, ~data & 0x0800); |
| 347 | 381 | |
| 348 | | data >>= 8;; |
| 382 | // bit 15 = CPS-A custom reset? |
| 349 | 383 | |
| 350 | | logerror("%s cps1_kensei_w offs %04x (from 68k to DRIVE BOARD via CN2) (%02x) (%d ACK, %d ST4, %d ST3, %d ST2) \n", machine().describe_context(), offset * 2, data, (data & 0x01), ((data & 0x02)>>1),((data & 0x04)>>2),((data & 0x08)>>3) ); |
| 384 | m_from68k_ack = (data & 0x0100) >> 8; |
| 385 | m_from68k_st4 = (data & 0x0200) >> 9; |
| 386 | m_from68k_st2 = (data & 0x0400) >> 10; |
| 387 | m_from68k_st3 = (data & 0x0800) >> 11; |
| 388 | |
| 389 | logerror("%s cps1_kensei_w offs %04x (from 68k to DRIVE BOARD via CN2) (%02x) (%d ACK, %d ST4, %d ST2, %d ST3) \n", machine().describe_context(), offset * 2, data, m_from68k_ack, m_from68k_st4, m_from68k_st2, m_from68k_st3 ); |
| 351 | 390 | |
| 352 | | |
| 353 | | if (data & 0xf0) |
| 354 | | logerror(" ^^ (unknown? %02x)\n", data & 0xf0); |
| 355 | 391 | } |
| 356 | 392 | else |
| 357 | 393 | { |
| r30823 | r30824 | |
| 498 | 534 | MCFG_QUANTUM_PERFECT_CPU("maincpu") |
| 499 | 535 | MACHINE_CONFIG_END |
| 500 | 536 | |
| 501 | | /* how the DRIVE PCB connects to the inputs, see comments after each line |
| 502 | 537 | |
| 503 | | |
| 504 | | */ |
| 505 | | |
| 506 | 538 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r) |
| 507 | 539 | { |
| 508 | 540 | // printf("kenseim_cmd_1234_r\n") |
| 509 | | return (m_to_68k_cmd & 0x00f)>>0; |
| 541 | return (m_to_68k_cmd_low & 0x0f)>>0; |
| 510 | 542 | } |
| 511 | 543 | |
| 512 | 544 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r) |
| 513 | 545 | { |
| 514 | 546 | // printf("kenseim_cmd_5678_r\n") |
| 515 | | m_to_68k_cmd++; // hack |
| 516 | | return (m_to_68k_cmd & 0x0f0)>>4; |
| 547 | m_to_68k_cmd_low = rand();// hack; |
| 548 | |
| 549 | return (m_to_68k_cmd_low & 0xf0)>>4; |
| 517 | 550 | } |
| 518 | 551 | |
| 519 | 552 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r) |
| 520 | 553 | { |
| 521 | | return (m_to_68k_cmd & 0x100) >> 8; // bit 9 of command? |
| 554 | return (m_to_68k_cmd_d9 & 0x1); // bit 9 of command? |
| 522 | 555 | } |
| 523 | 556 | |
| 524 | 557 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r) |
| 525 | 558 | { |
| 526 | | // hack |
| 527 | | return rand(); |
| 559 | m_to_68k_cmd_req = rand()&1; // hack |
| 560 | |
| 561 | return m_to_68k_cmd_req; |
| 528 | 562 | } |
| 529 | 563 | |
| 564 | |
| 530 | 565 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r) |
| 531 | 566 | { |
| 532 | 567 | // needed for COMMAND WAIT message.. |
| 533 | | return 0; |
| 568 | return m_to_68k_cmd_LVm; |
| 534 | 569 | } |
| 535 | 570 | |
| 536 | 571 | |