Miscellaneous cleanup.

* audio/redbaron.cpp: Added save state support.
* gladiatr.cpp: Fixed typo.
* Changed some unused functions to use [[maybe_unused]] attribute so they don't rot.
This commit is contained in:
Vas Crabb 2021-01-10 02:37:22 +11:00
parent 74b4231609
commit 549c0e9cf7
9 changed files with 119 additions and 90 deletions

View File

@ -16,9 +16,10 @@
#include "machine/clock.h"
#include "bus/midi/midi.h"
namespace {
// ======================> coco_midi_device
namespace {
class coco_midi_device :
public device_t,
public device_cococart_interface
@ -108,6 +109,7 @@ void dragon_midi_device::device_start()
read8sm_delegate(m_acia, FUNC(acia6850_device::read)),
write8sm_delegate(m_acia, FUNC(acia6850_device::write)));
}
} // anonymous namespace
DEFINE_DEVICE_TYPE_PRIVATE(COCO_MIDI, device_cococart_interface, coco_midi_device, "coco_midi", "CoCo MIDI PAK")

View File

@ -38,25 +38,24 @@ DEFINE_DEVICE_TYPE(REDBARON, redbaron_sound_device, "redbaron_custom", "Red Baro
// redbaron_sound_device - constructor
//-------------------------------------------------
redbaron_sound_device::redbaron_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, REDBARON, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_vol_lookup(nullptr),
m_channel(nullptr),
m_latch(0),
m_poly_counter(0),
m_poly_shift(0),
m_filter_counter(0),
m_crash_amp(0),
m_shot_amp(0),
m_shot_amp_counter(0),
m_squeal_amp(0),
m_squeal_amp_counter(0),
m_squeal_off_counter(0),
m_squeal_on_counter(0),
m_squeal_out(0)
redbaron_sound_device::redbaron_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock) :
device_t(mconfig, REDBARON, tag, owner, clock),
device_sound_interface(mconfig, *this),
m_vol_lookup(nullptr),
m_channel(nullptr),
m_latch(0),
m_poly_counter(0),
m_poly_shift(0),
m_filter_counter(0),
m_crash_amp(0),
m_shot_amp(0),
m_shot_amp_counter(0),
m_squeal_amp(0),
m_squeal_amp_counter(0),
m_squeal_off_counter(0),
m_squeal_on_counter(0),
m_squeal_out(0)
{
std::fill(std::begin(m_vol_crash), std::end(m_vol_crash), 0);
}
@ -66,13 +65,11 @@ redbaron_sound_device::redbaron_sound_device(const machine_config &mconfig, cons
void redbaron_sound_device::device_start()
{
int i;
m_vol_lookup = std::make_unique<int16_t[]>(32768);
for( i = 0; i < 0x8000; i++ )
m_vol_lookup[0x7fff-i] = (int16_t) (0x7fff/exp(1.0*i/4096));
for( int i = 0; i < 0x8000; i++ )
m_vol_lookup[0x7fff-i] = int16_t(0x7fff/exp(1.0*i/4096));
for( i = 0; i < 16; i++ )
for( int i = 0; i < 16; i++ )
{
/* r0 = R18 and R24, r1 = open */
double r0 = 1.0/(5600 + 680), r1 = 1/6e12;
@ -103,6 +100,19 @@ void redbaron_sound_device::device_start()
}
m_channel = stream_alloc(0, 1, OUTPUT_RATE);
save_item(NAME(m_latch));
save_item(NAME(m_poly_counter));
save_item(NAME(m_poly_shift));
save_item(NAME(m_filter_counter));
save_item(NAME(m_crash_amp));
save_item(NAME(m_shot_amp));
save_item(NAME(m_shot_amp_counter));
save_item(NAME(m_squeal_amp));
save_item(NAME(m_squeal_amp_counter));
save_item(NAME(m_squeal_off_counter));
save_item(NAME(m_squeal_on_counter));
save_item(NAME(m_squeal_out));
}
@ -123,7 +133,7 @@ void redbaron_sound_device::sound_stream_update(sound_stream &stream, std::vecto
while( m_poly_counter <= 0 )
{
m_poly_counter += OUTPUT_RATE;
if( ((m_poly_shift & 0x0001) == 0) == ((m_poly_shift & 0x4000) == 0) )
if( BIT(m_poly_shift, 0) == BIT(m_poly_shift, 14) )
m_poly_shift = (m_poly_shift << 1) | 1;
else
m_poly_shift <<= 1;
@ -142,17 +152,16 @@ void redbaron_sound_device::sound_stream_update(sound_stream &stream, std::vecto
/* shot not active: charge C32 (0.1u) */
if( (m_latch & 0x04) == 0 )
m_shot_amp = 32767;
else
if( (m_poly_shift & 0x8000) == 0 )
else if( (m_poly_shift & 0x8000) == 0 )
{
if( m_shot_amp > 0 )
{
/* discharge C32 (0.1u) through R26 (33k) + R27 (15k)
* 0.68 * C32 * (R26 + R27) = 3264us
*/
// #define C32_DISCHARGE_TIME (int)(32767 / 0.003264);
// constexpr int C32_DISCHARGE_TIME = int(32767 / 0.003264);
/* I think this is to short. Is C32 really 1u? */
#define C32_DISCHARGE_TIME (int)(32767 / 0.03264);
constexpr int C32_DISCHARGE_TIME = int(32767 / 0.03264);
m_shot_amp_counter -= C32_DISCHARGE_TIME;
while( m_shot_amp_counter <= 0 )
{
@ -175,7 +184,7 @@ void redbaron_sound_device::sound_stream_update(sound_stream &stream, std::vecto
/* charge C5 (22u) over R3 (68k) and CR1 (1N914)
* time = 0.68 * C5 * R3 = 1017280us
*/
#define C5_CHARGE_TIME (int)(32767 / 1.01728);
constexpr int C5_CHARGE_TIME = int(32767 / 1.01728);
m_squeal_amp_counter -= C5_CHARGE_TIME;
while( m_squeal_amp_counter <= 0 )
{
@ -230,10 +239,8 @@ void redbaron_sound_device::sounds_w(uint8_t data)
}
#ifdef UNUSED_FUNCTION
void redbaron_sound_device::pokey_w(offs_t offset, uint8_t data)
{
if( m_latch & 0x20 )
m_pokey->write(offset, data);
//if( m_latch & 0x20 )
//m_pokey->write(offset, data);
}
#endif

View File

@ -7,8 +7,6 @@
// TYPE DEFINITIONS
//**************************************************************************
// ======================> redbaron_sound_device
class redbaron_sound_device : public device_t, public device_sound_interface
{
public:
@ -24,26 +22,28 @@ protected:
virtual void sound_stream_update(sound_stream &stream, std::vector<read_stream_view> const &inputs, std::vector<write_stream_view> &outputs) override;
private:
[[maybe_unused]] void pokey_w(offs_t offset, uint8_t data);
std::unique_ptr<int16_t[]> m_vol_lookup;
int16_t m_vol_crash[16];
sound_stream *m_channel;
int m_latch;
int m_poly_counter;
int m_poly_shift;
uint8_t m_latch;
int32_t m_poly_counter;
uint16_t m_poly_shift;
int m_filter_counter;
int32_t m_filter_counter;
int m_crash_amp;
int m_shot_amp;
int m_shot_amp_counter;
uint8_t m_crash_amp;
uint16_t m_shot_amp;
int32_t m_shot_amp_counter;
int m_squeal_amp;
int m_squeal_amp_counter;
int m_squeal_off_counter;
int m_squeal_on_counter;
int m_squeal_out;
uint16_t m_squeal_amp;
int32_t m_squeal_amp_counter;
int32_t m_squeal_off_counter;
int32_t m_squeal_on_counter;
uint8_t m_squeal_out;
};
DECLARE_DEVICE_TYPE(REDBARON, redbaron_sound_device)

View File

@ -87,6 +87,7 @@
#define LOGPIA(...) LOGMASKED(LOG_PIA, __VA_ARGS__)
#define LOGDBG(...) LOGMASKED(LOG_DEBUG, __VA_ARGS__)
namespace {
class bitgraph_state : public driver_device
{
@ -111,6 +112,13 @@ public:
static constexpr feature_type imperfect_features() { return feature::KEYBOARD; }
void bitgrpha(machine_config &config);
void bitgrphb(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
uint8_t pia_r(offs_t offset);
void pia_w(offs_t offset, uint8_t data);
uint8_t pia_pa_r();
@ -135,19 +143,17 @@ public:
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
uint8_t ppu_read(offs_t offset);
[[maybe_unused]] uint8_t ppu_read(offs_t offset);
void ppu_write(offs_t offset, uint8_t data);
void ppu_i8243_w(offs_t offset, uint8_t data);
template <unsigned Offset> void ppu_i8243_w(uint8_t data);
void bg_motherboard(machine_config &config);
void bitgrpha(machine_config &config);
void bitgrphb(machine_config &config);
[[maybe_unused]] void bg_ppu(machine_config &config);
void bitgrapha_mem(address_map &map);
void bitgraphb_mem(address_map &map);
void ppu_io(address_map &map);
private:
virtual void machine_start() override;
virtual void machine_reset() override;
required_device<cpu_device> m_maincpu;
required_device<ram_device> m_ram;
required_device<acia6850_device> m_acia0;
@ -419,12 +425,10 @@ void bitgraph_state::ppu_write(offs_t offset, uint8_t data)
m_ppu[offset] = data;
}
#ifdef UNUSED_FUNCTION
void bitgraph_state::ppu_io(address_map &map)
{
// map(0x00, 0x00).r(FUNC(bitgraph_state::ppu_irq));
}
#endif
/*
p4 O: Centronics data 3..0
@ -432,29 +436,29 @@ void bitgraph_state::ppu_io(address_map &map)
p6 O: Centronics control
p7 I: Centronics status
*/
void bitgraph_state::ppu_i8243_w(offs_t offset, uint8_t data)
template <unsigned Offset> void bitgraph_state::ppu_i8243_w(uint8_t data)
{
LOG("PPU 8243 %d <- %02X\n", offset + 4, data);
switch (offset)
LOG("PPU 8243 %d <- %02X\n", Offset, data);
switch (Offset)
{
case 0:
case 4:
m_centronics->write_data0(BIT(data, 0));
m_centronics->write_data1(BIT(data, 1));
m_centronics->write_data2(BIT(data, 2));
m_centronics->write_data3(BIT(data, 3));
break;
case 1:
case 5:
m_centronics->write_data4(BIT(data, 0));
m_centronics->write_data5(BIT(data, 1));
m_centronics->write_data6(BIT(data, 2));
m_centronics->write_data7(BIT(data, 3));
break;
case 2:
case 6:
m_centronics->write_strobe(BIT(data, 0));
// 1: Paper instruction
m_centronics->write_init(BIT(data, 2));
break;
case 3:
case 7:
m_centronics->write_ack(BIT(data, 0));
m_centronics->write_busy(BIT(data, 1));
m_centronics->write_perror(BIT(data, 2));
@ -547,7 +551,6 @@ void bitgraph_state::bg_motherboard(machine_config &config)
m_psg->add_route(ALL_OUTPUTS, "mono", 1.00);
}
#ifdef UNUSED_FUNCTION
void bitgraph_state::bg_ppu(machine_config &config)
{
i8035_device &ppu(I8035(config, PPU_TAG, XTAL(6'900'000)));
@ -556,8 +559,14 @@ void bitgraph_state::bg_ppu(machine_config &config)
ppu.prog_out_cb().set("i8243", FUNC(i8243_device::prog_w));
i8243_device &i8243(I8243(config, "i8243"));
i8243.read_handler().set_nop();
i8243.write_handler().set(FUNC(bitgraph_state::ppu_i8243_w));
i8243.p4_in_cb().set_constant(0);
i8243.p5_in_cb().set_constant(0);
i8243.p6_in_cb().set_constant(0);
i8243.p7_in_cb().set_constant(0);
i8243.p4_out_cb().set(FUNC(bitgraph_state::ppu_i8243_w<4>));
i8243.p5_out_cb().set(FUNC(bitgraph_state::ppu_i8243_w<5>));
i8243.p6_out_cb().set(FUNC(bitgraph_state::ppu_i8243_w<6>));
i8243.p7_out_cb().set(FUNC(bitgraph_state::ppu_i8243_w<7>));
CENTRONICS(config, m_centronics, centronics_devices, "printer");
m_centronics->ack_handler().set("cent_status_in", FUNC(input_buffer_device::write_bit6));
@ -570,7 +579,6 @@ void bitgraph_state::bg_ppu(machine_config &config)
output_latch_device &cent_data_out(OUTPUT_LATCH(config, "cent_data_out"));
m_centronics->set_output_latch(cent_data_out);
}
#endif
void bitgraph_state::bitgrpha(machine_config &config)
{
@ -638,6 +646,8 @@ ROM_START( bitgrphb )
ROM_LOAD( "bg_mouse_u9.bin", 0x0000, 0x0800, CRC(fd827ff5) SHA1(6d4a8e9b18c7610c5cfde40464826d144d387601))
ROM_END
} // anonymous namespace
/* Driver */
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1981, bitgrpha, 0, 0, bitgrpha, bitgraph, bitgraph_state, empty_init, "BBN", "BitGraph rev A", ROT90 )

View File

@ -117,6 +117,7 @@ Sound processor - 6502
#include "emupal.h"
#include "speaker.h"
namespace {
class deco_ld_state : public driver_device
{
@ -143,6 +144,9 @@ public:
DECLARE_READ_LINE_MEMBER(begas_vblank_r);
DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
protected:
virtual void machine_start() override;
private:
required_device<cpu_device> m_maincpu;
optional_device<cpu_device> m_audiocpu;
@ -159,11 +163,12 @@ private:
required_shared_ptr<uint8_t> m_attr1;
int m_nmimask;
uint8_t acia_status_hack_r();
uint8_t sound_status_r();
void decold_sound_cmd_w(uint8_t data);
virtual void machine_start() override;
uint32_t screen_update_rblaster(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
[[maybe_unused]] void nmimask_w(uint8_t data);
INTERRUPT_GEN_MEMBER(sound_interrupt);
void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, uint8_t *spriteram, uint16_t tile_bank );
void rblaster_map(address_map &map);
@ -294,12 +299,10 @@ void deco_ld_state::rblaster_map(address_map &map)
/* sound arrangement is practically identical to Zero Target. */
#ifdef UNUSED_FUNCTION
void deco_ld_state::nmimask_w(uint8_t data)
{
m_nmimask = data & 0x80;
}
#endif
INTERRUPT_GEN_MEMBER(deco_ld_state::sound_interrupt)
{
@ -654,6 +657,7 @@ ROM_START( cobraa )
ROM_LOAD( "vd0-t.f6", 0x0000, 0x00020, CRC(78449942) SHA1(584e25f7bffccd943c4db1edf05552f7989e08a4) )
ROM_END
} // anonymous namespace
GAME( 1983, begas, 0, rblaster, begas, deco_ld_state, empty_init, ROT0, "Data East", "Bega's Battle (Revision 3)", MACHINE_NOT_WORKING )

View File

@ -863,7 +863,7 @@ static INPUT_PORTS_START( gladiatr )
PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_CHANGED_MEMBER(DEVICE_SELF, gladiatr_state, p1_s1, 0)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, gladiatr_state, p2_s2, 0)
PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_CHANGED_MEMBER(DEVICE_SELF, gladiatr_state, p1_s2, 0)
PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )

View File

@ -96,6 +96,7 @@ private:
void memory_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
uint32_t biu_ctrl_r(offs_t offset);
void biu_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
[[maybe_unused]] void bios_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask);
uint32_t parallel_port_r();
void parallel_port_w(uint32_t data);
uint8_t io20_r(offs_t offset);
@ -398,11 +399,9 @@ void pinball2k_state::biu_ctrl_w(offs_t offset, uint32_t data, uint32_t mem_mask
}
}
#ifdef UNUSED_FUNCTION
void pinball2k_state::bios_ram_w(offs_t offset, uint32_t data, uint32_t mem_mask)
{
}
#endif
uint8_t pinball2k_state::io20_r(offs_t offset)
{

View File

@ -183,6 +183,8 @@ A=AMA, P=PRO, these keys don't exist, and so the games cannot be played.
#include "speaker.h"
namespace {
class tutor_state : public driver_device
{
public:
@ -202,6 +204,10 @@ public:
void pyuutajr(machine_config &config);
void tutor(machine_config &config);
protected:
virtual void machine_start() override;
virtual void machine_reset() override;
private:
required_device<tms9995_device> m_maincpu;
required_device<generic_slot_device> m_cart;
@ -212,7 +218,12 @@ private:
required_memory_bank m_bank2;
memory_region *m_cart_rom;
int m_tape_interrupt_enable;
emu_timer *m_tape_interrupt_timer;
int m_bank1_switching;
int m_centronics_busy;
uint8_t key_r(offs_t offset);
uint8_t tutor_mapper_r(offs_t offset);
void tutor_mapper_w(offs_t offset, uint8_t data);
@ -222,14 +233,11 @@ private:
void tutor_printer_w(offs_t offset, uint8_t data);
uint8_t tutor_highmem_r(offs_t offset);
int m_tape_interrupt_enable;
emu_timer *m_tape_interrupt_timer;
virtual void machine_start() override;
virtual void machine_reset() override;
TIMER_CALLBACK_MEMBER(tape_interrupt_handler);
int m_centronics_busy;
DECLARE_WRITE_LINE_MEMBER(write_centronics_busy);
[[maybe_unused]] void test_w(offs_t offset, uint8_t data);
void pyuutajr_mem(address_map &map);
void tutor_io(address_map &map);
void tutor_memmap(address_map &map);
@ -540,7 +548,6 @@ void tutor_state::tutor_printer_w(offs_t offset, uint8_t data)
@>f000-@>f0fb: tms9995 internal RAM 2
*/
#ifdef UNUSED_FUNCTION
void tutor_state::test_w(offs_t offset, uint8_t data)
{
switch (offset)
@ -550,7 +557,6 @@ void tutor_state::test_w(offs_t offset, uint8_t data)
break;
}
}
#endif
void tutor_state::tutor_memmap(address_map &map)
{
@ -808,6 +814,8 @@ ROM_START(pyuutajr)
ROM_LOAD( "ipl.rom", 0x0000, 0x4000, CRC(2ca37e62) SHA1(eebdc5c37d3b532edd5e5ca65eb785269ebd1ac0)) /* system ROM */
ROM_END
} // anonymous namespace
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
COMP( 1983?, tutor, 0, 0, tutor, tutor, tutor_state, empty_init, "Tomy", "Tomy Tutor" , 0)
COMP( 1982, pyuuta, tutor, 0, tutor, tutor, tutor_state, empty_init, "Tomy", "Tomy Pyuuta" , 0)

View File

@ -23,19 +23,18 @@ uint8_t nbmj8900_state::palette_type1_r(offs_t offset)
void nbmj8900_state::palette_type1_w(offs_t offset, uint8_t data)
{
int r, g, b;
m_palette_ptr[offset] = data;
if (!(offset & 1)) return;
if (offset & 1)
{
offset &= 0x1fe;
offset &= 0x1fe;
int const r = (m_palette_ptr[offset + 0] >> 0) & 0x0f;
int const g = (m_palette_ptr[offset + 1] >> 4) & 0x0f;
int const b = (m_palette_ptr[offset + 1] >> 0) & 0x0f;
r = ((m_palette_ptr[offset + 0] & 0x0f) >> 0);
g = ((m_palette_ptr[offset + 1] & 0xf0) >> 4);
b = ((m_palette_ptr[offset + 1] & 0x0f) >> 0);
m_palette->set_pen_color((offset >> 1), pal4bit(r), pal4bit(g), pal4bit(b));
m_palette->set_pen_color((offset >> 1), pal4bit(r), pal4bit(g), pal4bit(b));
}
}
#ifdef UNUSED_FUNCTION