From 195999b14d34bcfb33ff62f0ec0b19b3a700687d Mon Sep 17 00:00:00 2001 From: Nathan Woods Date: Mon, 12 Jun 2017 06:41:09 -0400 Subject: [CoCo] Miscellaneous cleanups/hygiene (nw) 1. Changed '#ifndef __COCO__' ==> '#ifndef MAME_INCLUDES_COCO_H' 2. Moved device declarations to be private, added accessors when necessary --- src/mame/includes/coco.h | 50 +++++++++++++++++++++++++------------------ src/mame/machine/coco.cpp | 4 ++-- src/mame/machine/coco12.cpp | 19 +++++++--------- src/mame/machine/dgnalpha.cpp | 4 ++-- src/mame/machine/dragon.cpp | 4 ++-- 5 files changed, 43 insertions(+), 38 deletions(-) diff --git a/src/mame/includes/coco.h b/src/mame/includes/coco.h index db380183b8b..71e40489ba0 100644 --- a/src/mame/includes/coco.h +++ b/src/mame/includes/coco.h @@ -10,8 +10,8 @@ #pragma once -#ifndef __COCO__ -#define __COCO__ +#ifndef MAME_INCLUDES_COCO_H +#define MAME_INCLUDES_COCO_H #include "imagedev/cassette.h" @@ -90,22 +90,6 @@ class coco_state : public driver_device, public device_cococart_host_interface public: coco_state(const machine_config &mconfig, device_type type, const char *tag); - required_device m_maincpu; - required_device m_pia_0; - required_device m_pia_1; - required_device m_dac; - required_device m_sbs; - required_device m_wave; - required_device m_cococart; - required_device m_ram; - required_device m_cassette; - required_device m_floating; - optional_device m_rs232; - optional_device m_vhd_0; - optional_device m_vhd_1; - optional_device m_beckerport; - optional_ioport m_beckerportconfig; - // driver update handlers DECLARE_INPUT_CHANGED_MEMBER(keyboard_changed); DECLARE_INPUT_CHANGED_MEMBER(joystick_mode_changed); @@ -167,6 +151,13 @@ protected: virtual void pia1_pa_changed(uint8_t data); virtual void pia1_pb_changed(uint8_t data); + // accessors + cpu_device &maincpu() { return *m_maincpu; } + pia6821_device &pia_0() { return *m_pia_0; } + pia6821_device &pia_1() { return *m_pia_1; } + cococart_slot_device &cococart() { return *m_cococart; } + ram_device &ram() { return *m_ram; } + // miscellaneous virtual void update_keyboard_input(uint8_t value, uint8_t z); virtual void cart_w(bool state); @@ -234,10 +225,27 @@ private: bool snden(void) { return m_pia_1->cb2_output() ? true : false; } // VHD selection - coco_vhd_image_device *current_vhd(void); + coco_vhd_image_device *current_vhd(); // floating bus - uint8_t floating_bus_read(void); + uint8_t floating_bus_read(); + + // devices + required_device m_maincpu; + required_device m_pia_0; + required_device m_pia_1; + required_device m_dac; + required_device m_sbs; + required_device m_wave; + required_device m_cococart; + required_device m_ram; + required_device m_cassette; + required_device m_floating; + optional_device m_rs232; + optional_device m_vhd_0; + optional_device m_vhd_1; + optional_device m_beckerport; + optional_ioport m_beckerportconfig; // input ports required_ioport_array<7> m_keyboard; @@ -276,4 +284,4 @@ private: bool m_in_floating_bus_read; }; -#endif // __COCO__ +#endif // MAME_INCLUDES_COCO_H diff --git a/src/mame/machine/coco.cpp b/src/mame/machine/coco.cpp index 0ec8f2e5ab9..a43e8a8cacf 100644 --- a/src/mame/machine/coco.cpp +++ b/src/mame/machine/coco.cpp @@ -251,7 +251,7 @@ void coco_state::device_timer(emu_timer &timer, device_timer_id id, int param, v // CoCo 1/2 you should get $F627 instead. //------------------------------------------------- -uint8_t coco_state::floating_bus_read(void) +uint8_t coco_state::floating_bus_read() { uint8_t result; @@ -1133,7 +1133,7 @@ void coco_state::poll_hires_joystick(void) // current_vhd //------------------------------------------------- -coco_vhd_image_device *coco_state::current_vhd(void) +coco_vhd_image_device *coco_state::current_vhd() { switch(m_vhd_select) { diff --git a/src/mame/machine/coco12.cpp b/src/mame/machine/coco12.cpp index ffe2b0002de..3a1f9c6b3ac 100644 --- a/src/mame/machine/coco12.cpp +++ b/src/mame/machine/coco12.cpp @@ -29,16 +29,13 @@ void coco12_state::device_start() void coco12_state::configure_sam() { - cococart_slot_device *cart = m_cococart; - uint8_t *ram = m_ram->pointer(); - uint32_t ram_size = m_ram->size(); uint8_t *rom = memregion(MAINCPU_TAG)->base(); - uint8_t *cart_rom = cart->get_cart_base(); + uint8_t *cart_rom = cococart().get_cart_base(); - m_sam->configure_bank(0, ram, ram_size, false); // $0000-$7FFF - m_sam->configure_bank(1, &rom[0x0000], 0x2000, true); // $8000-$9FFF - m_sam->configure_bank(2, &rom[0x2000], 0x2000, true); // $A000-$BFFF - m_sam->configure_bank(3, cart_rom, 0x4000, true); // $C000-$FEFF + m_sam->configure_bank(0, ram().pointer(), ram().size(), false); // $0000-$7FFF + m_sam->configure_bank(1, &rom[0x0000], 0x2000, true); // $8000-$9FFF + m_sam->configure_bank(2, &rom[0x2000], 0x2000, true); // $A000-$BFFF + m_sam->configure_bank(3, cart_rom, 0x4000, true); // $C000-$FEFF // $FF00-$FF1F m_sam->configure_bank(4, read8_delegate(FUNC(coco12_state::ff00_read), this), write8_delegate(FUNC(coco12_state::ff00_write), this)); @@ -60,7 +57,7 @@ void coco12_state::configure_sam() WRITE_LINE_MEMBER( coco12_state::horizontal_sync ) { - m_pia_0->ca1_w(state); + pia_0().ca1_w(state); m_sam->hs_w(state); } @@ -72,7 +69,7 @@ WRITE_LINE_MEMBER( coco12_state::horizontal_sync ) WRITE_LINE_MEMBER( coco12_state::field_sync ) { - m_pia_0->cb1_w(state); + pia_0().cb1_w(state); } @@ -83,7 +80,7 @@ WRITE_LINE_MEMBER( coco12_state::field_sync ) READ8_MEMBER( coco12_state::sam_read ) { - uint8_t data = m_ram->read(offset); + uint8_t data = ram().read(offset); m_vdg->as_w(data & 0x80 ? ASSERT_LINE : CLEAR_LINE); m_vdg->inv_w(data & 0x40 ? ASSERT_LINE : CLEAR_LINE); return data; diff --git a/src/mame/machine/dgnalpha.cpp b/src/mame/machine/dgnalpha.cpp index 41ff87aeec7..a8f33681d15 100644 --- a/src/mame/machine/dgnalpha.cpp +++ b/src/mame/machine/dgnalpha.cpp @@ -355,12 +355,12 @@ WRITE_LINE_MEMBER( dragon_alpha_state::fdc_intrq_w ) else { if (m_pia_2->ca2_output_z()) - m_maincpu->set_input_line(INPUT_LINE_NMI, ASSERT_LINE); + maincpu().set_input_line(INPUT_LINE_NMI, ASSERT_LINE); } } else { - m_maincpu->set_input_line(INPUT_LINE_NMI, CLEAR_LINE); + maincpu().set_input_line(INPUT_LINE_NMI, CLEAR_LINE); } } diff --git a/src/mame/machine/dragon.cpp b/src/mame/machine/dragon.cpp index dd3672d4f9d..65af912dcbd 100644 --- a/src/mame/machine/dragon.cpp +++ b/src/mame/machine/dragon.cpp @@ -57,7 +57,7 @@ void dragon_state::pia1_pa_changed(uint8_t data) /* if strobe bit is high send data from pia0 port b to dragon parallel printer */ if (data & 0x02) { - uint8_t output = m_pia_1->b_output(); + uint8_t output = pia_1().b_output(); m_printer->output(output); } } @@ -118,7 +118,7 @@ void dragon64_state::pia1_pb_changed(uint8_t data) { dragon_state::pia1_pb_changed(data); - uint8_t ddr = ~m_pia_1->port_b_z_mask(); + uint8_t ddr = ~pia_1().port_b_z_mask(); /* If bit 2 of the pia1 ddrb is 1 then this pin is an output so use it */ /* to control the paging of the 32k and 64k basic roms */ -- cgit v1.2.3