Previous 15994 Revisions Next

r8689 Monday 2nd August, 2010 at 10:52:53 UTC by Sandro Ronco
[PSION] Added basic datapack interface
[src/mess/drivers]psion.c

src/mess/drivers/psion.c
r8688r8689
2323#include "emu.h"
2424#include "cpu/m6800/m6800.h"
2525#include "sound/beep.h"
26#include "devices/cartslot.h"
2627
28struct datapack
29{
30   UINT8 id;
31   UINT8 len;
32   UINT16 counter;
33   UINT8* data;
34};
35
2736static struct _psion
2837{
2938   UINT8 kb_counter;
r8688r8689
3746   UINT8 ram_bank;
3847   UINT8 ram_bank_count;
3948   UINT8 rom_bank_count;
49
50   UINT8 port2_ddr;
51   UINT8 port6_ddr;
52   UINT8 port6;
53
54   struct datapack pack1;
55   struct datapack pack2;
4056} psion;
4157
4258/*************************************************
r8688r8689
271287   }
272288}
273289
290void datapack_w(running_machine *machine, UINT8 data)
291{
292   //TODO
293}
294
295UINT8 datapack_r(running_machine *machine)
296{
297   if (!(psion.port6 & 0x80))
298   {
299      if (!(psion.port6 & 0x10) && psion.pack1.len > 0)
300         return psion.pack1.data[psion.pack1.counter];
301      else if (!(psion.port6 & 0x20) && psion.pack2.len > 0)
302         return psion.pack2.data[psion.pack2.counter];
303   }
304
305   return 0;
306}
307
274308WRITE8_HANDLER( hd63701_int_reg_w )
275309{
276310   switch (offset)
277311   {
312   case 0x01:
313      psion.port2_ddr = data;
314      break;
315   case 0x03:
316      /* datapack i/o data bus */
317      datapack_w(space->machine, data);
318      break;
278319   case 0x08:
279320      psion.tcsr_value = data;
280321      break;
322   case 0x16:
323      psion.port6_ddr = data;
324      break;
325   case 0x17:
326      /*
327      datapack control lines
328      x--- ---- slot on/off
329      -x-- ---- slot 3
330      --x- ---- slot 2
331      ---x ---- slot 1
332      ---- x--- output enable
333      ---- -x-- program line
334      ---- --x- reset line
335      ---- ---x clock line
336      */
337      if (psion.port6_ddr == 0xff)
338      {
339         if ((psion.port6 & 0x01) != (data & 0x01))
340         {
341            if (!(data & 0x10))
342               psion.pack1.counter++;
343            else if (!(data & 0x20))
344               psion.pack2.counter++;
345
346            if (psion.pack1.counter >= psion.pack1.len * 0x2000)
347               psion.pack1.counter -= 0x2000;
348         }
349
350         if (psion.port6 & 0x02)
351         {
352            if (!(data & 0x10))
353               psion.pack1.counter = 0;
354            else if (!(data & 0x20))
355               psion.pack2.counter = 0;
356         }
357
358         psion.port6 = data;
359      }
360      break;
281361   }
282362
283363   hd63701_internal_registers_w(space, offset, data);
r8688r8689
287367{
288368   switch (offset)
289369   {
370   case 0x03:
371      /* datapack i/o data bus */
372      return datapack_r(space->machine);
290373   case 0x15:
291374      /*
292375      x--- ---- ON key active high
r8688r8689
295378      ---- ---x battery status
296379      */
297380      return kb_read(space->machine) | input_port_read(space->machine, "BATTERY") | input_port_read(space->machine, "ON");
381   case 0x17:
382      return psion.port6;
298383   case 0x08:
299384      hd63701_internal_registers_w(space, offset, psion.tcsr_value);
300385   default:
r8688r8689
496581      PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D [)]") PORT_CODE(KEYCODE_D)
497582INPUT_PORTS_END
498583
584static DEVICE_IMAGE_LOAD( psion_pack1 )
585{
586   running_machine *machine = image.device().machine;
587   char opk_head[6];
588
589   image.fread(opk_head, 6);
590   image.fread(&psion.pack1.id, 1);
591   image.fread(&psion.pack1.len, 1);
592
593   if(strcmp(opk_head, "OPK") || psion.pack1.len * 0x2000 < image.length() - 6)
594      return IMAGE_INIT_FAIL;
595
596   image.fseek(6, SEEK_SET);
597   psion.pack1.data = auto_alloc_array(machine, UINT8, psion.pack1.len * 0x2000);
598   memset(psion.pack1.data, 0xff, psion.pack1.len * 0x2000);
599   image.fread(psion.pack1.data, image.length() - 6);
600
601   return IMAGE_INIT_PASS;
602}
603
604static DEVICE_IMAGE_UNLOAD( psion_pack1 )
605{
606   auto_free(image.device().machine, psion.pack1.data);
607   memset(&psion.pack1, 0, sizeof(psion.pack1));
608}
609
499610static MACHINE_START(psion)
500611{
501612   if (!strcmp(machine->gamedrv->name, "psionlam"))
r8688r8689
602713               *BITMAP_ADDR16(bitmap, (cur_y-1) * 9 + l, cur_x*6 + i) = 1;
603714   }
604715
605#if(1)
716#if(0)
606717   popmessage("cur: %u, pos %u, shift %u", hd44780.cursor_on, hd44780.ddram_a, hd44780.disp_shift);
607718#endif
608719    return 0;
r8688r8689
673784               *BITMAP_ADDR16(bitmap, (cur_y-1) * 9 + l, cur_x*6 + i) = 1;
674785   }
675786
676#if(1)
787#if(0)
677788   popmessage("cur: %u, pos %u, shift %u", hd44780.cursor_on, hd44780.cursor_pos, hd44780.disp_shift);
678789#endif
679790    return 0;
r8688r8689
700811   GFXDECODE_ENTRY( "chargen", 0x0000, psion_charlayout, 0, 1 )
701812GFXDECODE_END
702813
814
815static MACHINE_DRIVER_START( psion_slot )
816   /* Datapack slot 1 */
817   MDRV_CARTSLOT_ADD("pack1")
818   MDRV_CARTSLOT_EXTENSION_LIST("opk")
819   MDRV_CARTSLOT_NOT_MANDATORY
820   MDRV_CARTSLOT_LOAD(psion_pack1)
821   MDRV_CARTSLOT_UNLOAD(psion_pack1)
822MACHINE_DRIVER_END
823
703824/* basic configuration for 2 lines display */
704825static MACHINE_DRIVER_START( psion_2lines )
705826   /* basic machine hardware */
r8688r8689
728849   MDRV_SOUND_ADD( "beep", BEEP, 0 )
729850   MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
730851
852   MDRV_IMPORT_FROM( psion_slot )
731853MACHINE_DRIVER_END
732854
733855/* basic configuration for 4 lines display */
r8688r8689
757879   MDRV_SPEAKER_STANDARD_MONO( "mono" )
758880   MDRV_SOUND_ADD( "beep", BEEP, 0 )
759881   MDRV_SOUND_ROUTE( ALL_OUTPUTS, "mono", 1.00 )
882
883   MDRV_IMPORT_FROM( psion_slot )
760884MACHINE_DRIVER_END
761885
762886static MACHINE_DRIVER_START( psioncm )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team