Previous 15994 Revisions Next

r7665 Monday 29th March, 2010 at 21:27:53 UTC by Fabio Priuli
[SNES] wip:
- Fixed a bug in SPC7110 handlers (now Tengai Makyou Zero test reaches RTC tests and fails them, instead of getting stuck at MUL/DIV tests)
- Implemented very preliminary (and currently broken) SPC7110 RTC emulation
- Updated DSP2 handlers to better reflect Overload's docs (problem and fix actually found by byuu)
- Updated add-on chips handlers to reflect byuu's findings
[src/mame/machine]snes.c snes7110.c snesdsp2.c snesrtc.c
[src/mess/machine]snescart.c

src/mame/machine/snesdsp2.c
r7664r7665
254254   dsp2_register_save(machine);
255255}
256256
257static UINT8 dsp2_read( void )
257static UINT8 dsp2_dr_read( void )
258258{
259259   UINT8 r = 0xff;
260260   if (dsp2_state.out_count)
r7664r7665
267267   return r;
268268}
269269
270static void dsp2_write(UINT8 data)
270static void dsp2_dr_write(UINT8 data)
271271{
272272   if (dsp2_state.waiting_for_command)
273273   {
r7664r7665
377377   }
378378}
379379
380static UINT8 dsp2_sr_read( void )
381{
382   return 0x00;
383}
384
385static void dsp2_sr_write( UINT8 data )
386{
387   // do nothing
388}
389
380390static void dsp2_register_save( running_machine *machine )
381391{
382392   state_save_register_global(machine, dsp2_state.waiting_for_command);
src/mame/machine/snes7110.c
r7664r7665
764764
765765static void spc7110_mmio_write(running_machine *machine, UINT32 addr, UINT8 data);
766766static UINT8 spc7110_mmio_read(running_machine *machine, UINT32 addr);
767static void spc7110_update_time(running_machine *machine, UINT8 offset);
767768
768769enum RTC_State
769770{
r7664r7665
859860   UINT32 rtc_mode;
860861   UINT32 rtc_index;
861862
863   UINT64 rtc_offset;
864
865   UINT8 rtc_ram[16];   // 0-12 secs, min, hrs, etc.; 13-14-15 control registers
862866} _snes_spc7110_t;
863867
864868static _snes_spc7110_t snes_spc7110;
r7664r7665
921925   snes_spc7110.decomp = SPC7110Decomp_ctor(machine);
922926}
923927
928static void spc7110rtc_init(running_machine* machine)
929{
930   spc7110_init(machine);
931
932   snes_spc7110.rtc_state = RTCS_Inactive;
933   snes_spc7110.rtc_mode  = RTCM_Linear;
934   snes_spc7110.rtc_index = 0;
935
936   snes_spc7110.rtc_offset = 0;
937
938   spc7110_update_time(machine, 0);
939}
940
924941static UINT32 spc7110_datarom_addr(UINT32 addr)
925942{
926943   UINT32 size = snes_rom_size - 0x100000;
r7664r7665
959976   snes_spc7110.r4815 = addr >> 8;
960977}
961978
979// FIXME: SPC7110 RTC is capable of rounding/adding/zero-ing seconds, so
980// we should probably keep track internally of the time rather than updating
981// to the system time at each call with a "offset" tracking as we do now...
982// (and indeed current code fails to pass Tengai Makyou Zero tests)
983static void spc7110_update_time(running_machine *machine, UINT8 offset)
984{
985   mame_system_time curtime, *systime = &curtime;
986   mame_get_current_datetime(machine, &curtime);
987   int update = 1;
988
989   snes_spc7110.rtc_offset += offset;
990
991   // TEST: can we go beyond 24hrs of rounding?!? I doubt it will ever go beyond 3600, but I could be wrong...
992   assert(snes_spc7110.rtc_offset < 86400);
993
994   /* do not update if CR0 or CR2 timer disable flags are set */
995   if ((snes_spc7110.rtc_ram[13] & 0x01) || (snes_spc7110.rtc_ram[15] & 0x03))
996      update = 0;
997
998   if (update)
999   {
1000      /* update time with offset, assuming offset < 3600s */
1001      UINT8 second = systime->local_time.second;
1002      UINT8 minute = systime->local_time.minute;
1003      UINT8 hour = systime->local_time.hour;
1004      UINT8 mday = systime->local_time.mday;
1005
1006      while (snes_spc7110.rtc_offset >= 3600)
1007      {
1008         snes_spc7110.rtc_offset -= 3600;
1009         hour++;
1010
1011         if (hour == 24)
1012         {
1013            mday++;
1014            hour = 0;
1015         }
1016      }
1017
1018      while (snes_spc7110.rtc_offset >= 60)
1019      {
1020         snes_spc7110.rtc_offset -= 60;
1021         minute++;
1022
1023         if (minute == 60)
1024         {
1025            hour++;
1026            minute = 0;
1027         }
1028      }
1029
1030      while (snes_spc7110.rtc_offset)
1031      {
1032         snes_spc7110.rtc_offset -= 1;
1033         second++;
1034
1035         if (second == 60)
1036         {
1037            minute++;
1038            second = 0;
1039         }
1040      }
1041
1042      snes_spc7110.rtc_ram[0] = second % 10;
1043      snes_spc7110.rtc_ram[1] = second / 10;
1044      snes_spc7110.rtc_ram[2] = minute % 10;
1045      snes_spc7110.rtc_ram[3] = minute / 10;
1046      snes_spc7110.rtc_ram[4] = hour % 10;
1047      snes_spc7110.rtc_ram[5] = hour / 10;
1048      snes_spc7110.rtc_ram[6] = mday % 10;
1049      snes_spc7110.rtc_ram[7] = mday / 10;
1050      snes_spc7110.rtc_ram[8] = systime->local_time.month % 10;
1051      snes_spc7110.rtc_ram[9] = systime->local_time.month / 10;
1052      snes_spc7110.rtc_ram[8] = systime->local_time.month;
1053      snes_spc7110.rtc_ram[10] = (systime->local_time.year - 1900) % 10;
1054      snes_spc7110.rtc_ram[11] = ((systime->local_time.year - 1900) / 10) % 10;
1055      snes_spc7110.rtc_ram[12] = systime->local_time.weekday % 7;
1056   }
1057}
1058
9621059static UINT8 spc7110_mmio_read(running_machine *machine, UINT32 addr)
9631060{
9641061   UINT8 *ROM = memory_region(machine, "cart");
r7664r7665
9671064
9681065   switch(addr)
9691066   {
970      //==================
971      //decompression unit
972      //==================
1067   //==================
1068   //decompression unit
1069   //==================
9731070
974      case 0x4800:
1071   case 0x4800:
9751072      {
9761073         UINT16 counter = (snes_spc7110.r4809 + (snes_spc7110.r480a << 8));
9771074         counter--;
r7664r7665
9791076         snes_spc7110.r480a = counter >> 8;
9801077         return SPC7110Decomp_read(snes_spc7110.decomp);
9811078      }
982      case 0x4801: return snes_spc7110.r4801;
983      case 0x4802: return snes_spc7110.r4802;
984      case 0x4803: return snes_spc7110.r4803;
985      case 0x4804: return snes_spc7110.r4804;
986      case 0x4805: return snes_spc7110.r4805;
987      case 0x4806: return snes_spc7110.r4806;
988      case 0x4807: return snes_spc7110.r4807;
989      case 0x4808: return snes_spc7110.r4808;
990      case 0x4809: return snes_spc7110.r4809;
991      case 0x480a: return snes_spc7110.r480a;
992      case 0x480b: return snes_spc7110.r480b;
993      case 0x480c:
1079   case 0x4801: return snes_spc7110.r4801;
1080   case 0x4802: return snes_spc7110.r4802;
1081   case 0x4803: return snes_spc7110.r4803;
1082   case 0x4804: return snes_spc7110.r4804;
1083   case 0x4805: return snes_spc7110.r4805;
1084   case 0x4806: return snes_spc7110.r4806;
1085   case 0x4807: return snes_spc7110.r4807;
1086   case 0x4808: return snes_spc7110.r4808;
1087   case 0x4809: return snes_spc7110.r4809;
1088   case 0x480a: return snes_spc7110.r480a;
1089   case 0x480b: return snes_spc7110.r480b;
1090   case 0x480c:
9941091      {
9951092         UINT8 status = snes_spc7110.r480c;
9961093         snes_spc7110.r480c &= 0x7f;
9971094         return status;
9981095      }
9991096
1000      //==============
1001      //data port unit
1002      //==============
1097   //==============
1098   //data port unit
1099   //==============
10031100
1004      case 0x4810:
1101   case 0x4810:
10051102      {
10061103         UINT8 data;
10071104         UINT32 address, adjust, adjustaddr;
r7664r7665
10431140
10441141         return data;
10451142      }
1046      case 0x4811: return snes_spc7110.r4811;
1047      case 0x4812: return snes_spc7110.r4812;
1048      case 0x4813: return snes_spc7110.r4813;
1049      case 0x4814: return snes_spc7110.r4814;
1050      case 0x4815: return snes_spc7110.r4815;
1051      case 0x4816: return snes_spc7110.r4816;
1052      case 0x4817: return snes_spc7110.r4817;
1053      case 0x4818: return snes_spc7110.r4818;
1054      case 0x481a:
1143   case 0x4811: return snes_spc7110.r4811;
1144   case 0x4812: return snes_spc7110.r4812;
1145   case 0x4813: return snes_spc7110.r4813;
1146   case 0x4814: return snes_spc7110.r4814;
1147   case 0x4815: return snes_spc7110.r4815;
1148   case 0x4816: return snes_spc7110.r4816;
1149   case 0x4817: return snes_spc7110.r4817;
1150   case 0x4818: return snes_spc7110.r4818;
1151   case 0x481a:
10551152      {
10561153         UINT8 data;
10571154         UINT32 address, adjust;
r7664r7665
10831180         return data;
10841181      }
10851182
1086      //=========
1087      //math unit
1088      //=========
1183   //=========
1184   //math unit
1185   //=========
10891186
1090      case 0x4820: return snes_spc7110.r4820;
1091      case 0x4821: return snes_spc7110.r4821;
1092      case 0x4822: return snes_spc7110.r4822;
1093      case 0x4823: return snes_spc7110.r4823;
1094      case 0x4824: return snes_spc7110.r4824;
1095      case 0x4825: return snes_spc7110.r4825;
1096       case 0x4826: return snes_spc7110.r4826;
1097       case 0x4827: return snes_spc7110.r4827;
1098       case 0x4828: return snes_spc7110.r4828;
1099       case 0x4829: return snes_spc7110.r4829;
1100       case 0x482a: return snes_spc7110.r482a;
1101       case 0x482b: return snes_spc7110.r482b;
1102       case 0x482c: return snes_spc7110.r482c;
1103       case 0x482d: return snes_spc7110.r482d;
1104       case 0x482e: return snes_spc7110.r482e;
1105       case 0x482f:
1106       {
1187   case 0x4820: return snes_spc7110.r4820;
1188   case 0x4821: return snes_spc7110.r4821;
1189   case 0x4822: return snes_spc7110.r4822;
1190   case 0x4823: return snes_spc7110.r4823;
1191   case 0x4824: return snes_spc7110.r4824;
1192   case 0x4825: return snes_spc7110.r4825;
1193   case 0x4826: return snes_spc7110.r4826;
1194   case 0x4827: return snes_spc7110.r4827;
1195   case 0x4828: return snes_spc7110.r4828;
1196   case 0x4829: return snes_spc7110.r4829;
1197   case 0x482a: return snes_spc7110.r482a;
1198   case 0x482b: return snes_spc7110.r482b;
1199   case 0x482c: return snes_spc7110.r482c;
1200   case 0x482d: return snes_spc7110.r482d;
1201   case 0x482e: return snes_spc7110.r482e;
1202   case 0x482f:
1203      {
11071204         UINT8 status = snes_spc7110.r482f;
11081205         snes_spc7110.r482f &= 0x7f;
11091206         return status;
11101207      }
11111208
1112      //===================
1113      //memory mapping unit
1114      //===================
1209   //===================
1210   //memory mapping unit
1211   //===================
11151212
1116      case 0x4830: return snes_spc7110.r4830;
1117      case 0x4831: return snes_spc7110.r4831;
1118      case 0x4832: return snes_spc7110.r4832;
1119      case 0x4833: return snes_spc7110.r4833;
1120      case 0x4834: return snes_spc7110.r4834;
1213   case 0x4830: return snes_spc7110.r4830;
1214   case 0x4831: return snes_spc7110.r4831;
1215   case 0x4832: return snes_spc7110.r4832;
1216   case 0x4833: return snes_spc7110.r4833;
1217   case 0x4834: return snes_spc7110.r4834;
11211218
1219   //====================
1220   //real-time clock unit
1221   //====================
1222   case 0x4840: return snes_spc7110.r4840;
1223   case 0x4841:
1224      {
1225         UINT8 data = 0;
1226         if (snes_spc7110.rtc_state == RTCS_Inactive || snes_spc7110.rtc_state == RTCS_ModeSelect)
1227            return 0x00;
1228
1229         snes_spc7110.r4842 = 0x80;
1230         data = snes_spc7110.rtc_ram[snes_spc7110.rtc_index];
1231         snes_spc7110.rtc_index = (snes_spc7110.rtc_index + 1) & 15;
1232         return data;
1233      }
1234   case 0x4842:
1235      {
1236         UINT8 status = snes_spc7110.r4842;
1237         snes_spc7110.r4842 &= 0x7f;
1238         return status;
1239      }
11221240   }
11231241
11241242   return 0xff;
r7664r7665
11321250
11331251   switch(addr)
11341252   {
1135      //==================
1136      //decompression unit
1137      //==================
1253   //==================
1254   //decompression unit
1255   //==================
11381256
1139      case 0x4801: snes_spc7110.r4801 = data; break;
1140      case 0x4802: snes_spc7110.r4802 = data; break;
1141      case 0x4803: snes_spc7110.r4803 = data; break;
1142      case 0x4804: snes_spc7110.r4804 = data; break;
1143      case 0x4805: snes_spc7110.r4805 = data; break;
1144      case 0x4806:
1257   case 0x4801: snes_spc7110.r4801 = data; break;
1258   case 0x4802: snes_spc7110.r4802 = data; break;
1259   case 0x4803: snes_spc7110.r4803 = data; break;
1260   case 0x4804: snes_spc7110.r4804 = data; break;
1261   case 0x4805: snes_spc7110.r4805 = data; break;
1262   case 0x4806:
11451263      {
11461264         UINT32 table, index, length, address, mode, offset;
11471265         snes_spc7110.r4806 = data;
r7664r7665
11571275
11581276         SPC7110Decomp_init(snes_spc7110.decomp, machine, mode, offset, (snes_spc7110.r4805 + (snes_spc7110.r4806 << 8)) << mode);
11591277         snes_spc7110.r480c = 0x80;
1160      } break;
1278      }
1279      break;
11611280
1162      case 0x4807: snes_spc7110.r4807 = data; break;
1163      case 0x4808: snes_spc7110.r4808 = data; break;
1164      case 0x4809: snes_spc7110.r4809 = data; break;
1165      case 0x480a: snes_spc7110.r480a = data; break;
1166      case 0x480b: snes_spc7110.r480b = data; break;
1281   case 0x4807: snes_spc7110.r4807 = data; break;
1282   case 0x4808: snes_spc7110.r4808 = data; break;
1283   case 0x4809: snes_spc7110.r4809 = data; break;
1284   case 0x480a: snes_spc7110.r480a = data; break;
1285   case 0x480b: snes_spc7110.r480b = data; break;
11671286
1168      //==============
1169      //data port unit
1170      //==============
1287   //==============
1288   //data port unit
1289   //==============
11711290
1172      case 0x4811: snes_spc7110.r4811 = data; snes_spc7110.r481x |= 0x01; break;
1173      case 0x4812: snes_spc7110.r4812 = data; snes_spc7110.r481x |= 0x02; break;
1174      case 0x4813: snes_spc7110.r4813 = data; snes_spc7110.r481x |= 0x04; break;
1175      case 0x4814:
1291   case 0x4811: snes_spc7110.r4811 = data; snes_spc7110.r481x |= 0x01; break;
1292   case 0x4812: snes_spc7110.r4812 = data; snes_spc7110.r481x |= 0x02; break;
1293   case 0x4813: snes_spc7110.r4813 = data; snes_spc7110.r481x |= 0x04; break;
1294   case 0x4814:
11761295      {
11771296         snes_spc7110.r4814 = data;
11781297         snes_spc7110.r4814_latch = 1;
r7664r7665
12101329         break;
12111330      }
12121331
1213      case 0x4815:
1332   case 0x4815:
12141333      {
12151334         snes_spc7110.r4815 = data;
12161335         snes_spc7110.r4815_latch = 1;
r7664r7665
12481367         break;
12491368      }
12501369
1251      case 0x4816: snes_spc7110.r4816 = data; break;
1252      case 0x4817: snes_spc7110.r4817 = data; break;
1253      case 0x4818:
1370   case 0x4816: snes_spc7110.r4816 = data; break;
1371   case 0x4817: snes_spc7110.r4817 = data; break;
1372   case 0x4818:
12541373      {
1255          if(snes_spc7110.r481x != 0x07) break;
1374             if(snes_spc7110.r481x != 0x07)
1375            break;
12561376
1257          snes_spc7110.r4818 = data;
1258          snes_spc7110.r4814_latch = snes_spc7110.r4815_latch = 0;
1259          break;
1260       }
1377             snes_spc7110.r4818 = data;
1378             snes_spc7110.r4814_latch = snes_spc7110.r4815_latch = 0;
1379             break;
1380          }
12611381
1262      //=========
1263      //math unit
1264      //=========
1382   //=========
1383   //math unit
1384   //=========
12651385
1266      case 0x4820: snes_spc7110.r4820 = data; break;
1267      case 0x4821: snes_spc7110.r4821 = data; break;
1268      case 0x4822: snes_spc7110.r4822 = data; break;
1269      case 0x4823: snes_spc7110.r4823 = data; break;
1270      case 0x4824: snes_spc7110.r4824 = data; break;
1271      case 0x4825:
1386   case 0x4820: snes_spc7110.r4820 = data; break;
1387   case 0x4821: snes_spc7110.r4821 = data; break;
1388   case 0x4822: snes_spc7110.r4822 = data; break;
1389   case 0x4823: snes_spc7110.r4823 = data; break;
1390   case 0x4824: snes_spc7110.r4824 = data; break;
1391   case 0x4825:
12721392      {
1273          snes_spc7110.r4825 = data;
1393             snes_spc7110.r4825 = data;
12741394
1275          if(snes_spc7110.r482e & 1) {
1276             //signed 16-bit x 16-bit multiplication
1277             INT16 r0 = (INT16)(snes_spc7110.r4824 + (snes_spc7110.r4825 << 8));
1278             INT16 r1 = (INT16)(snes_spc7110.r4820 + (snes_spc7110.r4821 << 8));
1395             if(snes_spc7110.r482e & 1)
1396         {
1397                //signed 16-bit x 16-bit multiplication
1398                INT16 r0 = (INT16)(snes_spc7110.r4824 + (snes_spc7110.r4825 << 8));
1399                INT16 r1 = (INT16)(snes_spc7110.r4820 + (snes_spc7110.r4821 << 8));
12791400
1280             INT32 result = r0 * r1;
1281             snes_spc7110.r4828 = result;
1282             snes_spc7110.r4829 = result >> 8;
1283             snes_spc7110.r482a = result >> 16;
1284             snes_spc7110.r482b = result >> 24;
1285         } else {
1286             //unsigned 16-bit x 16-bit multiplication
1287             UINT16 r0 = (UINT16)(snes_spc7110.r4824 + (snes_spc7110.r4825 << 8));
1288             UINT16 r1 = (UINT16)(snes_spc7110.r4820 + (snes_spc7110.r4821 << 8));
1401                INT32 result = r0 * r1;
1402                snes_spc7110.r4828 = result;
1403                snes_spc7110.r4829 = result >> 8;
1404                snes_spc7110.r482a = result >> 16;
1405                snes_spc7110.r482b = result >> 24;
1406         }
1407         else
1408         {
1409                //unsigned 16-bit x 16-bit multiplication
1410                UINT16 r0 = (UINT16)(snes_spc7110.r4824 + (snes_spc7110.r4825 << 8));
1411                UINT16 r1 = (UINT16)(snes_spc7110.r4820 + (snes_spc7110.r4821 << 8));
12891412
1290             UINT32 result = r0 * r1;
1291             snes_spc7110.r4828 = result;
1292             snes_spc7110.r4829 = result >> 8;
1293             snes_spc7110.r482a = result >> 16;
1294             snes_spc7110.r482b = result >> 24;
1413                UINT32 result = r0 * r1;
1414                snes_spc7110.r4828 = result;
1415                snes_spc7110.r4829 = result >> 8;
1416                snes_spc7110.r482a = result >> 16;
1417                snes_spc7110.r482b = result >> 24;
12951418         }
12961419
12971420         snes_spc7110.r482f = 0x80;
12981421         break;
12991422      }
13001423
1301      case 0x4826: snes_spc7110.r4826 = data; break;
1302      case 0x4827:
1424   case 0x4826: snes_spc7110.r4826 = data; break;
1425   case 0x4827:
13031426      {
13041427         snes_spc7110.r4827 = data;
13051428
r7664r7665
13661489         break;
13671490      }
13681491
1369      case 0x482e:
1492   case 0x482e:
13701493      {
13711494         //reset math unit
13721495         snes_spc7110.r4820 = snes_spc7110.r4821 = snes_spc7110.r4822 = snes_spc7110.r4823 = 0;
r7664r7665
13781501         break;
13791502      }
13801503
1381      //===================
1382      //memory mapping unit
1383      //===================
1504   //===================
1505   //memory mapping unit
1506   //===================
13841507
1385      case 0x4830: snes_spc7110.r4830 = data; break;
1508   case 0x4830: snes_spc7110.r4830 = data; break;
13861509
1387      case 0x4831:
1510   case 0x4831:
13881511      {
13891512         snes_spc7110.r4831 = data;
1390         snes_spc7110.dx_offset = spc7110_datarom_addr((data & 7) * 0x100000);
1513         snes_spc7110.dx_offset = spc7110_datarom_addr(data * 0x100000);
13911514         break;
13921515      }
13931516
1394      case 0x4832:
1517   case 0x4832:
13951518      {
13961519         snes_spc7110.r4832 = data;
1397         snes_spc7110.ex_offset = spc7110_datarom_addr((data & 7) * 0x100000);
1520         snes_spc7110.ex_offset = spc7110_datarom_addr(data * 0x100000);
13981521         break;
13991522      }
14001523
1401      case 0x4833:
1524   case 0x4833:
14021525      {
14031526         snes_spc7110.r4833 = data;
1404         snes_spc7110.fx_offset = spc7110_datarom_addr((data & 7) * 0x100000);
1527         snes_spc7110.fx_offset = spc7110_datarom_addr(data * 0x100000);
14051528         break;
14061529      }
14071530
1408      case 0x4834: snes_spc7110.r4834 = data; break;
1531   case 0x4834: snes_spc7110.r4834 = data; break;
1532
1533   //====================
1534   //real-time clock unit
1535   //====================
1536
1537   case 0x4840:
1538      {
1539         snes_spc7110.r4840 = data;
1540
1541         if (!(snes_spc7110.r4840 & 1))
1542         {
1543            //disable RTC
1544            snes_spc7110.rtc_state = RTCS_Inactive;
1545            spc7110_update_time(machine, 0);
1546         }
1547         else
1548         {
1549            //enable RTC
1550            snes_spc7110.r4842 = 0x80;
1551            snes_spc7110.rtc_state = RTCS_ModeSelect;
1552         }
1553      }
1554      break;
1555
1556   case 0x4841:
1557      {
1558         snes_spc7110.r4841 = data;
1559
1560         switch (snes_spc7110.rtc_state)
1561         {
1562         case RTCS_ModeSelect:
1563            if (data == RTCM_Linear || data == RTCM_Indexed)
1564            {
1565               snes_spc7110.r4842 = 0x80;
1566               snes_spc7110.rtc_state = RTCS_IndexSelect;
1567               snes_spc7110.rtc_mode = (RTC_Mode)data;
1568               snes_spc7110.rtc_index = 0;
1569            }
1570            break;
1571
1572         case RTCS_IndexSelect:
1573            snes_spc7110.r4842 = 0x80;
1574            snes_spc7110.rtc_index = data & 15;
1575            if (snes_spc7110.rtc_mode == RTCM_Linear)
1576               snes_spc7110.rtc_state = RTCS_Write;
1577            break;
1578
1579         case RTCS_Write:
1580            snes_spc7110.r4842 = 0x80;
1581
1582            //control register 0
1583            if (snes_spc7110.rtc_index == 13)
1584            {
1585               //increment second counter
1586               if (data & 2)
1587                  spc7110_update_time(machine, 1);
1588
1589               //round minute counter
1590               if (data & 8)
1591               {
1592                  spc7110_update_time(machine, 0);
1593
1594                  UINT8 second = snes_spc7110.rtc_ram[0] + snes_spc7110.rtc_ram[1] * 10;
1595                  //clear seconds
1596                  snes_spc7110.rtc_ram[0] = 0;
1597                  snes_spc7110.rtc_ram[1] = 0;
1598
1599                  if (second >= 30)
1600                     spc7110_update_time(machine, 60);
1601               }
1602            }
1603
1604            //control register 2
1605            if (snes_spc7110.rtc_index == 15)
1606            {
1607               //disable timer and clear second counter
1608               if ((data & 1) && !(snes_spc7110.rtc_ram[15]  & 1))
1609               {
1610                  spc7110_update_time(machine, 0);
1611
1612                  //clear seconds
1613                  snes_spc7110.rtc_ram[0] = 0;
1614                  snes_spc7110.rtc_ram[1] = 0;
1615               }
1616
1617               //disable timer
1618               if((data & 2) && !(snes_spc7110.rtc_ram[15] & 2))
1619                  spc7110_update_time(machine, 0);
1620            }
1621
1622            snes_spc7110.rtc_ram[snes_spc7110.rtc_index] = data & 15;
1623            snes_spc7110.rtc_index = (snes_spc7110.rtc_index + 1) & 15;
1624            break;
1625         }
1626      }
1627      break;
14091628   }
14101629}
1630
1631static UINT8 spc7110_bank7_read(running_machine *machine, UINT32 offset)
1632{
1633   UINT8 *ROM = memory_region(machine, "cart");
1634   UINT32 addr = offset & 0x0fffff;
1635
1636   switch (offset & 0xf00000)
1637   {
1638   case 0x100000:
1639      return ROM[snes_spc7110.dx_offset + addr];
1640   case 0x200000:
1641      return ROM[snes_spc7110.ex_offset + addr];
1642   case 0x300000:
1643      return ROM[snes_spc7110.fx_offset + addr];
1644   default:
1645      break;
1646   }
1647   return 0xff;
1648}
src/mame/machine/snesrtc.c
r7664r7665
5252   rtc_state.ram[6] = systime->local_time.mday % 10;
5353   rtc_state.ram[7] = systime->local_time.mday / 10;
5454   rtc_state.ram[8] = systime->local_time.month;
55   rtc_state.ram[9] = (systime->local_time.year - 1900) % 10;
56   rtc_state.ram[10] = ((systime->local_time.year - 1900) / 10) % 10;
57   rtc_state.ram[11] = (systime->local_time.year - 1900) / 100;
55   rtc_state.ram[9] = (systime->local_time.year - 1000) % 10;
56   rtc_state.ram[10] = ((systime->local_time.year - 1000) / 10) % 10;
57   rtc_state.ram[11] = (systime->local_time.year - 1000) / 100;
5858   rtc_state.ram[12] = systime->local_time.weekday % 7;
5959}
6060
src/mame/machine/snes.c
r7664r7665
623623   else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
624624   {
625625      UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
626      if (offset >= 0x4800 && offset < limit)
626      if (offset >= 0x4800 && offset <= limit)
627627      {
628628         return spc7110_mmio_read(space->machine, offset);
629629      }
r7664r7665
934934   else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
935935   {
936936      UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
937      if (offset >= 0x4800 && offset < limit)
937      if (offset >= 0x4800 && offset <= limit)
938938      {
939939         spc7110_mmio_write(space->machine, (UINT32)offset, data);
940940         return;
r7664r7665
16031603/* 0x000000 - 0x2fffff */
16041604READ8_HANDLER( snes_r_bank1 )
16051605{
1606   UINT8 value;
1606   UINT8 value = 0xff;
16071607   UINT16 address = offset & 0xffff;
16081608
16091609   if (address < 0x2000)                                 /* Mirror of Low RAM */
r7664r7665
16131613   else if (address < 0x8000)
16141614   {
16151615      if (snes_has_addon_chip == HAS_SUPERFX)
1616         value = snes_ram[0xf00000 + (address & 0x1fff)];   // here it should 0xe00000 but there are mirroring issues
1616         value = snes_ram[0xf00000 + (address & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
16171617      else if (snes_has_addon_chip == HAS_OBC1)
16181618         value = obc1_read(space, offset);
1619      else if ((snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1620         value = (address < 0x7000) ? dsp2_read() : 0x00;
16211619      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
16221620         value = (address < 0x7000) ? dsp1_get_dr() : dsp1_get_sr();
16231621      else if (snes_has_addon_chip == HAS_CX4)
16241622         value = CX4_read(address - 0x6000);
16251623      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
1626         value = snes_ram[0x306000 + (offset & 0x1fff)];
1624      {
1625         if (offset < 0x10000)
1626            value = snes_ram[0x306000 + (offset & 0x1fff)];
1627      }
16271628      else
16281629      {
1629         logerror( "snes_r_bank1: Unmapped external chip read: %04x\n", address );
1630         logerror("snes_r_bank1: Unmapped external chip read: %04x\n", address);
16301631         value = 0xff;                                 /* Reserved */
16311632      }
16321633   }
16331634   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
16341635      value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
16351636   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1636      value = (address < 0xc000) ? dsp2_read() : 0x00;
1637      value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
16371638   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
16381639      value = dsp3_read(address);
16391640   else
r7664r7665
16451646/* 0x300000 - 0x3fffff */
16461647READ8_HANDLER( snes_r_bank2 )
16471648{
1648   UINT8 value;
1649   UINT8 value = 0xff;
16491650   UINT16 address = offset & 0xffff;
16501651
16511652   if (address < 0x2000)                                 /* Mirror of Low RAM */
r7664r7665
16551656   else if (address < 0x8000)                              /* SRAM for mode_21, Reserved othewise */
16561657   {
16571658      if (snes_has_addon_chip == HAS_SUPERFX)
1658         value = snes_ram[0xf00000 + (address & 0x1fff)];   // here it should 0xe00000 but there are mirroring issues
1659         value = snes_ram[0xf00000 + (address & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
16591660      else if (snes_has_addon_chip == HAS_OBC1)
16601661         value = obc1_read (space, offset);
1661      else if (snes_has_addon_chip == HAS_DSP2)
1662         value = (address < 0x7000) ? dsp2_read() : 0x00;
1662      else if (snes_has_addon_chip == HAS_CX4)
1663         value = CX4_read(address - 0x6000);
16631664      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
1664         value = snes_ram[0x306000 + (offset & 0x1fff)];
1665      {
1666         if (offset < 0x10000)
1667            value = snes_ram[0x306000 + (offset & 0x1fff)];
1668      }
16651669      else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
16661670      {
16671671         int mask = ((snes_cart.sram * 1024) - 1);            /* Limit SRAM size to what's actually present */
r7664r7665
16781682   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
16791683      value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
16801684   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2))
1681      value = (address < 0xc000) ? dsp2_read() : 0x00;
1685      value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
16821686   else if (snes_has_addon_chip == HAS_DSP3)
16831687      value = dsp3_read(address);
16841688   else if (snes_has_addon_chip == HAS_DSP4)
r7664r7665
16921696/* 0x400000 - 0x5fffff */
16931697READ8_HANDLER( snes_r_bank3 )
16941698{
1695   UINT8 value;
1699   UINT8 value = 0xff;
16961700   UINT16 address = offset & 0xffff;
16971701
1698   if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX))   /* Mode 20 & 22 */
1702   if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC))
16991703   {
1704      if (offset >= 0x100000 && offset < 0x110000)
1705         value = spc7110_mmio_read(space->machine, 0x4800);
1706   }
1707   else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX))   /* Mode 20 & 22 */
1708   {
17001709      if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20))
17011710         value = 0xff;                     /* Reserved */
17021711      else
r7664r7665
17271736         value = (address >= 0x4000) ? dsp1_get_sr() : dsp1_get_dr();
17281737      else
17291738      {
1730         logerror( "snes_r_bank4: Unmapped external chip read: %04x\n", address );
1739         logerror("snes_r_bank4: Unmapped external chip read: %04x\n", address);
17311740         value = 0xff;                     /* Reserved */
17321741      }
17331742   }
17341743   else if (snes_cart.mode & 0x0a)               /* Mode 21 & 25 */
1735      value = snes_ram[0x600000 + offset];
1744      value = snes_ram[0x600000 + offset];   
17361745
17371746   return value;
17381747}
r7664r7665
17761785   {
17771786      if (snes_cart.mode != SNES_MODE_25)
17781787         value = memory_read_byte(space, offset);
1779      else if (snes_has_addon_chip == HAS_CX4)
1780      {
1781         //printf( "R: CX4 hit from 0x800000\n" );
1782      }
1788      else if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000))
1789         value = CX4_read(address - 0x6000);
17831790      else                     /* Mode 25 has SRAM not mirrored from lower banks */
17841791      {
17851792         if (address < 0x6000)
r7664r7665
18001807   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
18011808      value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
18021809   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1803      value = (address < 0xc000) ? dsp2_read() : 0x00;
1810      value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
18041811   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
18051812      value = dsp3_read(address);
18061813   else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
r7664r7665
18171824   UINT8 value = 0;
18181825   UINT16 address = offset & 0xffff;
18191826
1820   if (snes_has_addon_chip == HAS_SDD1)
1827   if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
1828      value = spc7110_bank7_read(space->machine, offset);
1829   else if (snes_has_addon_chip == HAS_SDD1)
18211830      value = sdd1_read(space->machine, offset);
18221831   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
18231832      value = st010_read(address);
r7664r7665
18501859         snes_ram[0xf00000 + (address & 0x1fff)] = data;   // here it should 0xe00000 but there are mirroring issues
18511860      else if (snes_has_addon_chip == HAS_OBC1)
18521861         obc1_write(space, offset, data);
1853      else if ((snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1854         dsp2_write(data);
18551862      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
18561863         dsp1_set_dr(data);
18571864      else if (snes_has_addon_chip == HAS_CX4)
18581865         CX4_write(space->machine, address - 0x6000, data);
18591866      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
18601867      {
1861         snes_ram[0x306000 + (offset & 0x1fff)] = data;
1868         if (offset < 0x10000)
1869            snes_ram[0x306000 + (offset & 0x1fff)] = data;
18621870      }
18631871      else
1864         logerror( "snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data );
1872         logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data);
18651873   }
18661874   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
18671875      dsp1_set_dr(data);
1868   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000) && (address < 0xc000))
1869      dsp2_write(data);
1876   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1877   {
1878      if (address < 0xc000)
1879         dsp2_dr_write(data);
1880      else
1881         dsp2_sr_write(data);
1882   }
18701883   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
18711884      dsp3_write(address, data);
18721885   else
r7664r7665
18851898   else if (address < 0x8000)                  /* SRAM for mode_21, Reserved othewise */
18861899   {
18871900      if (snes_has_addon_chip == HAS_SUPERFX)
1888         snes_ram[0xf00000 + (address & 0x1fff)] = data;   // here it should 0xe00000 but there are mirroring issues
1901         snes_ram[0xf00000 + (address & 0x1fff)] = data;   // here it should be 0xe00000 but there are mirroring issues
18891902      else if (snes_has_addon_chip == HAS_OBC1)
18901903         obc1_write(space, offset, data);
1891      else if (snes_has_addon_chip == HAS_DSP2)
1892         dsp2_write(data);
1904      else if (snes_has_addon_chip == HAS_CX4)
1905         CX4_write(space->machine, address - 0x6000, data);
18931906      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
18941907      {
1895         snes_ram[0x306000 + (offset & 0x1fff)] = data;
1908         if (offset < 0x10000)
1909            snes_ram[0x306000 + (offset & 0x1fff)] = data;
18961910      }
18971911      else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
18981912      {
r7664r7665
19061920   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
19071921   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
19081922      dsp1_set_dr(data);
1909   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (address < 0xc000))
1910      dsp2_write(data);
1923   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2))
1924   {
1925      if (address < 0xc000)
1926         dsp2_dr_write(data);
1927      else
1928         dsp2_sr_write(data);
1929   }
19111930   else if (snes_has_addon_chip == HAS_DSP3)
19121931      dsp3_write(address, data);
19131932   else if ((snes_has_addon_chip == HAS_DSP4) && (address < 0xc000))
r7664r7665
19691988      memory_write_byte(space, offset, data);
19701989   else if (address < 0x8000)
19711990   {
1972      if (snes_has_addon_chip == HAS_CX4)
1973      {
1974         //printf( "R: CX4 hit from 0x800000\n" );
1975      }
1976      if (snes_cart.mode != SNES_MODE_25)
1991      if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000))
1992         CX4_write(space->machine, address - 0x6000, data);
1993      else if (snes_cart.mode != SNES_MODE_25)
19771994         memory_write_byte(space, offset, data);
19781995      else   /* Mode 25 has SRAM not mirrored from lower banks */
19791996      {
r7664r7665
19912008   }
19922009   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
19932010      dsp1_set_dr(data);
1994   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000) && (address < 0xc000))
1995      dsp2_write(data);
2011   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
2012   {
2013      if (address < 0xc000)
2014         dsp2_dr_write(data);
2015      else
2016         dsp2_sr_write(data);
2017   }
19962018   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
19972019      dsp3_write(address, data);
19982020   else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000))
r7664r7665
22892311         sdd1_init(machine);
22902312         break;
22912313      case HAS_SPC7110:
2292      case HAS_SPC7110_RTC:
22932314         spc7110_init(machine);
22942315         break;
2316      case HAS_SPC7110_RTC:
2317         spc7110rtc_init(machine);
2318         break;
22952319      case HAS_ST010:
22962320         st010_init(machine);
22972321         break;
src/mess/machine/snescart.c
r7664r7665
448448         * (actually up to 0x7d, because 0x7e and 0x7f are overwritten by WRAM). The top half (address
449449         * range 0x8000 - 0xffff) of each bank is also mirrored in banks 0x00 to 0x3f and 0x80 to 0xbf.
450450         */
451         while (read_blocks < 64 && read_blocks < total_blocks)
451         /* SPC7110 games needs this different loading routine */
452         if ((temp_buffer[0x00ffd6] == 0xf9 || temp_buffer[0x00ffd6] == 0xf5) && (temp_buffer[0x00ffd5] == 0x3a))
452453         {
453            /* Loading data */
454            memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x10000], 0x10000);
455            /* Mirroring */
456            memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
457            memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &snes_ram[0xc00000 + read_blocks * 0x10000], 0x10000);
458            memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
459            read_blocks++;
454            while (read_blocks < 16 && read_blocks < total_blocks)
455            {
456               /* Loading data */
457               memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x10000], 0x10000);
458               /* Mirroring */
459               memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
460               memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
461               read_blocks++;
462            }
460463         }
461         /* Filling banks up to 0xff and their mirrors */
462         while (read_blocks % 64)
464         else
463465         {
464            int j = 0, repeat_blocks;
465            while ((read_blocks % (64 >> j)) && j < 6)
466               j++;
467            repeat_blocks = read_blocks % (64 >> (j - 1));
466            while (read_blocks < 64 && read_blocks < total_blocks)
467            {
468               /* Loading data */
469               memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x10000], 0x10000);
470               /* Mirroring */
471               memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
472               memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &snes_ram[0xc00000 + read_blocks * 0x10000], 0x10000);
473               memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0xc08000 + read_blocks * 0x10000], 0x8000);
474               read_blocks++;
475            }
476            /* Filling banks up to 0xff and their mirrors */
477            while (read_blocks % 64)
478            {
479               int j = 0, repeat_blocks;
480               while ((read_blocks % (64 >> j)) && j < 6)
481                  j++;
482               repeat_blocks = read_blocks % (64 >> (j - 1));
468483
469            memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &snes_ram[0xc00000 + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
470            memcpy(&snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
471            memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &snes_ram[0x400000 + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
472            memcpy(&snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[0x800000 + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
473            read_blocks += repeat_blocks;
484               memcpy(&snes_ram[0xc00000 + read_blocks * 0x10000], &snes_ram[0xc00000 + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
485               memcpy(&snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
486               memcpy(&snes_ram[0x400000 + read_blocks * 0x10000], &snes_ram[0x400000 + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
487               memcpy(&snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[0x800000 + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
488               read_blocks += repeat_blocks;
489            }
474490         }
475491         break;
476492

Previous 15994 Revisions Next


© 1998-2018 The MESS Team