Skip to content

Commit 70325b7

Browse files
authored
sinclair/sprinter.cpp: Detect Game Configuration bitstream with checksum (#12908)
1 parent 65b35b0 commit 70325b7

File tree

1 file changed

+34
-15
lines changed

1 file changed

+34
-15
lines changed

src/mame/sinclair/sprinter.cpp

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Sprinter Sp2000 (Peters Plus Ltd)
2929
- ISA memory slots
3030
- fully untied from Spectrum parent
3131
- better rendering (currently not fully discovered) in Game Configuration
32-
- ? detect loading Configuration by checksum, not by presents in fastram
3332
3433
*******************************************************************************************/
3534

@@ -248,6 +247,8 @@ class sprinter_state : public spectrum_128_state
248247
u8 m_conf;
249248
bool m_conf_loading;
250249
bool m_starting;
250+
u16 m_bitstream_count;
251+
u32 m_bitstream_hash;
251252
bool m_dos; // 0-on, 1-off
252253
bool m_cash_on;
253254

@@ -753,13 +754,9 @@ void sprinter_state::dcp_w(offs_t offset, u8 data)
753754
update_video(dcpp & 1);
754755
break;
755756
case 0x2e:
756-
if (m_conf)
757-
machine().schedule_hard_reset();
758-
else
759-
{
760-
m_conf_loading = 1;
761-
machine().schedule_soft_reset();
762-
}
757+
m_conf = 0;
758+
m_conf_loading = 1;
759+
machine().schedule_soft_reset();
763760
break;
764761

765762
case 0x88:
@@ -779,7 +776,17 @@ void sprinter_state::dcp_w(offs_t offset, u8 data)
779776
m_cbl_wa = 0;
780777
m_cbl_wae = cbl_mode16();
781778
const u8 divs[16] = {13, 9, 0, 0, 0, 0, 0, 0, 27, 19, 13, 9, 6, 4, 3, 1};
782-
const attotime rate = (cbl_mode() && divs[m_cbl_xx & 15]) ? attotime::from_ticks(divs[m_cbl_xx & 15] + 1, X_SP / 192) : attotime::never;
779+
attotime rate;
780+
if (cbl_mode() && divs[m_cbl_xx & 15])
781+
{
782+
rate = attotime::from_ticks(divs[m_cbl_xx & 15] + 1, X_SP / 192);
783+
}
784+
else
785+
{
786+
rate = attotime::never;
787+
if (m_hold_irq)
788+
m_irq_off_timer->adjust(attotime::zero);
789+
}
783790
m_cbl_timer->adjust(rate, 0, rate);
784791
break;
785792
}
@@ -1110,15 +1117,23 @@ u8 sprinter_state::bootstrap_r(offs_t offset)
11101117

11111118
void sprinter_state::bootstrap_w(offs_t offset, u8 data)
11121119
{
1113-
if (m_conf_loading)
1120+
if (!m_conf_loading)
11141121
{
1115-
m_conf_loading = 0;
1116-
m_conf = !(m_maincpu->csbr_r() & 0x0f); // cs0 disabled => loader reads config from fastram (which is Game Config)
1117-
m_ram_pages[0x2e] = m_conf ? 0x41 : 0x00;
1118-
machine().schedule_soft_reset();
1122+
m_program.write_byte(0x10000 | u16(offset), data);
11191123
}
11201124
else
1121-
m_program.write_byte(0x10000 | u16(offset), data);
1125+
{
1126+
m_fastram[offset & 0xffff] = data;
1127+
m_bitstream_hash += data << (8 * (m_bitstream_count % 4));
1128+
if (++m_bitstream_count > 0xfff)
1129+
{
1130+
m_conf_loading = 0;
1131+
m_conf = !(m_maincpu->csbr_r() & 0x0f); // cs0 disabled => loader reads config from fastram
1132+
m_conf &= m_bitstream_hash == 0x3861cfa4; // Game Config
1133+
m_ram_pages[0x2e] = m_conf ? 0x41 : 0x00;
1134+
machine().schedule_soft_reset();
1135+
}
1136+
}
11221137
}
11231138

11241139
u8 sprinter_state::ram_r(offs_t offset)
@@ -1397,6 +1412,8 @@ void sprinter_state::machine_start()
13971412
save_item(NAME(m_joy2_ctrl));
13981413
save_item(NAME(m_conf));
13991414
save_item(NAME(m_conf_loading));
1415+
save_item(NAME(m_bitstream_count));
1416+
save_item(NAME(m_bitstream_hash));
14001417
save_item(NAME(m_starting));
14011418
save_item(NAME(m_dos));
14021419
save_item(NAME(m_cash_on));
@@ -1506,6 +1523,8 @@ void sprinter_state::machine_reset()
15061523

15071524
if (m_conf_loading)
15081525
{
1526+
m_bitstream_count = 0;
1527+
m_bitstream_hash = 0;
15091528
m_bank_rom[0]->set_entry(0x0c);
15101529
m_bank_view0.select(1);
15111530
m_bank_view3.disable();

0 commit comments

Comments
 (0)