trunk/src/mess/machine/pf10.c
| r18806 | r18807 | |
| 1 | | /*************************************************************************** |
| 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | Epson PF-10 |
| 3 | EPSON PF-10 |
| 4 | 4 | |
| 5 | | Serial floppy drive |
| 5 | Battery operated portable 3.5" floppy drive |
| 6 | 6 | |
| 7 | | Skeleton driver, not working |
| 7 | Status: Skeleton driver, not doing much. |
| 8 | 8 | |
| 9 | | ***************************************************************************/ |
| 9 | Copyright MESS Team. |
| 10 | Visit http://mamedev.org for licensing and usage restrictions. |
| 10 | 11 | |
| 11 | | #include "emu.h" |
| 12 | **********************************************************************/ |
| 13 | |
| 12 | 14 | #include "pf10.h" |
| 13 | | #include "cpu/m6800/m6800.h" |
| 14 | | #include "machine/upd765.h" |
| 15 | 15 | |
| 16 | 16 | |
| 17 | | /*************************************************************************** |
| 18 | | TYPE DEFINITIONS |
| 19 | | ***************************************************************************/ |
| 17 | //************************************************************************** |
| 18 | // DEVICE DEFINITIONS |
| 19 | //************************************************************************** |
| 20 | 20 | |
| 21 | | struct pf10_state |
| 22 | | { |
| 23 | | UINT8 dummy; |
| 24 | | }; |
| 21 | const device_type EPSON_PF10 = &device_creator<epson_pf10_device>; |
| 25 | 22 | |
| 26 | 23 | |
| 27 | | /***************************************************************************** |
| 28 | | INLINE FUNCTIONS |
| 29 | | *****************************************************************************/ |
| 24 | //------------------------------------------------- |
| 25 | // address maps |
| 26 | //------------------------------------------------- |
| 30 | 27 | |
| 31 | | INLINE pf10_state *get_safe_token(device_t *device) |
| 32 | | { |
| 33 | | assert(device != NULL); |
| 34 | | assert(device->type() == PF10); |
| 35 | | |
| 36 | | return (pf10_state *)downcast<pf10_device *>(device)->token(); |
| 37 | | } |
| 38 | | |
| 39 | | |
| 40 | | /***************************************************************************** |
| 41 | | ADDRESS MAPS |
| 42 | | *****************************************************************************/ |
| 43 | | |
| 44 | | static ADDRESS_MAP_START( pf10_mem, AS_PROGRAM, 8, pf10_device ) |
| 45 | | AM_RANGE(0x0040, 0x013f) AM_RAM /* internal ram */ |
| 28 | static ADDRESS_MAP_START( cpu_mem, AS_PROGRAM, 8, epson_pf10_device ) |
| 29 | AM_RANGE(0x0000, 0x001f) AM_READWRITE_LEGACY(m6801_io_r, m6801_io_w) |
| 30 | AM_RANGE(0x0040, 0x00ff) AM_RAM /* 192 bytes internal ram */ |
| 46 | 31 | AM_RANGE(0x0800, 0x0fff) AM_RAM /* external 2k ram */ |
| 47 | | AM_RANGE(0xe000, 0xffff) AM_ROM AM_REGION("pf10", 0) |
| 32 | AM_RANGE(0xe000, 0xffff) AM_ROM AM_REGION("maincpu", 0) |
| 48 | 33 | ADDRESS_MAP_END |
| 49 | 34 | |
| 50 | | static ADDRESS_MAP_START( pf10_io, AS_IO, 8, pf10_device ) |
| 35 | static ADDRESS_MAP_START( cpu_io, AS_IO, 8, epson_pf10_device ) |
| 51 | 36 | ADDRESS_MAP_UNMAP_HIGH |
| 52 | 37 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 53 | 38 | ADDRESS_MAP_END |
| 54 | 39 | |
| 55 | 40 | |
| 56 | | /***************************************************************************** |
| 57 | | MACHINE CONFIG |
| 58 | | *****************************************************************************/ |
| 41 | //------------------------------------------------- |
| 42 | // rom_region - device-specific ROM region |
| 43 | //------------------------------------------------- |
| 59 | 44 | |
| 60 | | static MACHINE_CONFIG_FRAGMENT( pf10 ) |
| 61 | | MCFG_CPU_ADD("pf10", M6803, XTAL_2_4576MHz / 4 /* ??? */) /* HD63A03 */ |
| 62 | | MCFG_CPU_PROGRAM_MAP(pf10_mem) |
| 63 | | MCFG_CPU_IO_MAP(pf10_io) |
| 64 | | |
| 65 | | MCFG_UPD765A_ADD("upd765a", false, true) |
| 66 | | MACHINE_CONFIG_END |
| 67 | | |
| 68 | | |
| 69 | | /*************************************************************************** |
| 70 | | ROM DEFINITIONS |
| 71 | | ***************************************************************************/ |
| 72 | | |
| 73 | 45 | ROM_START( pf10 ) |
| 74 | | ROM_REGION(0x2000, "pf10", 0) |
| 46 | ROM_REGION(0x2000, "maincpu", 0) |
| 75 | 47 | ROM_LOAD("k3pf1.bin", 0x0000, 0x2000, CRC(eef4593a) SHA1(bb176e4baf938fe58c2d32f7c46d7bb7b0627755)) |
| 76 | 48 | ROM_END |
| 77 | 49 | |
| 78 | | |
| 79 | | /***************************************************************************** |
| 80 | | DEVICE INTERFACE |
| 81 | | *****************************************************************************/ |
| 82 | | |
| 83 | | static DEVICE_START( pf10 ) |
| 50 | const rom_entry *epson_pf10_device::device_rom_region() const |
| 84 | 51 | { |
| 85 | | pf10_state *pf10 = get_safe_token(device); |
| 86 | | |
| 87 | | pf10->dummy = 0; |
| 52 | return ROM_NAME( pf10 ); |
| 88 | 53 | } |
| 89 | 54 | |
| 90 | | static DEVICE_RESET( pf10 ) |
| 91 | | { |
| 92 | | } |
| 93 | 55 | |
| 94 | | /*************************************************************************** |
| 95 | | IMPLEMENTATION |
| 96 | | ***************************************************************************/ |
| 56 | //------------------------------------------------- |
| 57 | // machine_config_additions - device-specific |
| 58 | // machine configurations |
| 59 | //------------------------------------------------- |
| 97 | 60 | |
| 98 | | /* serial interface in (to the host computer) */ |
| 99 | | READ_LINE_DEVICE_HANDLER( pf10_txd1_r ) |
| 61 | static const floppy_format_type pf10_floppy_formats[] = |
| 100 | 62 | { |
| 101 | | logerror("%s: pf10_txd1_r\n", device->machine().describe_context()); |
| 63 | FLOPPY_D88_FORMAT, |
| 64 | FLOPPY_MFM_FORMAT, |
| 65 | FLOPPY_MFI_FORMAT, |
| 66 | NULL |
| 67 | }; |
| 102 | 68 | |
| 103 | | return 0; |
| 104 | | } |
| 69 | static SLOT_INTERFACE_START( pf10_floppies ) |
| 70 | SLOT_INTERFACE( "35dd", FLOPPY_35_DD ) |
| 71 | SLOT_INTERFACE_END |
| 105 | 72 | |
| 106 | | WRITE_LINE_DEVICE_HANDLER( pf10_rxd1_w ) |
| 107 | | { |
| 108 | | logerror("%s: pf10_rxd1_w %u\n", device->machine().describe_context(), state); |
| 109 | | } |
| 73 | static MACHINE_CONFIG_FRAGMENT( pf10 ) |
| 74 | MCFG_CPU_ADD("maincpu", HD6303Y, XTAL_2_4576MHz / 4 /* ??? */) // HD63A03XF |
| 75 | MCFG_CPU_PROGRAM_MAP(cpu_mem) |
| 76 | MCFG_CPU_IO_MAP(cpu_io) |
| 110 | 77 | |
| 78 | MCFG_UPD765A_ADD("upd765a", false, true) |
| 79 | MCFG_FLOPPY_DRIVE_ADD("upd765a:0", pf10_floppies, "35dd", 0, pf10_floppy_formats) // SMD-165 |
| 111 | 80 | |
| 112 | | /* serial interface out (to another floppy drive) */ |
| 113 | | READ_LINE_DEVICE_HANDLER( pf10_txd2_r ) |
| 114 | | { |
| 115 | | logerror("%s: pf10_txd2_r\n", device->machine().describe_context()); |
| 81 | MCFG_EPSON_SIO_ADD("sio") |
| 82 | MACHINE_CONFIG_END |
| 116 | 83 | |
| 117 | | return 0; |
| 118 | | } |
| 119 | | |
| 120 | | WRITE_LINE_DEVICE_HANDLER( pf10_rxd2_w ) |
| 84 | machine_config_constructor epson_pf10_device::device_mconfig_additions() const |
| 121 | 85 | { |
| 122 | | logerror("%s: pf10_rxd2_w %u\n", device->machine().describe_context(), state); |
| 86 | return MACHINE_CONFIG_NAME( pf10 ); |
| 123 | 87 | } |
| 124 | 88 | |
| 125 | | const device_type PF10 = &device_creator<pf10_device>; |
| 126 | 89 | |
| 127 | | pf10_device::pf10_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 128 | | : device_t(mconfig, PF10, "PF-10", tag, owner, clock) |
| 129 | | { |
| 130 | | m_token = global_alloc_clear(pf10_state); |
| 131 | | } |
| 90 | //************************************************************************** |
| 91 | // LIVE DEVICE |
| 92 | //************************************************************************** |
| 132 | 93 | |
| 133 | 94 | //------------------------------------------------- |
| 134 | | // device_config_complete - perform any |
| 135 | | // operations now that the configuration is |
| 136 | | // complete |
| 95 | // epson_pf10_device - constructor |
| 137 | 96 | //------------------------------------------------- |
| 138 | 97 | |
| 139 | | void pf10_device::device_config_complete() |
| 98 | epson_pf10_device::epson_pf10_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 99 | device_t(mconfig, EPSON_PF10, "EPSON PF-10 floppy drive", tag, owner, clock), |
| 100 | device_epson_sio_interface(mconfig, *this), |
| 101 | m_cpu(*this, "maincpu"), |
| 102 | m_fdc(*this, "upd765a"), |
| 103 | m_sio(*this, "sio") |
| 140 | 104 | { |
| 141 | 105 | } |
| 142 | 106 | |
| 107 | |
| 143 | 108 | //------------------------------------------------- |
| 144 | 109 | // device_start - device-specific startup |
| 145 | 110 | //------------------------------------------------- |
| 146 | 111 | |
| 147 | | void pf10_device::device_start() |
| 112 | void epson_pf10_device::device_start() |
| 148 | 113 | { |
| 149 | | DEVICE_START_NAME( pf10 )(this); |
| 114 | m_floppy = subdevice<floppy_connector>("upd765a:0")->get_device(); |
| 150 | 115 | } |
| 151 | 116 | |
| 117 | |
| 152 | 118 | //------------------------------------------------- |
| 153 | | // device_reset - device-specific reset |
| 119 | // tx_w |
| 154 | 120 | //------------------------------------------------- |
| 155 | 121 | |
| 156 | | void pf10_device::device_reset() |
| 122 | void epson_pf10_device::tx_w(int level) |
| 157 | 123 | { |
| 158 | | DEVICE_RESET_NAME( pf10 )(this); |
| 124 | logerror("%s: tx_w(%d)\n", tag(), level); |
| 159 | 125 | } |
| 160 | 126 | |
| 127 | |
| 161 | 128 | //------------------------------------------------- |
| 162 | | // device_mconfig_additions - return a pointer to |
| 163 | | // the device's machine fragment |
| 129 | // pout_w |
| 164 | 130 | //------------------------------------------------- |
| 165 | 131 | |
| 166 | | machine_config_constructor pf10_device::device_mconfig_additions() const |
| 132 | void epson_pf10_device::pout_w(int level) |
| 167 | 133 | { |
| 168 | | return MACHINE_CONFIG_NAME( pf10 ); |
| 134 | logerror("%s: pout_w(%d)\n", tag(), level); |
| 169 | 135 | } |
| 170 | 136 | |
| 137 | |
| 171 | 138 | //------------------------------------------------- |
| 172 | | // device_rom_region - return a pointer to the |
| 173 | | // the device's ROM definitions |
| 139 | // rx_r |
| 174 | 140 | //------------------------------------------------- |
| 175 | 141 | |
| 176 | | const rom_entry *pf10_device::device_rom_region() const |
| 142 | int epson_pf10_device::rx_r() |
| 177 | 143 | { |
| 178 | | return ROM_NAME(pf10 ); |
| 144 | logerror("%s: rx_r\n", tag()); |
| 145 | |
| 146 | return 1; |
| 179 | 147 | } |
| 180 | 148 | |
| 181 | 149 | |
| 150 | //------------------------------------------------- |
| 151 | // pin_r |
| 152 | //------------------------------------------------- |
| 153 | |
| 154 | int epson_pf10_device::pin_r() |
| 155 | { |
| 156 | logerror("%s: pin_r\n", tag()); |
| 157 | |
| 158 | return 1; |
| 159 | } |
trunk/src/mess/machine/tf20.c
| r18806 | r18807 | |
| 1 | | /*************************************************************************** |
| 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | Epson TF-20 |
| 3 | EPSON TF-20 |
| 4 | 4 | |
| 5 | | Dual floppy drive with HX-20 factory option |
| 5 | Dual 5.25" floppy drive with HX-20 factory option |
| 6 | 6 | |
| 7 | Status: Issues with new uPD765, missing uPD7201 emulation. |
| 7 | 8 | |
| 8 | | Status: Boots from system disk, missing ??PD7201 emulation |
| 9 | Copyright MESS Team. |
| 10 | Visit http://mamedev.org for licensing and usage restrictions. |
| 9 | 11 | |
| 10 | | ***************************************************************************/ |
| 12 | **********************************************************************/ |
| 11 | 13 | |
| 12 | | #include "emu.h" |
| 13 | 14 | #include "tf20.h" |
| 14 | | #include "cpu/z80/z80.h" |
| 15 | | #include "machine/ram.h" |
| 16 | | #include "machine/upd7201.h" |
| 17 | | #include "machine/upd765.h" |
| 18 | | #include "imagedev/flopdrv.h" |
| 19 | | #include "formats/mfi_dsk.h" |
| 20 | 15 | |
| 21 | | /*************************************************************************** |
| 22 | | CONSTANTS |
| 23 | | ***************************************************************************/ |
| 24 | | |
| 25 | 16 | #define XTAL_CR1 XTAL_8MHz |
| 26 | 17 | #define XTAL_CR2 XTAL_4_9152MHz |
| 27 | 18 | |
| 28 | 19 | |
| 29 | | /*************************************************************************** |
| 30 | | TYPE DEFINITIONS |
| 31 | | ***************************************************************************/ |
| 20 | //************************************************************************** |
| 21 | // DEVICE DEFINITIONS |
| 22 | //************************************************************************** |
| 32 | 23 | |
| 33 | | struct tf20_state |
| 34 | | { |
| 35 | | device_t *cpu; |
| 36 | | ram_device *ram; |
| 37 | | upd765a_device *upd765a; |
| 38 | | upd7201_device *upd7201; |
| 39 | | floppy_image_device *floppy_0; |
| 40 | | floppy_image_device *floppy_1; |
| 24 | const device_type EPSON_TF20 = &device_creator<epson_tf20_device>; |
| 41 | 25 | |
| 42 | | void fdc_int(bool state) { |
| 43 | | cpu->execute().set_input_line(INPUT_LINE_IRQ0, state ? ASSERT_LINE : CLEAR_LINE); |
| 44 | | } |
| 45 | | }; |
| 46 | 26 | |
| 27 | //------------------------------------------------- |
| 28 | // address maps |
| 29 | //------------------------------------------------- |
| 47 | 30 | |
| 48 | | /***************************************************************************** |
| 49 | | INLINE FUNCTIONS |
| 50 | | *****************************************************************************/ |
| 51 | | |
| 52 | | INLINE tf20_state *get_safe_token(device_t *device) |
| 53 | | { |
| 54 | | assert(device != NULL); |
| 55 | | assert(device->type() == TF20); |
| 56 | | |
| 57 | | return (tf20_state *)downcast<tf20_device *>(device)->token(); |
| 58 | | } |
| 59 | | |
| 60 | | |
| 61 | | /*************************************************************************** |
| 62 | | IMPLEMENTATION |
| 63 | | ***************************************************************************/ |
| 64 | | |
| 65 | | /* serial clock, 38400 baud by default */ |
| 66 | | static TIMER_DEVICE_CALLBACK( serial_clock ) |
| 67 | | { |
| 68 | | tf20_state *tf20 = get_safe_token(timer.owner()); |
| 69 | | |
| 70 | | tf20->upd7201->rxca_w(ASSERT_LINE); |
| 71 | | tf20->upd7201->txca_w(ASSERT_LINE); |
| 72 | | tf20->upd7201->rxcb_w(ASSERT_LINE); |
| 73 | | tf20->upd7201->txcb_w(ASSERT_LINE); |
| 74 | | } |
| 75 | | |
| 76 | | /* a read from this location disables the rom */ |
| 77 | | static READ8_HANDLER( tf20_rom_disable ) |
| 78 | | { |
| 79 | | tf20_state *tf20 = get_safe_token(space.device().owner()); |
| 80 | | address_space &prg = space.device().memory().space(AS_PROGRAM); |
| 81 | | |
| 82 | | /* switch in ram */ |
| 83 | | prg.install_ram(0x0000, 0x7fff, tf20->ram->pointer()); |
| 84 | | |
| 85 | | return 0xff; |
| 86 | | } |
| 87 | | |
| 88 | | static READ8_HANDLER( tf20_dip_r ) |
| 89 | | { |
| 90 | | logerror("%s: tf20_dip_r\n", space.machine().describe_context()); |
| 91 | | |
| 92 | | return space.machine().root_device().ioport("tf20_dip")->read(); |
| 93 | | } |
| 94 | | |
| 95 | | static TIMER_CALLBACK( tf20_upd765_tc_reset ) |
| 96 | | { |
| 97 | | static_cast<upd765a_device *>(ptr)->tc_w(false); |
| 98 | | } |
| 99 | | |
| 100 | | static READ8_DEVICE_HANDLER( tf20_upd765_tc_r ) |
| 101 | | { |
| 102 | | tf20_state *tf20 = get_safe_token(device->owner()); |
| 103 | | logerror("%s: tf20_upd765_tc_r\n", device->machine().describe_context()); |
| 104 | | |
| 105 | | /* toggle tc on read */ |
| 106 | | tf20->upd765a->tc_w(true); |
| 107 | | space.machine().scheduler().timer_set(attotime::zero, FUNC(tf20_upd765_tc_reset), 0, device); |
| 108 | | |
| 109 | | return 0xff; |
| 110 | | } |
| 111 | | |
| 112 | | static WRITE8_HANDLER( tf20_fdc_control_w ) |
| 113 | | { |
| 114 | | tf20_state *tf20 = get_safe_token(space.device().owner()); |
| 115 | | logerror("%s: tf20_fdc_control_w %02x\n", space.machine().describe_context(), data); |
| 116 | | |
| 117 | | /* bit 0, motor on signal */ |
| 118 | | tf20->floppy_0->mon_w(!BIT(data, 0)); |
| 119 | | tf20->floppy_1->mon_w(!BIT(data, 0)); |
| 120 | | } |
| 121 | | |
| 122 | | static IRQ_CALLBACK( tf20_irq_ack ) |
| 123 | | { |
| 124 | | return 0x00; |
| 125 | | } |
| 126 | | |
| 127 | | |
| 128 | | /*************************************************************************** |
| 129 | | EXTERNAL INTERFACE |
| 130 | | ***************************************************************************/ |
| 131 | | |
| 132 | | /* serial output signal (to the host computer) */ |
| 133 | | READ_LINE_DEVICE_HANDLER( tf20_rxs_r ) |
| 134 | | { |
| 135 | | tf20_state *tf20 = get_safe_token(device); |
| 136 | | logerror("%s: tf20_rxs_r\n", device->machine().describe_context()); |
| 137 | | |
| 138 | | return tf20->upd7201->txda_r(); |
| 139 | | } |
| 140 | | |
| 141 | | READ_LINE_DEVICE_HANDLER( tf20_pins_r ) |
| 142 | | { |
| 143 | | tf20_state *tf20 = get_safe_token(device); |
| 144 | | logerror("%s: tf20_pins_r\n", device->machine().describe_context()); |
| 145 | | |
| 146 | | return tf20->upd7201->dtra_r(); |
| 147 | | } |
| 148 | | |
| 149 | | /* serial input signal (from host computer) */ |
| 150 | | WRITE_LINE_DEVICE_HANDLER( tf20_txs_w ) |
| 151 | | { |
| 152 | | tf20_state *tf20 = get_safe_token(device); |
| 153 | | logerror("%s: tf20_txs_w %u\n", device->machine().describe_context(), state); |
| 154 | | |
| 155 | | tf20->upd7201->rxda_w(state); |
| 156 | | } |
| 157 | | |
| 158 | | WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w ) |
| 159 | | { |
| 160 | | tf20_state *tf20 = get_safe_token(device); |
| 161 | | logerror("%s: tf20_pouts_w %u\n", device->machine().describe_context(), state); |
| 162 | | |
| 163 | | tf20->upd7201->ctsa_w(state); |
| 164 | | } |
| 165 | | |
| 166 | | #ifdef UNUSED_FUNCTION |
| 167 | | /* serial output signal (to another terminal) */ |
| 168 | | WRITE_LINE_DEVICE_HANDLER( tf20_txc_w ) |
| 169 | | { |
| 170 | | tf20_state *tf20 = get_safe_token(device); |
| 171 | | logerror("%s: tf20_txc_w %u\n", device->machine().describe_context(), state); |
| 172 | | |
| 173 | | tf20->upd7201->rxda_w(state); |
| 174 | | } |
| 175 | | |
| 176 | | /* serial input signal (from another terminal) */ |
| 177 | | READ_LINE_DEVICE_HANDLER( tf20_rxc_r ) |
| 178 | | { |
| 179 | | tf20_state *tf20 = get_safe_token(device); |
| 180 | | logerror("%s: tf20_rxc_r\n", device->machine().describe_context()); |
| 181 | | |
| 182 | | return tf20->upd7201->txda_r(); |
| 183 | | } |
| 184 | | |
| 185 | | WRITE_LINE_DEVICE_HANDLER( tf20_poutc_w ) |
| 186 | | { |
| 187 | | tf20_state *tf20 = get_safe_token(device); |
| 188 | | logerror("%s: tf20_poutc_w %u\n", device->machine().describe_context(), state); |
| 189 | | |
| 190 | | tf20->upd7201->ctsa_w(state); |
| 191 | | } |
| 192 | | |
| 193 | | READ_LINE_DEVICE_HANDLER( tf20_pinc_r ) |
| 194 | | { |
| 195 | | tf20_state *tf20 = get_safe_token(device); |
| 196 | | logerror("%s: tf20_pinc_r\n", device->machine().describe_context()); |
| 197 | | |
| 198 | | return tf20->upd7201->dtra_r(); |
| 199 | | } |
| 200 | | #endif |
| 201 | | |
| 202 | | |
| 203 | | /***************************************************************************** |
| 204 | | ADDRESS MAPS |
| 205 | | *****************************************************************************/ |
| 206 | | |
| 207 | | static ADDRESS_MAP_START( tf20_mem, AS_PROGRAM, 8, tf20_device ) |
| 208 | | AM_RANGE(0x0000, 0x7fff) AM_RAMBANK("bank21") |
| 209 | | AM_RANGE(0x8000, 0xffff) AM_RAMBANK("bank22") |
| 31 | static ADDRESS_MAP_START( cpu_mem, AS_PROGRAM, 8, epson_tf20_device ) |
| 32 | AM_RANGE(0x0000, 0x7fff) AM_RAMBANK("bank1") |
| 33 | AM_RANGE(0x8000, 0xffff) AM_RAMBANK("bank2") |
| 210 | 34 | ADDRESS_MAP_END |
| 211 | 35 | |
| 212 | | static ADDRESS_MAP_START( tf20_io, AS_IO, 8, tf20_device ) |
| 36 | static ADDRESS_MAP_START( cpu_io, AS_IO, 8, epson_tf20_device ) |
| 213 | 37 | ADDRESS_MAP_UNMAP_HIGH |
| 214 | 38 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 215 | 39 | AM_RANGE(0xf0, 0xf3) AM_DEVREADWRITE("3a", upd7201_device, ba_cd_r, ba_cd_w) |
| 216 | | AM_RANGE(0xf6, 0xf6) AM_READ_LEGACY(tf20_rom_disable) |
| 217 | | AM_RANGE(0xf7, 0xf7) AM_READ_LEGACY(tf20_dip_r) |
| 218 | | AM_RANGE(0xf8, 0xf8) AM_DEVREAD_LEGACY("5a", tf20_upd765_tc_r) AM_WRITE_LEGACY(tf20_fdc_control_w) |
| 40 | AM_RANGE(0xf6, 0xf6) AM_READ(rom_disable_r) |
| 41 | AM_RANGE(0xf7, 0xf7) AM_READ_PORT("tf20_dip") |
| 42 | AM_RANGE(0xf8, 0xf8) AM_READWRITE(upd765_tc_r, fdc_control_w) |
| 219 | 43 | AM_RANGE(0xfa, 0xfb) AM_DEVICE("5a", upd765a_device, map) |
| 220 | 44 | ADDRESS_MAP_END |
| 221 | 45 | |
| 222 | 46 | |
| 223 | | /*************************************************************************** |
| 224 | | INPUT PORTS |
| 225 | | ***************************************************************************/ |
| 47 | //------------------------------------------------- |
| 48 | // rom_region - device-specific ROM region |
| 49 | //------------------------------------------------- |
| 226 | 50 | |
| 51 | ROM_START( tf20 ) |
| 52 | ROM_REGION(0x0800, "rom", 0) |
| 53 | ROM_LOAD("tfx.15e", 0x0000, 0x0800, CRC(af34f084) SHA1(c9bdf393f757ba5d8f838108ceb2b079be1d616e)) |
| 54 | ROM_END |
| 55 | |
| 56 | const rom_entry *epson_tf20_device::device_rom_region() const |
| 57 | { |
| 58 | return ROM_NAME( tf20 ); |
| 59 | } |
| 60 | |
| 61 | |
| 62 | //------------------------------------------------- |
| 63 | // input_ports - device-specific input ports |
| 64 | //------------------------------------------------- |
| 65 | |
| 227 | 66 | INPUT_PORTS_START( tf20 ) |
| 228 | 67 | PORT_START("tf20_dip") |
| 229 | 68 | PORT_DIPNAME(0x0f, 0x0f, "Drive extension") |
| r18806 | r18807 | |
| 232 | 71 | PORT_DIPSETTING(0x07, "C & D Drive") |
| 233 | 72 | INPUT_PORTS_END |
| 234 | 73 | |
| 74 | ioport_constructor epson_tf20_device::device_input_ports() const |
| 75 | { |
| 76 | return INPUT_PORTS_NAME( tf20 ); |
| 77 | } |
| 235 | 78 | |
| 236 | | /***************************************************************************** |
| 237 | | MACHINE CONFIG |
| 238 | | *****************************************************************************/ |
| 239 | 79 | |
| 80 | //------------------------------------------------- |
| 81 | // machine_config_additions - device-specific |
| 82 | // machine configurations |
| 83 | //------------------------------------------------- |
| 84 | |
| 240 | 85 | static UPD7201_INTERFACE( tf20_upd7201_intf ) |
| 241 | 86 | { |
| 242 | 87 | DEVCB_NULL, /* interrupt: nc */ |
| r18806 | r18807 | |
| 271 | 116 | } |
| 272 | 117 | }; |
| 273 | 118 | |
| 274 | | static const floppy_format_type tf20_floppy_formats[] = { |
| 119 | static const floppy_format_type tf20_floppy_formats[] = |
| 120 | { |
| 121 | FLOPPY_D88_FORMAT, |
| 122 | FLOPPY_MFM_FORMAT, |
| 275 | 123 | FLOPPY_MFI_FORMAT, |
| 276 | 124 | NULL |
| 277 | 125 | }; |
| r18806 | r18807 | |
| 281 | 129 | SLOT_INTERFACE_END |
| 282 | 130 | |
| 283 | 131 | static MACHINE_CONFIG_FRAGMENT( tf20 ) |
| 284 | | MCFG_CPU_ADD("tf20", Z80, XTAL_CR1 / 2) /* uPD780C */ |
| 285 | | MCFG_CPU_PROGRAM_MAP(tf20_mem) |
| 286 | | MCFG_CPU_IO_MAP(tf20_io) |
| 132 | MCFG_CPU_ADD("19b", Z80, XTAL_CR1 / 2) /* uPD780C */ |
| 133 | MCFG_CPU_PROGRAM_MAP(cpu_mem) |
| 134 | MCFG_CPU_IO_MAP(cpu_io) |
| 287 | 135 | |
| 288 | | /* 64k internal ram */ |
| 136 | // 64k internal ram |
| 289 | 137 | MCFG_RAM_ADD("ram") |
| 290 | 138 | MCFG_RAM_DEFAULT_SIZE("64k") |
| 291 | 139 | |
| 292 | | /* upd765a floppy controller */ |
| 293 | | MCFG_UPD765A_ADD("5a", false, true) |
| 294 | | |
| 295 | | /* upd7201 serial interface */ |
| 140 | // upd7201 serial interface |
| 296 | 141 | MCFG_UPD7201_ADD("3a", XTAL_CR1 / 2, tf20_upd7201_intf) |
| 297 | | MCFG_TIMER_ADD_PERIODIC("serial_timer", serial_clock, attotime::from_hz(XTAL_CR2 / 128)) |
| 298 | 142 | |
| 299 | | /* 2 floppy drives */ |
| 143 | // floppy disk controller |
| 144 | MCFG_UPD765A_ADD("5a", true, true) |
| 145 | |
| 146 | // floppy drives |
| 300 | 147 | MCFG_FLOPPY_DRIVE_ADD("5a:0", tf20_floppies, "525dd", 0, tf20_floppy_formats) |
| 301 | 148 | MCFG_FLOPPY_DRIVE_ADD("5a:1", tf20_floppies, "525dd", 0, tf20_floppy_formats) |
| 149 | |
| 150 | // serial interface to another device |
| 151 | MCFG_EPSON_SIO_ADD("sio") |
| 302 | 152 | MACHINE_CONFIG_END |
| 303 | 153 | |
| 154 | machine_config_constructor epson_tf20_device::device_mconfig_additions() const |
| 155 | { |
| 156 | return MACHINE_CONFIG_NAME( tf20 ); |
| 157 | } |
| 304 | 158 | |
| 305 | | /*************************************************************************** |
| 306 | | ROM DEFINITIONS |
| 307 | | ***************************************************************************/ |
| 308 | 159 | |
| 309 | | ROM_START( tf20 ) |
| 310 | | ROM_REGION(0x0800, "tf20", 0) |
| 311 | | ROM_LOAD("tfx.15e", 0x0000, 0x0800, CRC(af34f084) SHA1(c9bdf393f757ba5d8f838108ceb2b079be1d616e)) |
| 312 | | ROM_END |
| 160 | //************************************************************************** |
| 161 | // LIVE DEVICE |
| 162 | //************************************************************************** |
| 313 | 163 | |
| 164 | //------------------------------------------------- |
| 165 | // epson_tf20_device - constructor |
| 166 | //------------------------------------------------- |
| 314 | 167 | |
| 315 | | /***************************************************************************** |
| 316 | | DEVICE INTERFACE |
| 317 | | *****************************************************************************/ |
| 318 | | |
| 319 | | static DEVICE_START( tf20 ) |
| 168 | epson_tf20_device::epson_tf20_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 169 | device_t(mconfig, EPSON_TF20, "EPSON TF-20 dual floppy drive", tag, owner, clock), |
| 170 | device_epson_sio_interface(mconfig, *this), |
| 171 | m_cpu(*this, "19b"), |
| 172 | m_ram(*this, "ram"), |
| 173 | m_fdc(*this, "5a"), |
| 174 | m_mpsc(*this, "3a"), |
| 175 | m_sio(*this, "sio") |
| 320 | 176 | { |
| 321 | | tf20_state *tf20 = get_safe_token(device); |
| 322 | | tf20->cpu = device->subdevice("tf20"); |
| 323 | | address_space &prg = tf20->cpu->memory().space(AS_PROGRAM); |
| 177 | } |
| 324 | 178 | |
| 325 | | tf20->cpu->execute().set_irq_acknowledge_callback(tf20_irq_ack); |
| 326 | 179 | |
| 327 | | /* ram device */ |
| 328 | | tf20->ram = device->subdevice<ram_device>("ram"); |
| 180 | //------------------------------------------------- |
| 181 | // device_start - device-specific startup |
| 182 | //------------------------------------------------- |
| 329 | 183 | |
| 330 | | /* make sure its already running */ |
| 331 | | if (!tf20->ram->started()) |
| 184 | void epson_tf20_device::device_start() |
| 185 | { |
| 186 | // make sure the ram device is already running |
| 187 | if (!m_ram->started()) |
| 332 | 188 | throw device_missing_dependencies(); |
| 333 | 189 | |
| 334 | | /* locate child devices */ |
| 335 | | tf20->upd765a = device->subdevice<upd765a_device>("5a"); |
| 336 | | tf20->upd7201 = downcast<upd7201_device *>(device->subdevice("3a")); |
| 337 | | tf20->floppy_0 = device->subdevice<floppy_connector>("5a:0")->get_device(); |
| 338 | | tf20->floppy_1 = device->subdevice<floppy_connector>("5a:1")->get_device(); |
| 190 | m_timer_serial = timer_alloc(0, NULL); |
| 191 | m_timer_tc = timer_alloc(1, NULL); |
| 339 | 192 | |
| 340 | | /* hookup the irq */ |
| 341 | | tf20->upd765a->setup_intrq_cb(upd765a_device::line_cb(FUNC(tf20_state::fdc_int), tf20)); |
| 193 | m_cpu->set_irq_acknowledge_callback(irq_callback); |
| 342 | 194 | |
| 343 | | /* enable second half of ram */ |
| 344 | | prg.install_ram(0x8000, 0xffff, tf20->ram->pointer() + 0x8000); |
| 195 | m_fd0 = subdevice<floppy_connector>("5a:0")->get_device(); |
| 196 | m_fd1 = subdevice<floppy_connector>("5a:1")->get_device(); |
| 197 | |
| 198 | m_fdc->setup_intrq_cb(upd765a_device::line_cb(FUNC(epson_tf20_device::fdc_irq), this)); |
| 199 | |
| 200 | // enable second half of ram |
| 201 | m_cpu->space(AS_PROGRAM).install_ram(0x8000, 0xffff, m_ram->pointer() + 0x8000); |
| 202 | |
| 345 | 203 | } |
| 346 | 204 | |
| 347 | | static DEVICE_RESET( tf20 ) |
| 205 | |
| 206 | //------------------------------------------------- |
| 207 | // device_reset - device-specific reset |
| 208 | //------------------------------------------------- |
| 209 | |
| 210 | void epson_tf20_device::device_reset() |
| 348 | 211 | { |
| 349 | | device_t *cpu = device->subdevice("tf20"); |
| 350 | | address_space &prg = cpu->memory().space(AS_PROGRAM); |
| 212 | // init timers |
| 213 | m_timer_serial->adjust(attotime::from_hz(XTAL_CR2 / 128), 0, attotime::from_hz(XTAL_CR2 / 128)); |
| 214 | m_timer_tc->adjust(attotime::never); |
| 351 | 215 | |
| 352 | | /* enable rom */ |
| 353 | | prg.install_rom(0x0000, 0x07ff, 0, 0x7800, cpu->region()->base()); |
| 216 | // enable rom |
| 217 | m_cpu->space(AS_PROGRAM).install_rom(0x0000, 0x07ff, 0, 0x7800, memregion("rom")->base()); |
| 354 | 218 | } |
| 355 | 219 | |
| 356 | | const device_type TF20 = &device_creator<tf20_device>; |
| 357 | 220 | |
| 358 | | tf20_device::tf20_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 359 | | : device_t(mconfig, TF20, "TF-20", tag, owner, clock) |
| 221 | //------------------------------------------------- |
| 222 | // device_timer - handler timer events |
| 223 | //------------------------------------------------- |
| 224 | |
| 225 | void epson_tf20_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 360 | 226 | { |
| 361 | | m_token = global_alloc_clear(tf20_state); |
| 227 | switch (id) |
| 228 | { |
| 229 | case 0: |
| 230 | m_mpsc->rxca_w(1); |
| 231 | m_mpsc->txca_w(1); |
| 232 | m_mpsc->rxcb_w(1); |
| 233 | m_mpsc->txcb_w(1); |
| 234 | break; |
| 235 | |
| 236 | case 1: |
| 237 | logerror("%s: tc off\n", tag()); |
| 238 | m_fdc->tc_w(false); |
| 239 | break; |
| 240 | } |
| 362 | 241 | } |
| 363 | 242 | |
| 243 | |
| 364 | 244 | //------------------------------------------------- |
| 365 | | // device_config_complete - perform any |
| 366 | | // operations now that the configuration is |
| 367 | | // complete |
| 245 | // irq vector callback |
| 368 | 246 | //------------------------------------------------- |
| 369 | 247 | |
| 370 | | void tf20_device::device_config_complete() |
| 248 | IRQ_CALLBACK( epson_tf20_device::irq_callback ) |
| 371 | 249 | { |
| 372 | | m_shortname = "tf20"; |
| 250 | return 0x00; |
| 373 | 251 | } |
| 374 | 252 | |
| 253 | |
| 375 | 254 | //------------------------------------------------- |
| 376 | | // device_start - device-specific startup |
| 255 | // fdc interrupt |
| 377 | 256 | //------------------------------------------------- |
| 378 | 257 | |
| 379 | | void tf20_device::device_start() |
| 258 | void epson_tf20_device::fdc_irq(bool state) |
| 380 | 259 | { |
| 381 | | DEVICE_START_NAME( tf20 )(this); |
| 260 | m_cpu->set_input_line(INPUT_LINE_IRQ0, state ? ASSERT_LINE : CLEAR_LINE); |
| 382 | 261 | } |
| 383 | 262 | |
| 263 | |
| 384 | 264 | //------------------------------------------------- |
| 385 | | // device_reset - device-specific reset |
| 265 | // tx_w |
| 386 | 266 | //------------------------------------------------- |
| 387 | 267 | |
| 388 | | void tf20_device::device_reset() |
| 268 | void epson_tf20_device::tx_w(int level) |
| 389 | 269 | { |
| 390 | | DEVICE_RESET_NAME( tf20 )(this); |
| 270 | logerror("%s: tx_w(%d)\n", tag(), level); |
| 271 | m_mpsc->rxda_w(level); |
| 391 | 272 | } |
| 392 | 273 | |
| 274 | |
| 393 | 275 | //------------------------------------------------- |
| 394 | | // device_mconfig_additions - return a pointer to |
| 395 | | // the device's machine fragment |
| 276 | // pout_w |
| 396 | 277 | //------------------------------------------------- |
| 397 | 278 | |
| 398 | | machine_config_constructor tf20_device::device_mconfig_additions() const |
| 279 | void epson_tf20_device::pout_w(int level) |
| 399 | 280 | { |
| 400 | | return MACHINE_CONFIG_NAME( tf20 ); |
| 281 | logerror("%s: pout_w(%d)\n", tag(), level); |
| 282 | m_mpsc->ctsa_w(level); |
| 401 | 283 | } |
| 402 | 284 | |
| 285 | |
| 403 | 286 | //------------------------------------------------- |
| 404 | | // device_rom_region - return a pointer to the |
| 405 | | // the device's ROM definitions |
| 287 | // rx_r |
| 406 | 288 | //------------------------------------------------- |
| 407 | 289 | |
| 408 | | const rom_entry *tf20_device::device_rom_region() const |
| 290 | int epson_tf20_device::rx_r() |
| 409 | 291 | { |
| 410 | | return ROM_NAME(tf20 ); |
| 292 | logerror("%s: rx_r\n", tag()); |
| 293 | return m_mpsc->txda_r(); |
| 411 | 294 | } |
| 412 | 295 | |
| 413 | 296 | |
| 297 | //------------------------------------------------- |
| 298 | // pin_r |
| 299 | //------------------------------------------------- |
| 300 | |
| 301 | int epson_tf20_device::pin_r() |
| 302 | { |
| 303 | logerror("%s: pin_r\n", tag()); |
| 304 | return m_mpsc->dtra_r(); |
| 305 | } |
| 306 | |
| 307 | |
| 308 | // a read from this location disables the rom |
| 309 | READ8_MEMBER( epson_tf20_device::rom_disable_r ) |
| 310 | { |
| 311 | // switch in ram |
| 312 | m_cpu->space(AS_PROGRAM).install_ram(0x0000, 0x7fff, m_ram->pointer()); |
| 313 | return 0xff; |
| 314 | } |
| 315 | |
| 316 | |
| 317 | READ8_MEMBER( epson_tf20_device::upd765_tc_r ) |
| 318 | { |
| 319 | logerror("%s: upd765_tc_r\n", space.machine().describe_context()); |
| 320 | |
| 321 | // toggle tc on read |
| 322 | m_fdc->tc_w(true); |
| 323 | m_timer_tc->adjust(attotime::zero); |
| 324 | |
| 325 | return 0xff; |
| 326 | } |
| 327 | |
| 328 | |
| 329 | WRITE8_MEMBER( epson_tf20_device::fdc_control_w ) |
| 330 | { |
| 331 | logerror("%s: tf20_fdc_control_w(%02x)\n", space.machine().describe_context(), data); |
| 332 | |
| 333 | // bit 0, motor on signal |
| 334 | m_fd0->mon_w(!BIT(data, 0)); |
| 335 | m_fd1->mon_w(!BIT(data, 0)); |
| 336 | } |
trunk/src/mess/machine/tf20.h
| r18806 | r18807 | |
| 1 | | /*************************************************************************** |
| 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | Epson TF-20 |
| 3 | EPSON TF-20 |
| 4 | 4 | |
| 5 | | Dual floppy drive with HX-20 factory option |
| 5 | Dual 5.25" floppy drive with HX-20 factory option |
| 6 | 6 | |
| 7 | | ***************************************************************************/ |
| 7 | Copyright MESS Team. |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. |
| 8 | 9 | |
| 10 | **********************************************************************/ |
| 11 | |
| 12 | #pragma once |
| 13 | |
| 9 | 14 | #ifndef __TF20_H__ |
| 10 | 15 | #define __TF20_H__ |
| 11 | 16 | |
| 12 | | #include "devcb.h" |
| 17 | #include "emu.h" |
| 18 | #include "cpu/z80/z80.h" |
| 19 | #include "machine/ram.h" |
| 20 | #include "machine/upd765.h" |
| 21 | #include "machine/upd7201.h" |
| 22 | #include "machine/epson_sio.h" |
| 23 | #include "imagedev/flopdrv.h" |
| 24 | #include "formats/mfi_dsk.h" |
| 25 | #include "formats/hxcmfm_dsk.h" |
| 26 | #include "formats/d88_dsk.h" |
| 13 | 27 | |
| 14 | 28 | |
| 15 | | /*************************************************************************** |
| 16 | | TYPE DEFINITIONS |
| 17 | | ***************************************************************************/ |
| 29 | //************************************************************************** |
| 30 | // TYPE DEFINITIONS |
| 31 | //************************************************************************** |
| 18 | 32 | |
| 19 | | #if 0 |
| 20 | | struct tf20_interface |
| 33 | class epson_tf20_device : public device_t, |
| 34 | public device_epson_sio_interface |
| 21 | 35 | { |
| 22 | | }; |
| 23 | | #endif |
| 36 | public: |
| 37 | // construction/destruction |
| 38 | epson_tf20_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 24 | 39 | |
| 40 | // optional information overrides |
| 41 | virtual const rom_entry *device_rom_region() const; |
| 42 | virtual machine_config_constructor device_mconfig_additions() const; |
| 43 | virtual ioport_constructor device_input_ports() const; |
| 25 | 44 | |
| 26 | | /*************************************************************************** |
| 27 | | FUNCTION PROTOTYPES |
| 28 | | ***************************************************************************/ |
| 45 | // not really public |
| 46 | DECLARE_READ8_MEMBER( rom_disable_r ); |
| 47 | DECLARE_READ8_MEMBER( upd765_tc_r ); |
| 48 | DECLARE_WRITE8_MEMBER( fdc_control_w ); |
| 49 | static IRQ_CALLBACK( irq_callback ); |
| 29 | 50 | |
| 30 | | /* serial interface in (to the host computer) */ |
| 31 | | WRITE_LINE_DEVICE_HANDLER( tf20_txs_w ); |
| 32 | | READ_LINE_DEVICE_HANDLER( tf20_rxs_r ); |
| 33 | | WRITE_LINE_DEVICE_HANDLER( tf20_pouts_w ); |
| 34 | | READ_LINE_DEVICE_HANDLER( tf20_pins_r ); |
| 51 | void fdc_irq(bool state); |
| 35 | 52 | |
| 36 | | #ifdef UNUSED_FUNCTION |
| 37 | | /* serial interface out (to another terminal) */ |
| 38 | | WRITE_LINE_DEVICE_HANDLER( tf20_txc_r ); |
| 39 | | READ_LINE_DEVICE_HANDLER( tf20_rxc_w ); |
| 40 | | WRITE_LINE_DEVICE_HANDLER( tf20_poutc_r ); |
| 41 | | READ_LINE_DEVICE_HANDLER( tf20_pinc_w ); |
| 42 | | #endif |
| 53 | protected: |
| 54 | // device-level overrides |
| 55 | virtual void device_config_complete() { m_shortname = "epson_tf20"; } |
| 56 | virtual void device_start(); |
| 57 | virtual void device_reset(); |
| 58 | virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr); |
| 43 | 59 | |
| 44 | | INPUT_PORTS_EXTERN( tf20 ); |
| 60 | // device_epson_sio_interface overrides |
| 61 | virtual int rx_r(); |
| 62 | virtual int pin_r(); |
| 63 | virtual void tx_w(int level); |
| 64 | virtual void pout_w(int level); |
| 45 | 65 | |
| 66 | private: |
| 67 | required_device<cpu_device> m_cpu; |
| 68 | required_device<ram_device> m_ram; |
| 69 | required_device<upd765a_device> m_fdc; |
| 70 | required_device<upd7201_device> m_mpsc; |
| 71 | required_device<epson_sio_device> m_sio; |
| 46 | 72 | |
| 47 | | /*************************************************************************** |
| 48 | | DEVICE CONFIGURATION MACROS |
| 49 | | ***************************************************************************/ |
| 73 | floppy_image_device *m_fd0; |
| 74 | floppy_image_device *m_fd1; |
| 50 | 75 | |
| 51 | | class tf20_device : public device_t |
| 52 | | { |
| 53 | | public: |
| 54 | | tf20_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 55 | | ~tf20_device() { global_free(m_token); } |
| 76 | emu_timer *m_timer_serial; |
| 77 | emu_timer *m_timer_tc; |
| 56 | 78 | |
| 57 | | // access to legacy token |
| 58 | | void *token() const { assert(m_token != NULL); return m_token; } |
| 59 | | protected: |
| 60 | | // device-level overrides |
| 61 | | virtual void device_config_complete(); |
| 62 | | virtual void device_start(); |
| 63 | | virtual void device_reset(); |
| 64 | | virtual const rom_entry *device_rom_region() const; |
| 65 | | virtual machine_config_constructor device_mconfig_additions() const; |
| 66 | | private: |
| 67 | | // internal state |
| 68 | | void *m_token; |
| 79 | static const int XTAL_CR1 = XTAL_8MHz; |
| 80 | static const int XTAL_CR2 = XTAL_4_9152MHz; |
| 69 | 81 | }; |
| 70 | 82 | |
| 71 | | extern const device_type TF20; |
| 72 | 83 | |
| 84 | // device type definition |
| 85 | extern const device_type EPSON_TF20; |
| 73 | 86 | |
| 74 | | #define MCFG_TF20_ADD(_tag) \ |
| 75 | | MCFG_DEVICE_ADD(_tag, TF20, 0) \ |
| 76 | 87 | |
| 77 | | |
| 78 | | #endif /* __TF20_H__ */ |
| 88 | #endif // __TF20_H__ |
trunk/src/mess/drivers/px4.c
| r18806 | r18807 | |
| 10 | 10 | #include "emu.h" |
| 11 | 11 | #include "cpu/z80/z80.h" |
| 12 | 12 | #include "machine/ram.h" |
| 13 | #include "machine/epson_sio.h" |
| 13 | 14 | #include "machine/ctronics.h" |
| 14 | 15 | #include "imagedev/cartslot.h" |
| 15 | 16 | #include "imagedev/cassette.h" |
| 16 | | #include "machine/tf20.h" |
| 17 | 17 | #include "machine/ram.h" |
| 18 | 18 | #include "machine/nvram.h" |
| 19 | 19 | #include "sound/speaker.h" |
| r18806 | r18807 | |
| 24 | 24 | // CONSTANTS |
| 25 | 25 | //************************************************************************** |
| 26 | 26 | |
| 27 | | #define VERBOSE 1 |
| 27 | #define VERBOSE 0 |
| 28 | 28 | |
| 29 | 29 | // interrupt sources |
| 30 | 30 | #define INT0_7508 0x01 |
| r18806 | r18807 | |
| 79 | 79 | m_ram(*this, RAM_TAG), |
| 80 | 80 | m_centronics(*this, "centronics"), |
| 81 | 81 | m_ext_cas(*this, "extcas"), |
| 82 | | m_speaker(*this, SPEAKER_TAG) |
| 82 | m_speaker(*this, SPEAKER_TAG), |
| 83 | m_sio(*this, "sio") |
| 83 | 84 | { } |
| 84 | 85 | |
| 85 | 86 | // internal devices |
| r18806 | r18807 | |
| 88 | 89 | required_device<centronics_device> m_centronics; |
| 89 | 90 | required_device<cassette_image_device> m_ext_cas; |
| 90 | 91 | required_device<device_t> m_speaker; |
| 92 | required_device<epson_sio_device> m_sio; |
| 91 | 93 | |
| 92 | 94 | /* gapnit register */ |
| 93 | 95 | UINT8 m_ctrl1; |
| r18806 | r18807 | |
| 200 | 202 | |
| 201 | 203 | |
| 202 | 204 | //************************************************************************** |
| 203 | | // SERIAL PORT |
| 204 | | //************************************************************************** |
| 205 | | |
| 206 | | // The floppy is connected to this port |
| 207 | | |
| 208 | | void px4_state::px4_sio_txd(device_t *device,int state) |
| 209 | | { |
| 210 | | if (VERBOSE) |
| 211 | | logerror("px4_sio_txd: %d\n", state); |
| 212 | | |
| 213 | | if (device != NULL) |
| 214 | | tf20_txs_w(device, state); |
| 215 | | } |
| 216 | | |
| 217 | | int px4_state::px4_sio_rxd(device_t *device) |
| 218 | | { |
| 219 | | if (VERBOSE) |
| 220 | | logerror("px4_sio_rxd\n"); |
| 221 | | |
| 222 | | if (device != NULL) |
| 223 | | return tf20_rxs_r(device); |
| 224 | | else |
| 225 | | return ASSERT_LINE; |
| 226 | | } |
| 227 | | |
| 228 | | int px4_state::px4_sio_pin(device_t *device) |
| 229 | | { |
| 230 | | if (VERBOSE) |
| 231 | | logerror("px4_sio_pin\n"); |
| 232 | | |
| 233 | | if (device != NULL) |
| 234 | | return tf20_pins_r(device); |
| 235 | | else |
| 236 | | return ASSERT_LINE; |
| 237 | | } |
| 238 | | |
| 239 | | void px4_state::px4_sio_pout(device_t *device,int state) |
| 240 | | { |
| 241 | | if (VERBOSE) |
| 242 | | logerror("px4_sio_pout: %d\n", state); |
| 243 | | |
| 244 | | if (device != NULL) |
| 245 | | tf20_pouts_w(device, state); |
| 246 | | } |
| 247 | | |
| 248 | | |
| 249 | | //************************************************************************** |
| 250 | 205 | // RS232C PORT |
| 251 | 206 | //************************************************************************** |
| 252 | 207 | |
| r18806 | r18807 | |
| 843 | 798 | |
| 844 | 799 | result |= m_centronics->busy_r() << 0; |
| 845 | 800 | result |= !m_centronics->pe_r() << 1; |
| 846 | | result |= px4_sio_pin(m_sio_device) << 2; |
| 847 | | result |= px4_sio_rxd(m_sio_device) << 3; |
| 801 | result |= m_sio->pin_r() << 2; |
| 802 | result |= m_sio->rx_r() << 3; |
| 848 | 803 | result |= px4_rs232c_dcd(m_rs232c_device) << 4; |
| 849 | 804 | result |= px4_rs232c_cts(m_rs232c_device) << 5; |
| 850 | 805 | result |= 1 << 6; // bit 6, csel, cartridge option select signal, set to 'other mode' |
| r18806 | r18807 | |
| 865 | 820 | if (!ART_TX_ENABLED) |
| 866 | 821 | { |
| 867 | 822 | // force high when disabled |
| 868 | | px4_sio_txd(m_sio_device, ASSERT_LINE); |
| 823 | m_sio->tx_w(1); |
| 869 | 824 | px4_rs232c_txd(m_rs232c_device, ASSERT_LINE); |
| 870 | 825 | } |
| 871 | 826 | |
| r18806 | r18807 | |
| 873 | 828 | if (ART_TX_ENABLED && BIT(data, 3)) |
| 874 | 829 | { |
| 875 | 830 | // force low when enabled and transmit enabled |
| 876 | | px4_sio_txd(m_sio_device, CLEAR_LINE); |
| 831 | m_sio->tx_w(0); |
| 877 | 832 | px4_rs232c_txd(m_rs232c_device, CLEAR_LINE); |
| 878 | 833 | } |
| 879 | 834 | |
| r18806 | r18807 | |
| 903 | 858 | m_centronics->strobe_w(!BIT(data, 0)); |
| 904 | 859 | m_centronics->init_prime_w(BIT(data, 1)); |
| 905 | 860 | |
| 906 | | px4_sio_pout(m_sio_device, BIT(data, 2)); |
| 861 | m_sio->pout_w(BIT(data, 2)); |
| 907 | 862 | |
| 908 | 863 | // bit 3, cartridge reset |
| 909 | 864 | |
| r18806 | r18807 | |
| 1210 | 1165 | // US ASCII keyboard |
| 1211 | 1166 | static INPUT_PORTS_START( px4_h450a ) |
| 1212 | 1167 | PORT_INCLUDE(px4_dips) |
| 1213 | | PORT_INCLUDE(tf20) |
| 1214 | 1168 | |
| 1215 | 1169 | PORT_START("keyboard_0") |
| 1216 | 1170 | PORT_BIT(0x00000001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_CHANGED_MEMBER(DEVICE_SELF, px4_state, key_callback, (void *)0) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(ESC)) // 00 |
| r18806 | r18807 | |
| 1313 | 1267 | /* item keyboard */ |
| 1314 | 1268 | static INPUT_PORTS_START( px4_h421a ) |
| 1315 | 1269 | PORT_INCLUDE(px4_dips) |
| 1316 | | PORT_INCLUDE(tf20) |
| 1317 | 1270 | INPUT_PORTS_END |
| 1318 | 1271 | |
| 1319 | 1272 | #endif |
| r18806 | r18807 | |
| 1389 | 1342 | MCFG_CARTSLOT_ADD("capsule2") |
| 1390 | 1343 | MCFG_CARTSLOT_NOT_MANDATORY |
| 1391 | 1344 | |
| 1392 | | // tf20 floppy drive |
| 1393 | | MCFG_TF20_ADD("floppy") |
| 1345 | // sio port |
| 1346 | MCFG_EPSON_SIO_ADD("sio") |
| 1394 | 1347 | MACHINE_CONFIG_END |
| 1395 | 1348 | |
| 1396 | 1349 | static MACHINE_CONFIG_DERIVED( px4p, px4 ) |