From 1a0b9509851e61a6a86004ae00f3065870d1c40a Mon Sep 17 00:00:00 2001 From: Ivan Vangelista Date: Fri, 26 Feb 2021 18:12:40 +0100 Subject: [PATCH] 4dpi, amstrad, apple2, bebox, besta, dkong, m24: initialized some variables which were causing incorrect behaviours in drvnoclear debug builds --- src/mame/drivers/4dpi.cpp | 2 + src/mame/drivers/amstrad.cpp | 6 -- src/mame/drivers/apple2.cpp | 2 + src/mame/drivers/besta.cpp | 17 ++- src/mame/drivers/m24.cpp | 9 +- src/mame/includes/amstrad.h | 193 ++++++++++++++++++----------------- src/mame/includes/bebox.h | 41 ++++---- src/mame/includes/dkong.h | 1 + src/mame/machine/amstrad.cpp | 6 +- src/mame/machine/bebox.cpp | 8 +- 10 files changed, 161 insertions(+), 124 deletions(-) diff --git a/src/mame/drivers/4dpi.cpp b/src/mame/drivers/4dpi.cpp index 3da7524b217..33e8acf115a 100644 --- a/src/mame/drivers/4dpi.cpp +++ b/src/mame/drivers/4dpi.cpp @@ -87,6 +87,7 @@ public: , m_gfx(*this, "gfx") , m_softlist(*this, "softlist") , m_leds(*this, "led%u", 0U) + , m_vme_isr(0) { } @@ -248,6 +249,7 @@ public: , m_serial(*this, "serial%u", 1U) , m_dsp(*this, "dsp") { + std::fill(std::begin(m_lio_isr), std::end(m_lio_isr), 0 ); } void pi4d30(machine_config &config); diff --git a/src/mame/drivers/amstrad.cpp b/src/mame/drivers/amstrad.cpp index 61a305dffb9..6867170c97f 100644 --- a/src/mame/drivers/amstrad.cpp +++ b/src/mame/drivers/amstrad.cpp @@ -962,8 +962,6 @@ void amstrad_state::amstrad_base(machine_config &config) m_crtc->out_vsync_callback().set(FUNC(amstrad_state::amstrad_vsync_changed)); m_crtc->out_cur_callback().set("exp", FUNC(cpc_expansion_slot_device::cursor_w)); - MCFG_VIDEO_START_OVERRIDE(amstrad_state,amstrad) - /* sound hardware */ SPEAKER(config, "mono").front_center(); AY8912(config, m_ay, 16_MHz_XTAL / 16); @@ -1087,8 +1085,6 @@ void amstrad_state::cpcplus(machine_config &config) m_crtc->out_hsync_callback().set(FUNC(amstrad_state::amstrad_plus_hsync_changed)); m_crtc->out_vsync_callback().set(FUNC(amstrad_state::amstrad_plus_vsync_changed)); - MCFG_VIDEO_START_OVERRIDE(amstrad_state,amstrad) - /* sound hardware */ SPEAKER(config, "mono").front_center(); AY8912(config, m_ay, 40_MHz_XTAL / 40); @@ -1166,8 +1162,6 @@ void amstrad_state::gx4000(machine_config &config) m_crtc->out_hsync_callback().set(FUNC(amstrad_state::amstrad_plus_hsync_changed)); m_crtc->out_vsync_callback().set(FUNC(amstrad_state::amstrad_plus_vsync_changed)); - MCFG_VIDEO_START_OVERRIDE(amstrad_state,amstrad) - /* sound hardware */ SPEAKER(config, "mono").front_center(); AY8912(config, m_ay, 40_MHz_XTAL / 40); diff --git a/src/mame/drivers/apple2.cpp b/src/mame/drivers/apple2.cpp index b8da52f9ae7..1e5e3d14579 100644 --- a/src/mame/drivers/apple2.cpp +++ b/src/mame/drivers/apple2.cpp @@ -317,6 +317,8 @@ void apple2_state::machine_start() m_cassette->output(-1.0f); m_upperbank->set_bank(0); m_inh_bank = 0; + m_strobe = 0; + m_transchar = 0; // precalculate joystick time constants m_x_calibration = attotime::from_nsec(10800).as_double(); diff --git a/src/mame/drivers/besta.cpp b/src/mame/drivers/besta.cpp index d974ff5f3d3..29d5158b678 100644 --- a/src/mame/drivers/besta.cpp +++ b/src/mame/drivers/besta.cpp @@ -14,6 +14,8 @@ #include "machine/terminal.h" +namespace { + class besta_state : public driver_device { public: @@ -29,11 +31,14 @@ public: void besta(machine_config &config); protected: + virtual void machine_start() override; + virtual void machine_reset() override; + +private: void besta_mem(address_map &map); uint8_t mpcc_reg_r(offs_t offset); void mpcc_reg_w(offs_t offset, uint8_t data); void kbd_put(u8 data); - virtual void machine_reset() override; uint8_t m_term_data; uint8_t m_mpcc_regs[32]; @@ -103,6 +108,13 @@ void besta_state::besta_mem(address_map &map) static INPUT_PORTS_START( besta ) INPUT_PORTS_END +void besta_state::machine_start() +{ + m_term_data = 0; + + save_item(NAME(m_term_data)); + save_item(NAME(m_mpcc_regs)); +} void besta_state::machine_reset() { @@ -143,6 +155,9 @@ ROM_START( besta88 ) ROMX_LOAD( "cp31os9.27c512", 0x0000, 0x10000, CRC(607a0a55) SHA1(c257a88672ab39d2f3fad681d22e062182b0236d), ROM_BIOS(2)) ROM_END +} // Anonymous namespace + + /* Driver */ // YEAR NAME PARENT COMPAT MACHINE INPUT CLASS INIT COMPANY FULLNAME FLAGS diff --git a/src/mame/drivers/m24.cpp b/src/mame/drivers/m24.cpp index 2e020fc3734..473e9593677 100644 --- a/src/mame/drivers/m24.cpp +++ b/src/mame/drivers/m24.cpp @@ -43,6 +43,9 @@ #include "softlist.h" + +namespace { + class m24_state : public driver_device { public: @@ -58,7 +61,8 @@ public: m_kbc(*this, "kbc"), m_keyboard(*this, "keyboard"), m_z8000_apb(*this, "z8000_apb"), - m_dsw0(*this, "DSW0") + m_dsw0(*this, "DSW0"), + m_nmi_enable(false) { } void olivetti(machine_config &config); @@ -658,6 +662,9 @@ ROM_START( m240 ) ROM_LOAD("pdbd.tms2516.kbdmcu_replacement_board.10u", 0x000, 0x800, BAD_DUMP CRC(b8c4c18a) SHA1(25b4c24e19ff91924c53557c66513ab242d926c6)) ROM_END +} // Anonymous namespace + + COMP( 1984, m21, ibm5150, 0, olivetti, m24, m24_state, empty_init, "Olivetti", "M21", MACHINE_NOT_WORKING ) COMP( 1983, m24, ibm5150, 0, olivetti, m24, m24_state, empty_init, "Olivetti", "M24", MACHINE_NOT_WORKING ) COMP( 1987, m240, ibm5150, 0, olivetti, m24, m24_state, empty_init, "Olivetti", "M240", MACHINE_NOT_WORKING ) diff --git a/src/mame/includes/amstrad.h b/src/mame/includes/amstrad.h index b69c5122fcb..171e927c136 100644 --- a/src/mame/includes/amstrad.h +++ b/src/mame/includes/amstrad.h @@ -50,88 +50,12 @@ #include "screen.h" -/**************************** - * Gate Array data (CPC) - - ****************************/ -struct gate_array_t -{ - std::unique_ptr bitmap; /* The bitmap we work on */ - uint8_t pen_selected; /* Pen selection */ - uint8_t mrer; /* Mode and ROM Enable Register */ - uint8_t upper_bank; - uint8_t romdis; // ROMDIS signal from the expansion port - - /* input signals from CRTC */ - int vsync; - int hsync; - int de; - int ma; - int ra; - - /* used for timing */ - int hsync_after_vsync_counter; - int hsync_counter; /* The gate array counts CRTC HSYNC pulses using an internal 6-bit counter. */ - - /* used for drawing the screen */ - attotime last_draw_time; - int y; - uint16_t *draw_p; /* Position in the bitmap where we are currently drawing */ - uint16_t colour; - uint16_t address; - uint8_t *mode_lookup; - uint8_t data; - uint8_t ticks; - uint8_t ticks_increment; - uint16_t line_ticks; - uint8_t colour_ticks; - uint8_t max_colour_ticks; -}; - -/**************************** - * ASIC data (CPC plus) - ****************************/ -struct asic_t -{ - uint8_t *ram; /* pointer to RAM used for the CPC+ ASIC memory-mapped registers */ - uint8_t enabled; /* Are CPC plus features enabled/unlocked */ - uint8_t pri; /* Programmable raster interrupt */ - uint8_t seqptr; /* Current position in the ASIC unlocking sequence */ - uint8_t rmr2; /* ROM mapping register 2 */ - uint16_t split_ma_base; /* Used to handle split screen support */ - uint16_t split_ma_started; /* Used to handle split screen support */ - uint16_t vpos; /* Current logical scanline */ - uint16_t h_start; /* Position where DE became active */ - uint16_t h_end; /* Position where DE became inactive */ - uint8_t addr_6845; /* We need these to store a shadow copy of R1 of the mc6845 */ - uint8_t horiz_disp; - uint8_t hscroll; - uint8_t de_start; /* flag to check if DE is been enabled this frame yet */ - bool hsync_first_tick; /* flag to check in first CRTC tick, used for knowing when to cover left side of screen to cover horizontal softscroll mess */ - uint8_t hsync_tick_count; - - /* DMA */ - uint8_t dma_status; - uint8_t dma_clear; /* Set if DMA interrupts are to be cleared automatically */ - uint8_t dma_prescaler[3]; /* DMA channel prescaler */ - uint16_t dma_repeat[3]; /* Location of the DMA channel's last repeat */ - uint16_t dma_addr[3]; /* DMA channel address */ - uint16_t dma_loopcount[3]; /* Count loops taken on this channel */ - uint16_t dma_pause[3]; /* DMA pause count */ -}; - - class amstrad_state : public driver_device { public: - enum - { - TIMER_PC2_LOW, - TIMER_VIDEO_UPDATE, - TIMER_SET_RESOLUTION - }; - amstrad_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag), + m_exp(*this, "exp"), m_maincpu(*this, "maincpu"), m_ay(*this, "ay"), m_fdc(*this, "upd765"), @@ -142,7 +66,6 @@ public: m_cassette(*this, "cassette"), m_cart(*this, "cartslot"), m_ram(*this, RAM_TAG), - m_exp(*this, "exp"), m_rtc(*this, "rtc"), m_region_maincpu(*this, "maincpu"), m_region_user1(*this, "user1"), @@ -158,6 +81,32 @@ public: m_palette(*this, "palette") { } + void cpcplus_cartslot(machine_config &config); + void amstrad_base(machine_config &config); + void cpc664(machine_config &config); + void cpcplus(machine_config &config); + void gx4000(machine_config &config); + void cpc6128(machine_config &config); + void aleste(machine_config &config); + void kccomp(machine_config &config); + void cpc464(machine_config &config); + + DECLARE_INPUT_CHANGED_MEMBER(cpc_monitor_changed); + + optional_device m_exp; // not on a GX4000; accessed by a static function in machine/amstrad.cpp + +protected: + enum + { + TIMER_PC2_LOW, + TIMER_VIDEO_UPDATE, + TIMER_SET_RESOLUTION + }; + + virtual void video_start() override; + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + +private: required_device m_maincpu; required_device m_ay; optional_device m_fdc; // not on a GX4000 @@ -168,13 +117,83 @@ public: optional_device m_cassette; // not on a GX4000, (or technically, the 6128+) optional_device m_cart; // only on 664+, 6128+ and GX4000 required_device m_ram; - optional_device m_exp; // not on a GX4000 optional_device m_rtc; // Aleste 520EX only int m_system_type; uint8_t m_aleste_mode; int m_plus_irq_cause; + +/**************************** + * Gate Array data (CPC) - + ****************************/ + struct gate_array_t + { + std::unique_ptr bitmap; /* The bitmap we work on */ + uint8_t pen_selected; /* Pen selection */ + uint8_t mrer; /* Mode and ROM Enable Register */ + uint8_t upper_bank; + uint8_t romdis; // ROMDIS signal from the expansion port + + /* input signals from CRTC */ + int vsync; + int hsync; + int de; + int ma; + int ra; + + /* used for timing */ + int hsync_after_vsync_counter; + int hsync_counter; /* The gate array counts CRTC HSYNC pulses using an internal 6-bit counter. */ + + /* used for drawing the screen */ + attotime last_draw_time; + int y; + uint16_t *draw_p; /* Position in the bitmap where we are currently drawing */ + uint16_t colour; + uint16_t address; + uint8_t *mode_lookup; + uint8_t data; + uint8_t ticks; + uint8_t ticks_increment; + uint16_t line_ticks; + uint8_t colour_ticks; + uint8_t max_colour_ticks; + }; + gate_array_t m_gate_array; + +/**************************** + * ASIC data (CPC plus) + ****************************/ + struct asic_t + { + uint8_t *ram; /* pointer to RAM used for the CPC+ ASIC memory-mapped registers */ + uint8_t enabled; /* Are CPC plus features enabled/unlocked */ + uint8_t pri; /* Programmable raster interrupt */ + uint8_t seqptr; /* Current position in the ASIC unlocking sequence */ + uint8_t rmr2; /* ROM mapping register 2 */ + uint16_t split_ma_base; /* Used to handle split screen support */ + uint16_t split_ma_started; /* Used to handle split screen support */ + uint16_t vpos; /* Current logical scanline */ + uint16_t h_start; /* Position where DE became active */ + uint16_t h_end; /* Position where DE became inactive */ + uint8_t addr_6845; /* We need these to store a shadow copy of R1 of the mc6845 */ + uint8_t horiz_disp; + uint8_t hscroll; + uint8_t de_start; /* flag to check if DE is been enabled this frame yet */ + bool hsync_first_tick; /* flag to check in first CRTC tick, used for knowing when to cover left side of screen to cover horizontal softscroll mess */ + uint8_t hsync_tick_count; + + /* DMA */ + uint8_t dma_status; + uint8_t dma_clear; /* Set if DMA interrupts are to be cleared automatically */ + uint8_t dma_prescaler[3]; /* DMA channel prescaler */ + uint16_t dma_repeat[3]; /* Location of the DMA channel's last repeat */ + uint16_t dma_addr[3]; /* DMA channel address */ + uint16_t dma_loopcount[3]; /* Count loops taken on this channel */ + uint16_t dma_pause[3]; /* DMA pause count */ + }; + asic_t m_asic; int m_GateArray_RamConfiguration; unsigned char *m_AmstradCPC_RamBanks[4]; @@ -205,7 +224,6 @@ public: void amstrad_plus_seqcheck(int data); DECLARE_MACHINE_START(amstrad); DECLARE_MACHINE_RESET(amstrad); - DECLARE_VIDEO_START(amstrad); void amstrad_cpc_palette(palette_device &palette) const; void amstrad_cpc_green_palette(palette_device &palette) const; DECLARE_MACHINE_START(plus); @@ -221,7 +239,6 @@ public: void aleste_palette(palette_device &palette) const; uint32_t screen_update_amstrad(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); DECLARE_WRITE_LINE_MEMBER(screen_vblank_amstrad); - DECLARE_INPUT_CHANGED_MEMBER(cpc_monitor_changed); TIMER_CALLBACK_MEMBER(amstrad_pc2_low); TIMER_CALLBACK_MEMBER(amstrad_video_update_timer); TIMER_CALLBACK_MEMBER(cb_set_resolution); @@ -251,18 +268,9 @@ public: DECLARE_WRITE_LINE_MEMBER(write_centronics_busy); - void cpcplus_cartslot(machine_config &config); - void amstrad_base(machine_config &config); - void cpc664(machine_config &config); - void cpcplus(machine_config &config); - void gx4000(machine_config &config); - void cpc6128(machine_config &config); - void aleste(machine_config &config); - void kccomp(machine_config &config); - void cpc464(machine_config &config); void amstrad_io(address_map &map); void amstrad_mem(address_map &map); -protected: + required_memory_region m_region_maincpu; optional_memory_region m_region_user1; required_memory_bank_array<16> m_banks; @@ -300,14 +308,13 @@ protected: void amstrad_common_init(); void enumerate_roms(); static uint8_t kccomp_get_colour_element(int colour_value); - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; int m_centronics_busy; uint8_t m_last_write; }; -/*----------- defined in machine/amstrad.c -----------*/ +/*----------- defined in machine/amstrad.cpp -----------*/ void cpc_exp_cards(device_slot_interface &device); diff --git a/src/mame/includes/bebox.h b/src/mame/includes/bebox.h index aa2bbc60d8f..d160cf5a861 100644 --- a/src/mame/includes/bebox.h +++ b/src/mame/includes/bebox.h @@ -31,11 +31,6 @@ class bebox_state : public driver_device { public: - enum - { - TIMER_GET_DEVICES - }; - bebox_state(const machine_config &mconfig, device_type type, const char *tag) : driver_device(mconfig, type, tag) , m_ppc(*this, "ppc%u", 1U) @@ -51,6 +46,27 @@ public: { } + + void bebox_peripherals(machine_config &config); + void bebox(machine_config &config); + void bebox2(machine_config &config); + + void init_bebox(); + + int m_dma_channel; // TODO: move to private once possible + +protected: + virtual void machine_start() override; + virtual void machine_reset() override; + + enum + { + TIMER_GET_DEVICES + }; + + virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; + +private: required_device_array m_ppc; required_device m_lsi53c810; required_device_array m_dma8237; @@ -64,13 +80,9 @@ public: uint32_t m_cpu_imask[2]; uint32_t m_interrupts; uint32_t m_crossproc_interrupts; - int m_dma_channel; uint16_t m_dma_offset[2][4]; uint8_t m_at_pages[0x10]; uint32_t m_scsi53c810_data[0x100 / 4]; - void init_bebox(); - virtual void machine_start() override; - virtual void machine_reset() override; DECLARE_WRITE_LINE_MEMBER(bebox_pic8259_master_set_int_line); DECLARE_WRITE_LINE_MEMBER(bebox_pic8259_slave_set_int_line); DECLARE_WRITE_LINE_MEMBER(bebox_dma_hrq_changed); @@ -122,19 +134,12 @@ public: void cirrus_config(device_t *device); pci_connector_device & add_pci_slot(machine_config &config, const char *tag, size_t index, const char *default_tag); - void bebox_peripherals(machine_config &config); - void bebox(machine_config &config); - void bebox2(machine_config &config); void main_mem(address_map &map); void slave_mem(address_map &map); -protected: - virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) override; -#ifdef UNUSED_LEGACY_CODE - uint32_t scsi53c810_pci_read(int function, int offset, uint32_t mem_mask); - void scsi53c810_pci_write(int function, int offset, uint32_t data, uint32_t mem_mask); -#endif + [[maybe_unused]] uint32_t scsi53c810_pci_read(int function, int offset, uint32_t mem_mask); + [[maybe_unused]] void scsi53c810_pci_write(int function, int offset, uint32_t data, uint32_t mem_mask); }; diff --git a/src/mame/includes/dkong.h b/src/mame/includes/dkong.h index 00c05c3c1be..d1e22797f4d 100644 --- a/src/mame/includes/dkong.h +++ b/src/mame/includes/dkong.h @@ -121,6 +121,7 @@ public: , m_snd_rom(*this, "soundcpu") , m_vidhw(DKONG_BOARD) , m_sig30Hz(0) + , m_star_ff(0) , m_blue_level(0) , m_cv1(0) , m_cv2(0) diff --git a/src/mame/machine/amstrad.cpp b/src/mame/machine/amstrad.cpp index aef00e0f979..4062bf5d7dd 100644 --- a/src/mame/machine/amstrad.cpp +++ b/src/mame/machine/amstrad.cpp @@ -1068,12 +1068,13 @@ WRITE_LINE_MEMBER(amstrad_state::amstrad_plus_de_changed) } -VIDEO_START_MEMBER(amstrad_state,amstrad) +void amstrad_state::video_start() { amstrad_init_lookups(); m_gate_array.bitmap = std::make_unique(m_screen->width(), m_screen->height() ); m_gate_array.hsync_after_vsync_counter = 3; + std::fill(std::begin(m_GateArray_render_colours), std::end(m_GateArray_render_colours), 0); } @@ -3017,6 +3018,9 @@ void amstrad_state::amstrad_common_init() m_aleste_mode = 0; + m_asic.enabled = 0; + + m_gate_array.romdis = 0; m_gate_array.mrer = 0; m_gate_array.vsync = 0; m_gate_array.hsync = 0; diff --git a/src/mame/machine/bebox.cpp b/src/mame/machine/bebox.cpp index b34b2837b89..dbc7f198063 100644 --- a/src/mame/machine/bebox.cpp +++ b/src/mame/machine/bebox.cpp @@ -2,7 +2,7 @@ // copyright-holders:Nathan Woods, R. Belmont /*************************************************************************** - machine/bebox.c + machine/bebox.cpp BeBox @@ -662,8 +662,8 @@ void bebox_state::scsi53c810_w(offs_t offset, uint64_t data, uint64_t mem_mask) } } +// the 2 following methods are legacy code, currently unused -#ifdef UNUSED_LEGACY_CODE uint32_t bebox_state::scsi53c810_pci_read(int function, int offset, uint32_t mem_mask) { uint32_t result = 0; @@ -717,14 +717,13 @@ void bebox_state::scsi53c810_pci_write(int function, int offset, uint32_t data, address_space &space = m_ppc[0]->space(AS_PROGRAM); addr = (m_scsi53c810_data[5] | 0xC0000000) & ~0xFF; - space.install_readwrite_handler(addr, addr + 0xFF, read64_delegate(FUNC(bebox_state::scsi53c810_r),this), write64_delegate(FUNC(bebox_state::scsi53c810_w),this)); + space.install_readwrite_handler(addr, addr + 0xFF, read64s_delegate(*this, FUNC(bebox_state::scsi53c810_r)), write64s_delegate(*this, FUNC(bebox_state::scsi53c810_w))); } } break; } } } -#endif void bebox_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) @@ -758,6 +757,7 @@ void bebox_state::machine_reset() void bebox_state::machine_start() { + m_interrupts = 0; } void bebox_state::init_bebox()