Previous 15994 Revisions Next

r5350 Wednesday 5th August, 2009 at 00:13:18 UTC by Jonathan Gevaryahu
[socrates] hooked up dumped speech rom (may only be 1/4 of the rom) and fixed up speech synth emulation so it passes speech cart self-test and even tries to talk in-game. Actual PARCOR speech synthesis core will come much later, hopefully.
[src/mess/drivers]socrates.c

src/mess/drivers/socrates.c
r5349r5350
9595UINT8 kb_latch_low[2];
9696UINT8 kb_latch_high[2];
9797UINT8 kb_latch_mouse;
98UINT8 io40_latch;
99UINT8 hblankstate;
100UINT8 vblankstate;
101UINT8 speech_running;
102UINT8 speech_selftest;
103UINT32 speech_regs[8];
98UINT8 io40_latch; // what was last written to speech reg (for open bus)?
99UINT8 hblankstate; // are we in hblank?
100UINT8 vblankstate; // are we in vblank?
101UINT8 speech_running; // is speech synth talking?
102UINT32 speech_address; // address in speech space
103UINT8 speech_dummy_read; // have we done a dummy read yet?
104UINT8 speech_load_address_count; // number of times load address has happened
105
104106} socrates={ {0}};
105107
106108static void socrates_set_rom_bank( running_machine *machine )
r5349r5350
181183 socrates.kb_latch_low[1] = 0x00;
182184 socrates.kb_latch_high[1] = 0x01;
183185 socrates.kb_latch_mouse = 0;
184 socrates.io40_latch = 0xf;
186 socrates.io40_latch = 0;
185187 socrates.hblankstate = 0;
186188 socrates.vblankstate = 0;
187189 socrates.speech_running = 0;
188 socrates.speech_selftest = 0; // should be readback
189 socrates.speech_regs[0] = 0;
190 socrates.speech_regs[1] = 0;
191 socrates.speech_regs[2] = 0;
192 socrates.speech_regs[3] = 0;
193 socrates.speech_regs[4] = 0;
194 socrates.speech_regs[5] = 0;
195 socrates.speech_regs[6] = 0;
196 socrates.speech_regs[7] = 0;
190 socrates.speech_address = 0;
191 socrates.speech_dummy_read = 0;
192 socrates.speech_load_address_count = 0;
197193}
198194
199195DRIVER_INIT( socrates )
r5349r5350
240236
241237WRITE8_HANDLER( unknownlatch_30 ) // writes to i/o 0x3x do SOMETHING, possibly waitstate related (may halt cpu until vblank start?)
242238{
243logerror("write to i/o 0x30 of %x\n", data);
239//logerror("write to i/o 0x30, data %x\n", data); // too annoying to leave enabled
244240}
245241
246242READ8_HANDLER( status_and_speech ) // read 0x4x, some sort of status reg
r5349r5350
253249// bit 2 - speech chip bit 2
254250// bit 1 - speech chip bit 1
255251// bit 0 - speech chip bit 0
256#ifdef EMULATE_SPEECH
257   UINT8 selftestpattern[14] = { 0x3, 0x5, 0xa, 0x3, 0x5, 0xf, 0x4, 0x3, 0x4, 0x2, 0x5, 0x1, 0x4, 0x4 };
258#endif
252UINT8 *speechrom = memory_region(space->machine, "speech");
259253   int temp = 0;
260254   temp |= (socrates.speech_running)?0x80:0;
261255   temp |= 0x40; // unknown
262256   temp |= (socrates.vblankstate)?0:0x20;
263257   temp |= (socrates.hblankstate)?0:0x10;
264   switch(socrates.io40_latch&0xF0)
258   switch(socrates.io40_latch&0xF0) // what was last opcode sent?
265259   {
266#ifdef EMULATE_SPEECH
267      case 0x60: // speech status 'read' register
268         temp |= selftestpattern[socrates.speech_selftest>>1];
260      case 0x60: case 0xE0:// speech status 'read' register
261      logerror("reading speech rom nybble from nybble address %x (byte address %x)\n",socrates.speech_address, socrates.speech_address>>1);
262      temp |= ((speechrom[(socrates.speech_address>>1)&0x1fff]>>((socrates.speech_address&1)*4))&0xF);
263         if (socrates.speech_dummy_read == 0) // if we havent done the dummy read yet, do so now
264         {
265            socrates.speech_dummy_read++;
266         }
267         else
268         {
269            socrates.speech_address++;
270         }
269271         break;
270      case 0xE0: // speech status 'read' register w/CPE? line active
271         temp |= selftestpattern[socrates.speech_selftest>>1];
272         break;
273#else
274      case 0x60: case 0xE0:
275      break;
276#endif
277272      default:
278         temp |= socrates.io40_latch&0xF;
273         temp |= socrates.io40_latch&0xF; // read open bus
279274         break;
280275   }
281276   logerror("read from i/o 0x4x of %x\n", temp);
282277   return temp;
283278}
279static TIMER_CALLBACK( clear_speech_cb )
280{
281   socrates.speech_running = 0;
282   socrates.speech_load_address_count = 0; // should this be here or in the write functuon subpart which is speak command?
283}
284284
285285WRITE8_HANDLER( speech_command ) // write 0x4x, some sort of bitfield; speech chip is probably hitachi hd38880 related but not exact, w/4 bit interface
286286{
287   logerror("write to i/o 0x4x of %x\n", data);
287288/*
288289// the high 4 bits of the write control which 'register' is written to, the low 4 bits are data (this is based on a readback test)
289290// 00-0f: readback: 70-7f
r5349r5350
334335   1111
335336*/
336337/* the socrates speech chip does not QUITE match the hd38880 though, but is very similar */
337
338   if (data==0x60) socrates.speech_selftest++;
339   if (socrates.speech_selftest > 14) socrates.speech_selftest = 0;
338   switch(data&0xF0)
339   {
340      case 0x80:
341         if (data==0x80)
342         {
343            /* write me: start talking */
344            socrates.speech_running = 1;
345            timer_set(space->machine, ATTOTIME_IN_SEC(4), NULL, 0, clear_speech_cb); // hack
346         }
347         break;
348      case 0x90: // unknown
349         break;
350      case 0xA0: // unknown
351         break;
352      case 0xB0: // unknown
353         break;
354      case 0xC0: // load address to vsm
355         socrates.speech_address |= (((int)data&0xF)<<(socrates.speech_load_address_count*4))<<1;
356         socrates.speech_load_address_count++;
357         logerror("loaded address nybble %X, byte address is currently %5X with %d nybbles loaded\n", data&0xF, socrates.speech_address>>1, socrates.speech_load_address_count);
358         break;
359      case 0xD0: // load bank or maybe init1 and init2?
360         // write code here
361         break;
362      case 0xE0: // read byte, handled elsewhere
363         break;
364      case 0xF0: // command: sub 0 is speak, sub 8 is reset
365         if ((data&0xF) == 0) // speak
366         {
367            socrates.speech_running = 1;
368            timer_set(space->machine, ATTOTIME_IN_SEC(4), NULL, 0, clear_speech_cb); // hack
369         }
370         else if ((data&0xF) == 8) // reset
371         {
372            socrates.speech_running = 0;
373            socrates.speech_address = 0;
374            socrates.speech_dummy_read = 0;
375            socrates.speech_load_address_count = 0;
376            socrates.io40_latch &= 0x0f; // set last command to 0 to prevent problems
377         }
378         else // other
379         {
380         logerror("speech command 0xF%x is unknown!\n",data&0xF);
381         }
382         break;
383      default: // 00 thru 70 are packets without the write bit set, ignore them
384         break;
385   }
340386   socrates.io40_latch = data;
341   logerror("write to i/o 0x4x of %x\n", data);
342387}
343388
344389READ8_HANDLER( socrates_keyboard_low_r ) // keyboard code low
r5349r5350
363408   socrates.kb_latch_high[1] = 1;
364409}
365410
366WRITE8_HANDLER( reset_speech ) // reset speech synth
411WRITE8_HANDLER( reset_speech ) // i/o 60: reset speech synth
367412{
368socrates.speech_selftest = 0;
369socrates.speech_regs[0] = 0;
370socrates.speech_regs[1] = 0;
371socrates.speech_regs[2] = 0;
372socrates.speech_regs[3] = 0;
373socrates.speech_regs[4] = 0;
374socrates.speech_regs[5] = 0;
375socrates.speech_regs[6] = 0;
376socrates.speech_regs[7] = 0;
413 socrates.speech_running = 0;
414 socrates.speech_address = 0;
415 socrates.speech_dummy_read = 0;
416 socrates.speech_load_address_count = 0;
417 socrates.io40_latch &= 0x0f; // set last command to 0 to prevent problems
377418logerror("write to i/o 0x60 of %x\n",data);
378419}
379420
r5349r5350
856897
857898    ROM_REGION(0x10000, "vram", 0)
858899    ROM_FILL(0x0000, 0xffff, 0xff) /* fill with ff, driver_init changes this to the 'correct' startup pattern */
900
901    ROM_REGION(0x10000, "speech", 0)
902    ROM_FILL(0x0000, 0xffff, 0x00) /* fill with 00, if no speech cart is present socrates will see this */
903    ROM_LOAD_OPTIONAL("speech_eng.bin", 0x0000, 0x2000, CRC(edc1fb3f) SHA1(78b4631fc3b1c038e14911047f9edd6c4e8bae58))
859904ROM_END
860905   
861906ROM_START(socratfc)
r5349r5350
867912
868913    ROM_REGION(0x10000, "vram", 0)
869914    ROM_FILL(0x0000, 0xffff, 0xff) /* fill with ff, driver_init changes this to the 'correct' startup pattern */
915
916    ROM_REGION(0x10000, "speech", 0)
917    ROM_FILL(0x0000, 0xffff, 0x00) /* fill with 00, if no speech cart is present socrates will see this */
918    ROM_LOAD_OPTIONAL("speech_eng.bin", 0x0000, 0x2000, BAD_DUMP CRC(edc1fb3f) SHA1(78b4631fc3b1c038e14911047f9edd6c4e8bae58)) // should be speech_fra.bin, but french speech cart is not dumped
870919ROM_END
871920
872921

Previous 15994 Revisions Next


© 1998-2018 The MESS Team