src/mess/machine/amstrad.c
| r15593 | r15594 | |
| 1197 | 1197 | } |
| 1198 | 1198 | else // CPC+/GX4000 |
| 1199 | 1199 | { |
| 1200 | | address_space *space = state->m_maincpu->memory().space(AS_PROGRAM); |
| 1200 | //address_space *space = state->m_maincpu->memory().space(AS_PROGRAM); |
| 1201 | 1201 | |
| 1202 | | if ( state->m_asic.enabled && ( state->m_asic.rmr2 & 0x18 ) == 0x18 ) |
| 1202 | /* if ( state->m_asic.enabled && ( state->m_asic.rmr2 & 0x18 ) == 0x18 ) |
| 1203 | 1203 | { |
| 1204 | 1204 | space->install_read_handler(0x4000, 0x5fff, read8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_r),state)); |
| 1205 | 1205 | space->install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_r),state)); |
| r15593 | r15594 | |
| 1213 | 1213 | space->install_write_bank(0x4000, 0x5fff, "bank11"); |
| 1214 | 1214 | space->install_write_bank(0x6000, 0x7fff, "bank12"); |
| 1215 | 1215 | } |
| 1216 | | |
| 1216 | */ |
| 1217 | 1217 | if(state->m_AmstradCPC_RamBanks[0] != NULL) |
| 1218 | 1218 | { |
| 1219 | 1219 | state->membank("bank1")->set_base(state->m_AmstradCPC_RamBanks[0]); |
| r15593 | r15594 | |
| 1407 | 1407 | WRITE8_MEMBER(amstrad_state::amstrad_plus_asic_4000_w) |
| 1408 | 1408 | { |
| 1409 | 1409 | // logerror("ASIC: Write to register at &%04x\n",offset+0x4000); |
| 1410 | | m_asic.ram[offset] = data & 0x0f; |
| 1410 | if ( m_asic.enabled && ( m_asic.rmr2 & 0x18 ) == 0x18 ) |
| 1411 | m_asic.ram[offset] = data & 0x0f; |
| 1412 | else |
| 1413 | { |
| 1414 | UINT8* RAM = (UINT8*)membank("bank11")->base(); |
| 1415 | RAM[offset] = data; |
| 1416 | } |
| 1411 | 1417 | } |
| 1412 | 1418 | |
| 1413 | 1419 | |
| 1414 | 1420 | WRITE8_MEMBER(amstrad_state::amstrad_plus_asic_6000_w) |
| 1415 | 1421 | { |
| 1416 | | m_asic.ram[offset+0x2000] = data; |
| 1417 | | if(offset >= 0x0400 && offset < 0x440 && ( offset & 0x01 ) ) // ASIC palette |
| 1422 | if ( m_asic.enabled && ( m_asic.rmr2 & 0x18 ) == 0x18 ) |
| 1418 | 1423 | { |
| 1419 | | m_asic.ram[ offset + 0x2000 ] = data & 0x0f; |
| 1420 | | } |
| 1421 | | if(offset == 0x0800) // Programmable raster interrupt |
| 1422 | | { |
| 1423 | | // logerror("ASIC: Wrote %02x to PRI\n",data); |
| 1424 | | m_asic.pri = data; |
| 1425 | | } |
| 1426 | | if(offset >= 0x0801 && offset <= 0x0803) // Split screen registers |
| 1427 | | { |
| 1428 | | logerror("ASIC: Split screen at line %i, address &%04x\n",m_asic.ram[0x2801],m_asic.ram[0x2803] + (m_asic.ram[0x2802] << 8)); |
| 1429 | | } |
| 1430 | | if(offset == 0x0804) // Soft scroll register |
| 1431 | | { |
| 1432 | | } |
| 1433 | | if(offset == 0x0805) // Interrupt vector register (for IM 2, used by Pang) |
| 1434 | | { |
| 1435 | | // high 5 bits go to interrupt vector |
| 1436 | | int vector; |
| 1437 | | |
| 1438 | | if ( m_asic.enabled ) |
| 1424 | m_asic.ram[offset+0x2000] = data; |
| 1425 | if(offset >= 0x0400 && offset < 0x440 && ( offset & 0x01 ) ) // ASIC palette |
| 1439 | 1426 | { |
| 1440 | | vector = (data & 0xf8) + (m_plus_irq_cause); |
| 1441 | | device_set_input_line_vector(m_maincpu, 0, vector); |
| 1442 | | logerror("ASIC: IM 2 vector write %02x, data = &%02x\n",vector,data); |
| 1427 | m_asic.ram[ offset + 0x2000 ] = data & 0x0f; |
| 1443 | 1428 | } |
| 1444 | | m_asic.dma_clear = data & 0x01; |
| 1445 | | } |
| 1446 | | // DMA channels |
| 1447 | | switch(offset) |
| 1448 | | { |
| 1449 | | case 0x0c00: |
| 1450 | | case 0x0c01: |
| 1451 | | m_asic.dma_addr[0] = (m_asic.ram[0x2c01] << 8) + m_asic.ram[0x2c00]; |
| 1452 | | m_asic.dma_status &= ~0x01; |
| 1453 | | logerror("ASIC: DMA 0 address set to &%04x\n",m_asic.dma_addr[0]); |
| 1454 | | break; |
| 1455 | | case 0x0c04: |
| 1456 | | case 0x0c05: |
| 1457 | | m_asic.dma_addr[1] = (m_asic.ram[0x2c05] << 8) + m_asic.ram[0x2c04]; |
| 1458 | | m_asic.dma_status &= ~0x02; |
| 1459 | | logerror("ASIC: DMA 1 address set to &%04x\n",m_asic.dma_addr[1]); |
| 1460 | | break; |
| 1461 | | case 0x0c08: |
| 1462 | | case 0x0c09: |
| 1463 | | m_asic.dma_addr[2] = (m_asic.ram[0x2c09] << 8) + m_asic.ram[0x2c08]; |
| 1464 | | m_asic.dma_status &= ~0x04; |
| 1465 | | logerror("ASIC: DMA 2 address set to &%04x\n",m_asic.dma_addr[2]); |
| 1466 | | break; |
| 1467 | | case 0x0c02: |
| 1468 | | m_asic.dma_prescaler[0] = data + 1; |
| 1469 | | logerror("ASIC: DMA 0 pause prescaler set to %i\n",data); |
| 1470 | | break; |
| 1471 | | case 0x0c06: |
| 1472 | | m_asic.dma_prescaler[1] = data + 1; |
| 1473 | | logerror("ASIC: DMA 1 pause prescaler set to %i\n",data); |
| 1474 | | break; |
| 1475 | | case 0x0c0a: |
| 1476 | | m_asic.dma_prescaler[2] = data + 1; |
| 1477 | | logerror("ASIC: DMA 2 pause prescaler set to %i\n",data); |
| 1478 | | break; |
| 1479 | | case 0x0c0f: |
| 1480 | | m_asic.dma_status = data; |
| 1481 | | logerror("ASIC: DMA status write - %02x\n",data); |
| 1482 | | if(data & 0x40) |
| 1429 | if(offset == 0x0800) // Programmable raster interrupt |
| 1483 | 1430 | { |
| 1484 | | logerror("ASIC: DMA 0 IRQ acknowledge\n"); |
| 1485 | | cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE); |
| 1486 | | m_plus_irq_cause = 0x06; |
| 1487 | | m_asic.ram[0x2c0f] &= ~0x40; |
| 1431 | // logerror("ASIC: Wrote %02x to PRI\n",data); |
| 1432 | m_asic.pri = data; |
| 1488 | 1433 | } |
| 1489 | | if(data & 0x20) |
| 1434 | if(offset >= 0x0801 && offset <= 0x0803) // Split screen registers |
| 1490 | 1435 | { |
| 1491 | | logerror("ASIC: DMA 1 IRQ acknowledge\n"); |
| 1492 | | cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE); |
| 1493 | | m_plus_irq_cause = 0x06; |
| 1494 | | m_asic.ram[0x2c0f] &= ~0x20; |
| 1436 | logerror("ASIC: Split screen at line %i, address &%04x\n",m_asic.ram[0x2801],m_asic.ram[0x2803] + (m_asic.ram[0x2802] << 8)); |
| 1495 | 1437 | } |
| 1496 | | if(data & 0x10) |
| 1438 | if(offset == 0x0804) // Soft scroll register |
| 1497 | 1439 | { |
| 1498 | | logerror("ASIC: DMA 2 IRQ acknowledge\n"); |
| 1499 | | cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE); |
| 1500 | | m_plus_irq_cause = 0x06; |
| 1501 | | m_asic.ram[0x2c0f] &= ~0x10; |
| 1502 | 1440 | } |
| 1503 | | m_asic.ram[0x2c0f] = (m_asic.ram[0x2c0f] & 0xf8) | (data & 0x07); |
| 1504 | | break; |
| 1441 | if(offset == 0x0805) // Interrupt vector register (for IM 2, used by Pang) |
| 1442 | { |
| 1443 | // high 5 bits go to interrupt vector |
| 1444 | int vector; |
| 1445 | |
| 1446 | if ( m_asic.enabled ) |
| 1447 | { |
| 1448 | vector = (data & 0xf8) + (m_plus_irq_cause); |
| 1449 | device_set_input_line_vector(m_maincpu, 0, vector); |
| 1450 | logerror("ASIC: IM 2 vector write %02x, data = &%02x\n",vector,data); |
| 1451 | } |
| 1452 | m_asic.dma_clear = data & 0x01; |
| 1453 | } |
| 1454 | // DMA channels |
| 1455 | switch(offset) |
| 1456 | { |
| 1457 | case 0x0c00: |
| 1458 | case 0x0c01: |
| 1459 | m_asic.dma_addr[0] = (m_asic.ram[0x2c01] << 8) + m_asic.ram[0x2c00]; |
| 1460 | m_asic.dma_status &= ~0x01; |
| 1461 | logerror("ASIC: DMA 0 address set to &%04x\n",m_asic.dma_addr[0]); |
| 1462 | break; |
| 1463 | case 0x0c04: |
| 1464 | case 0x0c05: |
| 1465 | m_asic.dma_addr[1] = (m_asic.ram[0x2c05] << 8) + m_asic.ram[0x2c04]; |
| 1466 | m_asic.dma_status &= ~0x02; |
| 1467 | logerror("ASIC: DMA 1 address set to &%04x\n",m_asic.dma_addr[1]); |
| 1468 | break; |
| 1469 | case 0x0c08: |
| 1470 | case 0x0c09: |
| 1471 | m_asic.dma_addr[2] = (m_asic.ram[0x2c09] << 8) + m_asic.ram[0x2c08]; |
| 1472 | m_asic.dma_status &= ~0x04; |
| 1473 | logerror("ASIC: DMA 2 address set to &%04x\n",m_asic.dma_addr[2]); |
| 1474 | break; |
| 1475 | case 0x0c02: |
| 1476 | m_asic.dma_prescaler[0] = data + 1; |
| 1477 | logerror("ASIC: DMA 0 pause prescaler set to %i\n",data); |
| 1478 | break; |
| 1479 | case 0x0c06: |
| 1480 | m_asic.dma_prescaler[1] = data + 1; |
| 1481 | logerror("ASIC: DMA 1 pause prescaler set to %i\n",data); |
| 1482 | break; |
| 1483 | case 0x0c0a: |
| 1484 | m_asic.dma_prescaler[2] = data + 1; |
| 1485 | logerror("ASIC: DMA 2 pause prescaler set to %i\n",data); |
| 1486 | break; |
| 1487 | case 0x0c0f: |
| 1488 | m_asic.dma_status = data; |
| 1489 | logerror("ASIC: DMA status write - %02x\n",data); |
| 1490 | if(data & 0x40) |
| 1491 | { |
| 1492 | logerror("ASIC: DMA 0 IRQ acknowledge\n"); |
| 1493 | cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE); |
| 1494 | m_plus_irq_cause = 0x06; |
| 1495 | m_asic.ram[0x2c0f] &= ~0x40; |
| 1496 | } |
| 1497 | if(data & 0x20) |
| 1498 | { |
| 1499 | logerror("ASIC: DMA 1 IRQ acknowledge\n"); |
| 1500 | cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE); |
| 1501 | m_plus_irq_cause = 0x06; |
| 1502 | m_asic.ram[0x2c0f] &= ~0x20; |
| 1503 | } |
| 1504 | if(data & 0x10) |
| 1505 | { |
| 1506 | logerror("ASIC: DMA 2 IRQ acknowledge\n"); |
| 1507 | cputag_set_input_line(machine(), "maincpu", 0, CLEAR_LINE); |
| 1508 | m_plus_irq_cause = 0x06; |
| 1509 | m_asic.ram[0x2c0f] &= ~0x10; |
| 1510 | } |
| 1511 | m_asic.ram[0x2c0f] = (m_asic.ram[0x2c0f] & 0xf8) | (data & 0x07); |
| 1512 | break; |
| 1513 | } |
| 1505 | 1514 | } |
| 1515 | else |
| 1516 | { |
| 1517 | UINT8* RAM = (UINT8*)membank("bank12")->base(); |
| 1518 | RAM[offset] = data; |
| 1519 | } |
| 1506 | 1520 | } |
| 1507 | 1521 | |
| 1508 | 1522 | |
| 1509 | 1523 | READ8_MEMBER(amstrad_state::amstrad_plus_asic_4000_r) |
| 1510 | 1524 | { |
| 1511 | 1525 | // logerror("RAM: read from &%04x\n",offset+0x4000); |
| 1512 | | return m_asic.ram[offset]; |
| 1526 | if ( m_asic.enabled && ( m_asic.rmr2 & 0x18 ) == 0x18 ) |
| 1527 | return m_asic.ram[offset]; |
| 1528 | else |
| 1529 | { |
| 1530 | UINT8* RAM = (UINT8*)membank("bank3")->base(); |
| 1531 | return RAM[offset]; |
| 1532 | } |
| 1513 | 1533 | } |
| 1514 | 1534 | |
| 1515 | 1535 | |
| 1516 | 1536 | READ8_MEMBER(amstrad_state::amstrad_plus_asic_6000_r) |
| 1517 | 1537 | { |
| 1518 | 1538 | // logerror("RAM: read from &%04x\n",offset+0x6000); |
| 1519 | | // Analogue ports |
| 1520 | | if(offset == 0x0808) |
| 1539 | if ( m_asic.enabled && ( m_asic.rmr2 & 0x18 ) == 0x18 ) |
| 1521 | 1540 | { |
| 1522 | | return (ioport("analog1")->read() & 0x3f); |
| 1541 | // Analogue ports |
| 1542 | if(offset == 0x0808) |
| 1543 | { |
| 1544 | return (ioport("analog1")->read() & 0x3f); |
| 1545 | } |
| 1546 | if(offset == 0x0809) |
| 1547 | { |
| 1548 | return (ioport("analog2")->read() & 0x3f); |
| 1549 | } |
| 1550 | if(offset == 0x080a) |
| 1551 | { |
| 1552 | return (ioport("analog3")->read() & 0x3f); |
| 1553 | } |
| 1554 | if(offset == 0x080b) |
| 1555 | { |
| 1556 | return (ioport("analog4")->read() & 0x3f); |
| 1557 | } |
| 1558 | if(offset == 0x080c || offset == 0x080e) |
| 1559 | { |
| 1560 | return 0x3f; |
| 1561 | } |
| 1562 | if(offset == 0x080d || offset == 0x080f) |
| 1563 | { |
| 1564 | return 0x00; |
| 1565 | } |
| 1566 | #if 0 |
| 1567 | if(offset == 0x0c0f) // DMA status and control |
| 1568 | { |
| 1569 | int result = 0; |
| 1570 | if(m_plus_irq_cause == 0x00) |
| 1571 | result |= 0x40; |
| 1572 | if(m_plus_irq_cause == 0x02) |
| 1573 | result |= 0x20; |
| 1574 | if(m_plus_irq_cause == 0x04) |
| 1575 | result |= 0x10; |
| 1576 | if(m_plus_irq_cause == 0x06) |
| 1577 | result |= 0x80; |
| 1578 | return result; |
| 1579 | } |
| 1580 | #endif |
| 1581 | return m_asic.ram[offset+0x2000]; |
| 1523 | 1582 | } |
| 1524 | | if(offset == 0x0809) |
| 1583 | else |
| 1525 | 1584 | { |
| 1526 | | return (ioport("analog2")->read() & 0x3f); |
| 1585 | UINT8* RAM = (UINT8*)membank("bank4")->base(); |
| 1586 | return RAM[offset]; |
| 1527 | 1587 | } |
| 1528 | | if(offset == 0x080a) |
| 1529 | | { |
| 1530 | | return (ioport("analog3")->read() & 0x3f); |
| 1531 | | } |
| 1532 | | if(offset == 0x080b) |
| 1533 | | { |
| 1534 | | return (ioport("analog4")->read() & 0x3f); |
| 1535 | | } |
| 1536 | | if(offset == 0x080c || offset == 0x080e) |
| 1537 | | { |
| 1538 | | return 0x3f; |
| 1539 | | } |
| 1540 | | if(offset == 0x080d || offset == 0x080f) |
| 1541 | | { |
| 1542 | | return 0x00; |
| 1543 | | } |
| 1544 | | #if 0 |
| 1545 | | if(offset == 0x0c0f) // DMA status and control |
| 1546 | | { |
| 1547 | | int result = 0; |
| 1548 | | if(m_plus_irq_cause == 0x00) |
| 1549 | | result |= 0x40; |
| 1550 | | if(m_plus_irq_cause == 0x02) |
| 1551 | | result |= 0x20; |
| 1552 | | if(m_plus_irq_cause == 0x04) |
| 1553 | | result |= 0x10; |
| 1554 | | if(m_plus_irq_cause == 0x06) |
| 1555 | | result |= 0x80; |
| 1556 | | return result; |
| 1557 | | } |
| 1558 | | #endif |
| 1559 | | return m_asic.ram[offset+0x2000]; |
| 1560 | 1588 | } |
| 1561 | 1589 | |
| 1562 | 1590 | |
| r15593 | r15594 | |
| 2954 | 2982 | MACHINE_RESET( plus ) |
| 2955 | 2983 | { |
| 2956 | 2984 | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 2985 | address_space *space = state->m_maincpu->memory().space(AS_PROGRAM); |
| 2957 | 2986 | int i; |
| 2958 | 2987 | UINT8 *rom = state->memregion("maincpu")->base(); |
| 2959 | 2988 | |
| r15593 | r15594 | |
| 2986 | 3015 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 2987 | 3016 | amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default |
| 2988 | 3017 | |
| 3018 | space->install_read_handler(0x4000, 0x5fff, read8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_r),state)); |
| 3019 | space->install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_r),state)); |
| 3020 | space->install_write_handler(0x4000, 0x5fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_w),state)); |
| 3021 | space->install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_w),state)); |
| 3022 | |
| 2989 | 3023 | // multiface_init(); |
| 2990 | 3024 | machine.scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution)); |
| 2991 | 3025 | } |
| r15593 | r15594 | |
| 3000 | 3034 | MACHINE_RESET( gx4000 ) |
| 3001 | 3035 | { |
| 3002 | 3036 | amstrad_state *state = machine.driver_data<amstrad_state>(); |
| 3037 | address_space *space = state->m_maincpu->memory().space(AS_PROGRAM); |
| 3003 | 3038 | int i; |
| 3004 | 3039 | UINT8 *rom = state->memregion("maincpu")->base(); |
| 3005 | 3040 | |
| r15593 | r15594 | |
| 3032 | 3067 | AmstradCPC_GA_SetRamConfiguration(machine); |
| 3033 | 3068 | amstrad_GateArray_write(machine, 0x081); // Epyx World of Sports requires upper ROM to be enabled by default |
| 3034 | 3069 | // multiface_init(); |
| 3070 | space->install_read_handler(0x4000, 0x5fff, read8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_r),state)); |
| 3071 | space->install_read_handler(0x6000, 0x7fff, read8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_r),state)); |
| 3072 | space->install_write_handler(0x4000, 0x5fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_4000_w),state)); |
| 3073 | space->install_write_handler(0x6000, 0x7fff, write8_delegate(FUNC(amstrad_state::amstrad_plus_asic_6000_w),state)); |
| 3035 | 3074 | |
| 3036 | 3075 | machine.scheduler().timer_set( attotime::zero, FUNC(cb_set_resolution)); |
| 3037 | 3076 | } |