src/mess/drivers/fmtowns.c
| r6586 | r6587 | |
| 852 | 852 | |
| 853 | 853 | static READ32_HANDLER(towns_padport_r) |
| 854 | 854 | { |
| 855 | logerror("PADPORT: read mask %08x\n",mem_mask); |
| 855 | 856 | if(ACCESSING_BITS_0_7) |
| 856 | 857 | return 0x7f; |
| 857 | 858 | |
| r6586 | r6587 | |
| 1255 | 1256 | towns_cd.cmd_status[2] = st2; |
| 1256 | 1257 | towns_cd.cmd_status[3] = st3; |
| 1257 | 1258 | // 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); |
| 1259 | 1260 | } |
| 1260 | 1261 | |
| 1261 | 1262 | static UINT8 towns_cd_get_track(running_machine* machine) |
| r6586 | r6587 | |
| 1283 | 1284 | return; |
| 1284 | 1285 | |
| 1285 | 1286 | 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); |
| 1287 | 1288 | if(param != 0) |
| 1288 | 1289 | { |
| 1289 | 1290 | timer_adjust_oneshot(towns_cd.read_timer,ATTOTIME_IN_HZ(300000),0); |
| r6586 | r6587 | |
| 1332 | 1333 | // parameters: |
| 1333 | 1334 | // 3 bytes: MSF of first sector to read |
| 1334 | 1335 | // 3 bytes: MSF of last sector to read |
| 1335 | | UINT32 lba1,lba2; |
| 1336 | UINT32 lba1,lba2,track; |
| 1336 | 1337 | |
| 1337 | 1338 | lba1 = towns_cd.parameter[7] << 16; |
| 1338 | 1339 | lba1 += towns_cd.parameter[6] << 8; |
| r6586 | r6587 | |
| 1344 | 1345 | towns_cd.lba_last = msf_to_lba(lba2); |
| 1345 | 1346 | |
| 1346 | 1347 | // 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) |
| 1348 | 1350 | { // recalculate LBA |
| 1349 | | if(towns_cd.parameter[6] < 2) |
| 1351 | if((towns_cd.parameter[6] & 0x0f) < 2) |
| 1350 | 1352 | { |
| 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 | } |
| 1353 | 1366 | } |
| 1354 | 1367 | else |
| 1355 | 1368 | { |
| 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); |
| 1358 | 1371 | } |
| 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) |
| 1361 | 1374 | { |
| 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 | } |
| 1364 | 1388 | } |
| 1365 | 1389 | else |
| 1366 | 1390 | { |
| 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); |
| 1369 | 1393 | } |
| 1370 | | lba2 += towns_cd.parameter[2]; |
| 1394 | lba2 |= towns_cd.parameter[2]; |
| 1371 | 1395 | towns_cd.lba_current = msf_to_lba(lba1); |
| 1372 | 1396 | towns_cd.lba_last = msf_to_lba(lba2); |
| 1373 | 1397 | } |
| 1374 | 1398 | |
| 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); |
| 1376 | 1400 | |
| 1377 | 1401 | if(towns_cd.lba_current > towns_cd.lba_last) |
| 1378 | 1402 | { |
| r6586 | r6587 | |
| 1462 | 1486 | if(towns_cd.command & 0x20) |
| 1463 | 1487 | { |
| 1464 | 1488 | 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 | } |
| 1465 | 1494 | if(cdda_audio_active(devtag_get_device(device->machine,"cdda"))) |
| 1466 | 1495 | towns_cd_set_status(device->machine,0x00,0x03,0x00,0x00); |
| 1467 | 1496 | else |
| r6586 | r6587 | |
| 2166 | 2195 | { |
| 2167 | 2196 | towns_vram = auto_alloc_array(machine,UINT32,0x20000); |
| 2168 | 2197 | 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); |
| 2170 | 2199 | towns_txtvram = auto_alloc_array(machine,UINT8,0x20000); |
| 2171 | 2200 | towns_serial_rom = auto_alloc_array(machine,UINT8,256/8); |
| 2172 | 2201 | towns_init_serial_rom(machine); |