• 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ão6d9d43c36247f5dd01ff4d32d595aa23ce8944b6 (tree)
Hora2020-02-15 16:12:39
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Mensagem de Log

[VM][SCSI_DEV][SCSI_CDROM] Fix freeze some PC-Engine's CD-ROM2 games and SCSI HDD for FM-Towns.

Mudança Sumário

Diff

--- a/source/src/vm/scsi_cdrom.cpp
+++ b/source/src/vm/scsi_cdrom.cpp
@@ -32,6 +32,7 @@ void SCSI_CDROM::initialize()
3232 {
3333 SCSI_DEV::initialize();
3434 fio_img = new FILEIO();
35+ __CDROM_DEBUG_LOG = osd->check_feature(_T("_CDROM_DEBUG_LOG"));
3536
3637 if(44100 % emu->get_sound_rate() == 0) {
3738 mix_loop_num = 44100 / emu->get_sound_rate();
@@ -45,7 +46,6 @@ void SCSI_CDROM::initialize()
4546 is_cue = false;
4647 current_track = 0;
4748 read_sectors = 0;
48- __CDROM_DEBUG_LOG = osd->check_feature(_T("_CDROM_DEBUG_LOG"));
4949 for(int i = 0; i < 99; i++) {
5050 memset(track_data_path[i], 0x00, _MAX_PATH * sizeof(_TCHAR));
5151 }
@@ -179,10 +179,11 @@ void SCSI_CDROM::event_callback(int event_id, int err)
179179 }
180180 }
181181 if(cdda_playing_frame == cdda_end_frame) {
182- // reached to end frame
183182 out_debug_log(_T("Reaches to the end of track.(FRAME %d). START_FRAME=%d END_FRAME=%d REPEAT=%s INTERRUPT=%s\n"),
184- cdda_playing_frame, cdda_start_frame, cdda_end_frame,
185- (cdda_repeat) ? _T("YES") : _T("NO"), (cdda_interrupt) ? _T("YES") : _T("NO"));
183+ cdda_playing_frame, cdda_start_frame, cdda_end_frame,
184+ (cdda_repeat) ? _T("YES") : _T("NO"),
185+ (cdda_interrupt) ? _T("YES") : _T("NO"));
186+ // reached to end frame
186187 if(cdda_repeat) {
187188 // reload buffer
188189 // Restart.
@@ -191,6 +192,11 @@ void SCSI_CDROM::event_callback(int event_id, int err)
191192 if(fio_img->IsOpened()) {
192193 fio_img->Fseek((cdda_start_frame - toc_table[trk].lba_offset) * 2352, FILEIO_SEEK_SET);
193194 }
195+// fio_img->Fclose();
196+ //current_track = 0;
197+ //int trk = get_track(cdda_start_frame);
198+// int trk = current_track;
199+// fio_img->Fseek((cdda_start_frame - toc_table[trk].lba_offset) * 2352, FILEIO_SEEK_SET);
194200 } else {
195201 fio_img->Fseek(cdda_start_frame * 2352, FILEIO_SEEK_SET);
196202 }
@@ -200,14 +206,18 @@ void SCSI_CDROM::event_callback(int event_id, int err)
200206 read_sectors = 0;
201207 memset(cdda_buffer, 0x00, sizeof(cdda_buffer));
202208 }
209+// read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t) , array_length(cdda_buffer) / 2352);
203210 cdda_buffer_ptr = 0;
204211 cdda_playing_frame = cdda_start_frame;
205212 access = true;
206213 } else {
207214 // Stop
208215 if(event_cdda_delay_play >= 0) cancel_event(this, event_cdda_delay_play);
209- register_event(this, EVENT_CDDA_DELAY_STOP, 1000.0, false, &event_cdda_delay_play);
210216 memset(cdda_buffer, 0x00, sizeof(cdda_buffer));
217+ register_event(this, EVENT_CDDA_DELAY_STOP, 1000.0, false, &event_cdda_delay_play);
218+
219+ //set_cdda_status(CDDA_OFF);
220+ //register_event(this, EVENT_CDDA_DELAY_STOP, 1000.0, false, &event_cdda_delay_play);
211221 access = false;
212222 }
213223 } else if((cdda_buffer_ptr % 2352) == 0) {
@@ -220,6 +230,7 @@ void SCSI_CDROM::event_callback(int event_id, int err)
220230 read_sectors = 0;
221231 memset(cdda_buffer, 0x00, sizeof(cdda_buffer));
222232 }
233+// read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t), array_length(cdda_buffer) / 2352);
223234 cdda_buffer_ptr = 0;
224235 access = false;
225236 } else {
@@ -336,6 +347,7 @@ void SCSI_CDROM::get_track_by_track_num(int track)
336347 fio_img->Fclose();
337348 }
338349 out_debug_log(_T("LOAD TRK #%02d from %s\n"), track, track_data_path[track - 1]);
350+
339351 if((track > 0) && (track < 100) && (track < track_num)) {
340352 if((strlen(track_data_path[track - 1]) <= 0) ||
341353 !(fio_img->Fopen(track_data_path[track - 1], FILEIO_READ_BINARY))) {
@@ -547,8 +559,8 @@ void SCSI_CDROM::start_command()
547559
548560 if(cdda_end_frame <= toc_table[current_track].index0) {
549561 cdda_end_frame = toc_table[current_track + 1].index0; // don't play pregap
550- } else if(cdda_end_frame > toc_table[track_num].index0) {
551- cdda_end_frame = toc_table[track_num].index0; // end of disc
562+ } else if(cdda_end_frame > toc_table[current_track + 1].index0) {
563+ cdda_end_frame = toc_table[current_track + 1].index0; // don't play pregap
552564 }
553565 #if 1
554566 if(is_cue) {
@@ -559,15 +571,11 @@ void SCSI_CDROM::start_command()
559571 #endif
560572 if(cdda_end_frame <= toc_table[current_track].index0) {
561573 cdda_end_frame = toc_table[current_track + 1].index0; // don't play pregap
562- } else if(cdda_end_frame > toc_table[track_num].index0) {
563- cdda_end_frame = toc_table[track_num].index0; // end of disc
564- }
565- if(fio_img->IsOpened()) {
566- read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t), array_length(cdda_buffer) / 2352);
567- } else {
568- read_sectors = 0;
569- memset(cdda_buffer, 0x00, sizeof(cdda_buffer));
574+ } else if(cdda_end_frame > toc_table[current_track + 1].index0) {
575+ cdda_end_frame = toc_table[current_track + 1].index0; // don't play pregap
570576 }
577+ //memset(cdda_buffer, 0x00, array_length(cdda_buffer));
578+ read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t), array_length(cdda_buffer) / 2352);
571579 if((command[1] & 3) != 0) {
572580 cdda_repeat = ((command[1] & 3) == 1);
573581 // read buffer
@@ -635,13 +643,23 @@ void SCSI_CDROM::start_command()
635643 // PCE tries to be clever here and set (start of track + track pregap size) to skip the pregap
636644 // (I guess it wants the TOC to have the real start sector for data tracks and the start of the pregap for audio?)
637645
638-// int track = get_track(cdda_start_frame);
639-// int track = current_track;
646+// int track = get_track(cdda_end_frame);
647+ int track = current_track;
640648 // cdda_start_frame = toc_table[track].index0;
641649 cdda_playing_frame = cdda_start_frame;
642- //if(cdda_end_frame > toc_table[track + 1].index1 && (cdda_end_frame - toc_table[track].pregap) <= toc_table[track + 1].index1) {
643- // cdda_end_frame = toc_table[track + 1].index1;
644- //}
650+// if(is_cue) {
651+// fio_img->Fseek((cdda_start_frame - toc_table[current_track].lba_offset) * 2352, FILEIO_SEEK_SET);
652+// } else {
653+// fio_img->Fseek(cdda_start_frame * 2352, FILEIO_SEEK_SET);
654+// }
655+ //read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t), array_length(cdda_buffer) / 2352);
656+// if(cdda_end_frame < toc_table[track].lba_offset) {
657+// cdda_end_frame = toc_table[track + 1].index1;
658+// }
659+
660+ if(cdda_end_frame > toc_table[track + 1].index1 && (cdda_end_frame - toc_table[track].pregap) <= toc_table[track + 1].index1) {
661+ cdda_end_frame = toc_table[track + 1].index1;
662+ }
645663 cdda_buffer_ptr = 0;
646664 }
647665 break;
@@ -656,17 +674,12 @@ void SCSI_CDROM::start_command()
656674 cdda_start_frame = toc_table[_track].index0;
657675 cdda_end_frame = toc_table[_track].lba_size + toc_table[_track].lba_offset;
658676 cdda_playing_frame = cdda_start_frame;
659- if(fio_img->IsOpened()) {
660- if(is_cue) {
661- fio_img->Fseek((cdda_start_frame - toc_table[current_track].lba_offset) * 2352, FILEIO_SEEK_SET);
662- } else {
663- fio_img->Fseek(cdda_start_frame * 2352, FILEIO_SEEK_SET);
664- }
665- read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t), array_length(cdda_buffer) / 2352);
677+ if(is_cue) {
678+ fio_img->Fseek((cdda_start_frame - toc_table[current_track].lba_offset) * 2352, FILEIO_SEEK_SET);
666679 } else {
667- memset(cdda_buffer, 0x00, sizeof(cdda_buffer));
668- read_sectors = 0;
680+ fio_img->Fseek(cdda_start_frame * 2352, FILEIO_SEEK_SET);
669681 }
682+ read_sectors = fio_img->Fread(cdda_buffer, 2352 * sizeof(uint8_t), array_length(cdda_buffer) / 2352);
670683 cdda_buffer_ptr = 0;
671684 }
672685 }
@@ -680,27 +693,26 @@ void SCSI_CDROM::start_command()
680693 cdda_repeat = ((command[1] & 3) == 1);
681694 cdda_interrupt = ((command[1] & 3) == 2);
682695
683-// if(event_cdda_delay_play >= 0) cancel_event(this, event_cdda_delay_play);
684-// register_event(this, EVENT_CDDA_DELAY_PLAY, 10.0, false, &event_cdda_delay_play);
685- set_cdda_status(CDDA_PLAYING);
686- } else {
687- cdda_repeat = false;
688- cdda_interrupt = false;
689-// if(event_cdda_delay_play >= 0) cancel_event(this, event_cdda_delay_play);
690-// register_event(this, EVENT_CDDA_DELAY_STOP, 10.0, false, &event_cdda_delay_play);
691- set_cdda_status(CDDA_OFF);
692- }
696+ if(event_cdda_delay_play >= 0) cancel_event(this, event_cdda_delay_play);
697+ register_event(this, EVENT_CDDA_DELAY_PLAY, 10.0, false, &event_cdda_delay_play);
698+ //set_cdda_status(CDDA_PLAYING);
699+ }
693700 }
694701 // change to status phase
695702 set_dat(is_device_ready() ? SCSI_STATUS_GOOD : SCSI_STATUS_CHKCOND);
696703 if(is_device_ready()) {
697704 write_signals(&outputs_done, 0xffffffff);
705+ //if(event_delay_interrupt >= 0) cancel_event(this, event_delay_interrupt);
706+ //register_event(this, EVENT_CDROM_DELAY_INTERRUPT_ON, 10.0, false, &event_delay_interrupt);
707+
698708 }
699709 set_phase_delay(SCSI_PHASE_STATUS, 10.0);
700710 return;
701711
702712 case 0xda:
703- out_debug_log(_T("Command: NEC Pause\n"), scsi_id);
713+ #ifdef _SCSI_DEBUG_LOG
714+ this->out_debug_log(_T("[SCSI_DEV:ID=%d] Command: NEC Pause\n"), scsi_id);
715+ #endif
704716 if(is_device_ready()) {
705717 if(cdda_status == CDDA_PLAYING) {
706718 set_cdda_status(CDDA_PAUSED);
@@ -713,7 +725,9 @@ void SCSI_CDROM::start_command()
713725 return;
714726
715727 case 0xdd:
716- out_debug_log(_T("Command: NEC Read Sub Channel Q\n"));
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
717731 if(is_device_ready()) {
718732 // create track info
719733 uint32_t frame = (cdda_status == CDDA_OFF) ? cdda_start_frame : cdda_playing_frame;
@@ -757,10 +771,14 @@ void SCSI_CDROM::start_command()
757771 return;
758772
759773 case 0xde:
760- out_debug_log(_T("Command: NEC Get Dir Info\n"));
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
761777 if(is_device_ready()) {
762778 buffer->clear();
763- out_debug_log(_T("CMD=%02x ARG=%02x \n"), command[1], command[2]);
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
764782 switch(command[1]) {
765783 case 0x00: /* Get first and last track numbers */
766784 buffer->write(TO_BCD(1));
@@ -835,16 +853,22 @@ bool SCSI_CDROM::read_buffer(int length)
835853
836854 if(is_cue) {
837855 // ToDo: Need seek wait.
838- out_debug_log(_T("Seek to LBA %d LENGTH=%d\n"), position / 2352, length);
856+ #ifdef _CDROM_DEBUG_LOG
857+ this->out_debug_log(_T("Seek to LBA %d LENGTH=%d\n"), position / 2352, length);
858+ #endif
839859 if(fio_img->Fseek(((long)position - (long)(toc_table[current_track].lba_offset * 2352)), FILEIO_SEEK_SET) != 0) {
840860 set_sense_code(SCSI_SENSE_ILLGLBLKADDR); //SCSI_SENSE_SEEKERR
841- out_debug_log(_T("Error on reading (ILLGLBLKADDR) at line %d\n"), __LINE__);
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
842864 return false;
843865 }
844866 } else {
845867 if(fio_img->Fseek((long)position, FILEIO_SEEK_SET) != 0) {
846868 set_sense_code(SCSI_SENSE_ILLGLBLKADDR); //SCSI_SENSE_SEEKERR
847- out_debug_log(_T("Error on reading (ILLGLBLKADDR) at line %d\n"), __LINE__);
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
848872 return false;
849873 }
850874 }
@@ -854,7 +878,10 @@ bool SCSI_CDROM::read_buffer(int length)
854878 int tmp_length = 2352 - offset;
855879
856880 if(fio_img->Fread(tmp_buffer, tmp_length, 1) != 1) {
857- out_debug_log(_T("Error on reading (ILLGLBLKADDR) at line %d\n"), __LINE__);
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+
858885 set_sense_code(SCSI_SENSE_ILLGLBLKADDR); //SCSI_SENSE_NORECORDFND
859886 return false;
860887 }
@@ -881,10 +908,14 @@ bool SCSI_CDROM::write_buffer(int length)
881908 int value = buffer->read();
882909 if(command[0] == SCSI_CMD_MODE_SEL6) {
883910 if(i == 4) {
884- out_debug_log(_T("NEC Read Mode = %02X\n"), value);
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
885914 read_mode = (value != 0);
886915 } else if(i == 10) {
887- out_debug_log(_T("NEC Retry Count = %02X\n"), value);
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
888919 }
889920 }
890921 position++;
@@ -1031,7 +1062,10 @@ bool SCSI_CDROM::open_cue_file(const _TCHAR* file_path)
10311062 image_tmp_data_path.clear();
10321063 image_tmp_data_path = std::string(parent_dir);
10331064 image_tmp_data_path.append(_arg2);
1034- out_debug_log(_T("**FILE %s\n"), image_tmp_data_path.c_str());
1065+
1066+ #ifdef _CDROM_DEBUG_LOG
1067+ this->out_debug_log(_T("**FILE %s\n"), image_tmp_data_path.c_str());
1068+ #endif
10351069 goto _n_continue; // ToDo: Check ARG2 (BINARY etc..) 20181118 K.O
10361070 } else if(_arg1 == "TRACK") {
10371071 _arg2_ptr_s = _arg2.find_first_of((const char *)" \t");
@@ -1170,7 +1204,7 @@ bool SCSI_CDROM::open_cue_file(const _TCHAR* file_path)
11701204
11711205
11721206 //#ifdef _CDROM_DEBUG_LOG
1173- out_debug_log(_T("TRACK#%02d TYPE=%s PREGAP=%d INDEX0=%d INDEX1=%d LBA_SIZE=%d LBA_OFFSET=%d PATH=%s\n"),
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"),
11741208 i, (toc_table[i].is_audio) ? _T("AUDIO") : _T("MODE1/2352"),
11751209 toc_table[i].pregap, toc_table[i].index0, toc_table[i].index1,
11761210 toc_table[i].lba_size, toc_table[i].lba_offset, track_data_path[i - 1]);
@@ -1269,19 +1303,19 @@ void SCSI_CDROM::open(const _TCHAR* file_path)
12691303 }
12701304 }
12711305 }
1272- if(__SCSI_DEBUG_LOG) {
1306+#ifdef _SCSI_DEBUG_LOG
12731307 if(mounted()) {
12741308 for(int i = 0; i < track_num + 1; i++) {
12751309 uint32_t idx0_msf = lba_to_msf(toc_table[i].index0);
12761310 uint32_t idx1_msf = lba_to_msf(toc_table[i].index1);
12771311 uint32_t pgap_msf = lba_to_msf(toc_table[i].pregap);
1278- out_debug_log(_T("Track%02d: Index0=%02x:%02x:%02x Index1=%02x:%02x:%02x PreGap=%02x:%02x:%02x\n"), i + 1,
1312+ this->out_debug_log(_T("Track%02d: Index0=%02x:%02x:%02x Index1=%02x:%02x:%02x PreGap=%02x:%02x:%02x\n"), i + 1,
12791313 (idx0_msf >> 16) & 0xff, (idx0_msf >> 8) & 0xff, idx0_msf & 0xff,
12801314 (idx1_msf >> 16) & 0xff, (idx1_msf >> 8) & 0xff, idx1_msf & 0xff,
12811315 (pgap_msf >> 16) & 0xff, (pgap_msf >> 8) & 0xff, pgap_msf & 0xff);
12821316 }
12831317 }
1284- }
1318+#endif
12851319 }
12861320
12871321 void SCSI_CDROM::close()
--- a/source/src/vm/scsi_cdrom.h
+++ b/source/src/vm/scsi_cdrom.h
@@ -100,6 +100,7 @@ public:
100100 virtual void mix(int32_t* buffer, int cnt);
101101 virtual void set_volume(int ch, int decibel_l, int decibel_r);
102102 virtual bool process_state(FILEIO* state_fio, bool loading);
103+ virtual void out_debug_log(const _TCHAR *format, ...);
103104
104105 // virtual scsi functions
105106 virtual void reset_device();
@@ -129,7 +130,6 @@ public:
129130 {
130131 register_output_signal(&outputs_done, device, id, mask);
131132 }
132- virtual void out_debug_log(const _TCHAR *format, ...);
133133 void open(const _TCHAR* file_path);
134134 void close();
135135 bool mounted();
--- a/source/src/vm/scsi_dev.cpp
+++ b/source/src/vm/scsi_dev.cpp
@@ -13,7 +13,6 @@
1313 #define EVENT_SEL 0
1414 #define EVENT_PHASE 1
1515 #define EVENT_REQ 2
16-#define EVENT_BSY 3
1716 //#define _SCSI_DEBUG_LOG
1817
1918 void SCSI_DEV::initialize()
@@ -54,16 +53,8 @@ void SCSI_DEV::reset()
5453 data_bus = 0;
5554 sel_status = atn_status = ack_status = rst_status = false;
5655 selected = atn_pending = false;
57- next_bsy = 0;
5856
59- if(event_sel > -1) cancel_event(this, event_sel);
60- if(event_phase > -1) cancel_event(this, event_phase);
61- if(event_req > -1) cancel_event(this, event_req);
62- if(event_bsy > -1) cancel_event(this, event_bsy);
63- event_sel = event_phase = event_req = event_bsy = -1;
64- // Release BUS
65-// write_signals(&outputs_dat, 0);
66- write_signals(&outputs_bsy, 0);
57+ event_sel = event_phase = event_req = -1;
6758 set_phase(SCSI_PHASE_BUS_FREE);
6859 set_sense_code(SCSI_SENSE_NOSENSE);
6960 }
@@ -110,8 +101,6 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
110101 command_index = 0;
111102 set_phase_delay(SCSI_PHASE_COMMAND, 10.0);
112103 // set_phase(SCSI_PHASE_COMMAND);
113-// set_bsy(1);
114-// set_req_delay(0, 1000.0);
115104 }
116105 }
117106 }
@@ -172,7 +161,7 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
172161 */
173162 bool prev_status = ack_status;
174163 ack_status = ((data & mask) != 0);
175- //out_debug_log(_T("ACK=%s from %s"), (ack_status) ? _T("ON") : _T("OFF"), (prev_status) ? _T("ON") : _T("OFF"));
164+
176165 if(phase == SCSI_PHASE_BUS_FREE) {
177166 // this device is not selected
178167 } else if(!prev_status & ack_status) {
@@ -198,7 +187,6 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
198187 break;
199188 }
200189 set_req_delay(0, 0.1);
201-// set_req_delay(0, 0.25); // 4MHz
202190 } else if(prev_status && !ack_status) {
203191 // H -> L
204192 if(atn_pending) {
@@ -317,8 +305,6 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
317305 memset(command, 0, sizeof(command));
318306 command_index = 0;
319307 set_phase_delay(SCSI_PHASE_COMMAND, 10.0);
320-// set_bsy(1);
321-// set_req_delay(0, 1000.0);
322308 } else {
323309 // abort, change to bus free phase
324310 set_phase_delay(SCSI_PHASE_BUS_FREE, 10.0);
@@ -360,18 +346,13 @@ void SCSI_DEV::write_signal(int id, uint32_t data, uint32_t mask)
360346 void SCSI_DEV::event_callback(int event_id, int err)
361347 {
362348 switch(event_id) {
363- case EVENT_BSY:
364- event_bsy = -1;
365- set_bsy(next_bsy);
366- break;
367349 case EVENT_SEL:
368350 event_sel = -1;
369351 if((data_bus & 0x7f) == (1 << scsi_id)) {
370352 if(is_device_existing()) {
371353 // this device is selected!
372354 out_debug_log(_T("This device is selected\n"));
373- set_bsy(1);
374-// set_req(1);
355+ set_bsy(true);
375356 selected = true;
376357 }
377358 }
@@ -392,24 +373,22 @@ void SCSI_DEV::event_callback(int event_id, int err)
392373 void SCSI_DEV::set_phase(int value)
393374 {
394375 out_debug_log(_T("Phase %s -> %s\n"), scsi_phase_name[phase], scsi_phase_name[value]);
395- set_io (value & 1);
396- set_msg(value & 2);
397- set_cd (value & 4);
398-
399376 if(event_phase != -1) {
400377 cancel_event(this, event_phase);
401378 event_phase = -1;
402379 }
380+ set_io (value & 1);
381+ set_msg(value & 2);
382+ set_cd (value & 4);
383+
403384 if(value == SCSI_PHASE_BUS_FREE) {
404- set_bsy(0);
385+ set_bsy(false);
405386 set_req(0);
406387 selected = false;
407388 } else {
408389 first_req_clock = 0;
409- set_bsy(1);
410- set_req(1);
411- //set_req_delay(0, 800.0);
412- //set_bsy_delay(0, 800.0);
390+// set_bsy(true);
391+ set_req_delay(1, 10.0);
413392 }
414393 phase = value;
415394 }
@@ -430,23 +409,12 @@ void SCSI_DEV::set_phase_delay(int value, double usec)
430409
431410 void SCSI_DEV::set_dat(int value)
432411 {
412+ if(__SCSI_DEBUG_LOG) {
433413 // emu->force_out_debug_log(_T("[SCSI_DEV:ID=%d] DATA = %02x\n"), scsi_id, value);
414+ }
434415 write_signals(&outputs_dat, value);
435416 }
436417
437-void SCSI_DEV::set_bsy_delay(int value, double usec)
438-{
439- if(event_bsy > -1) {
440- cancel_event(this, event_bsy);
441- event_bsy = -1;
442- }
443- next_bsy = value;
444- if(usec <= 10.0) {
445- set_bsy(value);
446- } else {
447- register_event(this, EVENT_BSY, usec, false, &event_bsy);
448- }
449-}
450418 void SCSI_DEV::set_bsy(int value)
451419 {
452420 out_debug_log(_T("BUSY = %d\n"), value ? 1 : 0);
@@ -473,7 +441,7 @@ void SCSI_DEV::set_msg(int value)
473441
474442 void SCSI_DEV::set_req(int value)
475443 {
476-// out_debug_log(_T("REQ = %d\n"), value ? 1 : 0);
444+ out_debug_log(_T("REQ = %d\n"), value ? 1 : 0);
477445 if(event_req != -1) {
478446 cancel_event(this, event_req);
479447 event_req = -1;
@@ -520,7 +488,7 @@ void SCSI_DEV::start_command()
520488 {
521489 switch(command[0]) {
522490 case SCSI_CMD_TST_U_RDY:
523- out_debug_log(_T("Command: Test Unit Ready\n"));
491+ out_debug_log(_T("Command: Test Unit Ready\n"));
524492 // change to status phase
525493 if(!is_device_ready()) {
526494 set_dat(SCSI_STATUS_CHKCOND);
@@ -529,7 +497,6 @@ void SCSI_DEV::start_command()
529497 set_dat(SCSI_STATUS_GOOD);
530498 set_sense_code(SCSI_SENSE_NOSENSE);
531499 }
532-// remain = 0;
533500 set_phase_delay(SCSI_PHASE_STATUS, 10.0);
534501 break;
535502
@@ -642,9 +609,9 @@ void SCSI_DEV::start_command()
642609 break;
643610
644611 case SCSI_CMD_READ6:
645- out_debug_log(_T("Command: Read 6-byte\n"));
646612 // start position
647613 position = (command[1] & 0x1f) * 0x10000 + command[2] * 0x100 + command[3];
614+ out_debug_log(_T("Command: Read 6-byte LBA=%d BLOCKS=%d\n"), position, command[4]);
648615 position *= physical_block_size();
649616 // transfer length
650617 remain = command[4] * logical_block_size();
@@ -670,9 +637,9 @@ void SCSI_DEV::start_command()
670637 break;
671638
672639 case SCSI_CMD_WRITE6:
673- out_debug_log(_T("Command: Write 6-Byte\n"));
674640 // start position
675641 position = (command[1] & 0x1f) * 0x10000 + command[2] * 0x100 + command[3];
642+ out_debug_log(_T("Command: Write 6-byte LBA=%d BLOCKS=%d\n"), position, command[4]);
676643 position *= physical_block_size();
677644 // transfer length
678645 remain = command[4] * logical_block_size();
@@ -690,9 +657,9 @@ void SCSI_DEV::start_command()
690657 break;
691658
692659 case SCSI_CMD_READ10:
693- out_debug_log(_T("Command: Read 10-byte\n"));
694660 // start position
695661 position = command[2] * 0x1000000 + command[3] * 0x10000 + command[4] * 0x100 + command[5];
662+ out_debug_log(_T("Command: Read 10-byte LBA=%d BLOCKS=%d\n"), position, command[7] * 0x100 + command[8]);
696663 position *= physical_block_size();
697664 // transfer length
698665 remain = command[7] * 0x100 + command[8];
@@ -719,13 +686,12 @@ void SCSI_DEV::start_command()
719686 break;
720687
721688 case SCSI_CMD_WRITE10:
722- out_debug_log(_T("Command: Write 10-Byte\n"));
723689 goto WRITE10;
724690 case SCSI_CMD_WRT_VERIFY:
725- out_debug_log(_T("Command: Write and Verify\n"));
726691 WRITE10:
727692 // start position
728693 position = command[2] * 0x1000000 + command[3] * 0x10000 + command[4] * 0x100 + command[5];
694+ out_debug_log(_T("Command: %s LBA=%d BLOCKS=%d\n"), (command[0] == SCSI_CMD_WRT_VERIFY) ? _T("Write and Verify") : _T("Write 10-byte"), position, command[7] * 0x100 + command[8]);
729695 position *= physical_block_size();
730696 // transfer length
731697 remain = command[7] * 0x100 + command[8];
@@ -744,9 +710,9 @@ void SCSI_DEV::start_command()
744710 break;
745711
746712 case SCSI_CMD_READ12:
747- out_debug_log(_T("Command: Read 12-byte\n"));
748713 // start position
749714 position = command[2] * 0x1000000 + command[3] * 0x10000 + command[4] * 0x100 + command[5];
715+ out_debug_log(_T("Command: Read 12-byte LBA=%d BLOCKS=%d\n"), position, command[6] * 0x1000000 + command[7] * 0x10000 + command[8] * 0x100 + command[9]);
750716 position *= physical_block_size();
751717 // transfer length
752718 remain = command[6] * 0x1000000 + command[7] * 0x10000 + command[8] * 0x100 + command[9];
@@ -773,9 +739,9 @@ void SCSI_DEV::start_command()
773739 break;
774740
775741 case SCSI_CMD_WRITE12:
776- out_debug_log(_T("Command: Write 12-Byte\n"));
777742 // start position
778743 position = command[2] * 0x1000000 + command[3] * 0x10000 + command[4] * 0x100 + command[5];
744+ out_debug_log(_T("Command: Write 12-byte LBA=%d BLOCKS=%d\n"), position, command[6] * 0x1000000 + command[7] * 0x10000 + command[8] * 0x100 + command[9]);
779745 position *= physical_block_size();
780746 // transfer length
781747 remain = command[6] * 0x1000000 + command[7] * 0x10000 + command[8] * 0x100 + command[9];
@@ -820,7 +786,7 @@ bool SCSI_DEV::write_buffer(int length)
820786 return true;
821787 }
822788
823-#define STATE_VERSION 3
789+#define STATE_VERSION 2
824790
825791 bool SCSI_DEV::process_state(FILEIO* state_fio, bool loading)
826792 {
@@ -853,7 +819,5 @@ bool SCSI_DEV::process_state(FILEIO* state_fio, bool loading)
853819 state_fio->StateValue(position);
854820 state_fio->StateValue(remain);
855821 state_fio->StateValue(sense_code);
856- state_fio->StateValue(event_bsy);
857- state_fio->StateValue(next_bsy);
858822 return true;
859823 }
--- a/source/src/vm/scsi_dev.h
+++ b/source/src/vm/scsi_dev.h
@@ -150,35 +150,30 @@ protected:
150150
151151 int phase, next_phase, next_req;
152152 int event_sel, event_phase, event_req;
153- int next_bsy;
154- int event_bsy;
155-
156153 uint32_t first_req_clock;
157154 double next_req_usec;
158155
159156 uint8_t sense_code;
160-
157+
161158 bool _SCSI_HOST_WIDE;
162159 bool _SCSI_DEV_IMMEDIATE_SELECT;
163160 bool __SCSI_DEBUG_LOG;
164161 bool _OUT_DEBUG_LOG;
165-
166162 public:
167163 SCSI_DEV(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
168164 {
169- _SCSI_HOST_WIDE = false;
170- _SCSI_DEV_IMMEDIATE_SELECT = false;
171- __SCSI_DEBUG_LOG = false;
172- _OUT_DEBUG_LOG = false;
173165 initialize_output_signals(&outputs_dat);
174166 initialize_output_signals(&outputs_bsy);
175167 initialize_output_signals(&outputs_cd);
176168 initialize_output_signals(&outputs_io);
177169 initialize_output_signals(&outputs_msg);
178170 initialize_output_signals(&outputs_req);
171+ _SCSI_HOST_WIDE = false;
172+ _SCSI_DEV_IMMEDIATE_SELECT = false;
173+ __SCSI_DEBUG_LOG = false;
174+ _OUT_DEBUG_LOG = false;
179175
180176 set_device_name(_T("SCSI DEVICE"));
181-
182177 }
183178 ~SCSI_DEV() {}
184179
@@ -200,6 +195,7 @@ public:
200195 //#else
201196 register_output_signal(&outputs_dat, device, SIG_SCSI_DAT, 0xff);
202197 //#endif
198+// register_output_signal(&outputs_dat, device, SIG_SCSI_DAT, 1 << scsi_id);
203199 register_output_signal(&outputs_bsy, device, SIG_SCSI_BSY, 1 << scsi_id);
204200 register_output_signal(&outputs_cd, device, SIG_SCSI_CD, 1 << scsi_id);
205201 register_output_signal(&outputs_io, device, SIG_SCSI_IO, 1 << scsi_id);
@@ -218,7 +214,6 @@ public:
218214 void set_phase_delay(int value, double usec);
219215 void set_dat(int value);
220216 void set_bsy(int value);
221- void set_bsy_delay(int value, double usec);
222217 void set_cd(int value);
223218 void set_io(int value);
224219 void set_msg(int value);
Show on old repository browser