src/mess/machine/spectrum.c
| r4592 | r4593 | |
| 57 | 57 | { |
| 58 | 58 | /* Hack for correct handling 0xffff interrupt vector */ |
| 59 | 59 | if (address == 0x0001) |
| 60 | | if (cpu_get_reg(space->machine->cpu[0], REG_GENPCBASE)==0xffff) |
| 60 | if (cpu_get_reg(cputag_get_cpu(space->machine, "maincpu"), REG_GENPCBASE)==0xffff) |
| 61 | 61 | { |
| 62 | | cpu_set_reg(space->machine->cpu[0], Z80_PC, 0xfff4); |
| 62 | cpu_set_reg(cputag_get_cpu(space->machine, "maincpu"), Z80_PC, 0xfff4); |
| 63 | 63 | return 0xfff4; |
| 64 | 64 | } |
| 65 | 65 | return address; |
| r4592 | r4593 | |
| 67 | 67 | |
| 68 | 68 | MACHINE_RESET( spectrum ) |
| 69 | 69 | { |
| 70 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 70 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 71 | 71 | memory_set_direct_update_handler(space, spectrum_direct); |
| 72 | 72 | } |
| 73 | 73 | |
| r4592 | r4593 | |
| 104 | 104 | spectrum_setup_z80(image->machine, snapshot_data, snapshot_size); |
| 105 | 105 | } |
| 106 | 106 | free(snapshot_data); |
| 107 | | //logerror("Snapshot loaded - new PC = %04x\n", (unsigned) cpu_get_reg(machine->cpu[0], Z80_PC) & 0x0ffff); |
| 107 | //logerror("Snapshot loaded - new PC = %04x\n", (unsigned) cpu_get_reg(cputag_get_cpu(image->machine, "maincpu"), Z80_PC) & 0x0ffff); |
| 108 | 108 | return INIT_PASS; |
| 109 | 109 | |
| 110 | 110 | error: |
| r4592 | r4593 | |
| 193 | 193 | UINT8 lo, hi, data; |
| 194 | 194 | UINT16 offset, size; |
| 195 | 195 | UINT16 status; |
| 196 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 196 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 197 | 197 | |
| 198 | 198 | lo = pSnapshot[2] & 0x0ff; |
| 199 | 199 | hi = pSnapshot[3] & 0x0ff; |
| r4592 | r4593 | |
| 206 | 206 | |
| 207 | 207 | lo = pSnapshot[6] & 0x0ff; |
| 208 | 208 | hi = pSnapshot[7] & 0x0ff; |
| 209 | | cpu_set_reg(machine->cpu[0], Z80_BC, (hi << 8) | lo); |
| 209 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_BC, (hi << 8) | lo); |
| 210 | 210 | lo = pSnapshot[8] & 0x0ff; |
| 211 | 211 | hi = pSnapshot[9] & 0x0ff; |
| 212 | | cpu_set_reg(machine->cpu[0], Z80_DE, (hi << 8) | lo); |
| 212 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_DE, (hi << 8) | lo); |
| 213 | 213 | lo = pSnapshot[10] & 0x0ff; |
| 214 | 214 | hi = pSnapshot[11] & 0x0ff; |
| 215 | | cpu_set_reg(machine->cpu[0], Z80_HL, (hi << 8) | lo); |
| 215 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_HL, (hi << 8) | lo); |
| 216 | 216 | lo = pSnapshot[12] & 0x0ff; |
| 217 | 217 | hi = pSnapshot[13] & 0x0ff; |
| 218 | | cpu_set_reg(machine->cpu[0], Z80_AF, (hi << 8) | lo); |
| 218 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_AF, (hi << 8) | lo); |
| 219 | 219 | |
| 220 | 220 | lo = pSnapshot[14] & 0x0ff; |
| 221 | 221 | hi = pSnapshot[15] & 0x0ff; |
| 222 | | cpu_set_reg(machine->cpu[0], Z80_IX, (hi << 8) | lo); |
| 222 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IX, (hi << 8) | lo); |
| 223 | 223 | lo = pSnapshot[16] & 0x0ff; |
| 224 | 224 | hi = pSnapshot[17] & 0x0ff; |
| 225 | | cpu_set_reg(machine->cpu[0], Z80_IY, (hi << 8) | lo); |
| 225 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IY, (hi << 8) | lo); |
| 226 | 226 | |
| 227 | 227 | lo = pSnapshot[18] & 0x0ff; |
| 228 | 228 | hi = pSnapshot[19] & 0x0ff; |
| 229 | | cpu_set_reg(machine->cpu[0], Z80_BC2, (hi << 8) | lo); |
| 229 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_BC2, (hi << 8) | lo); |
| 230 | 230 | lo = pSnapshot[20] & 0x0ff; |
| 231 | 231 | hi = pSnapshot[21] & 0x0ff; |
| 232 | | cpu_set_reg(machine->cpu[0], Z80_DE2, (hi << 8) | lo); |
| 232 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_DE2, (hi << 8) | lo); |
| 233 | 233 | lo = pSnapshot[22] & 0x0ff; |
| 234 | 234 | hi = pSnapshot[23] & 0x0ff; |
| 235 | | cpu_set_reg(machine->cpu[0], Z80_HL2, (hi << 8) | lo); |
| 235 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_HL2, (hi << 8) | lo); |
| 236 | 236 | lo = pSnapshot[24] & 0x0ff; |
| 237 | 237 | hi = pSnapshot[25] & 0x0ff; |
| 238 | | cpu_set_reg(machine->cpu[0], Z80_AF2, (hi << 8) | lo); |
| 238 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_AF2, (hi << 8) | lo); |
| 239 | 239 | |
| 240 | | cpu_set_reg(machine->cpu[0], Z80_R, (pSnapshot[26] & 0x0ff)); |
| 241 | | cpu_set_reg(machine->cpu[0], Z80_I, (pSnapshot[27] & 0x0ff)); |
| 240 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_R, (pSnapshot[26] & 0x0ff)); |
| 241 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_I, (pSnapshot[27] & 0x0ff)); |
| 242 | 242 | |
| 243 | 243 | lo = pSnapshot[28] & 0x0ff; |
| 244 | 244 | hi = pSnapshot[29] & 0x0ff; |
| 245 | | cpu_set_reg(machine->cpu[0], Z80_SP, (hi << 8) | lo); |
| 245 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_SP, (hi << 8) | lo); |
| 246 | 246 | lo = pSnapshot[30] & 0x0ff; |
| 247 | 247 | hi = pSnapshot[31] & 0x0ff; |
| 248 | | cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo); |
| 248 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_PC, (hi << 8) | lo); |
| 249 | 249 | |
| 250 | 250 | lo = pSnapshot[32] & 0x0ff; |
| 251 | 251 | hi = pSnapshot[33] & 0x0ff; |
| r4592 | r4593 | |
| 266 | 266 | status = (hi << 8) | lo; |
| 267 | 267 | |
| 268 | 268 | data = (status & 0x01); |
| 269 | | cpu_set_reg(machine->cpu[0], Z80_IFF1, data); |
| 270 | | data = (status & 0x04)>>2; |
| 271 | | cpu_set_reg(machine->cpu[0], Z80_IFF2, data); |
| 269 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF1, data); |
| 270 | data = (status & 0x04) >> 2; |
| 271 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF2, data); |
| 272 | 272 | |
| 273 | | data = (status & 0x08)>>3; |
| 273 | data = (status & 0x08) >> 3; |
| 274 | 274 | if (data) |
| 275 | | cpu_set_reg(machine->cpu[0], Z80_IM, 0); |
| 275 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IM, 0); |
| 276 | 276 | else |
| 277 | 277 | { |
| 278 | | data = (status & 0x02)>>1; |
| 278 | data = (status & 0x02) >> 1; |
| 279 | 279 | if (data) |
| 280 | | cpu_set_reg(machine->cpu[0], Z80_IM, 2); |
| 280 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IM, 2); |
| 281 | 281 | else |
| 282 | | cpu_set_reg(machine->cpu[0], Z80_IM, 1); |
| 282 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IM, 1); |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | | data = (status & 0x10)>>4; |
| 286 | | cpu_set_input_line(machine->cpu[0], 0, data); |
| 287 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, data); |
| 288 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_HALT, 0); |
| 285 | data = (status & 0x10) >> 4; |
| 286 | cputag_set_input_line(machine, "maincpu", 0, data); |
| 287 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, data); |
| 288 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, 0); |
| 289 | 289 | |
| 290 | 290 | spectrum_page_basicrom(machine); |
| 291 | 291 | |
| r4592 | r4593 | |
| 331 | 331 | long bank_offset; |
| 332 | 332 | unsigned char lo, hi, data; |
| 333 | 333 | unsigned short addr; |
| 334 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 334 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 335 | 335 | |
| 336 | 336 | if ((SnapshotSize != 49179) && (spectrum_128_port_7ffd_data == -1)) |
| 337 | 337 | { |
| r4592 | r4593 | |
| 339 | 339 | return; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | | cpu_set_reg(machine->cpu[0], Z80_I, (pSnapshot[0] & 0x0ff)); |
| 342 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_I, (pSnapshot[0] & 0x0ff)); |
| 343 | 343 | lo = pSnapshot[1] & 0x0ff; |
| 344 | 344 | hi = pSnapshot[2] & 0x0ff; |
| 345 | | cpu_set_reg(machine->cpu[0], Z80_HL2, (hi << 8) | lo); |
| 345 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_HL2, (hi << 8) | lo); |
| 346 | 346 | lo = pSnapshot[3] & 0x0ff; |
| 347 | 347 | hi = pSnapshot[4] & 0x0ff; |
| 348 | | cpu_set_reg(machine->cpu[0], Z80_DE2, (hi << 8) | lo); |
| 348 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_DE2, (hi << 8) | lo); |
| 349 | 349 | lo = pSnapshot[5] & 0x0ff; |
| 350 | 350 | hi = pSnapshot[6] & 0x0ff; |
| 351 | | cpu_set_reg(machine->cpu[0], Z80_BC2, (hi << 8) | lo); |
| 351 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_BC2, (hi << 8) | lo); |
| 352 | 352 | lo = pSnapshot[7] & 0x0ff; |
| 353 | 353 | hi = pSnapshot[8] & 0x0ff; |
| 354 | | cpu_set_reg(machine->cpu[0], Z80_AF2, (hi << 8) | lo); |
| 354 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_AF2, (hi << 8) | lo); |
| 355 | 355 | lo = pSnapshot[9] & 0x0ff; |
| 356 | 356 | hi = pSnapshot[10] & 0x0ff; |
| 357 | | cpu_set_reg(machine->cpu[0], Z80_HL, (hi << 8) | lo); |
| 357 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_HL, (hi << 8) | lo); |
| 358 | 358 | lo = pSnapshot[11] & 0x0ff; |
| 359 | 359 | hi = pSnapshot[12] & 0x0ff; |
| 360 | | cpu_set_reg(machine->cpu[0], Z80_DE, (hi << 8) | lo); |
| 360 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_DE, (hi << 8) | lo); |
| 361 | 361 | lo = pSnapshot[13] & 0x0ff; |
| 362 | 362 | hi = pSnapshot[14] & 0x0ff; |
| 363 | | cpu_set_reg(machine->cpu[0], Z80_BC, (hi << 8) | lo); |
| 363 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_BC, (hi << 8) | lo); |
| 364 | 364 | lo = pSnapshot[15] & 0x0ff; |
| 365 | 365 | hi = pSnapshot[16] & 0x0ff; |
| 366 | | cpu_set_reg(machine->cpu[0], Z80_IY, (hi << 8) | lo); |
| 366 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IY, (hi << 8) | lo); |
| 367 | 367 | lo = pSnapshot[17] & 0x0ff; |
| 368 | 368 | hi = pSnapshot[18] & 0x0ff; |
| 369 | | cpu_set_reg(machine->cpu[0], Z80_IX, (hi << 8) | lo); |
| 369 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IX, (hi << 8) | lo); |
| 370 | 370 | data = (pSnapshot[19] & 0x04) >> 2; |
| 371 | | cpu_set_reg(machine->cpu[0], Z80_IFF2, data); |
| 372 | | cpu_set_reg(machine->cpu[0], Z80_IFF1, data); |
| 371 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF2, data); |
| 372 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF1, data); |
| 373 | 373 | data = (pSnapshot[20] & 0x0ff); |
| 374 | | cpu_set_reg(machine->cpu[0], Z80_R, data); |
| 374 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_R, data); |
| 375 | 375 | lo = pSnapshot[21] & 0x0ff; |
| 376 | 376 | hi = pSnapshot[22] & 0x0ff; |
| 377 | | cpu_set_reg(machine->cpu[0], Z80_AF, (hi << 8) | lo); |
| 377 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_AF, (hi << 8) | lo); |
| 378 | 378 | lo = pSnapshot[23] & 0x0ff; |
| 379 | 379 | hi = pSnapshot[24] & 0x0ff; |
| 380 | | cpu_set_reg(machine->cpu[0], Z80_SP, (hi << 8) | lo); |
| 380 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_SP, (hi << 8) | lo); |
| 381 | 381 | data = (pSnapshot[25] & 0x0ff); |
| 382 | | cpu_set_reg(machine->cpu[0], Z80_IM, data); |
| 382 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IM, data); |
| 383 | 383 | |
| 384 | 384 | /* Set border colour */ |
| 385 | 385 | spectrum_PreviousFE = (spectrum_PreviousFE & 0xf8) | (pSnapshot[26] & 0x07); |
| r4592 | r4593 | |
| 387 | 387 | set_last_border_color(pSnapshot[26] & 0x07); |
| 388 | 388 | force_border_redraw(); |
| 389 | 389 | |
| 390 | | cpu_set_input_line(machine->cpu[0], 0, data); |
| 391 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, data); |
| 392 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_HALT, 0); |
| 390 | cputag_set_input_line(machine, "maincpu", 0, data); |
| 391 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, data); |
| 392 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, 0); |
| 393 | 393 | |
| 394 | 394 | if (SnapshotSize == 49179) |
| 395 | 395 | /* 48K Snapshot */ |
| r4592 | r4593 | |
| 410 | 410 | if (SnapshotSize == 49179) |
| 411 | 411 | { |
| 412 | 412 | /* get pc from stack */ |
| 413 | | addr = cpu_get_reg(machine->cpu[0], Z80_SP) & 0xFFFF; |
| 413 | addr = cpu_get_reg(cputag_get_cpu(machine, "maincpu"), Z80_SP) & 0xFFFF; |
| 414 | 414 | |
| 415 | | cpu_set_reg(machine->cpu[0], Z80_PC, |
| 415 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_PC, |
| 416 | 416 | ((UINT16) memory_read_byte(space,addr + 0) ) >> 8 | |
| 417 | 417 | ((UINT16) memory_read_byte(space,addr + 1) ) >> 0); |
| 418 | 418 | |
| 419 | 419 | addr += 2; |
| 420 | | cpu_set_reg(machine->cpu[0], Z80_SP, (addr & 0x0ffff)); |
| 420 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_SP, (addr & 0x0ffff)); |
| 421 | 421 | |
| 422 | 422 | |
| 423 | 423 | } |
| r4592 | r4593 | |
| 453 | 453 | /* program counter */ |
| 454 | 454 | lo = pSnapshot[49179] & 0x0ff; |
| 455 | 455 | hi = pSnapshot[49180] & 0x0ff; |
| 456 | | cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo); |
| 456 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_PC, (hi << 8) | lo); |
| 457 | 457 | } |
| 458 | 458 | } |
| 459 | 459 | |
| r4592 | r4593 | |
| 462 | 462 | { |
| 463 | 463 | unsigned char ch; |
| 464 | 464 | int i; |
| 465 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 465 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 466 | 466 | |
| 467 | 467 | do |
| 468 | 468 | { |
| r4592 | r4593 | |
| 588 | 588 | int i; |
| 589 | 589 | unsigned char lo, hi, data; |
| 590 | 590 | SPECTRUM_Z80_SNAPSHOT_TYPE z80_type; |
| 591 | | const address_space *space = cpu_get_address_space(machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 591 | const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 592 | 592 | |
| 593 | 593 | z80_type = spectrum_identify_z80(pSnapshot, SnapshotSize); |
| 594 | 594 | |
| r4592 | r4593 | |
| 629 | 629 | /* AF */ |
| 630 | 630 | hi = pSnapshot[0] & 0x0ff; |
| 631 | 631 | lo = pSnapshot[1] & 0x0ff; |
| 632 | | cpu_set_reg(machine->cpu[0], Z80_AF, (hi << 8) | lo); |
| 632 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_AF, (hi << 8) | lo); |
| 633 | 633 | /* BC */ |
| 634 | 634 | lo = pSnapshot[2] & 0x0ff; |
| 635 | 635 | hi = pSnapshot[3] & 0x0ff; |
| 636 | | cpu_set_reg(machine->cpu[0], Z80_BC, (hi << 8) | lo); |
| 636 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_BC, (hi << 8) | lo); |
| 637 | 637 | /* HL */ |
| 638 | 638 | lo = pSnapshot[4] & 0x0ff; |
| 639 | 639 | hi = pSnapshot[5] & 0x0ff; |
| 640 | | cpu_set_reg(machine->cpu[0], Z80_HL, (hi << 8) | lo); |
| 640 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_HL, (hi << 8) | lo); |
| 641 | 641 | |
| 642 | 642 | /* SP */ |
| 643 | 643 | lo = pSnapshot[8] & 0x0ff; |
| 644 | 644 | hi = pSnapshot[9] & 0x0ff; |
| 645 | | cpu_set_reg(machine->cpu[0], Z80_SP, (hi << 8) | lo); |
| 645 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_SP, (hi << 8) | lo); |
| 646 | 646 | |
| 647 | 647 | /* I */ |
| 648 | | cpu_set_reg(machine->cpu[0], Z80_I, (pSnapshot[10] & 0x0ff)); |
| 648 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_I, (pSnapshot[10] & 0x0ff)); |
| 649 | 649 | |
| 650 | 650 | /* R */ |
| 651 | 651 | data = (pSnapshot[11] & 0x07f) | ((pSnapshot[12] & 0x01) << 7); |
| 652 | | cpu_set_reg(machine->cpu[0], Z80_R, data); |
| 652 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_R, data); |
| 653 | 653 | |
| 654 | 654 | /* Set border colour */ |
| 655 | 655 | spectrum_PreviousFE = (spectrum_PreviousFE & 0xf8) | ((pSnapshot[12] & 0x0e) >> 1); |
| r4592 | r4593 | |
| 659 | 659 | |
| 660 | 660 | lo = pSnapshot[13] & 0x0ff; |
| 661 | 661 | hi = pSnapshot[14] & 0x0ff; |
| 662 | | cpu_set_reg(machine->cpu[0], Z80_DE, (hi << 8) | lo); |
| 662 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_DE, (hi << 8) | lo); |
| 663 | 663 | |
| 664 | 664 | lo = pSnapshot[15] & 0x0ff; |
| 665 | 665 | hi = pSnapshot[16] & 0x0ff; |
| 666 | | cpu_set_reg(machine->cpu[0], Z80_BC2, (hi << 8) | lo); |
| 666 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_BC2, (hi << 8) | lo); |
| 667 | 667 | |
| 668 | 668 | lo = pSnapshot[17] & 0x0ff; |
| 669 | 669 | hi = pSnapshot[18] & 0x0ff; |
| 670 | | cpu_set_reg(machine->cpu[0], Z80_DE2, (hi << 8) | lo); |
| 670 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_DE2, (hi << 8) | lo); |
| 671 | 671 | |
| 672 | 672 | lo = pSnapshot[19] & 0x0ff; |
| 673 | 673 | hi = pSnapshot[20] & 0x0ff; |
| 674 | | cpu_set_reg(machine->cpu[0], Z80_HL2, (hi << 8) | lo); |
| 674 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_HL2, (hi << 8) | lo); |
| 675 | 675 | |
| 676 | 676 | hi = pSnapshot[21] & 0x0ff; |
| 677 | 677 | lo = pSnapshot[22] & 0x0ff; |
| 678 | | cpu_set_reg(machine->cpu[0], Z80_AF2, (hi << 8) | lo); |
| 678 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_AF2, (hi << 8) | lo); |
| 679 | 679 | |
| 680 | 680 | lo = pSnapshot[23] & 0x0ff; |
| 681 | 681 | hi = pSnapshot[24] & 0x0ff; |
| 682 | | cpu_set_reg(machine->cpu[0], Z80_IY, (hi << 8) | lo); |
| 682 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IY, (hi << 8) | lo); |
| 683 | 683 | |
| 684 | 684 | lo = pSnapshot[25] & 0x0ff; |
| 685 | 685 | hi = pSnapshot[26] & 0x0ff; |
| 686 | | cpu_set_reg(machine->cpu[0], Z80_IX, (hi << 8) | lo); |
| 686 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IX, (hi << 8) | lo); |
| 687 | 687 | |
| 688 | 688 | /* Interrupt Flip/Flop */ |
| 689 | 689 | if (pSnapshot[27] == 0) |
| 690 | 690 | { |
| 691 | | cpu_set_reg(machine->cpu[0], Z80_IFF1, 0); |
| 692 | | /* cpu_set_reg(machine->cpu[0], Z80_IRQ_STATE, 0); */ |
| 691 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF1, 0); |
| 692 | /* cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IRQ_STATE, 0); */ |
| 693 | 693 | } |
| 694 | 694 | else |
| 695 | 695 | { |
| 696 | | cpu_set_reg(machine->cpu[0], Z80_IFF1, 1); |
| 697 | | /* cpu_set_reg(machine->cpu[0], Z80_IRQ_STATE, 1); */ |
| 696 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF1, 1); |
| 697 | /* cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IRQ_STATE, 1); */ |
| 698 | 698 | } |
| 699 | 699 | |
| 700 | | cpu_set_input_line(machine->cpu[0], 0, data); |
| 701 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, data); |
| 702 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_HALT, 0); |
| 700 | cputag_set_input_line(machine, "maincpu", 0, data); |
| 701 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, data); |
| 702 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_HALT, 0); |
| 703 | 703 | |
| 704 | 704 | /* IFF2 */ |
| 705 | 705 | if (pSnapshot[28] != 0) |
| r4592 | r4593 | |
| 710 | 710 | { |
| 711 | 711 | data = 0; |
| 712 | 712 | } |
| 713 | | cpu_set_reg(machine->cpu[0], Z80_IFF2, data); |
| 713 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IFF2, data); |
| 714 | 714 | |
| 715 | 715 | /* Interrupt Mode */ |
| 716 | | cpu_set_reg(machine->cpu[0], Z80_IM, (pSnapshot[29] & 0x03)); |
| 716 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_IM, (pSnapshot[29] & 0x03)); |
| 717 | 717 | |
| 718 | 718 | if (z80_type == SPECTRUM_Z80_SNAPSHOT_48K_OLD) |
| 719 | 719 | { |
| 720 | 720 | lo = pSnapshot[6] & 0x0ff; |
| 721 | 721 | hi = pSnapshot[7] & 0x0ff; |
| 722 | | cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo); |
| 722 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_PC, (hi << 8) | lo); |
| 723 | 723 | |
| 724 | 724 | spectrum_page_basicrom(machine); |
| 725 | 725 | |
| r4592 | r4593 | |
| 744 | 744 | |
| 745 | 745 | lo = pSnapshot[32] & 0x0ff; |
| 746 | 746 | hi = pSnapshot[33] & 0x0ff; |
| 747 | | cpu_set_reg(machine->cpu[0], Z80_PC, (hi << 8) | lo); |
| 747 | cpu_set_reg(cputag_get_cpu(machine, "maincpu"), Z80_PC, (hi << 8) | lo); |
| 748 | 748 | |
| 749 | 749 | if ((z80_type == SPECTRUM_Z80_SNAPSHOT_128K) || ((z80_type == SPECTRUM_Z80_SNAPSHOT_TS2068) && !strcmp(machine->gamedrv->name,"ts2068"))) |
| 750 | 750 | { |
| r4592 | r4593 | |
| 857 | 857 | |
| 858 | 858 | QUICKLOAD_LOAD(spectrum) |
| 859 | 859 | { |
| 860 | | const address_space *space = cpu_get_address_space(image->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 860 | const address_space *space = cputag_get_address_space(image->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 861 | 861 | int i; |
| 862 | 862 | int quick_addr = 0x4000; |
| 863 | 863 | int quick_length; |
src/mess/machine/svi318.c
| r4592 | r4593 | |
| 61 | 61 | |
| 62 | 62 | static INS8250_INTERRUPT( svi318_ins8250_interrupt ) |
| 63 | 63 | { |
| 64 | | if (svi.bankLow != SVI_CART) { |
| 65 | | cpu_set_input_line(device->machine->cpu[0], 0, (state ? HOLD_LINE : CLEAR_LINE)); |
| 64 | if (svi.bankLow != SVI_CART) |
| 65 | { |
| 66 | cputag_set_input_line(device->machine, "maincpu", 0, (state ? HOLD_LINE : CLEAR_LINE)); |
| 66 | 67 | } |
| 67 | 68 | } |
| 68 | 69 | |
| r4592 | r4593 | |
| 435 | 436 | int j; |
| 436 | 437 | UINT8 data = svi.svi806_gfx[ svi.svi806_ram[ ( ma + i ) & 0x7FF ] * 16 + ra ]; |
| 437 | 438 | |
| 438 | | if ( i == cursor_x ) { |
| 439 | if ( i == cursor_x ) |
| 440 | { |
| 439 | 441 | data = 0xFF; |
| 440 | 442 | } |
| 441 | 443 | |
| r4592 | r4593 | |
| 506 | 508 | |
| 507 | 509 | void svi318_vdp_interrupt(running_machine *machine, int i) |
| 508 | 510 | { |
| 509 | | cpu_set_input_line(machine->cpu[0], 0, (i ? HOLD_LINE : CLEAR_LINE)); |
| 511 | cputag_set_input_line(machine, "maincpu", 0, (i ? HOLD_LINE : CLEAR_LINE)); |
| 510 | 512 | } |
| 511 | 513 | |
| 512 | 514 | |
| r4592 | r4593 | |
| 623 | 625 | DRIVER_INIT( svi318 ) |
| 624 | 626 | { |
| 625 | 627 | /* z80 stuff */ |
| 626 | | z80_set_cycle_tables( machine->cpu[0], cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex ); |
| 628 | z80_set_cycle_tables( cputag_get_cpu(machine, "maincpu"), cc_op, cc_cb, cc_ed, cc_xy, cc_xycb, cc_ex ); |
| 627 | 629 | |
| 628 | 630 | memset(&svi, 0, sizeof (svi) ); |
| 629 | 631 | |
| 630 | | if ( ! strcmp( machine->gamedrv->name, "svi318" ) || ! strcmp( machine->gamedrv->name, "svi318n" ) ) { |
| 632 | if ( ! strcmp( machine->gamedrv->name, "svi318" ) || ! strcmp( machine->gamedrv->name, "svi318n" ) ) |
| 633 | { |
| 631 | 634 | svi.svi318 = 1; |
| 632 | 635 | } |
| 633 | 636 | |
| 634 | | cpu_set_input_line_vector(machine->cpu[0], 0, 0xff); |
| 637 | cpu_set_input_line_vector(cputag_get_cpu(machine, "maincpu"), 0, 0xff); |
| 635 | 638 | |
| 636 | 639 | /* memory */ |
| 637 | 640 | svi.empty_bank = auto_malloc (0x8000); |
| r4592 | r4593 | |
| 712 | 715 | |
| 713 | 716 | WRITE8_HANDLER( svi318_writemem4 ) |
| 714 | 717 | { |
| 715 | | if ( svi.svi806_ram_enabled ) { |
| 716 | | if ( offset < 0x800 ) { |
| 718 | if ( svi.svi806_ram_enabled ) |
| 719 | { |
| 720 | if ( offset < 0x800 ) |
| 721 | { |
| 717 | 722 | svi.svi806_ram[ offset ] = data; |
| 718 | 723 | } |
| 719 | | } else { |
| 724 | } |
| 725 | else |
| 726 | { |
| 720 | 727 | if ( svi.bankHigh2_read_only ) |
| 721 | 728 | return; |
| 722 | 729 | |
| r4592 | r4593 | |
| 734 | 741 | svi.bankLow_ptr = svi.empty_bank; |
| 735 | 742 | svi.bankLow_read_only = 1; |
| 736 | 743 | |
| 737 | | switch( svi.bankLow ) { |
| 744 | switch( svi.bankLow ) |
| 745 | { |
| 738 | 746 | case SVI_INTERNAL: |
| 739 | 747 | svi.bankLow_ptr = memory_region(machine, "maincpu"); |
| 740 | 748 | break; |
| 741 | 749 | case SVI_CART: |
| 742 | | if ( pcart ) { |
| 750 | if ( pcart ) |
| 751 | { |
| 743 | 752 | svi.bankLow_ptr = pcart; |
| 744 | 753 | } |
| 745 | 754 | break; |
| 746 | 755 | case SVI_EXPRAM2: |
| 747 | | if ( mess_ram_size >= 64 * 1024 ) { |
| 756 | if ( mess_ram_size >= 64 * 1024 ) |
| 757 | { |
| 748 | 758 | svi.bankLow_ptr = mess_ram + mess_ram_size - 64 * 1024; |
| 749 | 759 | svi.bankLow_read_only = 0; |
| 750 | 760 | } |
| 751 | 761 | break; |
| 752 | 762 | case SVI_EXPRAM3: |
| 753 | | if ( mess_ram_size > 128 * 1024 ) { |
| 763 | if ( mess_ram_size > 128 * 1024 ) |
| 764 | { |
| 754 | 765 | svi.bankLow_ptr = mess_ram + mess_ram_size - 128 * 1024; |
| 755 | 766 | svi.bankLow_read_only = 0; |
| 756 | 767 | } |
| r4592 | r4593 | |
| 760 | 771 | svi.bankHigh1_ptr = svi.bankHigh2_ptr = svi.empty_bank; |
| 761 | 772 | svi.bankHigh1_read_only = svi.bankHigh2_read_only = 1; |
| 762 | 773 | |
| 763 | | switch( svi.bankHigh1 ) { |
| 774 | switch( svi.bankHigh1 ) |
| 775 | { |
| 764 | 776 | case SVI_INTERNAL: |
| 765 | | if ( mess_ram_size == 16 * 1024 ) { |
| 777 | if ( mess_ram_size == 16 * 1024 ) |
| 778 | { |
| 766 | 779 | svi.bankHigh2_ptr = mess_ram; |
| 767 | 780 | svi.bankHigh2_read_only = 0; |
| 768 | | } else { |
| 781 | } |
| 782 | else |
| 783 | { |
| 769 | 784 | svi.bankHigh1_ptr = mess_ram; |
| 770 | 785 | svi.bankHigh1_read_only = 0; |
| 771 | 786 | svi.bankHigh2_ptr = mess_ram + 0x4000; |
| r4592 | r4593 | |
| 773 | 788 | } |
| 774 | 789 | break; |
| 775 | 790 | case SVI_EXPRAM2: |
| 776 | | if ( mess_ram_size > 64 * 1024 ) { |
| 791 | if ( mess_ram_size > 64 * 1024 ) |
| 792 | { |
| 777 | 793 | svi.bankHigh1_ptr = mess_ram + mess_ram_size - 64 * 1024 + 32 * 1024; |
| 778 | 794 | svi.bankHigh1_read_only = 0; |
| 779 | 795 | svi.bankHigh2_ptr = mess_ram + mess_ram_size - 64 * 1024 + 48 * 1024; |
| r4592 | r4593 | |
| 781 | 797 | } |
| 782 | 798 | break; |
| 783 | 799 | case SVI_EXPRAM3: |
| 784 | | if ( mess_ram_size > 128 * 1024 ) { |
| 800 | if ( mess_ram_size > 128 * 1024 ) |
| 801 | { |
| 785 | 802 | svi.bankHigh1_ptr = mess_ram + mess_ram_size - 128 * 1024 + 32 * 1024; |
| 786 | 803 | svi.bankHigh1_read_only = 0; |
| 787 | 804 | svi.bankHigh2_ptr = mess_ram + mess_ram_size - 128 * 1024 + 48 * 1024; |
| r4592 | r4593 | |
| 791 | 808 | } |
| 792 | 809 | |
| 793 | 810 | /* Check for special CART based banking */ |
| 794 | | if ( svi.bankLow == SVI_CART && ( v & 0xc0 ) != 0xc0 ) { |
| 811 | if ( svi.bankLow == SVI_CART && ( v & 0xc0 ) != 0xc0 ) |
| 812 | { |
| 795 | 813 | svi.bankHigh1_ptr = svi.empty_bank; |
| 796 | 814 | svi.bankHigh1_read_only = 1; |
| 797 | 815 | svi.bankHigh2_ptr = svi.empty_bank; |
| 798 | 816 | svi.bankHigh2_read_only = 1; |
| 799 | | if ( pcart && ! ( v & 0x80 ) ) { |
| 817 | if ( pcart && ! ( v & 0x80 ) ) |
| 818 | { |
| 800 | 819 | svi.bankHigh2_ptr = pcart + 0x4000; |
| 801 | 820 | } |
| 802 | | if ( pcart && ! ( v & 0x40 ) ) { |
| 821 | if ( pcart && ! ( v & 0x40 ) ) |
| 822 | { |
| 803 | 823 | svi.bankHigh1_ptr = pcart; |
| 804 | 824 | } |
| 805 | 825 | } |
| r4592 | r4593 | |
| 809 | 829 | memory_set_bankptr(machine, 3, svi.bankHigh2_ptr ); |
| 810 | 830 | |
| 811 | 831 | /* SVI-806 80 column card specific banking */ |
| 812 | | if ( svi.svi806_present ) { |
| 813 | | if ( svi.svi806_ram_enabled ) { |
| 832 | if ( svi.svi806_present ) |
| 833 | { |
| 834 | if ( svi.svi806_ram_enabled ) |
| 835 | { |
| 814 | 836 | memory_set_bankptr(machine, 4, svi.svi806_ram ); |
| 815 | | } else { |
| 837 | } |
| 838 | else |
| 839 | { |
| 816 | 840 | memory_set_bankptr(machine, 4, svi.bankHigh2_ptr + 0x3000 ); |
| 817 | 841 | } |
| 818 | 842 | } |
| r4592 | r4593 | |
| 837 | 861 | const device_config *fdc = devtag_get_device(space->machine, "wd179x"); |
| 838 | 862 | const device_config *printer = devtag_get_device(space->machine, "centronics"); |
| 839 | 863 | |
| 840 | | if (svi.bankLow == SVI_CART) { |
| 864 | if (svi.bankLow == SVI_CART) |
| 865 | { |
| 841 | 866 | return 0xff; |
| 842 | 867 | } |
| 843 | 868 | |
| r4592 | r4593 | |
| 899 | 924 | const device_config *fdc = devtag_get_device(space->machine, "wd179x"); |
| 900 | 925 | const device_config *printer = devtag_get_device(space->machine, "centronics"); |
| 901 | 926 | |
| 902 | | if (svi.bankLow == SVI_CART) { |
| 927 | if (svi.bankLow == SVI_CART) |
| 928 | { |
| 903 | 929 | return; |
| 904 | 930 | } |
| 905 | 931 | |
src/mess/drivers/saturn.c
| r4592 | r4593 | |
| 261 | 261 | |
| 262 | 262 | /*A-Bus IRQ checks,where they could be located these?*/ |
| 263 | 263 | #define ABUSIRQ(_irq_,_vector_) \ |
| 264 | | { cpu_set_input_line_and_vector(device->machine->cpu[0], _irq_, HOLD_LINE , _vector_); } |
| 264 | { cputag_set_input_line_and_vector(device->machine, "maincpu", _irq_, HOLD_LINE , _vector_); } |
| 265 | 265 | #if 0 |
| 266 | 266 | if(stv_scu[42] & 1)//IRQ ACK |
| 267 | 267 | { |
| r4592 | r4593 | |
| 586 | 586 | intback_stage = 2; |
| 587 | 587 | } |
| 588 | 588 | smpc_intbackhelper(machine); |
| 589 | | cpu_set_input_line_and_vector(machine->cpu[0], 8, HOLD_LINE , 0x47); |
| 589 | cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x47); |
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | if ((offset == 1) && (data & 0x40)) |
| r4592 | r4593 | |
| 629 | 629 | if(!(stv_scu[40] & 0x0100)) /*Pad irq*/ |
| 630 | 630 | { |
| 631 | 631 | if(LOG_SMPC) logerror ("Interrupt: PAD irq, Vector 0x48 Level 0x08\n"); |
| 632 | | cpu_set_input_line_and_vector(machine->cpu[0], 8, HOLD_LINE , 0x48); |
| 632 | cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x48); |
| 633 | 633 | } |
| 634 | 634 | } |
| 635 | 635 | |
| r4592 | r4593 | |
| 646 | 646 | if(LOG_SMPC) logerror ("SMPC: Slave ON\n"); |
| 647 | 647 | smpc_ram[0x5f]=0x02; |
| 648 | 648 | stv_enable_slave_sh2 = 1; |
| 649 | | cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, CLEAR_LINE); |
| 649 | cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, CLEAR_LINE); |
| 650 | 650 | break; |
| 651 | 651 | case 0x03: |
| 652 | 652 | if(LOG_SMPC) logerror ("SMPC: Slave OFF\n"); |
| 653 | 653 | smpc_ram[0x5f]=0x03; |
| 654 | 654 | stv_enable_slave_sh2 = 0; |
| 655 | 655 | cpuexec_trigger(machine, 1000); |
| 656 | | cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, ASSERT_LINE); |
| 656 | cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, ASSERT_LINE); |
| 657 | 657 | break; |
| 658 | 658 | case 0x06: |
| 659 | 659 | if(LOG_SMPC) logerror ("SMPC: Sound ON\n"); |
| 660 | 660 | /* wrong? */ |
| 661 | 661 | smpc_ram[0x5f]=0x06; |
| 662 | | cpu_set_input_line(machine->cpu[2], INPUT_LINE_RESET, CLEAR_LINE); |
| 662 | cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, CLEAR_LINE); |
| 663 | 663 | en_68k = 1; |
| 664 | 664 | break; |
| 665 | 665 | case 0x07: |
| 666 | 666 | if(LOG_SMPC) logerror ("SMPC: Sound OFF\n"); |
| 667 | | cpu_set_input_line(machine->cpu[2], INPUT_LINE_RESET, ASSERT_LINE); |
| 667 | cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); |
| 668 | 668 | en_68k = 0; |
| 669 | 669 | smpc_ram[0x5f]=0x07; |
| 670 | 670 | break; |
| r4592 | r4593 | |
| 674 | 674 | case 0x0d: |
| 675 | 675 | if(LOG_SMPC) logerror ("SMPC: System Reset\n"); |
| 676 | 676 | smpc_ram[0x5f]=0x0d; |
| 677 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_RESET, PULSE_LINE); |
| 677 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_RESET, PULSE_LINE); |
| 678 | 678 | system_reset(); |
| 679 | 679 | break; |
| 680 | 680 | case 0x0e: |
| 681 | 681 | if(LOG_SMPC) logerror ("SMPC: Change Clock to 352\n"); |
| 682 | 682 | smpc_ram[0x5f]=0x0e; |
| 683 | | cpu_set_clock(machine->cpu[0], MASTER_CLOCK_352/2); |
| 684 | | cpu_set_clock(machine->cpu[1], MASTER_CLOCK_352/2); |
| 685 | | cpu_set_clock(machine->cpu[2], MASTER_CLOCK_352/5); |
| 686 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 683 | cputag_set_clock(machine, "maincpu", MASTER_CLOCK_352/2); |
| 684 | cputag_set_clock(machine, "slave", MASTER_CLOCK_352/2); |
| 685 | cputag_set_clock(machine, "audiocpu", MASTER_CLOCK_352/5); |
| 686 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 687 | 687 | break; |
| 688 | 688 | case 0x0f: |
| 689 | 689 | if(LOG_SMPC) logerror ("SMPC: Change Clock to 320\n"); |
| 690 | 690 | smpc_ram[0x5f]=0x0f; |
| 691 | | cpu_set_clock(machine->cpu[0], MASTER_CLOCK_320/2); |
| 692 | | cpu_set_clock(machine->cpu[1], MASTER_CLOCK_320/2); |
| 693 | | cpu_set_clock(machine->cpu[2], MASTER_CLOCK_320/5); |
| 694 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 691 | cputag_set_clock(machine, "maincpu", MASTER_CLOCK_320/2); |
| 692 | cputag_set_clock(machine, "slave", MASTER_CLOCK_320/2); |
| 693 | cputag_set_clock(machine, "audiocpu", MASTER_CLOCK_320/5); |
| 694 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); // ff said this causes nmi, should we set a timer then nmi? |
| 695 | 695 | break; |
| 696 | 696 | /*"Interrupt Back"*/ |
| 697 | 697 | case 0x10: |
| r4592 | r4593 | |
| 743 | 743 | { |
| 744 | 744 | // if(LOG_SMPC) logerror ("Interrupt: System Manager (SMPC) at scanline %04x, Vector 0x47 Level 0x08\n",scanline); |
| 745 | 745 | smpc_intbackhelper(machine); |
| 746 | | cpu_set_input_line_and_vector(machine->cpu[0], 8, HOLD_LINE , 0x47); |
| 746 | cputag_set_input_line_and_vector(machine, "maincpu", 8, HOLD_LINE , 0x47); |
| 747 | 747 | } |
| 748 | 748 | break; |
| 749 | 749 | /* RTC write*/ |
| r4592 | r4593 | |
| 772 | 772 | if(LOG_SMPC) logerror ("SMPC: NMI request\n"); |
| 773 | 773 | smpc_ram[0x5f]=0x18; |
| 774 | 774 | /*NMI is unconditionally requested?*/ |
| 775 | | cpu_set_input_line(machine->cpu[0], INPUT_LINE_NMI, PULSE_LINE); |
| 775 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE); |
| 776 | 776 | break; |
| 777 | 777 | case 0x19: |
| 778 | 778 | if(LOG_SMPC) logerror ("SMPC: NMI Enable\n"); |
| r4592 | r4593 | |
| 1062 | 1062 | /*Sound IRQ*/ |
| 1063 | 1063 | if(/*(!(stv_scu[40] & 0x40)) &&*/ scsp_to_main_irq == 1) |
| 1064 | 1064 | { |
| 1065 | | //cpu_set_input_line_and_vector(space->machine->cpu[0], 9, HOLD_LINE , 0x46); |
| 1065 | //cputag_set_input_line_and_vector(space->machine, "maincpu", 9, HOLD_LINE , 0x46); |
| 1066 | 1066 | logerror("SCSP: Main CPU interrupt\n"); |
| 1067 | 1067 | #if 0 |
| 1068 | 1068 | if((scu_dst_0 & 0x7ffffff) != 0x05a00000) |
| 1069 | 1069 | { |
| 1070 | 1070 | if(!(stv_scu[40] & 0x1000)) |
| 1071 | 1071 | { |
| 1072 | | cpu_set_input_line_and_vector(space->machine->cpu[0], 3, HOLD_LINE, 0x4c); |
| 1072 | cputag_set_input_line_and_vector(space->machine, "maincpu", 3, HOLD_LINE, 0x4c); |
| 1073 | 1073 | logerror("SCU: Illegal DMA interrupt\n"); |
| 1074 | 1074 | } |
| 1075 | 1075 | } |
| r4592 | r4593 | |
| 1123 | 1123 | /*Sound IRQ*/ |
| 1124 | 1124 | if(/*(!(stv_scu[40] & 0x40)) &&*/ scsp_to_main_irq == 1) |
| 1125 | 1125 | { |
| 1126 | | //cpu_set_input_line_and_vector(space->machine->cpu[0], 9, HOLD_LINE , 0x46); |
| 1126 | //cputag_set_input_line_and_vector(space->machine, "maincpu", 9, HOLD_LINE , 0x46); |
| 1127 | 1127 | logerror("SCSP: Main CPU interrupt\n"); |
| 1128 | 1128 | } |
| 1129 | 1129 | } |
| r4592 | r4593 | |
| 1173 | 1173 | /*Sound IRQ*/ |
| 1174 | 1174 | if(/*(!(stv_scu[40] & 0x40)) &&*/ scsp_to_main_irq == 1) |
| 1175 | 1175 | { |
| 1176 | | //cpu_set_input_line_and_vector(space->machine->cpu[0], 9, HOLD_LINE , 0x46); |
| 1176 | //cputag_set_input_line_and_vector(space->machine, "maincpu", 9, HOLD_LINE , 0x46); |
| 1177 | 1177 | logerror("SCSP: Main CPU interrupt\n"); |
| 1178 | 1178 | } |
| 1179 | 1179 | } |
| r4592 | r4593 | |
| 1290 | 1290 | /*Lv 0 DMA end irq*/ |
| 1291 | 1291 | static TIMER_CALLBACK( dma_lv0_ended ) |
| 1292 | 1292 | { |
| 1293 | | cpu_set_input_line_and_vector(machine->cpu[0], 5, (stv_irq.dma_end[0]) ? HOLD_LINE : CLEAR_LINE, 0x4b); |
| 1293 | cputag_set_input_line_and_vector(machine, "maincpu", 5, (stv_irq.dma_end[0]) ? HOLD_LINE : CLEAR_LINE, 0x4b); |
| 1294 | 1294 | |
| 1295 | 1295 | D0MV_0; |
| 1296 | 1296 | } |
| r4592 | r4593 | |
| 1298 | 1298 | /*Lv 1 DMA end irq*/ |
| 1299 | 1299 | static TIMER_CALLBACK( dma_lv1_ended ) |
| 1300 | 1300 | { |
| 1301 | | cpu_set_input_line_and_vector(machine->cpu[0], 6, (stv_irq.dma_end[1]) ? HOLD_LINE : CLEAR_LINE, 0x4a); |
| 1301 | cputag_set_input_line_and_vector(machine, "maincpu", 6, (stv_irq.dma_end[1]) ? HOLD_LINE : CLEAR_LINE, 0x4a); |
| 1302 | 1302 | |
| 1303 | 1303 | D1MV_0; |
| 1304 | 1304 | } |
| r4592 | r4593 | |
| 1306 | 1306 | /*Lv 2 DMA end irq*/ |
| 1307 | 1307 | static TIMER_CALLBACK( dma_lv2_ended ) |
| 1308 | 1308 | { |
| 1309 | | cpu_set_input_line_and_vector(machine->cpu[0], 6, (stv_irq.dma_end[2]) ? HOLD_LINE : CLEAR_LINE, 0x49); |
| 1309 | cputag_set_input_line_and_vector(machine, "maincpu", 6, (stv_irq.dma_end[2]) ? HOLD_LINE : CLEAR_LINE, 0x49); |
| 1310 | 1310 | |
| 1311 | 1311 | D2MV_0; |
| 1312 | 1312 | } |
| r4592 | r4593 | |
| 1867 | 1867 | logerror("cpu %s (PC=%08X) MINIT write = %08x\n", space->cpu->tag, cpu_get_pc(space->cpu),data); |
| 1868 | 1868 | cpuexec_boost_interleave(space->machine, minit_boost_timeslice, ATTOTIME_IN_USEC(minit_boost)); |
| 1869 | 1869 | cpuexec_trigger(space->machine, 1000); |
| 1870 | | sh2_set_frt_input(space->machine->cpu[1], PULSE_LINE); |
| 1870 | sh2_set_frt_input(cputag_get_cpu(space->machine, "slave"), PULSE_LINE); |
| 1871 | 1871 | } |
| 1872 | 1872 | |
| 1873 | 1873 | static WRITE32_HANDLER( sinit_w ) |
| 1874 | 1874 | { |
| 1875 | 1875 | logerror("cpu %s (PC=%08X) SINIT write = %08x\n", space->cpu->tag, cpu_get_pc(space->cpu),data); |
| 1876 | 1876 | cpuexec_boost_interleave(space->machine, sinit_boost_timeslice, ATTOTIME_IN_USEC(sinit_boost)); |
| 1877 | | sh2_set_frt_input(space->machine->cpu[0], PULSE_LINE); |
| 1877 | sh2_set_frt_input(cputag_get_cpu(space->machine, "maincpu"), PULSE_LINE); |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | 1880 | static UINT32 backup[64*1024/4]; |
| r4592 | r4593 | |
| 2067 | 2067 | timer_0 = 0; \ |
| 2068 | 2068 | { \ |
| 2069 | 2069 | /*if(LOG_IRQ) logerror ("Interrupt: VBlank-OUT Vector 0x41 Level 0x0e\n");*/ \ |
| 2070 | | cpu_set_input_line_and_vector(machine->cpu[0], 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ |
| 2070 | cputag_set_input_line_and_vector(machine, "maincpu", 0xe, (stv_irq.vblank_out) ? HOLD_LINE : CLEAR_LINE , 0x41); \ |
| 2071 | 2071 | } \ |
| 2072 | 2072 | |
| 2073 | 2073 | #define VBLANK_IN_IRQ \ |
| 2074 | 2074 | { \ |
| 2075 | 2075 | /*if(LOG_IRQ) logerror ("Interrupt: VBlank IN Vector 0x40 Level 0x0f\n");*/ \ |
| 2076 | | cpu_set_input_line_and_vector(device->machine->cpu[0], 0xf, (stv_irq.vblank_in) ? HOLD_LINE : CLEAR_LINE , 0x40); \ |
| 2076 | cputag_set_input_line_and_vector(device->machine, "maincpu", 0xf, (stv_irq.vblank_in) ? HOLD_LINE : CLEAR_LINE , 0x40); \ |
| 2077 | 2077 | } \ |
| 2078 | 2078 | |
| 2079 | 2079 | #define HBLANK_IN_IRQ \ |
| 2080 | 2080 | timer_1 = stv_scu[37] & 0x1ff; \ |
| 2081 | 2081 | { \ |
| 2082 | 2082 | /*if(LOG_IRQ) logerror ("Interrupt: HBlank-In at scanline %04x, Vector 0x42 Level 0x0d\n",scanline);*/ \ |
| 2083 | | cpu_set_input_line_and_vector(machine->cpu[0], 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ |
| 2083 | cputag_set_input_line_and_vector(machine, "maincpu", 0xd, (stv_irq.hblank_in) ? HOLD_LINE : CLEAR_LINE, 0x42); \ |
| 2084 | 2084 | } \ |
| 2085 | 2085 | |
| 2086 | 2086 | #define TIMER_0_IRQ \ |
| 2087 | 2087 | if(timer_0 == (stv_scu[36] & 0x3ff)) \ |
| 2088 | 2088 | { \ |
| 2089 | 2089 | /*if(LOG_IRQ) logerror ("Interrupt: Timer 0 at scanline %04x, Vector 0x43 Level 0x0c\n",scanline);*/ \ |
| 2090 | | cpu_set_input_line_and_vector(machine->cpu[0], 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ |
| 2090 | cputag_set_input_line_and_vector(machine, "maincpu", 0xc, (stv_irq.timer_0) ? HOLD_LINE : CLEAR_LINE, 0x43 ); \ |
| 2091 | 2091 | } \ |
| 2092 | 2092 | |
| 2093 | 2093 | #define TIMER_1_IRQ \ |
| r4592 | r4593 | |
| 2096 | 2096 | if(!(stv_scu[38] & 0x80)) \ |
| 2097 | 2097 | { \ |
| 2098 | 2098 | /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ |
| 2099 | | cpu_set_input_line_and_vector(machine->cpu[0], 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2099 | cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2100 | 2100 | } \ |
| 2101 | 2101 | else \ |
| 2102 | 2102 | { \ |
| 2103 | 2103 | if((timer_0) == (stv_scu[36] & 0x3ff)) \ |
| 2104 | 2104 | { \ |
| 2105 | 2105 | /*if(LOG_IRQ) logerror ("Interrupt: Timer 1 at point %04x, Vector 0x44 Level 0x0b\n",point);*/ \ |
| 2106 | | cpu_set_input_line_and_vector(machine->cpu[0], 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2106 | cputag_set_input_line_and_vector(machine, "maincpu", 0xb, (stv_irq.timer_1) ? HOLD_LINE : CLEAR_LINE, 0x44 ); \ |
| 2107 | 2107 | } \ |
| 2108 | 2108 | } \ |
| 2109 | 2109 | } \ |
| 2110 | 2110 | |
| 2111 | 2111 | #define VDP1_IRQ \ |
| 2112 | 2112 | { \ |
| 2113 | | cpu_set_input_line_and_vector(machine->cpu[0], 2, (stv_irq.vdp1_end) ? HOLD_LINE : CLEAR_LINE, 0x4d); \ |
| 2113 | cputag_set_input_line_and_vector(machine, "maincpu", 2, (stv_irq.vdp1_end) ? HOLD_LINE : CLEAR_LINE, 0x4d); \ |
| 2114 | 2114 | } \ |
| 2115 | 2115 | |
| 2116 | 2116 | static TIMER_CALLBACK( hblank_in_irq ) |
| r4592 | r4593 | |
| 2190 | 2190 | saturn_region = rgn; |
| 2191 | 2191 | |
| 2192 | 2192 | // set compatible options |
| 2193 | | sh2drc_set_options(machine->cpu[0], SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL); |
| 2194 | | sh2drc_set_options(machine->cpu[1], SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL); |
| 2193 | sh2drc_set_options(cputag_get_cpu(machine, "maincpu"), SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL); |
| 2194 | sh2drc_set_options(cputag_get_cpu(machine, "slave"), SH2DRC_STRICT_VERIFY|SH2DRC_STRICT_PCREL); |
| 2195 | 2195 | |
| 2196 | 2196 | /* get the current date/time from the core */ |
| 2197 | 2197 | mame_get_current_datetime(machine, &systime); |
| r4592 | r4593 | |
| 2271 | 2271 | static MACHINE_RESET( saturn ) |
| 2272 | 2272 | { |
| 2273 | 2273 | // don't let the slave cpu and the 68k go anywhere |
| 2274 | | cpu_set_input_line(machine->cpu[1], INPUT_LINE_RESET, ASSERT_LINE); |
| 2274 | cputag_set_input_line(machine, "slave", INPUT_LINE_RESET, ASSERT_LINE); |
| 2275 | 2275 | stv_enable_slave_sh2 = 0; |
| 2276 | | cpu_set_input_line(machine->cpu[2], INPUT_LINE_RESET, ASSERT_LINE); |
| 2276 | cputag_set_input_line(machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE); |
| 2277 | 2277 | |
| 2278 | 2278 | smpcSR = 0x40; // this bit is always on according to docs |
| 2279 | 2279 | |
| r4592 | r4593 | |
| 2288 | 2288 | memset(stv_workram_l, 0, 0x100000); |
| 2289 | 2289 | memset(stv_workram_h, 0, 0x100000); |
| 2290 | 2290 | |
| 2291 | | cpu_set_clock(machine->cpu[0], MASTER_CLOCK_320/2); |
| 2292 | | cpu_set_clock(machine->cpu[1], MASTER_CLOCK_320/2); |
| 2293 | | cpu_set_clock(machine->cpu[2], MASTER_CLOCK_320/5); |
| 2291 | cputag_set_clock(machine, "maincpu", MASTER_CLOCK_320/2); |
| 2292 | cputag_set_clock(machine, "slave", MASTER_CLOCK_320/2); |
| 2293 | cputag_set_clock(machine, "audiocpu", MASTER_CLOCK_320/5); |
| 2294 | 2294 | |
| 2295 | 2295 | stvcd_reset( machine ); |
| 2296 | 2296 | |
| r4592 | r4593 | |
| 2387 | 2387 | if (irq > 0) |
| 2388 | 2388 | { |
| 2389 | 2389 | scsp_last_line = irq; |
| 2390 | | cpu_set_input_line(device->machine->cpu[2], irq, ASSERT_LINE); |
| 2390 | cputag_set_input_line(device->machine, "audiocpu", irq, ASSERT_LINE); |
| 2391 | 2391 | } |
| 2392 | 2392 | else if (irq < 0) |
| 2393 | 2393 | { |
| 2394 | | cpu_set_input_line(device->machine->cpu[2], -irq, CLEAR_LINE); |
| 2394 | cputag_set_input_line(device->machine, "audiocpu", -irq, CLEAR_LINE); |
| 2395 | 2395 | } |
| 2396 | 2396 | else |
| 2397 | 2397 | { |
| 2398 | | cpu_set_input_line(device->machine->cpu[2], scsp_last_line, CLEAR_LINE); |
| 2398 | cputag_set_input_line(device->machine, "audiocpu", scsp_last_line, CLEAR_LINE); |
| 2399 | 2399 | } |
| 2400 | 2400 | } |
| 2401 | 2401 | |
| r4592 | r4593 | |
| 2516 | 2516 | CONS( 1994, saturneu, saturn, 0, saturn, saturn, saturneu, 0, "Sega", "Saturn (PAL)", GAME_NOT_WORKING ) |
| 2517 | 2517 | CONS( 1995, vsaturn, saturn, 0, saturn, saturn, saturnjp, 0, "JVC", "V-Saturn", GAME_NOT_WORKING ) |
| 2518 | 2518 | CONS( 1995, hisaturn, saturn, 0, saturn, saturn, saturnjp, 0, "Hitachi", "HiSaturn", GAME_NOT_WORKING ) |
| 2519 | | |
| 2520 | | |