Previous 15994 Revisions Next

r14878 Monday 9th April, 2012 at 00:53:42 UTC by R. Belmont
Apple II: Even more slot ROM arbitration work. 80 column mode works on IIe again, and AppleWorks 3 no longer crashes on boot. [R. Belmont]
[src/mess/machine]apple2.c

src/mess/machine/apple2.c
r14877r14878
6666
6767static READ8_HANDLER ( apple2_c1xx_r );
6868static WRITE8_HANDLER ( apple2_c1xx_w );
69static READ8_HANDLER ( apple2_c3xx_r );
70static WRITE8_HANDLER ( apple2_c3xx_w );
6971static READ8_HANDLER ( apple2_c4xx_r );
7072static WRITE8_HANDLER ( apple2_c4xx_w );
7173
r14877r14878
108110   read8_space_func rh; const char *rh_name = NULL;
109111   write8_space_func wh; const char *wh_name = NULL;
110112   offs_t begin, end_r, end_w;
111   UINT8 *rbase, *wbase, *rom; //, *slot_ram;
112   UINT32 rom_length, offset; //, slot_length;
113   UINT8 *rbase, *wbase, *rom;
114   UINT32 rom_length, offset;
113115   bank_disposition_t bank_disposition;
114116   int wh_nop = 0;
115117
r14877r14878
125127   /* get critical info */
126128   rom = machine.region("maincpu")->base();
127129   rom_length = machine.region("maincpu")->bytes() & ~0xFFF;
128//  slot_length = machine.region("maincpu")->bytes() - rom_length;
129//  slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
130130
131131   /* loop through the entire memory map */
132132   bank = state->m_mem_config.first_bank;
r14877r14878
180180               rh = apple2_c1xx_r;
181181               rh_name = "apple2_c1xx_r";
182182            }
183            else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x200)
184            {   // slot 3
185               rh = apple2_c3xx_r;
186               rh_name = "apple2_c3xx_r";
187            }
183188            else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300)
184189            {   // slots 4-7
185190               rh = apple2_c4xx_r;
186191               rh_name = "apple2_c4xx_r";
187192            }
193                else
194                {
195                    printf("ERROR: Unhandled case for APPLE2_MEM_SLOT write_mem = %x!\n", (meminfo.write_mem & APPLE2_MEM_MASK));
196                }
188197         }
189198         else if ((meminfo.read_mem & 0xC0000000) == APPLE2_MEM_ROM)
190199         {
r14877r14878
267276               wh = apple2_c1xx_w;
268277               wh_name = "apple2_c1xx_w";
269278            }
279            else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x200)
280            {   // slot 3
281               wh = apple2_c3xx_w;
282               wh_name = "apple2_c3xx_w";
283            }
270284            else if ((meminfo.write_mem & APPLE2_MEM_MASK) == 0x300)
271285            {   // slots 4-7
272286               wh = apple2_c4xx_w;
r14877r14878
435449
436450   if (slot_ram)
437451   {
438      if (1) //state->m_a2_cnxx_slot == -1)
439      {
440//            printf("slotram_r: cnxx_slot now %d\n", slotnum);
441         state->m_a2_cnxx_slot = slotnum;
442         apple2_update_memory(machine);
443      }
452        state->m_a2_cnxx_slot = -1;
453      apple2_update_memory(machine);
444454
445455      return slot_ram[offset];
446456   }
r14877r14878
458468   slotnum = ((offset>>8) & 0xf) + 1;
459469    slotdevice = state->m_a2bus->get_a2bus_card(slotnum);
460470                                 
461   if (1) //state->m_a2_cnxx_slot == -1)
462   {
463//        printf("c1xx_r: cnxx_slot now %d\n", slotnum);
464      state->m_a2_cnxx_slot = slotnum;
465      apple2_update_memory(space->machine());
466   }
471    state->m_a2_cnxx_slot = slotnum;
472    apple2_update_memory(space->machine());
467473
468474   if (slotdevice != NULL)
469475   {
r14877r14878
507513   }
508514}
509515
510static READ8_HANDLER( apple2_c4xx_r )
516static READ8_HANDLER( apple2_c3xx_r )
511517{
512518   apple2_state *state = space->machine().driver_data<apple2_state>();
513519   int slotnum;
514520   device_a2bus_card_interface *slotdevice;
515521
516   slotnum = ((offset>>8) & 0xf) + 4;
522   slotnum = 3;
517523    slotdevice = state->m_a2bus->get_a2bus_card(slotnum);
518524
519   if (1) //state->m_a2_cnxx_slot == -1)
525    state->m_a2_cnxx_slot = slotnum;
526    apple2_update_memory(space->machine());
527
528   // is a card installed in this slot?
529   if (slotdevice != NULL)
520530   {
521      state->m_a2_cnxx_slot = slotnum;
522//        printf("c4xx_r: cnxx_slot now %d\n", slotnum);
523      apple2_update_memory(space->machine());
531      return slotdevice->read_cnxx(*space, offset&0xff);
524532   }
533   else
534   {
535      return apple2_slotram_r(space->machine(), slotnum, offset);
536   }
525537
538   // else fall through to floating bus
539   return apple2_getfloatingbusvalue(space->machine());
540}
541
542static WRITE8_HANDLER ( apple2_c3xx_w )
543{
544   apple2_state *state = space->machine().driver_data<apple2_state>();
545   int slotnum;
546   device_a2bus_card_interface *slotdevice;
547   UINT8 *rom, *slot_ram;
548   UINT32 rom_length, slot_length;
549
550   // find slot_ram if any
551   rom = space->machine().region("maincpu")->base();
552   rom_length = space->machine().region("maincpu")->bytes() & ~0xFFF;
553   slot_length = space->machine().region("maincpu")->bytes() - rom_length;
554   slot_ram = (slot_length > 0) ? &rom[rom_length] : NULL;
555
556   slotnum = 3;
557    slotdevice = state->m_a2bus->get_a2bus_card(slotnum);
558
559    state->m_a2_cnxx_slot = slotnum;
560    apple2_update_memory(space->machine());
561
562   if (slotdevice != NULL)
563   {
564      slotdevice->write_cnxx(*space, offset&0xff, data);
565   }
566   else
567   {
568      if (slot_ram)
569         slot_ram[offset] = data;
570   }
571}
572
573static READ8_HANDLER( apple2_c4xx_r )
574{
575   apple2_state *state = space->machine().driver_data<apple2_state>();
576   int slotnum;
577   device_a2bus_card_interface *slotdevice;
578
579   slotnum = ((offset>>8) & 0xf) + 4;
580    slotdevice = state->m_a2bus->get_a2bus_card(slotnum);
581
582    state->m_a2_cnxx_slot = slotnum;
583    apple2_update_memory(space->machine());
584
526585   // is a card installed in this slot?
527586   if (slotdevice != NULL)
528587   {
r14877r14878
554613   slotnum = ((offset>>8) & 0xf) + 4;
555614    slotdevice = state->m_a2bus->get_a2bus_card(slotnum);
556615
557   if (1) //state->m_a2_cnxx_slot == -1)
558   {
559//        printf("c4xx_w: cnxx_slot now %d\n", slotnum);
560      state->m_a2_cnxx_slot = slotnum;
561      apple2_update_memory(space->machine());
562   }
616    state->m_a2_cnxx_slot = slotnum;
617    apple2_update_memory(space->machine());
563618
564619   if (slotdevice != NULL)
565620   {
r14877r14878
578633   if (!space->debugger_access())
579634   {
580635        apple2_state *state = space->machine().driver_data<apple2_state>();
581//        printf("cfff_r: cnxx_slot now %d\n", -1);
582636      state->m_a2_cnxx_slot = -1;
583637      apple2_update_memory(space->machine());
584638   }
r14877r14878
591645   if (!space->debugger_access())
592646   {
593647        apple2_state *state = space->machine().driver_data<apple2_state>();
594//        printf("cfff_w: cnxx_slot now %d\n", -1);
595648        state->m_a2_cnxx_slot = -1;
596649        apple2_update_memory(space->machine());
597650    }
r14877r14878
760813static void apple2_mem_C800(running_machine &machine, offs_t begin, offs_t end, apple2_meminfo *meminfo)
761814{
762815   apple2_state *state = machine.driver_data<apple2_state>();
763   if (state->m_flags & VAR_INTCXROM)
816    if ((state->m_flags & VAR_INTCXROM) || (state->m_a2_cnxx_slot == -1))
764817   {
765818      meminfo->read_mem         = (begin & 0x0FFF) | (state->m_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM;
766819      meminfo->write_mem         = APPLE2_MEM_FLOATING;
r14877r14878
782835   }
783836   else
784837   {
785      if (state->m_flags & VAR_INTCXROM)
838      if ((state->m_flags & VAR_INTCXROM) || (state->m_a2_cnxx_slot == -1))
786839      {
787840         meminfo->read_mem      = (begin & 0x0FFF) | (state->m_flags & VAR_ROMSWITCH ? 0x4000 : 0x0000) | APPLE2_MEM_ROM;
788841         meminfo->write_mem      = APPLE2_MEM_FLOATING;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team