src/mess/drivers/vidbrain.c
| r15135 | r15136 | |
| 130 | 130 | |
| 131 | 131 | // joystick enable |
| 132 | 132 | m_joy_enable = BIT(data, 7); |
| 133 | | |
| 134 | | if (m_joy_enable) |
| 135 | | { |
| 136 | | // TODO calculate NE555 firing time based on input port values |
| 137 | | //timer_set(attotime::from_msec(t), TIMER_JOYSTICK); |
| 138 | | } |
| 139 | 133 | } |
| 140 | 134 | |
| 141 | 135 | |
| r15135 | r15136 | |
| 307 | 301 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("MASTER CONTROL") PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) PORT_CHANGED_MEMBER(DEVICE_SELF, vidbrain_state, trigger_reset, 0) |
| 308 | 302 | |
| 309 | 303 | PORT_START("JOY1-X") |
| 310 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(25) PORT_PLAYER(1) |
| 304 | PORT_BIT( 0xff, 70, IPT_AD_STICK_X ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(1) |
| 311 | 305 | |
| 312 | 306 | PORT_START("JOY1-Y") |
| 313 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(25) PORT_PLAYER(1) |
| 307 | PORT_BIT( 0xff, 70, IPT_AD_STICK_Y ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(1) |
| 314 | 308 | |
| 315 | 309 | PORT_START("JOY2-X") |
| 316 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(25) PORT_PLAYER(2) |
| 310 | PORT_BIT( 0xff, 70, IPT_AD_STICK_X ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(2) |
| 317 | 311 | |
| 318 | 312 | PORT_START("JOY2-Y") |
| 319 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(25) PORT_PLAYER(2) |
| 313 | PORT_BIT( 0xff, 70, IPT_AD_STICK_Y ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(2) |
| 320 | 314 | |
| 321 | 315 | PORT_START("JOY3-X") |
| 322 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(25) PORT_PLAYER(3) |
| 316 | PORT_BIT( 0xff, 70, IPT_AD_STICK_X ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(3) |
| 323 | 317 | |
| 324 | 318 | PORT_START("JOY3-Y") |
| 325 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(25) PORT_PLAYER(3) |
| 319 | PORT_BIT( 0xff, 70, IPT_AD_STICK_Y ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(3) |
| 326 | 320 | |
| 327 | 321 | PORT_START("JOY4-X") |
| 328 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X ) PORT_SENSITIVITY(25) PORT_PLAYER(4) |
| 322 | PORT_BIT( 0xff, 70, IPT_AD_STICK_X ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(4) |
| 329 | 323 | |
| 330 | 324 | PORT_START("JOY4-Y") |
| 331 | | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_Y ) PORT_SENSITIVITY(25) PORT_PLAYER(4) |
| 325 | PORT_BIT( 0xff, 70, IPT_AD_STICK_Y ) PORT_MINMAX(0, 139) PORT_SENSITIVITY(25) PORT_PLAYER(4) |
| 332 | 326 | |
| 333 | 327 | PORT_START("JOY-R") |
| 334 | 328 | PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1) |
| r15135 | r15136 | |
| 397 | 391 | } |
| 398 | 392 | } |
| 399 | 393 | |
| 394 | WRITE_LINE_MEMBER( vidbrain_state::hblank_w ) |
| 395 | { |
| 396 | if (state && m_joy_enable && !m_timer_ne555->enabled()) |
| 397 | { |
| 398 | UINT8 joydata = 0; |
| 399 | |
| 400 | if (!BIT(m_keylatch, 0)) joydata = ioport("JOY1-X")->read(); |
| 401 | if (!BIT(m_keylatch, 1)) joydata = ioport("JOY1-Y")->read(); |
| 402 | if (!BIT(m_keylatch, 2)) joydata = ioport("JOY2-X")->read(); |
| 403 | if (!BIT(m_keylatch, 3)) joydata = ioport("JOY2-Y")->read(); |
| 404 | if (!BIT(m_keylatch, 4)) joydata = ioport("JOY3-X")->read(); |
| 405 | if (!BIT(m_keylatch, 5)) joydata = ioport("JOY3-Y")->read(); |
| 406 | if (!BIT(m_keylatch, 6)) joydata = ioport("JOY4-X")->read(); |
| 407 | if (!BIT(m_keylatch, 7)) joydata = ioport("JOY4-Y")->read(); |
| 408 | |
| 409 | // NE555 in monostable mode |
| 410 | // R = 3K9 + (0..140K) |
| 411 | // C = 0.003uF |
| 412 | // t = 1.1 * R * C |
| 413 | double t = 1.1 * (RES_K(3.9) + RES_K(joydata)) * 3; |
| 414 | |
| 415 | timer_set(attotime::from_nsec(t), TIMER_JOYSTICK); |
| 416 | } |
| 417 | } |
| 418 | |
| 400 | 419 | static UINT8 memory_read_byte(address_space *space, offs_t address) { return space->read_byte(address); } |
| 401 | 420 | |
| 402 | 421 | static UV201_INTERFACE( uv_intf ) |
| 403 | 422 | { |
| 404 | 423 | SCREEN_TAG, |
| 405 | 424 | DEVCB_DRIVER_LINE_MEMBER(vidbrain_state, ext_int_w), |
| 425 | DEVCB_DRIVER_LINE_MEMBER(vidbrain_state, hblank_w), |
| 406 | 426 | DEVCB_MEMORY_HANDLER(F3850_TAG, PROGRAM, memory_read_byte) |
| 407 | 427 | }; |
| 408 | 428 | |
| r15135 | r15136 | |
| 448 | 468 | void vidbrain_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 449 | 469 | { |
| 450 | 470 | m_uv->ext_int_w(0); |
| 471 | |
| 472 | m_ext_int_latch = 1; |
| 473 | interrupt_check(); |
| 451 | 474 | } |
| 452 | 475 | |
| 453 | 476 | |
| r15135 | r15136 | |
| 459 | 482 | { |
| 460 | 483 | // register IRQ callback |
| 461 | 484 | device_set_irq_callback(m_maincpu, vidbrain_int_ack); |
| 485 | |
| 486 | // allocate timers |
| 487 | m_timer_ne555 = timer_alloc(TIMER_JOYSTICK); |
| 462 | 488 | |
| 463 | 489 | // register for state saving |
| 464 | 490 | save_item(NAME(m_vector)); |