trunk/src/mame/drivers/kenseim.c
| r30862 | r30863 | |
| 200 | 200 | UINT8 m_to_68k_cmd_d9; |
| 201 | 201 | UINT8 m_to_68k_cmd_req; |
| 202 | 202 | UINT8 m_to_68k_cmd_LVm; |
| 203 | |
| 204 | UINT8 m_to_68k_cmd_flags; |
| 203 | 205 | |
| 204 | 206 | int m_from68k_ack; |
| 205 | 207 | int m_from68k_st4; |
| r30862 | r30863 | |
| 220 | 222 | }; |
| 221 | 223 | |
| 222 | 224 | |
| 225 | /******************************* |
| 226 | Misc System Functions |
| 227 | ******************************/ |
| 228 | |
| 223 | 229 | void kenseim_state::set_leds(UINT32 ledstates) |
| 224 | 230 | { |
| 225 | 231 | for (int i=0; i<20; i++) |
| r30862 | r30863 | |
| 310 | 316 | logerror("%s write %01x to port C (%02x unmasked)\n", machine().describe_context(), (data & 0xf0)>>4, data ); |
| 311 | 317 | } |
| 312 | 318 | |
| 313 | | WRITE8_MEMBER(kenseim_state::portd_w) |
| 319 | |
| 320 | READ8_MEMBER(kenseim_state::portc_r) |
| 314 | 321 | { |
| 322 | // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons |
| 323 | // button order not confirmed |
| 324 | |
| 315 | 325 | // port direction is set to 4-in 4-out |
| 316 | | printf("%s write %01x to port D (%02x unmasked) (to 68k command flags?)\n", machine().describe_context(), data & 0x0f, data) ; |
| 326 | //int ret = rand() & 0x0f; |
| 327 | // bits 0x09 checked at 1171 |
| 328 | //logerror("%s read port C\n", machine().describe_context()); |
| 329 | return ioport("CAB-IN")->read(); |
| 317 | 330 | } |
| 318 | 331 | |
| 319 | | WRITE8_MEMBER(kenseim_state::porte_w) |
| 332 | READ8_MEMBER(kenseim_state::porta_r) |
| 320 | 333 | { |
| 321 | | // only access is at 0ABE, surrounded by port D reads / writes |
| 322 | | m_to_68k_cmd_low = data; |
| 323 | | printf("%s write %02x to port E (to 68k command bits?)\n", machine().describe_context(), data); |
| 334 | return ioport("DSW1")->read(); // confirmed by code |
| 324 | 335 | } |
| 325 | 336 | |
| 326 | | READ8_MEMBER(kenseim_state::portd_r) |
| 337 | READ8_MEMBER(kenseim_state::portb_r) |
| 327 | 338 | { |
| 328 | | // port direction is set to 4-in 4-out |
| 329 | | // int ret = rand() & 0xf0; |
| 339 | return ioport("DSW2")->read(); // confirmed by code |
| 340 | } |
| 330 | 341 | |
| 331 | | int ret; |
| 332 | 342 | |
| 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 |
| 343 | /******************************* |
| 344 | Comms? |
| 345 | ******************************/ |
| 335 | 346 | |
| 336 | | int in20 = m_from68k_st3; |
| 337 | | int in40 = m_from68k_st2; |
| 338 | 347 | |
| 339 | | ret = (in10 << 4) | (in20 << 5) | (in40 << 6) | (in80 << 7); |
| 340 | 348 | |
| 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. |
| 342 | | logerror("%s read port D (returning %02x)\n", machine().describe_context(), ret); |
| 343 | | return ret; |
| 344 | | } |
| 345 | 349 | |
| 350 | /* 68k side COMMS reads */ |
| 346 | 351 | |
| 347 | | READ8_MEMBER(kenseim_state::portc_r) |
| 352 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r) |
| 348 | 353 | { |
| 349 | | // almost certain, check as 2 pairs, 0x09 and 0x06, the two 'coin' buttons and two 'start' buttons |
| 350 | | // button order not confirmed |
| 354 | // printf("kenseim_cmd_1234_r\n") |
| 355 | return (m_to_68k_cmd_low & 0x0f)>>0; |
| 356 | } |
| 351 | 357 | |
| 352 | | // port direction is set to 4-in 4-out |
| 353 | | //int ret = rand() & 0x0f; |
| 354 | | // bits 0x09 checked at 1171 |
| 355 | | //logerror("%s read port C\n", machine().describe_context()); |
| 356 | | return ioport("CAB-IN")->read(); |
| 358 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r) |
| 359 | { |
| 360 | // printf("kenseim_cmd_5678_r\n") |
| 361 | return (m_to_68k_cmd_low & 0xf0)>>4; |
| 357 | 362 | } |
| 358 | 363 | |
| 359 | | READ8_MEMBER(kenseim_state::porta_r) |
| 364 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r) |
| 360 | 365 | { |
| 361 | | return ioport("DSW1")->read(); // confirmed by code |
| 366 | return (m_to_68k_cmd_d9 & 0x1); // bit 9 of command? |
| 362 | 367 | } |
| 363 | 368 | |
| 364 | | READ8_MEMBER(kenseim_state::portb_r) |
| 369 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r) |
| 365 | 370 | { |
| 366 | | return ioport("DSW2")->read(); // confirmed by code |
| 371 | logerror("%s kenseim_cmd_req_r\n", machine().describe_context()); |
| 372 | return m_to_68k_cmd_req; |
| 367 | 373 | } |
| 368 | 374 | |
| 375 | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r) |
| 376 | { |
| 377 | // needed for COMMAND WAIT message.. |
| 378 | return m_to_68k_cmd_LVm;; |
| 379 | } |
| 369 | 380 | |
| 381 | /* 68k side COMMS writes */ |
| 370 | 382 | |
| 371 | 383 | |
| 372 | 384 | WRITE16_MEMBER(kenseim_state::cps1_kensei_w) |
| r30862 | r30863 | |
| 386 | 398 | m_from68k_st2 = (data & 0x0400) >> 10; |
| 387 | 399 | m_from68k_st3 = (data & 0x0800) >> 11; |
| 388 | 400 | |
| 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 ); |
| 401 | printf("%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 ); |
| 390 | 402 | |
| 391 | 403 | } |
| 392 | 404 | else |
| r30862 | r30863 | |
| 395 | 407 | } |
| 396 | 408 | } |
| 397 | 409 | |
| 410 | |
| 411 | |
| 412 | /* Z80 side COMMS writes */ |
| 413 | |
| 414 | WRITE8_MEMBER(kenseim_state::portd_w) |
| 415 | { |
| 416 | // port direction is set to 4-in 4-out |
| 417 | m_to_68k_cmd_flags = data & 0xf; |
| 418 | |
| 419 | // bit 0x4, 0x02 bit 0x1 used. |
| 420 | // wrong |
| 421 | |
| 422 | m_to_68k_cmd_req = (m_to_68k_cmd_flags&0x2)>>1; |
| 423 | m_to_68k_cmd_LVm = ((m_to_68k_cmd_flags & 0x4) >> 2) ^ 1; |
| 424 | m_to_68k_cmd_d9 = (m_to_68k_cmd_flags&0x1)>>0; |
| 425 | |
| 426 | printf("%s write %01x to port D (%02x unmasked) (from DRIVE BOARD to 68k command flags?)\n", machine().describe_context(), data & 0x0f, data) ; |
| 427 | } |
| 428 | |
| 429 | WRITE8_MEMBER(kenseim_state::porte_w) |
| 430 | { |
| 431 | // only access is at 0ABE, surrounded by port D reads / writes |
| 432 | m_to_68k_cmd_low = data; |
| 433 | printf("%s write %02x to port E (from DRIVE BOARD to 68k command bits?)\n", machine().describe_context(), data); |
| 434 | } |
| 435 | |
| 436 | /* Z80 side COMMS reads */ |
| 437 | |
| 438 | READ8_MEMBER(kenseim_state::portd_r) |
| 439 | { |
| 440 | // port direction is set to 4-in 4-out |
| 441 | // int ret = rand() & 0xf0; |
| 442 | |
| 443 | int ret; |
| 444 | |
| 445 | int in10 = m_from68k_ack; // loop at 0x929 - 0x92e waits for this to be 0 |
| 446 | int in80 = m_from68k_st4; // loop at 0x931 - 0x936 then waits for this to be 1 |
| 447 | |
| 448 | int in20 = m_from68k_st3; |
| 449 | int in40 = m_from68k_st2; |
| 450 | |
| 451 | ret = (in10 << 4) | (in20 << 5) | (in40 << 6) | (in80 << 7); |
| 452 | |
| 453 | // 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. |
| 454 | logerror("%s read port D (returning %02x)\n", machine().describe_context(), ret); |
| 455 | return ret; |
| 456 | } |
| 457 | |
| 458 | |
| 459 | |
| 460 | |
| 398 | 461 | /* |
| 399 | 462 | Manufacturer: Fujitsu |
| 400 | 463 | Part Number: MB89363 / MB89363B / MB89363R |
| r30862 | r30863 | |
| 534 | 597 | MCFG_QUANTUM_PERFECT_CPU("maincpu") |
| 535 | 598 | MACHINE_CONFIG_END |
| 536 | 599 | |
| 537 | | |
| 538 | | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_1234_r) |
| 539 | | { |
| 540 | | // printf("kenseim_cmd_1234_r\n") |
| 541 | | return (m_to_68k_cmd_low & 0x0f)>>0; |
| 542 | | } |
| 543 | | |
| 544 | | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_5678_r) |
| 545 | | { |
| 546 | | // printf("kenseim_cmd_5678_r\n") |
| 547 | | m_to_68k_cmd_low = rand();// hack; |
| 548 | | |
| 549 | | return (m_to_68k_cmd_low & 0xf0)>>4; |
| 550 | | } |
| 551 | | |
| 552 | | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_9_r) |
| 553 | | { |
| 554 | | return (m_to_68k_cmd_d9 & 0x1); // bit 9 of command? |
| 555 | | } |
| 556 | | |
| 557 | | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_req_r) |
| 558 | | { |
| 559 | | m_to_68k_cmd_req = rand()&1; // hack |
| 560 | | |
| 561 | | return m_to_68k_cmd_req; |
| 562 | | } |
| 563 | | |
| 564 | | |
| 565 | | CUSTOM_INPUT_MEMBER(kenseim_state::kenseim_cmd_LVm_r) |
| 566 | | { |
| 567 | | // needed for COMMAND WAIT message.. |
| 568 | | return m_to_68k_cmd_LVm; |
| 569 | | } |
| 570 | | |
| 571 | | |
| 572 | 600 | static INPUT_PORTS_START( kenseim ) |
| 573 | 601 | // the regular CPS1 input ports are used for comms with the extra board |
| 574 | 602 | PORT_START("IN0") |