Skip to content

Commit 89e3885

Browse files
committed
dm9368: update output when rbi is written,
seabattl,elf: remove unneeded 7seg output trampoline, didact: #define pia6820_device pia6821_device, please don't do that
1 parent 53d47b4 commit 89e3885

File tree

7 files changed

+81
-68
lines changed

7 files changed

+81
-68
lines changed

src/devices/video/dm9368.cpp

+35-12
Original file line numberDiff line numberDiff line change
@@ -40,32 +40,55 @@ dm9368_device::dm9368_device(const machine_config &mconfig, const char *tag, dev
4040
device_t(mconfig, DM9368, tag, owner, clock),
4141
m_update_cb(*this),
4242
m_rbo_cb(*this),
43+
m_a(0),
4344
m_rbi(1),
4445
m_rbo(1)
4546
{
4647
}
4748

49+
void dm9368_device::device_start()
50+
{
51+
// state saving
52+
save_item(NAME(m_a));
53+
save_item(NAME(m_rbi));
54+
save_item(NAME(m_rbo));
55+
}
56+
57+
58+
// interface
4859

4960
void dm9368_device::a_w(u8 data)
5061
{
51-
int const a(data & 0x0f);
52-
int const rbo((m_rbi || a) ? 1 : 0);
53-
u8 const value(rbo ? s_segment_data[a] : 0);
62+
data &= 0xf;
63+
if (data != m_a)
64+
{
65+
m_a = data;
66+
update();
67+
}
68+
}
69+
70+
void dm9368_device::rbi_w(int state)
71+
{
72+
state = state ? 1 : 0;
73+
if (state != m_rbi)
74+
{
75+
m_rbi = state;
76+
update();
77+
}
78+
}
79+
80+
void dm9368_device::update()
81+
{
82+
// RBI blanks the display only if A0-A3 is 0
83+
int const rbo((m_rbi || m_a) ? 1 : 0);
84+
u8 const value(rbo ? s_segment_data[m_a] : 0);
5485

5586
if (!rbo)
5687
LOG("DM9368 Blanked Rippling Zero\n");
5788
else
58-
LOG("DM9368 Output Data: %u = %02x\n", a, value);
89+
LOG("DM9368 Output Data: %u = %02x\n", m_a, value);
5990

6091
m_update_cb(0, value, 0x7f);
6192
if (rbo != m_rbo)
6293
m_rbo_cb(m_rbo = rbo);
6394
}
64-
65-
66-
void dm9368_device::device_start()
67-
{
68-
// state saving
69-
save_item(NAME(m_rbi));
70-
save_item(NAME(m_rbo));
71-
}

src/devices/video/dm9368.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -36,27 +36,29 @@ class dm9368_device : public device_t
3636
auto rbo_cb() { return m_rbo_cb.bind(); }
3737

3838
// construction/destruction
39-
dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock);
39+
dm9368_device(const machine_config &mconfig, const char *tag, device_t *owner, u32 clock = 0);
4040

4141
void a_w(u8 data);
4242

43-
void rbi_w(int state) { m_rbi = state; }
43+
void rbi_w(int state);
4444
int rbo_r() { return m_rbo; }
4545

4646
protected:
4747
// device_t implementation
4848
virtual void device_start() override ATTR_COLD;
49-
50-
void update();
49+
virtual void device_reset() override ATTR_COLD { update(); }
5150

5251
private:
5352
devcb_write8 m_update_cb;
5453
devcb_write_line m_rbo_cb;
5554

55+
u8 m_a;
5656
int m_rbi;
5757
int m_rbo;
5858

5959
static const u8 s_segment_data[16];
60+
61+
void update();
6062
};
6163

6264

src/mame/netronics/elf.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void elf2_state::elf2_io(address_map &map)
9292

9393
/* Input Ports */
9494

