From bf6d5d7a2deee1224bb845bcba4c30ec4e55e64f Mon Sep 17 00:00:00 2001 From: Vas Crabb Date: Thu, 25 Jul 2024 06:51:43 +1000 Subject: Miscellaneous fixes: igspgmcrypt.cpp: Fixed a recently-introduced Endianness issue. sega/dsbz80.cpp: Don't leak the MPEG audio decoder. sega/dsbz80.cpp: Don't initialise the sample buffer on construction - it happens on reset anyway. formats/fs_coco_os9.cpp: Use lowercase for hexadecimal literals. --- src/lib/formats/fs_coco_os9.cpp | 48 ++++++++++++++++++++--------------------- src/mame/igs/pgmcrypt.cpp | 2 +- src/mame/sega/dsbz80.cpp | 24 ++++++++++++++------- src/mame/sega/dsbz80.h | 20 +++++++++++------ src/mame/skeleton/boo.cpp | 4 ++-- 5 files changed, 56 insertions(+), 42 deletions(-) diff --git a/src/lib/formats/fs_coco_os9.cpp b/src/lib/formats/fs_coco_os9.cpp index f8a14c7acdd..334bb9d5b79 100644 --- a/src/lib/formats/fs_coco_os9.cpp +++ b/src/lib/formats/fs_coco_os9.cpp @@ -364,7 +364,7 @@ std::pair> coco_os9_impl::file_read(const std::vector= total_allocated_sectors) abblk_bytes[j] = 0x00; else @@ -442,28 +442,28 @@ err_t coco_os9_impl::format(const meta_data &meta) // root directory header auto roothdr_blk = m_blockdev.get(1 + allocation_bitmap_lsns); roothdr_blk.fill(0x00); - roothdr_blk.w8(0x00, 0xBF); + roothdr_blk.w8(0x00, 0xbf); roothdr_blk.w8(0x01, 0x00); roothdr_blk.w8(0x02, 0x00); roothdr_blk.w24b(0x03, creation_os9date); roothdr_blk.w16b(0x06, creation_os9time); roothdr_blk.w8(0x08, 0x01); roothdr_blk.w8(0x09, 0x00); - roothdr_blk.w8(0x0A, 0x00); - roothdr_blk.w8(0x0B, 0x00); - roothdr_blk.w8(0x0C, 0x40); - roothdr_blk.w24b(0x0D, creation_os9date); + roothdr_blk.w8(0x0a, 0x00); + roothdr_blk.w8(0x0b, 0x00); + roothdr_blk.w8(0x0c, 0x40); + roothdr_blk.w24b(0x0d, creation_os9date); roothdr_blk.w24b(0x10, 1 + allocation_bitmap_lsns + 1); roothdr_blk.w16b(0x13, 8); // root directory data auto rootdata_blk = m_blockdev.get(1 + allocation_bitmap_lsns + 1); rootdata_blk.fill(0x00); - rootdata_blk.w8(0x00, 0x2E); - rootdata_blk.w8(0x01, 0xAE); - rootdata_blk.w8(0x1F, 1 + allocation_bitmap_lsns); - rootdata_blk.w8(0x20, 0xAE); - rootdata_blk.w8(0x3F, 1 + allocation_bitmap_lsns); + rootdata_blk.w8(0x00, 0x2e); + rootdata_blk.w8(0x01, 0xae); + rootdata_blk.w8(0x1f, 1 + allocation_bitmap_lsns); + rootdata_blk.w8(0x20, 0xae); + rootdata_blk.w8(0x3f, 1 + allocation_bitmap_lsns); return ERR_OK; } @@ -580,7 +580,7 @@ std::string coco_os9_impl::pick_os9_string(std::string_view raw_string) // and add the final character if we have to if (iter < raw_string.end() && *iter & 0x80) - result.append(1, *iter & 0x7F); + result.append(1, *iter & 0x7f); return result; } @@ -595,7 +595,7 @@ std::string coco_os9_impl::to_os9_string(std::string_view s, size_t length) std::string result(length, '\0'); for (auto i = 0; i < std::min(length, s.size()); i++) { - result[i] = (s[i] & 0x7F) + result[i] = (s[i] & 0x7f) | (i == s.size() ? 0x80 : 0x00); } return result; @@ -610,11 +610,11 @@ util::arbitrary_datetime coco_os9_impl::from_os9_date(u32 os9_date, u16 os9_time { util::arbitrary_datetime dt; memset(&dt, 0, sizeof(dt)); - dt.year = ((os9_date >> 16) & 0xFF) + 1900; - dt.month = (os9_date >> 8) & 0xFF; - dt.day_of_month = (os9_date >> 0) & 0xFF; - dt.hour = (os9_time >> 8) & 0xFF; - dt.minute = (os9_time >> 0) & 0xFF; + dt.year = ((os9_date >> 16) & 0xff) + 1900; + dt.month = (os9_date >> 8) & 0xff; + dt.day_of_month = (os9_date >> 0) & 0xff; + dt.hour = (os9_time >> 8) & 0xff; + dt.minute = (os9_time >> 0) & 0xff; return dt; } @@ -625,11 +625,11 @@ util::arbitrary_datetime coco_os9_impl::from_os9_date(u32 os9_date, u16 os9_time std::tuple coco_os9_impl::to_os9_date(const util::arbitrary_datetime &datetime) { - u32 os9_date = ((datetime.year - 1900) & 0xFF) << 16 - | (datetime.month & 0xFF) << 8 - | (datetime.day_of_month & 0xFF) << 0; - u16 os9_time = (datetime.hour & 0xFF) << 8 - | (datetime.minute & 0xFF) << 0; + u32 os9_date = ((datetime.year - 1900) & 0xff) << 16 + | (datetime.month & 0xff) << 8 + | (datetime.day_of_month & 0xff) << 0; + u16 os9_time = (datetime.hour & 0xff) << 8 + | (datetime.minute & 0xff) << 0; return std::make_tuple(os9_date, os9_time); } diff --git a/src/mame/igs/pgmcrypt.cpp b/src/mame/igs/pgmcrypt.cpp index 05fc751d77a..bf40b16c7bf 100644 --- a/src/mame/igs/pgmcrypt.cpp +++ b/src/mame/igs/pgmcrypt.cpp @@ -2161,7 +2161,7 @@ static const uint8_t icescape_tab[0x100] = { void icescape_decrypt(running_machine &machine) { - auto const src = reinterpret_cast(machine.root_device().memregion("user1")->base()); + auto const src = util::little_endian_cast(reinterpret_cast(machine.root_device().memregion("user1")->base())); int const rom_size = 0x80000; diff --git a/src/mame/sega/dsbz80.cpp b/src/mame/sega/dsbz80.cpp index 77564109635..f6060d890cb 100644 --- a/src/mame/sega/dsbz80.cpp +++ b/src/mame/sega/dsbz80.cpp @@ -73,6 +73,7 @@ dsbz80_device::dsbz80_device(const machine_config &mconfig, const char *tag, dev m_ourcpu(*this, "mpegcpu"), m_uart(*this, "uart"), m_mpeg_rom(*this, "mpeg"), + m_rxd_handler(*this), m_mp_start(0), m_mp_end(0), m_mp_vol(0x7f), @@ -84,10 +85,8 @@ dsbz80_device::dsbz80_device(const machine_config &mconfig, const char *tag, dev m_end(0), m_mp_pos(0), m_audio_pos(0), - m_audio_avail(0), - m_rxd_handler(*this) + m_audio_avail(0) { - std::fill(std::begin(m_audio_buf), std::end(m_audio_buf), 0); } //------------------------------------------------- @@ -96,7 +95,7 @@ dsbz80_device::dsbz80_device(const machine_config &mconfig, const char *tag, dev void dsbz80_device::device_start() { - m_decoder = new mpeg_audio(&m_mpeg_rom[0], mpeg_audio::L2, false, 0); + m_decoder.reset(new mpeg_audio(&m_mpeg_rom[0], mpeg_audio::L2, false, 0)); stream_alloc(0, 2, 32000); save_item(NAME(m_mp_start)); @@ -128,6 +127,15 @@ void dsbz80_device::device_reset() m_uart->write_cts(0); } +//------------------------------------------------- +// device_stop - device-specific cleanup +//------------------------------------------------- + +void dsbz80_device::device_stop() +{ + m_decoder.reset(); +} + void dsbz80_device::write_txd(int state) { m_uart->write_rxd(state); @@ -251,7 +259,7 @@ void dsbz80_device::mpeg_end_w(offs_t offset, uint8_t data) void dsbz80_device::mpeg_volume_w(uint8_t data) { // TODO: MSB used but unknown purpose - m_mp_vol = 0x7f - (data & 0x7f); + m_mp_vol = ~data & 0x7f; } void dsbz80_device::mpeg_stereo_w(uint8_t data) @@ -268,7 +276,7 @@ void dsbz80_device::sound_stream_update(sound_stream &stream, std::vector + + //************************************************************************** // TYPE DEFINITIONS //************************************************************************** @@ -24,14 +27,14 @@ public: void write_txd(int state); - void dsbz80_map(address_map &map); - void dsbz80io_map(address_map &map); - protected: - // device-level overrides + // device_t implementation virtual void device_start() override; virtual void device_reset() override; + virtual void device_stop() override; virtual void device_add_mconfig(machine_config &config) override; + + // device_sound_interface implementation virtual void sound_stream_update(sound_stream &stream, std::vector const &inputs, std::vector &outputs) override; private: @@ -39,13 +42,13 @@ private: required_device m_uart; required_region_ptr m_mpeg_rom; - mpeg_audio *m_decoder; + devcb_write_line m_rxd_handler; + + std::unique_ptr m_decoder; int16_t m_audio_buf[1152*2]; uint32_t m_mp_start, m_mp_end, m_mp_vol, m_mp_pan, m_mp_state, m_lp_start, m_lp_end, m_start, m_end; int32_t m_mp_pos, m_audio_pos, m_audio_avail; - devcb_write_line m_rxd_handler; - void output_txd(int state); void mpeg_trigger_w(uint8_t data); @@ -54,6 +57,9 @@ private: void mpeg_volume_w(uint8_t data); void mpeg_stereo_w(uint8_t data); uint8_t mpeg_pos_r(offs_t offset); + + void dsbz80_map(address_map &map); + void dsbz80io_map(address_map &map); }; diff --git a/src/mame/skeleton/boo.cpp b/src/mame/skeleton/boo.cpp index 75df476c7b0..ae595fe77e2 100644 --- a/src/mame/skeleton/boo.cpp +++ b/src/mame/skeleton/boo.cpp @@ -31,8 +31,8 @@ namespace { class boo_state : public driver_device { public: - boo_state(const machine_config &mconfig, device_type type, const char *tag) - : driver_device(mconfig, type, tag), + boo_state(const machine_config &mconfig, device_type type, const char *tag) : + driver_device(mconfig, type, tag), m_maincpu(*this, "maincpu"), m_gfxdecode(*this, "gfxdecode") { } -- cgit v1.2.3