diff --git a/src/emu/machine/spchrom.c b/src/emu/machine/spchrom.c index 22883a2ed2e..2d37d3fb8ec 100644 --- a/src/emu/machine/spchrom.c +++ b/src/emu/machine/spchrom.c @@ -27,16 +27,25 @@ speechrom_device::speechrom_device(const machine_config &mconfig, const char *ta : device_t(mconfig, SPEECHROM, "SPEECHROM", tag, owner, clock, "speechrom", __FILE__), m_speechROMaddr(0), m_load_pointer(0), - m_ROM_bits_count(0) + m_ROM_bits_count(0), + m_reverse(false) { } /* Read 'count' bits serially from speech ROM + + Actually, the ROM is expected to have reversed bit order, but there are + many dumps with normal bit order. + + compatibility mode: 01234567 01234567 01234567 ... + correct mode: 76543210 76543210 76543210 ... */ int speechrom_device::read(int count) { int val; + int spchbyte; + int pos; if (m_load_pointer) { /* first read after load address is ignored */ @@ -45,26 +54,35 @@ int speechrom_device::read(int count) } if (m_speechROMaddr < m_speechROMlen) - if (count < m_ROM_bits_count) - { - m_ROM_bits_count -= count; - val = (m_speechrom_data[m_speechROMaddr] >> m_ROM_bits_count) & (0xFF >> (8 - count)); - } - else - { - val = ((int) m_speechrom_data[m_speechROMaddr]) << 8; - - m_speechROMaddr = (m_speechROMaddr + 1) & TMS5220_ADDRESS_MASK; - - if (m_speechROMaddr < m_speechROMlen) - val |= m_speechrom_data[m_speechROMaddr]; - - m_ROM_bits_count += 8 - count; - - val = (val >> m_ROM_bits_count) & (0xFF >> (8 - count)); - } - else + { val = 0; + pos = 8 - m_ROM_bits_count; + + spchbyte = (m_reverse? (m_speechrom_data[m_speechROMaddr] >> pos) : (m_speechrom_data[m_speechROMaddr] << pos)) & 0xff; + + while (count > 0) + { + val = val << 1; + if ((spchbyte & (m_reverse? 0x01:0x80))!=0) val |= 1; + spchbyte = m_reverse? (spchbyte >> 1) : (spchbyte << 1); + count--; + if (pos == 7) + { + pos = 0; + m_speechROMaddr = (m_speechROMaddr + 1) & TMS5220_ADDRESS_MASK; + if (m_speechROMaddr >= m_speechROMlen) + count = 0; + else + spchbyte = m_speechrom_data[m_speechROMaddr]; + } + else pos++; + } + m_ROM_bits_count = 8 - pos; + } + else + { + val = 0; + } return val; } diff --git a/src/emu/machine/spchrom.h b/src/emu/machine/spchrom.h index 623142f5dfc..8dba6eaa3db 100644 --- a/src/emu/machine/spchrom.h +++ b/src/emu/machine/spchrom.h @@ -18,6 +18,7 @@ public: int read(int count); void load_address(int data); void read_and_branch(); + void set_reverse_bit_order(bool reverse) { m_reverse = reverse; } // device-level overrides virtual void device_start(); @@ -28,6 +29,7 @@ private: unsigned int m_speechROMaddr; /* 18 bit pointer in ROM */ int m_load_pointer; /* which 4-bit nibble will be affected by load address */ int m_ROM_bits_count; /* current bit position in ROM */ + bool m_reverse; }; diff --git a/src/mess/drivers/ti99_8.c b/src/mess/drivers/ti99_8.c index 960235458c1..372d2b45326 100644 --- a/src/mess/drivers/ti99_8.c +++ b/src/mess/drivers/ti99_8.c @@ -1139,11 +1139,6 @@ ROM_START(ti99_8) ROM_REGION(0x8000, ROM1_TAG, 0) ROM_LOAD("u25_rom1.bin", 0x0000, 0x8000, CRC(b574461a) SHA1(42c6aed44802cfabdd26b565d6e5ddfcd689f11e)) - // Speech ROMs - ROM_REGION(0x8000, SPEECH_TAG, 0) - ROM_LOAD("cd2325a.vsm", 0x0000, 0x4000, CRC(1f58b571) SHA1(0ef4f178716b575a1c0c970c56af8a8d97561ffe)) - ROM_LOAD("cd2326a.vsm", 0x4000, 0x4000, CRC(65d00401) SHA1(a367242c2c96cebf0e2bf21862f3f6734b2b3020)) - // System GROMs. 3 chips @ f830 // The schematics do not enumerate the circuits but only talk about // "circuits on board" (COB) so we name the GROMs as gM_N.bin where M is the diff --git a/src/mess/machine/ti99/speech8.c b/src/mess/machine/ti99/speech8.c index 69956f35f81..b117827c638 100644 --- a/src/mess/machine/ti99/speech8.c +++ b/src/mess/machine/ti99/speech8.c @@ -118,6 +118,8 @@ void ti998_spsyn_device::device_start() const speech8_config *conf = reinterpret_cast(static_config()); m_ready.resolve(conf->ready, *this); m_vsp = subdevice(SPEECHSYN_TAG); + speechrom_device* mem = subdevice("vsm"); + mem->set_reverse_bit_order(true); } void ti998_spsyn_device::device_reset() @@ -142,11 +144,8 @@ MACHINE_CONFIG_END as the TI speech synthesizer. */ ROM_START( ti998_speech ) ROM_REGION(0x8000, "vsm", 0) - // Note: the following line is actually wrong; the speech roms in the ti 99/4a and 99/8 are two VSM roms labeled CD2325A and CD2326A, and contain the same data as the following line rom does, but with the byte bit order reversed. This bit ordering issue needs to be fixed elsewhere in the code here before the original/real roms can be used. - ROM_LOAD_OPTIONAL("spchrom.bin", 0x0000, 0x8000, CRC(58b155f7) SHA1(382292295c00dff348d7e17c5ce4da12a1d87763)) /* system speech ROM */ - // correct lines are: - // ROM_LOAD_OPTIONAL("cd2325a.vsm", 0x0000, 0x4000, CRC(1f58b571) SHA1(0ef4f178716b575a1c0c970c56af8a8d97561ffe)) - // ROM_LOAD_OPTIONAL("cd2326a.vsm", 0x4000, 0x4000, CRC(65d00401) SHA1(a367242c2c96cebf0e2bf21862f3f6734b2b3020)) + ROM_LOAD("cd2325a.vsm", 0x0000, 0x4000, CRC(1f58b571) SHA1(0ef4f178716b575a1c0c970c56af8a8d97561ffe)) + ROM_LOAD("cd2326a.vsm", 0x4000, 0x4000, CRC(65d00401) SHA1(a367242c2c96cebf0e2bf21862f3f6734b2b3020)) ROM_END machine_config_constructor ti998_spsyn_device::device_mconfig_additions() const