From be62159ab843f07daf385c00b7bf1d942c695172 Mon Sep 17 00:00:00 2001 From: hap Date: Sat, 1 Mar 2025 19:12:42 +0100 Subject: [PATCH] mystwarr: small cleanup --- src/mame/konami/mystwarr.cpp | 58 ++++++++----------- src/mame/konami/mystwarr_v.cpp | 102 +++++++++++++++++---------------- src/mame/saitek/gk2000.cpp | 1 + 3 files changed, 77 insertions(+), 84 deletions(-) diff --git a/src/mame/konami/mystwarr.cpp b/src/mame/konami/mystwarr.cpp index 604ed5dfd1f..2445cbca91f 100644 --- a/src/mame/konami/mystwarr.cpp +++ b/src/mame/konami/mystwarr.cpp @@ -143,6 +143,7 @@ we have no way of knowing which is the later/corrected version. #include "machine/eepromser.h" #include "sound/k054539.h" #include "sound/okim6295.h" + #include "speaker.h" @@ -154,7 +155,7 @@ uint16_t mystwarr_state::eeprom_r(offs_t offset, uint16_t mem_mask) return ioport("IN1")->read(); } -// logerror("msb access to eeprom port\n"); + //logerror("msb access to eeprom port\n"); return 0; } @@ -166,8 +167,7 @@ void mystwarr_state::mweeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask) ioport("EEPROMOUT")->write(data, 0xffff); } -// logerror("unknown LSB write %x to eeprom\n", data); - + //logerror("unknown LSB write %x to eeprom\n", data); } uint16_t mystwarr_state::dddeeprom_r(offs_t offset, uint16_t mem_mask) @@ -198,14 +198,14 @@ TIMER_DEVICE_CALLBACK_MEMBER(mystwarr_state::mystwarr_interrupt) if (!(m_mw_irq_control & 0x01)) return; - if(scanline == 240) + if (scanline == 240) m_maincpu->set_input_line(M68K_IRQ_2, HOLD_LINE); - if(scanline == 0) + if (scanline == 0) m_maincpu->set_input_line(M68K_IRQ_4, HOLD_LINE); /* writes to LSB of 0x410000 port and clears a work RAM flag, almost likely not really necessary. */ -// m_maincpu->set_input_line(M68K_IRQ_6, HOLD_LINE); + //m_maincpu->set_input_line(M68K_IRQ_6, HOLD_LINE); } TIMER_DEVICE_CALLBACK_MEMBER(mystwarr_state::metamrph_interrupt) @@ -213,12 +213,12 @@ TIMER_DEVICE_CALLBACK_MEMBER(mystwarr_state::metamrph_interrupt) int scanline = param; /* irq 4 has an irq routine in metamrph, but it's not really called */ -// m_maincpu->set_input_line(M68K_IRQ_4, HOLD_LINE); + //m_maincpu->set_input_line(M68K_IRQ_4, HOLD_LINE); - if(scanline == 24) + if (scanline == 24) m_maincpu->set_input_line(M68K_IRQ_6, HOLD_LINE); - if(scanline == 248) + if (scanline == 248) if (m_k055673->k053246_is_irq_enabled()) m_maincpu->set_input_line(M68K_IRQ_5, HOLD_LINE); } @@ -228,12 +228,12 @@ TIMER_DEVICE_CALLBACK_MEMBER(mystwarr_state::mchamp_interrupt) if (!(m_mw_irq_control & 0x40)) return; - if(scanline == 247) + if (scanline == 247) { if (m_k055673->k053246_is_irq_enabled()) m_maincpu->set_input_line(M68K_IRQ_6, HOLD_LINE); } - if(scanline == 23) + if (scanline == 23) m_maincpu->set_input_line(M68K_IRQ_2, HOLD_LINE); } @@ -256,10 +256,9 @@ void mystwarr_state::irq_ack_w(offs_t offset, uint16_t data, uint16_t mem_mask) if (offset == 3 && ACCESSING_BITS_0_7) { - m_mw_irq_control = data&0xff; - -// if ((data &0xf0) != 0xd0) logerror("Unknown write to IRQ reg: %x\n", data); + m_mw_irq_control = data & 0xff; + //if ((data &0xf0) != 0xd0) logerror("Unknown write to IRQ reg: %x\n", data); } } @@ -280,7 +279,7 @@ void mystwarr_state::k053247_scattered_word_w(offs_t offset, uint16_t data, uint { if (offset & 0x0078) { -// osd_printf_debug("spr write %x to %x (PC=%x)\n", data, offset, m_maincpu->pc()); + //osd_printf_debug("spr write %x to %x (PC=%x)\n", data, offset, m_maincpu->pc()); COMBINE_DATA(&m_spriteram[offset]); } else @@ -440,7 +439,6 @@ void mystwarr_state::k053247_martchmp_word_w(offs_t offset, uint16_t data, uint1 else { offset = (offset & 0x0007) | ((offset & 0x1fe0) >> 2); - m_k055673->k053247_word_w(offset,data,mem_mask); } } @@ -461,7 +459,7 @@ void mystwarr_state::mccontrol_w(offs_t offset, uint16_t data, uint16_t mem_mask m_k055673->k053246_set_objcha_line((data&0x04) ? ASSERT_LINE : CLEAR_LINE); } -// else logerror("write %x to LSB of mccontrol\n", data); + //else logerror("write %x to LSB of mccontrol\n", data); } void mystwarr_state::mceeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask) @@ -478,7 +476,7 @@ void mystwarr_state::mceeprom_w(offs_t offset, uint16_t data, uint16_t mem_mask) // bit 6 VINTEN ioport("EEPROMOUT")->write(data, 0xffff); } - // logerror("unknown LSB write %x to eeprom\n", data); + //logerror("unknown LSB write %x to eeprom\n", data); } /* Martial Champion */ @@ -886,25 +884,21 @@ MACHINE_START_MEMBER(mystwarr_state,mystwarr) MACHINE_RESET_MEMBER(mystwarr_state,mystwarr) { - int i; - // soften chorus(chip 0 channel 0-3), boost voice(chip 0 channel 4-7) - for (i=0; i<=3; i++) + for (int i = 0; i <= 3; i++) { m_k054539_1->set_gain(i, 0.8); m_k054539_1->set_gain(i+4, 2.0); } // soften percussions(chip 1 channel 0-7) - for (i=0; i<=7; i++) m_k054539_2->set_gain(i, 0.5); + for (int i = 0; i <= 7; i++) m_k054539_2->set_gain(i, 0.5); } MACHINE_RESET_MEMBER(mystwarr_state,dadandrn) { - int i; - // boost voice(chip 0 channel 4-7) - for (i=4; i<=7; i++) m_k054539_1->set_gain(i, 2.0); + for (int i = 4; i <= 7; i++) m_k054539_1->set_gain(i, 2.0); } MACHINE_START_MEMBER(mystwarr_state,viostormbl) @@ -922,15 +916,13 @@ MACHINE_START_MEMBER(mystwarr_state,viostormbl) MACHINE_RESET_MEMBER(mystwarr_state,viostorm) { if (m_k054539_1.found()) - for (int i=4; i<=7; i++) m_k054539_1->set_gain(i, 2.0); // boost voice(chip 0 channel 4-7) + for (int i = 4; i <= 7; i++) m_k054539_1->set_gain(i, 2.0); // boost voice(chip 0 channel 4-7) } MACHINE_RESET_MEMBER(mystwarr_state,metamrph) { - int i; - // boost voice(chip 0 channel 4-7) and soften other channels - for (i=0; i<=3; i++) + for (int i = 0; i <= 3; i++) { m_k054539_1->set_gain(i, 0.8); m_k054539_1->set_gain(i+4, 1.8); @@ -941,18 +933,14 @@ MACHINE_RESET_MEMBER(mystwarr_state,metamrph) MACHINE_RESET_MEMBER(mystwarr_state,martchmp) { - int i; - // boost voice(chip 0 channel 4-7) - for (i=4; i<=7; i++) m_k054539_1->set_gain(i, 1.4); + for (int i = 4; i <= 7; i++) m_k054539_1->set_gain(i, 1.4); } MACHINE_RESET_MEMBER(mystwarr_state,gaiapols) { - int i; - // boost voice(chip 0 channel 5-7) - for (i=5; i<=7; i++) m_k054539_1->set_gain(i, 2.0); + for (int i = 5; i <= 7; i++) m_k054539_1->set_gain(i, 2.0); } diff --git a/src/mame/konami/mystwarr_v.cpp b/src/mame/konami/mystwarr_v.cpp index 8b8c8b9cae1..9fc8b894f93 100644 --- a/src/mame/konami/mystwarr_v.cpp +++ b/src/mame/konami/mystwarr_v.cpp @@ -18,7 +18,7 @@ void mystwarr_state::decode_tiles() { uint8_t *s = memregion("k056832")->base(); int len = memregion("k056832")->bytes(); - uint8_t *pFinish = s+len-3; + uint8_t *pFinish = s + len - 3; uint8_t *d; int gfxnum = m_k056832->get_gfx_num(); @@ -59,7 +59,15 @@ void mystwarr_state::decode_tiles() // Mystic Warriors requires tile based blending. K056832_CB_MEMBER(mystwarr_state::mystwarr_tile_callback) { - if (layer == 1) {if ((*code & 0xff00) + (*color) == 0x4101) m_cbparam++; else m_cbparam--;} //* water hack (TEMPORARY) + if (layer == 1) + { + //* water hack (TEMPORARY) + if ((*code & 0xff00) + (*color) == 0x4101) + m_cbparam++; + else + m_cbparam--; + } + *color = m_layer_colorbase[layer] | (*color >> 1 & 0x1e); } @@ -77,10 +85,10 @@ K056832_CB_MEMBER(mystwarr_state::game4bpp_tile_callback) K055673_CB_MEMBER(mystwarr_state::mystwarr_sprite_callback) { - *priority_mask = *color & 0x00e0; + *priority_mask = *color & 0xe0; - const int effect_attributes = ((*color >> 8) & 0b11) << K055555_MIXSHIFT; // used for blending - *color = m_sprite_colorbase | (*color & 0x001f) | effect_attributes; + const int effect = ((*color >> 8) & 0b11) << K055555_MIXSHIFT; // used for blending + *color = m_sprite_colorbase | (*color & 0x1f) | effect; } K055673_CB_MEMBER(mystwarr_state::metamrph_sprite_callback) @@ -88,16 +96,14 @@ K055673_CB_MEMBER(mystwarr_state::metamrph_sprite_callback) *priority_mask = (*color & 0xe0) >> 2; const int shadow = (*color >> 10) & 0b11; - const int effect_attributes = ((*color >> 8) & 0b11) << K055555_MIXSHIFT; // used for blending - *color = (*color & 0x1f) | m_sprite_colorbase | effect_attributes | ((shadow == 0b11) ? K055555_SKIPSHADOW : 0); + const int effect = ((*color >> 8) & 0b11) << K055555_MIXSHIFT; // used for blending + *color = m_sprite_colorbase | (*color & 0x1f) | effect | ((shadow == 0b11) ? K055555_SKIPSHADOW : 0); } K055673_CB_MEMBER(mystwarr_state::gaiapols_sprite_callback) { - int c = *color; - - *color = m_sprite_colorbase | (c>>4 & 0x20) | (c & 0x001f); - *priority_mask = c & 0x00e0; + *priority_mask = *color & 0xe0; + *color = m_sprite_colorbase | (*color >> 4 & 0x20) | (*color & 0x1f); } K055673_CB_MEMBER(mystwarr_state::martchmp_sprite_callback) @@ -111,7 +117,7 @@ K055673_CB_MEMBER(mystwarr_state::martchmp_sprite_callback) *color = m_sprite_colorbase | (c & 0x1f); if (m_oinprion & 0xf0) - *priority_mask = m_cbparam; // use PCU2 internal priority + *priority_mask = m_cbparam; // use PCU2 internal priority else *priority_mask = c & 0xf0; // use color implied priority } @@ -124,12 +130,12 @@ TILE_GET_INFO_MEMBER(mystwarr_state::get_gai_936_tile_info) uint8_t *ROM = memregion("gfx4")->base(); uint8_t *dat1 = ROM, *dat2 = ROM + 0x20000, *dat3 = ROM + 0x60000; - tileno = dat3[tile_index] | ((dat2[tile_index]&0x3f)<<8); + tileno = dat3[tile_index] | ((dat2[tile_index] & 0x3f) << 8); if (tile_index & 1) - colour = (dat1[tile_index>>1]&0xf); + colour = (dat1[tile_index >> 1] & 0xf); else - colour = ((dat1[tile_index>>1]>>4)&0xf); + colour = ((dat1[tile_index >> 1] >> 4) & 0xf); if (dat2[tile_index] & 0x80) colour |= 0x10; @@ -160,15 +166,13 @@ VIDEO_START_MEMBER(mystwarr_state, gaiapols) TILE_GET_INFO_MEMBER(mystwarr_state::get_ult_936_tile_info) { - int tileno, colour; uint8_t *ROM = memregion("gfx4")->base(); uint8_t *dat1 = ROM, *dat2 = ROM + 0x40000; - tileno = dat2[tile_index] | ((dat1[tile_index]&0x1f)<<8); + int tileno = dat2[tile_index] | ((dat1[tile_index] & 0x1f) << 8); + int colour = m_sub1_colorbase; - colour = m_sub1_colorbase; - - tileinfo.set(0, tileno, colour, (dat1[tile_index]&0x40) ? TILE_FLIPX : 0); + tileinfo.set(0, tileno, colour, (dat1[tile_index] & 0x40) ? TILE_FLIPX : 0); } VIDEO_START_MEMBER(mystwarr_state, dadandrn) @@ -258,18 +262,22 @@ VIDEO_START_MEMBER(mystwarr_state, martchmp) uint32_t mystwarr_state::screen_update_mystwarr(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - int i, old, blendmode=0; + int blendmode = 0; - if (m_cbparam<0) m_cbparam=0; else if (m_cbparam>=32) blendmode=(1<<16|GXMIX_BLEND_FORCE)<<2; //* water hack (TEMPORARY) + //* water hack (TEMPORARY) + if (m_cbparam < 0) + m_cbparam = 0; + else if (m_cbparam >= 32) + blendmode = (1 << 16 | GXMIX_BLEND_FORCE) << 2; - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - old = m_layer_colorbase[i]; - m_layer_colorbase[i] = m_k055555->K055555_get_palette_index(i)<<4; - if( old != m_layer_colorbase[i] ) m_k056832->mark_plane_dirty(i); + int old = m_layer_colorbase[i]; + m_layer_colorbase[i] = m_k055555->K055555_get_palette_index(i) << 4; + if (old != m_layer_colorbase[i]) m_k056832->mark_plane_dirty(i); } - m_sprite_colorbase = m_k055555->K055555_get_palette_index(4)<<5; + m_sprite_colorbase = m_k055555->K055555_get_palette_index(4) << 5; konamigx_mixer(screen, bitmap, cliprect, nullptr, 0, nullptr, 0, blendmode, nullptr, 0); return 0; @@ -277,16 +285,14 @@ uint32_t mystwarr_state::screen_update_mystwarr(screen_device &screen, bitmap_rg uint32_t mystwarr_state::screen_update_metamrph(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - int i, old; - - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - old = m_layer_colorbase[i]; - m_layer_colorbase[i] = m_k055555->K055555_get_palette_index(i)<<4; + int old = m_layer_colorbase[i]; + m_layer_colorbase[i] = m_k055555->K055555_get_palette_index(i) << 4; if (old != m_layer_colorbase[i]) m_k056832->mark_plane_dirty(i); } - m_sprite_colorbase = m_k055555->K055555_get_palette_index(4)<<4; + m_sprite_colorbase = m_k055555->K055555_get_palette_index(4) << 4; konamigx_mixer(screen, bitmap, cliprect, nullptr, GXSUB_K053250 | GXSUB_4BPP, nullptr, 0, 0, nullptr, 0); return 0; @@ -294,12 +300,10 @@ uint32_t mystwarr_state::screen_update_metamrph(screen_device &screen, bitmap_rg uint32_t mystwarr_state::screen_update_martchmp(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - int i, old, blendmode; - - for (i = 0; i < 4; i++) + for (int i = 0; i < 4; i++) { - old = m_layer_colorbase[i]; - m_layer_colorbase[i] = m_k055555->K055555_get_palette_index(i)<<4; + int old = m_layer_colorbase[i]; + m_layer_colorbase[i] = m_k055555->K055555_get_palette_index(i) << 4; if (old != m_layer_colorbase[i]) m_k056832->mark_plane_dirty(i); } @@ -309,7 +313,7 @@ uint32_t mystwarr_state::screen_update_martchmp(screen_device &screen, bitmap_rg m_oinprion = m_k055555->K055555_read_register(K55_OINPRI_ON); // not quite right - blendmode = (m_oinprion==0xef && m_k054338->register_r(K338_REG_PBLEND)) ? ((1<<16|GXMIX_BLEND_FORCE)<<2) : 0; + int blendmode = (m_oinprion == 0xef && m_k054338->register_r(K338_REG_PBLEND)) ? ((1 << 16 | GXMIX_BLEND_FORCE) << 2) : 0; konamigx_mixer(screen, bitmap, cliprect, nullptr, 0, nullptr, 0, blendmode, nullptr, 0); return 0; @@ -322,7 +326,7 @@ void mystwarr_state::ddd_053936_enable_w(offs_t offset, uint16_t data, uint16_t if (ACCESSING_BITS_8_15) { m_roz_enable = data & 0x0100; - m_roz_rombank = (data & 0xc000)>>14; + m_roz_rombank = (data & 0xc000) >> 14; } } @@ -377,7 +381,7 @@ uint16_t mystwarr_state::gai_053936_tilerom_0_r(offs_t offset) uint8_t *ROM2 = (uint8_t *)memregion("gfx4")->base(); ROM1 += 0x20000; - ROM2 += 0x20000+0x40000; + ROM2 += 0x20000 + 0x40000; return ((ROM1[offset]<<8) | ROM2[offset]); } @@ -407,7 +411,7 @@ uint16_t mystwarr_state::gai_053936_tilerom_2_r(offs_t offset) offset += (m_roz_rombank * 0x100000); - return ROM[offset/2]<<8; + return ROM[offset/2] << 8; } uint16_t mystwarr_state::ddd_053936_tilerom_2_r(offs_t offset) @@ -416,7 +420,7 @@ uint16_t mystwarr_state::ddd_053936_tilerom_2_r(offs_t offset) offset += (m_roz_rombank * 0x100000); - return ROM[offset]<<8; + return ROM[offset] << 8; } uint32_t mystwarr_state::screen_update_dadandrn(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)/* and gaiapols */ @@ -425,20 +429,20 @@ uint32_t mystwarr_state::screen_update_dadandrn(screen_device &screen, bitmap_rg if (m_gametype == 0) { - m_sprite_colorbase = (m_k055555->K055555_get_palette_index(4)<<4)&0x7f; + m_sprite_colorbase = (m_k055555->K055555_get_palette_index(4) << 4) & 0x7f; rozmode = GXSUB_4BPP; } else { - m_sprite_colorbase = (m_k055555->K055555_get_palette_index(4)<<3)&0x7f; + m_sprite_colorbase = (m_k055555->K055555_get_palette_index(4) << 3) & 0x7f; rozmode = GXSUB_8BPP; } if (m_k056832->get_layer_association()) { - for (i=0; i<4; i++) + for (i = 0; i < 4; i++) { - newbase = m_k055555->K055555_get_palette_index(i)<<4; + newbase = m_k055555->K055555_get_palette_index(i) << 4; if (m_layer_colorbase[i] != newbase) { m_layer_colorbase[i] = newbase; @@ -448,9 +452,9 @@ uint32_t mystwarr_state::screen_update_dadandrn(screen_device &screen, bitmap_rg } else { - for (dirty=0, i=0; i<4; i++) + for (dirty = 0, i = 0; i < 4; i++) { - newbase = m_k055555->K055555_get_palette_index(i)<<4; + newbase = m_k055555->K055555_get_palette_index(i) << 4; if (m_layer_colorbase[i] != newbase) { m_layer_colorbase[i] = newbase; diff --git a/src/mame/saitek/gk2000.cpp b/src/mame/saitek/gk2000.cpp index b5a5842001e..7a843baa73b 100644 --- a/src/mame/saitek/gk2000.cpp +++ b/src/mame/saitek/gk2000.cpp @@ -45,6 +45,7 @@ Mephisto Explorer: - PCB label: 51CT09-01001L - Hitachi H8/3212 MCU (QFP), 10MHz XTAL, same ROM contents as Barracuda - LCD layout is slightly different, symbols are on the right side +- no board edge LEDs, LCD backlight via P51 H8/323 A13 MCU is used in: - Saitek GK 2000 (1992 version, 86071220X12)