Previous 15994 Revisions Next

r6550 Sunday 6th December, 2009 at 09:53:21 UTC by Barry Rodewald
[FMTOWNS] Re-worked CD-ROM command status reading to add a delay before status bytes can be read. This fixes CD IRQs, allowing further progress in booting from CD, and directory access of CDs.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r6549r6550
11941194 *  0x4c4 - Parameter port (R/W)
11951195 *    Inserts a byte into an array of 8 bytes used for command parameters
11961196 *    Writing to this port puts the byte at the front of the array, and
1197 *    pushes the other parameters back.  Parameters are in BCD?
1197 *    pushes the other parameters back.
11981198 *
11991199 *  0x4c6 (W/O)
12001200 *    bit 3 - software transfer mode
r6549r6550
12401240   }
12411241}
12421242
1243static TIMER_CALLBACK( towns_cd_status_ready )
1244{
1245   towns_cd.status |= 0x02;  // status read request
1246   towns_cd.status |= 0x01;  // ready
1247   towns_cd.cmd_status_ptr = 0;
1248   towns_cdrom_set_irq((running_machine*)ptr,TOWNS_CD_IRQ_MPU,1);
1249}
1250
1251static void towns_cd_set_status(running_machine* machine, UINT8 st0, UINT8 st1, UINT8 st2, UINT8 st3)
1252{
1253   towns_cd.cmd_status[0] = st0;
1254   towns_cd.cmd_status[1] = st1;
1255   towns_cd.cmd_status[2] = st2;
1256   towns_cd.cmd_status[3] = st3;
1257   // wait a bit
1258   timer_set(machine,ATTOTIME_IN_MSEC(20),machine,0,towns_cd_status_ready);
1259}
1260
12431261static UINT8 towns_cd_get_track(running_machine* machine)
12441262{
12451263   const device_config* cdrom = devtag_get_device(machine,"cdrom");
r6549r6550
12651283      return;
12661284   
12671285   masked = upd71071_dmarq(device,param,3);  // CD-ROM controller uses DMA1 channel 3
1268   //logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,towns_cd.buffer_ptr);
1286   logerror("DMARQ: param=%i ret=%i bufferptr=%i\n",param,masked,towns_cd.buffer_ptr);
12691287   if(param != 0)
12701288   {
12711289      timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),0);
r6549r6550
12861304         logerror("DMA1: end of transfer (LBA=%08x)\n",towns_cd.lba_current);
12871305         if(towns_cd.lba_current >= towns_cd.lba_last)
12881306         { 
1289            towns_cd.status |= 0x02;  // status read request
1290            towns_cd.cmd_status_ptr = 0;
12911307            towns_cd.extra_status = 0;
1292            towns_cd.cmd_status[0] = 0x06;
1293            towns_cd.cmd_status[1] = 0x00;
1294            towns_cd.cmd_status[2] = 0x00;
1295            towns_cd.cmd_status[3] = 0x00;
1308            towns_cd_set_status(device->machine,0x06,0x00,0x00,0x00);
12961309            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_DMA,1);
1310            towns_cd.buffer_ptr = -1;
12971311            towns_cd.status |= 0x01;  // ready
12981312         }
12991313         else
13001314         {
1301            towns_cd.status |= 0x02;  // status read request
1302            towns_cd.cmd_status_ptr = 0;
13031315            towns_cd.extra_status = 0;
1304            towns_cd.cmd_status[0] = 0x22;
1305            towns_cd.cmd_status[1] = 0x00;
1306            towns_cd.cmd_status[2] = 0x00;
1307            towns_cd.cmd_status[3] = 0x00;
1316            towns_cd_set_status(device->machine,0x22,0x00,0x00,0x00);
13081317            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_DMA,1);
13091318            cdrom_read_data(mess_cd_get_cdrom_file(devtag_get_device(device->machine,"cdrom")),++towns_cd.lba_current,towns_cd.buffer,CD_TRACK_MODE1);
13101319            timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1);
13111320            towns_cd.buffer_ptr = -1;
1312            towns_cd.status |= 0x01;  // ready
13131321         }
13141322      }
13151323   }
r6549r6550
13251333   //          3 bytes: MSF of first sector to read
13261334   //          3 bytes: MSF of last sector to read
13271335   UINT32 lba1,lba2;
1328   
1336
13291337   lba1 = towns_cd.parameter[7] << 16;
13301338   lba1 += towns_cd.parameter[6] << 8;
13311339   lba1 += towns_cd.parameter[5];
13321340   lba2 = towns_cd.parameter[4] << 16;
13331341   lba2 += towns_cd.parameter[3] << 8;
13341342   lba2 += towns_cd.parameter[2];
1335   towns_cd.lba_current = msf_to_lba(lba1-0x200);
1336   towns_cd.lba_last = msf_to_lba(lba2-0x200);
1343   towns_cd.lba_current = msf_to_lba(lba1);
1344   towns_cd.lba_last = msf_to_lba(lba2);
13371345   
1346   // 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   {  // recalculate LBA
1349      if(towns_cd.parameter[6] < 2)
1350      {
1351         lba1 = (towns_cd.parameter[7] - 1) << 16;
1352         lba1 += (towns_cd.parameter[6] + 58) << 8;
1353      }
1354      else
1355      {
1356         lba1 = towns_cd.parameter[7] << 16;
1357         lba1 += (towns_cd.parameter[6] - 2) << 8;
1358      }
1359      lba1 += towns_cd.parameter[5];
1360      if(towns_cd.parameter[3] < 2)
1361      {
1362         lba2 = (towns_cd.parameter[4] - 1) << 16;
1363         lba2 += (towns_cd.parameter[3] + 58) << 8;
1364      }
1365      else
1366      {
1367         lba2 = towns_cd.parameter[4] << 16;
1368         lba2 += (towns_cd.parameter[3] - 2) << 8;
1369      }
1370      lba2 += towns_cd.parameter[2];
1371      towns_cd.lba_current = msf_to_lba(lba1);
1372      towns_cd.lba_last = msf_to_lba(lba2);
1373   }
1374   
13381375   logerror("CD: Mode 1 read from LBA next:%i last:%i\n",towns_cd.lba_current,towns_cd.lba_last);
13391376
13401377   if(towns_cd.lba_current > towns_cd.lba_last)
13411378   {
1342      towns_cd.status |= 0x03; // immediate status return?
13431379      towns_cd.extra_status = 0;
1344      towns_cd.cmd_status[0] = 0x01;
1345      towns_cd.cmd_status[1] = 0x00;
1346      towns_cd.cmd_status[2] = 0x00;
1347      towns_cd.cmd_status[3] = 0x00;
1348      towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1380      towns_cd_set_status(device->machine,0x01,0x00,0x00,0x00);
13491381   }
13501382   else
13511383   {
13521384      cdrom_read_data(mess_cd_get_cdrom_file(device),towns_cd.lba_current,towns_cd.buffer,CD_TRACK_MODE1);
1353      towns_cd.buffer_ptr = 0;
1354      towns_cd.status |= 0x03; // immediate status return?
13551385      towns_cd.status |= 0x10;  // DMA transfer begin
13561386      towns_cd.status &= ~0x20;  // not a software transfer
1357      towns_cd.cmd_status_ptr = 0;
1387//      towns_cd.buffer_ptr = 0;
1388//      timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1);
13581389      towns_cd.extra_status = 2;
1359      towns_cd.cmd_status[0] = 0x00;
1360      towns_cd.cmd_status[1] = 0x00;
1361      towns_cd.cmd_status[2] = 0x00;
1362      towns_cd.cmd_status[3] = 0x00;
1363      towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1390      towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
13641391   }
1365   
1366   // start read timer - assume single-speed currently
1367   //timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1);
13681392}
13691393
13701394static void towns_cdrom_play_cdda(const device_config* device)
r6549r6550
13901414   cdda_start_audio(cdda,towns_cd.cdda_current,towns_cd.cdda_length);
13911415   logerror("CD: CD-DA start from LBA:%i length:%i\n",towns_cd.cdda_current,towns_cd.cdda_length);
13921416   
1393   towns_cd.status |= 0x03;
13941417   towns_cd.extra_status = 1;
1395   towns_cd.cmd_status[0] = 0x00;
1396   towns_cd.cmd_status[1] = 0x00;
1397   towns_cd.cmd_status[2] = 0x00;
1398   towns_cd.cmd_status[3] = 0x00;
1399   towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1400   
1418   towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
14011419}
14021420
14031421static void towns_cdrom_execute_command(const device_config* device)
r6549r6550
14061424   {  // No CD in drive
14071425      if(towns_cd.command & 0x20)
14081426      {
1409         towns_cd.status |= 0x02;  // status read request
1410         towns_cd.cmd_status_ptr = 0;
14111427         towns_cd.extra_status = 0;
1412         towns_cd.cmd_status[0] = 0x10;
1413         towns_cd.cmd_status[1] = 0x00;
1414         towns_cd.cmd_status[2] = 0x00;
1415         towns_cd.cmd_status[3] = 0x00;
1416         towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1428         towns_cd_set_status(device->machine,0x10,0x00,0x00,0x00);
14171429      }
14181430   }
14191431   else
r6549r6550
14231435         case 0x00:  // Seek
14241436            if(towns_cd.command & 0x20)
14251437            {
1426               towns_cd.status |= 0x02;  // status read request
1427               towns_cd.cmd_status_ptr = 0;
14281438               towns_cd.extra_status = 1;
1429               towns_cd.cmd_status[0] = 0x00;
1430               towns_cd.cmd_status[1] = 0x00;
1431               towns_cd.cmd_status[2] = 0x00;
1432               towns_cd.cmd_status[3] = 0x00;
1433               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1439               towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
14341440            }
14351441            logerror("CD: Command 0x00: SEEK\n");
14361442            break;
r6549r6550
14441450            break;
14451451         case 0x05:  // Read TOC
14461452            logerror("CD: Command 0x05: READ TOC\n");
1447            towns_cd.status |= 0x02;  // status read request
1448            towns_cd.cmd_status_ptr = 0;
14491453            towns_cd.extra_status = 1;
1450            towns_cd.cmd_status[0] = 0x00;
1451            towns_cd.cmd_status[1] = 0x00;
1452            towns_cd.cmd_status[2] = 0x00;
1453            towns_cd.cmd_status[3] = 0x00;
1454            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1454            towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
14551455            break;
14561456         case 0x06:  // Read CD-DA state?
14571457            logerror("CD: Command 0x06: READ CD-DA STATE\n");
1458            towns_cd.status |= 0x02;  // status read request
1459            towns_cd.cmd_status_ptr = 0;
14601458            towns_cd.extra_status = 1;
1461            towns_cd.cmd_status[0] = 0x00;
1462            towns_cd.cmd_status[1] = 0x00;
1463            towns_cd.cmd_status[2] = 0x00;
1464            towns_cd.cmd_status[3] = 0x00;
1465            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1459            towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
14661460            break;
14671461         case 0x80:  // set state
14681462            if(towns_cd.command & 0x20)
14691463            {
1470               towns_cd.status |= 0x02;  // status read request
1471               towns_cd.cmd_status_ptr = 0;
14721464               towns_cd.extra_status = 0;
1473               towns_cd.cmd_status[0] = 0x00;
1474               towns_cd.cmd_status[1] = 0x01;
1475               towns_cd.cmd_status[2] = 0x00;
1476               towns_cd.cmd_status[3] = 0x00;
14771465               if(cdda_audio_active(devtag_get_device(device->machine,"cdda")))
1478               {
1479                  towns_cd.cmd_status[0] = 0x00;
1480                  towns_cd.cmd_status[1] |= 0x02;
1481               }
1482               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1466                  towns_cd_set_status(device->machine,0x00,0x03,0x00,0x00);
1467               else
1468                  towns_cd_set_status(device->machine,0x00,0x01,0x00,0x00);
1469
14831470            }
14841471            logerror("CD: Command 0x80: set state\n");
14851472            break;
14861473         case 0x81:  // set state (CDDASET)
14871474            if(towns_cd.command & 0x20)
14881475            {
1489               towns_cd.status |= 0x02;  // status read request
1490               towns_cd.cmd_status_ptr = 0;
14911476               towns_cd.extra_status = 0;
1492               towns_cd.cmd_status[0] = 0x00;
1493               towns_cd.cmd_status[1] = 0x00;
1494               towns_cd.cmd_status[2] = 0x00;
1495               towns_cd.cmd_status[3] = 0x00;
1496               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1477               towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
14971478            }
14981479            logerror("CD: Command 0x81: set state (CDDASET)\n");
14991480            break;
15001481         case 0x84:   // Unknown (status?)
15011482            if(towns_cd.command & 0x20)
15021483            {
1503               towns_cd.status |= 0x02;  // status read request
1504               towns_cd.cmd_status_ptr = 0;
15051484               towns_cd.extra_status = 1;
1506               towns_cd.cmd_status[0] = 0x00;
1507               towns_cd.cmd_status[1] = 0x00;
1508               towns_cd.cmd_status[2] = 0x00;
1509               towns_cd.cmd_status[3] = 0x00;
1485               towns_cd_set_status(device->machine,0x00,0x00,0x00,0x00);
15101486               cdda_stop_audio(devtag_get_device(device->machine,"cdda"));
1511               towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
15121487            }
15131488            logerror("CD: Command 0x84: STOP CD-DA\n");
15141489            break;
15151490         default:
1516            towns_cd.status |= 0x02;  // status read request
1517            towns_cd.cmd_status_ptr = 0;
15181491            towns_cd.extra_status = 0;
1519            towns_cd.cmd_status[0] = 0x10;
1520            towns_cd.cmd_status[1] = 0x00;
1521            towns_cd.cmd_status[2] = 0x00;
1522            towns_cd.cmd_status[3] = 0x00;
1523            towns_cdrom_set_irq(device->machine,TOWNS_CD_IRQ_MPU,1);
1492            towns_cd_set_status(device->machine,0x10,0x00,0x00,0x00);
15241493            logerror("CD: Unknown or unimplemented command %02x\n",towns_cd.command);
15251494      }
15261495   }
r6549r6550
15521521            // check for more status bytes
15531522            if(towns_cd.extra_status != 0)
15541523            {
1555               towns_cd.status |= 0x02;
15561524               switch(towns_cd.command & 0x9f)
15571525               {
15581526                  case 0x00:  // seek
1559                     towns_cd.cmd_status[0] = 0x04;
1560                     towns_cd.cmd_status[1] = 0x00;
1561                     towns_cd.cmd_status[2] = 0x00;
1562                     towns_cd.cmd_status[3] = 0x00;
1527                     towns_cd_set_status(space->machine,0x04,0x00,0x00,0x00);
15631528                     towns_cd.extra_status = 0;
15641529                     break;
15651530                  case 0x02:  // read
15661531                     if(towns_cd.extra_status == 2)
1567                     {
1568                        towns_cd.cmd_status[0] = 0x22;
1569                     }
1570                     else
1571                        towns_cd.cmd_status[0] = 0x06;
1572                     towns_cd.cmd_status[1] = 0x00;
1573                     towns_cd.cmd_status[2] = 0x00;
1574                     towns_cd.cmd_status[3] = 0x00;
1532                        towns_cd_set_status(space->machine,0x22,0x00,0x00,0x00);
15751533                     towns_cd.extra_status = 0;
15761534                     break;
15771535                  case 0x04:  // play cdda
1578                     towns_cd.cmd_status[0] = 0x07;
1579                     towns_cd.cmd_status[1] = 0x00;
1580                     towns_cd.cmd_status[2] = 0x00;
1581                     towns_cd.cmd_status[3] = 0x00;
1536                     towns_cd_set_status(space->machine,0x07,0x00,0x00,0x00);
15821537                     towns_cd.extra_status = 0;
15831538                     break;
15841539                  case 0x05:  // read toc
r6549r6550
15861541                     {
15871542                        case 1:
15881543                        case 3:
1589                           towns_cd.cmd_status[0] = 0x16;
1590                           towns_cd.cmd_status[1] = 0x00;
1591                           towns_cd.cmd_status[2] = 0x00;
1592                           towns_cd.cmd_status[3] = 0x00;
1544                           towns_cd_set_status(space->machine,0x16,0x00,0x00,0x00);
15931545                           towns_cd.extra_status++;
15941546                           break;
15951547                        case 2: // st1 = first track number (BCD)
1596                           towns_cd.cmd_status[0] = 0x17;
1597                           towns_cd.cmd_status[1] = 0x01;
1598                           towns_cd.cmd_status[2] = 0x00;
1599                           towns_cd.cmd_status[3] = 0x00;
1548                           towns_cd_set_status(space->machine,0x17,0x01,0x00,0x00);
16001549                           towns_cd.extra_status++;
16011550                           break;
16021551                        case 4: // st1 = last track number (BCD)
1603                           towns_cd.cmd_status[0] = 0x17;
1604                           towns_cd.cmd_status[1] = byte_to_bcd(cdrom_get_last_track(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom"))));
1605                           towns_cd.cmd_status[2] = 0x00;
1606                           towns_cd.cmd_status[3] = 0x00;
1552                           towns_cd_set_status(space->machine,0x17,
1553                              byte_to_bcd(cdrom_get_last_track(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")))),
1554                              0x00,0x00);
16071555                           towns_cd.extra_status++;
16081556                           break;
16091557                        case 5:  // st1 = control/adr of track 0xaa?
1610                           towns_cd.cmd_status[0] = 0x16;
1611                           towns_cd.cmd_status[1] = cdrom_get_adr_control(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),0xaa);
1612                           towns_cd.cmd_status[2] = 0xaa;
1613                           towns_cd.cmd_status[3] = 0x00;
1558                           towns_cd_set_status(space->machine,0x16,
1559                              cdrom_get_adr_control(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),0xaa),
1560                              0xaa,0x00);
16141561                           towns_cd.extra_status++;
16151562                           break;
16161563                        case 6:  // st1/2/3 = address of track 0xaa? (BCD)
16171564                           addr = cdrom_get_track_start(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),0xaa);
16181565                           addr = lba_to_msf(addr);
1619                           towns_cd.cmd_status[0] = 0x17;
1620                           towns_cd.cmd_status[1] = (addr & 0xff0000) >> 16;
1621                           towns_cd.cmd_status[2] = (addr & 0x00ff00) >> 8;
1622                           towns_cd.cmd_status[3] = addr & 0x0000ff;
1566                           towns_cd_set_status(space->machine,0x17,
1567                              (addr & 0xff0000) >> 16,(addr & 0x00ff00) >> 8,addr & 0x0000ff);
16231568                           towns_cd.extra_status++;
16241569                           break;   
16251570                        default:  // same as case 5 and 6, but for each individual track
16261571                           if(towns_cd.extra_status & 0x01)
16271572                           {
1628                              towns_cd.cmd_status[0] = 0x16;
1629                              towns_cd.cmd_status[1] = (cdrom_get_adr_control(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),(towns_cd.extra_status/2)-3) & 0x0f) << 4;
1630                              towns_cd.cmd_status[1] |= (cdrom_get_adr_control(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),(towns_cd.extra_status/2)-3) & 0xf0) >> 4;
1631                              towns_cd.cmd_status[2] = (towns_cd.extra_status/2)-3;
1632                              towns_cd.cmd_status[3] = 0x00;
1573                              towns_cd_set_status(space->machine,0x16,
1574                                 ((cdrom_get_adr_control(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),(towns_cd.extra_status/2)-3) & 0x0f) << 4)
1575                                 | ((cdrom_get_adr_control(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),(towns_cd.extra_status/2)-3) & 0xf0) >> 4),
1576                                 (towns_cd.extra_status/2)-3,0x00);
16331577                              towns_cd.extra_status++;
16341578                           }
16351579                           else
16361580                           {
16371581                              addr = cdrom_get_track_start(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom")),(towns_cd.extra_status/2)-4);
16381582                              addr = lba_to_msf(addr);
1639                              towns_cd.cmd_status[0] = 0x17;
1640                              towns_cd.cmd_status[1] = (addr & 0xff0000) >> 16;
1641                              towns_cd.cmd_status[2] = (addr & 0x00ff00) >> 8;
1642                              towns_cd.cmd_status[3] = addr & 0x0000ff;
1583                              towns_cd_set_status(space->machine,0x17,
1584                                 (addr & 0xff0000) >> 16,(addr & 0x00ff00) >> 8,addr & 0x0000ff);
16431585                              if(((towns_cd.extra_status/2)-3) >= cdrom_get_last_track(mess_cd_get_cdrom_file(devtag_get_device(space->machine,"cdrom"))))
16441586                              {
16451587                                 towns_cd.extra_status = 0;
r6549r6550
16541596                     switch(towns_cd.extra_status)
16551597                     {
16561598                        case 1:  // st2 = track number
1657                           towns_cd.cmd_status[0] = 0x18;
1658                           towns_cd.cmd_status[1] = 0x00;
1659                           towns_cd.cmd_status[2] = towns_cd_get_track(space->machine);  // track number
1660                           towns_cd.cmd_status[3] = 0x00;
1599                           towns_cd_set_status(space->machine,0x18,
1600                              0x00,towns_cd_get_track(space->machine),0x00);
16611601                           towns_cd.extra_status++;
16621602                           break;
16631603                        case 2:  // st0/1/2 = MSF from beginning of current track
16641604                           addr = cdda_get_audio_lba(devtag_get_device(space->machine,"cdda"));
16651605                           addr = lba_to_msf(addr - towns_cd.cdda_current); 
1666                           towns_cd.cmd_status[0] = 0x19;
1667                           towns_cd.cmd_status[1] = (addr & 0xff0000) >> 16;
1668                           towns_cd.cmd_status[2] = (addr & 0x00ff00) >> 8;
1669                           towns_cd.cmd_status[3] = addr & 0x0000ff;
1606                           towns_cd_set_status(space->machine,0x19,
1607                              (addr & 0xff0000) >> 16,(addr & 0x00ff00) >> 8,addr & 0x0000ff);
16701608                           towns_cd.extra_status++;
16711609                           break;
16721610                        case 3:  // st1/2 = current MSF
16731611                           addr = cdda_get_audio_lba(devtag_get_device(space->machine,"cdda"));
16741612                           addr = lba_to_msf(addr);  // this data is incorrect, but will do until exact meaning is found
1675                           towns_cd.cmd_status[0] = 0x19;
1676                           towns_cd.cmd_status[1] = 0;
1677                           towns_cd.cmd_status[2] = (addr & 0xff0000) >> 16;
1678                           towns_cd.cmd_status[3] = (addr & 0x00ff00) >> 8;
1613                           towns_cd_set_status(space->machine,0x19,
1614                              0x00,(addr & 0xff0000) >> 16,(addr & 0x00ff00) >> 8);
16791615                           towns_cd.extra_status++;
16801616                           break;
16811617                        case 4:
16821618                           addr = cdda_get_audio_lba(devtag_get_device(space->machine,"cdda"));
16831619                           addr = lba_to_msf(addr);  // this data is incorrect, but will do until exact meaning is found
1684                           towns_cd.cmd_status[0] = 0x20;
1685                           towns_cd.cmd_status[1] = addr & 0x0000ff;
1686                           towns_cd.cmd_status[2] = 0x00;
1687                           towns_cd.cmd_status[3] = 0x00;
1620                           towns_cd_set_status(space->machine,0x20,
1621                              addr & 0x0000ff,0x00,0x00);
16881622                           towns_cd.extra_status = 0;
16891623                           break;
16901624                     }
16911625                     break;
16921626                  case 0x84:
1693                     towns_cd.cmd_status[0] = 0x11;
1694                     towns_cd.cmd_status[1] = 0x00;
1695                     towns_cd.cmd_status[2] = 0x00;
1696                     towns_cd.cmd_status[3] = 0x00;
1627                     towns_cd_set_status(space->machine,0x11,0x00,0x00,0x00);
16971628                     towns_cd.extra_status = 0;
16981629                     break;
16991630               }
17001631            }
17011632         }
1702         logerror("CD: reading command status port, returning %02x\n",ret);
1633         logerror("CD: reading command status port (%i), returning %02x\n",towns_cd.cmd_status_ptr,ret);
17031634         towns_cd.cmd_status_ptr++;
17041635         if(towns_cd.cmd_status_ptr > 3)
1636         {
17051637            towns_cd.cmd_status_ptr = 0;
1638/*            if(towns_cd.extra_status != 0)
1639            {
1640               towns_cdrom_set_irq(space->machine,TOWNS_CD_IRQ_MPU,1);
1641               towns_cd.status |= 0x02;
1642            }*/
1643         }
17061644         return ret;
17071645      default:
17081646         return 0x00;
r6549r6550
17461684         {
17471685            towns_cd.status |= 0x10;  // DMA transfer begin
17481686            towns_cd.status &= ~0x20;  // not a software transfer
1749            towns_cd.buffer_ptr = 0;
1750            timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1);
1687            if(towns_cd.buffer_ptr < 0)
1688            {
1689               towns_cd.buffer_ptr = 0;
1690               timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),1);
1691            }
17511692         }
1693         logerror("CD: transfer mode write %02x\n",data);
17521694         break;
17531695      default:
17541696         logerror("CD: write %02x to port %02x\n",data,offset*2);
r6549r6550
22572199   towns_kb_status = 0x18;
22582200   towns_kb_irq1_enable = 0;
22592201   towns_cd.status = 0x01;  // CDROM controller ready
2202   towns_cd.buffer_ptr = -1;
22602203   timer_adjust_periodic(towns_rtc_timer,attotime_zero,0,ATTOTIME_IN_HZ(1));
22612204   timer_adjust_periodic(towns_kb_timer,attotime_zero,0,ATTOTIME_IN_MSEC(10));
22622205}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team