From 24371e7a4af8a28e843218f3c887bc60360acc5b Mon Sep 17 00:00:00 2001 From: Olivier Galibert Date: Thu, 18 May 2023 18:09:58 +0200 Subject: cdda: Modernize a little cubo: Fix the setup --- src/devices/bus/ata/atapicdr.cpp | 6 +---- src/devices/bus/ata/gdrom.cpp | 2 -- src/devices/bus/isa/mcd.cpp | 2 +- src/devices/bus/nscsi/cd.cpp | 3 +-- src/devices/bus/scsi/scsicd.cpp | 4 +--- src/devices/machine/akiko.cpp | 15 +++++++++--- src/devices/machine/akiko.h | 2 ++ src/devices/machine/stvcd.cpp | 4 +--- src/devices/sound/cdda.cpp | 20 +++++----------- src/devices/sound/cdda.h | 8 ++++--- src/mame/amiga/cubo.cpp | 50 ++++++++++++++++++---------------------- src/mame/fujitsu/fmtowns.cpp | 2 +- src/mame/nec/pce_cd.cpp | 2 +- src/mame/shared/megacdcd.cpp | 2 +- 14 files changed, 55 insertions(+), 67 deletions(-) diff --git a/src/devices/bus/ata/atapicdr.cpp b/src/devices/bus/ata/atapicdr.cpp index b5803a3a6ba..5a6741c258a 100644 --- a/src/devices/bus/ata/atapicdr.cpp +++ b/src/devices/bus/ata/atapicdr.cpp @@ -52,7 +52,7 @@ void atapi_cdrom_device::device_add_mconfig(machine_config &config) GDROM(config, "image").set_interface("cdrom"); else CDROM(config, "image").set_interface("cdrom"); - CDDA(config, "cdda"); + CDDA(config, "cdda").set_cdrom_tag("image"); } void atapi_cdrom_device::device_start() @@ -107,7 +107,6 @@ void atapi_cdrom_device::device_reset() atapi_hle_device::device_reset(); m_media_change = true; m_sequence_counter = m_image->sequence_counter(); - m_cdda->set_cdrom(m_image); } void atapi_fixed_cdrom_device::device_reset() @@ -115,7 +114,6 @@ void atapi_fixed_cdrom_device::device_reset() atapi_hle_device::device_reset(); m_media_change = false; m_sequence_counter = m_image->sequence_counter(); - m_cdda->set_cdrom(m_image); } void atapi_dvdrom_device::device_reset() @@ -123,7 +121,6 @@ void atapi_dvdrom_device::device_reset() atapi_hle_device::device_reset(); m_media_change = true; m_sequence_counter = m_image->sequence_counter(); - m_cdda->set_cdrom(m_image); } void atapi_fixed_dvdrom_device::device_reset() @@ -131,7 +128,6 @@ void atapi_fixed_dvdrom_device::device_reset() atapi_hle_device::device_reset(); m_media_change = false; m_sequence_counter = m_image->sequence_counter(); - m_cdda->set_cdrom(m_image); } void atapi_cdrom_device::process_buffer() diff --git a/src/devices/bus/ata/gdrom.cpp b/src/devices/bus/ata/gdrom.cpp index a362bf5cb18..9d0f5c49dec 100644 --- a/src/devices/bus/ata/gdrom.cpp +++ b/src/devices/bus/ata/gdrom.cpp @@ -170,8 +170,6 @@ void gdrom_device::device_reset() GDROM_Cmd11_Reply[i] = GDROM_Def_Cmd11_Reply[i]; atapi_cdrom_device::device_reset(); - - m_cdda->set_cdrom(m_image); } // scsicd_exec_command diff --git a/src/devices/bus/isa/mcd.cpp b/src/devices/bus/isa/mcd.cpp index b0f0b79660f..0b99c220cd1 100644 --- a/src/devices/bus/isa/mcd.cpp +++ b/src/devices/bus/isa/mcd.cpp @@ -29,6 +29,7 @@ void mcd_isa_device::device_add_mconfig(machine_config &config) CDDA(config, m_cdda); m_cdda->add_route(0, "lheadphone", 1.0); m_cdda->add_route(1, "rheadphone", 1.0); + m_cdda->set_cdrom_tag(*this); } //------------------------------------------------- @@ -84,7 +85,6 @@ bool mcd_isa_device::read_sector(bool first) if(m_cdrom_handle->get_track_type(m_cdrom_handle->get_track(lba)) == cdrom_file::CD_TRACK_AUDIO) { m_cdda->stop_audio(); - m_cdda->set_cdrom(this); m_cdda->start_audio(lba, m_readcount); return true; } diff --git a/src/devices/bus/nscsi/cd.cpp b/src/devices/bus/nscsi/cd.cpp index c160af6f0f0..21a8658f3fb 100644 --- a/src/devices/bus/nscsi/cd.cpp +++ b/src/devices/bus/nscsi/cd.cpp @@ -99,7 +99,6 @@ void nscsi_cdrom_device::device_reset() { nscsi_full_device::device_reset(); sequence_counter = image->sequence_counter(); - cdda->set_cdrom(image); lba = 0; cur_sector = -1; mode_data_size = 12; @@ -108,7 +107,7 @@ void nscsi_cdrom_device::device_reset() void nscsi_cdrom_device::device_add_mconfig(machine_config &config) { CDROM(config, image).set_interface("cdrom"); - CDDA(config, "cdda"); + CDDA(config, cdda).set_cdrom_tag(image); } int nscsi_cdrom_device::to_msf(int frame) diff --git a/src/devices/bus/scsi/scsicd.cpp b/src/devices/bus/scsi/scsicd.cpp index d0e873175ad..2833917984f 100644 --- a/src/devices/bus/scsi/scsicd.cpp +++ b/src/devices/bus/scsi/scsicd.cpp @@ -33,14 +33,12 @@ void scsicd_device::device_start() void scsicd_device::device_reset() { scsihle_device::device_reset(); - - m_cdda->set_cdrom(m_image); } void scsicd_device::device_add_mconfig(machine_config &config) { CDROM(config, "image").set_interface("cdrom"); - CDDA(config, "cdda"); + CDDA(config, "cdda").set_cdrom_tag("image"); } bool scsicd_device::exists() const diff --git a/src/devices/machine/akiko.cpp b/src/devices/machine/akiko.cpp index 186d2a640ec..17de79e7d97 100644 --- a/src/devices/machine/akiko.cpp +++ b/src/devices/machine/akiko.cpp @@ -52,6 +52,11 @@ DEFINE_DEVICE_TYPE(AKIKO, akiko_device, "akiko", "CBM AKIKO") void akiko_device::device_add_mconfig(machine_config &config) { + CDROM(config, m_cdrom).set_interface("cdrom"); + CDDA(config, m_cdda); + m_cdda->add_route(0, ":lspeaker", 0.50); + m_cdda->add_route(1, ":rspeaker", 0.50); + m_cdda->set_cdrom_tag(m_cdrom); } @@ -83,8 +88,8 @@ akiko_device::akiko_device(const machine_config &mconfig, const char *tag, devic , m_cdrom_cmd_start(0) , m_cdrom_cmd_end(0) , m_cdrom_cmd_resp(0) - , m_cdda(*this, "^cdda") - , m_cdrom(*this, "^cdrom") + , m_cdda(*this, "cdda") + , m_cdrom(*this, "cdrom") , m_cdrom_toc(nullptr) , m_dma_timer(nullptr) , m_frame_timer(nullptr) @@ -252,6 +257,11 @@ void akiko_device::mem_w8(offs_t offset, uint8_t data) m_mem_w(offset, data << shift, 0xff << shift); } +void akiko_device::set_mute(bool mute) +{ + m_cdda->set_output_gain( 0, mute ? 0.0 : 1.0 ); +} + /************************************* * @@ -777,7 +787,6 @@ uint32_t akiko_device::read(offs_t offset) switch( offset ) { case 0x00/4: /* ID */ - if ( m_cdrom->exists() ) m_cdda->set_cdrom(m_cdrom); return 0x0000cafe; case 0x04/4: /* CDROM STATUS 1 */ diff --git a/src/devices/machine/akiko.h b/src/devices/machine/akiko.h index 0ceef8e118e..eddf3525e61 100644 --- a/src/devices/machine/akiko.h +++ b/src/devices/machine/akiko.h @@ -44,6 +44,8 @@ public: uint32_t read(offs_t offset); void write(offs_t offset, uint32_t data, uint32_t mem_mask = ~0); + void set_mute(bool mute); + protected: // device-level overrides virtual void device_start() override; diff --git a/src/devices/machine/stvcd.cpp b/src/devices/machine/stvcd.cpp index 2eb2511704a..af3ac2350c2 100644 --- a/src/devices/machine/stvcd.cpp +++ b/src/devices/machine/stvcd.cpp @@ -121,6 +121,7 @@ void stvcd_device::device_add_mconfig(machine_config &config) CDDA(config, m_cdda); m_cdda->add_route(0, *this, 1.0, AUTO_ALLOC_INPUT, 0); m_cdda->add_route(1, *this, 1.0, AUTO_ALLOC_INPUT, 1); + m_cdda->set_cdrom_tag("cdrom"); } void stvcd_device::device_start() @@ -2102,8 +2103,6 @@ void stvcd_device::device_reset() } // open device - m_cdda->set_cdrom(m_cdrom_image); - if (m_cdrom_image->exists()) { LOG("Opened CD-ROM successfully, reading root directory\n"); @@ -2819,7 +2818,6 @@ void stvcd_device::set_tray_close() return; hirqreg |= DCHG; - m_cdda->set_cdrom(m_cdrom_image); if (m_cdrom_image->exists()) { diff --git a/src/devices/sound/cdda.cpp b/src/devices/sound/cdda.cpp index 7eeef3871e4..dc763020935 100644 --- a/src/devices/sound/cdda.cpp +++ b/src/devices/sound/cdda.cpp @@ -38,7 +38,7 @@ void cdda_device::device_start() m_audio_length = 0; m_audio_samples = 0; m_audio_bptr = 0; - m_disc = nullptr; + m_sequence_counter = 0; m_audio_end_cb.resolve_safe(); @@ -50,17 +50,8 @@ void cdda_device::device_start() save_pointer( NAME(m_audio_cache), cdrom_file::MAX_SECTOR_DATA * MAX_SECTORS ); save_item( NAME(m_audio_samples) ); save_item( NAME(m_audio_bptr) ); -} - - -/*------------------------------------------------- - cdda_set_cdrom - set the CD-ROM file for the - given CDDA stream --------------------------------------------------*/ + save_item( NAME(m_sequence_counter) ); -void cdda_device::set_cdrom(cdrom_image_device *file) -{ - m_disc = file; } @@ -168,15 +159,16 @@ void cdda_device::get_audio_data(write_stream_view &bufL, write_stream_view &buf { /* if no file, audio not playing, audio paused, or out of disc data, just zero fill */ - if (!m_disc || !m_audio_playing || m_audio_pause || (!m_audio_length && !m_audio_samples)) + if (m_disc->sequence_counter() != m_sequence_counter || !m_disc->exists() || !m_audio_playing || m_audio_pause || (!m_audio_length && !m_audio_samples)) { - if( m_disc && m_audio_playing && !m_audio_pause && !m_audio_length ) + if( m_audio_playing && !m_audio_pause && !m_audio_length ) { m_audio_playing = false; m_audio_ended_normally = true; m_audio_end_cb(ASSERT_LINE); } + m_sequence_counter = m_disc->sequence_counter(); m_audio_data[0] = m_audio_data[1] = 0; bufL.fill(0, sampindex); bufR.fill(0, sampindex); @@ -245,7 +237,7 @@ DEFINE_DEVICE_TYPE(CDDA, cdda_device, "cdda", "CD/DA") cdda_device::cdda_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : device_t(mconfig, CDDA, tag, owner, clock) , device_sound_interface(mconfig, *this) - , m_disc(nullptr) + , m_disc(*this, finder_base::DUMMY_TAG) , m_stream(nullptr) , m_audio_end_cb(*this) { diff --git a/src/devices/sound/cdda.h b/src/devices/sound/cdda.h index 516b0006336..1d8921f688e 100644 --- a/src/devices/sound/cdda.h +++ b/src/devices/sound/cdda.h @@ -11,9 +11,9 @@ class cdda_device : public device_t, public device_sound_interface { public: - cdda_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 44'100); + cdda_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock = 44100); - void set_cdrom(cdrom_image_device *file); + template void set_cdrom_tag(T &&tag) { m_disc.set_tag(std::forward(tag)); } void start_audio(uint32_t startlba, uint32_t numblocks); void stop_audio(); @@ -37,7 +37,7 @@ protected: private: void get_audio_data(write_stream_view &bufL, write_stream_view &bufR); - cdrom_image_device * m_disc; + required_device m_disc; // internal state sound_stream * m_stream; @@ -50,6 +50,8 @@ private: uint32_t m_audio_bptr; int16_t m_audio_data[2]; + uint32_t m_sequence_counter; + devcb_write_line m_audio_end_cb; }; diff --git a/src/mame/amiga/cubo.cpp b/src/mame/amiga/cubo.cpp index fa81edd3b7a..a19025f9b26 100644 --- a/src/mame/amiga/cubo.cpp +++ b/src/mame/amiga/cubo.cpp @@ -337,7 +337,7 @@ public: : amiga_state(mconfig, type, tag) , m_player_ports(*this, {"P1", "P2"}) , m_microtouch(*this, "microtouch") - , m_cdda(*this, "cdda") + , m_akiko(*this, "akiko") { } void handle_joystick_cia(uint8_t pra, uint8_t dra); @@ -374,7 +374,7 @@ protected: private: required_device m_microtouch; - required_device m_cdda; + required_device m_akiko; typedef void (cubo_state::*input_hack_func)(); input_hack_func m_input_hack{}; @@ -414,7 +414,7 @@ WRITE_LINE_MEMBER( cubo_state::akiko_int_w ) void cubo_state::akiko_cia_0_port_a_write(uint8_t data) { /* bit 0 = cd audio mute */ - m_cdda->set_output_gain( 0, ( data & 1 ) ? 0.0 : 1.0 ); + m_akiko->set_mute(data & 1); /* bit 1 = Power Led on Amiga */ m_power_led = BIT(~data, 1); @@ -438,7 +438,7 @@ void cubo_state::cubo_mem(address_map &map) map(0x800000, 0x800003).portr("DIPSW1"); map(0x800010, 0x800013).portr("DIPSW2"); map(0xa80000, 0xb7ffff).noprw(); - map(0xb80000, 0xb8003f).rw("akiko", FUNC(akiko_device::read), FUNC(akiko_device::write)); + map(0xb80000, 0xb8003f).rw(m_akiko, FUNC(akiko_device::read), FUNC(akiko_device::write)); map(0xbf0000, 0xbfffff).rw(FUNC(cubo_state::cia_r), FUNC(cubo_state::gayle_cia_w)); map(0xc00000, 0xdfffff).m(m_chipset, FUNC(address_map_bank_device::amap32)); map(0xe00000, 0xe7ffff).rom().region("kickstart", 0x80000); @@ -1082,13 +1082,13 @@ void cubo_state::cubo(machine_config &config) I2C_24C08(config, "i2cmem", 0); // AT24C08N - akiko_device &akiko(AKIKO(config, "akiko", 0)); - akiko.mem_r_callback().set(FUNC(amiga_state::chip_ram_r)); - akiko.mem_w_callback().set(FUNC(amiga_state::chip_ram_w)); - akiko.int_callback().set(FUNC(cubo_state::akiko_int_w)); - akiko.scl_callback().set("i2cmem", FUNC(i2cmem_device::write_scl)); - akiko.sda_r_callback().set("i2cmem", FUNC(i2cmem_device::read_sda)); - akiko.sda_w_callback().set("i2cmem", FUNC(i2cmem_device::write_sda)); + AKIKO(config, m_akiko, 0); + m_akiko->mem_r_callback().set(FUNC(amiga_state::chip_ram_r)); + m_akiko->mem_w_callback().set(FUNC(amiga_state::chip_ram_w)); + m_akiko->int_callback().set(FUNC(cubo_state::akiko_int_w)); + m_akiko->scl_callback().set("i2cmem", FUNC(i2cmem_device::write_scl)); + m_akiko->sda_r_callback().set("i2cmem", FUNC(i2cmem_device::read_sda)); + m_akiko->sda_w_callback().set("i2cmem", FUNC(i2cmem_device::write_sda)); // video hardware pal_video(config); @@ -1109,10 +1109,6 @@ void cubo_state::cubo(machine_config &config) m_paula->mem_read_cb().set(FUNC(amiga_state::chip_ram_r)); m_paula->int_cb().set(FUNC(amiga_state::paula_int_w)); - CDDA(config, m_cdda); - m_cdda->add_route(0, "lspeaker", 0.50); - m_cdda->add_route(1, "rspeaker", 0.50); - /* cia */ // these are setup differently on other amiga drivers (needed for floppy to work) which is correct / why? MOS8520(config, m_cia_0, amiga_state::CLK_E_PAL); @@ -1125,8 +1121,6 @@ void cubo_state::cubo(machine_config &config) MICROTOUCH(config, m_microtouch, 9600).stx().set(FUNC(cubo_state::rs232_rx_w)); - CDROM(config, "cdrom").set_interface("cdrom"); - /* fdc */ AMIGA_FDC(config, m_fdc, amiga_state::CLK_7M_PAL); m_fdc->index_callback().set("cia_1", FUNC(mos8520_device::flag_w)); @@ -1163,77 +1157,77 @@ void cubo_state::init_cubo() ROM_START( cndypuzl ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "cndypuzl", 0, BAD_DUMP SHA1(5f41ed3521b3e05d233ac1245b78cb0b118b2b90) ) ROM_END ROM_START( haremchl ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "haremchl", 0, BAD_DUMP SHA1(abbab347c0d7c5eef0465d0eee770754a452e874) ) ROM_END ROM_START( lsrquiz ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "lsrquiz", 0, BAD_DUMP SHA1(41fb6cd0c9d36bd77e9c3db69d36801edc791e96) ) ROM_END ROM_START( lsrquiz2i ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "lsrquiz2", 0, BAD_DUMP SHA1(78e261df1c548fa492e6cf37a9469640bb8816bf) ) ROM_END ROM_START( lsrquizg ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "laserquizgreek2pro", 0, BAD_DUMP SHA1(8538915b4a0078f19197a5562e37ed3e6d0429a4) ) ROM_END ROM_START( mgprem11 ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "mgprem11", 0, BAD_DUMP SHA1(7808db33d5949f6c86d12b32bc388c12377e7038) ) ROM_END ROM_START( lasstixx ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "lasstixx", 0, BAD_DUMP SHA1(b8f6138e1f1840c193e786c56dab03c512f3e21f) ) ROM_END ROM_START( mgnumber ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "magicnumber", 0, BAD_DUMP SHA1(60e1fadc42694742d19cc0ac2b6e99e9e33faa3d) ) ROM_END ROM_START( odeontw ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "twister32_17_3", 0, BAD_DUMP SHA1(a40ec484708e22059f7186415283084ebf01323e) ) // has its audio cut a little, worth to mark as redump needed ROM_END ROM_START( odeontw2 ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "odeontw2", 0, BAD_DUMP SHA1(f39e09f35b65a6ae9f1eba4a22f970626b7d3b71) ) ROM_END ROM_START( eldoralg ) CD32_BIOS - DISK_REGION( "cdrom" ) + DISK_REGION( "akiko" ) DISK_IMAGE_READONLY( "eldorado", 0, BAD_DUMP SHA1(bc1617c2e3438b729421c1d8b1bf88840b12f030) ) ROM_END diff --git a/src/mame/fujitsu/fmtowns.cpp b/src/mame/fujitsu/fmtowns.cpp index 3d54fd492c6..1a34b87e571 100644 --- a/src/mame/fujitsu/fmtowns.cpp +++ b/src/mame/fujitsu/fmtowns.cpp @@ -1332,7 +1332,6 @@ void towns_state::towns_cdrom_play_cdda(cdrom_image_device* device) m_towns_cd.cdda_current = msf_to_lbafm(lba1); m_towns_cd.cdda_length = msf_to_lbafm(lba2) - m_towns_cd.cdda_current + 1; - m_cdda->set_cdrom(device); m_cdda->start_audio(m_towns_cd.cdda_current,m_towns_cd.cdda_length); if(LOG_CD) logerror("CD: CD-DA start from LBA:%i length:%i\n",m_towns_cd.cdda_current,m_towns_cd.cdda_length); if(m_towns_cd.command & 0x20) @@ -2553,6 +2552,7 @@ void towns_state::towns_base(machine_config &config) SOFTWARE_LIST(config, "fd_list_misc").set_original("fmtowns_flop_misc"); CDROM(config, m_cdrom, 0).set_interface("fmt_cdrom"); + m_cdda->set_cdrom_tag(m_cdrom); SOFTWARE_LIST(config, "cd_list").set_original("fmtowns_cd"); UPD71071(config, m_dma[0], 0); diff --git a/src/mame/nec/pce_cd.cpp b/src/mame/nec/pce_cd.cpp index e57fddab3d6..2e4dc4b5baa 100644 --- a/src/mame/nec/pce_cd.cpp +++ b/src/mame/nec/pce_cd.cpp @@ -242,7 +242,6 @@ void pce_cd_device::late_setup() if (m_cdrom->exists()) { m_toc = &m_cdrom->get_toc(); - m_cdda->set_cdrom(m_cdrom); m_last_frame = m_cdrom->get_track_start(m_cdrom->get_last_track() - 1); m_last_frame += m_toc->tracks[m_cdrom->get_last_track() - 1].frames; m_end_frame = m_last_frame; @@ -277,6 +276,7 @@ void pce_cd_device::device_add_mconfig(machine_config &config) m_msm->add_route(ALL_OUTPUTS, "^rspeaker", 0.50); CDDA(config, m_cdda); + m_cdda->set_cdrom_tag(m_cdrom); m_cdda->audio_end_cb().set(FUNC(pce_cd_device::cdda_end_mark_cb)); m_cdda->add_route(0, "^lspeaker", 1.00); m_cdda->add_route(1, "^rspeaker", 1.00); diff --git a/src/mame/shared/megacdcd.cpp b/src/mame/shared/megacdcd.cpp index 0b4a53009b0..c7fc4753c31 100644 --- a/src/mame/shared/megacdcd.cpp +++ b/src/mame/shared/megacdcd.cpp @@ -1121,7 +1121,6 @@ void lc89510_temp_device::reset_cd(void) if ( m_cdrom->exists() ) { segacd.toc = &m_cdrom->get_toc(); - m_cdda->set_cdrom(m_cdrom); m_cdda->stop_audio(); //stop any pending CD-DA } } @@ -1164,6 +1163,7 @@ void lc89510_temp_device::device_add_mconfig(machine_config &config) cdda_device &cdda(CDDA(config, "cdda")); cdda.add_route(0, ":lspeaker", 0.50); // TODO: accurate volume balance cdda.add_route(1, ":rspeaker", 0.50); + cdda.set_cdrom_tag(m_cdrom); } -- cgit v1.2.3