diff --git a/src/devices/bus/bbc/1mhzbus/cc500.cpp b/src/devices/bus/bbc/1mhzbus/cc500.cpp index c04fc06429e..6da7a1b995c 100644 --- a/src/devices/bus/bbc/1mhzbus/cc500.cpp +++ b/src/devices/bus/bbc/1mhzbus/cc500.cpp @@ -38,6 +38,8 @@ #include "emu.h" #include "cc500.h" +#include + //************************************************************************** // DEVICE DEFINITIONS @@ -110,9 +112,9 @@ bbc_cc500_device::bbc_cc500_device(const machine_config &mconfig, const char *ta void bbc_cc500_device::device_start() { - memset(m_palette_ram, 0, sizeof(m_palette_ram)); + std::fill(std::begin(m_palette_ram), std::end(m_palette_ram), rgb_t(0)); - /* register for save states */ + // register for save states save_item(NAME(m_palette_ram)); } diff --git a/src/devices/bus/bbc/userport/palext.cpp b/src/devices/bus/bbc/userport/palext.cpp index dab527e478b..090fae74593 100644 --- a/src/devices/bus/bbc/userport/palext.cpp +++ b/src/devices/bus/bbc/userport/palext.cpp @@ -16,6 +16,9 @@ #include "emu.h" #include "palext.h" +#include + + //************************************************************************** // DEVICE DEFINITIONS //************************************************************************** @@ -76,9 +79,9 @@ bbc_cpalette_device::bbc_cpalette_device(const machine_config &mconfig, const ch void bbc_palext_device::device_start() { - memset(m_palette_ram, 0, sizeof(m_palette_ram)); + std::fill(std::begin(m_palette_ram), std::end(m_palette_ram), rgb_t(0)); - /* register for save states */ + // register for save states save_item(NAME(m_colour)); save_item(NAME(m_palette_ram)); } diff --git a/src/devices/machine/64h156.cpp b/src/devices/machine/64h156.cpp index 6613b34ab69..60498046dd9 100644 --- a/src/devices/machine/64h156.cpp +++ b/src/devices/machine/64h156.cpp @@ -72,7 +72,6 @@ c64h156_device::c64h156_device(const machine_config &mconfig, const char *tag, d m_atni(0), m_atna(0) { - memset(&cur_live, 0x00, sizeof(cur_live)); cur_live.tm = attotime::never; cur_live.state = IDLE; cur_live.next_state = -1; diff --git a/src/devices/machine/64h156.h b/src/devices/machine/64h156.h index ed607885db7..707071bb424 100644 --- a/src/devices/machine/64h156.h +++ b/src/devices/machine/64h156.h @@ -117,28 +117,28 @@ private: struct live_info { attotime tm; - int state, next_state; - int sync; - int byte; - int ds; - int oe; - int soe; - int accl; - uint8_t accl_yb; + int state = 0, next_state = 0; + int sync = 0; + int byte = 0; + int ds = 0; + int oe = 0; + int soe = 0; + int accl = 0; + uint8_t accl_yb = 0; attotime edge; - uint16_t shift_reg; - int cycle_counter; - int cell_counter; - int bit_counter; - int zero_counter; - int cycles_until_random_flux; + uint16_t shift_reg = 0; + int cycle_counter = 0; + int cell_counter = 0; + int bit_counter = 0; + int zero_counter = 0; + int cycles_until_random_flux = 0; - uint8_t yb; - uint8_t shift_reg_write; + uint8_t yb = 0; + uint8_t shift_reg_write = 0; attotime write_start_time; attotime write_buffer[32]; - int write_position; + int write_position = 0; }; devcb_write_line m_write_atn; diff --git a/src/mame/exidy/vertigo_v.cpp b/src/mame/exidy/vertigo_v.cpp index a782b8236b3..a50a32fd531 100644 --- a/src/mame/exidy/vertigo_v.cpp +++ b/src/mame/exidy/vertigo_v.cpp @@ -163,27 +163,27 @@ void vertigo_state::vertigo_vproc_reset() /* Decode microcode */ for (int i = 0; i < MC_LENGTH; i++) { - m_mc[i].x = (mcode[i] >> 44) & 0x3f; - m_mc[i].a = (mcode[i] >> 40) & 0xf; - m_mc[i].b = (mcode[i] >> 36) & 0xf; - m_mc[i].inst = (mcode[i] >> 27) & 077; - m_mc[i].dest = (mcode[i] >> 33) & 07; - m_mc[i].cn = (mcode[i] >> 26) & 0x1; - m_mc[i].mreq = (mcode[i] >> 25) & 0x1; - m_mc[i].rwrite = (mcode[i] >> 23) & 0x1; - m_mc[i].rsel = m_mc[i].rwrite & ((mcode[i] >> 24) & 0x1); - m_mc[i].of = (mcode[i] >> 20) & 0x7; - m_mc[i].iif = (mcode[i] >> 18) & 0x3; - m_mc[i].oa = (mcode[i] >> 16) & 0x3; - m_mc[i].jpos = (mcode[i] >> 14) & 0x1; - m_mc[i].jmp = (mcode[i] >> 12) & 0x3; - m_mc[i].jcon = (mcode[i] >> 9) & 0x7; - m_mc[i].ma = mcode[i] & 0x1ff; + m_mc[i].x = BIT(mcode[i], 44, 6); + m_mc[i].a = BIT(mcode[i], 40, 4); + m_mc[i].b = BIT(mcode[i], 36, 4); + m_mc[i].inst = BIT(mcode[i], 27, 6); + m_mc[i].dest = BIT(mcode[i], 33, 3); + m_mc[i].cn = BIT(mcode[i], 26, 1); + m_mc[i].mreq = BIT(mcode[i], 25, 1); + m_mc[i].rwrite = BIT(mcode[i], 23, 1); + m_mc[i].rsel = BIT(mcode[i], 24, 1) & m_mc[i].rwrite; + m_mc[i].of = BIT(mcode[i], 20, 3); + m_mc[i].iif = BIT(mcode[i], 18, 2); + m_mc[i].oa = BIT(mcode[i], 16, 2); + m_mc[i].jpos = BIT(mcode[i], 14, 1); + m_mc[i].jmp = BIT(mcode[i], 12, 2); + m_mc[i].jcon = BIT(mcode[i], 9, 3); + m_mc[i].ma = BIT(mcode[i], 0, 9); } - memset(&m_vs, 0, sizeof(m_vs)); - memset(&m_bsp, 0, sizeof(m_bsp)); - memset(&m_vgen, 0, sizeof(m_vgen)); + m_vs = vproc(); + m_bsp = am2901(); + m_vgen = vector_generator(); } diff --git a/src/mame/exidy/victory.h b/src/mame/exidy/victory.h index 84e2a189abe..4bd9ce87553 100644 --- a/src/mame/exidy/victory.h +++ b/src/mame/exidy/victory.h @@ -70,13 +70,13 @@ private: /* microcode state */ struct micro_t { - uint16_t i; - uint16_t pc; - uint8_t r,g,b; - uint8_t xp,yp; - uint8_t cmd,cmdlo; - emu_timer * timer; - uint8_t timer_active; + uint16_t i = 0; + uint16_t pc = 0; + uint8_t r = 0, g = 0, b = 0; + uint8_t xp = 0, yp = 0; + uint8_t cmd = 0, cmdlo = 0; + emu_timer * timer = nullptr; + uint8_t timer_active = 0; attotime endtime; void count_states(int states); diff --git a/src/mame/exidy/victory_v.cpp b/src/mame/exidy/victory_v.cpp index 87c0fb3c33a..48aa198b7cf 100644 --- a/src/mame/exidy/victory_v.cpp +++ b/src/mame/exidy/victory_v.cpp @@ -49,7 +49,7 @@ void victory_state::video_start() m_scrollx = m_scrolly = 0; m_video_control = 0; - memset(&m_micro, 0, sizeof(m_micro)); + m_micro = micro_t(); m_micro.timer = machine().scheduler().timer_alloc(timer_expired_delegate()); for (int i = 0; i < 128; i++) diff --git a/src/mame/interton/vc4000.h b/src/mame/interton/vc4000.h index a71eea4dc25..ad4381a7582 100644 --- a/src/mame/interton/vc4000.h +++ b/src/mame/interton/vc4000.h @@ -71,7 +71,7 @@ private: struct SPRITE { - const SPRITE_HELPER *data; + const SPRITE_HELPER *data = nullptr; int mask = 0; int state = 0; int delay = 0; diff --git a/src/mame/konami/viper.cpp b/src/mame/konami/viper.cpp index b9f2e23df28..88a0c6d2c21 100644 --- a/src/mame/konami/viper.cpp +++ b/src/mame/konami/viper.cpp @@ -623,13 +623,13 @@ private: uint32_t eicr = 0U; uint32_t svr = 0U; - uint8_t pctpr = 0xfU; + uint8_t pctpr = 0x0U; int active_irq = 0; - MPC8240_IRQ irq[MPC8240_NUM_INTERRUPTS]{}; + MPC8240_IRQ irq[MPC8240_NUM_INTERRUPTS]; - MPC8240_GLOBAL_TIMER global_timer[4]{}; + MPC8240_GLOBAL_TIMER global_timer[4]; }; MPC8240_EPIC m_epic{}; @@ -1238,7 +1238,7 @@ void viper_state::mpc8240_interrupt(int irq) void viper_state::mpc8240_epic_init() { - memset(&m_epic, 0, sizeof(m_epic)); + m_epic = MPC8240_EPIC(); m_epic.global_timer[0].timer = timer_alloc(FUNC(viper_state::epic_global_timer_callback), this); m_epic.global_timer[1].timer = timer_alloc(FUNC(viper_state::epic_global_timer_callback), this); m_epic.global_timer[2].timer = timer_alloc(FUNC(viper_state::epic_global_timer_callback), this); diff --git a/src/mame/sega/saturn.h b/src/mame/sega/saturn.h index bf04c744186..f9920c4b021 100644 --- a/src/mame/sega/saturn.h +++ b/src/mame/sega/saturn.h @@ -166,12 +166,12 @@ protected: /* VDP1 */ - void stv_set_framebuffer_config( void ); - void stv_prepare_framebuffers( void ); - void stv_vdp1_change_framebuffers( void ); - void video_update_vdp1( void ); - void stv_vdp1_process_list( void ); - void stv_vdp1_set_drawpixel( void ); + void stv_set_framebuffer_config(); + void stv_prepare_framebuffers(); + void stv_vdp1_change_framebuffers(); + void video_update_vdp1(); + void stv_vdp1_process_list(); + void stv_vdp1_set_drawpixel(); void stv_vdp1_draw_normal_sprite(const rectangle &cliprect, int sprite_type); void stv_vdp1_draw_scaled_sprite(const rectangle &cliprect); @@ -202,14 +202,14 @@ protected: int32_t g1, int32_t g2, int32_t slg1, int32_t slg2, int32_t *ng1, int32_t *ng2, int32_t b1, int32_t b2, int32_t slb1, int32_t slb2, int32_t *nb1, int32_t *nb2, int32_t _y1, int32_t y2); - uint16_t stv_vdp1_apply_gouraud_shading( int x, int y, uint16_t pix ); + uint16_t stv_vdp1_apply_gouraud_shading(int x, int y, uint16_t pix); void stv_vdp1_setup_shading(const struct spoint* q, const rectangle &cliprect); - uint8_t stv_read_gouraud_table( void ); - void stv_clear_gouraud_shading(void); + uint8_t stv_read_gouraud_table(); + void stv_clear_gouraud_shading(); - void stv_clear_framebuffer( int which_framebuffer ); - void stv_vdp1_state_save_postload( void ); - int stv_vdp1_start ( void ); + void stv_clear_framebuffer(int which_framebuffer); + void stv_vdp1_state_save_postload(); + int stv_vdp1_start(); struct stv_vdp1_poly_scanline { @@ -263,19 +263,19 @@ protected: /* VDP2 */ - uint8_t get_vblank( void ); - uint8_t get_hblank( void ); - int get_hcounter( void ); - int get_vcounter( void ); - int get_vblank_duration( void ); - int get_hblank_duration( void ); - int get_pixel_clock( void ); - uint8_t get_odd_bit( void ); - void stv_vdp2_dynamic_res_change( void ); - int get_vblank_start_position( void ); - int get_ystep_count( void ); + uint8_t get_vblank(); + uint8_t get_hblank(); + int get_hcounter(); + int get_vcounter(); + int get_vblank_duration(); + int get_hblank_duration(); + int get_pixel_clock(); + uint8_t get_odd_bit(); + void stv_vdp2_dynamic_res_change(); + int get_vblank_start_position(); + int get_ystep_count(); - void refresh_palette_data( void ); + void refresh_palette_data(); inline int stv_vdp2_window_process(int x,int y); void stv_vdp2_get_window0_coordinates(int *s_x, int *e_x, int *s_y, int *e_y, int y); void stv_vdp2_get_window1_coordinates(int *s_x, int *e_x, int *s_y, int *e_y, int y); @@ -292,8 +292,8 @@ protected: void stv_vdp2_drawgfxzoom(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, uint32_t code,uint32_t color,int flipx,int flipy,int sx,int sy,int transparency,int scalex, int scaley,int sprite_screen_width, int sprite_screen_height, int alpha); void stv_vdp2_drawgfxzoom_rgb555(bitmap_rgb32 &dest_bmp,const rectangle &clip,uint32_t code,uint32_t color,int flipx,int flipy,int sx,int sy,int transparency,int scalex, int scaley,int sprite_screen_width, int sprite_screen_height, int alpha); - void stv_vdp2_drawgfx_rgb555( bitmap_rgb32 &dest_bmp, const rectangle &clip, uint32_t code, int flipx, int flipy, int sx, int sy, int transparency, int alpha); - void stv_vdp2_drawgfx_rgb888( bitmap_rgb32 &dest_bmp, const rectangle &clip, uint32_t code, int flipx, int flipy, int sx, int sy, int transparency, int alpha); + void stv_vdp2_drawgfx_rgb555(bitmap_rgb32 &dest_bmp, const rectangle &clip, uint32_t code, int flipx, int flipy, int sx, int sy, int transparency, int alpha); + void stv_vdp2_drawgfx_rgb888(bitmap_rgb32 &dest_bmp, const rectangle &clip, uint32_t code, int flipx, int flipy, int sx, int sy, int transparency, int alpha); void stv_vdp2_drawgfx_alpha(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, uint32_t code,uint32_t color, int flipx,int flipy,int offsx,int offsy, int transparency, int alpha); void stv_vdp2_drawgfx_transpen(bitmap_rgb32 &dest_bmp,const rectangle &clip,gfx_element *gfx, uint32_t code,uint32_t color, int flipx,int flipy,int offsx,int offsy, int transparency); @@ -306,17 +306,17 @@ protected: inline bool stv_vdp2_roz_window(int x, int y); inline bool stv_vdp2_roz_mode3_window(int x, int y, int rot_parameter); inline int get_roz_window_pixel(int s_x,int e_x,int s_y,int e_y,int x, int y,uint8_t winenable,uint8_t winarea); - void stv_vdp2_fill_rotation_parameter_table( uint8_t rot_parameter ); - uint8_t stv_vdp2_check_vram_cycle_pattern_registers( uint8_t access_command_pnmdr, uint8_t access_command_cpdr, uint8_t bitmap_enable ); - uint8_t stv_vdp2_is_rotation_applied(void); - uint8_t stv_vdp2_are_map_registers_equal(void); - void stv_vdp2_get_map_page( int x, int y, int *_map, int *_page ); + void stv_vdp2_fill_rotation_parameter_table(uint8_t rot_parameter); + uint8_t stv_vdp2_check_vram_cycle_pattern_registers(uint8_t access_command_pnmdr, uint8_t access_command_cpdr, uint8_t bitmap_enable); + uint8_t stv_vdp2_is_rotation_applied(); + uint8_t stv_vdp2_are_map_registers_equal(); + void stv_vdp2_get_map_page(int x, int y, int *_map, int *_page); void stv_vdp2_draw_mosaic(bitmap_rgb32 &bitmap, const rectangle &cliprect, uint8_t is_roz); - void stv_vdp2_fade_effects( void ); - void stv_vdp2_compute_color_offset( int *r, int *g, int *b, int cor ); + void stv_vdp2_fade_effects(); + void stv_vdp2_compute_color_offset(int *r, int *g, int *b, int cor); void stv_vdp2_compute_color_offset_UINT32(rgb_t *rgb, int cor); - void stv_vdp2_check_fade_control_for_layer( void ); + void stv_vdp2_check_fade_control_for_layer(); void stv_vdp2_draw_line(bitmap_rgb32 &bitmap, const rectangle &cliprect); void stv_vdp2_draw_back(bitmap_rgb32 &bitmap, const rectangle &cliprect); @@ -328,9 +328,9 @@ protected: void draw_sprites(bitmap_rgb32 &bitmap, const rectangle &cliprect, uint8_t pri); int true_vcount[263][4]; - void stv_vdp2_state_save_postload( void ); - void stv_vdp2_exit ( void ); - int stv_vdp2_start ( void ); + void stv_vdp2_state_save_postload(); + void stv_vdp2_exit(); + int stv_vdp2_start(); uint8_t m_vdpdebug_roz = 0; diff --git a/src/mame/sega/saturn_v.cpp b/src/mame/sega/saturn_v.cpp index b5c6135934f..944d1d2140b 100644 --- a/src/mame/sega/saturn_v.cpp +++ b/src/mame/sega/saturn_v.cpp @@ -232,7 +232,7 @@ void saturn_state::stv_clear_framebuffer( int which_framebuffer ) } -void saturn_state::stv_prepare_framebuffers( void ) +void saturn_state::stv_prepare_framebuffers() { int i,rowsize; @@ -273,7 +273,7 @@ void saturn_state::stv_prepare_framebuffers( void ) } -void saturn_state::stv_vdp1_change_framebuffers( void ) +void saturn_state::stv_vdp1_change_framebuffers() { m_vdp1.framebuffer_current_display ^= 1; m_vdp1.framebuffer_current_draw ^= 1; @@ -283,7 +283,7 @@ void saturn_state::stv_vdp1_change_framebuffers( void ) stv_prepare_framebuffers(); } -void saturn_state::stv_set_framebuffer_config( void ) +void saturn_state::stv_set_framebuffer_config() { if ( m_vdp1.framebuffer_mode == STV_VDP1_TVM && m_vdp1.framebuffer_double_interlace == STV_VDP1_DIE ) return; @@ -521,12 +521,12 @@ the rest are data used by it */ -void saturn_state::stv_clear_gouraud_shading(void) +void saturn_state::stv_clear_gouraud_shading() { - memset( &stv_gouraud_shading, 0, sizeof( stv_gouraud_shading ) ); + stv_gouraud_shading = decltype(stv_gouraud_shading)(); } -uint8_t saturn_state::stv_read_gouraud_table( void ) +uint8_t saturn_state::stv_read_gouraud_table() { int gaddr; @@ -1086,7 +1086,7 @@ void saturn_state::drawpixel_generic(int x, int y, int patterndata, int offsetcn } -void saturn_state::stv_vdp1_set_drawpixel( void ) +void saturn_state::stv_vdp1_set_drawpixel() { int sprite_type = stv2_current_sprite.CMDCTRL & 0x000f; int sprite_mode = stv2_current_sprite.CMDPMOD&0x0038; @@ -1818,7 +1818,7 @@ TIMER_CALLBACK_MEMBER(saturn_state::vdp1_draw_end ) } -void saturn_state::stv_vdp1_process_list( void ) +void saturn_state::stv_vdp1_process_list() { int position; int spritecount; @@ -2062,7 +2062,7 @@ void saturn_state::stv_vdp1_process_list( void ) if (VDP1_LOG) logerror ("End of list processing!\n"); } -void saturn_state::video_update_vdp1( void ) +void saturn_state::video_update_vdp1() { int framebuffer_changed = 0; @@ -2157,7 +2157,7 @@ void saturn_state::video_update_vdp1( void ) //popmessage("%04x %04x",STV_VDP1_EWRR_X3,STV_VDP1_EWRR_Y3); } -void saturn_state::stv_vdp1_state_save_postload( void ) +void saturn_state::stv_vdp1_state_save_postload() { uint8_t *vdp1 = m_vdp1.gfx_decode.get(); int offset; @@ -2179,7 +2179,7 @@ void saturn_state::stv_vdp1_state_save_postload( void ) } } -int saturn_state::stv_vdp1_start ( void ) +int saturn_state::stv_vdp1_start() { m_vdp1_regs = make_unique_clear(0x020/2 ); m_vdp1_vram = make_unique_clear(0x100000/4 ); @@ -4450,7 +4450,7 @@ void saturn_state::stv_vdp2_fill_rotation_parameter_table( uint8_t rot_parameter } /* check if RGB layer has rotation applied */ -uint8_t saturn_state::stv_vdp2_is_rotation_applied(void) +uint8_t saturn_state::stv_vdp2_is_rotation_applied() { #define _FIXED_1 (0x00010000) #define _FIXED_0 (0x00000000) @@ -4477,7 +4477,7 @@ uint8_t saturn_state::stv_vdp2_is_rotation_applied(void) } } -uint8_t saturn_state::stv_vdp2_are_map_registers_equal(void) +uint8_t saturn_state::stv_vdp2_are_map_registers_equal() { int i; @@ -4491,7 +4491,7 @@ uint8_t saturn_state::stv_vdp2_are_map_registers_equal(void) return 1; } -void saturn_state::stv_vdp2_check_fade_control_for_layer( void ) +void saturn_state::stv_vdp2_check_fade_control_for_layer() { if ( stv2_current_tilemap.fade_control & 1 ) { @@ -8159,7 +8159,7 @@ void saturn_state::saturn_vdp2_cram_w(offs_t offset, uint32_t data, uint32_t mem } } -void saturn_state::refresh_palette_data( void ) +void saturn_state::refresh_palette_data() { int r,g,b; int c_i; @@ -8235,7 +8235,7 @@ void saturn_state::saturn_vdp2_regs_w(offs_t offset, uint16_t data, uint16_t mem printf("VDP2 sets up 8 Mbit VRAM!\n"); } -int saturn_state::get_hblank_duration( void ) +int saturn_state::get_hblank_duration() { int res; @@ -8250,7 +8250,7 @@ int saturn_state::get_hblank_duration( void ) /*some vblank lines measurements (according to Charles MacDonald)*/ /* TODO: interlace mode "eats" one line, should be 262.5 */ -int saturn_state::get_vblank_duration( void ) +int saturn_state::get_vblank_duration() { int res; @@ -8266,7 +8266,7 @@ int saturn_state::get_vblank_duration( void ) return res; } -int saturn_state::get_pixel_clock( void ) +int saturn_state::get_pixel_clock() { int res,divider; @@ -8287,7 +8287,7 @@ int saturn_state::get_pixel_clock( void ) } /* TODO: hblank position and hblank firing doesn't really match HW behaviour. */ -uint8_t saturn_state::get_hblank( void ) +uint8_t saturn_state::get_hblank() { const rectangle &visarea = m_screen->visible_area(); int cur_h = m_screen->hpos(); @@ -8298,7 +8298,7 @@ uint8_t saturn_state::get_hblank( void ) return 0; } -uint8_t saturn_state::get_vblank( void ) +uint8_t saturn_state::get_vblank() { int cur_v,vblank; cur_v = m_screen->vpos(); @@ -8311,7 +8311,7 @@ uint8_t saturn_state::get_vblank( void ) return 0; } -uint8_t saturn_state::get_odd_bit( void ) +uint8_t saturn_state::get_odd_bit() { if(STV_VDP2_HRES & 4) //exclusive monitor mode makes this bit to be always 1 return 1; @@ -8323,7 +8323,7 @@ uint8_t saturn_state::get_odd_bit( void ) return m_vdp2.odd;//m_screen->frame_number() & 1; } -int saturn_state::get_vblank_start_position( void ) +int saturn_state::get_vblank_start_position() { // TODO: test says that second setting happens at 241, might need further investigation ... // also first one happens at 240, but needs mods in SMPC otherwise we get 2 credits at startup in shanhigw and sokyugrt @@ -8338,7 +8338,7 @@ int saturn_state::get_vblank_start_position( void ) return vblank_line; } -int saturn_state::get_ystep_count( void ) +int saturn_state::get_ystep_count() { int max_y = m_screen->height(); int y_step; @@ -8352,7 +8352,7 @@ int saturn_state::get_ystep_count( void ) } /* TODO: these needs to be checked via HW tests! */ -int saturn_state::get_hcounter( void ) +int saturn_state::get_hcounter() { int hcount; @@ -8383,7 +8383,7 @@ int saturn_state::get_hcounter( void ) return hcount; } -int saturn_state::get_vcounter( void ) +int saturn_state::get_vcounter() { int vcount; @@ -8402,7 +8402,7 @@ int saturn_state::get_vcounter( void ) return (true_vcount[vcount & 0x1ff][STV_VDP2_VRES]); // Non-interlace } -void saturn_state::stv_vdp2_state_save_postload( void ) +void saturn_state::stv_vdp2_state_save_postload() { uint8_t *gfxdata = m_vdp2.gfx_decode.get(); int offset; @@ -8438,13 +8438,13 @@ void saturn_state::stv_vdp2_state_save_postload( void ) refresh_palette_data(); } -void saturn_state::stv_vdp2_exit ( void ) +void saturn_state::stv_vdp2_exit() { m_vdp2.roz_bitmap[0].reset(); m_vdp2.roz_bitmap[1].reset(); } -int saturn_state::stv_vdp2_start ( void ) +int saturn_state::stv_vdp2_start() { machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(&saturn_state::stv_vdp2_exit, this)); @@ -8505,7 +8505,7 @@ VIDEO_START_MEMBER(saturn_state,stv_vdp2) } } -void saturn_state::stv_vdp2_dynamic_res_change( void ) +void saturn_state::stv_vdp2_dynamic_res_change() { const int d_vres[4] = { 224, 240, 256, 256 }; const int d_hres[4] = { 320, 352, 640, 704 }; @@ -8546,7 +8546,7 @@ void saturn_state::stv_vdp2_dynamic_res_change( void ) /*This is for calculating the rgb brightness*/ /*TODO: Optimize this...*/ -void saturn_state::stv_vdp2_fade_effects( void ) +void saturn_state::stv_vdp2_fade_effects() { /* Note:We have to use temporary storages because palette_get_color must use diff --git a/src/mame/sega/segaic16.cpp b/src/mame/sega/segaic16.cpp index 52eb685e11b..ab257af17f6 100644 --- a/src/mame/sega/segaic16.cpp +++ b/src/mame/sega/segaic16.cpp @@ -537,8 +537,6 @@ segaic16_video_device::segaic16_video_device(const machine_config &mconfig, cons , m_pagelatch_cb(*this, DEVICE_SELF, FUNC(segaic16_video_device::tilemap_16b_fill_latch)) , m_gfxdecode(*this, finder_base::DUMMY_TAG) { - memset(m_rotate, 0, sizeof(m_rotate)); - memset(m_bg_tilemap, 0, sizeof(m_bg_tilemap)); } void segaic16_video_device::device_start() @@ -1205,7 +1203,7 @@ void segaic16_video_device::tilemap_init(int which, int type, int colorbase, int tilemap_get_info_delegate get_tile_info(*this); /* reset the tilemap info */ - memset(info, 0, sizeof(*info)); + *info = tilemap_info(); info->index = which; info->type = type; for (int i = 0; i < numbanks; i++) @@ -1477,7 +1475,7 @@ void segaic16_video_device::rotate_init(int which, int type, int colorbase) struct rotate_info *info = &m_rotate[which]; /* reset the tilemap info */ - memset(info, 0, sizeof(*info)); + *info = rotate_info(); info->index = which; info->type = type; info->colorbase = colorbase; diff --git a/src/mame/sega/segaic16.h b/src/mame/sega/segaic16.h index 0959fb3320d..e11fa7c48a3 100644 --- a/src/mame/sega/segaic16.h +++ b/src/mame/sega/segaic16.h @@ -76,45 +76,47 @@ public: struct tilemap_callback_info { - uint16_t * rambase; /* base of RAM for this tilemap page */ - const uint8_t * bank; /* pointer to bank array */ - uint16_t banksize; /* size of banks */ + uint16_t * rambase = nullptr; // base of RAM for this tilemap page + const uint8_t * bank = nullptr; // pointer to bank array + uint16_t banksize = 0; // size of banks }; - struct tilemap_info { - uint8_t index; /* index of this structure */ - uint8_t type; /* type of tilemap (see segaic16.h for details) */ - uint8_t numpages; /* number of allocated pages */ - uint8_t flip; /* screen flip? */ - uint8_t rowscroll, colscroll; /* are rowscroll/colscroll enabled (if external enables are used) */ - uint8_t bank[8]; /* indexes of the tile banks */ - uint16_t banksize; /* number of tiles per bank */ - uint16_t latched_xscroll[4]; /* latched X scroll values */ - uint16_t latched_yscroll[4]; /* latched Y scroll values */ - uint16_t latched_pageselect[4]; /* latched page select values */ - int32_t xoffs; /* X scroll offset */ - tilemap_t * tilemaps[16]; /* up to 16 tilemap pages */ - tilemap_t * textmap; /* a single text tilemap */ - struct tilemap_callback_info tmap_info[16]; /* callback info for 16 tilemap pages */ - struct tilemap_callback_info textmap_info; /* callback info for a single textmap page */ - void (*reset)(screen_device &screen, struct tilemap_info *info);/* reset callback */ - void (*draw_layer)(screen_device &screen, struct tilemap_info *info, bitmap_ind16 &bitmap, const rectangle &cliprect, int which, int flags, int priority); - uint16_t * textram; /* pointer to textram pointer */ - uint16_t * tileram; /* pointer to tileram pointer */ - emu_timer * latch_timer; /* timer for latching 16b tilemap scroll values */ + using reset_func = void (*)(screen_device &screen, tilemap_info *info); + using draw_layer_func = void (*)(screen_device &screen, tilemap_info *info, bitmap_ind16 &bitmap, const rectangle &cliprect, int which, int flags, int priority); + + uint8_t index = 0; // index of this structure + uint8_t type = 0; // type of tilemap (see segaic16.h for details) + uint8_t numpages = 0; // number of allocated pages + uint8_t flip = 0; // screen flip? + uint8_t rowscroll = 0, colscroll = 0; // are rowscroll/colscroll enabled (if external enables are used) + uint8_t bank[8]; // indexes of the tile banks + uint16_t banksize = 0; // number of tiles per bank + uint16_t latched_xscroll[4] = {0,0,0,0}; // latched X scroll values + uint16_t latched_yscroll[4] = {0,0,0,0}; // latched Y scroll values + uint16_t latched_pageselect[4] = {0,0,0,0}; // latched page select values + int32_t xoffs = 0; // X scroll offset + tilemap_t * tilemaps[16]{}; // up to 16 tilemap pages + tilemap_t * textmap = nullptr; // a single text tilemap + tilemap_callback_info tmap_info[16]; // callback info for 16 tilemap pages + tilemap_callback_info textmap_info; // callback info for a single textmap page + reset_func reset = nullptr; // reset callback + draw_layer_func draw_layer = nullptr; + uint16_t * textram = nullptr; // pointer to textram pointer + uint16_t * tileram = nullptr; // pointer to tileram pointer + emu_timer * latch_timer = nullptr; // timer for latching 16b tilemap scroll values }; struct rotate_info { - uint8_t index; /* index of this structure */ - uint8_t type; /* type of rotate system (see segaic16.h for details) */ - uint16_t colorbase; /* base color index */ - int32_t ramsize; /* size of rotate RAM */ - uint16_t * rotateram; /* pointer to rotateram pointer */ - std::unique_ptr buffer; /* buffered data */ + uint8_t index = 0; // index of this structure + uint8_t type = 0; // type of rotate system (see segaic16.h for details) + uint16_t colorbase = 0; // base color index + int32_t ramsize = 0; // size of rotate RAM + uint16_t * rotateram = nullptr; // pointer to rotateram pointer + std::unique_ptr buffer; // buffered data }; template segaic16_video_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&decode_tag) diff --git a/src/mame/sega/segaic16_road.cpp b/src/mame/sega/segaic16_road.cpp index 35d31cb4057..9ce28256cce 100644 --- a/src/mame/sega/segaic16_road.cpp +++ b/src/mame/sega/segaic16_road.cpp @@ -522,7 +522,7 @@ void segaic16_road_device::segaic16_road_init(int which, int type, int colorbase road_info *info = &segaic16_road[which]; /* reset the tilemap info */ - memset(info, 0, sizeof(*info)); + *info = road_info(); info->index = which; info->type = type; info->colorbase1 = colorbase1; diff --git a/src/mame/sega/segaic16_road.h b/src/mame/sega/segaic16_road.h index a8c2e3a77ad..e5f174623db 100644 --- a/src/mame/sega/segaic16_road.h +++ b/src/mame/sega/segaic16_road.h @@ -23,20 +23,21 @@ public: static constexpr unsigned ROAD_FOREGROUND = 1; - struct road_info { - u8 index; /* index of this structure */ - u8 type; /* type of road system (see segaic16.h for details) */ - u8 control; /* control register value */ - u16 colorbase1; /* color base for road ROM data */ - u16 colorbase2; /* color base for road background data */ - u16 colorbase3; /* color base for sky data */ - s32 xoffs; /* X scroll offset */ - void (*draw)(struct road_info *info, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority); - u16 * roadram; /* pointer to roadram pointer */ - std::unique_ptr buffer; /* buffered roadram pointer */ - std::unique_ptr gfx; /* expanded road graphics */ + using draw_func = void (*)(struct road_info *info, bitmap_ind16 &bitmap, const rectangle &cliprect, int priority); + + u8 index = 0; // index of this structure + u8 type = 0; // type of road system (see segaic16.h for details) + u8 control = 0; // control register value + u16 colorbase1 = 0; // color base for road ROM data + u16 colorbase2 = 0; // color base for road background data + u16 colorbase3 = 0; // color base for sky data + s32 xoffs = 0; // X scroll offset + draw_func draw = nullptr; + u16 * roadram = nullptr; // pointer to roadram pointer + std::unique_ptr buffer; // buffered roadram pointer + std::unique_ptr gfx; // expanded road graphics }; diff --git a/src/mame/shared/vboysound.cpp b/src/mame/shared/vboysound.cpp index aad7975c851..a4c39921dcf 100644 --- a/src/mame/shared/vboysound.cpp +++ b/src/mame/shared/vboysound.cpp @@ -221,8 +221,8 @@ void vboysnd_device::device_start() for (int i=0; i<8; i++) waveEnv2LenTbl[i] = (i + 1) * 4 * 120; - for (int i = 0; i < 5; i++) - memset(&snd_channel[i], 0, sizeof(s_snd_channel)); + for (auto &chan : snd_channel) + chan = s_snd_channel(); memset(m_aram, 0, 0x600); } diff --git a/src/mame/shared/vboysound.h b/src/mame/shared/vboysound.h index 54ec887b172..6cd1d80879d 100644 --- a/src/mame/shared/vboysound.h +++ b/src/mame/shared/vboysound.h @@ -33,21 +33,21 @@ protected: static constexpr unsigned CHANNELS = 4; struct s_snd_channel { - int8_t playing = 0; // the sound is playing + int8_t playing = 0; // the sound is playing // state when sound was enabled - uint32_t env_steptime = 0; // Envelope step time - uint8_t env0 = 0; // Envelope data - uint8_t env1 = 0; // Envelope data - uint8_t volLeft = 0; // Left output volume - uint8_t volRight = 0; // Right output volume - uint8_t sample[580]{}; // sample to play + uint32_t env_steptime = 0; // Envelope step time + uint8_t env0 = 0; // Envelope data + uint8_t env1 = 0; // Envelope data + uint8_t volLeft = 0; // Left output volume + uint8_t volRight = 0; // Right output volume + uint8_t sample[580]{}; // sample to play int sample_len = 0; // length of sample // values that change, as the sample is played int offset = 0; // current offset in sample int time = 0; // the duration that this sample is to be played - uint8_t envelope = 0; // Current envelope level (604) + uint8_t envelope = 0; // Current envelope level (604) int env_time = 0; // The duration between envelope decay/grow (608) }; diff --git a/src/mame/svision/svis_snd.cpp b/src/mame/svision/svis_snd.cpp index 6b9645d6a36..8a89e4e1880 100644 --- a/src/mame/svision/svis_snd.cpp +++ b/src/mame/svision/svis_snd.cpp @@ -9,6 +9,8 @@ #include "emu.h" #include "svis_snd.h" +#include + // configurable logging #define LOG_DMA (1U << 1) #define LOG_NOISE (1U << 2) @@ -50,9 +52,9 @@ svision_sound_device::svision_sound_device(const machine_config &mconfig, const void svision_sound_device::device_start() { - memset(&m_dma, 0, sizeof(m_dma)); - memset(&m_noise, 0, sizeof(m_noise)); - memset(m_channel, 0, sizeof(m_channel)); + m_dma = DMA(); + m_noise = NOISE(); + std::fill(std::begin(m_channel), std::end(m_channel), CHANNEL()); m_mixer_channel = stream_alloc(0, 2, machine().sample_rate()); diff --git a/src/mame/tatsumi/tx1.h b/src/mame/tatsumi/tx1.h index 2e28d5579db..669b7c2648b 100644 --- a/src/mame/tatsumi/tx1.h +++ b/src/mame/tatsumi/tx1.h @@ -71,16 +71,16 @@ protected: private: struct math_t { - uint16_t cpulatch; - uint16_t promaddr; - uint16_t inslatch; - uint32_t mux; - uint16_t ppshift; - uint32_t i0ff; - uint16_t retval; - uint16_t muxlatch; // TX-1 - int dbgaddr; - int dbgpc = 0; + uint16_t cpulatch = 0; + uint16_t promaddr = 0; + uint16_t inslatch = 0; + uint32_t mux = 0; + uint16_t ppshift = 0; + uint32_t i0ff = 0; + uint16_t retval = 0; + uint16_t muxlatch = 0; // TX-1 + int dbgaddr = 0; + int dbgpc = 0; uint16_t get_datarom_addr() const; uint16_t get_bb_datarom_addr() const; diff --git a/src/mame/tatsumi/tx1_m.cpp b/src/mame/tatsumi/tx1_m.cpp index 5856ceb0a9a..33f562a653c 100644 --- a/src/mame/tatsumi/tx1_m.cpp +++ b/src/mame/tatsumi/tx1_m.cpp @@ -1339,7 +1339,7 @@ void tx1_state::machine_reset() // TODO: This is connected to the /BUSACK line of the Z80 m_maincpu->set_input_line(INPUT_LINE_TEST, ASSERT_LINE); - memset(&m_math, 0, sizeof(m_math)); + m_math = math_t(); m_sn74s516.state = 0; } diff --git a/src/mame/ussr/dvk_kcgd.cpp b/src/mame/ussr/dvk_kcgd.cpp index 7fe0f1c37c8..19df0c2bf28 100644 --- a/src/mame/ussr/dvk_kcgd.cpp +++ b/src/mame/ussr/dvk_kcgd.cpp @@ -199,7 +199,7 @@ TIMER_CALLBACK_MEMBER(kcgd_state::toggle_500hz) void kcgd_state::machine_reset() { - memset(&m_video, 0, sizeof(m_video)); + m_video = decltype(m_video)(); } void kcgd_state::machine_start() diff --git a/src/mame/ussr/dvk_ksm.cpp b/src/mame/ussr/dvk_ksm.cpp index 51cd6b887a1..0ed025bee79 100644 --- a/src/mame/ussr/dvk_ksm.cpp +++ b/src/mame/ussr/dvk_ksm.cpp @@ -226,7 +226,7 @@ TIMER_CALLBACK_MEMBER(ksm_state::clock_brg) void ksm_state::machine_reset() { - memset(&m_video, 0, sizeof(m_video)); + m_video = decltype(m_video)(); brga = 0; brgb = 0; brgc = 0; diff --git a/src/mame/ussr/sm7238.cpp b/src/mame/ussr/sm7238.cpp index 02fb11faad3..3f0143668df 100644 --- a/src/mame/ussr/sm7238.cpp +++ b/src/mame/ussr/sm7238.cpp @@ -154,7 +154,7 @@ void sm7238_state::sm7238_io(address_map &map) void sm7238_state::machine_reset() { - memset(&m_video, 0, sizeof(m_video)); + m_video = decltype(m_video)(); m_videobank->set_bank(0); } diff --git a/src/mame/ussr/tiamc1_a.cpp b/src/mame/ussr/tiamc1_a.cpp index f0829c07f94..a6c25479ab3 100644 --- a/src/mame/ussr/tiamc1_a.cpp +++ b/src/mame/ussr/tiamc1_a.cpp @@ -74,8 +74,8 @@ void tiamc1_sound_device::device_start() { int i, j; - timer8253_reset(&m_timer0); - timer8253_reset(&m_timer1); + m_timer0 = timer8253struct(); + m_timer1 = timer8253struct(); m_channel = stream_alloc(0, 1, clock() / CLOCK_DIVIDER); @@ -147,12 +147,6 @@ void tiamc1_sound_device::sound_stream_update(sound_stream &stream, std::vector< } -void tiamc1_sound_device::timer8253_reset(struct timer8253struct *t) -{ - memset(t,0,sizeof(struct timer8253struct)); -} - - void tiamc1_sound_device::timer8253_tick(struct timer8253struct *t, int chn) { if (t->channel[chn].enable && t->channel[chn].gate) diff --git a/src/mame/ussr/tiamc1_a.h b/src/mame/ussr/tiamc1_a.h index fe59bef6591..d2961a7b5dd 100644 --- a/src/mame/ussr/tiamc1_a.h +++ b/src/mame/ussr/tiamc1_a.h @@ -49,7 +49,6 @@ private: }; - void timer8253_reset(struct timer8253struct *t); void timer8253_tick(struct timer8253struct *t,int chn); void timer8253_wr(struct timer8253struct *t, int reg, uint8_t val); char timer8253_get_output(struct timer8253struct *t, int chn);