diff options
| author | 2022-08-26 02:20:44 +1000 | |
|---|---|---|
| committer | 2022-08-26 02:20:44 +1000 | |
| commit | cfa539f1ede5c443fb091cbe82fca019ea6c54a1 (patch) | |
| tree | ddc86c6f502b22d3406b40fd55c0d22e27cd5d94 /src | |
| parent | 278ebb10d53336d6bc458e62edd824ebb7cd6ac6 (diff) | |
-megaduck.xml: Added explicit info about cartridge banking.
* There are three kinds of cartridge: 32K flat, 16K fixed plus 16K
switchable, and 32K switchable. Cart implementation will come later.
-Various cleanups:
* gbcolor.xml: Proper Pinyin description for sqsd.
* sound/pokey.cpp: Minor cleanup, and got rid of an unnecessary member
in channel structures (only used in inline member functions).
* nintendo/gb.cpp: Spell Mega Duck with a space consistently.
* sega/turbo_a.cpp: Use an optional device finder to get discrete sound
device. The function that would add this seems to have been lost.
Diffstat (limited to 'src')
| -rw-r--r-- | src/devices/bus/generic/slot.h | 32 | ||||
| -rw-r--r-- | src/devices/bus/vboy/rom.cpp | 2 | ||||
| -rw-r--r-- | src/devices/bus/vboy/slot.cpp | 9 | ||||
| -rw-r--r-- | src/devices/bus/vboy/slot.h | 18 | ||||
| -rw-r--r-- | src/devices/sound/pokey.cpp | 87 | ||||
| -rw-r--r-- | src/devices/sound/pokey.h | 28 | ||||
| -rw-r--r-- | src/mame/nintendo/gb.cpp | 4 | ||||
| -rw-r--r-- | src/mame/sega/turbo.h | 2 | ||||
| -rw-r--r-- | src/mame/sega/turbo_a.cpp | 25 |
9 files changed, 121 insertions, 86 deletions
diff --git a/src/devices/bus/generic/slot.h b/src/devices/bus/generic/slot.h index da1e7e21988..c6f506a03bf 100644 --- a/src/devices/bus/generic/slot.h +++ b/src/devices/bus/generic/slot.h @@ -52,6 +52,38 @@ public: } } + // TODO: find a better home for this helper + template <typename T, typename U> + static T map_non_power_of_two(T count, U &&map) + { + if (T(0) >= count) + return T(0); + + T const max(count - 1); + T mask(max); + for (unsigned i = 1; (sizeof(T) * 8) > i; i <<= 1) + mask = T(std::make_unsigned_t<T>(mask) | (std::make_unsigned_t<T>(mask) >> i)); + int bits(0); + while (BIT(mask, bits)) + ++bits; + + for (T entry = T(0); mask >= entry; ++entry) + { + T mapped(entry); + int b(bits - 1); + while (max < mapped) + { + while (BIT(max, b)) + --b; + assert(0 <= b); + mapped = T(std::make_unsigned_t<T>(mapped) & ~(std::make_unsigned_t<T>(1) << b--)); + } + map(entry, mapped); + } + + return mask; + } + // construction/destruction virtual ~device_generic_cart_interface(); diff --git a/src/devices/bus/vboy/rom.cpp b/src/devices/bus/vboy/rom.cpp index 14fac38ca1f..434741458b0 100644 --- a/src/devices/bus/vboy/rom.cpp +++ b/src/devices/bus/vboy/rom.cpp @@ -63,7 +63,7 @@ image_init_result vboy_flat_rom_device::load() 0, 0, rom_base(), - [this, rom = reinterpret_cast<u32 *>(romregion->base())] (offs_t begin, offs_t end, offs_t mirror, offs_t src) + [this, rom = &romregion->as_u32()] (offs_t begin, offs_t end, offs_t mirror, offs_t src) { LOG( "Install ROM 0x%08X-0x%08X at 0x%08X-0x%08X mirror %08X\n", diff --git a/src/devices/bus/vboy/slot.cpp b/src/devices/bus/vboy/slot.cpp index 1fe0c1c651e..0c6df96ca61 100644 --- a/src/devices/bus/vboy/slot.cpp +++ b/src/devices/bus/vboy/slot.cpp @@ -27,6 +27,7 @@ DEFINE_DEVICE_TYPE(VBOY_CART_SLOT, vboy_cart_slot_device, "vboy_cart_slot", "Nintendo Virtual Boy Cartridge Slot") + //************************************************************************** // vboy_cart_slot_device //************************************************************************** @@ -129,22 +130,22 @@ std::string vboy_cart_slot_device::get_default_card_software(get_default_card_so software_part const *const part(!image_name.empty() ? find_software_item(image_name, true) : nullptr); if (part) { - //printf("[%s] Found software part for image name '%s'\n", tag(), image_name.c_str()); + osd_printf_verbose("[%s] Found software part for image name '%s'\n", tag(), image_name); for (rom_entry const &entry : part->romdata()) { if (ROMENTRY_ISREGION(entry) && (entry.name() == "sram")) { - //printf("[%s] Found 'sram' data area, enabling cartridge backup RAM\n", tag()); + osd_printf_verbose("[%s] Found 'sram' data area, enabling cartridge backup RAM\n", tag()); return "flatrom_sram"; } } } else { - //printf("[%s] No software part found for image name '%s'\n", tag(), image_name.c_str()); + osd_printf_verbose("[%s] No software part found for image name '%s'\n", tag(), image_name); } - //printf("[%s] Assuming plain ROM cartridge\n", tag()); + osd_printf_verbose("[%s] Assuming plain ROM cartridge\n", tag()); return "flatrom"; } diff --git a/src/devices/bus/vboy/slot.h b/src/devices/bus/vboy/slot.h index 650c3380636..b628db8af0d 100644 --- a/src/devices/bus/vboy/slot.h +++ b/src/devices/bus/vboy/slot.h @@ -64,6 +64,10 @@ #include "imagedev/cartrom.h" +#include <cassert> +#include <string> +#include <utility> + //************************************************************************** // FORWARD DECLARATIONS @@ -140,13 +144,13 @@ public: protected: device_vboy_cart_interface(machine_config const &mconfig, device_t &device); - bool has_slot() const { return nullptr != m_slot; } - address_space *exp_space() { return m_slot ? m_slot->m_exp_space.target() : nullptr; } - address_space *chip_space() { return m_slot ? m_slot->m_chip_space.target() : nullptr; } - address_space *rom_space() { return m_slot ? m_slot->m_rom_space.target() : nullptr; } - offs_t exp_base() { return m_slot ? m_slot->m_exp_base : 0U; } - offs_t chip_base() { return m_slot ? m_slot->m_chip_base : 0U; } - offs_t rom_base() { return m_slot ? m_slot->m_rom_base : 0U; } + bool has_slot() const noexcept { return nullptr != m_slot; } + address_space *exp_space() noexcept { return m_slot ? m_slot->m_exp_space.target() : nullptr; } + address_space *chip_space() noexcept { return m_slot ? m_slot->m_chip_space.target() : nullptr; } + address_space *rom_space() noexcept { return m_slot ? m_slot->m_rom_space.target() : nullptr; } + offs_t exp_base() noexcept { return m_slot ? m_slot->m_exp_base : 0U; } + offs_t chip_base() noexcept { return m_slot ? m_slot->m_chip_base : 0U; } + offs_t rom_base() noexcept { return m_slot ? m_slot->m_rom_base : 0U; } void battery_load(void *buffer, int length, int fill) { assert(m_slot); m_slot->battery_load(buffer, length, fill); } void battery_load(void *buffer, int length, void *def_buffer) { assert(m_slot); m_slot->battery_load(buffer, length, def_buffer); } diff --git a/src/devices/sound/pokey.cpp b/src/devices/sound/pokey.cpp index 7a67605e4fe..11bf0bc3158 100644 --- a/src/devices/sound/pokey.cpp +++ b/src/devices/sound/pokey.cpp @@ -189,23 +189,23 @@ DEFINE_DEVICE_TYPE(POKEY, pokey_device, "pokey", "Atari C012294 POKEY") // pokey_device - constructor //------------------------------------------------- -pokey_device::pokey_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) - : device_t(mconfig, POKEY, tag, owner, clock), - device_sound_interface(mconfig, *this), - device_execute_interface(mconfig, *this), - device_state_interface(mconfig, *this), - m_icount(0), - m_stream(nullptr), - m_pot_r_cb(*this), - m_allpot_r_cb(*this), - m_serin_r_cb(*this), - m_serout_w_cb(*this), - m_keyboard_r(*this), - m_irq_f(*this), - m_output_type(LEGACY_LINEAR), - m_serout_ready_timer(nullptr), - m_serout_complete_timer(nullptr), - m_serin_ready_timer(nullptr) +pokey_device::pokey_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) : + device_t(mconfig, POKEY, tag, owner, clock), + device_sound_interface(mconfig, *this), + device_execute_interface(mconfig, *this), + device_state_interface(mconfig, *this), + m_icount(0), + m_stream(nullptr), + m_pot_r_cb(*this), + m_allpot_r_cb(*this), + m_serin_r_cb(*this), + m_serout_w_cb(*this), + m_keyboard_r(*this), + m_irq_f(*this), + m_output_type(LEGACY_LINEAR), + m_serout_ready_timer(nullptr), + m_serout_complete_timer(nullptr), + m_serin_ready_timer(nullptr) { } @@ -217,12 +217,9 @@ void pokey_device::device_start() { //int sample_rate = clock(); - /* Setup channels */ - for (int i=0; i<POKEY_CHANNELS; i++) - { - m_channel[i].m_parent = this; - m_channel[i].m_INTMask = 0; - } + // Set up channels + for (pokey_channel &chan : m_channel) + chan.m_INTMask = 0; m_channel[CHAN1].m_INTMask = IRQ_TIMR1; m_channel[CHAN2].m_INTMask = IRQ_TIMR2; m_channel[CHAN4].m_INTMask = IRQ_TIMR4; @@ -249,7 +246,7 @@ void pokey_device::device_start() vol_init(); for (int i=0; i<4; i++) - m_channel[i].m_AUDC = 0xB0; + m_channel[i].m_AUDC = 0xb0; /* The pokey does not have a reset line. These should be initialized * with random values. @@ -570,7 +567,7 @@ void pokey_device::step_pot() * */ -void pokey_device::step_one_clock(void) +void pokey_device::step_one_clock() { if (m_SKCTL & SK_RESET) { @@ -604,33 +601,33 @@ void pokey_device::step_one_clock(void) if ((m_AUDCTL & CH1_HICLK) && (clock_triggered[CLK_1])) { if (m_AUDCTL & CH12_JOINED) - m_channel[CHAN1].inc_chan(7); + m_channel[CHAN1].inc_chan(*this, 7); else - m_channel[CHAN1].inc_chan(4); + m_channel[CHAN1].inc_chan(*this, 4); } int base_clock = (m_AUDCTL & CLK_15KHZ) ? CLK_114 : CLK_28; if ((!(m_AUDCTL & CH1_HICLK)) && (clock_triggered[base_clock])) - m_channel[CHAN1].inc_chan(1); + m_channel[CHAN1].inc_chan(*this, 1); if ((m_AUDCTL & CH3_HICLK) && (clock_triggered[CLK_1])) { if (m_AUDCTL & CH34_JOINED) - m_channel[CHAN3].inc_chan(7); + m_channel[CHAN3].inc_chan(*this, 7); else - m_channel[CHAN3].inc_chan(4); + m_channel[CHAN3].inc_chan(*this, 4); } if ((!(m_AUDCTL & CH3_HICLK)) && (clock_triggered[base_clock])) - m_channel[CHAN3].inc_chan(1); + m_channel[CHAN3].inc_chan(*this, 1); if (clock_triggered[base_clock]) { if (!(m_AUDCTL & CH12_JOINED)) - m_channel[CHAN2].inc_chan(1); + m_channel[CHAN2].inc_chan(*this, 1); if (!(m_AUDCTL & CH34_JOINED)) - m_channel[CHAN4].inc_chan(1); + m_channel[CHAN4].inc_chan(*this, 1); } /* Potentiometer handling */ @@ -645,7 +642,7 @@ void pokey_device::step_one_clock(void) if (m_channel[CHAN3].check_borrow()) { if (m_AUDCTL & CH34_JOINED) - m_channel[CHAN4].inc_chan(1); + m_channel[CHAN4].inc_chan(*this, 1); else m_channel[CHAN3].reset_channel(); @@ -677,7 +674,7 @@ void pokey_device::step_one_clock(void) m_old_raw_inval = true; } - if ( (m_SKCTL & SK_TWOTONE) && (m_channel[CHAN2].m_borrow_cnt == 1) ) + if ((m_SKCTL & SK_TWOTONE) && (m_channel[CHAN2].m_borrow_cnt == 1)) { m_channel[CHAN1].reset_channel(); m_old_raw_inval = true; @@ -686,7 +683,7 @@ void pokey_device::step_one_clock(void) if (m_channel[CHAN1].check_borrow()) { if (m_AUDCTL & CH12_JOINED) - m_channel[CHAN2].inc_chan(1); + m_channel[CHAN2].inc_chan(*this, 1); else m_channel[CHAN1].reset_channel(); @@ -710,7 +707,7 @@ void pokey_device::step_one_clock(void) // check if some of the requested timer interrupts are enabled if ((m_IRQST & IRQ_TIMR2) && !m_irq_f.isnull()) - m_irq_f(IRQ_TIMR2); + m_irq_f(IRQ_TIMR2); } if (m_old_raw_inval) @@ -1101,7 +1098,7 @@ inline void pokey_device::process_channel(int ch) } -void pokey_device::pokey_potgo(void) +void pokey_device::pokey_potgo() { if (!(m_SKCTL & SK_RESET)) return; @@ -1281,12 +1278,12 @@ char *pokey_device::audctl2str(int val) return buff; } -pokey_device::pokey_channel::pokey_channel() - : m_AUDF(0), - m_AUDC(0), - m_borrow_cnt(0), - m_counter(0), - m_output(0), - m_filter_sample(0) +pokey_device::pokey_channel::pokey_channel() : + m_AUDF(0), + m_AUDC(0), + m_borrow_cnt(0), + m_counter(0), + m_output(0), + m_filter_sample(0) { } diff --git a/src/devices/sound/pokey.h b/src/devices/sound/pokey.h index b0cdb867cc3..06c69a846e8 100644 --- a/src/devices/sound/pokey.h +++ b/src/devices/sound/pokey.h @@ -206,33 +206,33 @@ private: { public: pokey_channel(); - pokey_device *m_parent; + uint8_t m_INTMask; - uint8_t m_AUDF; /* AUDFx (D200, D202, D204, D206) */ - uint8_t m_AUDC; /* AUDCx (D201, D203, D205, D207) */ - int32_t m_borrow_cnt; /* borrow counter */ - int32_t m_counter; /* channel counter */ - uint8_t m_output; /* channel output signal (1 active, 0 inactive) */ - uint8_t m_filter_sample; /* high-pass filter sample */ + uint8_t m_AUDF; // AUDFx (D200, D202, D204, D206) + uint8_t m_AUDC; // AUDCx (D201, D203, D205, D207) + int32_t m_borrow_cnt; // borrow counter + int32_t m_counter; // channel counter + uint8_t m_output; // channel output signal (1 active, 0 inactive) + uint8_t m_filter_sample; // high-pass filter sample - inline void sample(void) { m_filter_sample = m_output; } - inline void reset_channel(void) { m_counter = m_AUDF ^ 0xff; m_borrow_cnt = 0; } + void sample() { m_filter_sample = m_output; } + void reset_channel() { m_counter = m_AUDF ^ 0xff; m_borrow_cnt = 0; } - inline void inc_chan(int cycles) + void inc_chan(pokey_device &host, int cycles) { m_counter = (m_counter + 1) & 0xff; if (m_counter == 0 && m_borrow_cnt == 0) { m_borrow_cnt = cycles; - if (m_parent->m_IRQEN & m_INTMask) + if (host.m_IRQEN & m_INTMask) { /* Exposed state has changed: This should only be updated after a resync ... */ - m_parent->machine().scheduler().synchronize(timer_expired_delegate(FUNC(pokey_device::sync_set_irqst), m_parent), m_INTMask); + host.machine().scheduler().synchronize(timer_expired_delegate(FUNC(pokey_device::sync_set_irqst), &host), m_INTMask); } } } - inline int check_borrow() + int check_borrow() { if (m_borrow_cnt > 0) { @@ -254,7 +254,7 @@ private: void vol_init(); inline void process_channel(int ch); - void pokey_potgo(void); + void pokey_potgo(); char *audc2str(int val); char *audctl2str(int val); diff --git a/src/mame/nintendo/gb.cpp b/src/mame/nintendo/gb.cpp index db59aef5d5f..85c06e5f8bc 100644 --- a/src/mame/nintendo/gb.cpp +++ b/src/mame/nintendo/gb.cpp @@ -892,7 +892,7 @@ uint8_t gbc_state::gbc_io2_r(offs_t offset) Map megaduck video related area on to regular Game Boy video area Different locations of the video registers: - Register Game Boy MegaDuck + Register Game Boy Mega Duck LCDC FF40 FF10 (See different bit order below) STAT FF41 FF11 SCY FF42 FF12 @@ -912,7 +912,7 @@ uint8_t gbc_state::gbc_io2_r(offs_t offset) Different LCDC register - Game Boy MegaDuck + Game Boy Mega Duck 0 6 - BG & Window Display : 0 - Off, 1 - On 1 0 - OBJ Display: 0 - Off, 1 - On 2 1 - OBJ Size: 0 - 8x8, 1 - 8x16 diff --git a/src/mame/sega/turbo.h b/src/mame/sega/turbo.h index 38f4fa36137..808411aa0a3 100644 --- a/src/mame/sega/turbo.h +++ b/src/mame/sega/turbo.h @@ -36,6 +36,7 @@ public: , m_videoram(*this, "videoram") , m_sprite_position(*this, "spritepos") , m_samples(*this, "samples") + , m_discrete(*this, "discrete") , m_gfxdecode(*this, "gfxdecode") , m_screen(*this, "screen") , m_digits(*this, "digit%u", 0U) @@ -57,6 +58,7 @@ protected: required_shared_ptr<uint8_t> m_sprite_position; required_device<samples_device> m_samples; + optional_device<discrete_device> m_discrete; required_device<gfxdecode_device> m_gfxdecode; required_device<screen_device> m_screen; diff --git a/src/mame/sega/turbo_a.cpp b/src/mame/sega/turbo_a.cpp index 54a3f31212d..db99ba87673 100644 --- a/src/mame/sega/turbo_a.cpp +++ b/src/mame/sega/turbo_a.cpp @@ -41,22 +41,21 @@ void turbo_state::update_samples() TIMER_CALLBACK_MEMBER(turbo_state::update_sound_a) { - discrete_device *discrete = machine.device<discrete_device>("discrete"); int data = param; // missing short crash sample, but I've never seen it triggered - discrete->write(0, !(data & 0x01)); - discrete->write(1, (data >> 1) & 1); - discrete->write(2, (data >> 2) & 1); - discrete->write(3, (data >> 3) & 1); - discrete->write(4, (data >> 4) & 1); - discrete->write(5, !(data & 0x20)); - discrete->write(6, !(data & 0x40)); - -if (!((data >> 1) & 1)) osd_printf_debug("/TRIG1\n"); -if (!((data >> 2) & 1)) osd_printf_debug("/TRIG2\n"); -if (!((data >> 3) & 1)) osd_printf_debug("/TRIG3\n"); -if (!((data >> 4) & 1)) osd_printf_debug("/TRIG4\n"); + m_discrete->write(0, BIT(~data, 0)); + m_discrete->write(1, BIT( data, 1)); + m_discrete->write(2, BIT( data, 2)); + m_discrete->write(3, BIT( data, 3)); + m_discrete->write(4, BIT( data, 4)); + m_discrete->write(5, BIT(~data, 5)); + m_discrete->write(6, BIT(~data, 6)); + + if (!BIT(data, 1)) osd_printf_debug("/TRIG1\n"); + if (!BIT(data, 2)) osd_printf_debug("/TRIG2\n"); + if (!BIT(data, 3)) osd_printf_debug("/TRIG3\n"); + if (!BIT(data, 4)) osd_printf_debug("/TRIG4\n"); // osel = (osel & 6) | ((data >> 5) & 1); // update_samples(samples); |
