diff options
Diffstat (limited to 'src/mess/machine')
-rw-r--r-- | src/mess/machine/amigacd.c | 547 | ||||
-rw-r--r-- | src/mess/machine/amigacd.h | 9 | ||||
-rw-r--r-- | src/mess/machine/amigacrt.c | 464 | ||||
-rw-r--r-- | src/mess/machine/amigacrt.h | 8 | ||||
-rw-r--r-- | src/mess/machine/amigakbd.c | 67 | ||||
-rw-r--r-- | src/mess/machine/amigakbd.h | 1 |
6 files changed, 36 insertions, 1060 deletions
diff --git a/src/mess/machine/amigacd.c b/src/mess/machine/amigacd.c deleted file mode 100644 index 165ecc60c60..00000000000 --- a/src/mess/machine/amigacd.c +++ /dev/null @@ -1,547 +0,0 @@ -/*************************************************************************** - - Amiga CD-ROM controller emulation - -Notes: -Many thanks to Toni Wilen for all the help and information about the -DMAC controller. - -***************************************************************************/ - - -#include "emu.h" -#include "includes/amiga.h" -#include "amigacd.h" -#include "machine/6525tpi.h" -#include "imagedev/chd_cd.h" -#include "machine/matsucd.h" - - -#define VERBOSE_DMAC 0 - -#define LOG(x) do { if (VERBOSE_DMAC) logerror x; } while (0) - -/* constants */ -#define CD_SECTOR_TIME (1000/((300*1024)/2048)) /* 2X CDROM sector time in msec (300KBps) */ - -/*************************************************************************** - - DMAC - -***************************************************************************/ - -/* - * value to go into DAWR - */ -#define DAWR_ATZSC 3 /* according to A3000T service-manual */ - -/* - * bits defined for CNTR - */ -#define CNTR_TCEN (1<<7) /* Terminal Count Enable */ -#define CNTR_PREST (1<<6) /* Perp Reset (not implemented :-((( ) */ -#define CNTR_PDMD (1<<5) /* Perp Device Mode Select (1=SCSI,0=XT/AT) */ -#define CNTR_INTEN (1<<4) /* Interrupt Enable */ -#define CNTR_DDIR (1<<3) /* Device Direction. 1==rd host, wr to perp */ - -/* - * bits defined for ISTR - */ -#define ISTR_INTX (1<<8) /* XT/AT Interrupt pending */ -#define ISTR_INT_F (1<<7) /* Interrupt Follow */ -#define ISTR_INTS (1<<6) /* SCSI Peripheral Interrupt */ -#define ISTR_E_INT (1<<5) /* End-Of-Process Interrupt */ -#define ISTR_INT_P (1<<4) /* Interrupt Pending */ -#define ISTR_UE_INT (1<<3) /* Under-Run FIFO Error Interrupt */ -#define ISTR_OE_INT (1<<2) /* Over-Run FIFO Error Interrupt */ -#define ISTR_FF_FLG (1<<1) /* FIFO-Full Flag */ -#define ISTR_FE_FLG (1<<0) /* FIFO-Empty Flag */ - -struct dmac_data_t -{ - UINT16 istr; /* Interrupt Status Register (R) */ - UINT16 cntr; /* Control Register (RW) */ - UINT32 wtc; /* Word Transfer Count Register (RW) */ - UINT32 acr; /* Address Count Register (RW) */ - UINT16 dawr; /* DACK Width Register (W) */ - emu_timer *dma_timer; -}; - -static dmac_data_t dmac_data; - -static void check_interrupts( running_machine &machine ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - - /* if interrupts are disabled, bail */ - if ( (dmac_data.cntr & CNTR_INTEN) == 0 ) - return; - - /* if no interrupts are pending, bail */ - if ( (dmac_data.istr & ISTR_INT_P) == 0 ) - return; - - /* otherwise, generate the IRQ */ - state->amiga_custom_w(*state->m_maincpu_program_space, REG_INTREQ, 0x8000 | INTENA_PORTS, 0xffff); -} - -static TIMER_CALLBACK(dmac_dma_proc) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - while( dmac_data.wtc > 0 ) - { - UINT16 dat16; - UINT8 dat8; - - if ( matsucd_get_next_byte( &dat8 ) < 0 ) - break; - - dat16 = dat8; - - if ( matsucd_get_next_byte( &dat8 ) < 0 ) - break; - - dat16 <<= 8; - dat16 |= dat8; - - (*state->m_chip_ram_w)(state, dmac_data.acr, dat16); - - dmac_data.acr += 2; - dmac_data.wtc--; - } - - if ( dmac_data.wtc > 0 ) - { - matsucd_read_next_block(); - dmac_data.dma_timer->adjust(attotime::from_msec( CD_SECTOR_TIME )); - } - else - { - dmac_data.istr |= ISTR_INT_P | ISTR_E_INT; - check_interrupts( machine ); - } -} - -READ16_MEMBER( amiga_state::amiga_dmac_r ) -{ - offset &= 0xff; - - switch( offset ) - { - case 0x20: - { - UINT8 v = dmac_data.istr; - LOG(( "DMAC: PC=%08x - ISTR Read(%04x)\n", space.device().safe_pc(), dmac_data.istr )); - - dmac_data.istr &= ~0x0f; - return v; - } - break; - - case 0x21: - { - LOG(( "DMAC: PC=%08x - CNTR Read(%04x)\n", space.device().safe_pc(), dmac_data.cntr )); - return dmac_data.cntr; - } - break; - - case 0x40: /* wtc hi */ - { - LOG(( "DMAC: PC=%08x - WTC HI Read\n", space.device().safe_pc() )); - return (dmac_data.wtc >> 16); - } - break; - - case 0x41: /* wtc lo */ - { - LOG(( "DMAC: PC=%08x - WTC LO Read\n", space.device().safe_pc() )); - return dmac_data.wtc; - } - break; - - case 0x42: /* acr hi */ - { - LOG(( "DMAC: PC=%08x - ACR HI Read\n", space.device().safe_pc() )); - return (dmac_data.acr >> 16); - } - break; - - case 0x43: /* acr lo */ - { - LOG(( "DMAC: PC=%08x - ACR LO Read\n", space.device().safe_pc() )); - return dmac_data.acr; - } - break; - - case 0x48: /* wd33c93 SCSI expansion */ - case 0x49: - { - LOG(( "DMAC: PC=%08x - WD33C93 Read(%d)\n", space.device().safe_pc(), offset & 1 )); - return 0x00; /* Not available without SCSI expansion */ - } - break; - - case 0x50: - { - LOG(( "DMAC: PC=%08x - CDROM RESP Read\n", space.device().safe_pc() )); - return matsucd_response_r(space.machine()); - } - break; - - case 0x51: /* XT IO */ - case 0x52: - case 0x53: - { - LOG(( "DMAC: PC=%08x - XT IO Read(%d)\n", space.device().safe_pc(), (offset & 3)-1 )); - return 0xff; - } - break; - - case 0x58: /* TPI6525 */ - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - { - tpi6525_device *tpi = space.machine().device<tpi6525_device>("tpi6525"); - LOG(( "DMAC: PC=%08x - TPI6525 Read(%d)\n", space.device().safe_pc(), (offset - 0x58) )); - return tpi->read(space, offset - 0x58); - } - break; - - case 0x70: /* DMA start strobe */ - { - LOG(( "DMAC: PC=%08x - DMA Start Strobe\n", space.device().safe_pc() )); - dmac_data.dma_timer->adjust(attotime::from_msec( CD_SECTOR_TIME )); - } - break; - - case 0x71: /* DMA stop strobe */ - { - LOG(( "DMAC: PC=%08x - DMA Stop Strobe\n", space.device().safe_pc() )); - dmac_data.dma_timer->reset( ); - } - break; - - case 0x72: /* Clear IRQ strobe */ - { - LOG(( "DMAC: PC=%08x - IRQ Clear Strobe\n", space.device().safe_pc() )); - dmac_data.istr &= ~ISTR_INT_P; - } - break; - - case 0x74: /* Flush strobe */ - { - LOG(( "DMAC: PC=%08x - Flush Strobe\n", space.device().safe_pc() )); - dmac_data.istr |= ISTR_FE_FLG; - } - break; - - default: - logerror( "DMAC-READ: PC=%08x, offset = %02x\n", space.device().safe_pc(), offset ); - break; - } - - return 0; -} - -WRITE16_MEMBER( amiga_state::amiga_dmac_w ) -{ - offset &= 0xff; - - switch( offset ) - { - case 0x21: /* control write */ - { - LOG(( "DMAC: PC=%08x - CNTR Write(%04x)\n", space.device().safe_pc(), data )); - dmac_data.cntr = data; - check_interrupts(space.machine()); - } - break; - - case 0x40: /* wtc hi */ - { - LOG(( "DMAC: PC=%08x - WTC HI Write - data = %04x\n", space.device().safe_pc(), data )); - dmac_data.wtc &= 0x0000ffff; - dmac_data.wtc |= ((UINT32)data) << 16; - } - break; - - case 0x41: /* wtc lo */ - { - LOG(( "DMAC: PC=%08x - WTC LO Write - data = %04x\n", space.device().safe_pc(), data )); - dmac_data.wtc &= 0xffff0000; - dmac_data.wtc |= data; - } - break; - - case 0x42: /* acr hi */ - { - LOG(( "DMAC: PC=%08x - ACR HI Write - data = %04x\n", space.device().safe_pc(), data )); - dmac_data.acr &= 0x0000ffff; - dmac_data.acr |= ((UINT32)data) << 16; - } - break; - - case 0x43: /* acr lo */ - { - LOG(( "DMAC: PC=%08x - ACR LO Write - data = %04x\n", space.device().safe_pc(), data )); - dmac_data.acr &= 0xffff0000; - dmac_data.acr |= data; - } - break; - - case 0x47: /* dawr */ - { - LOG(( "DMAC: PC=%08x - DAWR Write - data = %04x\n", space.device().safe_pc(), data )); - dmac_data.dawr = data; - } - break; - - case 0x48: /* wd33c93 SCSI expansion */ - case 0x49: - { - LOG(( "DMAC: PC=%08x - WD33C93 Write(%d) - data = %04x\n", space.device().safe_pc(), offset & 1, data )); - /* Not available without SCSI expansion */ - } - break; - - case 0x50: - { - LOG(( "DMAC: PC=%08x - CDROM CMD Write - data = %04x\n", space.device().safe_pc(), data )); - matsucd_command_w(space.machine(), data ); - } - break; - - case 0x58: /* TPI6525 */ - case 0x59: - case 0x5A: - case 0x5B: - case 0x5C: - case 0x5D: - case 0x5E: - case 0x5F: - case 0x60: - case 0x61: - case 0x62: - case 0x63: - case 0x64: - case 0x65: - case 0x66: - case 0x67: - { - tpi6525_device *tpi = space.machine().device<tpi6525_device>("tpi6525"); - LOG(( "DMAC: PC=%08x - TPI6525 Write(%d) - data = %04x\n", space.device().safe_pc(), (offset - 0x58), data )); - tpi->write(space, offset - 0x58, data); - } - break; - - case 0x70: /* DMA start strobe */ - { - LOG(( "DMAC: PC=%08x - DMA Start Strobe\n", space.device().safe_pc() )); - dmac_data.dma_timer->adjust(attotime::from_msec( CD_SECTOR_TIME )); - } - break; - - case 0x71: /* DMA stop strobe */ - { - LOG(( "DMAC: PC=%08x - DMA Stop Strobe\n", space.device().safe_pc() )); - dmac_data.dma_timer->reset( ); - } - break; - - case 0x72: /* Clear IRQ strobe */ - { - LOG(( "DMAC: PC=%08x - IRQ Clear Strobe\n", space.device().safe_pc() )); - dmac_data.istr &= ~ISTR_INT_P; - } - break; - - case 0x74: /* Flush Strobe */ - { - LOG(( "DMAC: PC=%08x - Flush Strobe\n", space.device().safe_pc() )); - dmac_data.istr |= ISTR_FE_FLG; - } - break; - - default: - logerror( "DMAC-WRITE: PC=%08x, offset = %02x, data = %04x\n", space.device().safe_pc(), offset, data ); - break; - } -} - -/*************************************************************************** - - Autoconfig - -***************************************************************************/ - -static void dmac_install(running_machine &machine, offs_t base) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - address_space &space = *state->m_maincpu_program_space; - space.install_read_handler(base, base + 0xFFFF, read16_delegate(FUNC(amiga_state::amiga_dmac_r),state)); - space.install_write_handler(base, base + 0xFFFF, write16_delegate(FUNC(amiga_state::amiga_dmac_w),state)); -} - -static void dmac_uninstall(running_machine &machine, offs_t base) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - address_space &space = *state->m_maincpu_program_space; - space.unmap_readwrite(base, base + 0xFFFF); -} - -static const amiga_autoconfig_device dmac_device = -{ - 0, /* link into free memory list */ - 0, /* ROM vector offset valid */ - 0, /* multiple devices on card */ - 1, /* number of 64k pages */ - 3, /* product number (DMAC) */ - 0, /* prefer 8MB address space */ - 0, /* can be shut up */ - 0x0202, /* manufacturers number (Commodore) */ - 0, /* serial number */ - 0, /* ROM vector offset */ - NULL, /* interrupt control read */ - NULL, /* interrupt control write */ - dmac_install, /* memory installation */ - dmac_uninstall /* memory uninstallation */ -}; - -/*************************************************************************** - - TPI6525 - -***************************************************************************/ - -READ8_MEMBER( amiga_state::amigacd_tpi6525_portc_r ) -{ - int ret = 0; - - tpi6525_device *tpi = space.machine().device<tpi6525_device>("tpi6525"); - - if ( (tpi->get_ddr_c() & 0x04) == 0 ) /* if pin 2 is set to input */ - { - ret |= matsucd_stch_r() ? 0x00 : 0x04; /* read status change signal */ - } - - if ( (tpi->get_ddr_c() & 0x08) == 0 ) /* if pin 3 is set to input */ - ret |= matsucd_sten_r() ? 0x08 : 0x00; /* read enable signal */ - - return ret; -} - -WRITE8_MEMBER( amiga_state::amigacd_tpi6525_portb_w ) -{ - tpi6525_device *tpi = space.machine().device<tpi6525_device>("tpi6525"); - - if ( tpi->get_ddr_b() & 0x01 ) /* if pin 0 is set to output */ - matsucd_cmd_w( data & 1 ); /* write to the /CMD signal */ - - if ( tpi->get_ddr_b() & 0x02 ) /* if pin 1 is set to output */ - matsucd_enable_w( data & 2 ); /* write to the /ENABLE signal */ -} - -static emu_timer *tp6525_delayed_timer; - -static TIMER_CALLBACK(tp6525_delayed_irq) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - (void)param; - - if ( (CUSTOM_REG(REG_INTREQ) & INTENA_PORTS) == 0 ) - { - state->amiga_custom_w(*state->m_maincpu_program_space, REG_INTREQ, 0x8000 | INTENA_PORTS, 0xffff); - } - else - { - tp6525_delayed_timer->adjust(attotime::from_msec(1)); - } -} - -static void amigacd_tpi6525_irq_trampoline(device_t *device, int level) -{ - amiga_state *state = device->machine().driver_data<amiga_state>(); - LOG(( "TPI6525 Interrupt: level = %d\n", level )); - - if ( level ) - { - if ( (CUSTOM_REG(REG_INTREQ) & INTENA_PORTS) == 0 ) - { - state->amiga_custom_w(*state->m_maincpu_program_space, REG_INTREQ, 0x8000 | INTENA_PORTS, 0xffff); - } - else - { - /* we *have to* deliver the irq, so if we can't, delay it and try again later */ - tp6525_delayed_timer->adjust(attotime::from_msec(1)); - } - } -} - -WRITE_LINE_MEMBER( amiga_state::amigacd_tpi6525_irq ) -{ - tpi6525_device *tpi = machine().device<tpi6525_device>("tpi6525"); - - amigacd_tpi6525_irq_trampoline(tpi, state); -} - -static void cdrom_status_enabled( running_machine &machine, int level ) -{ - tpi6525_device *tpi = machine.device<tpi6525_device>("tpi6525"); - - /* PC3 on the 6525 */ - tpi->i3_w(level); -} - -static void cdrom_status_change( running_machine &machine, int level ) -{ - tpi6525_device *tpi = machine.device<tpi6525_device>("tpi6525"); - - /* invert */ - level = level ? 0 : 1; - - /* PC2 on the 6525 */ - tpi->i2_w(level); -} - -static void cdrom_subcode_ready( running_machine &machine, int level ) -{ - tpi6525_device *tpi = machine.device<tpi6525_device>("tpi6525"); - - /* PC1 on the 6525 */ - tpi->i1_w(level); -} - -void amigacd_start(running_machine &machine) -{ - /* initialize the dmac */ - memset( &dmac_data, 0, sizeof( dmac_data ) ); - - dmac_data.dma_timer = machine.scheduler().timer_alloc(FUNC(dmac_dma_proc)); - tp6525_delayed_timer = machine.scheduler().timer_alloc(FUNC(tp6525_delayed_irq)); - - /* set up DMAC with autoconfig */ - amiga_add_autoconfig( machine, &dmac_device ); - - matsucd_init( machine.device<cdrom_image_device>("cdrom"), "cdda" ); -} - -void amigacd_reset(running_machine &machine) -{ - /* initialize the cdrom */ - matsucd_set_status_enabled_callback( cdrom_status_enabled ); - matsucd_set_status_changed_callback( cdrom_status_change ); - matsucd_set_subcode_ready_callback( cdrom_subcode_ready ); -} diff --git a/src/mess/machine/amigacd.h b/src/mess/machine/amigacd.h deleted file mode 100644 index 5cc820ef2a1..00000000000 --- a/src/mess/machine/amigacd.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef __AMIGACD_H__ -#define __AMIGACD_H__ - - -void amigacd_start(running_machine &machine); -void amigacd_reset(running_machine &machine); - - -#endif /* __AMIGACD_H__ */ diff --git a/src/mess/machine/amigacrt.c b/src/mess/machine/amigacrt.c deleted file mode 100644 index dd1ab1bed0d..00000000000 --- a/src/mess/machine/amigacrt.c +++ /dev/null @@ -1,464 +0,0 @@ -/*************************************************************************** - - Amiga cartridge emulation - -TODO: -- Investigate why the AR2/3 sometimes garble the video on exit from the cart -- Add Nordic Power and similar carts -- Add HRTMon A1200 cart - -***************************************************************************/ - - -#include "emu.h" -#include "includes/amiga.h" -#include "cpu/m68000/m68000.h" -#include "machine/amigacrt.h" - -enum -{ - /* supported cartridges */ - ACTION_REPLAY = 0, - ACTION_REPLAY_MKII, - ACTION_REPLAY_MKIII -}; - -struct amigacrt_t -{ - int cart_type; - int ar1_spurious; - UINT16 ar23_mode; -}; -static amigacrt_t amigacrt; - -/*************************************************************************** - - Utilities - -***************************************************************************/ - -static int check_kickstart_12_13( running_machine &machine, const char *cart_name ) -{ - UINT16 * ksmem = (UINT16 *)(*machine.root_device().memregion( "user1" )); - - if ( ksmem[2] == 0x00FC ) - return 1; - - logerror( "%s requires Kickstart version 1.2 or 1.3 - Cart not installed\n", cart_name ); - - return 0; -} - -/*************************************************************************** - - Amiga Action Replay 1 - - Whenever you push the button, an NMI interrupt is generated. - - The cartridge protects itself from being removed from memory by - generating an interrupt whenever either the spurious interrupt - vector is written at $60, or the nmi interrupt vector is written at - $7c. If the spurious interrupt vector at $60 is written, then - a NMI is generated, and the spurious irq vector is restored. If the - NMI vector at $7c is written, then a spurious interrupt is generated, - and the NMI vector is restored. - - When breakpoints are set, the target address is replaced by a trap - instruction, and the original contents of the address are kept in - the cartridge's RAM. A trap handler is installed pointing to $40 - in RAM, where code that clears memory address $60 followed by two - nops are written. There seems to be a small delay between the write - to $60 and until the actual NMI is generated, since the cart expects - the PC to be at $46 (at the second nop). - -***************************************************************************/ - -IRQ_CALLBACK_MEMBER(amiga_state::amiga_ar1_irqack) -{ - if ( irqline == 7 && amigacrt.ar1_spurious ) - { - return M68K_INT_ACK_SPURIOUS; - } - - return (24+irqline); -} - -static TIMER_CALLBACK( amiga_ar1_delayed_nmi ) -{ - (void)param; - machine.device("maincpu")->execute().set_input_line(7, PULSE_LINE); -} - -static void amiga_ar1_nmi( running_machine &machine ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - /* get the cart's built-in ram */ - UINT16 *ar_ram = (UINT16 *)(state->m_maincpu_program_space->get_write_ptr(0x9fc000)); - - if ( ar_ram != NULL ) - { - int i; - - /* copy custom register values */ - for( i = 0; i < 256; i++ ) - ar_ram[0x1800+i] = CUSTOM_REG(i); - - /* trigger NMI irq */ - amigacrt.ar1_spurious = 0; - machine.scheduler().timer_set(machine.device<cpu_device>("maincpu")->cycles_to_attotime(28), FUNC(amiga_ar1_delayed_nmi)); - } -} - -WRITE16_MEMBER( amiga_state::amiga_ar1_chipmem_w ) -{ - int pc = space.device().safe_pc(); - - /* see if we're inside the AR1 rom */ - if ( ((pc >> 16) & 0xff ) != 0xf0 ) - { - /* if we're not, see if either the Spurious IRQ vector - or the NMI vector are being overwritten */ - if ( offset == (0x60/2) || offset == (0x7c/2) ) - { - /* trigger an NMI or spurious irq */ - amigacrt.ar1_spurious = (offset == 0x60/2) ? 0 : 1; - space.machine().scheduler().timer_set(space.machine().device<cpu_device>("maincpu")->cycles_to_attotime(28), FUNC(amiga_ar1_delayed_nmi)); - } - } - - (*m_chip_ram_w)(this, offset * 2, data ); -} - -static void amiga_ar1_check_overlay( running_machine &machine ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - - state->m_maincpu_program_space->install_write_handler(0x000000, 0x00007f, write16_delegate(FUNC(amiga_state::amiga_ar1_chipmem_w),state)); -} - -static void amiga_ar1_init( running_machine &machine ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - void *ar_ram; - - /* check kickstart version */ - if ( !check_kickstart_12_13( machine, "Amiga Action Replay" ) ) - { - amigacrt.cart_type = -1; - return; - } - - /* setup the cart ram */ - ar_ram = auto_alloc_array(machine, UINT8, 0x4000); - memset(ar_ram, 0, 0x4000); - - /* Install ROM */ - state->m_maincpu_program_space->install_read_bank(0xf00000, 0xf7ffff, "bank2"); - state->m_maincpu_program_space->unmap_write(0xf00000, 0xf7ffff); - - /* Install RAM */ - state->m_maincpu_program_space->install_readwrite_bank(0x9fc000, 0x9fffff, "bank3"); - - /* Configure Banks */ - state->membank("bank2")->set_base(machine.root_device().memregion("user2")->base()); - state->membank("bank3")->set_base(ar_ram); - - amigacrt.ar1_spurious = 0; - - /* Install IRQ ACK callback */ - device_execute_interface::static_set_irq_acknowledge_callback(*machine.device<cpu_device>("maincpu"), device_irq_acknowledge_delegate(FUNC(amiga_state::amiga_ar1_irqack), state)); -} - -/*************************************************************************** - - Amiga Action Replay MKII/MKIII - - Whenever you push the button, an overlay of the cartridge appears - in RAM and an NMI interrupt is generated. Only reads are overlayed. - Writes go directly to chipmem (so that the CPU can write the stack - information for the NMI). Once the interrupt is taken, the cart - disables the ROM overlay and checks it's internal mode register - to see why it was invoked. - - When a breakpoint is set the cart replaces the target instruction - with a trap, and adds a trap handler that it locates in the $100-$120 - area. The handler simply has one instruction: TST.B $BFE001. This cia - access is monitored, and the conditions match (PC < 120 and a previous - command requested the monitoring of the cia) then the cart is invoked. - -***************************************************************************/ - -static void amiga_ar23_freeze( running_machine &machine ); - -READ16_MEMBER( amiga_state::amiga_ar23_cia_r ) -{ - int pc = space.device().safe_pc(); - - if ( ACCESSING_BITS_0_7 && offset == 2048 && pc >= 0x40 && pc < 0x120 ) - { - amiga_ar23_freeze(space.machine()); - } - - return amiga_cia_r( space, offset, mem_mask ); -} - -WRITE16_MEMBER( amiga_state::amiga_ar23_mode_w ) -{ - if ( data & 2 ) - { - space.install_read_handler(0xbfd000, 0xbfefff, read16_delegate(FUNC(amiga_state::amiga_ar23_cia_r), this)); - } - else - { - space.install_read_handler(0xbfd000, 0xbfefff, read16_delegate(FUNC(amiga_state::amiga_cia_r), this)); - } - - amigacrt.ar23_mode = (data&0x3); - if ( amigacrt.ar23_mode == 0 ) - amigacrt.ar23_mode = 1; - -} - -READ16_MEMBER( amiga_state::amiga_ar23_mode_r ) -{ - amiga_state *state = space.machine().driver_data<amiga_state>(); - UINT16 *mem = (UINT16 *)(*state->memregion( "user2" )); - - if ( ACCESSING_BITS_0_7 ) - { - if ( offset < 2 ) - return (mem[offset] | (amigacrt.ar23_mode&3)); - - if ( offset == 0x03 ) /* disable cart overlay on chip mem */ - { - UINT32 mirror_mask = state->m_chip_ram.bytes(); - - state->membank("bank1")->set_entry(0); - - while( (mirror_mask<<1) < 0x100000 ) - { - mirror_mask |= ( mirror_mask << 1 ); - } - - /* overlay disabled, map RAM on 0x000000 */ - space.install_write_bank(0x000000, state->m_chip_ram.bytes() - 1, 0, mirror_mask, "bank1"); - } - } - - return mem[offset]; -} - -WRITE16_MEMBER( amiga_state::amiga_ar23_chipmem_w ) -{ - if ( offset == (0x08/2) ) - { - if ( amigacrt.ar23_mode & 1 ) - amiga_ar23_freeze(space.machine()); - } - - (*m_chip_ram_w)(this, offset * 2, data ); -} - -static void amiga_ar23_freeze( running_machine &machine ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - int pc = machine.device("maincpu")->safe_pc(); - - /* only freeze if we're not inside the cart's ROM */ - if ( ((pc >> 16) & 0xfe ) != 0x40 ) - { - /* get the cart's built-in ram */ - UINT16 *ar_ram = (UINT16 *)state->m_maincpu_program_space->get_write_ptr(0x440000); - - if ( ar_ram != NULL ) - { - int i; - - for( i = 0; i < 0x100; i++ ) - ar_ram[0x7800+i] = CUSTOM_REG(i); - } - - /* overlay the cart rom's in chipram */ - state->membank("bank1")->set_entry(2); - - /* writes go to chipram */ - state->m_maincpu_program_space->install_write_handler(0x000000, state->m_chip_ram.bytes() - 1, write16_delegate(FUNC(amiga_state::amiga_ar23_chipmem_w),state)); - - /* trigger NMI irq */ - machine.device("maincpu")->execute().set_input_line(7, PULSE_LINE); - } -} - -static void amiga_ar23_nmi( running_machine &machine ) -{ - amigacrt.ar23_mode = 0; - amiga_ar23_freeze(machine); -} - -#if 0 -static WRITE16_HANDLER( amiga_ar23_custom_w ) -{ - int pc = space.device().safe_pc(); - - /* see if we're inside the AR2 rom */ - if ( ((pc >> 16) & 0xfe ) != 0x40 ) - { - /* get the cart's built-in ram */ - UINT16 *ar_ram = (UINT16 *)memory_get_write_ptr(0, AS_PROGRAM, 0x440000); - - if ( ar_ram != NULL ) - { - ar_ram[0x7800+offset] = data; - } - } - - amiga_custom_w( offset, data, mem_mask ); -} - -static READ16_HANDLER( amiga_ar23_custom_r ) -{ - UINT16 data = amiga_custom_r( offset, mem_mask ); - - int pc = space.device().safe_pc(); - - /* see if we're inside the AR2 rom */ - if ( ((pc >> 16) & 0xfe ) != 0x40 ) - { - /* get the cart's built-in ram */ - UINT16 *ar_ram = (UINT16 *)memory_get_write_ptr(0, AS_PROGRAM, 0x440000); - - if ( ar_ram != NULL ) - { - ar_ram[0x7800+offset] = data; - } - } - - return data; -} -#endif - -static void amiga_ar23_check_overlay( running_machine &machine ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - amigacrt.ar23_mode = 3; - state->m_maincpu_program_space->install_write_handler(0x000000, 0x00000f, write16_delegate(FUNC(amiga_state::amiga_ar23_chipmem_w),state)); -} - -void amiga_state::amiga_ar23_init( running_machine &machine, int ar3 ) -{ - amiga_state *state = machine.driver_data<amiga_state>(); - UINT32 mirror = 0x20000, size = 0x1ffff; - void *ar_ram; - - /* check kickstart version */ - if ( !check_kickstart_12_13( machine, "Action Replay MKII or MKIII" ) ) - { - amigacrt.cart_type = -1; - return; - } - - /* setup the cart ram */ - ar_ram = auto_alloc_array_clear(machine, UINT8,0x10000); - - if ( ar3 ) - { - mirror = 0; - size = 0x3ffff; - } - - /* Install ROM */ - state->m_maincpu_program_space->install_read_bank(0x400000, 0x400000+size, 0, mirror, "bank2"); - state->m_maincpu_program_space->unmap_write(0x400000, 0x400000+size, 0, mirror); - - /* Install RAM */ - state->m_maincpu_program_space->install_read_bank(0x440000, 0x44ffff, "bank3"); - state->m_maincpu_program_space->install_write_bank(0x440000, 0x44ffff, "bank3"); - - /* Install Custom chip monitor */ -// state->m_maincpu_program_space->install_legacy_read_handler(0xdff000, 0xdff1ff, FUNC(amiga_ar23_custom_r)); -// state->m_maincpu_program_space->install_legacy_write_handler(0xdff000, 0xdff1ff, FUNC(amiga_ar23_custom_w)); - - /* Install status/mode handlers */ - state->m_maincpu_program_space->install_read_handler( 0x400000, 0x400007, 0, mirror, read16_delegate( FUNC(amiga_state::amiga_ar23_mode_r), this)); - state->m_maincpu_program_space->install_write_handler(0x400000, 0x400003, 0, mirror, write16_delegate(FUNC(amiga_state::amiga_ar23_mode_w), this)); - - /* Configure Banks */ - state->membank("bank2")->set_base(machine.root_device().memregion("user2")->base()); - state->membank("bank3")->set_base(ar_ram); - - state->membank("bank1")->configure_entries(0, 2, state->m_chip_ram, 0); - state->membank("bank1")->configure_entries(1, 2, machine.root_device().memregion("user1")->base(), 0); - state->membank("bank1")->configure_entries(2, 2, machine.root_device().memregion("user2")->base(), 0); - - amigacrt.ar23_mode = 3; -} - -/*************************************************************************** - - MAME/MESS hooks - -***************************************************************************/ - -void amiga_cart_init( running_machine &machine ) -{ - /* see what is there */ - UINT16 *mem = (UINT16 *)(*machine.root_device().memregion( "user2" )); - amiga_state *state = machine.driver_data<amiga_state>(); - - amigacrt.cart_type = -1; - - if ( mem != NULL ) - { - if ( mem[0x00] == 0x1111 ) - { - amigacrt.cart_type = ACTION_REPLAY; - amiga_ar1_init(machine); - } - else if ( mem[0x0C] == 0x4D6B ) - { - amigacrt.cart_type = ACTION_REPLAY_MKII; - state->amiga_ar23_init(machine, 0); - } - else if ( mem[0x0C] == 0x4D4B ) - { - amigacrt.cart_type = ACTION_REPLAY_MKIII; - state->amiga_ar23_init(machine, 1); - } - } -} - -void amiga_cart_check_overlay( running_machine &machine ) -{ - if ( amigacrt.cart_type < 0 ) - return; - - switch( amigacrt.cart_type ) - { - case ACTION_REPLAY: - amiga_ar1_check_overlay(machine); - break; - - case ACTION_REPLAY_MKII: - case ACTION_REPLAY_MKIII: - amiga_ar23_check_overlay(machine); - break; - } -} - -void amiga_cart_nmi( running_machine &machine ) -{ - if ( amigacrt.cart_type < 0 ) - return; - - switch( amigacrt.cart_type ) - { - case ACTION_REPLAY: - amiga_ar1_nmi(machine); - break; - - case ACTION_REPLAY_MKII: - case ACTION_REPLAY_MKIII: - amiga_ar23_nmi(machine); - break; - } -} diff --git a/src/mess/machine/amigacrt.h b/src/mess/machine/amigacrt.h deleted file mode 100644 index 6e603ed8b98..00000000000 --- a/src/mess/machine/amigacrt.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef AMIGACRT_H -#define AMIGACRT_H - -void amiga_cart_init( running_machine &machine ); -void amiga_cart_check_overlay( running_machine &machine ); -void amiga_cart_nmi( running_machine &machine ); - -#endif /* AMIGACRT_H */ diff --git a/src/mess/machine/amigakbd.c b/src/mess/machine/amigakbd.c index 5bd49545dab..f8f103e5cb2 100644 --- a/src/mess/machine/amigakbd.c +++ b/src/mess/machine/amigakbd.c @@ -21,7 +21,11 @@ const device_type AMIGAKBD = &device_creator<amigakbd_device>; amigakbd_device::amigakbd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : device_t(mconfig, AMIGAKBD, "Amiga Keyboard", tag, owner, clock, "amigakbd", __FILE__), m_write_kclk(*this), - m_write_kdat(*this) + m_write_kdat(*this), + m_buf(NULL), + m_buf_pos(0), + m_cur_pos(0), + m_timer(NULL) { } @@ -36,8 +40,6 @@ void amigakbd_device::device_start() /* allocate a keyboard buffer */ m_buf = auto_alloc_array(machine(), UINT8, KEYBOARD_BUFFER_SIZE); - m_buf_pos = 0; - m_cur_pos = 0; m_timer = timer_alloc(0); m_timer->reset(); } @@ -82,46 +84,33 @@ void amigakbd_device::device_timer(emu_timer &timer, device_timer_id id, int par } } -INPUT_CHANGED_MEMBER(amigakbd_device::kbd_update) +INPUT_CHANGED_MEMBER( amigakbd_device::kbd_update ) { int index = (int)(FPTR)param, i; UINT32 oldvalue = oldval * field.mask(), newvalue = newval * field.mask(); UINT32 delta = oldvalue ^ newvalue; - /* Special case Page UP, which we will use as Action Replay button */ - if ( (index == 3) && ( delta & 0x80000000 ) && ( newvalue & 0x80000000 ) ) - { - const amiga_machine_interface *amiga_intf = amiga_get_interface(machine()); + int key_buf_was_empty = ( m_buf_pos == m_cur_pos ) ? 1 : 0; - if ( amiga_intf != NULL && amiga_intf->nmi_callback ) - { - (*amiga_intf->nmi_callback)(machine()); - } - } - else + for( i = 0; i < 32; i++ ) { - int key_buf_was_empty = ( m_buf_pos == m_cur_pos ) ? 1 : 0; - - for( i = 0; i < 32; i++ ) + if ( delta & ( 1 << i ) ) { - if ( delta & ( 1 << i ) ) - { - int down = ( newvalue & ( 1 << i ) ) ? 0 : 1; - int scancode = ( ( (index*32)+i ) << 1 ) | down; - int amigacode = ~scancode; - - /* add the keycode to the buffer */ - m_buf[m_buf_pos++] = amigacode & 0xff; - m_buf_pos %= KEYBOARD_BUFFER_SIZE; - } - } + int down = ( newvalue & ( 1 << i ) ) ? 0 : 1; + int scancode = ( ( (index*32)+i ) << 1 ) | down; + int amigacode = ~scancode; - /* if the buffer was empty and we have new data, start a timer to send the keystrokes */ - if ( key_buf_was_empty && ( m_buf_pos != m_cur_pos ) ) - { - m_timer->adjust(machine().first_screen()->frame_period() / 4); + /* add the keycode to the buffer */ + m_buf[m_buf_pos++] = amigacode & 0xff; + m_buf_pos %= KEYBOARD_BUFFER_SIZE; } } + + /* if the buffer was empty and we have new data, start a timer to send the keystrokes */ + if ( key_buf_was_empty && ( m_buf_pos != m_cur_pos ) ) + { + m_timer->adjust(machine().first_screen()->frame_period() / 4); + } } /*********************************************************************************************/ @@ -274,3 +263,17 @@ ioport_constructor amigakbd_device::device_input_ports() const { return INPUT_PORTS_NAME( amiga_us_keyboard ); } + +//------------------------------------------------- +// rom_region - device-specific ROM region +//------------------------------------------------- + +ROM_START( keyboard_mpu ) + ROM_REGION(0x800, "keyboard", 0) + ROM_LOAD("328191-01.ic1", 0x000, 0x800, NO_DUMP) +ROM_END + +const rom_entry *amigakbd_device::device_rom_region() const +{ + return ROM_NAME( keyboard_mpu ); +} diff --git a/src/mess/machine/amigakbd.h b/src/mess/machine/amigakbd.h index 904e3c61350..bec639c6c35 100644 --- a/src/mess/machine/amigakbd.h +++ b/src/mess/machine/amigakbd.h @@ -30,6 +30,7 @@ public: // optional information overrides virtual ioport_constructor device_input_ports() const; + virtual const rom_entry *device_rom_region() const; DECLARE_INPUT_CHANGED_MEMBER( kbd_update ); |