Previous 15994 Revisions Next

r8783 Sunday 15th August, 2010 at 11:41:07 UTC by Sandro Ronco
[PSION] Added NVRAM
[src/mess/drivers]psion.c

src/mess/drivers/psion.c
r8782r8783
1111      - move HD44780 implementation in a device
1212
1313      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
1516
1617        16/07/2010 Skeleton driver.
1718
r8782r8783
3637
3738static struct _psion
3839{
39   UINT8 kb_counter;
40   UINT16 kb_counter;
4041   UINT8 enable_nmi;
4142   UINT8 *sys_register;
4243   UINT8 tcsr_value;
44   UINT8 stby_pwr;
4345
4446   /* RAM/ROM banks */
4547   UINT8 *ram;
48   size_t ram_size;
49   UINT8 *paged_ram;
4650   UINT8 rom_bank;
4751   UINT8 ram_bank;
4852   UINT8 ram_bank_count;
r8782r8783
277281void update_bank(running_machine *machine)
278282{
279283   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);
281285
282286   if (psion.rom_bank_count)
283287   {
r8782r8783
397401   case 0x03:
398402      /* datapack i/o data bus */
399403      return datapack_r(space->machine);
404   case 0x14:
405      return (hd63701_internal_registers_r(space, offset)&0x7f) | (psion.stby_pwr<<7);
400406   case 0x15:
401407      /*
402408      x--- ---- ON key active high
r8782r8783
404410      ---- --x- ??
405411      ---- ---x battery status
406412      */
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;
408414   case 0x17:
409415      return psion.port6;
410416   case 0x08:
r8782r8783
417423/* Read/Write common */
418424void io_rw(const address_space* space, UINT16 offset)
419425{
426   if (space->debugger_access)
427      return;
428
420429   switch (offset & 0xffc0)
421430   {
422431   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);
424436      break;
425437   case 0x100:
426438      //Pulse enable
r8782r8783
499511   return 0;
500512}
501513
514static 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
502523static ADDRESS_MAP_START(psioncm_mem, ADDRESS_SPACE_PROGRAM, 8)
503524   ADDRESS_MAP_UNMAP_LOW
504525   AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w)
505526   AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register)
506527   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)
508529   AM_RANGE(0x8000, 0xffff) AM_ROM
509530ADDRESS_MAP_END
510531
r8782r8783
513534   AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w)
514535   AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register)
515536   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)
517538   AM_RANGE(0x8000, 0xffff) AM_ROM
518539ADDRESS_MAP_END
519540
r8782r8783
522543   AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w)
523544   AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register)
524545   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)
526547   AM_RANGE(0x4000, 0x7fff) AM_RAMBANK("rambank")
527548   AM_RANGE(0x8000, 0xffff) AM_ROM
528549ADDRESS_MAP_END
r8782r8783
532553   AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w)
533554   AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register)
534555   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)
536557   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("rombank")
537558   AM_RANGE(0xc000, 0xffff) AM_ROM
538559ADDRESS_MAP_END
r8782r8783
542563   AM_RANGE(0x0000, 0x001f) AM_READWRITE(hd63701_int_reg_r, hd63701_int_reg_w)
543564   AM_RANGE(0x0040, 0x00ff) AM_RAM AM_BASE(&psion.sys_register)
544565   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)
546567   AM_RANGE(0x4000, 0x7fff) AM_RAMBANK("rambank")
547568   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("rombank")
548569   AM_RANGE(0xc000, 0xffff) AM_ROM
r8782r8783
556577      PORT_CONFSETTING( 0x01, "Low Battery" )
557578
558579   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)
560581
561582   PORT_START("K1")
562583      PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("MODE") PORT_CODE(KEYCODE_EQUALS)
r8782r8783
653674   memset(&psion.pack2, 0, sizeof(psion.pack2));
654675}
655676
677static 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
656702static MACHINE_START(psion)
657703{
658704   if (!strcmp(machine->gamedrv->name, "psionlam"))
r8782r8783
682728   }
683729
684730   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);
686732
687733   timer_pulse(machine, ATTOTIME_IN_SEC(1), NULL, 0, nmi_timer);
688734   timer_pulse(machine, ATTOTIME_IN_MSEC(500), NULL, 0, blink_timer);
r8782r8783
902948   MDRV_SOUND_ADD( "beep", BEEP, 0 )
903949   MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
904950
951   MDRV_NVRAM_HANDLER(psion)
952
905953   MDRV_IMPORT_FROM( psion_slot )
906954MACHINE_DRIVER_END
907955
r8782r8783
933981   MDRV_SOUND_ADD( "beep", BEEP, 0 )
934982   MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
935983
984   MDRV_NVRAM_HANDLER(psion)
985
936986   MDRV_IMPORT_FROM( psion_slot )
937987MACHINE_DRIVER_END
938988

Previous 15994 Revisions Next


© 1998-2018 The MESS Team