• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

Common Source Code Project for Qt (a.k.a for FM-7).


Commit MetaInfo

Revisão7f8d701b417137795038e8c24df116e01a878bb5 (tree)
Hora2020-02-15 23:20:24
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Mensagem de Log

[VM][FMTOWNS][CDROM][SCSI_DEV][WIP] Implementing CDC and CDROM.

Mudança Sumário

Diff

--- a/source/src/vm/fmtowns/cdc.cpp
+++ b/source/src/vm/fmtowns/cdc.cpp
@@ -7,6 +7,7 @@
77
88 #include "cdc.h"
99 #include "../../fifo.h"
10+
1011 #include "../scsi_host.h"
1112 #include "../upd71071.h"
1213 #include "towns_cdrom.h"
@@ -21,14 +22,14 @@ namespace FMTOWNS {
2122 void CDC::set_context_scsi_host(SCSI_HOST* dev)
2223 {
2324 d_scsi_host = dev;
24- d_scsi_host->set_context_irq(this, SIG_TOWNS_CDC_IRQ, 0xffffffff);
25- d_scsi_host->set_context_drq(this, SIG_TOWNS_CDC_DRQ, 0xffffffff);
26- d_scsi_host->set_context_bsy(this, SIG_TOWNS_CDC_BSY, 0xffffffff);
27- d_scsi_host->set_context_cd(this, SIG_TOWNS_CDC_CD, 0xffffffff);
28- d_scsi_host->set_context_io(this, SIG_TOWNS_CDC_IO, 0xffffffff);
29- d_scsi_host->set_context_msg(this, SIG_TOWNS_CDC_MSG, 0xffffffff);
30- d_scsi_host->set_context_req(this, SIG_TOWNS_CDC_REQ, 0xffffffff);
31- d_scsi_host->set_context_ack(this, SIG_TOWNS_CDC_ACK, 0xffffffff);
25+ d_scsi_host->set_context_irq(this, SIG_TOWNS_CDC_IRQ, 1 << 0);
26+ d_scsi_host->set_context_drq(this, SIG_TOWNS_CDC_DRQ, 1 << 0);
27+ d_scsi_host->set_context_bsy(this, SIG_TOWNS_CDC_BSY, 1 << 0);
28+ d_scsi_host->set_context_cd(this, SIG_TOWNS_CDC_CD, 1 << 0);
29+ d_scsi_host->set_context_io(this, SIG_TOWNS_CDC_IO, 1 << 0);
30+ d_scsi_host->set_context_msg(this, SIG_TOWNS_CDC_MSG, 1 << 0);
31+ d_scsi_host->set_context_req(this, SIG_TOWNS_CDC_REQ, 1 << 0);
32+ d_scsi_host->set_context_ack(this, SIG_TOWNS_CDC_ACK, 1 << 0);
3233 }
3334
3435
@@ -40,9 +41,10 @@ void CDC::set_context_cdrom(TOWNS_CDROM* dev)
4041
4142 void CDC::reset()
4243 {
43- param_fifo->clear();
4444 stat_fifo->clear();
45-
45+ memset(param_queue, 0x00, sizeof(param_queue));
46+ param_ptr = 0;
47+
4648 has_status = false;
4749 extra_status = 0;
4850 submpu_ready = true;
@@ -60,13 +62,12 @@ void CDC::reset()
6062 command_type_play = false; // false = status command
6163 stat_reply_intr = false;
6264 req_status = false;
63-
65+ readptr = 0;
6466 d_scsi_host->reset();
6567 }
6668
6769 void CDC::initialize()
6870 {
69- param_fifo = new FIFO(6); //
7071 stat_fifo = new FIFO(4);
7172
7273 submpu_ready = true;
@@ -88,10 +89,8 @@ void CDC::initialize()
8889
8990 void CDC::release()
9091 {
91- param_fifo->release();
9292 stat_fifo->release();
9393
94- delete param_fifo;
9594 delete stat_fifo;
9695 }
9796 void CDC::write_io8(uint32_t address, uint32_t data)
@@ -114,7 +113,9 @@ void CDC::write_io8(uint32_t address, uint32_t data)
114113 if(dma_intr) write_signals(&output_dma_intr, 0x00000000);
115114 dma_intr = false;
116115 }
117- if((data & 0x04) != 0) this->reset();
116+ if((data & 0x04) != 0) {
117+ reset();
118+ }
118119 submpu_intr_mask = ((data & 0x02) != 0) ? true : false;
119120 dma_intr_mask = ((data & 0x01) != 0) ? true : false;
120121 w_regs[address & 0x0f] = data;
@@ -125,29 +126,32 @@ void CDC::write_io8(uint32_t address, uint32_t data)
125126 command_type_play = ((data & 0x80) != 0) ? false : true; // false = status command
126127 stat_reply_intr = ((data & 0x40) != 0) ? true : false;
127128 req_status = ((data & 0x20) != 0) ? true : false;
129+ w_regs[address & 0x0f] = data;
130+ readptr = 0;
128131 if(command_type_play) {
129132 enqueue_command_play(data);
130133 } else {
131134 enqueue_command_status(data);
132135 }
133- w_regs[address & 0x0f] = data;
134136 }
137+ param_ptr = 0;
138+
139+// memset(param_queue, 0x00, sizeof(param_queue));
135140 break;
136141 case 0x04: // Parameter register
137- if(submpu_ready) {
138- if(param_fifo->full()) {
139- param_fifo->read(); // Dummy read
140- }
141- param_fifo->write((int)(data & 0xff));
142- w_regs[address & 0x0f] = data;
143- }
142+ param_queue[param_ptr] = data;
143+ param_ptr = (param_ptr + 1) & 0x07;
144144 break;
145145 case 0x06:
146- {
147- dma_transfer = ((data & 0x10) != 0) ? true : false;
148- pio_transfer = ((data & 0x08) != 0) ? true : false;
149- w_regs[address & 0x0f] = data;
150- }
146+ if((data & 0x08) != 0) {
147+ dma_transfer = false;
148+ pio_transfer = true;
149+ }
150+ if((data & 0x10) != 0) {
151+ dma_transfer = true;
152+ pio_transfer = false;
153+ }
154+ w_regs[address & 0x0f] = data;
151155 break;
152156 default:
153157 if((address & 0x01) == 0) {
@@ -290,6 +294,8 @@ uint32_t CDC::read_io8(uint32_t address)
290294 case 0x4: //
291295 if(pio_transfer) {
292296 val = d_scsi_host->read_dma_io8(0);
297+ out_debug_log(_T("PIO READ PTR=%d DATA=%02X"), readptr, val);
298+ readptr++;
293299 }
294300 break;
295301 case 0xc: // Sub code status register
@@ -314,34 +320,27 @@ void CDC::read_cdrom(bool req_reply)
314320
315321 uint8_t m1, s1, f1;
316322 uint8_t m2, s2, f2;
317- f2 = (uint8_t)(param_fifo->read() & 0xff);
318- s2 = (uint8_t)(param_fifo->read() & 0xff);
319- m2 = (uint8_t)(param_fifo->read() & 0xff);
323+// uint8_t pad1, dcmd;
320324
321- f1 = (uint8_t)(param_fifo->read() & 0xff);
322- s1 = (uint8_t)(param_fifo->read() & 0xff);
323- m1 = (uint8_t)(param_fifo->read() & 0xff);
325+ m1 = FROM_BCD(param_queue[0]);
326+ s1 = FROM_BCD(param_queue[1]);
327+ f1 = FROM_BCD(param_queue[2]);
324328
325- uint32_t lba1 = ((uint32_t)m1 & 0x1f) * 0x10000 + ((uint32_t)s1) * 0x100 + (uint32_t)f1;
326- uint32_t lba2 = ((uint32_t)m2 & 0x1f) * 0x10000 + ((uint32_t)s2) * 0x100 + (uint32_t)f2;
329+ m2 = FROM_BCD(param_queue[3]);
330+ s2 = FROM_BCD(param_queue[4]);
331+ f2 = FROM_BCD(param_queue[5]);
332+ uint8_t pad1 = param_queue[6];
333+ uint8_t dcmd = param_queue[7];
334+
335+ int32_t lba1 = ((m1 * (60 * 75)) + (s1 * 75) + f1) - 150;
336+ int32_t lba2 = ((m2 * (60 * 75)) + (s2 * 75) + f2) - 150;
337+
327338 uint32_t __remain;
328339 int track = 0;
329340 if(d_cdrom != NULL) {
330341 track = d_cdrom->get_track(lba1);
331342 }
332- out_debug_log(_T("READ_CDROM TRACK=%d LBA1=%06X LBA2=%06X F1/S1/M1=%02X/%02X/%02X F2/S2/M2=%02X/%02X/%02X"), track, lba1, lba2, f1, s1, m1, f2, s2, m2);
333- if(track < 2) {
334- if(lba1 >= 150) {
335- lba1 = lba1 - 150;
336- } else {
337- lba1 = 0;
338- }
339- if(lba2 >= 150) {
340- lba2 = lba2 - 150;
341- } else {
342- lba2 = 0;
343- }
344- }
343+ out_debug_log(_T("READ_CDROM TRACK=%d LBA1=%06X LBA2=%06X F1/S1/M1=%02X/%02X/%02X F2/S2/M2=%02X/%02X/%02X PAD=%02X DCMD=%02X"), track, lba1, lba2, f1, s1, m1, f2, s2, m2, pad1, dcmd);
345344 if(d_cdrom != NULL) {
346345 d_cdrom->set_cdda_status(CDDA_OFF);
347346 }
@@ -353,15 +352,15 @@ void CDC::read_cdrom(bool req_reply)
353352 __remain = lba2 - lba1;
354353 //seek_time = get_seek_time(lba1);
355354
356- command[0] = SCSI_CMD_READ12;
357- command[1] = 0; // LUN = 0
358- command[2] = 0;
359- command[3] = m2 & 0x1f;
360- command[4] = s2;
361- command[5] = f2;
355+ command[0] = SCSI_CMD_READ10;
356+ command[1] = 0;
357+ command[2] = 0;
358+ command[3] = m1;
359+ command[4] = s1;
360+ command[5] = f1;
362361
363- command[6] = 0;
364- command[7] = (uint8_t)((__remain / 0x10000) & 0xff);
362+ command[4] = 0;
363+ command[5] = (uint8_t)((__remain / 0x10000) & 0xff);
365364 command[8] = (uint8_t)((__remain / 0x100) & 0xff);
366365 command[9] = (uint8_t) (__remain % 0x100);
367366
@@ -387,16 +386,31 @@ void CDC::stop_cdda(bool req_reply)
387386 if(req_reply) write_status(0x10, 0x00, 0x00, 0x00);
388387 return;
389388 }
389+
390+ uint8_t m1, s1, f1;
391+ uint8_t m2, s2, f2;
392+
393+ m1 = FROM_BCD(param_queue[0]);
394+ s1 = FROM_BCD(param_queue[1]);
395+ f1 = FROM_BCD(param_queue[2]);
396+
397+ m2 = FROM_BCD(param_queue[3]);
398+ s2 = FROM_BCD(param_queue[4]);
399+ f2 = FROM_BCD(param_queue[5]);
400+ uint8_t pad1 = param_queue[6];
401+ uint8_t dcmd = param_queue[7];
402+
390403 command[0] = TOWNS_CDROM_CDDA_STOP;
391404 command[1] = 0;
392405 command[2] = 0;
393- command[3] = (uint8_t)(param_fifo->read() & 0xff);
394- command[4] = (uint8_t)(param_fifo->read() & 0xff);
395- command[5] = (uint8_t)(param_fifo->read() & 0xff);
406+ command[3] = f1;
407+ command[4] = s1;
408+ command[5] = m1;
396409 command[6] = 0;
397- command[7] = (uint8_t)(param_fifo->read() & 0xff);
398- command[8] = (uint8_t)(param_fifo->read() & 0xff);
399- command[9] = (uint8_t)(param_fifo->read() & 0xff);
410+ command[7] = f2;
411+ command[8] = s2;
412+ command[9] = m2;
413+
400414 if(req_reply) {
401415 extra_status = 1;
402416 write_status(0x00, 0x00, 0x00, 0x00);
@@ -412,16 +426,30 @@ void CDC::stop_cdda2(bool req_reply)
412426 if(req_reply) write_status(0x10, 0x00, 0x00, 0x00);
413427 return;
414428 }
429+ uint8_t m1, s1, f1;
430+ uint8_t m2, s2, f2;
431+
432+ m1 = FROM_BCD(param_queue[0]);
433+ s1 = FROM_BCD(param_queue[1]);
434+ f1 = FROM_BCD(param_queue[2]);
435+
436+ m2 = FROM_BCD(param_queue[3]);
437+ s2 = FROM_BCD(param_queue[4]);
438+ f2 = FROM_BCD(param_queue[5]);
439+ uint8_t pad1 = param_queue[6];
440+ uint8_t dcmd = param_queue[7];
441+
415442 command[0] = TOWNS_CDROM_CDDA_STOP;
416443 command[1] = 0;
417444 command[2] = 0;
418- command[3] = (uint8_t)(param_fifo->read() & 0xff);
419- command[4] = (uint8_t)(param_fifo->read() & 0xff);
420- command[5] = (uint8_t)(param_fifo->read() & 0xff);
445+ command[3] = f1;
446+ command[4] = m1;
447+ command[5] = s1;
421448 command[6] = 0;
422- command[7] = (uint8_t)(param_fifo->read() & 0xff);
423- command[8] = (uint8_t)(param_fifo->read() & 0xff);
424- command[9] = (uint8_t)(param_fifo->read() & 0xff);
449+ command[7] = f2;
450+ command[8] = m2;
451+ command[9] = s2;
452+
425453 if(req_reply) {
426454 extra_status = 1;
427455 write_status(0x00, 0x00, 0x00, 0x00);
@@ -437,16 +465,30 @@ void CDC::unpause_cdda(bool req_reply)
437465 if(req_reply) write_status(0x10, 0x00, 0x00, 0x00);
438466 return;
439467 }
468+ uint8_t m1, s1, f1;
469+ uint8_t m2, s2, f2;
470+
471+ m1 = FROM_BCD(param_queue[0]);
472+ s1 = FROM_BCD(param_queue[1]);
473+ f1 = FROM_BCD(param_queue[2]);
474+
475+ m2 = FROM_BCD(param_queue[3]);
476+ s2 = FROM_BCD(param_queue[4]);
477+ f2 = FROM_BCD(param_queue[5]);
478+ uint8_t pad1 = param_queue[6];
479+ uint8_t dcmd = param_queue[7];
480+
440481 command[0] = TOWNS_CDROM_CDDA_UNPAUSE;
441482 command[1] = 0;
442483 command[2] = 0;
443- command[3] = (uint8_t)(param_fifo->read() & 0xff);
444- command[4] = (uint8_t)(param_fifo->read() & 0xff);
445- command[5] = (uint8_t)(param_fifo->read() & 0xff);
484+ command[3] = f1;
485+ command[4] = m1;
486+ command[5] = s1;
446487 command[6] = 0;
447- command[7] = (uint8_t)(param_fifo->read() & 0xff);
448- command[8] = (uint8_t)(param_fifo->read() & 0xff);
449- command[9] = (uint8_t)(param_fifo->read() & 0xff);
488+ command[7] = f2;
489+ command[8] = m2;
490+ command[9] = s2;
491+
450492 if(req_reply) {
451493 extra_status = 1;
452494 write_status(0x00, 0x03, 0x00, 0x00);
@@ -462,17 +504,29 @@ void CDC::play_cdda(bool req_reply)
462504 if(req_reply) write_status(0x10, 0x00, 0x00, 0x00);
463505 return;
464506 }
507+ uint8_t m1, s1, f1;
508+ uint8_t m2, s2, f2;
509+
510+ m1 = FROM_BCD(param_queue[0]);
511+ s1 = FROM_BCD(param_queue[1]);
512+ f1 = FROM_BCD(param_queue[2]);
513+
514+ m2 = FROM_BCD(param_queue[3]);
515+ s2 = FROM_BCD(param_queue[4]);
516+ f2 = FROM_BCD(param_queue[5]);
517+ uint8_t pad1 = param_queue[6];
518+ uint8_t dcmd = param_queue[7];
519+
465520 command[0] = TOWNS_CDROM_CDDA_PLAY;
466521 command[1] = 0;
467522 command[2] = 0;
468- command[3] = (uint8_t)(param_fifo->read() & 0xff);
469- command[4] = (uint8_t)(param_fifo->read() & 0xff);
470- command[5] = (uint8_t)(param_fifo->read() & 0xff);
523+ command[3] = f1;
524+ command[4] = m1;
525+ command[5] = s1;
471526 command[6] = 0;
472- command[7] = (uint8_t)(param_fifo->read() & 0xff);
473- command[8] = (uint8_t)(param_fifo->read() & 0xff);
474- command[9] = (uint8_t)(param_fifo->read() & 0xff);
475-
527+ command[7] = f2;
528+ command[8] = m2;
529+ command[9] = s2;
476530
477531 if(req_reply) {
478532 extra_status = 1;
@@ -504,14 +558,17 @@ void CDC::enqueue_command_play(uint8_t cmd)
504558 {
505559 //write_signals(&output_submpu_intr, 0x00000000);
506560 if((d_cdrom->read_signal(SIG_TOWNS_CDROM_IS_MEDIA_INSERTED) == 0x00000000) && (cmd != 0xa0)) { // Not Inserted
561+ out_debug_log(_T("CMD (%02X) BUT DISC NOT ACTIVE"), cmd);
507562 if(req_status) {
508563 extra_status = 0;
509564 write_status(0x10, 0x00, 0x00, 0x00);
510565 }
511566 } else {
512567 has_status = false;
568+ d_scsi_host->write_dma_io8(0, 0x81); // SELECT SCSI 0
513569 switch(cmd & 0x1f) {
514570 case 0x00: // SEEK
571+ out_debug_log(_T("CMD SEEK (%02X)"), cmd);
515572 if(req_status) {
516573 extra_status = 1;
517574 write_status(0x00, 0x00, 0x00, 0x00);
@@ -519,18 +576,22 @@ void CDC::enqueue_command_play(uint8_t cmd)
519576 // ToDo: REAL SEEK
520577 break;
521578 case 0x01: // Unknown (from MAME)
579+ out_debug_log(_T("CMD UNKNOWN (%02X)"), cmd);
522580 if(req_status) {
523581 extra_status = 0;
524582 write_status(0x00, 0xff, 0xff, 0xff);
525583 }
526584 break;
527585 case 0x02: // READ (Mode1)
586+ out_debug_log(_T("CMD READ MODE1 (%02X)"), cmd);
528587 read_cdrom(req_status);
529588 break;
530589 case 0x04: // PLAY CDDA
590+ out_debug_log(_T("CMD PLAY CDDA (%02X)"), cmd);
531591 play_cdda(req_status);
532592 break;
533593 case 0x05: // Read TOC
594+ out_debug_log(_T("CMD READ TOC (%02X)"), cmd);
534595 if(req_status) {
535596 extra_status = 1;
536597 write_status(0x00, 0x00, 0x00, 0x00);
@@ -540,14 +601,17 @@ void CDC::enqueue_command_play(uint8_t cmd)
540601 }
541602 break;
542603 case 0x06: // CD-DA Stats (?)
604+ out_debug_log(_T("CMD READ CD-DA STATUS (%02X)"), cmd);
543605 extra_status = 1;
544606 write_status(0x00, 0x00, 0x00, 0x00);
545607 break;
546608 case 0x1f: // ??
609+ out_debug_log(_T("CMD UNKNOWN (%02X)"), cmd);
547610 extra_status = 0;
548611 write_status(0x00, 0x00, 0x00, 0x00);
549612 break;
550613 default: // Illegal command
614+ out_debug_log(_T("CMD Illegal(%02X)"), cmd);
551615 extra_status = 0;
552616 write_status(0x10, 0x00, 0x00, 0x00);
553617 break;
@@ -559,14 +623,17 @@ void CDC::enqueue_command_status(uint8_t cmd)
559623 {
560624 //write_signals(&output_submpu_intr, 0x00000000);
561625 if((d_cdrom->read_signal(SIG_TOWNS_CDROM_IS_MEDIA_INSERTED) == 0x00000000) && (cmd != 0xa0)) { // Not Inserted
626+ out_debug_log(_T("CMD (%02X) BUT DISC NOT ACTIVE"), cmd);
562627 if(req_status) {
563628 extra_status = 0;
564629 write_status(0x10, 0x00, 0x00, 0x00);
565630 }
566631 } else {
567632 has_status = false;
633+ d_scsi_host->write_dma_io8(0, 0x81); // SELECT SCSI 0
568634 switch(cmd & 0x1f) {
569635 case 0x00: // set state
636+ out_debug_log(_T("CMD SET CDDA STATE (%02X)"), cmd);
570637 if(req_status) {
571638 extra_status = 0;
572639 if(d_cdrom->read_signal(SIG_SCSI_CDROM_PLAYING) != 0) { // Active() && !(paused)
@@ -577,25 +644,31 @@ void CDC::enqueue_command_status(uint8_t cmd)
577644 }
578645 break;
579646 case 0x01: // set state (CDDASET)
647+ out_debug_log(_T("CMD SET CDDASET STATE (%02X)"), cmd);
580648 if(req_status) {
581649 extra_status = 0;
582650 write_status(0x00, 0x00, 0x00, 0x00);
583651 }
584652 break;
585653 case 0x04: // STOP CDDA
654+ out_debug_log(_T("CMD PAUSE CDDA $84(%02X)"), cmd);
586655 stop_cdda(req_status);
587656 break;
588657 case 0x05: // STOP CDDA (Difference from $84?)
658+ out_debug_log(_T("CMD PAUSE CDDA $85(%02X)"), cmd);
589659 stop_cdda2(req_status);
590660 break;
591661 case 0x07: // UNPAUSE CDDA
662+ out_debug_log(_T("CMD RESUME CDDA(%02X)"), cmd);
592663 unpause_cdda(req_status);
593664 break;
594665 default: // Illegal command
666+ out_debug_log(_T("CMD Illegal(%02X)"), cmd);
595667 extra_status = 0;
596668 write_status(0x10, 0x00, 0x00, 0x00);
597669 break;
598670 }
671+// d_scsi_host->write_dma_io8(0, 0x81); // SELECT SCSI 0
599672 }
600673 }
601674
@@ -603,11 +676,14 @@ void CDC::write_signal(int ch, uint32_t data, uint32_t mask)
603676 {
604677 switch(ch) {
605678 case SIG_TOWNS_CDC_DRQ:
679+ out_debug_log(_T("SIG_TOWND_CDC_DRQ"));
606680 if((data & mask) != 0) {
607681 if((dma_transfer) ) {
608682 software_transfer_phase = false;
609-// uint8_t val = d_scsi_host->read_dma_io8(0);
610- d_dmac->write_signal(SIG_UPD71071_CH3, data, mask);
683+ uint8_t val = d_scsi_host->read_dma_io8(0);
684+ out_debug_log(_T("DRQ/DMA PTR=%d DATA=%02X"), readptr, val);
685+ d_dmac->write_signal(SIG_UPD71071_CH3, val, 0xff);
686+ readptr++;
611687 // write_signals(&output_dma_line, val); // Indirect call do_dma().
612688 } else if((pio_transfer) ) {
613689 software_transfer_phase = true;
@@ -701,9 +777,6 @@ bool CDC::process_state(FILEIO* state_fio, bool loading)
701777 if(!state_fio->StateCheckInt32(this_device_id)) {
702778 return false;
703779 }
704- if(!(param_fifo->process_state((void *)state_fio, loading))) {
705- return false;
706- }
707780 if(!(stat_fifo->process_state((void *)state_fio, loading))) {
708781 return false;
709782 }
@@ -729,6 +802,8 @@ bool CDC::process_state(FILEIO* state_fio, bool loading)
729802 state_fio->StateValue(req_status);
730803 state_fio->StateValue(ack_status);
731804
805+ state_fio->StateBuffer(param_queue, sizeof(param_queue), 1);
806+ state_fio->StateValue(param_ptr);
732807 return true;
733808
734809 }
--- a/source/src/vm/fmtowns/cdc.h
+++ b/source/src/vm/fmtowns/cdc.h
@@ -21,6 +21,7 @@
2121
2222 class SCSI_HOST;
2323 class FIFO;
24+
2425 namespace FMTOWNS {
2526 class TOWNS_CDROM;
2627 }
@@ -36,9 +37,11 @@ protected:
3637 SCSI_HOST* d_scsi_host;
3738 TOWNS_CDROM* d_cdrom;
3839
39- FIFO* param_fifo;
40+ uint8_t param_queue[8];
41+ int param_ptr;
4042 FIFO* stat_fifo;
4143
44+ int readptr;
4245 bool has_status;
4346 int extra_status;
4447 bool submpu_ready;
--- a/source/src/vm/fmtowns/fmtowns.h
+++ b/source/src/vm/fmtowns/fmtowns.h
@@ -169,6 +169,7 @@
169169 //#define SCSI_HOST_WIDE
170170 #define _SCSI_DEBUG_LOG
171171 //#define SCSI_DEV_IMMEDIATE_SELECT
172+#define _CDROM_DEBUG_LOG
172173
173174 // device informations for win32
174175 #define USE_CPU_TYPE 2
--- a/source/src/vm/fmtowns/towns_cdrom.h
+++ b/source/src/vm/fmtowns/towns_cdrom.h
@@ -72,8 +72,8 @@ public:
7272 virtual void release();
7373
7474 virtual void reset();
75- virtual void write_signal(int id, uint32_t data, uint32_t mask);
76- virtual uint32_t read_signal(int id);
75+ virtual void __FASTCALL write_signal(int id, uint32_t data, uint32_t mask);
76+ virtual uint32_t __FASTCALL read_signal(int id);
7777
7878 virtual void event_callback(int event_id, int err);
7979
@@ -99,7 +99,10 @@ public:
9999 {
100100 return SCSI_CDROM::get_seek_time(lba);
101101 }
102-
102+ virtual uint8_t get_cdda_status()
103+ {
104+ return cdda_status;
105+ }
103106 };
104107
105108 }
--- a/source/src/vm/scsi_cdrom.cpp
+++ b/source/src/vm/scsi_cdrom.cpp
@@ -17,9 +17,6 @@
1717 #define CDDA_PLAYING 1
1818 #define CDDA_PAUSED 2
1919
20-#define _SCSI_DEBUG_LOG
21-#define _CDROM_DEBUG_LOG
22-
2320 // 0-99 is reserved for SCSI_DEV class
2421 #define EVENT_CDDA 100
2522 #define EVENT_CDDA_DELAY_PLAY 101
@@ -442,7 +439,6 @@ void SCSI_CDROM::start_command()
442439 //out_debug_log(_T("Command: #%02x %02x %02x %02x %02x %02x\n"), command[0], command[1], command[2], command[3], command[4], command[5]);
443440 switch(command[0]) {
444441 case SCSI_CMD_READ6:
445- //seek_time = 10;//get_seek_time((command[1] & 0x1f) * 0x10000 + command[2] * 0x100 + command[3]);
446442 seek_time = get_seek_time((command[1] & 0x1f) * 0x10000 + command[2] * 0x100 + command[3]);
447443 set_cdda_status(CDDA_OFF);
448444 if(seek_time > 10.0) {
@@ -458,7 +454,7 @@ void SCSI_CDROM::start_command()
458454 break;
459455 case SCSI_CMD_READ10:
460456 case SCSI_CMD_READ12:
461- seek_time = get_seek_time((command[1] & 0x1f) * 0x10000 + command[2] * 0x100 + command[3]);
457+ seek_time = get_seek_time(command[2] * 0x1000000 + command[3] * 0x10000 + command[4] * 0x100 + command[5]);
462458 set_cdda_status(CDDA_OFF);
463459 if(seek_time > 10.0) {
464460 if(event_cdda_delay_play >= 0) {
@@ -710,9 +706,7 @@ void SCSI_CDROM::start_command()
710706 return;
711707
712708 case 0xda:
713- #ifdef _SCSI_DEBUG_LOG
714- this->out_debug_log(_T("[SCSI_DEV:ID=%d] Command: NEC Pause\n"), scsi_id);
715- #endif
709+ out_debug_log(_T("Command: NEC Pause\n"));
716710 if(is_device_ready()) {
717711 if(cdda_status == CDDA_PLAYING) {
718712 set_cdda_status(CDDA_PAUSED);
@@ -725,9 +719,7 @@ void SCSI_CDROM::start_command()
725719 return;
726720
727721 case 0xdd:
728- #ifdef _SCSI_DEBUG_LOG
729- this->out_debug_log(_T("[SCSI_DEV:ID=%d] Command: NEC Read Sub Channel Q\n"), scsi_id);
730- #endif
722+ out_debug_log(_T("Command: NEC Read Sub Channel Q\n"));
731723 if(is_device_ready()) {
732724 // create track info
733725 uint32_t frame = (cdda_status == CDDA_OFF) ? cdda_start_frame : cdda_playing_frame;
@@ -771,14 +763,10 @@ void SCSI_CDROM::start_command()
771763 return;
772764
773765 case 0xde:
774- #ifdef _SCSI_DEBUG_LOG
775- this->out_debug_log(_T("[SCSI_DEV:ID=%d] Command: NEC Get Dir Info\n"), scsi_id);
776- #endif
766+ out_debug_log(_T("Command: NEC Get Dir Info\n"));
777767 if(is_device_ready()) {
778768 buffer->clear();
779- #ifdef _SCSI_DEBUG_LOG
780- this->out_debug_log(_T("[SCSI_DEV:ID=%d] CMD=%02x ARG=%02x \n"), scsi_id, command[1], command[2]);
781- #endif
769+ out_debug_log(_T("CMD=%02x ARG=%02x \n"), command[1], command[2]);
782770 switch(command[1]) {
783771 case 0x00: /* Get first and last track numbers */
784772 buffer->write(TO_BCD(1));
@@ -853,22 +841,16 @@ bool SCSI_CDROM::read_buffer(int length)
853841
854842 if(is_cue) {
855843 // ToDo: Need seek wait.
856- #ifdef _CDROM_DEBUG_LOG
857- this->out_debug_log(_T("Seek to LBA %d LENGTH=%d\n"), position / 2352, length);
858- #endif
844+ out_debug_log(_T("Seek to LBA %d LENGTH=%d\n"), position / 2352, length);
859845 if(fio_img->Fseek(((long)position - (long)(toc_table[current_track].lba_offset * 2352)), FILEIO_SEEK_SET) != 0) {
860846 set_sense_code(SCSI_SENSE_ILLGLBLKADDR); //SCSI_SENSE_SEEKERR
861- #ifdef _SCSI_DEBUG_LOG
862- this->out_debug_log(_T("[SCSI_DEV:ID=%d] Error on reading (ILLGLBLKADDR) at line %d\n"), scsi_id, __LINE__);
863- #endif
847+ out_debug_log(_T("Error on reading (ILLGLBLKADDR) at line %d\n"), __LINE__);
864848 return false;
865849 }
866850 } else {
867851 if(fio_img->Fseek((long)position, FILEIO_SEEK_SET) != 0) {
868852 set_sense_code(SCSI_SENSE_ILLGLBLKADDR); //SCSI_SENSE_SEEKERR
869- #ifdef _SCSI_DEBUG_LOG
870- this->out_debug_log(_T("[SCSI_DEV:ID=%d] Error on reading (ILLGLBLKADDR) at line %d\n"), scsi_id, __LINE__);
871- #endif
853+ out_debug_log(_T("Error on reading (ILLGLBLKADDR) at line %d\n"), __LINE__);
872854 return false;
873855 }
874856 }
@@ -878,10 +860,7 @@ bool SCSI_CDROM::read_buffer(int length)
878860 int tmp_length = 2352 - offset;
879861
880862 if(fio_img->Fread(tmp_buffer, tmp_length, 1) != 1) {
881- #ifdef _SCSI_DEBUG_LOG
882- this->out_debug_log(_T("[SCSI_DEV:ID=%d] Error on reading (ILLGLBLKADDR) at line %d\n"), scsi_id, __LINE__);
883- #endif
884-
863+ out_debug_log(_T("Error on reading (ILLGLBLKADDR) at line %d\n"), __LINE__);
885864 set_sense_code(SCSI_SENSE_ILLGLBLKADDR); //SCSI_SENSE_NORECORDFND
886865 return false;
887866 }
@@ -908,14 +887,10 @@ bool SCSI_CDROM::write_buffer(int length)
908887 int value = buffer->read();
909888 if(command[0] == SCSI_CMD_MODE_SEL6) {
910889 if(i == 4) {
911- #ifdef _SCSI_DEBUG_LOG
912- this->out_debug_log(_T("[SCSI_DEV:ID=%d] NEC Read Mode = %02X\n"), scsi_id, value);
913- #endif
890+ out_debug_log(_T("NEC Read Mode = %02X\n"), value);
914891 read_mode = (value != 0);
915892 } else if(i == 10) {
916- #ifdef _SCSI_DEBUG_LOG
917- this->out_debug_log(_T("[SCSI_DEV:ID=%d] NEC Retry Count = %02X\n"), scsi_id, value);
918- #endif
893+ out_debug_log(_T("NEC Retry Count = %02X\n"), value);
919894 }
920895 }
921896 position++;
@@ -1063,9 +1038,7 @@ bool SCSI_CDROM::open_cue_file(const _TCHAR* file_path)
10631038 image_tmp_data_path = std::string(parent_dir);
10641039 image_tmp_data_path.append(_arg2);
10651040
1066- #ifdef _CDROM_DEBUG_LOG
1067- this->out_debug_log(_T("**FILE %s\n"), image_tmp_data_path.c_str());
1068- #endif
1041+ out_debug_log(_T("**FILE %s\n"), image_tmp_data_path.c_str());
10691042 goto _n_continue; // ToDo: Check ARG2 (BINARY etc..) 20181118 K.O
10701043 } else if(_arg1 == "TRACK") {
10711044 _arg2_ptr_s = _arg2.find_first_of((const char *)" \t");
@@ -1204,7 +1177,7 @@ bool SCSI_CDROM::open_cue_file(const _TCHAR* file_path)
12041177
12051178
12061179 //#ifdef _CDROM_DEBUG_LOG
1207- this->out_debug_log(_T("TRACK#%02d TYPE=%s PREGAP=%d INDEX0=%d INDEX1=%d LBA_SIZE=%d LBA_OFFSET=%d PATH=%s\n"),
1180+ out_debug_log(_T("TRACK#%02d TYPE=%s PREGAP=%d INDEX0=%d INDEX1=%d LBA_SIZE=%d LBA_OFFSET=%d PATH=%s\n"),
12081181 i, (toc_table[i].is_audio) ? _T("AUDIO") : _T("MODE1/2352"),
12091182 toc_table[i].pregap, toc_table[i].index0, toc_table[i].index1,
12101183 toc_table[i].lba_size, toc_table[i].lba_offset, track_data_path[i - 1]);
@@ -1303,8 +1276,8 @@ void SCSI_CDROM::open(const _TCHAR* file_path)
13031276 }
13041277 }
13051278 }
1306-#ifdef _SCSI_DEBUG_LOG
1307- if(mounted()) {
1279+
1280+ if(mounted() && (__SCSI_DEBUG_LOG)) {
13081281 for(int i = 0; i < track_num + 1; i++) {
13091282 uint32_t idx0_msf = lba_to_msf(toc_table[i].index0);
13101283 uint32_t idx1_msf = lba_to_msf(toc_table[i].index1);
@@ -1315,7 +1288,6 @@ void SCSI_CDROM::open(const _TCHAR* file_path)
13151288 (pgap_msf >> 16) & 0xff, (pgap_msf >> 8) & 0xff, pgap_msf & 0xff);
13161289 }
13171290 }
1318-#endif
13191291 }
13201292
13211293 void SCSI_CDROM::close()
Show on old repository browser