src/mess/drivers/psion.c
| r8782 | r8783 | |
| 11 | 11 | - move HD44780 implementation in a device |
| 12 | 12 | |
| 13 | 13 | Note: |
| 14 | | - 4 lines dysplay has an custom LCD controller derived from an HD66780 |
| 14 | - 4 lines display has an custom LCD controller derived from an HD66780 |
| 15 | - NVRAM works only if the machine is turned off (with OFF menu) before closing MESS |
| 15 | 16 | |
| 16 | 17 | 16/07/2010 Skeleton driver. |
| 17 | 18 | |
| r8782 | r8783 | |
| 36 | 37 | |
| 37 | 38 | static struct _psion |
| 38 | 39 | { |
| 39 | | UINT8 kb_counter; |
| 40 | UINT16 kb_counter; |
| 40 | 41 | UINT8 enable_nmi; |
| 41 | 42 | UINT8 *sys_register; |
| 42 | 43 | UINT8 tcsr_value; |
| 44 | UINT8 stby_pwr; |
| 43 | 45 | |
| 44 | 46 | /* RAM/ROM banks */ |
| 45 | 47 | UINT8 *ram; |
| 48 | size_t ram_size; |
| 49 | UINT8 *paged_ram; |
| 46 | 50 | UINT8 rom_bank; |
| 47 | 51 | UINT8 ram_bank; |
| 48 | 52 | UINT8 ram_bank_count; |
| r8782 | r8783 | |
| 277 | 281 | void update_bank(running_machine *machine) |
| 278 | 282 | { |
| 279 | 283 | if (psion.ram_bank < psion.ram_bank_count && psion.ram_bank_count) |
| 280 | | memory_set_bankptr(machine,"rambank", psion.ram + psion.ram_bank*0x4000); |
| 284 | memory_set_bankptr(machine,"rambank", psion.paged_ram + psion.ram_bank*0x4000); |
| 281 | 285 | |
| 282 | 286 | if (psion.rom_bank_count) |
| 283 | 287 | { |
| r8782 | r8783 | |
| 397 | 401 | case 0x03: |
| 398 | 402 | /* datapack i/o data bus */ |
| 399 | 403 | return datapack_r(space->machine); |
| 404 | case 0x14: |
| 405 | return (hd63701_internal_registers_r(space, offset)&0x7f) | (psion.stby_pwr<<7); |
| 400 | 406 | case 0x15: |
| 401 | 407 | /* |
| 402 | 408 | x--- ---- ON key active high |
| r8782 | r8783 | |
| 404 | 410 | ---- --x- ?? |
| 405 | 411 | ---- ---x battery status |
| 406 | 412 | */ |
| 407 | | return kb_read(space->machine) | input_port_read(space->machine, "BATTERY") | input_port_read(space->machine, "ON"); |
| 413 | return kb_read(space->machine) | input_port_read(space->machine, "BATTERY") | input_port_read(space->machine, "ON") | (psion.kb_counter == 0x7ff)<<1; |
| 408 | 414 | case 0x17: |
| 409 | 415 | return psion.port6; |
| 410 | 416 | case 0x08: |
| r8782 | r8783 | |
| 417 | 423 | /* Read/Write common */ |
| 418 | 424 | void io_rw(const address_space* space, UINT16 offset) |
| 419 | 425 | { |
| 426 | if (space->debugger_access) |
| 427 | return; |
| 428 | |
| 420 | 429 | switch (offset & 0xffc0) |
| 421 | 430 | { |
| 422 | 431 | case 0xc0: |
| 423 | | //Switch off |
| 432 | /* switch off, CPU goes into standby mode */ |
| 433 | psion.enable_nmi = 0; |
| 434 | psion.stby_pwr = 1; |
| 435 | space->machine->device<cpu_device>("maincpu")->suspend(SUSPEND_REASON_HALT, 1); |
| 424 | 436 | break; |
| 425 | 437 | case 0x100: |
| 426 | 438 | //Pulse enable |
| r8782 | r8783 | |
| 499 | 511 | return 0; |
| 500 | 512 | } |
| 501 | 513 | |
| 514 | static INPUT_CHANGED( psion_on ) |
| 515 | { |
| 516 | cpu_device *cpu = field->port->machine->device<cpu_device>("maincpu"); |
| 517 | |
| 518 | /* reset the CPU for resume from standby */ |
| 519 | if (cpu->suspended(SUSPEND_REASON_HALT)) |
| 520 | cpu->reset(); |
| 521 | } |
| 522 | |
| 502 | 523 | static ADDRESS_MAP_START(psioncm_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 503 | 524 | ADDRESS_MAP_UNMAP_LOW |
| 504 | 525 | AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w) |
| 505 | 526 | AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register) |
| 506 | 527 | AM_RANGE(0x0100, 0x03ff) AM_READWRITE(io_r, io_w) |
| 507 | | AM_RANGE(0x2000, 0x3fff) AM_RAM |
| 528 | AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&psion.ram) AM_SIZE(&psion.ram_size) |
| 508 | 529 | AM_RANGE(0x8000, 0xffff) AM_ROM |
| 509 | 530 | ADDRESS_MAP_END |
| 510 | 531 | |
| r8782 | r8783 | |
| 513 | 534 | AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w) |
| 514 | 535 | AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register) |
| 515 | 536 | AM_RANGE(0x0100, 0x03ff) AM_READWRITE(io_r, io_w) |
| 516 | | AM_RANGE(0x0400, 0x5fff) AM_RAM |
| 537 | AM_RANGE(0x0400, 0x5fff) AM_RAM AM_BASE(&psion.ram) AM_SIZE(&psion.ram_size) |
| 517 | 538 | AM_RANGE(0x8000, 0xffff) AM_ROM |
| 518 | 539 | ADDRESS_MAP_END |
| 519 | 540 | |
| r8782 | r8783 | |
| 522 | 543 | AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w) |
| 523 | 544 | AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register) |
| 524 | 545 | AM_RANGE(0x0100, 0x03ff) AM_READWRITE(io_r, io_w) |
| 525 | | AM_RANGE(0x0400, 0x3fff) AM_RAM |
| 546 | AM_RANGE(0x0400, 0x3fff) AM_RAM AM_BASE(&psion.ram) AM_SIZE(&psion.ram_size) |
| 526 | 547 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK("rambank") |
| 527 | 548 | AM_RANGE(0x8000, 0xffff) AM_ROM |
| 528 | 549 | ADDRESS_MAP_END |
| r8782 | r8783 | |
| 532 | 553 | AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w) |
| 533 | 554 | AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register) |
| 534 | 555 | AM_RANGE(0x0100, 0x03ff) AM_READWRITE(io_r, io_w) |
| 535 | | AM_RANGE(0x0400, 0x7fff) AM_RAM |
| 556 | AM_RANGE(0x0400, 0x7fff) AM_RAM AM_BASE(&psion.ram) AM_SIZE(&psion.ram_size) |
| 536 | 557 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("rombank") |
| 537 | 558 | AM_RANGE(0xc000, 0xffff) AM_ROM |
| 538 | 559 | ADDRESS_MAP_END |
| r8782 | r8783 | |
| 542 | 563 | AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w) |
| 543 | 564 | AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register) |
| 544 | 565 | AM_RANGE(0x0100, 0x03ff) AM_READWRITE(io_r, io_w) |
| 545 | | AM_RANGE(0x0400, 0x3fff) AM_RAM |
| 566 | AM_RANGE(0x0400, 0x3fff) AM_RAM AM_BASE(&psion.ram) AM_SIZE(&psion.ram_size) |
| 546 | 567 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK("rambank") |
| 547 | 568 | AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("rombank") |
| 548 | 569 | AM_RANGE(0xc000, 0xffff) AM_ROM |
| r8782 | r8783 | |
| 556 | 577 | PORT_CONFSETTING( 0x01, "Low Battery" ) |
| 557 | 578 | |
| 558 | 579 | PORT_START("ON") |
| 559 | | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON/CLEAR") PORT_CODE(KEYCODE_F10) |
| 580 | PORT_BIT(0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON/CLEAR") PORT_CODE(KEYCODE_F10) PORT_CHANGED(psion_on, 0) |
| 560 | 581 | |
| 561 | 582 | PORT_START("K1") |
| 562 | 583 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MODE") PORT_CODE(KEYCODE_EQUALS) |
| r8782 | r8783 | |
| 653 | 674 | memset(&psion.pack2, 0, sizeof(psion.pack2)); |
| 654 | 675 | } |
| 655 | 676 | |
| 677 | static NVRAM_HANDLER( psion ) |
| 678 | { |
| 679 | if (read_or_write) |
| 680 | { |
| 681 | mame_fwrite(file, psion.sys_register, 0xc0); |
| 682 | mame_fwrite(file, psion.ram, psion.ram_size); |
| 683 | if (psion.ram_bank_count) |
| 684 | mame_fwrite(file, psion.paged_ram, psion.ram_bank_count * 0x4000); |
| 685 | } |
| 686 | else |
| 687 | { |
| 688 | if (file) |
| 689 | { |
| 690 | mame_fread(file, psion.sys_register, 0xc0); |
| 691 | mame_fread(file, psion.ram, psion.ram_size); |
| 692 | if (psion.ram_bank_count) |
| 693 | mame_fread(file, psion.paged_ram, psion.ram_bank_count * 0x4000); |
| 694 | |
| 695 | psion.stby_pwr = 1; |
| 696 | } |
| 697 | else |
| 698 | psion.stby_pwr = 0; |
| 699 | } |
| 700 | } |
| 701 | |
| 656 | 702 | static MACHINE_START(psion) |
| 657 | 703 | { |
| 658 | 704 | if (!strcmp(machine->gamedrv->name, "psionlam")) |
| r8782 | r8783 | |
| 682 | 728 | } |
| 683 | 729 | |
| 684 | 730 | if (psion.ram_bank_count) |
| 685 | | psion.ram = auto_alloc_array(machine, UINT8, psion.ram_bank_count * 0x4000); |
| 731 | psion.paged_ram = auto_alloc_array(machine, UINT8, psion.ram_bank_count * 0x4000); |
| 686 | 732 | |
| 687 | 733 | timer_pulse(machine, ATTOTIME_IN_SEC(1), NULL, 0, nmi_timer); |
| 688 | 734 | timer_pulse(machine, ATTOTIME_IN_MSEC(500), NULL, 0, blink_timer); |
| r8782 | r8783 | |
| 902 | 948 | MDRV_SOUND_ADD( "beep", BEEP, 0 ) |
| 903 | 949 | MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) |
| 904 | 950 | |
| 951 | MDRV_NVRAM_HANDLER(psion) |
| 952 | |
| 905 | 953 | MDRV_IMPORT_FROM( psion_slot ) |
| 906 | 954 | MACHINE_DRIVER_END |
| 907 | 955 | |
| r8782 | r8783 | |
| 933 | 981 | MDRV_SOUND_ADD( "beep", BEEP, 0 ) |
| 934 | 982 | MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 ) |
| 935 | 983 | |
| 984 | MDRV_NVRAM_HANDLER(psion) |
| 985 | |
| 936 | 986 | MDRV_IMPORT_FROM( psion_slot ) |
| 937 | 987 | MACHINE_DRIVER_END |
| 938 | 988 | |