95-
INPUT_CHANGED_MEMBER( elf2_state::input_w )
95+
INPUT_CHANGED_MEMBER(elf2_state::input_w)
9696
{
9797
if (newval)
9898
{
@@ -206,11 +206,6 @@ void elf2_state::machine_start()
206206

207207
m_led.resolve();
208208

209-
/* initialize LED displays */
210-
m_7segs.resolve();
211-
m_led_l->rbi_w(1);
212-
m_led_h->rbi_w(1);
213-
214209
/* setup memory banking */
215210
program.install_rom(0x0000, 0x00ff, m_ram->pointer());
216211
program.install_write_handler(0x0000, 0x00ff, write8sm_delegate(*this, FUNC(elf2_state::memory_w)));
@@ -268,8 +263,8 @@ void elf2_state::elf2(machine_config &config)
268263
m_kb->x3_rd_callback().set_ioport("X3");
269264
m_kb->x4_rd_callback().set_ioport("X4");
270265

271-
DM9368(config, m_led_h, 0).update_cb().set(FUNC(elf2_state::digit_w<0>));
272-
DM9368(config, m_led_l, 0).update_cb().set(FUNC(elf2_state::digit_w<1>));
266+
DM9368(config, m_led_h).update_cb().set_output("digit0");
267+
DM9368(config, m_led_l).update_cb().set_output("digit1");
273268

274269
SPEAKER(config, "mono").front_center();
275270

@@ -292,4 +287,4 @@ ROM_END
292287
/* System Drivers */
293288

294289
// YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS
295-
COMP( 1978, elf2, 0, 0, elf2, elf2, elf2_state, empty_init, "Netronics", "Elf II", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND)
290+
COMP( 1978, elf2, 0, 0, elf2, elf2, elf2_state, empty_init, "Netronics", "Elf II", MACHINE_SUPPORTS_SAVE | MACHINE_NO_SOUND_HW )

src/mame/netronics/elf.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ class elf2_state : public driver_device
3535
, m_cassette(*this, "cassette")
3636
, m_ram(*this, RAM_TAG)
3737
, m_special(*this, "SPECIAL")
38-
, m_7segs(*this, "digit%u", 0U)
3938
, m_led(*this, "led0")
4039
{ }
4140

4241
void elf2(machine_config &config);
4342

44-
DECLARE_INPUT_CHANGED_MEMBER( input_w );
43+
DECLARE_INPUT_CHANGED_MEMBER(input_w);
44+
45+
protected:
46+
virtual void machine_start() override ATTR_COLD;
4547

4648
private:
4749
uint8_t dispon_r();
@@ -55,14 +57,11 @@ class elf2_state : public driver_device
5557
uint8_t dma_r();
5658
void sc_w(uint8_t data);
5759
void da_w(int state);
58-
template <unsigned N> void digit_w(uint8_t data) { m_7segs[N] = data; }
5960

60-
DECLARE_QUICKLOAD_LOAD_MEMBER( quickload_cb );
61+
DECLARE_QUICKLOAD_LOAD_MEMBER(quickload_cb);
6162
void elf2_io(address_map &map) ATTR_COLD;
6263
void elf2_mem(address_map &map) ATTR_COLD;
6364

64-
virtual void machine_start() override ATTR_COLD;
65-
6665
required_device<cosmac_device> m_maincpu;
6766
required_device<cdp1861_device> m_vdc;
6867
required_device<mm74c922_device> m_kb;
@@ -71,7 +70,6 @@ class elf2_state : public driver_device
7170
required_device<cassette_image_device> m_cassette;
7271
required_device<ram_device> m_ram;
7372
required_ioport m_special;
74-
output_finder<2> m_7segs;
7573
output_finder<> m_led;
7674

7775
// display state

src/mame/skeleton/cosmicos.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -605,9 +605,6 @@ void cosmicos_state::machine_start()
605605
m_digits.resolve();
606606
m_leds.resolve();
607607

608-
/* initialize LED display */
609-
m_led->rbi_w(1);
610-
611608
/* register for state saving */
612609
save_item(NAME(m_wait));
613610
save_item(NAME(m_clear));
@@ -672,7 +669,7 @@ void cosmicos_state::cosmicos(machine_config &config)
672669

673670
/* video hardware */
674671
config.set_default_layout(layout_cosmicos);
675-
DM9368(config, m_led, 0);
672+
DM9368(config, m_led);
676673
TIMER(config, "digit").configure_periodic(FUNC(cosmicos_state::digit_tick), attotime::from_hz(100));
677674
TIMER(config, "interrupt").configure_periodic(FUNC(cosmicos_state::int_tick), attotime::from_hz(1000));
678675

src/mame/skeleton/didact.cpp

+23-21
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ namespace {
9595
/* Didact base class */
9696
class didact_state : public driver_device
9797
{
98-
public:
98+
public:
9999
didact_state(const machine_config &mconfig, device_type type, const char * tag)
100100
: driver_device(mconfig, type, tag)
101101
, m_cass(*this, "cassette")
@@ -107,6 +107,7 @@ class didact_state : public driver_device
107107

108108
DECLARE_INPUT_CHANGED_MEMBER(trigger_reset);
109109
DECLARE_INPUT_CHANGED_MEMBER(trigger_shift);
110+
110111
protected:
111112
virtual void machine_start() override { m_led.resolve(); }
112113

@@ -327,14 +328,12 @@ void md6802_state::md6802_map(address_map &map)
327328
*/
328329
/* Didact mp68a driver class */
329330

330-
// Just a statement that the real mp68a hardware was designed with 6820 and not 6821
331+
// The real mp68a hardware was designed with 6820 and not 6821.
331332
// They are functional equivalents BUT has different electrical characteristics.
332333
// 2019-07-27 Cassette added: saves ok, load is unreliable, probably an original design problem.
333-
#define pia6820_device pia6821_device
334-
#define PIA6820 PIA6821
335334
class mp68a_state : public didact_state
336335
{
337-
public:
336+
public:
338337
mp68a_state(const machine_config &mconfig, device_type type, const char * tag)
339338
: didact_state(mconfig, type, tag)
340339
, m_maincpu(*this, "maincpu")
@@ -361,9 +360,10 @@ class mp68a_state : public didact_state
361360
virtual void machine_start() override ATTR_COLD;
362361
void mp68a(machine_config &config);
363362
void mp68a_map(address_map &map) ATTR_COLD;
363+
364364
protected:
365-
required_device<pia6820_device> m_pia1;
366-
required_device<pia6820_device> m_pia2;
365+
required_device<pia6821_device> m_pia1;
366+
required_device<pia6821_device> m_pia2;
367367
};
368368

369369
INPUT_CHANGED_MEMBER(didact_state::trigger_shift)
@@ -425,13 +425,13 @@ uint8_t mp68a_state::pia2_kbB_r()
425425
while (a012 > 0 && !(line & (1 << --a012)));
426426
a012 += 8;
427427
}
428-
if ( a012 == 0 && (line = ((m_lines[2]) | m_lines[3])) != 0)
428+
if (a012 == 0 && (line = ((m_lines[2]) | m_lines[3])) != 0)
429429
{
430430
a012 = 8;
431431
while (a012 > 0 && !(line & (1 << --a012)));
432432
}
433433

434-
pb = a012; // A0-A2 -> PB0-PB3
434+
pb = a012; // A0-A2 -> PB0-PB3
435435

436436
if (m_shift)
437437
{
@@ -486,8 +486,8 @@ void mp68a_state::machine_start()
486486
void mp68a_state::mp68a_map(address_map &map)
487487
{
488488
map(0x0000, 0x00ff).ram().mirror(0xf000);
489-
map(0x0500, 0x0503).rw(m_pia1, FUNC(pia6820_device::read), FUNC(pia6820_device::write)).mirror(0xf0fc);
490-
map(0x0600, 0x0603).rw(m_pia2, FUNC(pia6820_device::read), FUNC(pia6820_device::write)).mirror(0xf0fc);
489+
map(0x0500, 0x0503).rw(m_pia1, FUNC(pia6821_device::read), FUNC(pia6821_device::write)).mirror(0xf0fc);
490+
map(0x0600, 0x0603).rw(m_pia2, FUNC(pia6821_device::read), FUNC(pia6821_device::write)).mirror(0xf0fc);
491491
map(0x0700, 0x07ff).ram().mirror(0xf000);
492492
map(0x0800, 0x0bff).rom().mirror(0xf400).region("maincpu", 0x0800);
493493
}
@@ -536,7 +536,7 @@ void mp68a_state::mp68a_map(address_map &map)
536536
/* Didact modulab driver class */
537537
class modulab_state : public didact_state
538538
{
539-
public:
539+
public:
540540
modulab_state(const machine_config &mconfig, device_type type, const char * tag)
541541
: didact_state(mconfig, type, tag)
542542
, m_maincpu(*this, "maincpu")
@@ -553,10 +553,12 @@ class modulab_state : public didact_state
553553
virtual void machine_reset() override ATTR_COLD;
554554
virtual void machine_start() override ATTR_COLD;
555555
void modulab(machine_config &config);
556+
556557
protected:
557558
uint8_t io_r(offs_t offset);
558559
void io_w(offs_t offset, u8 data);
559560
void da_w(int state);
561+
560562
private:
561563
void modulab_map(address_map &map) ATTR_COLD;
562564
// Offsets for display and keyboard i/o
@@ -571,7 +573,7 @@ class modulab_state : public didact_state
571573
class shift8
572574
{
573575
public:
574-
shift8(){ byte = 0; }
576+
shift8() { byte = 0; }
575577
void shiftIn(uint8_t in){ byte = ((byte << 1) & 0xfe) | (in & 1 ? 1 : 0); }
576578
uint8_t byte;
577579
};
@@ -850,10 +852,10 @@ void mp68a_state::mp68a(machine_config &config)
850852

851853
/* Devices */
852854
/* PIA #1 0x500-0x503 - used differently by laborations and loaded software */
853-
PIA6820(config, m_pia1, 0);
855+
PIA6821(config, m_pia1, 0); // actually 6820
854856

855857
/* PIA #2 Keyboard & Display 0x600-0x603 */
856-
PIA6820(config, m_pia2, 0);
858+
PIA6821(config, m_pia2, 0); // actually 6820
857859
/* --PIA inits----------------------- */
858860
/* 0x0BAF 0x601 (Control A) = 0x30 - CA2 is low and enable DDRA */
859861
/* 0x0BB1 0x603 (Control B) = 0x30 - CB2 is low and enable DDRB */
@@ -886,12 +888,12 @@ void mp68a_state::mp68a(machine_config &config)
886888
/* 0x086B 0x600 (Port A) = 0x70 */
887889
/* 0x086B 0x600 (Port A) = 0x50 */
888890
/* 0x086B 0x600 (Port A) = 0x70 */
889-
DM9368(config, m_digits[0], 0).update_cb().set(FUNC(mp68a_state::digit_w<0>));
890-
DM9368(config, m_digits[1], 0).update_cb().set(FUNC(mp68a_state::digit_w<1>));
891-
DM9368(config, m_digits[2], 0).update_cb().set(FUNC(mp68a_state::digit_w<2>));
892-
DM9368(config, m_digits[3], 0).update_cb().set(FUNC(mp68a_state::digit_w<3>));
893-
DM9368(config, m_digits[4], 0).update_cb().set(FUNC(mp68a_state::digit_w<4>));
894-
DM9368(config, m_digits[5], 0).update_cb().set(FUNC(mp68a_state::digit_w<5>));
891+
DM9368(config, m_digits[0]).update_cb().set(FUNC(mp68a_state::digit_w<0>));
892+
DM9368(config, m_digits[1]).update_cb().set(FUNC(mp68a_state::digit_w<1>));
893+
DM9368(config, m_digits[2]).update_cb().set(FUNC(mp68a_state::digit_w<2>));
894+
DM9368(config, m_digits[3]).update_cb().set(FUNC(mp68a_state::digit_w<3>));
895+
DM9368(config, m_digits[4]).update_cb().set(FUNC(mp68a_state::digit_w<4>));
896+
DM9368(config, m_digits[5]).update_cb().set(FUNC(mp68a_state::digit_w<5>));
895897

896898
/* Cassette */
897899
SPEAKER(config, "mono").front_center();

src/mame/zaccaria/seabattl.cpp

+7-11
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,8 @@ class seabattl_state : public driver_device
5454
m_videoram(*this, "videoram"),
5555
m_colorram(*this, "colorram"),
5656
m_objram(*this, "objram"),
57-
m_digits(*this, { "sc_thousand", "sc_hundred", "sc_half", "sc_unity", "tm_half", "tm_unity" }),
57+
m_digits(*this, "digit%u", 0U),
5858
m_s2636(*this, "s2636"),
59-
m_7segs(*this, "digit%u", 0U),
6059
m_lamp(*this, "lamp0"),
6160
m_waveenable(false),
6261
m_collision(0),
@@ -86,7 +85,6 @@ class seabattl_state : public driver_device
8685
void time_display_w(uint8_t data);
8786
void score_display_w(uint8_t data);
8887
void score2_display_w(uint8_t data);
89-
template <unsigned N> void digit_w(uint8_t data) { m_7segs[N] = data; }
9088

9189
void seabattl_palette(palette_device &palette) const;
9290
uint32_t screen_update_seabattl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
@@ -100,7 +98,6 @@ class seabattl_state : public driver_device
10098
required_shared_ptr<uint8_t> m_objram;
10199
required_device_array<dm9368_device, 6> m_digits;
102100
required_device<s2636_device> m_s2636;
103-
output_finder<6> m_7segs;
104101
output_finder<> m_lamp;
105102

106103
tilemap_t *m_bg_tilemap = nullptr;
@@ -240,7 +237,6 @@ uint32_t seabattl_state::screen_update_seabattl(screen_device &screen, bitmap_in
240237

241238
void seabattl_state::video_start()
242239
{
243-
m_7segs.resolve();
244240
m_screen->register_screen_bitmap(m_collision_bg);
245241
m_bg_tilemap = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(*this, FUNC(seabattl_state::get_bg_tile_info)), TILEMAP_SCAN_ROWS, 8, 8, 32, 32);
246242
m_bg_tilemap->set_transparent_pen(0);
@@ -496,12 +492,12 @@ void seabattl_state::seabattl(machine_config &config)
496492
m_s2636->set_offsets(-13, -29);
497493
m_s2636->add_route(ALL_OUTPUTS, "mono", 0.10);
498494

499-
DM9368(config, m_digits[0], 0).update_cb().set(FUNC(seabattl_state::digit_w<0>));
500-
DM9368(config, m_digits[1], 0).update_cb().set(FUNC(seabattl_state::digit_w<1>));
501-
DM9368(config, m_digits[2], 0).update_cb().set(FUNC(seabattl_state::digit_w<2>));
502-
DM9368(config, m_digits[3], 0).update_cb().set(FUNC(seabattl_state::digit_w<3>));
503-
DM9368(config, m_digits[4], 0).update_cb().set(FUNC(seabattl_state::digit_w<4>));
504-
DM9368(config, m_digits[5], 0).update_cb().set(FUNC(seabattl_state::digit_w<5>));
495+
DM9368(config, m_digits[0]).update_cb().set_output("digit0");
496+
DM9368(config, m_digits[1]).update_cb().set_output("digit1");
497+
DM9368(config, m_digits[2]).update_cb().set_output("digit2");
498+
DM9368(config, m_digits[3]).update_cb().set_output("digit3");
499+
DM9368(config, m_digits[4]).update_cb().set_output("digit4");
500+
DM9368(config, m_digits[5]).update_cb().set_output("digit5");
505501

506502
/* video hardware */
507503
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);

0 commit comments

Comments
 (0)