• R/O
  • HTTP
  • SSH
  • HTTPS

common_source_project-fm7: Commit

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


Commit MetaInfo

Revisionc2157ea0d8bf02b4215d8fea0cda9c6ad05d0a29 (tree)
Time2018-12-13 21:00:43
AuthorK.Ohta <whatisthis.sowhat@gmai...>
CommiterK.Ohta

Log Message

[VM][SCSI_CDROM] Add write_signal() to control CDDA from MACHINE.
[VM][PCENGINE] Stop CDDA at writing to $1804.

Change Summary

Incremental Difference

--- a/source/src/vm/pcengine/pce.cpp
+++ b/source/src/vm/pcengine/pce.cpp
@@ -1887,10 +1887,7 @@ void PCE::cdrom_write(uint16_t addr, uint8_t data)
18871887 d_scsi_host->write_signal(SIG_SCSI_SEL, 0, 1);
18881888 adpcm_dma_enabled = false;
18891889 // From Ootake v2.38
1890- //d_scsi_host->write_signal(SIG_SCSI_RST, 0xff, 0xff);
1891- //d_scsi_cdrom->reset_device();
18921890 cdrom_regs[0x03] = 0x00; // Reset IRQ status at al.
1893- //set_cdrom_irq_line(0x70, CLEAR_LINE);
18941891 set_cdrom_irq_line(0x0, 0x0); // Update IRQ
18951892 break;
18961893
@@ -1921,12 +1918,15 @@ void PCE::cdrom_write(uint16_t addr, uint8_t data)
19211918
19221919 case 0x04: /* CD reset */
19231920 if(data & 0x02) {
1921+ // Reset CDROM
1922+ // From Ootake v2.38
1923+ d_scsi_cdrom->write_signal(SIG_SCSI_CDROM_CDDA_STOP, 0xff, 0xff);
19241924 // Reset ADPCM hardware
19251925 reset_adpcm();
1926- set_cdrom_irq_line(0x70, CLEAR_LINE);
19271926 adpcm_dma_enabled = false;
19281927 out_debug_log(_T("ADPCM CMD=$04 RESET\n"));
1929-
1928+ cdrom_regs[0x03] = 0x00; // Reset IRQ status at al.
1929+ set_cdrom_irq_line(0x0, 0x0); // Update IRQ
19301930 }
19311931 d_scsi_host->write_signal(SIG_SCSI_RST, data, 0x02);
19321932 break;
@@ -2025,20 +2025,15 @@ void PCE::cdrom_write(uint16_t addr, uint8_t data)
20252025 adpcm_play();
20262026 d_msm->reset_w(0);
20272027 out_debug_log(_T("ADPCM START PLAY START=%04x END=%04x HALF=%04x\n"), msm_start_addr, msm_end_addr, msm_half_addr);
2028- } else if(((data & 0x40) == 0) && ((cdrom_regs[0x0D] & 0x40) != 0) && (adpcm_play_in_progress)) {
2029- // 20181213 K.O: Import from Ootake v2.83.Thanks to developers of Ootake.
2030- if(((data & 0x20) != 0) && ((adpcm_length & 0xffff) >= 0x8000) && ((adpcm_length & 0xffff) <= 0x80ff)) {
2031- msm_half_addr = (adpcm_read_ptr + 0x85) & 0xffff;
2032- } else {
2033- msm_half_addr = (adpcm_read_ptr + (adpcm_length >> 1)) & 0xffff;
2034- }
2035- if(!(data & 0x20)) {
2036- set_cdrom_irq_line(PCE_CD_IRQ_SAMPLE_HALF_PLAY, CLEAR_LINE);
2037- set_cdrom_irq_line(PCE_CD_IRQ_SAMPLE_FULL_PLAY, CLEAR_LINE);
2038- adpcm_stop(false);
2039- d_msm->reset_w(1);
2028+ } else if(((data & 0x40) == 0)) {
2029+ if(((cdrom_regs[0x0D] & 0x40) != 0) && (adpcm_play_in_progress)) {
2030+ // 20181213 K.O: Import from Ootake v2.83.Thanks to developers of Ootake.
2031+ if(((data & 0x20) != 0) && ((adpcm_length & 0xffff) >= 0x8000) && ((adpcm_length & 0xffff) <= 0x80ff)) {
2032+ msm_half_addr = (adpcm_read_ptr + 0x85) & 0xffff;
2033+ } else {
2034+ msm_half_addr = (adpcm_read_ptr + (adpcm_length >> 1)) & 0xffff;
2035+ }
20402036 }
2041- } else if ((data & 0x40) == 0) {
20422037 // used by Buster Bros to cancel an in-flight sample
20432038 // if repeat flag (bit5) is high, ADPCM should be fully played (from Ootake)
20442039 if(!(data & 0x20)) {
--- a/source/src/vm/scsi_cdrom.cpp
+++ b/source/src/vm/scsi_cdrom.cpp
@@ -76,6 +76,31 @@ void SCSI_CDROM::reset()
7676
7777 }
7878
79+void SCSI_CDROM::write_signal(int id, uint32_t data, uint32_t mask)
80+{
81+ bool _b = ((data & mask) != 0);
82+ switch(id) {
83+ case SIG_SCSI_CDROM_CDDA_STOP:
84+ if(cdda_status != CDDA_OFF) {
85+ if(_b) set_cdda_status(CDDA_OFF);
86+ }
87+ break;
88+ case SIG_SCSI_CDROM_CDDA_PLAY:
89+ if(cdda_status != CDDA_PLAYING) {
90+ if(_b) set_cdda_status(CDDA_PLAYING);
91+ }
92+ break;
93+ case SIG_SCSI_CDROM_CDDA_PAUSE:
94+ if(cdda_status != CDDA_PAUSED) {
95+ if(_b) set_cdda_status(CDDA_PAUSED);
96+ }
97+ break;
98+ default:
99+ SCSI_DEV::write_signal(id, data, mask);
100+ break;
101+ }
102+}
103+
79104 uint32_t SCSI_CDROM::read_signal(int id)
80105 {
81106 switch(id) {
--- a/source/src/vm/scsi_cdrom.h
+++ b/source/src/vm/scsi_cdrom.h
@@ -15,6 +15,9 @@
1515 #define SIG_SCSI_CDROM_PLAYING 0
1616 #define SIG_SCSI_CDROM_SAMPLE_L 1
1717 #define SIG_SCSI_CDROM_SAMPLE_R 2
18+#define SIG_SCSI_CDROM_CDDA_PLAY 3
19+#define SIG_SCSI_CDROM_CDDA_STOP 4
20+#define SIG_SCSI_CDROM_CDDA_PAUSE 5
1821
1922 class FILEIO;
2023
@@ -89,6 +92,7 @@ public:
8992 void release();
9093 void reset();
9194 uint32_t read_signal(int id);
95+ void write_signal(int id, uint32_t data, uint32_t mask);
9296 void event_callback(int event_id, int err);
9397 void mix(int32_t* buffer, int cnt);
9498 void set_volume(int ch, int decibel_l, int decibel_r);
--- a/source/src/vm/scsi_dev.h
+++ b/source/src/vm/scsi_dev.h
@@ -173,7 +173,7 @@ public:
173173 void initialize();
174174 void release();
175175 void reset();
176- void write_signal(int id, uint32_t data, uint32_t mask);
176+ virtual void write_signal(int id, uint32_t data, uint32_t mask);
177177 void event_callback(int event_id, int err);
178178 bool process_state(FILEIO* state_fio, bool loading);
179179
Show on old repository browser