trunk/src/mess/machine/mos8722.c
| r0 | r17757 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | MOS Technology 8722 Memory Management Unit emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "mos8722.h" |
| 11 | |
| 12 | |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // MACROS / CONSTANTS |
| 16 | //************************************************************************** |
| 17 | |
| 18 | #define LOG 0 |
| 19 | |
| 20 | |
| 21 | // registers |
| 22 | enum |
| 23 | { |
| 24 | CR = 0, |
| 25 | PCRA, LCRA = PCRA, |
| 26 | PCRB, LCRB = PCRB, |
| 27 | PCRC, LCRC = PCRC, |
| 28 | PCRD, LCRD = PCRD, |
| 29 | MCR, |
| 30 | RCR, |
| 31 | P0L, |
| 32 | P0H, |
| 33 | P1L, |
| 34 | P1H, |
| 35 | VR |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | // configuration register |
| 40 | enum |
| 41 | { |
| 42 | CR_IO_SYSTEM_IO = 0, |
| 43 | CR_IO_HI_ROM |
| 44 | }; |
| 45 | |
| 46 | enum |
| 47 | { |
| 48 | CR_ROM_SYSTEM_ROM = 0, |
| 49 | CR_ROM_INT_FUNC_ROM, |
| 50 | CR_ROM_EXT_FUNC_ROM, |
| 51 | CR_ROM_RAM |
| 52 | }; |
| 53 | |
| 54 | #define CR_IO BIT(m_reg[CR], 0) |
| 55 | #define CR_ROM_LO BIT(m_reg[CR], 1) |
| 56 | #define CR_ROM_MID ((m_reg[CR] >> 2) & 0x03) |
| 57 | #define CR_ROM_HI ((m_reg[CR] >> 4) & 0x03) |
| 58 | #define CR_A16 BIT(m_reg[CR], 6) |
| 59 | |
| 60 | |
| 61 | // mode configuration register |
| 62 | #define MCR_8500 BIT(m_reg[MCR], 0) |
| 63 | #define MCR_FSDIR BIT(m_reg[MCR], 3) |
| 64 | #define MCR_GAME BIT(m_reg[MCR], 4) |
| 65 | #define MCR_EXROM BIT(m_reg[MCR], 5) |
| 66 | #define MCR_C64 BIT(m_reg[MCR], 6) |
| 67 | #define MCR_40_80 BIT(m_reg[MCR], 7) |
| 68 | |
| 69 | |
| 70 | // RAM configuration register |
| 71 | enum |
| 72 | { |
| 73 | RCR_STATUS_NO = 0, |
| 74 | RCR_STATUS_BOTTOM, |
| 75 | RCR_STATUS_TOP, |
| 76 | RCR_STATUS_BOTH |
| 77 | }; |
| 78 | |
| 79 | #define RCR_SHARE (m_reg[RCR] & 0x03) |
| 80 | #define RCR_STATUS ((m_reg[RCR] >> 2) & 0x03) |
| 81 | #define RCR_A16 BIT(m_reg[RCR], 6) |
| 82 | |
| 83 | |
| 84 | |
| 85 | //************************************************************************** |
| 86 | // DEVICE DEFINITIONS |
| 87 | //************************************************************************** |
| 88 | |
| 89 | const device_type MOS8722 = &device_creator<mos8722_device>; |
| 90 | |
| 91 | |
| 92 | //************************************************************************** |
| 93 | // LIVE DEVICE |
| 94 | //************************************************************************** |
| 95 | |
| 96 | //------------------------------------------------- |
| 97 | // mos8722_device - constructor |
| 98 | //------------------------------------------------- |
| 99 | |
| 100 | mos8722_device::mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 101 | : device_t(mconfig, MOS8722, "MOS8722", tag, owner, clock) |
| 102 | { |
| 103 | } |
| 104 | |
| 105 | |
| 106 | //------------------------------------------------- |
| 107 | // device_config_complete - perform any |
| 108 | // operations now that the configuration is |
| 109 | // complete |
| 110 | //------------------------------------------------- |
| 111 | |
| 112 | void mos8722_device::device_config_complete() |
| 113 | { |
| 114 | // inherit a copy of the static data |
| 115 | const mos8722_interface *intf = reinterpret_cast<const mos8722_interface *>(static_config()); |
| 116 | if (intf != NULL) |
| 117 | *static_cast<mos8722_interface *>(this) = *intf; |
| 118 | |
| 119 | // or initialize to defaults if none provided |
| 120 | else |
| 121 | { |
| 122 | memset(&m_out_z80en_cb, 0, sizeof(m_out_z80en_cb)); |
| 123 | memset(&m_out_fsdir_cb, 0, sizeof(m_out_fsdir_cb)); |
| 124 | memset(&m_in_game_cb, 0, sizeof(m_in_game_cb)); |
| 125 | memset(&m_in_exrom_cb, 0, sizeof(m_in_exrom_cb)); |
| 126 | memset(&m_in_sense40_cb, 0, sizeof(m_in_sense40_cb)); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | |
| 131 | //------------------------------------------------- |
| 132 | // device_start - device-specific startup |
| 133 | //------------------------------------------------- |
| 134 | |
| 135 | void mos8722_device::device_start() |
| 136 | { |
| 137 | // resolve callbacks |
| 138 | m_out_z80en_func.resolve(m_out_z80en_cb, *this); |
| 139 | m_out_fsdir_func.resolve(m_out_fsdir_cb, *this); |
| 140 | m_in_game_func.resolve(m_in_game_cb, *this); |
| 141 | m_in_exrom_func.resolve(m_in_exrom_cb, *this); |
| 142 | m_in_sense40_func.resolve(m_in_sense40_cb, *this); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | //------------------------------------------------- |
| 147 | // device_reset - device-specific reset |
| 148 | //------------------------------------------------- |
| 149 | |
| 150 | void mos8722_device::device_reset() |
| 151 | { |
| 152 | } |
| 153 | |
| 154 | |
| 155 | //------------------------------------------------- |
| 156 | // read - register read |
| 157 | //------------------------------------------------- |
| 158 | |
| 159 | READ8_MEMBER( mos8722_device::read ) |
| 160 | { |
| 161 | return 0; |
| 162 | } |
| 163 | |
| 164 | |
| 165 | //------------------------------------------------- |
| 166 | // write - register write |
| 167 | //------------------------------------------------- |
| 168 | |
| 169 | WRITE8_MEMBER( mos8722_device::write ) |
| 170 | { |
| 171 | } |
| 172 | |
| 173 | |
| 174 | //------------------------------------------------- |
| 175 | // fsdir_r - fast serial direction read |
| 176 | //------------------------------------------------- |
| 177 | |
| 178 | READ_LINE_MEMBER( mos8722_device::fsdir_r ) |
| 179 | { |
| 180 | return 1; |
| 181 | } |
| 182 | |
| 183 | |
| 184 | //------------------------------------------------- |
| 185 | // ms0_r - memory status 0 read |
| 186 | //------------------------------------------------- |
| 187 | |
| 188 | READ_LINE_MEMBER( mos8722_device::ms0_r ) |
| 189 | { |
| 190 | return 1; |
| 191 | } |
| 192 | |
| 193 | |
| 194 | //------------------------------------------------- |
| 195 | // ms1_r - memory status 1 read |
| 196 | //------------------------------------------------- |
| 197 | |
| 198 | READ_LINE_MEMBER( mos8722_device::ms1_r ) |
| 199 | { |
| 200 | return 1; |
| 201 | } |
| 202 | |
| 203 | |
| 204 | //------------------------------------------------- |
| 205 | // ms2_r - memory status 2 read |
| 206 | //------------------------------------------------- |
| 207 | |
| 208 | READ_LINE_MEMBER( mos8722_device::ms2_r ) |
| 209 | { |
| 210 | return 1; |
| 211 | } |
| 212 | |
| 213 | |
| 214 | //------------------------------------------------- |
| 215 | // ms3_r - memory status 3 read |
| 216 | //------------------------------------------------- |
| 217 | |
| 218 | READ_LINE_MEMBER( mos8722_device::ms3_r ) |
| 219 | { |
| 220 | return 1; |
| 221 | } |
| 222 | |
| 223 | |
| 224 | //------------------------------------------------- |
| 225 | // ta_r - translated address read |
| 226 | //------------------------------------------------- |
| 227 | |
| 228 | offs_t mos8722_device::ta_r(offs_t offset, int aec) |
| 229 | { |
| 230 | return offset; |
| 231 | } |
trunk/src/mess/machine/mos8722.h
| r0 | r17757 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | MOS Technology 8722 Memory Management Unit emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | ********************************************************************** |
| 9 | _____ _____ |
| 10 | Vdd 1 |* \_/ | 48 SENSE40 |
| 11 | _RESET 2 | | 47 (MS3) 128/64 |
| 12 | TA15 3 | | 46 _EXROM |
| 13 | TA14 4 | | 45 _GAME |
| 14 | TA13 5 | | 44 FSDIR |
| 15 | TA12 6 | | 43 _Z80EN |
| 16 | TA11 7 | | 42 D7 |
| 17 | TA10 8 | | 41 D6 |
| 18 | TA9 9 | | 40 D5 |
| 19 | TA8 10 | | 39 D4 |
| 20 | _CAS1 11 | | 38 D3 |
| 21 | _CAS0 12 | MOS8722 | 37 D2 |
| 22 | I/O SEL (MS2) 13 | | 36 D1 |
| 23 | ROMBANK1 (MS1) 14 | | 35 D0 |
| 24 | ROMBANK0 (MS0) 15 | | 34 Vss |
| 25 | AEC 16 | | 33 phi0 |
| 26 | MUX 17 | | 32 R/_W |
| 27 | A0 18 | | 31 A15 |
| 28 | A1 19 | | 30 A14 |
| 29 | A2 20 | | 29 A13 |
| 30 | A3 21 | | 28 A12 |
| 31 | A4/A5 22 | | 27 A11 |
| 32 | A6/A7 23 | | 26 A10 |
| 33 | A8 24 |_____________| 25 A9 |
| 34 | |
| 35 | **********************************************************************/ |
| 36 | |
| 37 | #pragma once |
| 38 | |
| 39 | #ifndef __MOS8722__ |
| 40 | #define __MOS8722__ |
| 41 | |
| 42 | #include "emu.h" |
| 43 | |
| 44 | |
| 45 | |
| 46 | //************************************************************************** |
| 47 | // INTERFACE CONFIGURATION MACROS |
| 48 | //************************************************************************** |
| 49 | |
| 50 | #define MCFG_MOS8722_ADD(_tag, _config) \ |
| 51 | MCFG_DEVICE_ADD(_tag, MOS8722, 0) \ |
| 52 | MCFG_DEVICE_CONFIG(_config) |
| 53 | |
| 54 | |
| 55 | #define MOS8722_INTERFACE(name) \ |
| 56 | const mos8722_interface (name) = |
| 57 | |
| 58 | |
| 59 | |
| 60 | //************************************************************************** |
| 61 | // TYPE DEFINITIONS |
| 62 | //************************************************************************** |
| 63 | |
| 64 | // ======================> mos8722_interface |
| 65 | |
| 66 | struct mos8722_interface |
| 67 | { |
| 68 | devcb_write_line m_out_z80en_cb; |
| 69 | devcb_write_line m_out_fsdir_cb; |
| 70 | devcb_read_line m_in_game_cb; |
| 71 | devcb_read_line m_in_exrom_cb; |
| 72 | devcb_read_line m_in_sense40_cb; |
| 73 | }; |
| 74 | |
| 75 | |
| 76 | // ======================> mos8722_device |
| 77 | |
| 78 | class mos8722_device : public device_t, |
| 79 | public mos8722_interface |
| 80 | { |
| 81 | public: |
| 82 | // construction/destruction |
| 83 | mos8722_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock); |
| 84 | |
| 85 | DECLARE_READ8_MEMBER( read ); |
| 86 | DECLARE_WRITE8_MEMBER( write ); |
| 87 | |
| 88 | DECLARE_READ_LINE_MEMBER( fsdir_r ); |
| 89 | DECLARE_READ_LINE_MEMBER( ms0_r ); |
| 90 | DECLARE_READ_LINE_MEMBER( ms1_r ); |
| 91 | DECLARE_READ_LINE_MEMBER( ms2_r ); |
| 92 | DECLARE_READ_LINE_MEMBER( ms3_r ); |
| 93 | |
| 94 | offs_t ta_r(offs_t offset, int aec); |
| 95 | |
| 96 | protected: |
| 97 | // device-level overrides |
| 98 | virtual void device_config_complete(); |
| 99 | virtual void device_start(); |
| 100 | virtual void device_reset(); |
| 101 | |
| 102 | private: |
| 103 | devcb_resolved_write_line m_out_z80en_func; |
| 104 | devcb_resolved_write_line m_out_fsdir_func; |
| 105 | devcb_resolved_read_line m_in_game_func; |
| 106 | devcb_resolved_read_line m_in_exrom_func; |
| 107 | devcb_resolved_read_line m_in_sense40_func; |
| 108 | |
| 109 | UINT8 m_reg[10]; |
| 110 | }; |
| 111 | |
| 112 | |
| 113 | // device type definition |
| 114 | extern const device_type MOS8722; |
| 115 | |
| 116 | |
| 117 | |
| 118 | #endif |