src/mess/drivers/socrates.c
| r5349 | r5350 | |
| 95 | 95 | UINT8 kb_latch_low[2]; |
| 96 | 96 | UINT8 kb_latch_high[2]; |
| 97 | 97 | UINT8 kb_latch_mouse; |
| 98 | | UINT8 io40_latch; |
| 99 | | UINT8 hblankstate; |
| 100 | | UINT8 vblankstate; |
| 101 | | UINT8 speech_running; |
| 102 | | UINT8 speech_selftest; |
| 103 | | UINT32 speech_regs[8]; |
| 98 | UINT8 io40_latch; // what was last written to speech reg (for open bus)? |
| 99 | UINT8 hblankstate; // are we in hblank? |
| 100 | UINT8 vblankstate; // are we in vblank? |
| 101 | UINT8 speech_running; // is speech synth talking? |
| 102 | UINT32 speech_address; // address in speech space |
| 103 | UINT8 speech_dummy_read; // have we done a dummy read yet? |
| 104 | UINT8 speech_load_address_count; // number of times load address has happened |
| 105 | |
| 104 | 106 | } socrates={ {0}}; |
| 105 | 107 | |
| 106 | 108 | static void socrates_set_rom_bank( running_machine *machine ) |
| r5349 | r5350 | |
| 181 | 183 | socrates.kb_latch_low[1] = 0x00; |
| 182 | 184 | socrates.kb_latch_high[1] = 0x01; |
| 183 | 185 | socrates.kb_latch_mouse = 0; |
| 184 | | socrates.io40_latch = 0xf; |
| 186 | socrates.io40_latch = 0; |
| 185 | 187 | socrates.hblankstate = 0; |
| 186 | 188 | socrates.vblankstate = 0; |
| 187 | 189 | 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; |
| 197 | 193 | } |
| 198 | 194 | |
| 199 | 195 | DRIVER_INIT( socrates ) |
| r5349 | r5350 | |
| 240 | 236 | |
| 241 | 237 | WRITE8_HANDLER( unknownlatch_30 ) // writes to i/o 0x3x do SOMETHING, possibly waitstate related (may halt cpu until vblank start?) |
| 242 | 238 | { |
| 243 | | logerror("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 |
| 244 | 240 | } |
| 245 | 241 | |
| 246 | 242 | READ8_HANDLER( status_and_speech ) // read 0x4x, some sort of status reg |
| r5349 | r5350 | |
| 253 | 249 | // bit 2 - speech chip bit 2 |
| 254 | 250 | // bit 1 - speech chip bit 1 |
| 255 | 251 | // 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 |
| 252 | UINT8 *speechrom = memory_region(space->machine, "speech"); |
| 259 | 253 | int temp = 0; |
| 260 | 254 | temp |= (socrates.speech_running)?0x80:0; |
| 261 | 255 | temp |= 0x40; // unknown |
| 262 | 256 | temp |= (socrates.vblankstate)?0:0x20; |
| 263 | 257 | temp |= (socrates.hblankstate)?0:0x10; |
| 264 | | switch(socrates.io40_latch&0xF0) |
| 258 | switch(socrates.io40_latch&0xF0) // what was last opcode sent? |
| 265 | 259 | { |
| 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 | } |
| 269 | 271 | 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 |
| 277 | 272 | default: |
| 278 | | temp |= socrates.io40_latch&0xF; |
| 273 | temp |= socrates.io40_latch&0xF; // read open bus |
| 279 | 274 | break; |
| 280 | 275 | } |
| 281 | 276 | logerror("read from i/o 0x4x of %x\n", temp); |
| 282 | 277 | return temp; |
| 283 | 278 | } |
| 279 | static 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 | } |
| 284 | 284 | |
| 285 | 285 | WRITE8_HANDLER( speech_command ) // write 0x4x, some sort of bitfield; speech chip is probably hitachi hd38880 related but not exact, w/4 bit interface |
| 286 | 286 | { |
| 287 | logerror("write to i/o 0x4x of %x\n", data); |
| 287 | 288 | /* |
| 288 | 289 | // 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) |
| 289 | 290 | // 00-0f: readback: 70-7f |
| r5349 | r5350 | |
| 334 | 335 | 1111 |
| 335 | 336 | */ |
| 336 | 337 | /* 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 | } |
| 340 | 386 | socrates.io40_latch = data; |
| 341 | | logerror("write to i/o 0x4x of %x\n", data); |
| 342 | 387 | } |
| 343 | 388 | |
| 344 | 389 | READ8_HANDLER( socrates_keyboard_low_r ) // keyboard code low |
| r5349 | r5350 | |
| 363 | 408 | socrates.kb_latch_high[1] = 1; |
| 364 | 409 | } |
| 365 | 410 | |
| 366 | | WRITE8_HANDLER( reset_speech ) // reset speech synth |
| 411 | WRITE8_HANDLER( reset_speech ) // i/o 60: reset speech synth |
| 367 | 412 | { |
| 368 | | socrates.speech_selftest = 0; |
| 369 | | socrates.speech_regs[0] = 0; |
| 370 | | socrates.speech_regs[1] = 0; |
| 371 | | socrates.speech_regs[2] = 0; |
| 372 | | socrates.speech_regs[3] = 0; |
| 373 | | socrates.speech_regs[4] = 0; |
| 374 | | socrates.speech_regs[5] = 0; |
| 375 | | socrates.speech_regs[6] = 0; |
| 376 | | socrates.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 |
| 377 | 418 | logerror("write to i/o 0x60 of %x\n",data); |
| 378 | 419 | } |
| 379 | 420 | |
| r5349 | r5350 | |
| 856 | 897 | |
| 857 | 898 | ROM_REGION(0x10000, "vram", 0) |
| 858 | 899 | 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)) |
| 859 | 904 | ROM_END |
| 860 | 905 | |
| 861 | 906 | ROM_START(socratfc) |
| r5349 | r5350 | |
| 867 | 912 | |
| 868 | 913 | ROM_REGION(0x10000, "vram", 0) |
| 869 | 914 | 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 |
| 870 | 919 | ROM_END |
| 871 | 920 | |
| 872 | 921 | |