Previous 15994 Revisions Next

r8050 Saturday 15th May, 2010 at 16:42:06 UTC by R. Belmont
[APPLE2] Expansion slots now have control over all the same resources they do in the real machine, including C800 banking.
[src/mess/drivers]apple2.c
[src/mess/machine]ap2_slot.c ap2_slot.h apple2.c

src/mess/machine/ap2_slot.c
r8049r8050
77*********************************************************************/
88
99#include "ap2_slot.h"
10#include "includes/apple2.h"
1011
11
1212/***************************************************************************
1313    TYPE DEFINITIONS
1414***************************************************************************/
r8049r8050
167167}
168168
169169/*-------------------------------------------------
170    apple2_slot_ROM_w - slot write function
170    apple2_slot_ROM_w - slot ROM read function
171171-------------------------------------------------*/
172READ8_DEVICE_HANDLER(apple2_slot_ROM_r)
173{
174   const apple2_slot_config *config = get_config(device);
175   apple2_slot_token *token = get_token(device);
172176
177   /* do we actually have a device, and can we read? */
178   if ((token->slot_device != NULL) && (config->rhcnxx != NULL))
179   {
180      return (*config->rhcnxx)(token->slot_device, offset);
181   }
182
183   if (config->slotnum > 0)
184   {
185      return apple2_slotram_r(device->machine, config->slotnum, offset + ((config->slotnum-1)<<8));
186   }
187
188   return apple2_getfloatingbusvalue(device->machine);
189}
190
191/*-------------------------------------------------
192    apple2_slot_ROM_w - slot ROM write function
193-------------------------------------------------*/
194
173195WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w)
174196{
175197   const apple2_slot_config *config = get_config(device);
176198   apple2_slot_token *token = get_token(device);
177199
178   /* do we actually have a device, and can we read? */
200   /* do we actually have a device, and can we write? */
179201   if ((token->slot_device != NULL) && (config->whcnxx != NULL))
180202   {
181203      (*config->whcnxx)(token->slot_device, offset, data);
src/mess/machine/ap2_slot.h
r8049r8050
1111
1212#include "emu.h"
1313
14
1514/***************************************************************************
1615    CONSTANTS
1716***************************************************************************/
r8049r8050
2827struct _apple2_slot_config
2928{
3029   const char *tag;
31   read8_device_func rh;
30   int slotnum;         // slot number
31
32   read8_device_func rh;      // C0nX I/O space (DEVSEL)
3233   write8_device_func wh;
33   read8_device_func rhc800;
34
35   read8_device_func rhcnxx;   // CnXX ROM space (IOSEL)
36   write8_device_func whcnxx;
37
38   read8_device_func rhc800;   // C800 ROM extension space (IOSTB)
3439   write8_device_func whc800;
35   write8_device_func whcnxx;
3640};
3741
3842
r8049r8050
4145    DEVICE CONFIGURATION MACROS
4246***************************************************************************/
4347
44#define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh, _rhc800, _whc800, _whcnxx)      \
48#define MDRV_APPLE2_SLOT_ADD(_slot_number, _slot_device_tag, _rh, _wh, _rhc800, _whc800, _rhcnxx, _whcnxx)      \
4549   MDRV_DEVICE_ADD("slot_" #_slot_number, APPLE2_SLOT, 0)         \
4650   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, tag, _slot_device_tag)   \
51   MDRV_DEVICE_CONFIG_DATA32(apple2_slot_config, slotnum, _slot_number)      \
4752   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rh, _rh)      \
4853   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, wh, _wh)      \
4954   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rhc800, _rhc800)      \
5055   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whc800, _whc800)      \
56   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, rhcnxx, _rhcnxx)      \
5157   MDRV_DEVICE_CONFIG_DATAPTR(apple2_slot_config, whcnxx, _whcnxx)      \
5258
5359
r8049r8050
6571/* slot write function */
6672WRITE8_DEVICE_HANDLER(apple2_slot_w);
6773
74/* slot ROM read function */
75READ8_DEVICE_HANDLER(apple2_slot_ROM_r);
76
6877/* slot ROM write function */
6978WRITE8_DEVICE_HANDLER(apple2_slot_ROM_w);
7079
src/mess/machine/apple2.c
r8049r8050
4444static UINT32 a2_mask;
4545static UINT32 a2_set;
4646
47static INT32 a2_cnxx_slot;
47INT32 a2_cnxx_slot;
4848
4949/* local */
5050static int a2_speaker_state;
r8049r8050
433433   }
434434}
435435
436static READ8_HANDLER( apple2_c1xx_r )
436/* returns default CnXX slotram for a slot space */
437INT8 apple2_slotram_r(running_machine *machine, int slotnum, int offset)
437438{
438   int slotnum;
439439   UINT8 *rom, *slot_ram;
440440   UINT32 rom_length, slot_length;
441441
442442   // 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;
443   rom = memory_region(machine, "maincpu");
444   rom_length = memory_region_length(machine, "maincpu") & ~0xFFF;
445   slot_length = memory_region_length(machine, "maincpu") - rom_length;
446446   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
447447
448448   if (slot_ram)
449449   {
450      slotnum = ((offset>>8) & 0xf) + 1;
451      if (a2_cnxx_slot != slotnum)
450      if (a2_cnxx_slot == -1)
452451      {
453452         a2_cnxx_slot = slotnum;
454         apple2_update_memory(space->machine);
453         apple2_update_memory(machine);
455454      }
456455
457456      return slot_ram[offset];
458457   }
458
459459   // else fall through to floating bus
460   return apple2_getfloatingbusvalue(machine);
461}
460462
463static READ8_HANDLER( apple2_c1xx_r )
464{
465   int slotnum;
466   running_device *slotdevice;
467
468   slotnum = ((offset>>8) & 0xf) + 1;
469   slotdevice = apple2_slot(space->machine, slotnum);
470
471   if (a2_cnxx_slot == -1)
472   {
473      a2_cnxx_slot = slotnum;
474      apple2_update_memory(space->machine);
475   }
476
477   if (slotdevice != NULL)
478   {
479      return apple2_slot_ROM_r(slotdevice, offset&0xff);
480   }
481   else
482   {
483      return apple2_slotram_r(space->machine, slotnum, offset);
484   }
485
486   // else fall through to floating bus
461487   return apple2_getfloatingbusvalue(space->machine);
462488}
463489
r8049r8050
492518static READ8_HANDLER( apple2_c4xx_r )
493519{
494520   int slotnum;
495   UINT8 *rom, *slot_ram;
496   UINT32 rom_length, slot_length;
521   running_device *slotdevice;
497522
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;
523   slotnum = ((offset>>8) & 0xf) + 4;
524   slotdevice = apple2_slot(space->machine, slotnum);
503525
504   if (slot_ram)
526   if (a2_cnxx_slot == -1)
505527   {
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      }
528      a2_cnxx_slot = slotnum;
529      apple2_update_memory(space->machine);
530   }
512531
513      return slot_ram[offset+0x300];
532   // is a card installed in this slot?
533   if (slotdevice != NULL)
534   {
535      return apple2_slot_ROM_r(slotdevice, offset&0xff);
514536   }
537   else
538   {
539      return apple2_slotram_r(space->machine, slotnum, offset);
540   }
541
515542   // else fall through to floating bus
516
517543   return apple2_getfloatingbusvalue(space->machine);
518544}
519545
r8049r8050
531557   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
532558
533559   slotnum = ((offset>>8) & 0xf) + 4;
534
535560   slotdevice = apple2_slot(space->machine, slotnum);
536561
562   if (a2_cnxx_slot == -1)
563   {
564      a2_cnxx_slot = slotnum;
565      apple2_update_memory(space->machine);
566   }
567
537568   if (slotdevice != NULL)
538569   {
539570      apple2_slot_ROM_w(slotdevice, offset&0xff, data);
src/mess/drivers/apple2.c
r8049r8050
627627   MDRV_APPLEFDC_ADD("fdc", apple2_fdc_interface)
628628
629629   /* slots */
630   MDRV_APPLE2_SLOT_ADD(0, "langcard", apple2_langcard_r, apple2_langcard_w, 0, 0, 0)
631   MDRV_APPLE2_SLOT_ADD(4, "mockingboard", mockingboard_r, mockingboard_w, 0, 0, 0)
632   MDRV_APPLE2_SLOT_ADD(6, "fdc", applefdc_r, applefdc_w, 0, 0, 0)
630   MDRV_APPLE2_SLOT_ADD(0, "langcard", apple2_langcard_r, apple2_langcard_w, 0, 0, 0, 0)
631   MDRV_APPLE2_SLOT_ADD(4, "mockingboard", mockingboard_r, mockingboard_w, 0, 0, 0, 0)
632   MDRV_APPLE2_SLOT_ADD(6, "fdc", applefdc_r, applefdc_w, 0, 0, 0, 0)
633633
634634   MDRV_FLOPPY_APPLE_2_DRIVES_ADD(apple2_floppy_config,15,16)
635635MACHINE_DRIVER_END
r8049r8050
666666
667667   ROM_REGION(0x8700,"maincpu",0)
668668   ROM_LOAD ( "las3000.rom", 0x0000, 0x8000, CRC(9C7AEB09) SHA1(3302ADF41E258CF50210C19736948C8FA65E91DE))
669   ROM_LOAD ( "l3kdisk.rom", 0x0500, 0x0100, CRC(2D4B1584) SHA1(989780B77E100598124DF7B72663E5A31A3339C0))
669   ROM_LOAD ( "l3kdisk.rom", 0x8500, 0x0100, CRC(2D4B1584) SHA1(989780B77E100598124DF7B72663E5A31A3339C0))
670670ROM_END
671671
672672MACHINE_DRIVER_START( apple2e )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team