Previous 15994 Revisions Next

r7841 Saturday 17th April, 2010 at 17:59:18 UTC by R. Belmont
[APPLE2] Give expansion cards more of their actual capabilities.
[src/mess/machine]ap2_slot.c ap2_slot.h apple2.c

src/mess/machine/ap2_slot.c
r7840r7841
131131   }
132132}
133133
134/*-------------------------------------------------
135    apple2_c800_slot_r - slot read function
136-------------------------------------------------*/
134137
138READ8_DEVICE_HANDLER(apple2_c800_slot_r)
139{
140   UINT8 result = 0x00;
141   const apple2_slot_config *config = get_config(device);
142   apple2_slot_token *token = get_token(device);
135143
144   /* do we actually have a device, and can we read? */
145   if ((token->slot_device != NULL) && (config->rhc800 != NULL))
146   {
147      result = (*config->rhc800)(token->slot_device, offset);
148   }
149
150   return result;
151}
152
136153/*-------------------------------------------------
154    apple2_c800_slot_w - slot write function
155-------------------------------------------------*/
156
157WRITE8_DEVICE_HANDLER(apple2_c800_slot_w)
158{
159   const apple2_slot_config *config = get_config(device);
160   apple2_slot_token *token = get_token(device);
161
162   /* do we actually have a device, and can we read? */
163   if ((token->slot_device != NULL) && (config->whc800 != NULL))
164   {
165      (*config->whc800)(token->slot_device, offset, data);
166   }
167}
168
169/*-------------------------------------------------
170    apple2_slot_ROM_w - slot write function
171-------------------------------------------------*/
172
173WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w)
174{
175   const apple2_slot_config *config = get_config(device);
176   apple2_slot_token *token = get_token(device);
177
178   /* do we actually have a device, and can we read? */
179   if ((token->slot_device != NULL) && (config->whcnxx != NULL))
180   {
181      (*config->whcnxx)(token->slot_device, offset, data);
182   }
183}
184
185/*-------------------------------------------------
137186    DEVICE_GET_INFO(apple2_slot) - device get info
138187    function
139188-------------------------------------------------*/
src/mess/machine/ap2_slot.h
r7840r7841
3030   const char *tag;
3131   read8_device_func rh;
3232   write8_device_func wh;
33   read8_device_func rhc800;
34   write8_device_func whc800;
35   write8_device_func whcnxx;
3336};
3437
3538
r7840r7841
3841    DEVICE CONFIGURATION MACROS
3942***************************************************************************/
4043
41#define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh)      \
44#define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh, _rhc800, _whc800, _whcnxx)      \
4245   MDRV_DEVICE_ADD("slot_" #_slot_number, APPLE2_SLOT, 0)         \
4346   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, tag, _slot_device_tag)   \
4447   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rh, _rh)      \
4548   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, wh, _wh)      \
49   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rhc800, _rhc800)      \
50   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whc800, _whc800)      \
51   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whcnxx, _whcnxx)      \
4652
4753
4854
r7840r7841
5965/* slot write function */
6066WRITE8_DEVICE_HANDLER(apple2_slot_w);
6167
68/* slot ROM write function */
69WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w);
70
71/* slot extended ROM read function */
72READ8_DEVICE_HANDLER(apple2_c800_slot_r);
73
74/* slot extended ROM write function */
75WRITE8_DEVICE_HANDLER(apple2_c800_slot_w);
76
6277/* slot device lookup */
6378running_device *apple2_slot(running_machine *machine, int slotnum);
6479
src/mess/machine/apple2.c
r7840r7841
4444static UINT32 a2_mask;
4545static UINT32 a2_set;
4646
47static INT32 a2_cnxx_slot;
4748
4849/* local */
4950static int a2_speaker_state;
r7840r7841
7374static WRITE8_HANDLER ( apple2_c05x_w );
7475static WRITE8_HANDLER ( apple2_c07x_w );
7576
77static READ8_HANDLER ( apple2_c1xx_r );
78static WRITE8_HANDLER ( apple2_c1xx_w );
79static READ8_HANDLER ( apple2_c4xx_r );
80static WRITE8_HANDLER ( apple2_c4xx_w );
7681
82static READ8_HANDLER ( apple2_c800_r );
83static WRITE8_HANDLER ( apple2_c800_w );
84static READ8_HANDLER ( apple2_ce00_r );
85static WRITE8_HANDLER ( apple2_ce00_w );
7786
7887/* -----------------------------------------------------------------------
7988 * New Apple II memory manager
r7840r7841
173182         }
174183         else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_SLOT)
175184         {
176            /* slot RAM */
177            if (slot_ram)
178               rbase = &slot_ram[meminfo.read_mem & APPLE2_MEM_MASK];
179            else
180               rh = read_floatingbus;
185            // slots 1-2
186            if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0)
187            {
188               rh = apple2_c1xx_r;
189            }
190            else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300)
191            {   // slots 4-7
192               rh = apple2_c4xx_r;
193            }
181194         }
182195         else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_ROM)
183196         {
r7840r7841
251264         }
252265         else if ((meminfo.write_mem & 0xC0000000) == APPLE2_MEM_SLOT)
253266         {
254            /* slot RAM */
255            if (slot_ram)
256               wbase = &slot_ram[meminfo.write_mem & APPLE2_MEM_MASK];
257            else
258               wh_nop = 1;
267            /* slot RAM/ROM */
268
269            // slots 1-2
270            if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0)
271            {
272               wh = apple2_c1xx_w;
273            }
274            else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300)
275            {   // slots 4-7
276               wh = apple2_c4xx_w;
277            }
259278         }
260279         else if ((meminfo.write_mem & 0xC0000000) == APPLE2_MEM_ROM)
261280         {
r7840r7841
340359
341360      if (offset < 0x80)
342361      {
362         if (a2_cnxx_slot != -1)
363         {
364            a2_cnxx_slot = -1;
365            apple2_update_memory(space->machine);
366         }
367
343368         /* normal handler */
344369         if (handlers[offset / 0x10])
345370            result = handlers[offset / 0x10](space, offset % 0x10);
r7840r7841
384409
385410   if (offset < 0x80)
386411   {
412      if (a2_cnxx_slot != -1)
413      {
414         a2_cnxx_slot = -1;
415         apple2_update_memory(space->machine);
416      }
417
387418      /* normal handler */
388419      if (handlers[offset / 0x10])
389420         handlers[offset / 0x10](space, offset % 0x10, data);
r7840r7841
402433   }
403434}
404435
436static READ8_HANDLER( apple2_c1xx_r )
437{
438   int slotnum;
439   UINT8 *rom, *slot_ram;
440   UINT32 rom_length, slot_length;
405441
442   // find slot_ram if any
443   rom = memory_region(space->machine, "maincpu");
444   rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF;
445   slot_length = memory_region_length(space->machine, "maincpu") - rom_length;
446   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
406447
448   if (slot_ram)
449   {
450      slotnum = ((offset>>8) & 0xf) + 1;
451      if (a2_cnxx_slot != slotnum)
452      {
453         a2_cnxx_slot = slotnum;
454         apple2_update_memory(space->machine);
455      }
456
457      return slot_ram[offset];
458   }
459   // else fall through to floating bus
460
461   return apple2_getfloatingbusvalue(space->machine);
462}
463
464static WRITE8_HANDLER ( apple2_c1xx_w )
465{
466   int slotnum;
467   running_device *slotdevice;
468   UINT8 *rom, *slot_ram;
469   UINT32 rom_length, slot_length;
470
471   // find slot_ram if any
472   rom = memory_region(space->machine, "maincpu");
473   rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF;
474   slot_length = memory_region_length(space->machine, "maincpu") - rom_length;
475   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
476
477   slotnum = ((offset>>8) & 0xf) + 1;
478
479   slotdevice = apple2_slot(space->machine, slotnum);
480
481   if (slotdevice != NULL)
482   {
483      apple2_slot_ROM_w(slotdevice, offset&0xff, data);
484   }
485   else
486   {
487      if (slot_ram)
488         slot_ram[offset] = data;
489   }
490}
491
492static READ8_HANDLER( apple2_c4xx_r )
493{
494   int slotnum;
495   UINT8 *rom, *slot_ram;
496   UINT32 rom_length, slot_length;
497
498   // find slot_ram if any
499   rom = memory_region(space->machine, "maincpu");
500   rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF;
501   slot_length = memory_region_length(space->machine, "maincpu") - rom_length;
502   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
503
504   if (slot_ram)
505   {
506      slotnum = ((offset>>8) & 0xf) + 4;
507      if (a2_cnxx_slot != slotnum)
508      {
509         a2_cnxx_slot = slotnum;
510         apple2_update_memory(space->machine);
511      }
512
513      return slot_ram[offset+0x300];
514   }
515   // else fall through to floating bus
516
517   return apple2_getfloatingbusvalue(space->machine);
518}
519
520static WRITE8_HANDLER ( apple2_c4xx_w )
521{
522   int slotnum;
523   running_device *slotdevice;
524   UINT8 *rom, *slot_ram;
525   UINT32 rom_length, slot_length;
526
527   // find slot_ram if any
528   rom = memory_region(space->machine, "maincpu");
529   rom_length = memory_region_length(space->machine, "maincpu") & ~0xFFF;
530   slot_length = memory_region_length(space->machine, "maincpu") - rom_length;
531   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
532
533   slotnum = ((offset>>8) & 0xf) + 4;
534
535   slotdevice = apple2_slot(space->machine, slotnum);
536
537   if (slotdevice != NULL)
538   {
539      apple2_slot_ROM_w(slotdevice, offset&0xff, data);
540   }
541   else
542   {
543      if (slot_ram)
544         slot_ram[offset] = data;
545   }
546}
547
548static READ8_HANDLER(apple2_cfff_r)
549{
550   // debugger guard
551   if(!space->debugger_access)
552   {
553      a2_cnxx_slot = -1;
554      apple2_update_memory(space->machine);
555   }
556
557   return apple2_getfloatingbusvalue(space->machine);
558}
559
560static WRITE8_HANDLER(apple2_cfff_w)
561{
562   a2_cnxx_slot = -1;
563   apple2_update_memory(space->machine);
564}
565
566static READ8_HANDLER ( apple2_c800_r )
567{
568   running_device *slotdevice;
569
570   slotdevice = apple2_slot(space->machine, a2_cnxx_slot);
571
572   if (slotdevice != NULL)
573   {
574      return apple2_c800_slot_r(slotdevice, offset&0xfff);
575   }
576
577   return apple2_getfloatingbusvalue(space->machine);
578}
579
580static WRITE8_HANDLER ( apple2_c800_w )
581{
582   running_device *slotdevice;
583
584   slotdevice = apple2_slot(space->machine, a2_cnxx_slot);
585
586   if (slotdevice != NULL)
587   {
588      apple2_c800_slot_w(slotdevice, offset&0xfff, data);
589   }
590}
591
592static READ8_HANDLER ( apple2_ce00_r )
593{
594   running_device *slotdevice;
595
596   slotdevice = apple2_slot(space->machine, a2_cnxx_slot);
597
598   if (slotdevice != NULL)
599   {
600      return apple2_c800_slot_r(slotdevice, (offset&0xfff) + 0x600);
601   }
602
603   return apple2_getfloatingbusvalue(space->machine);
604}
605
606static WRITE8_HANDLER ( apple2_ce00_w )
607{
608      running_device *slotdevice;
609
610   slotdevice = apple2_slot(space->machine, a2_cnxx_slot);
611
612   if (slotdevice != NULL)
613   {
614      apple2_c800_slot_w(slotdevice, (offset&0xfff)+0x600, data);
615   }
616}
617
407618static void apple2_mem_0000(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo)
408619{
409620   meminfo->read_mem         = (apple2_flags & VAR_ALTZP)   ? 0x010000 : 0x000000;
r7840r7841
466677   meminfo->write_handler = apple2_c0xx_w;
467678}
468679
680static void apple2_mem_CFFF(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo)
681{
682   meminfo->read_handler = apple2_cfff_r;
683   meminfo->write_handler = apple2_cfff_w;
684}
685
469686static void apple2_mem_Cx00(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo)
470687{
471688   if (apple2_flags & VAR_INTCXROM)
r7840r7841
496713
497714static void apple2_mem_C800(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo)
498715{
499   meminfo->read_mem         = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM;
500   meminfo->write_mem         = APPLE2_MEM_FLOATING;
716   if (a2_cnxx_slot == -1)
717   {
718      meminfo->read_mem         = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM;
719      meminfo->write_mem         = APPLE2_MEM_FLOATING;
720   }
721   else
722   {
723      meminfo->read_handler = apple2_c800_r;
724      meminfo->write_handler = apple2_c800_w;
725   }
501726}
502727
503728static void apple2_mem_CE00(running_machine *machine, offs_t begin, offs_t end, apple2_meminfo *meminfo)
r7840r7841
509734   }
510735   else
511736   {
512      meminfo->read_mem      = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM;
513      meminfo->write_mem      = APPLE2_MEM_FLOATING;
737      if (a2_cnxx_slot == -1)
738      {
739         meminfo->read_mem      = (begin & 0x0FFF) | (apple2_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM;
740         meminfo->write_mem      = APPLE2_MEM_FLOATING;
741      }
742      else
743      {
744         meminfo->read_handler = apple2_ce00_r;
745         meminfo->write_handler = apple2_ce00_w;
746      }
514747   }
515748}
516749
r7840r7841
579812   { 0xC300, 0xC3FF, apple2_mem_C300, A2MEM_MONO },
580813   { 0xC400, 0xC7FF, apple2_mem_Cx00, A2MEM_MONO },
581814   { 0xC800, 0xCDFF, apple2_mem_C800, A2MEM_MONO },
582   { 0xCE00, 0xCFFF, apple2_mem_CE00, A2MEM_MONO },
815   { 0xCE00, 0xCFFE, apple2_mem_CE00, A2MEM_MONO },
816   { 0xCFFF, 0xCFFF, apple2_mem_CFFF, A2MEM_IO },
583817   { 0xD000, 0xDFFF, apple2_mem_D000, A2MEM_DUAL },
584818   { 0xE000, 0xFFFF, apple2_mem_E000, A2MEM_DUAL },
585819   { 0 }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team