src/mess/machine/nes.c
| r8381 | r8382 | |
| 310 | 310 | int cfg = input_port_read(space->machine, "CTRLSEL"); |
| 311 | 311 | int ret; |
| 312 | 312 | |
| 313 | | if ((cfg & 0x000f) >= 0x04) // for now we treat the FC keyboard separately from other inputs! |
| 313 | if ((cfg & 0x000f) >= 0x07) // for now we treat the FC keyboard separately from other inputs! |
| 314 | 314 | { |
| 315 | 315 | // here we should have the tape input |
| 316 | 316 | ret = 0; |
| r8381 | r8382 | |
| 378 | 378 | int cfg = input_port_read(space->machine, "CTRLSEL"); |
| 379 | 379 | int ret; |
| 380 | 380 | |
| 381 | | if ((cfg & 0x000f) == 0x04) // for now we treat the FC keyboard separately from other inputs! |
| 381 | if ((cfg & 0x000f) == 0x07) // for now we treat the FC keyboard separately from other inputs! |
| 382 | 382 | { |
| 383 | 383 | if (state->fck_scan < 9) |
| 384 | 384 | ret = ~nes_read_fc_keyboard_line(space->machine, state->fck_scan, state->fck_mode) & 0x1e; |
| r8381 | r8382 | |
| 449 | 449 | } |
| 450 | 450 | |
| 451 | 451 | |
| 452 | | |
| 453 | | static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port, int supports_zapper, int paddle_port ) |
| 452 | // FIXME: this is getting messier and messier (no pun intended). inputs reading should be simplified and port_categories cleaned up |
| 453 | // to also emulate the fact that nothing should be in Port 2 if there is a Crazy Climber pad, etc. |
| 454 | static void nes_read_input_device( running_machine *machine, int cfg, nes_input *vals, int pad_port, int supports_zapper ) |
| 454 | 455 | { |
| 455 | | static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4" }; |
| 456 | | |
| 456 | nes_state *state = (nes_state *)machine->driver_data; |
| 457 | static const char *const padnames[] = { "PAD1", "PAD2", "PAD3", "PAD4", "CC_LEFT", "CC_RIGHT" }; |
| 458 | |
| 457 | 459 | vals->i0 = 0; |
| 458 | 460 | vals->i1 = 0; |
| 459 | 461 | vals->i2 = 0; |
| 460 | | |
| 461 | | switch(cfg & 0x0f) |
| 462 | |
| 463 | switch (cfg & 0x0f) |
| 462 | 464 | { |
| 463 | 465 | case 0x01: /* gamepad */ |
| 464 | 466 | if (pad_port >= 0) |
| 465 | 467 | vals->i0 = input_port_read(machine, padnames[pad_port]); |
| 466 | 468 | break; |
| 467 | | |
| 469 | |
| 468 | 470 | case 0x02: /* zapper 1 */ |
| 469 | 471 | if (supports_zapper) |
| 470 | 472 | { |
| r8381 | r8382 | |
| 473 | 475 | vals->i2 = input_port_read(machine, "ZAPPER1_Y"); |
| 474 | 476 | } |
| 475 | 477 | break; |
| 476 | | |
| 478 | |
| 477 | 479 | case 0x03: /* zapper 2 */ |
| 478 | 480 | if (supports_zapper) |
| 479 | 481 | { |
| r8381 | r8382 | |
| 482 | 484 | vals->i2 = input_port_read(machine, "ZAPPER2_Y"); |
| 483 | 485 | } |
| 484 | 486 | break; |
| 485 | | |
| 487 | |
| 486 | 488 | case 0x04: /* arkanoid paddle */ |
| 487 | | if (paddle_port >= 0) |
| 489 | if (pad_port == 1) |
| 488 | 490 | vals->i0 = (UINT8) ((UINT8) input_port_read(machine, "PADDLE") + (UINT8)0x52) ^ 0xff; |
| 489 | 491 | break; |
| 492 | |
| 493 | case 0x05: /* crazy climber controller */ |
| 494 | if (pad_port == 0) |
| 495 | { |
| 496 | state->in_0.i0 = input_port_read(machine, padnames[4]); |
| 497 | state->in_1.i0 = input_port_read(machine, padnames[5]); |
| 498 | } |
| 499 | break; |
| 490 | 500 | } |
| 491 | 501 | } |
| 492 | 502 | |
| r8381 | r8382 | |
| 524 | 534 | /* Check if lightgun has been chosen as input: if so, enable crosshair */ |
| 525 | 535 | timer_set(space->machine, attotime_zero, NULL, 0, lightgun_tick); |
| 526 | 536 | |
| 527 | | if ((cfg & 0x000f) >= 0x04) // for now we treat the FC keyboard separately from other inputs! |
| 537 | if ((cfg & 0x000f) >= 0x07) // for now we treat the FC keyboard separately from other inputs! |
| 528 | 538 | { |
| 529 | 539 | // here we should also have the tape output |
| 530 | 540 | |
| r8381 | r8382 | |
| 546 | 556 | { |
| 547 | 557 | if (data & 0x01) |
| 548 | 558 | return; |
| 549 | | |
| 559 | |
| 550 | 560 | if (LOG_JOY) |
| 551 | 561 | logerror("joy 0 bits read: %d\n", state->in_0.shift); |
| 552 | | |
| 562 | |
| 553 | 563 | /* Toggling bit 0 high then low resets both controllers */ |
| 554 | 564 | state->in_0.shift = 0; |
| 555 | 565 | state->in_1.shift = 0; |
| 556 | | |
| 566 | |
| 557 | 567 | /* Read the input devices */ |
| 558 | | nes_read_input_device(space->machine, cfg >> 0, &state->in_0, 0, TRUE, -1); |
| 559 | | nes_read_input_device(space->machine, cfg >> 4, &state->in_1, 1, TRUE, 1); |
| 560 | | nes_read_input_device(space->machine, cfg >> 8, &state->in_2, 2, FALSE, -1); |
| 561 | | nes_read_input_device(space->machine, cfg >> 12, &state->in_3, 3, FALSE, -1); |
| 562 | | |
| 568 | if ((cfg & 0x000f) != 0x06) |
| 569 | { |
| 570 | nes_read_input_device(space->machine, cfg >> 0, &state->in_0, 0, TRUE); |
| 571 | nes_read_input_device(space->machine, cfg >> 4, &state->in_1, 1, TRUE); |
| 572 | nes_read_input_device(space->machine, cfg >> 8, &state->in_2, 2, FALSE); |
| 573 | nes_read_input_device(space->machine, cfg >> 12, &state->in_3, 3, FALSE); |
| 574 | } |
| 575 | else // crazy climber pad |
| 576 | { |
| 577 | nes_read_input_device(space->machine, 0, &state->in_1, 1, TRUE); |
| 578 | nes_read_input_device(space->machine, 0, &state->in_2, 2, FALSE); |
| 579 | nes_read_input_device(space->machine, 0, &state->in_3, 3, FALSE); |
| 580 | nes_read_input_device(space->machine, cfg >> 0, &state->in_0, 0, TRUE); |
| 581 | } |
| 582 | |
| 563 | 583 | if (cfg & 0x0f00) |
| 564 | 584 | state->in_0.i0 |= (state->in_2.i0 << 8) | (0x08 << 16); |
| 565 | | |
| 585 | |
| 566 | 586 | if (cfg & 0xf000) |
| 567 | 587 | state->in_1.i0 |= (state->in_3.i0 << 8) | (0x04 << 16); |
| 568 | 588 | } |
src/mess/drivers/nes.c
| r8381 | r8382 | |
| 61 | 61 | PORT_CATEGORY_ITEM( 0x0000, "Unconnected", 0 ) |
| 62 | 62 | PORT_CATEGORY_ITEM( 0x0001, "Gamepad", 1 ) |
| 63 | 63 | PORT_CATEGORY_ITEM( 0x0002, "Zapper", 5 ) |
| 64 | PORT_CATEGORY_ITEM( 0x0006, "Crazy Climber pad", 10 ) |
| 64 | 65 | PORT_CATEGORY_CLASS( 0x00f0, 0x0010, "P2 Controller") |
| 65 | 66 | PORT_CATEGORY_ITEM( 0x0000, "Unconnected", 0 ) |
| 66 | 67 | PORT_CATEGORY_ITEM( 0x0010, "Gamepad", 2 ) |
| 67 | 68 | PORT_CATEGORY_ITEM( 0x0030, "Zapper", 6 ) |
| 68 | 69 | PORT_CATEGORY_ITEM( 0x0040, "Arkanoid paddle", 7 ) |
| 70 | // PORT_CATEGORY_ITEM( 0x0050, "Family Trainer", 11 ) |
| 69 | 71 | PORT_CATEGORY_CLASS( 0x0f00, 0x0000, "P3 Controller") |
| 70 | 72 | PORT_CATEGORY_ITEM( 0x0000, "Unconnected", 0 ) |
| 71 | 73 | PORT_CATEGORY_ITEM( 0x0100, "Gamepad", 3 ) |
| r8381 | r8382 | |
| 129 | 131 | |
| 130 | 132 | PORT_START("PADDLE") /* Arkanoid paddle */ |
| 131 | 133 | PORT_BIT( 0xff, 0x7f, IPT_PADDLE) PORT_SENSITIVITY(25) PORT_KEYDELTA(3) PORT_MINMAX(0x62,0xf2) PORT_CATEGORY(7) |
| 134 | |
| 135 | PORT_START("CC_LEFT") |
| 136 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 137 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 138 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SELECT ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 139 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 140 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_UP ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 141 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_DOWN ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 142 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_LEFT ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 143 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKLEFT_RIGHT ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 144 | |
| 145 | PORT_START("CC_RIGHT") |
| 146 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 147 | PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 148 | PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 149 | PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNUSED ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 150 | PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_UP ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 151 | PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_DOWN ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 152 | PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_LEFT ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 153 | PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICKRIGHT_RIGHT ) PORT_CATEGORY(10) PORT_PLAYER(1) |
| 154 | |
| 132 | 155 | INPUT_PORTS_END |
| 133 | 156 | |
| 134 | 157 | static INPUT_PORTS_START( nes ) |
| r8381 | r8382 | |
| 379 | 402 | PORT_CATEGORY_ITEM( 0x0000, "Unconnected", 0 ) |
| 380 | 403 | PORT_CATEGORY_ITEM( 0x0001, "Gamepad", 1 ) |
| 381 | 404 | PORT_CATEGORY_ITEM( 0x0002, "Zapper", 5 ) |
| 382 | | PORT_CATEGORY_ITEM( 0x0004, "FC Keyboard", 8 ) |
| 405 | PORT_CATEGORY_ITEM( 0x0006, "Crazy Climber pad", 10 ) |
| 406 | PORT_CATEGORY_ITEM( 0x0007, "FC Keyboard", 8 ) |
| 383 | 407 | PORT_CATEGORY_ITEM( 0x0008, "Subor Keyboard", 9 ) |
| 384 | 408 | PORT_CATEGORY_CLASS( 0x00f0, 0x0010, "P2 Controller") |
| 385 | 409 | PORT_CATEGORY_ITEM( 0x0000, "Unconnected", 0 ) |
| 386 | 410 | PORT_CATEGORY_ITEM( 0x0010, "Gamepad", 2 ) |
| 387 | 411 | PORT_CATEGORY_ITEM( 0x0030, "Zapper", 6 ) |
| 388 | 412 | PORT_CATEGORY_ITEM( 0x0040, "Arkanoid paddle", 7 ) |
| 413 | // PORT_CATEGORY_ITEM( 0x0050, "Family Trainer", 11 ) |
| 389 | 414 | PORT_CATEGORY_CLASS( 0x0f00, 0x0000, "P3 Controller") |
| 390 | 415 | PORT_CATEGORY_ITEM( 0x0000, "Unconnected", 0 ) |
| 391 | 416 | PORT_CATEGORY_ITEM( 0x0100, "Gamepad", 3 ) |