trunk/src/mess/drivers/vic20.c
| r20546 | r20547 | |
| 156 | 156 | switch ((offset >> 10) & 0x07) |
| 157 | 157 | { |
| 158 | 158 | default: |
| 159 | | data = m_charom[offset & 0xfff]; |
| 159 | data = m_charom->base()[offset & 0xfff]; |
| 160 | 160 | break; |
| 161 | 161 | |
| 162 | 162 | case IO0: |
| r20546 | r20547 | |
| 186 | 186 | case BLK5: blk5 = 0; break; |
| 187 | 187 | |
| 188 | 188 | case BLK6: |
| 189 | | data = m_basic[offset & 0x1fff]; |
| 189 | data = m_basic->base()[offset & 0x1fff]; |
| 190 | 190 | break; |
| 191 | 191 | |
| 192 | 192 | case BLK7: |
| 193 | | data = m_kernal[offset & 0x1fff]; |
| 193 | data = m_kernal->base()[offset & 0x1fff]; |
| 194 | 194 | break; |
| 195 | 195 | } |
| 196 | 196 | |
| r20546 | r20547 | |
| 296 | 296 | } |
| 297 | 297 | else |
| 298 | 298 | { |
| 299 | | data = m_charom[offset & 0xfff]; |
| 299 | data = m_charom->base()[offset & 0xfff]; |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | return m_exp->cd_r(space, offset & 0x1fff, data, ram1, ram2, ram3, blk1, blk2, blk3, blk5, io2, io3); |
| r20546 | r20547 | |
| 355 | 355 | // INPUT_PORTS( vic20 ) |
| 356 | 356 | //------------------------------------------------- |
| 357 | 357 | |
| 358 | INPUT_CHANGED_MEMBER( vic20_state::restore_w ) |
| 359 | { |
| 360 | m_via0->write_ca1(newval); |
| 361 | } |
| 362 | |
| 358 | 363 | static INPUT_PORTS_START( vic20 ) |
| 359 | | PORT_INCLUDE( vic_keyboard ) // ROW0 -> ROW7 |
| 364 | PORT_START( "ROW0" ) |
| 365 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Del Inst") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 366 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2) PORT_CHAR('\xA3') |
| 367 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('+') |
| 368 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 369 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 370 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 371 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('#') |
| 372 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 360 | 373 | |
| 361 | | PORT_INCLUDE( vic_special ) // SPECIAL |
| 374 | PORT_START( "ROW1" ) |
| 375 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 376 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('*') |
| 377 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_P) PORT_CHAR('P') |
| 378 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_I) PORT_CHAR('I') |
| 379 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Y) PORT_CHAR('Y') |
| 380 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_R) PORT_CHAR('R') |
| 381 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_W) PORT_CHAR('W') |
| 382 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x90") PORT_CODE(KEYCODE_TILDE) PORT_CHAR(0x2190) |
| 383 | |
| 384 | PORT_START( "ROW2" ) |
| 385 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Crsr Right Left") PORT_CODE(KEYCODE_RCONTROL) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 386 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(';') PORT_CHAR(']') |
| 387 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_L) PORT_CHAR('L') |
| 388 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_J) PORT_CHAR('J') |
| 389 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_G) PORT_CHAR('G') |
| 390 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 391 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 392 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_TAB) PORT_CHAR(UCHAR_SHIFT_2) |
| 393 | |
| 394 | PORT_START( "ROW3" ) |
| 395 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Crsr Down Up") PORT_CODE(KEYCODE_RALT) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 396 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 397 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 398 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_N) PORT_CHAR('N') |
| 399 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_V) PORT_CHAR('V') |
| 400 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_X) PORT_CHAR('X') |
| 401 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Shift (Left)") PORT_CODE(KEYCODE_LSHIFT) |
| 402 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Stop Run") PORT_CODE(KEYCODE_HOME) |
| 403 | |
| 404 | PORT_START( "ROW4" ) |
| 405 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 406 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Shift (Right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 407 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 408 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_M) PORT_CHAR('M') |
| 409 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 410 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 411 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Z) PORT_CHAR('Z') |
| 412 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 413 | |
| 414 | PORT_START( "ROW5" ) |
| 415 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F3)) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 416 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR('=') |
| 417 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_COLON) PORT_CHAR(':') PORT_CHAR('[') |
| 418 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_K) PORT_CHAR('K') |
| 419 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_H) PORT_CHAR('H') |
| 420 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 421 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_S) PORT_CHAR('S') |
| 422 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("CBM") PORT_CODE(KEYCODE_LCONTROL) |
| 423 | |
| 424 | PORT_START( "ROW6" ) |
| 425 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F5)) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 426 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("\xE2\x86\x91 Pi") PORT_CODE(KEYCODE_DEL) PORT_CHAR(0x2191) PORT_CHAR(0x03C0) |
| 427 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') |
| 428 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_O) PORT_CHAR('O') |
| 429 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_U) PORT_CHAR('U') |
| 430 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_T) PORT_CHAR('T') |
| 431 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 432 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_Q) PORT_CHAR('Q') |
| 433 | |
| 434 | PORT_START( "ROW7" ) |
| 435 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F7)) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 436 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("Home Clr") PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(HOME)) |
| 437 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('-') |
| 438 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 439 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 440 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 441 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 442 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 443 | |
| 444 | PORT_START( "RESTORE" ) |
| 445 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RESTORE") PORT_CODE(KEYCODE_PRTSCR) PORT_CHANGED_MEMBER(DEVICE_SELF, vic20_state, restore_w, 0) |
| 446 | |
| 447 | PORT_START( "LOCK" ) |
| 448 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("SHIFT LOCK") PORT_CODE(KEYCODE_CAPSLOCK) PORT_TOGGLE PORT_CHAR(UCHAR_MAMEKEY(CAPSLOCK)) |
| 449 | PORT_BIT( 0x7f, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 362 | 450 | INPUT_PORTS_END |
| 363 | 451 | |
| 364 | 452 | |
| r20546 | r20547 | |
| 475 | 563 | m_iec->atn_w(!BIT(data, 7)); |
| 476 | 564 | } |
| 477 | 565 | |
| 566 | READ_LINE_MEMBER( vic20_state::via0_ca1_r ) |
| 567 | { |
| 568 | return m_restore->read(); |
| 569 | } |
| 570 | |
| 478 | 571 | static const via6522_interface via0_intf = |
| 479 | 572 | { |
| 480 | 573 | DEVCB_DRIVER_MEMBER(vic20_state, via0_pa_r), |
| 481 | 574 | DEVCB_DEVICE_MEMBER(VIC20_USER_PORT_TAG, vic20_user_port_device, pb_r), |
| 482 | | DEVCB_NULL, // RESTORE |
| 575 | DEVCB_DRIVER_LINE_MEMBER(vic20_state, via0_ca1_r), |
| 483 | 576 | DEVCB_NULL, |
| 484 | 577 | DEVCB_NULL, |
| 485 | 578 | DEVCB_NULL, |
| r20546 | r20547 | |
| 516 | 609 | |
| 517 | 610 | UINT8 data = 0xff; |
| 518 | 611 | |
| 519 | | if (!BIT(m_key_col, 0)) data &= ioport("ROW0")->read(); |
| 520 | | if (!BIT(m_key_col, 1)) data &= ioport("ROW1")->read(); |
| 521 | | if (!BIT(m_key_col, 2)) data &= ioport("ROW2")->read(); |
| 522 | | if (!BIT(m_key_col, 3)) data &= ioport("ROW3")->read(); |
| 523 | | if (!BIT(m_key_col, 4)) data &= ioport("ROW4")->read(); |
| 524 | | if (!BIT(m_key_col, 5)) data &= ioport("ROW5")->read(); |
| 525 | | if (!BIT(m_key_col, 6)) data &= ioport("ROW6")->read(); |
| 526 | | if (!BIT(m_key_col, 7)) data &= ioport("ROW7")->read(); |
| 612 | if (!BIT(m_key_col, 0)) data &= m_row0->read(); |
| 613 | if (!BIT(m_key_col, 1)) data &= m_row1->read(); |
| 614 | if (!BIT(m_key_col, 2)) data &= m_row2->read(); |
| 615 | if (!BIT(m_key_col, 3)) data &= m_row3->read(); |
| 616 | if (!BIT(m_key_col, 4)) data &= m_row4->read(); |
| 617 | if (!BIT(m_key_col, 5)) data &= m_row5->read(); |
| 618 | if (!BIT(m_key_col, 6)) data &= m_row6->read(); |
| 619 | if (!BIT(m_key_col, 7)) data &= m_row7->read(); |
| 527 | 620 | |
| 528 | 621 | return data; |
| 529 | 622 | } |
| r20546 | r20547 | |
| 691 | 784 | |
| 692 | 785 | void vic20_state::machine_start() |
| 693 | 786 | { |
| 694 | | // find memory regions |
| 695 | | m_basic = memregion("basic")->base(); |
| 696 | | m_kernal = memregion("kernal")->base(); |
| 697 | | m_charom = memregion("charom")->base(); |
| 698 | | |
| 699 | 787 | // initialize memory |
| 700 | 788 | UINT8 data = 0xff; |
| 701 | 789 | |