Previous 15994 Revisions Next

r6274 Tuesday 3rd November, 2009 at 22:22:47 UTC by Harmony
[APPLE2] Fixed Bugzilla #1866, "Running with -debug switch causes disk corruption". [Harmony]
Dev's Analysis: space->debugger_access is real, and beautiful. Love it and use it.
[src/mess/machine]apple2.c

src/mess/machine/apple2.c
r6273r6274
305305
306306READ8_HANDLER(apple2_c0xx_r)
307307{
308   static const read8_space_func handlers[] =
308   if(!space->debugger_access)
309309   {
310      apple2_c00x_r,
311      apple2_c01x_r,
312      apple2_c02x_r,
313      apple2_c03x_r,
314      NULL,
315      apple2_c05x_r,
316      apple2_c06x_r,
317      apple2_c07x_r
318   };
319   UINT8 result = 0x00;
320   int slotnum;
321   const device_config *slotdevice;
310      static const read8_space_func handlers[] =
311      {
312         apple2_c00x_r,
313         apple2_c01x_r,
314         apple2_c02x_r,
315         apple2_c03x_r,
316         NULL,
317         apple2_c05x_r,
318         apple2_c06x_r,
319         apple2_c07x_r
320      };
321      UINT8 result = 0x00;
322      int slotnum;
323      const device_config *slotdevice;
322324
323   offset &= 0xFF;
325      offset &= 0xFF;
324326
325   if (offset < 0x80)
326   {
327      /* normal handler */
328      if (handlers[offset / 0x10])
329         result = handlers[offset / 0x10](space, offset % 0x10);
330   }
331   else
332   {
333      /* slot handler; identify the slot number */
334      slotnum = (offset - 0x80) / 0x10;
327      if (offset < 0x80)
328      {
329         /* normal handler */
330         if (handlers[offset / 0x10])
331            result = handlers[offset / 0x10](space, offset % 0x10);
332      }
333      else
334      {
335         /* slot handler; identify the slot number */
336         slotnum = (offset - 0x80) / 0x10;
335337
336      /* now identify the device */
337      slotdevice = apple2_slot(space->machine, slotnum);
338         /* now identify the device */
339         slotdevice = apple2_slot(space->machine, slotnum);
338340
339      /* and if we can, read from the slot */
340      if (slotdevice != NULL)
341         result = apple2_slot_r(slotdevice, offset % 0x10);
341         /* and if we can, read from the slot */
342         if (slotdevice != NULL)
343            result = apple2_slot_r(slotdevice, offset % 0x10);
344      }
345      return result;
342346   }
343   return result;
347
348   return 0;
344349}
345350
346351
r6273r6274
835840
836841READ8_HANDLER ( apple2_c00x_r )
837842{
838   UINT8 result;
843   UINT8 result = 0;
839844
840   /* Read the keyboard data and strobe */
841   profiler_mark_start(PROFILER_C00X);
842   result = AY3600_keydata_strobe_r();
843   profiler_mark_end();
845   if(!space->debugger_access)
846   {
847      /* Read the keyboard data and strobe */
848      profiler_mark_start(PROFILER_C00X);
849      result = AY3600_keydata_strobe_r();
850      profiler_mark_end();
851   }
844852
845853   return result;
846854}
r6273r6274
885893{
886894   UINT8 result = apple2_getfloatingbusvalue(space->machine) & 0x7F;
887895
888   profiler_mark_start(PROFILER_C01X);
896   if(!space->debugger_access)
897   {
898      profiler_mark_start(PROFILER_C01X);
889899
890   LOG(("a2 softswitch_r: %04x\n", offset + 0xc010));
891   switch (offset)
892   {
893      case 0x00:         result |= AY3600_anykey_clearstrobe_r();      break;
894      case 0x01:         result |= (a2 & VAR_LCRAM2)      ? 0x80 : 0x00;   break;
895      case 0x02:         result |= (a2 & VAR_LCRAM)      ? 0x80 : 0x00;   break;
896      case 0x03:         result |= (a2 & VAR_RAMRD)      ? 0x80 : 0x00;   break;
897      case 0x04:         result |= (a2 & VAR_RAMWRT)      ? 0x80 : 0x00;   break;
898      case 0x05:         result |= (a2 & VAR_INTCXROM)   ? 0x80 : 0x00;   break;
899      case 0x06:         result |= (a2 & VAR_ALTZP)      ? 0x80 : 0x00;   break;
900      case 0x07:         result |= (a2 & VAR_SLOTC3ROM)   ? 0x80 : 0x00;   break;
901      case 0x08:         result |= (a2 & VAR_80STORE)   ? 0x80 : 0x00;   break;
902      case 0x09:         result |= !video_screen_get_vblank(space->machine->primary_screen)      ? 0x80 : 0x00;   break;
903      case 0x0A:         result |= (a2 & VAR_TEXT)      ? 0x80 : 0x00;   break;
904      case 0x0B:         result |= (a2 & VAR_MIXED)      ? 0x80 : 0x00;   break;
905      case 0x0C:         result |= (a2 & VAR_PAGE2)      ? 0x80 : 0x00;   break;
906      case 0x0D:         result |= (a2 & VAR_HIRES)      ? 0x80 : 0x00;   break;
907      case 0x0E:         result |= (a2 & VAR_ALTCHARSET)   ? 0x80 : 0x00;   break;
908      case 0x0F:         result |= (a2 & VAR_80COL)      ? 0x80 : 0x00;   break;
900      LOG(("a2 softswitch_r: %04x\n", offset + 0xc010));
901      switch (offset)
902      {
903         case 0x00:         result |= AY3600_anykey_clearstrobe_r();      break;
904         case 0x01:         result |= (a2 & VAR_LCRAM2)      ? 0x80 : 0x00;   break;
905         case 0x02:         result |= (a2 & VAR_LCRAM)      ? 0x80 : 0x00;   break;
906         case 0x03:         result |= (a2 & VAR_RAMRD)      ? 0x80 : 0x00;   break;
907         case 0x04:         result |= (a2 & VAR_RAMWRT)      ? 0x80 : 0x00;   break;
908         case 0x05:         result |= (a2 & VAR_INTCXROM)   ? 0x80 : 0x00;   break;
909         case 0x06:         result |= (a2 & VAR_ALTZP)      ? 0x80 : 0x00;   break;
910         case 0x07:         result |= (a2 & VAR_SLOTC3ROM)   ? 0x80 : 0x00;   break;
911         case 0x08:         result |= (a2 & VAR_80STORE)   ? 0x80 : 0x00;   break;
912         case 0x09:         result |= !video_screen_get_vblank(space->machine->primary_screen)      ? 0x80 : 0x00;   break;
913         case 0x0A:         result |= (a2 & VAR_TEXT)      ? 0x80 : 0x00;   break;
914         case 0x0B:         result |= (a2 & VAR_MIXED)      ? 0x80 : 0x00;   break;
915         case 0x0C:         result |= (a2 & VAR_PAGE2)      ? 0x80 : 0x00;   break;
916         case 0x0D:         result |= (a2 & VAR_HIRES)      ? 0x80 : 0x00;   break;
917         case 0x0E:         result |= (a2 & VAR_ALTCHARSET)   ? 0x80 : 0x00;   break;
918         case 0x0F:         result |= (a2 & VAR_80COL)      ? 0x80 : 0x00;   break;
919      }
920
921      profiler_mark_end();
909922   }
910923
911   profiler_mark_end();
912924   return result;
913925}
914926
r6273r6274
934946
935947READ8_HANDLER( apple2_c02x_r )
936948{
937   apple2_c02x_w(space, offset, 0);
949   if(!space->debugger_access)
950   {
951      apple2_c02x_w(space, offset, 0);
952   }
938953   return apple2_getfloatingbusvalue(space->machine);
939954}
940955
r6273r6274
962977
963978READ8_HANDLER ( apple2_c03x_r )
964979{
965   if (!offset)
980   if(!space->debugger_access)
966981   {
967      const device_config *speaker_device = devtag_get_device(space->machine, "a2speaker");
982      if (!offset)
983      {
984         const device_config *speaker_device = devtag_get_device(space->machine, "a2speaker");
968985
969      if (a2_speaker_state == 1)
970         a2_speaker_state = 0;
971      else
972         a2_speaker_state = 1;
973      speaker_level_w(speaker_device, a2_speaker_state);
986         if (a2_speaker_state == 1)
987         {
988            a2_speaker_state = 0;
989         }
990         else
991         {
992            a2_speaker_state = 1;
993         }
994         speaker_level_w(speaker_device, a2_speaker_state);
995      }
974996   }
975997   return apple2_getfloatingbusvalue(space->machine);
976998}
r6273r6274
9941016
9951017READ8_HANDLER ( apple2_c05x_r )
9961018{
997   UINT32 mask;
1019   if(!space->debugger_access)
1020   {
1021      UINT32 mask;
9981022
999   /* ANx has reverse SET logic */
1000   if (offset >= 8)
1001      offset ^= 1;
1023      /* ANx has reverse SET logic */
1024      if (offset >= 8)
1025      {
1026         offset ^= 1;
1027      }
10021028
1003   mask = 0x100 << (offset / 2);
1004   apple2_setvar(space->machine, (offset & 1) ? mask : 0, mask);
1029      mask = 0x100 << (offset / 2);
1030      apple2_setvar(space->machine, (offset & 1) ? mask : 0, mask);
1031   }
10051032   return apple2_getfloatingbusvalue(space->machine);
10061033}
10071034
r6273r6274
10251052READ8_HANDLER ( apple2_c06x_r )
10261053{
10271054   int result = 0;
1028   switch (offset & 0x0F)
1055   if(!space->debugger_access)
10291056   {
1030      case 0x01:
1031         /* Open-Apple/Joystick button 0 */
1032         result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON0);
1033         break;
1034      case 0x02:
1035         /* Closed-Apple/Joystick button 1 */
1036         result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON1);
1037         break;
1038      case 0x03:
1039         /* Joystick button 2. Later revision motherboards connected this to SHIFT also */
1040         result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON2);
1041         break;
1042      case 0x04:
1043         /* X Joystick 1 axis */
1044         result = attotime_to_double(timer_get_time(space->machine)) < joystick_x1_time;
1045         break;
1046      case 0x05:
1047         /* Y Joystick 1 axis */
1048         result = attotime_to_double(timer_get_time(space->machine)) < joystick_y1_time;
1049         break;
1050      case 0x06:
1051         /* X Joystick 2 axis */
1052         result = attotime_to_double(timer_get_time(space->machine)) < joystick_x2_time;
1053         break;
1054      case 0x07:
1055         /* Y Joystick 2 axis */
1056         result = attotime_to_double(timer_get_time(space->machine)) < joystick_y2_time;
1057         break;
1058      default:
1059         /* c060 Empty Cassette head read
1060             * and any other non joystick c06 port returns this according to applewin
1061             */
1062         return apple2_getfloatingbusvalue(space->machine);
1057      switch (offset & 0x0F)
1058      {
1059         case 0x01:
1060            /* Open-Apple/Joystick button 0 */
1061            result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON0);
1062            break;
1063         case 0x02:
1064            /* Closed-Apple/Joystick button 1 */
1065            result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON1);
1066            break;
1067         case 0x03:
1068            /* Joystick button 2. Later revision motherboards connected this to SHIFT also */
1069            result = apple2_pressed_specialkey(space->machine, SPECIALKEY_BUTTON2);
1070            break;
1071         case 0x04:
1072            /* X Joystick 1 axis */
1073            result = attotime_to_double(timer_get_time(space->machine)) < joystick_x1_time;
1074            break;
1075         case 0x05:
1076            /* Y Joystick 1 axis */
1077            result = attotime_to_double(timer_get_time(space->machine)) < joystick_y1_time;
1078            break;
1079         case 0x06:
1080            /* X Joystick 2 axis */
1081            result = attotime_to_double(timer_get_time(space->machine)) < joystick_x2_time;
1082            break;
1083         case 0x07:
1084            /* Y Joystick 2 axis */
1085            result = attotime_to_double(timer_get_time(space->machine)) < joystick_y2_time;
1086            break;
1087         default:
1088            /* c060 Empty Cassette head read
1089                * and any other non joystick c06 port returns this according to applewin
1090                */
1091            return apple2_getfloatingbusvalue(space->machine);
1092      }
10631093   }
10641094   return result ? 0x80 : 0x00;
10651095}
r6273r6274
10721102
10731103READ8_HANDLER ( apple2_c07x_r )
10741104{
1075   double x_calibration = attotime_to_double(ATTOTIME_IN_USEC(12));
1076   double y_calibration = attotime_to_double(ATTOTIME_IN_USEC(13));
1105   if(!space->debugger_access)
1106   {
1107      double x_calibration = attotime_to_double(ATTOTIME_IN_USEC(12));
1108      double y_calibration = attotime_to_double(ATTOTIME_IN_USEC(13));
10771109
1078   if (offset == 0)
1079   {
1080      joystick_x1_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_1_x");
1081      joystick_y1_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_1_y");
1082      joystick_x2_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_2_x");
1083      joystick_y2_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_2_y");
1110      if (offset == 0)
1111      {
1112         joystick_x1_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_1_x");
1113         joystick_y1_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_1_y");
1114         joystick_x2_time = attotime_to_double(timer_get_time(space->machine)) + x_calibration * input_port_read(space->machine, "joystick_2_x");
1115         joystick_y2_time = attotime_to_double(timer_get_time(space->machine)) + y_calibration * input_port_read(space->machine, "joystick_2_y");
1116      }
10841117   }
10851118   return 0;
10861119}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team