• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revision1fa982e2951aa68bbd6fcbdebd1bc7a7cc82f621 (tree)
Zeit2020-11-23 00:36:08
AutorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][FMTOWNS][CDROM] Rename delay/status methods to unique name.

[VM][FMTOWNS][CDROM] Don't occure duplicated EOT.

Ändern Zusammenfassung

Diff

--- a/source/src/vm/fmtowns/towns_cdrom.cpp
+++ b/source/src/vm/fmtowns/towns_cdrom.cpp
@@ -37,14 +37,14 @@
3737 #define EVENT_CDROM_DRQ 107
3838 #define EVENT_CDROM_NEXT_SECTOR 108
3939 #define EVENT_CDROM_DELAY_READY 109
40-#define EVENT_CDROM_DELAY_READY2 110
40+#define EVENT_CDROM_READY_NOSTATUS 110
4141
4242 #define EVENT_CDROM_EOT 112
4343 #define EVENT_CDROM_RESTORE 113
4444 #define EVENT_CDROM_WAIT 114
4545 #define EVENT_CDROM_TIMEOUT 115
46-#define EVENT_CDROM_DELAY_READY3 116
47-#define EVENT_CDROM_DELAY_READY4 117
46+#define EVENT_CDROM_READY_EOT 116
47+#define EVENT_CDROM_READY_CDDAREPLY 117
4848
4949 //#define _CDROM_DEBUG_LOG
5050
@@ -128,6 +128,7 @@ void TOWNS_CDROM::initialize()
128128 event_delay_ready = -1;
129129 event_cdda_delay_stop = -1;
130130 event_time_out = -1;
131+ event_eot = -1;
131132
132133 // ToDo: larger buffer for later VMs.
133134 max_fifo_length = ((machine_id == 0x0700) || (machine_id >= 0x0900)) ? 65536 : 8192;
@@ -225,10 +226,10 @@ void TOWNS_CDROM::do_dma_eot(bool by_signal)
225226 dma_intr = true;
226227 // mcu_intr = false;
227228
228- drq_tick = false;
229229
230230 clear_event(this, event_time_out);
231231 clear_event(this, event_drq);
232+ clear_event(this, event_eot);
232233
233234 if((read_length <= 0) && (databuffer->empty())) {
234235 clear_event(this, event_next_sector);
@@ -237,6 +238,13 @@ void TOWNS_CDROM::do_dma_eot(bool by_signal)
237238 cdrom_debug_log(_T("EOT(%s/DMA)"), (by_signal) ? by_dma : by_event);
238239 } else {
239240 cdrom_debug_log(_T("NEXT(%s/DMA)"), (by_signal) ? by_dma : by_event);
241+ // TRY: Register after EOT. 20201123 K.O
242+// status_seek = true;
243+// register_event(this, EVENT_CDROM_SEEK_COMPLETED,
244+// 1000.0,
245+// false,
246+// &event_seek_completed);
247+// status_data_ready(false);
240248 }
241249 write_signals(&outputs_drq, 0x00000000);
242250 if(!(dma_intr_mask) && (stat_reply_intr)) {
@@ -319,7 +327,7 @@ void TOWNS_CDROM::status_parameter_error(bool forceint)
319327 void TOWNS_CDROM::status_read_done(bool forceint)
320328 {
321329 if(forceint) stat_reply_intr = true;
322- set_status_2(req_status, 0, TOWNS_CD_STATUS_READ_DONE, 0, 0, 0);
330+ set_status_read_done(req_status, 0, TOWNS_CD_STATUS_READ_DONE, 0, 0, 0);
323331 // cdrom_debug_log(_T("READ DONE"));
324332 }
325333
@@ -399,22 +407,22 @@ void TOWNS_CDROM::set_delay_ready()
399407 force_register_event(this, EVENT_CDROM_DELAY_READY, 1000.0, false, event_delay_ready);
400408 }
401409
402-void TOWNS_CDROM::set_delay_ready2()
410+void TOWNS_CDROM::set_delay_ready_nostatus()
403411 {
404412 // From Towns Linux 2.2
405413 // But, some software (i.e. Star Cruiser II) failes to loading at 300uS.
406414 // May need *at least* 1000uS. - 20200517 K.O
407- force_register_event(this, EVENT_CDROM_DELAY_READY2, 1000.0, false, event_delay_ready);
415+ force_register_event(this, EVENT_CDROM_READY_NOSTATUS, 1000.0, false, event_delay_ready);
408416 }
409417
410-void TOWNS_CDROM::set_delay_ready3()
418+void TOWNS_CDROM::set_delay_ready_eot()
411419 {
412- force_register_event(this, EVENT_CDROM_DELAY_READY3, 1000.0, false, event_delay_ready);
420+ force_register_event(this, EVENT_CDROM_READY_EOT, 1000.0, false, event_delay_ready);
413421 }
414422
415-void TOWNS_CDROM::set_delay_ready4()
423+void TOWNS_CDROM::set_delay_ready_cddareply()
416424 {
417- force_register_event(this, EVENT_CDROM_DELAY_READY4, 100.0, false, event_delay_ready);
425+ force_register_event(this, EVENT_CDROM_READY_CDDAREPLY, 100.0, false, event_delay_ready);
418426 }
419427
420428 void TOWNS_CDROM::status_not_accept(int extra, uint8_t s1, uint8_t s2, uint8_t s3)
@@ -674,8 +682,11 @@ uint32_t TOWNS_CDROM::read_dma_io8(uint32_t addr)
674682 if((databuffer->empty()) && (read_length <= 0)) {
675683 //cdrom_debug_log(_T("EOT(DMA) by read_dma_io8()"));
676684 read_length_bak = 0;
685+ // Fallback
677686 register_event(this, EVENT_CDROM_EOT,
678- 0.2 * 1.0e6 / ((double)transfer_speed * 150.0e3 ), false, NULL);
687+// 0.2 * 1.0e6 / ((double)transfer_speed * 150.0e3 ),
688+ 1.0e3,
689+ false, &event_eot);
679690 }
680691 return data_reg;
681692 }
@@ -758,8 +769,8 @@ void TOWNS_CDROM::read_cdrom()
758769 register_event(this, EVENT_CDROM_SEEK_COMPLETED, usec, false, &event_seek_completed);
759770 if(req_status) {
760771 // May not need extra status, integrated after reading. 20200906 K.O
761- set_status(req_status, 0, 0x00, 0x00, 0x00, 0x00);
762-// set_status(req_status, 2, 0x00, 0x00, 0x00, 0x00);
772+// set_status(req_status, 0, 0x00, 0x00, 0x00, 0x00);
773+ set_status(req_status, 2, 0x00, 0x00, 0x00, 0x00);
763774 } else {
764775 if(pio_transfer) {
765776 set_status(true, 0, TOWNS_CD_STATUS_CMD_ABEND, 0x00, 0x00, 0x00); // OK?
@@ -799,29 +810,28 @@ void TOWNS_CDROM::set_status(bool _req_status, int extra, uint8_t s0, uint8_t s1
799810 status_queue->write(s3);
800811 set_delay_ready();
801812 } else {
802- set_delay_ready2();
813+ set_delay_ready_nostatus();
803814 }
804-// cdrom_debug_log(_T("SET STATUS %02x: %02x %02x %02x %02x EXTRA=%d"), latest_command, s0, s1, s2, s3, extra_status);
805815 }
806816
807-void TOWNS_CDROM::set_status_2(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3)
817+void TOWNS_CDROM::set_status_read_done(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3)
808818 {
809819 status_queue->clear();
810820 extra_status = 0;
811- if(_req_status) {
821+// if(_req_status) {
812822 if(extra > 0) extra_status = extra;
813823 status_queue->write(s0);
814824 status_queue->write(s1);
815825 status_queue->write(s2);
816826 status_queue->write(s3);
817- set_delay_ready3();
818- } else {
819- set_delay_ready3();
820- }
821-// cdrom_debug_log(_T("SET STATUS %02x: %02x %02x %02x %02x EXTRA=%d"), latest_command, s0, s1, s2, s3, extra_status);
827+// } else {
828+// set_delay_ready_eot();
829+// }
830+ set_delay_ready_eot();
831+
822832 }
823833
824-void TOWNS_CDROM::set_status_3(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3)
834+void TOWNS_CDROM::set_status_cddareply(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3)
825835 {
826836 status_queue->clear();
827837 extra_status = 0;
@@ -831,11 +841,8 @@ void TOWNS_CDROM::set_status_3(bool _req_status, int extra, uint8_t s0, uint8_t
831841 status_queue->write(s1);
832842 status_queue->write(s2);
833843 status_queue->write(s3);
834- set_delay_ready4();
835- } else {
836- set_delay_ready4();
837844 }
838-// cdrom_debug_log(_T("SET STATUS %02x: %02x %02x %02x %02x EXTRA=%d"), latest_command, s0, s1, s2, s3, extra_status);
845+ set_delay_ready_cddareply();
839846 }
840847
841848 void TOWNS_CDROM::set_status_immediate(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3)
@@ -867,7 +874,9 @@ void TOWNS_CDROM::set_extra_status()
867874 set_status_extra(TOWNS_CD_STATUS_SEEK_COMPLETED, 0x00, 0x00, 0x00);
868875 extra_status = 0;
869876 break;
870- case CDROM_COMMAND_READ_MODE1: // seek
877+ case CDROM_COMMAND_READ_MODE1:
878+ case CDROM_COMMAND_READ_MODE2:
879+ case CDROM_COMMAND_READ_RAW:
871880 if(extra_status == 2) {
872881 set_status_extra(TOWNS_CD_STATUS_DATA_READY, 0, 0, 0);
873882 }
@@ -1213,23 +1222,21 @@ void TOWNS_CDROM::event_callback(int event_id, int err)
12131222 mcu_ready = true;
12141223 set_mcu_intr(true);
12151224 break;
1216- case EVENT_CDROM_DELAY_READY2: // WITHOUT STATUS
1225+ case EVENT_CDROM_READY_NOSTATUS: // WITHOUT STATUS
12171226 event_delay_ready = -1;
12181227 mcu_ready = true;
12191228 set_mcu_intr(true);
12201229 break;
1221- case EVENT_CDROM_DELAY_READY3: // WITHOUT STATUS
1230+ case EVENT_CDROM_READY_EOT:
12221231 event_delay_ready = -1;
12231232 mcu_ready = true;
1224- has_status = (req_status) ? true : false;
1225-// if(!(has_status)) {
1226-// status_queue->clear();
1227-// }
1228- if((req_status) && (stat_reply_intr)) {
1233+ has_status = true;
1234+// has_status = (req_status) ? true : false;
1235+ if(/*(req_status) && */(stat_reply_intr)) {
12291236 set_mcu_intr(true);
12301237 }
12311238 break;
1232- case EVENT_CDROM_DELAY_READY4: // WITHOUT STATUS
1239+ case EVENT_CDROM_READY_CDDAREPLY:
12331240 event_delay_ready = -1;
12341241 mcu_ready = true;
12351242 has_status = true;
@@ -1330,14 +1337,19 @@ void TOWNS_CDROM::event_callback(int event_id, int err)
13301337 /// 20200926 K.O
13311338 stat = read_buffer(1);
13321339 if((stat)) {
1340+#if 1
13331341 register_event(this, EVENT_CDROM_NEXT_SECTOR,
13341342 (1.0e6 / ((double)transfer_speed * 150.0e3)) *
13351343 ((double)(physical_block_size())) *
13361344 1.0, // OK?
1337-// 5.0e3, // From TSUGARU
13381345 false, &event_next_sector);
1346+#else
1347+ register_event(this, EVENT_CDROM_NEXT_SECTOR,
1348+ 5.0e3, // From TSUGARU
1349+ false, &event_next_sector);
1350+#endif
13391351 }
1340- register_event(this, EVENT_CDROM_TIMEOUT, 1000.0e3, false, &event_time_out);
1352+ //register_event(this, EVENT_CDROM_TIMEOUT, 1000.0e3, false, &event_time_out);
13411353 } /*else {
13421354 status_read_done(false);
13431355 }*/
@@ -1352,6 +1364,7 @@ void TOWNS_CDROM::event_callback(int event_id, int err)
13521364 } else {
13531365 status_data_ready(false);
13541366 }
1367+ // ToDo: Prefetch
13551368 status_seek = true;
13561369 register_event(this, EVENT_CDROM_SEEK_COMPLETED,
13571370 100.0,
@@ -1360,13 +1373,14 @@ void TOWNS_CDROM::event_callback(int event_id, int err)
13601373 break;
13611374 case EVENT_CDROM_DRQ:
13621375 // ToDo: Buffer OVERFLOW at PIO mode.
1376+
13631377 if((dma_transfer_phase) && !(databuffer->empty())) {
13641378 write_signals(&outputs_drq, /*(drq_tick) ? 0xffffffff : 0x00000000*/ 0xffffffff);
1365- //drq_tick = !(drq_tick);
13661379 }
13671380 //read_pos++;
13681381 break;
13691382 case EVENT_CDROM_EOT:
1383+ event_eot = -1;
13701384 clear_event(this, event_time_out);
13711385 if(dma_transfer_phase) {
13721386 do_dma_eot(false);
@@ -1851,14 +1865,13 @@ void TOWNS_CDROM::reset_device()
18511865 clear_event(this, event_seek);
18521866 clear_event(this, event_delay_ready);
18531867 clear_event(this, event_time_out);
1868+ clear_event(this, event_eot);
18541869
18551870 read_length = 0;
18561871 read_length_bak = 0;
18571872
18581873 media_changed = false;
18591874
1860- drq_tick = false;
1861-
18621875 databuffer->clear();
18631876 status_queue->clear();
18641877 latest_command = 0x00;
@@ -2023,8 +2036,8 @@ void TOWNS_CDROM::unpause_cdda_from_cmd()
20232036 */
20242037 if((stat_reply_intr) && !(req_status)) {
20252038 set_subq();
2026-// set_status_3(true, 1, 0x00, 0, 0x00, 0x00);
2027- set_status_3(true, 0, TOWNS_CD_STATUS_RESUME_DONE, 0, 0x00, 0x00);
2039+// set_status_cddareply(true, 1, 0x00, 0, 0x00, 0x00);
2040+ set_status_cddareply(true, 0, TOWNS_CD_STATUS_RESUME_DONE, 0, 0x00, 0x00);
20282041 return;
20292042 }
20302043 }
@@ -2076,7 +2089,7 @@ void TOWNS_CDROM::pause_cdda_from_cmd()
20762089 if((stat_reply_intr) && !(req_status)) {
20772090 set_subq();
20782091 // status_accept(0, 0x00, 0x00);
2079- set_status_3(true, 1, TOWNS_CD_STATUS_ACCEPT, 0, 0x00, 0x00);
2092+ set_status_cddareply(true, 1, TOWNS_CD_STATUS_ACCEPT, 0, 0x00, 0x00);
20802093 return;
20812094 }
20822095 }
@@ -2162,7 +2175,7 @@ void TOWNS_CDROM::play_cdda_from_cmd()
21622175 if(cdda_status == CDDA_PLAYING) {
21632176 if((start_tmp == cdda_start_frame) && (end_tmp == cdda_end_frame)) {
21642177 // Dummy
2165- set_status_3(true, 1, TOWNS_CD_STATUS_ACCEPT, 0, 0x00, 0x00);
2178+ set_status_cddareply(true, 1, TOWNS_CD_STATUS_ACCEPT, 0, 0x00, 0x00);
21662179 return;
21672180 }
21682181 }
@@ -2203,7 +2216,7 @@ void TOWNS_CDROM::play_cdda_from_cmd()
22032216 * @note This may solve halt incident of Kyukyoku Tiger, but something are wrong.
22042217 * @note 20201113 K.O
22052218 */
2206- set_status_3(true, 1, TOWNS_CD_STATUS_ACCEPT, 0, 0x00, 0x00);
2219+ set_status_cddareply(true, 1, TOWNS_CD_STATUS_ACCEPT, 0, 0x00, 0x00);
22072220 // status_accept(1, 0x00, 0x00);
22082221 }
22092222
@@ -3156,8 +3169,8 @@ void TOWNS_CDROM::write_io8(uint32_t addr, uint32_t data)
31563169 param_ptr = 0;
31573170 mcu_ready = false;
31583171 extra_status = 0;
3159- dma_transfer_phase = false;
3160- pio_transfer_phase = false;
3172+ //dma_transfer_phase = false;
3173+ //pio_transfer_phase = false;
31613174 if(d_cpu == NULL) {
31623175 cdrom_debug_log(_T("CMD=%02X"), data);
31633176 } else {
@@ -3180,10 +3193,9 @@ void TOWNS_CDROM::write_io8(uint32_t addr, uint32_t data)
31803193 dma_transfer = true;
31813194 pio_transfer = false;
31823195 }
3183- if((dma_transfer) && !(dma_transfer_phase)) {
3196+ if((dma_transfer) /*&& !(dma_transfer_phase)*/) {
31843197 dma_transfer_phase = true;
3185- force_register_event(this, EVENT_CDROM_DRQ, /*0.25 * 1.0e6 / ((double)transfer_speed * 150.0e3 ) */ 1.0 / 4.0, true, event_drq);
3186- drq_tick = true;
3198+ force_register_event(this, EVENT_CDROM_DRQ, /*0.25 * 1.0e6 / ((double)transfer_speed * 150.0e3 ) */ 1.0 / 8.0, true, event_drq);
31873199 } else if((pio_transfer) && !(pio_transfer_phase)) {
31883200 pio_transfer_phase = true;
31893201 }
@@ -3256,7 +3268,7 @@ bool TOWNS_CDROM::get_debug_regs_info(_TCHAR *buffer, size_t buffer_len)
32563268 /*
32573269 * Note: 20200428 K.O: DO NOT USE STATE SAVE, STILL don't implement completely yet.
32583270 */
3259-#define STATE_VERSION 6
3271+#define STATE_VERSION 7
32603272
32613273 bool TOWNS_CDROM::process_state(FILEIO* state_fio, bool loading)
32623274 {
@@ -3300,7 +3312,6 @@ bool TOWNS_CDROM::process_state(FILEIO* state_fio, bool loading)
33003312 state_fio->StateValue(read_length);
33013313 state_fio->StateValue(read_length_bak);
33023314 state_fio->StateValue(next_seek_lba);
3303- state_fio->StateValue(drq_tick);
33043315
33053316 state_fio->StateValue(mcuint_val);
33063317
@@ -3384,12 +3395,10 @@ bool TOWNS_CDROM::process_state(FILEIO* state_fio, bool loading)
33843395 state_fio->StateValue(event_seek_completed);
33853396 state_fio->StateValue(event_delay_ready);
33863397 state_fio->StateValue(event_time_out);
3398+ state_fio->StateValue(event_eot);
33873399
33883400 // SCSI_DEV
33893401 state_fio->StateValue(position);
3390-// state_fio->StateValue(remain);
3391-// state_fio->StateValue(local_data_pos);
3392-// state_fio->StateValue(sense_code);
33933402 return true;
33943403 }
33953404
--- a/source/src/vm/fmtowns/towns_cdrom.h
+++ b/source/src/vm/fmtowns/towns_cdrom.h
@@ -292,7 +292,6 @@ protected:
292292 bool dma_intr;
293293 bool mcu_intr_mask;
294294 bool dma_intr_mask;
295- bool drq_tick;
296295
297296 bool mcuint_val;
298297
@@ -308,6 +307,7 @@ protected:
308307 int event_halt;
309308 int event_delay_command;
310309 int event_time_out;
310+ int event_eot;
311311
312312 int cdda_sample_l;
313313 int cdda_sample_r;
@@ -350,8 +350,8 @@ protected:
350350 void set_extra_status();
351351
352352 void set_status(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
353- void set_status_2(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
354- void set_status_3(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
353+ void set_status_read_done(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
354+ void set_status_cddareply(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
355355 void set_status_immediate(bool _req_status, int extra, uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
356356 void set_status_extra(uint8_t s0, uint8_t s1, uint8_t s2, uint8_t s3);
357357 void set_status_extra_toc_addr(uint8_t s1, uint8_t s2, uint8_t s3);
@@ -379,9 +379,9 @@ protected:
379379
380380 void __FASTCALL status_illegal_lba(int extra, uint8_t s1, uint8_t s2, uint8_t s3);
381381 void set_delay_ready();
382- void set_delay_ready2();
383- void set_delay_ready3();
384- void set_delay_ready4();
382+ void set_delay_ready_nostatus();
383+ void set_delay_ready_eot();
384+ void set_delay_ready_cddareply();
385385
386386 uint32_t cdrom_get_adr(int trk);
387387
Show on old repository browser