Previous 15994 Revisions Next

r6587 Wednesday 9th December, 2009 at 05:35:50 UTC by Barry Rodewald
[FMTOWNS] Fixed CD-ROM reading the wrong sector under certain conditions.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r6586r6587
852852
853853static READ32_HANDLER(towns_padport_r)
854854{
855   logerror("PADPORT: read mask %08x\n",mem_mask);
855856   if(ACCESSING_BITS_0_7)
856857      return 0x7f;
857858
r6586r6587
12551256   towns_cd.cmd_status[2] = st2;
12561257   towns_cd.cmd_status[3] = st3;
12571258   // wait a bit
1258   timer_set(machine,ATTOTIME_IN_MSEC(20),machine,0,towns_cd_status_ready);
1259   timer_set(machine,ATTOTIME_IN_MSEC(1),machine,0,towns_cd_status_ready);
12591260}
12601261
12611262static UINT8 towns_cd_get_track(running_machine* machine)
r6586r6587
12831284      return;
12841285   
12851286   masked = upd71071_dmarq(device,param,3);  // CD-ROM controller uses DMA1 channel 3
1286   logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,towns_cd.buffer_ptr);
1287//   logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,towns_cd.buffer_ptr);
12871288   if(param != 0)
12881289   {
12891290      timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),0);
r6586r6587
13321333   // parameters:
13331334   //          3 bytes: MSF of first sector to read
13341335   //          3 bytes: MSF of last sector to read
1335   UINT32 lba1,lba2;
1336   UINT32 lba1,lba2,track;
13361337
13371338   lba1 = towns_cd.parameter[7] << 16;
13381339   lba1 += towns_cd.parameter[6] << 8;
r6586r6587
13441345   towns_cd.lba_last = msf_to_lba(lba2);
13451346   
13461347   // first track starts at 00:02:00 - this is hardcoded in the boot procedure
1347   if(cdrom_get_track(mess_cd_get_cdrom_file(device),lba1) == 0)
1348   track = cdrom_get_track(mess_cd_get_cdrom_file(device),lba1);
1349   if(track < 2)
13481350   {  // recalculate LBA
1349      if(towns_cd.parameter[6] < 2)
1351      if((towns_cd.parameter[6] & 0x0f) < 2)
13501352      {
1351         lba1 = (towns_cd.parameter[7] - 1) << 16;
1352         lba1 += (towns_cd.parameter[6] + 58) << 8;
1353         lba1 = 0;
1354         if((towns_cd.parameter[6] & 0xf0) == 0x00)
1355         {
1356            lba1 |= (((towns_cd.parameter[6] + 8) & 0x0f) << 8);
1357            lba1 |= (((towns_cd.parameter[6] + 0x80) & 0xf0) << 8);
1358            lba1 |= ((towns_cd.parameter[7] - 1) << 16);
1359         }
1360         else
1361         {
1362            lba1 |= (((towns_cd.parameter[6] + 8) & 0x0f) << 8);
1363            lba1 |= (((towns_cd.parameter[6] - 0x10) & 0xf0) << 8);
1364            lba1 |= ((towns_cd.parameter[7]) << 16);
1365         }
13531366      }
13541367      else
13551368      {
1356         lba1 = towns_cd.parameter[7] << 16;
1357         lba1 += (towns_cd.parameter[6] - 2) << 8;
1369         lba1 = (towns_cd.parameter[7] << 16);
1370         lba1 |= ((towns_cd.parameter[6] - 2) << 8);
13581371      }
1359      lba1 += towns_cd.parameter[5];
1360      if(towns_cd.parameter[3] < 2)
1372      lba1 |= towns_cd.parameter[5];
1373      if((towns_cd.parameter[3] & 0x0f) < 2)
13611374      {
1362         lba2 = (towns_cd.parameter[4] - 1) << 16;
1363         lba2 += (towns_cd.parameter[3] + 58) << 8;
1375         lba2 = 0;
1376         if((towns_cd.parameter[3] & 0xf0) == 0x00)
1377         {
1378            lba2 |= (((towns_cd.parameter[3] + 8) & 0x0f) << 8);
1379            lba2 |= (((towns_cd.parameter[3] + 0x80) & 0xf0) << 8);
1380            lba2 |= ((towns_cd.parameter[4] - 1) << 16);
1381         }
1382         else
1383         {
1384            lba2 |= (((towns_cd.parameter[3] + 8) & 0x0f) << 8);
1385            lba2 |= (((towns_cd.parameter[3] - 0x10) & 0xf0) << 8);
1386            lba2 |= ((towns_cd.parameter[4]) << 16);
1387         }
13641388      }
13651389      else
13661390      {
1367         lba2 = towns_cd.parameter[4] << 16;
1368         lba2 += (towns_cd.parameter[3] - 2) << 8;
1391         lba2 = (towns_cd.parameter[4] << 16);
1392         lba2 |= ((towns_cd.parameter[3] - 2) << 8);
13691393      }
1370      lba2 += towns_cd.parameter[2];
1394      lba2 |= towns_cd.parameter[2];
13711395      towns_cd.lba_current = msf_to_lba(lba1);
13721396      towns_cd.lba_last = msf_to_lba(lba2);
13731397   }
13741398   
1375   logerror("CD: Mode 1 read from LBA next:%i last:%i\n",towns_cd.lba_current,towns_cd.lba_last);
1399   logerror("CD: Mode 1 read from LBA next:%i last:%i track:%i\n",towns_cd.lba_current,towns_cd.lba_last,track);
13761400
13771401   if(towns_cd.lba_current > towns_cd.lba_last)
13781402   {
r6586r6587
14621486            if(towns_cd.command & 0x20)
14631487            {
14641488               towns_cd.extra_status = 0;
1489               if(towns_cd.parameter[7] != 0)
1490               {
1491                  towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
1492                  break;
1493               }
14651494               if(cdda_audio_active(devtag_get_device(device->machine,"cdda")))
14661495                  towns_cd_set_status(device->machine,0x00,0x03,0x00,0x00);
14671496               else
r6586r6587
21662195{
21672196   towns_vram = auto_alloc_array(machine,UINT32,0x20000);
21682197   towns_cmos = auto_alloc_array(machine,UINT8,0x2000);
2169   towns_gfxvram = auto_alloc_array(machine,UINT8,0x40000);
2198   towns_gfxvram = auto_alloc_array(machine,UINT8,0x80000);
21702199   towns_txtvram = auto_alloc_array(machine,UINT8,0x20000);
21712200   towns_serial_rom = auto_alloc_array(machine,UINT8,256/8);
21722201   towns_init_serial_rom(machine);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team