summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author hap <happppp@users.noreply.github.com>2023-08-30 19:52:07 +0200
committer hap <happppp@users.noreply.github.com>2023-08-30 19:52:17 +0200
commitf6ff2217e145d9277491c8d751d15a90b5d63c87 (patch)
tree20c03eced92abdd3ced1a3b4e16e1dfe107183cc
parentbbaa41135ff740b555b461379f13343300c9722b (diff)
system1: do cycle adjust with modulo instead of float,
cking_master: move init function
-rw-r--r--src/mame/chess/cking_master.cpp38
-rw-r--r--src/mame/chess/compuchess.cpp6
-rw-r--r--src/mame/sega/system1.cpp25
-rw-r--r--src/mame/sega/system1.h4
4 files changed, 41 insertions, 32 deletions
diff --git a/src/mame/chess/cking_master.cpp b/src/mame/chess/cking_master.cpp
index 1a40def69c5..20e1040833f 100644
--- a/src/mame/chess/cking_master.cpp
+++ b/src/mame/chess/cking_master.cpp
@@ -74,6 +74,28 @@ private:
u16 m_inp_mux = 0;
};
+
+
+/*******************************************************************************
+ Initialization
+*******************************************************************************/
+
+void master_state::init_master()
+{
+ u8 *rom = memregion("maincpu")->base();
+ const u32 len = memregion("maincpu")->bytes();
+
+ // descramble data lines
+ for (int i = 0; i < len; i++)
+ rom[i] = bitswap<8>(rom[i], 4,5,0,7,6,1,3,2);
+
+ // descramble address lines
+ std::vector<u8> buf(len);
+ memcpy(&buf[0], rom, len);
+ for (int i = 0; i < len; i++)
+ rom[i] = buf[bitswap<16>(i, 15,14,13,12,11,3,7,9, 10,8,6,5,4,2,1,0)];
+}
+
void master_state::machine_start()
{
// register for savestates
@@ -116,22 +138,6 @@ u8 master_state::input_r()
return ~data;
}
-void master_state::init_master()
-{
- u8 *rom = memregion("maincpu")->base();
- const u32 len = memregion("maincpu")->bytes();
-
- // descramble data lines
- for (int i = 0; i < len; i++)
- rom[i] = bitswap<8>(rom[i], 4,5,0,7,6,1,3,2);
-
- // descramble address lines
- std::vector<u8> buf(len);
- memcpy(&buf[0], rom, len);
- for (int i = 0; i < len; i++)
- rom[i] = buf[bitswap<16>(i, 15,14,13,12,11,3,7,9, 10,8,6,5,4,2,1,0)];
-}
-
/*******************************************************************************
diff --git a/src/mame/chess/compuchess.cpp b/src/mame/chess/compuchess.cpp
index d7b21d97b37..63668fd9a31 100644
--- a/src/mame/chess/compuchess.cpp
+++ b/src/mame/chess/compuchess.cpp
@@ -180,6 +180,12 @@ private:
bool m_blink = false;
};
+
+
+/*******************************************************************************
+ Initialization
+*******************************************************************************/
+
void cmpchess_state::machine_start()
{
// register for savestates
diff --git a/src/mame/sega/system1.cpp b/src/mame/sega/system1.cpp
index 7ba1693538d..9af62730962 100644
--- a/src/mame/sega/system1.cpp
+++ b/src/mame/sega/system1.cpp
@@ -340,7 +340,7 @@ void system1_state::machine_start()
}
save_item(NAME(m_dakkochn_mux_data));
- save_item(NAME(m_cycle_adjust));
+ save_item(NAME(m_adjust_cycles));
save_item(NAME(m_videomode_prev));
save_item(NAME(m_mcu_control));
save_item(NAME(m_nob_maincpu_latch));
@@ -375,18 +375,15 @@ void system1_state::machine_reset()
is 10, which means the 20MHz clock is divided by 6. When /M1 is high, the reload
count is 11, which means the clock is divided by 5.
- Since /M1 is low for 2 cycles during opcode fetch, this makes every opcode fetch
- take an extra 2 20MHz clocks, which is 0.4 cycles at 4MHz.
+ Since /M1 is low for 2 cycles during opcode fetch, this makes every opcode fetch
+ take an extra 2 20MHz clocks, which is 2/5th cycles at 4MHz.
*/
-void system1_state::refresh_cb(u8 data)
+void system1_state::adjust_cycles(u8 data)
{
- m_cycle_adjust += 0.4;
- if (m_cycle_adjust >= 1.0)
- {
- m_cycle_adjust -= 1.0;
+ m_adjust_cycles = (m_adjust_cycles + 2) % 5;
+ if (m_adjust_cycles <= 1)
m_maincpu->adjust_icount(-1);
- }
}
@@ -2174,7 +2171,7 @@ void system1_state::sys1ppi(machine_config &config)
m_maincpu->set_addrmap(AS_PROGRAM, &system1_state::system1_map);
m_maincpu->set_addrmap(AS_IO, &system1_state::system1_ppi_io_map);
m_maincpu->set_vblank_int("screen", FUNC(system1_state::irq0_line_hold));
- m_maincpu->refresh_cb().set(FUNC(system1_state::refresh_cb));
+ m_maincpu->refresh_cb().set(FUNC(system1_state::adjust_cycles));
Z80(config, m_soundcpu, SOUND_CLOCK/2);
m_soundcpu->set_addrmap(AS_PROGRAM, &system1_state::sound_map);
@@ -2193,7 +2190,7 @@ void system1_state::sys1ppi(machine_config &config)
/* video hardware */
SCREEN(config, m_screen, SCREEN_TYPE_RASTER);
- m_screen->set_video_attributes(VIDEO_ALWAYS_UPDATE); /* needed for proper hardware collisions */
+ m_screen->set_video_attributes(VIDEO_ALWAYS_UPDATE); /* needed for proper hardware collisions */
m_screen->set_raw(MASTER_CLOCK/2, 640, 0, 512, 260, 0, 224);
m_screen->set_screen_update(FUNC(system1_state::screen_update_system1));
m_screen->set_palette(m_palette);
@@ -2242,7 +2239,7 @@ void system1_state::encrypted_sys1ppi_maps(machine_config &config)
m_maincpu->set_addrmap(AS_OPCODES, &system1_state::decrypted_opcodes_map);
m_maincpu->set_addrmap(AS_IO, &system1_state::system1_ppi_io_map);
m_maincpu->set_vblank_int("screen", FUNC(system1_state::irq0_line_hold));
- m_maincpu->refresh_cb().set(FUNC(system1_state::refresh_cb));
+ m_maincpu->refresh_cb().set(FUNC(system1_state::adjust_cycles));
}
void system1_state::encrypted_sys1pio_maps(machine_config &config)
@@ -2251,7 +2248,7 @@ void system1_state::encrypted_sys1pio_maps(machine_config &config)
m_maincpu->set_addrmap(AS_OPCODES, &system1_state::decrypted_opcodes_map);
m_maincpu->set_addrmap(AS_IO, &system1_state::system1_pio_io_map);
m_maincpu->set_vblank_int("screen", FUNC(system1_state::irq0_line_hold));
- m_maincpu->refresh_cb().set(FUNC(system1_state::refresh_cb));
+ m_maincpu->refresh_cb().set(FUNC(system1_state::adjust_cycles));
}
void system1_state::encrypted_sys2_mc8123_maps(machine_config &config)
@@ -2260,7 +2257,7 @@ void system1_state::encrypted_sys2_mc8123_maps(machine_config &config)
m_maincpu->set_addrmap(AS_OPCODES, &system1_state::banked_decrypted_opcodes_map);
m_maincpu->set_addrmap(AS_IO, &system1_state::system1_ppi_io_map);
m_maincpu->set_vblank_int("screen", FUNC(system1_state::irq0_line_hold));
- m_maincpu->refresh_cb().set(FUNC(system1_state::refresh_cb));
+ m_maincpu->refresh_cb().set(FUNC(system1_state::adjust_cycles));
}
void system1_state::sys1pioxb(machine_config &config)
diff --git a/src/mame/sega/system1.h b/src/mame/sega/system1.h
index 304eb1ca060..cc21c621bae 100644
--- a/src/mame/sega/system1.h
+++ b/src/mame/sega/system1.h
@@ -137,7 +137,7 @@ private:
u8 m_tilemap_pages = 0;
// protection, miscs
- float m_cycle_adjust = 0.0;
+ u8 m_adjust_cycles = 0;
u8 m_mute_xor = 0;
u8 m_dakkochn_mux_data = 0;
u8 m_mcu_control = 0;
@@ -166,7 +166,7 @@ private:
void sound_control_w(u8 data);
// misc handlers
- void refresh_cb(u8 data);
+ void adjust_cycles(u8 data);
void mcu_control_w(u8 data);
u8 mcu_io_r(offs_t offset);
void mcu_io_w(offs_t offset, u8 data);