Previous 15994 Revisions Next

r4346 Wednesday 25th February, 2009 at 11:46:49 UTC by Dirk Best
Added /PC pin output support to the CIA emulation
[src/emu/machine]6526cia.c 6526cia.h
[src/mame/drivers]alg.c arcadia.c cubocd32.c mquake.c upscope.c
[src/mess/drivers]amiga.c
[src/mess/machine]c64.c cbmb.c

src/mame/drivers/cubocd32.c
r4345r4346
212212static const cia6526_interface cia_0_intf =
213213{
214214   DEVCB_LINE(amiga_cia_0_irq),                           /* irq_func */
215   DEVCB_NULL,   /* pc_func */
215216   0,                                       /* tod_clock */
216217   {
217218      { DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(cd32_cia_0_porta_w) },      /* port A */
r4345r4346
222223static const cia6526_interface cia_1_intf =
223224{
224225   DEVCB_LINE(amiga_cia_1_irq),                           /* irq_func */
226   DEVCB_NULL,   /* pc_func */
225227   0,                                       /* tod_clock */
226228   {
227229      { DEVCB_NULL, DEVCB_NULL },                           /* port A */
src/mame/drivers/alg.c
r4345r4346
378378static const cia6526_interface cia_0_intf =
379379{
380380   DEVCB_LINE(amiga_cia_0_irq),                        /* irq_func */
381   DEVCB_NULL,   /* pc_func */
381382   0,                                    /* tod_clock */
382383   {
383384      { DEVCB_HANDLER(alg_cia_0_porta_r), DEVCB_HANDLER(alg_cia_0_porta_w) },   /* port A */
r4345r4346
388389static const cia6526_interface cia_1_intf =
389390{
390391   DEVCB_LINE(amiga_cia_1_irq),                        /* irq_func */
392   DEVCB_NULL,   /* pc_func */
391393   0,                                    /* tod_clock */
392394   {
393395      { DEVCB_HANDLER(alg_cia_1_porta_r), DEVCB_HANDLER(alg_cia_1_porta_w), },   /* port A */
src/mame/drivers/arcadia.c
r4345r4346
260260static const cia6526_interface cia_0_intf =
261261{
262262   DEVCB_LINE(amiga_cia_0_irq),                              /* irq_func */
263   DEVCB_NULL,   /* pc_func */
263264   0,                                          /* tod_clock */
264265   {
265266      { DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(arcadia_cia_0_porta_w) },   /* port A */
r4345r4346
270271static const cia6526_interface cia_1_intf =
271272{
272273   DEVCB_LINE(amiga_cia_1_irq),                              /* irq_func */
274   DEVCB_NULL,   /* pc_func */
273275   0,                                          /* tod_clock */
274276   {
275277      { DEVCB_NULL, DEVCB_NULL },                              /* port A */
src/mame/drivers/upscope.c
r4345r4346
277277static const cia6526_interface cia_0_intf =
278278{
279279   DEVCB_LINE(amiga_cia_0_irq),                              /* irq_func */
280   DEVCB_NULL,   /* pc_func */
280281   0,                                          /* tod_clock */
281282   {
282283      { DEVCB_NULL, DEVCB_HANDLER(upscope_cia_0_porta_w) },               /* port A */
r4345r4346
287288static const cia6526_interface cia_1_intf =
288289{
289290   DEVCB_LINE(amiga_cia_1_irq),                              /* irq_func */
291   DEVCB_NULL,   /* pc_func */
290292   0,                                          /* tod_clock */
291293   {
292294      { DEVCB_HANDLER(upscope_cia_1_porta_r), DEVCB_HANDLER(upscope_cia_1_porta_w), },   /* port A */
src/mame/drivers/mquake.c
r4345r4346
333333static const cia6526_interface cia_0_intf =
334334{
335335   DEVCB_LINE(amiga_cia_0_irq),                           /* irq_func */
336   DEVCB_NULL,   /* pc_func */
336337   0,                                       /* tod_clock */
337338   {
338339      { DEVCB_INPUT_PORT("CIA0PORTA"), DEVCB_HANDLER(mquake_cia_0_porta_w) },   /* port A */
r4345r4346
343344static const cia6526_interface cia_1_intf =
344345{
345346   DEVCB_LINE(amiga_cia_1_irq),                           /* irq_func */
347   DEVCB_NULL,   /* pc_func */
346348   0,                                       /* tod_clock */
347349   {
348350      { DEVCB_NULL, DEVCB_NULL },                           /* port A */
src/emu/machine/6526cia.c
r4345r4346
6767{
6868   const device_config *device;
6969   devcb_resolved_write_line irq_func;
70   devcb_resolved_write_line pc_func;
7071
7172   cia_port      port[2];
7273   cia_timer      timer[2];
r4345r4346
141142   memset(cia, 0, sizeof(*cia));
142143   cia->device = device;
143144   devcb_resolve_write_line(&cia->irq_func, &intf->irq_func, device);
145   devcb_resolve_write_line(&cia->pc_func, &intf->pc_func, device);
144146
145147   /* setup ports */
146148   for (p = 0; p < (sizeof(cia->port) / sizeof(cia->port[0])); p++)
r4345r4346
273275
274276
275277/*-------------------------------------------------
278    cia_update_pc - pulse /pc output
279-------------------------------------------------*/
280
281static void cia_update_pc(const device_config *device)
282{
283   cia_state *cia = get_token(device);
284
285   /* this should really be one cycle long */
286   devcb_call_write_line(&cia->pc_func, 0);
287   devcb_call_write_line(&cia->pc_func, 1);
288}
289
290
291/*-------------------------------------------------
276292    cia_update_interrupts
277293-------------------------------------------------*/
278294
r4345r4346
651667               else
652668                  data &= ~0x80;
653669            }
670
671            /* pulse /PC following the read */
672            cia_update_pc(device);
654673         }
655674         break;
656675
r4345r4346
742761         port->latch = data;
743762         port->out = (data & port->ddr) | (port->in & ~port->ddr);
744763         devcb_call_write8(&port->write, 0, port->out);
764
765         /* pulse /PC following the write */
766         if (offset == CIA_PRB)
767            cia_update_pc(device);
768
745769         break;
746770
747771      /* port A/B direction */
src/emu/machine/6526cia.h
r4345r4346
4545struct _cia6526_interface
4646{
4747   devcb_write_line irq_func;
48   devcb_write_line pc_func;
49
4850   int tod_clock;
4951
5052   struct
src/mess/machine/cbmb.c
r4345r4346
242242const cia6526_interface cbmb_cia =
243243{
244244   DEVCB_DEVICE_LINE(TPI6525, "tpi6525_0", tpi6525_irq2_level),
245   DEVCB_NULL,   /* pc_func */
245246   60,
246247
247248   {
src/mess/machine/c64.c
r4345r4346
1212    (program write some short test code into the vic sprite register)
1313 */
1414
15/*
15/*
1616   2008-09-06: Tape status for C64 & C128 [FP & RZ]
1717   - tape loading works
1818   - tap files are supported
r4345r4346
126126            cpu_set_input_line(machine->cpu[1], INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq);
127127         }
128128      }
129     
129
130130      else
131131      {
132132         cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq);
133133      }
134     
134
135135      nmilevel = (input_port_read(machine, "SPECIAL") & 0x80) || cia1irq;
136136   }
137137}
r4345r4346
294294
295295   if ( input_port_read(device->machine, "CTRLSEL") & 0x80 )
296296      value &= c64_keyline[9];
297    else
297    else
298298      value &= c64_keyline[8];
299299
300300    if (is_c128(device->machine))
r4345r4346
421421const cia6526_interface c64_ntsc_cia0 =
422422{
423423   DEVCB_LINE(c64_cia0_interrupt),
424   DEVCB_NULL,   /* pc_func */
424425   60,
425426
426427   {
r4345r4346
432433const cia6526_interface c64_pal_cia0 =
433434{
434435   DEVCB_LINE(c64_cia0_interrupt),
436   DEVCB_NULL,   /* pc_func */
435437   50,
436438
437439   {
r4345r4346
443445const cia6526_interface c64_ntsc_cia1 =
444446{
445447   DEVCB_LINE(c64_cia1_interrupt),
448   DEVCB_NULL,   /* pc_func */
446449   60,
447450
448451   {
r4345r4346
454457const cia6526_interface c64_pal_cia1 =
455458{
456459   DEVCB_LINE(c64_cia1_interrupt),
460   DEVCB_NULL,   /* pc_func */
457461   50,
458462
459463   {
r4345r4346
502506
503507WRITE8_HANDLER(c64_ioarea_w)
504508{
505   if (c64_io_enabled)
509   if (c64_io_enabled)
506510   {
507511      c64_write_io(space, offset, data);
508   }
509   else
512   }
513   else
510514   {
511515      c64_io_ram_w_ptr[offset] = data;
512516   }
r4345r4346
584588----------------------------------------------------------------------
585589 C000  RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM     -
586590----------------------------------------------------------------------
587 B000                                             
591 B000
588592       BASIC  RAM    RAM    RAM    RAM    BASIC  ROMH   ROMH    -
589 A000                                             
593 A000
590594----------------------------------------------------------------------
591 9000                                             
595 9000
592596       RAM    RAM    RAM    RAM    RAM    ROML   RAM    ROML   ROML(*
593 8000                                             
597 8000
594598----------------------------------------------------------------------
595 7000                                             
596                                             
597 6000                                             
599 7000
600
601 6000
598602       RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM     -
599 5000                                             
600                                             
601 4000                                             
603 5000
604
605 4000
602606----------------------------------------------------------------------
603 3000                                             
604                                             
607 3000
608
605609 2000  RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM     -
606                                             
607 1000                                             
610
611 1000
608612----------------------------------------------------------------------
609613 0000  RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM    RAM
610614----------------------------------------------------------------------
r4345r4346
643647
644648            RAM         various ranges  Commodore 64's internal RAM.
645649
646            -           1000-7FFF and   Open address space.
650            -           1000-7FFF and   Open address space.
647651                        A000-CFFF       The Commodore 64's memory chips
648652                                        do not detect any memory accesses
649653                                        to this area except the VIC-II's
r4345r4346
678682   int data = (UINT8) device_get_info_int(machine->cpu[0], CPUINFO_INT_M6510_PORT) & 0x07;
679683
680684   /* If nothing has changed or reset = 0, don't do anything */
681   if ((data == old) && (exrom == c64_exrom) && (game == c64_game) && !reset)
685   if ((data == old) && (exrom == c64_exrom) && (game == c64_game) && !reset)
682686      return;
683687
684688   /* Are we in Ultimax mode? */
r4345r4346
788792   data = (c64_port_data & ~direction) | (data & direction);
789793
790794   /* resistors make P0,P1,P2 go high when respective line is changed to input */
791   if (!(direction & 0x04))
795   if (!(direction & 0x04))
792796      data |= 0x04;
793797
794798   if (!(direction & 0x02))
r4345r4346
801805
802806   if (c64_tape_on)
803807   {
804      if (direction & 0x08)
808      if (direction & 0x08)
805809      {
806810         cassette_output(devtag_get_device(device->machine, CASSETTE, "cassette"), (data & 0x08) ? -(0x5a9e >> 1) : +(0x5a9e >> 1));
807811      }
r4345r4346
846850         data |=  0x10;
847851   }
848852
849   if (is_c65(device->machine))
853   if (is_c65(device->machine))
850854   {
851855      if (input_port_read(device->machine, "SPECIAL") & 0x20)      /* Check Caps Lock */
852856         data &= ~0x40;
853857
854      else
858      else
855859         data |=  0x40;
856860   }
857861
r4345r4346
948952      temp = pot3; pot3 = pot4; pot4 = temp;
949953   }
950954
951   switch (cia0porta & 0xc0)
955   switch (cia0porta & 0xc0)
952956   {
953957   case 0x40:
954958      return which ? pot2 : pot1;
r4345r4346
10241028   device_set_info_fct(machine->cpu[0], CPUINFO_FCT_M6510_PORTREAD, (genf *) c64_m6510_port_read);
10251029   device_set_info_fct(machine->cpu[0], CPUINFO_FCT_M6510_PORTWRITE, (genf *) c64_m6510_port_write);
10261030
1027   if (!ultimax)
1031   if (!ultimax)
10281032   {
10291033      UINT8 *mem = memory_region(machine, "main");
10301034      c64_basic    = mem + 0x10000;
r4345r4346
11711175
11721176      /* Shift Lock is mapped on Left Shift */
11731177      if ((i == 1) && (input_port_read(device->machine, "SPECIAL") & 0x40) && !is_c128(device->machine))   // Fix Me! Currently, neither left Shift nor Shift Lock works in c128, but reading this in c128 produces a bug!
1174         value &= ~0x80;         
1178         value &= ~0x80;
11751179
11761180      c64_keyline[i] = value;
11771181   }
r4345r4346
11831187      case 0x00:
11841188         value &= ~input_port_read(device->machine, "JOY1_1B");         /* Joy1 Directions + Button 1 */
11851189         break;
1186     
1190
11871191      case 0x01:
11881192         if (input_port_read(device->machine, "OTHER") & 0x40)         /* Paddle2 Button */
11891193            value &= ~0x08;
r4345r4346
11971201         if (input_port_read(device->machine, "OTHER") & 0x01)         /* Mouse Button Right */
11981202            value &= ~0x01;
11991203         break;
1200         
1204
12011205      case 0x03:
12021206         value &= ~(input_port_read(device->machine, "JOY1_2B") & 0x1f);   /* Joy1 Directions + Button 1 */
12031207         break;
1204     
1208
12051209      case 0x04:
12061210/* was there any input on the lightpen? where is it mapped? */
12071211//         if (input_port_read(device->machine, "OTHER") & 0x04)         /* Lightpen Signal */
r4345r4346
12251229      case 0x00:
12261230         value &= ~input_port_read(device->machine, "JOY2_1B");         /* Joy2 Directions + Button 1 */
12271231         break;
1228     
1232
12291233      case 0x10:
12301234         if (input_port_read(device->machine, "OTHER") & 0x10)         /* Paddle4 Button */
12311235            value &= ~0x08;
r4345r4346
12391243         if (input_port_read(device->machine, "OTHER") & 0x01)         /* Mouse Button Right */
12401244            value &= ~0x01;
12411245         break;
1242     
1246
12431247      case 0x30:
12441248         value &= ~(input_port_read(device->machine, "JOY2_2B") & 0x1f);   /* Joy2 Directions + Button 1 */
12451249         break;
r4345r4346
12611265   c64_keyline[9] = value;
12621266
12631267   /* C128 only : keypad input ports */
1264   if (is_c128(device->machine))
1268   if (is_c128(device->machine))
12651269   {
12661270      for (i = 0; i < 3; i++)
12671271      {
r4345r4346
12721276   }
12731277
12741278   /* C65 only : function keys input ports */
1275   if (is_c65(device->machine))
1279   if (is_c65(device->machine))
12761280   {
12771281      value = 0xff;
12781282
r4345r4346
12871291   timer_set(device->machine, attotime_zero, NULL, 0, lightpen_tick);
12881292
12891293   set_led_status (1, input_port_read(device->machine, "SPECIAL") & 0x40 ? 1 : 0);      /* Shift Lock */
1290   set_led_status (0, input_port_read(device->machine, "CTRLSEL") & 0x80 ? 1 : 0);      /* Joystick Swap */
1294   set_led_status (0, input_port_read(device->machine, "CTRLSEL") & 0x80 ? 1 : 0);      /* Joystick Swap */
12911295}
12921296
12931297
r4345r4346
12981302***********************************************/
12991303
13001304/* Info based on http://ist.uwaterloo.ca/~schepers/formats/CRT.TXT       */
1301/* Please refer to the webpage for the latest version and for a very
1305/* Please refer to the webpage for the latest version and for a very
13021306   complete listing of various cart types and their bankswitch tricks    */
13031307/*
13041308  Cartridge files were introduced in the CCS64  emulator,  written  by  Per
r4345r4346
13231327   $0040-EOF :      Blocks of data
13241328
13251329  Each block of data, called 'CHIP', can be of variable size. The first
13260x10 bytes of each CHIP block is the block header, and it contains various
1327informations on the block itself, as its size (both with and without the
13300x10 bytes of each CHIP block is the block header, and it contains various
1331informations on the block itself, as its size (both with and without the
13281332header), the loading address and an index to identify which memory bank
13291333the data must be loaded to.  FP ]
13301334
r4345r4346
14411445   REAL_FC_I,         /* 29 - (3)                           */
14421446   ACTION_REPLAY_4,   /* 30 - Action Replay 4                  */
14431447   STARDOS,         /* 31 - StarDOS                        */
1444   /*
1445   (1) Ocean type 1 includes Navy Seals, Robocop 2 & 3,  Shadow  of
1448   /*
1449   (1) Ocean type 1 includes Navy Seals, Robocop 2 & 3,  Shadow  of
14461450   the Beast, Toki, Terminator 2 and more. Both 256 and 128 Kb images.
14471451   (2) Dinamic includes Narco Police and more.
1448   (3) Type 29 is reserved for the real Final Cartridge I, the one
1452   (3) Type 29 is reserved for the real Final Cartridge I, the one
14491453   above (Type 13) will become Final Cartridge II.               */
14501454   /****************************************
1451   Vice also defines the following types:
1455   Vice also defines the following types:
14521456   #define CARTRIDGE_ACTION_REPLAY3    -29
14531457   #define CARTRIDGE_IEEE488           -11
14541458   #define CARTRIDGE_IDE64             -7
14551459   #define CARTRIDGE_RETRO_REPLAY      -5
14561460   #define CARTRIDGE_SUPER_SNAPSHOT    -4
14571461
1458   Can we support these as well?         
1462   Can we support these as well?
14591463   *****************************************/
14601464};
14611465
r4345r4346
15121516
15131517
15141518      /* Data in a .crt image are organized in blocks called 'CHIP':
1515         each 'CHIP' consists of a 0x10 header, which contains the
1516         actual size of the block, the loading address and info on
1519         each 'CHIP' consists of a 0x10 header, which contains the
1520         actual size of the block, the loading address and info on
15171521         the bankswitch, followed by the actual data               */
15181522      while (j < size)
15191523      {
15201524         unsigned short chip_size, chip_bank_index, chip_data_size;
15211525         unsigned char buffer[10];
1522         
1526
15231527         /* Start to parse the CHIP header */
15241528         /* First 4 bytes are the string 'CHIP' */
15251529         image_fread(image, buffer, 6);
r4345r4346
15311535         /* 0x08-0x09 chip type (ROM, RAM + no ROM, Flash ROM) */
15321536         image_fread(image, buffer + 6, 2);
15331537
1534         /* 0x0a-0x0b is the bank number of the CHIP block */
1538         /* 0x0a-0x0b is the bank number of the CHIP block */
15351539         /* We currently don't use this, but it is needed to support more cart types. */
15361540         image_fread(image, &chip_bank_index, 2);
15371541         chip_bank_index = BIG_ENDIANIZE_INT16(chip_bank_index);
15381542
1539         /* 0x0c-0x0d is the loading address of the CHIP block */
1543         /* 0x0c-0x0d is the loading address of the CHIP block */
15401544         image_fread(image, &address, 2);
15411545         address = BIG_ENDIANIZE_INT16(address);
15421546
1543         /* 0x0e-0x0f is the data size of the CHIP block (without header) */
1547         /* 0x0e-0x0f is the data size of the CHIP block (without header) */
15441548         image_fread(image, &chip_data_size, 2);
15451549         chip_data_size = BIG_ENDIANIZE_INT16(chip_data_size);
15461550
r4345r4346
15711575   }
15721576
15731577   /* We also support .80 files for c64 & .e0/.f0 for max */
1574   else
1578   else
15751579   {
15761580      /* Assign loading address according to extension */
15771581      if (!mame_stricmp (filetype, "80"))
r4345r4346
16001604   }
16011605
16021606   /* If we load a .crt file, use EXROM & GAME from the header! */
1603   if ((cbm_c64_exrom != -1) && (cbm_c64_game != -1))
1607   if ((cbm_c64_exrom != -1) && (cbm_c64_game != -1))
16041608   {
16051609      c64_exrom = cbm_c64_exrom;
16061610      c64_game  = cbm_c64_game;
r4345r4346
16131617   memset(roml, 0, 0x2000);
16141618   memset(romh, 0, 0x2000);
16151619
1616   for (i=0; (i < sizeof(c64_cbm_cart) / sizeof(c64_cbm_cart[0])) && (c64_cbm_cart[i].size != 0); i++)
1620   for (i=0; (i < sizeof(c64_cbm_cart) / sizeof(c64_cbm_cart[0])) && (c64_cbm_cart[i].size != 0); i++)
16171621   {
1618      if (c64_cbm_cart[i].addr < 0xc000)
1622      if (c64_cbm_cart[i].addr < 0xc000)
16191623         memcpy(roml + c64_cbm_cart[i].addr - 0x8000, c64_cbm_cart[i].chip, c64_cbm_cart[i].size);
16201624
1621      else
1625      else
16221626         memcpy(romh + c64_cbm_cart[i].addr - 0xe000, c64_cbm_cart[i].chip, c64_cbm_cart[i].size);
16231627   }
16241628
src/mess/drivers/amiga.c
r4345r4346
219219static const cia6526_interface cia_0_ntsc_intf =
220220{
221221   DEVCB_LINE(amiga_cia_0_irq),                           /* irq_func */
222   DEVCB_NULL,   /* pc_func */
222223   60,                                       /* tod_clock */
223224   {
224225      { DEVCB_HANDLER(amiga_cia_0_portA_r), DEVCB_HANDLER(amiga_cia_0_portA_w) },   /* port A */
r4345r4346
229230static const cia6526_interface cia_0_pal_intf =
230231{
231232   DEVCB_LINE(amiga_cia_0_irq),                           /* irq_func */
233   DEVCB_NULL,   /* pc_func */
232234   50,                                       /* tod_clock */
233235   {
234236      { DEVCB_HANDLER(amiga_cia_0_portA_r), DEVCB_HANDLER(amiga_cia_0_portA_w) },   /* port A */
r4345r4346
239241static const cia6526_interface cia_1_intf =
240242{
241243   DEVCB_LINE(amiga_cia_1_irq),                           /* irq_func */
244   DEVCB_NULL,   /* pc_func */
242245   0,                                       /* tod_clock */
243246   {
244247      { DEVCB_NULL, DEVCB_NULL },                        /* port A */
r4345r4346
249252static const cia6526_interface cia_0_cdtv_intf =
250253{
251254   DEVCB_LINE(amiga_cia_0_irq),                           /* irq_func */
255   DEVCB_NULL,   /* pc_func */
252256   0,                                       /* tod_clock */
253257   {
254258      { DEVCB_HANDLER(amiga_cia_0_cdtv_portA_r), DEVCB_HANDLER(amiga_cia_0_portA_w) },   /* port A */
r4345r4346
259263static const cia6526_interface cia_1_cdtv_intf =
260264{
261265   DEVCB_LINE(amiga_cia_1_irq),                           /* irq_func */
266   DEVCB_NULL,   /* pc_func */
262267   0,                                       /* tod_clock */
263268   {
264269      { DEVCB_NULL, DEVCB_NULL, },                        /* port A */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team