trunk/src/mess/audio/dave.c
| r23493 | r23494 | |
| 1 | 1 | /********************************************************************** |
| 2 | 2 | |
| 3 | | "Dave" Sound Chip |
| 3 | Intelligent Designs DAVE emulation |
| 4 | 4 | |
| 5 | | DAVE SOUND CHIP FOUND IN ENTERPRISE |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 6 | 7 | |
| 7 | | working: |
| 8 | **********************************************************************/ |
| 8 | 9 | |
| 9 | | - pure tone |
| 10 | | - sampled sounds |
| 11 | | - 1 kHz, 50 Hz and 1 Hz ints |
| 12 | | - external ints (int1 and int2) - not correct speed yet |
| 10 | #include "dave.h" |
| 13 | 11 | |
| 14 | | **********************************************************************/ |
| 15 | 12 | |
| 16 | | #include "emu.h" |
| 17 | | #include "audio/dave.h" |
| 18 | 13 | |
| 14 | //************************************************************************** |
| 15 | // MACROS / CONSTANTS |
| 16 | //************************************************************************** |
| 19 | 17 | |
| 20 | | /*************************************************************************** |
| 21 | | MACROS / CONSTANTS |
| 22 | | ***************************************************************************/ |
| 18 | #define LOG 0 |
| 23 | 19 | |
| 24 | 20 | #define STEP 0x08000 |
| 25 | 21 | |
| 26 | 22 | |
| 27 | | /*************************************************************************** |
| 28 | | IMPLEMENTATION |
| 29 | | ***************************************************************************/ |
| 30 | 23 | |
| 31 | | const device_type DAVE = &device_creator<dave_sound_device>; |
| 24 | //************************************************************************** |
| 25 | // DEVICE DEFINITIONS |
| 26 | //************************************************************************** |
| 32 | 27 | |
| 33 | | dave_sound_device::dave_sound_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 34 | | : device_t(mconfig, DAVE, "Dave", tag, owner, clock), |
| 35 | | device_sound_interface(mconfig, *this) |
| 36 | | { |
| 37 | | } |
| 28 | const device_type DAVE = &device_creator<dave_device>; |
| 38 | 29 | |
| 30 | |
| 31 | DEVICE_ADDRESS_MAP_START( z80_program_map, 8, dave_device ) |
| 32 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(program_r, program_w) |
| 33 | ADDRESS_MAP_END |
| 34 | |
| 35 | DEVICE_ADDRESS_MAP_START( z80_io_map, 8, dave_device ) |
| 36 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(io_r, io_w) |
| 37 | ADDRESS_MAP_END |
| 38 | |
| 39 | static ADDRESS_MAP_START( program_map, DAVE_AS_PROGRAM, 8, dave_device ) |
| 40 | ADDRESS_MAP_END |
| 41 | |
| 42 | static ADDRESS_MAP_START( io_map, DAVE_AS_IO, 8, dave_device ) |
| 43 | ADDRESS_MAP_END |
| 44 | |
| 45 | |
| 46 | |
| 47 | //************************************************************************** |
| 48 | // LIVE DEVICE |
| 49 | //************************************************************************** |
| 50 | |
| 39 | 51 | //------------------------------------------------- |
| 40 | | // device_config_complete - perform any |
| 41 | | // operations now that the configuration is |
| 42 | | // complete |
| 52 | // dave_device - constructor |
| 43 | 53 | //------------------------------------------------- |
| 44 | 54 | |
| 45 | | void dave_sound_device::device_config_complete() |
| 55 | dave_device::dave_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 56 | : device_t(mconfig, DAVE, "DAVE", tag, owner, clock), |
| 57 | device_memory_interface(mconfig, *this), |
| 58 | device_sound_interface(mconfig, *this), |
| 59 | m_program_space_config("program", ENDIANNESS_LITTLE, 8, 22, 0, *ADDRESS_MAP_NAME(program_map)), |
| 60 | m_io_space_config("I/O", ENDIANNESS_LITTLE, 8, 16, 0, *ADDRESS_MAP_NAME(io_map)), |
| 61 | m_write_irq(*this), |
| 62 | m_write_lh(*this), |
| 63 | m_write_rh(*this) |
| 46 | 64 | { |
| 47 | | // inherit a copy of the static data |
| 48 | | const dave_interface *intf = reinterpret_cast<const dave_interface *>(static_config()); |
| 49 | | if (intf != NULL) |
| 50 | | *static_cast<dave_interface *>(this) = *intf; |
| 51 | | |
| 52 | | // or initialize to defaults if none provided |
| 53 | | else |
| 54 | | { |
| 55 | | memset(&m_reg_r_cb, 0, sizeof(m_reg_r_cb)); |
| 56 | | memset(&m_reg_w_cb, 0, sizeof(m_reg_w_cb)); |
| 57 | | memset(&m_int_cb, 0, sizeof(m_int_cb)); |
| 58 | | } |
| 59 | 65 | } |
| 60 | 66 | |
| 67 | |
| 61 | 68 | //------------------------------------------------- |
| 62 | 69 | // device_start - device-specific startup |
| 63 | 70 | //------------------------------------------------- |
| 64 | 71 | |
| 65 | | void dave_sound_device::device_start() |
| 72 | void dave_device::device_start() |
| 66 | 73 | { |
| 67 | | m_reg_r.resolve(m_reg_r_cb, *this); |
| 68 | | m_reg_w.resolve(m_reg_w_cb, *this); |
| 69 | | m_int_callback.resolve(m_int_cb, *this); |
| 74 | // resolve callbacks |
| 75 | m_write_irq.resolve_safe(); |
| 76 | m_write_lh.resolve_safe(); |
| 77 | m_write_rh.resolve_safe(); |
| 78 | |
| 79 | // allocate timers |
| 80 | m_timer_1hz = timer_alloc(TIMER_1HZ); |
| 81 | m_timer_1hz->adjust(attotime::from_hz(2), 0, attotime::from_hz(2)); |
| 70 | 82 | |
| 71 | | /* temp! */ |
| 72 | | m_nick_virq = 0; |
| 73 | | |
| 74 | | /* initialise 1kHz timer */ |
| 75 | | m_int_latch = 0; |
| 76 | | m_int_input = 0; |
| 77 | | m_int_enable = 0; |
| 78 | | m_timer_irq = 0; |
| 79 | | m_fifty_hz_state = 0; |
| 80 | | m_one_khz_state = 0; |
| 81 | | m_fifty_hz_count = DAVE_FIFTY_HZ_COUNTER_RELOAD; |
| 82 | | m_one_hz_count = DAVE_ONE_HZ_COUNTER_RELOAD; |
| 83 | | machine().scheduler().timer_pulse(attotime::from_hz(1000), timer_expired_delegate(FUNC(dave_sound_device::dave_1khz_callback),this)); |
| 84 | | |
| 83 | m_timer_50hz = timer_alloc(TIMER_50HZ); |
| 84 | m_timer_50hz->adjust(attotime::from_hz(2000), 0, attotime::from_hz(2000)); |
| 85 | |
| 86 | // state saving |
| 87 | save_item(NAME(m_segment)); |
| 88 | save_item(NAME(m_irq_status)); |
| 89 | save_item(NAME(m_irq_enable)); |
| 90 | save_item(NAME(m_period)); |
| 91 | save_item(NAME(m_count)); |
| 92 | save_item(NAME(m_level)); |
| 93 | save_item(NAME(m_level_or)); |
| 94 | save_item(NAME(m_level_and)); |
| 95 | save_item(NAME(m_mame_volumes)); |
| 96 | |
| 85 | 97 | for (int i = 0; i < 3; i++) |
| 86 | 98 | { |
| 87 | 99 | m_period[i] = (STEP * machine().sample_rate()) / 125000; |
| r23493 | r23494 | |
| 94 | 106 | |
| 95 | 107 | /* 3 tone channels + 1 noise channel */ |
| 96 | 108 | m_sound_stream_var = machine().sound().stream_alloc(*this, 0, 2, machine().sample_rate(), this); |
| 97 | | |
| 98 | | save_item(NAME(m_regs)); |
| 99 | | save_item(NAME(m_int_latch)); |
| 100 | | save_item(NAME(m_int_enable)); |
| 101 | | save_item(NAME(m_int_input)); |
| 102 | | save_item(NAME(m_int_irq)); |
| 103 | | save_item(NAME(m_timer_irq)); |
| 104 | | save_item(NAME(m_one_khz_state)); |
| 105 | | save_item(NAME(m_one_hz_count)); |
| 106 | | save_item(NAME(m_fifty_hz_state)); |
| 107 | | save_item(NAME(m_fifty_hz_count)); |
| 108 | | save_item(NAME(m_period)); |
| 109 | | save_item(NAME(m_count)); |
| 110 | | save_item(NAME(m_level)); |
| 111 | | save_item(NAME(m_level_or)); |
| 112 | | save_item(NAME(m_level_and)); |
| 113 | | save_item(NAME(m_mame_volumes)); |
| 114 | | save_item(NAME(m_nick_virq)); |
| 115 | 109 | } |
| 116 | 110 | |
| 111 | |
| 117 | 112 | //------------------------------------------------- |
| 118 | 113 | // device_reset - device-specific reset |
| 119 | 114 | //------------------------------------------------- |
| 120 | 115 | |
| 121 | | void dave_sound_device::device_reset() |
| 116 | void dave_device::device_reset() |
| 122 | 117 | { |
| 118 | m_write_irq(CLEAR_LINE); |
| 119 | |
| 120 | for (int i = 0; i < 4; i++) |
| 121 | m_segment[i] = 0; |
| 122 | |
| 123 | m_irq_status = 0; |
| 124 | m_irq_enable = 0; |
| 125 | |
| 123 | 126 | for (int i = 0; i < 32; i++) |
| 124 | 127 | m_regs[i] = 0; |
| 125 | | |
| 126 | | address_space &space = machine().driver_data()->generic_space(); |
| 127 | | reg_w(space, 0x10, 0); |
| 128 | | reg_w(space, 0x11, 0); |
| 129 | | reg_w(space, 0x12, 0); |
| 130 | | reg_w(space, 0x13, 0); |
| 131 | 128 | } |
| 132 | 129 | |
| 133 | 130 | |
| 134 | | /*------------------------------------------------- |
| 135 | | dave_refresh_ints |
| 136 | | -------------------------------------------------*/ |
| 131 | //------------------------------------------------- |
| 132 | // device_timer - handler timer events |
| 133 | //------------------------------------------------- |
| 137 | 134 | |
| 138 | | void dave_sound_device::refresh_ints() |
| 135 | void dave_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 139 | 136 | { |
| 140 | | int int_wanted; |
| 137 | switch (id) |
| 138 | { |
| 139 | case TIMER_1HZ: |
| 140 | m_irq_status ^= IRQ_1HZ_DIVIDER; |
| 141 | 141 | |
| 142 | | logerror("int latch: %02x enable: %02x input: %02x\n", (int) m_int_latch, (int) m_int_enable, (int) m_int_input); |
| 142 | if (m_irq_status & IRQ_1HZ_DIVIDER) |
| 143 | m_irq_status |= IRQ_1HZ_LATCH; |
| 144 | break; |
| 143 | 145 | |
| 144 | | int_wanted = ((m_int_enable << 1) & m_int_latch) != 0; |
| 145 | | m_int_callback(int_wanted); |
| 146 | case TIMER_50HZ: |
| 147 | m_irq_status ^= IRQ_50HZ_DIVIDER; |
| 148 | |
| 149 | if (m_irq_status & IRQ_50HZ_DIVIDER) |
| 150 | m_irq_status |= IRQ_50HZ_LATCH; |
| 151 | break; |
| 152 | } |
| 153 | |
| 154 | update_interrupt(); |
| 146 | 155 | } |
| 147 | 156 | |
| 148 | 157 | |
| 149 | | /*------------------------------------------------- |
| 150 | | dave_refresh_selectable_int |
| 151 | | -------------------------------------------------*/ |
| 158 | //------------------------------------------------- |
| 159 | // memory_space_config - return a description of |
| 160 | // any address spaces owned by this device |
| 161 | //------------------------------------------------- |
| 152 | 162 | |
| 153 | | void dave_sound_device::refresh_selectable_int() |
| 163 | const address_space_config *dave_device::memory_space_config(address_spacenum spacenum) const |
| 154 | 164 | { |
| 155 | | /* update 1kHz/50Hz/tg latch and int input */ |
| 156 | | switch ((m_regs[7]>>5) & 0x03) |
| 165 | switch (spacenum) |
| 157 | 166 | { |
| 158 | | /* 1kHz */ |
| 159 | | case 0: |
| 160 | | m_int_latch &= ~(1<<1); |
| 161 | | m_int_latch |= (m_int_irq >> 1) & 0x02; |
| 167 | case DAVE_AS_PROGRAM: return &m_program_space_config; |
| 168 | case DAVE_AS_IO: return &m_io_space_config; |
| 169 | default: return NULL; |
| 170 | } |
| 171 | } |
| 162 | 172 | |
| 163 | | /* set int input state */ |
| 164 | | m_int_input &= ~(1<<0); |
| 165 | | m_int_input |= (m_one_khz_state & 0x01) << 0; |
| 166 | | break; |
| 167 | 173 | |
| 168 | | /* 50Hz */ |
| 169 | | case 1: |
| 170 | | m_int_latch &= ~(1<<1); |
| 171 | | m_int_latch |= m_int_irq & 0x02; |
| 174 | //------------------------------------------------- |
| 175 | // sound_stream_update - handle a stream update |
| 176 | //------------------------------------------------- |
| 172 | 177 | |
| 173 | | /* set int input state */ |
| 174 | | m_int_input &= ~(1<<0); |
| 175 | | m_int_input |= (m_fifty_hz_state & 0x01) << 0; |
| 176 | | break; |
| 178 | void dave_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 179 | { |
| 180 | stream_sample_t *buffer1, *buffer2; |
| 181 | /* 0 = channel 0 left volume, 1 = channel 0 right volume, |
| 182 | 2 = channel 1 left volume, 3 = channel 1 right volume, |
| 183 | 4 = channel 2 left volume, 5 = channel 2 right volume |
| 184 | 6 = noise channel left volume, 7 = noise channel right volume */ |
| 185 | int output_volumes[8]; |
| 186 | int left_volume; |
| 187 | int right_volume; |
| 188 | |
| 189 | //logerror("sound update!\n"); |
| 190 | |
| 191 | buffer1 = outputs[0]; |
| 192 | buffer2 = outputs[1]; |
| 193 | |
| 194 | while (samples) |
| 195 | { |
| 196 | int vol[4]; |
| 197 | |
| 198 | /* vol[] keeps track of how long each square wave stays */ |
| 199 | /* in the 1 position during the sample period. */ |
| 200 | vol[0] = vol[1] = vol[2] = vol[3] = 0; |
| 201 | |
| 202 | for (int i = 0; i < 3; i++) |
| 203 | { |
| 204 | if ((m_regs[7] & (1 << i))==0) |
| 205 | { |
| 206 | if (m_level[i]) vol[i] += m_count[i]; |
| 207 | m_count[i] -= STEP; |
| 208 | /* Period[i] is the half period of the square wave. Here, in each */ |
| 209 | /* loop I add Period[i] twice, so that at the end of the loop the */ |
| 210 | /* square wave is in the same status (0 or 1) it was at the start. */ |
| 211 | /* vol[i] is also incremented by Period[i], since the wave has been 1 */ |
| 212 | /* exactly half of the time, regardless of the initial position. */ |
| 213 | /* If we exit the loop in the middle, Output[i] has to be inverted */ |
| 214 | /* and vol[i] incremented only if the exit status of the square */ |
| 215 | /* wave is 1. */ |
| 216 | while (m_count[i] <= 0) |
| 217 | { |
| 218 | m_count[i] += m_period[i]; |
| 219 | if (m_count[i] > 0) |
| 220 | { |
| 221 | m_level[i] ^= 0x0ffffffff; |
| 222 | if (m_level[i]) vol[i] += m_period[i]; |
| 223 | break; |
| 224 | } |
| 225 | m_count[i] += m_period[i]; |
| 226 | vol[i] += m_period[i]; |
| 227 | } |
| 228 | if (m_level[i]) |
| 229 | vol[i] -= m_count[i]; |
| 230 | } |
| 231 | } |
| 232 | |
| 233 | /* update volume outputs */ |
| 234 | |
| 235 | /* setup output volumes for each channel */ |
| 236 | /* channel 0 */ |
| 237 | output_volumes[0] = ((m_level[0] & m_level_and[0]) | m_level_or[0]) & m_mame_volumes[0]; |
| 238 | output_volumes[1] = ((m_level[0] & m_level_and[1]) | m_level_or[1]) & m_mame_volumes[4]; |
| 239 | /* channel 1 */ |
| 240 | output_volumes[2] = ((m_level[1] & m_level_and[2]) | m_level_or[2]) & m_mame_volumes[1]; |
| 241 | output_volumes[3] = ((m_level[1] & m_level_and[3]) | m_level_or[3]) & m_mame_volumes[5]; |
| 242 | /* channel 2 */ |
| 243 | output_volumes[4] = ((m_level[2] & m_level_and[4]) | m_level_or[4]) & m_mame_volumes[2]; |
| 244 | output_volumes[5] = ((m_level[2] & m_level_and[5]) | m_level_or[5]) & m_mame_volumes[6]; |
| 245 | /* channel 3 */ |
| 246 | output_volumes[6] = ((m_level[3] & m_level_and[6]) | m_level_or[6]) & m_mame_volumes[3]; |
| 247 | output_volumes[7] = ((m_level[3] & m_level_and[7]) | m_level_or[7]) & m_mame_volumes[7]; |
| 248 | |
| 249 | left_volume = (output_volumes[0] + output_volumes[2] + output_volumes[4] + output_volumes[6])>>2; |
| 250 | right_volume = (output_volumes[1] + output_volumes[3] + output_volumes[5] + output_volumes[7])>>2; |
| 251 | |
| 252 | *(buffer1++) = left_volume; |
| 253 | *(buffer2++) = right_volume; |
| 254 | |
| 255 | samples--; |
| 256 | } |
| 257 | } |
| 177 | 258 | |
| 178 | 259 | |
| 179 | | default: |
| 180 | | break; |
| 181 | | } |
| 260 | //------------------------------------------------- |
| 261 | // int1_w - interrupt 1 write |
| 262 | //------------------------------------------------- |
| 182 | 263 | |
| 183 | | refresh_ints(); |
| 264 | WRITE_LINE_MEMBER( dave_device::int1_w ) |
| 265 | { |
| 266 | if (!(m_irq_status & IRQ_INT1) && state) |
| 267 | m_irq_status |= IRQ_INT1_LATCH; |
| 268 | |
| 269 | if (state) |
| 270 | m_irq_status |= IRQ_INT1; |
| 271 | else |
| 272 | m_irq_status &= ~IRQ_INT1; |
| 273 | |
| 274 | update_interrupt(); |
| 184 | 275 | } |
| 185 | 276 | |
| 186 | 277 | |
| 187 | | /*------------------------------------------------- |
| 188 | | dave_1khz_callback |
| 189 | | -------------------------------------------------*/ |
| 278 | //------------------------------------------------- |
| 279 | // int2_w - interrupt 2 write |
| 280 | //------------------------------------------------- |
| 190 | 281 | |
| 191 | | TIMER_CALLBACK_MEMBER(dave_sound_device::dave_1khz_callback) |
| 282 | WRITE_LINE_MEMBER( dave_device::int2_w ) |
| 192 | 283 | { |
| 193 | | /* time over - want int */ |
| 194 | | m_one_khz_state ^= 0x0ffffffff; |
| 284 | if (!(m_irq_status & IRQ_INT2) && state) |
| 285 | m_irq_status |= IRQ_INT2_LATCH; |
| 195 | 286 | |
| 196 | | /* lo-high transition causes int */ |
| 197 | | if (m_one_khz_state != 0) |
| 198 | | { |
| 199 | | m_int_irq |= (1<<2); |
| 200 | | } |
| 287 | if (state) |
| 288 | m_irq_status |= IRQ_INT2; |
| 289 | else |
| 290 | m_irq_status &= ~IRQ_INT2; |
| 201 | 291 | |
| 292 | update_interrupt(); |
| 293 | } |
| 202 | 294 | |
| 203 | | /* update fifty Hz counter */ |
| 204 | | m_fifty_hz_count--; |
| 205 | 295 | |
| 206 | | if (m_fifty_hz_count == 0) |
| 207 | | { |
| 208 | | /* these two lines are temp here */ |
| 209 | | m_nick_virq ^= 0x0ffffffff; |
| 210 | | set_external_int_state(DAVE_INT1_ID, m_nick_virq); |
| 296 | //------------------------------------------------- |
| 297 | // program_r - program space read |
| 298 | //------------------------------------------------- |
| 211 | 299 | |
| 300 | READ8_MEMBER( dave_device::program_r ) |
| 301 | { |
| 302 | UINT8 segment = m_segment[offset >> 14]; |
| 303 | offset = (segment << 14) | (offset & 0x3fff); |
| 212 | 304 | |
| 213 | | m_fifty_hz_count = DAVE_FIFTY_HZ_COUNTER_RELOAD; |
| 214 | | m_fifty_hz_state ^= 0x0ffffffff; |
| 305 | return m_addrspace[0]->read_byte(offset); |
| 306 | } |
| 215 | 307 | |
| 216 | | if (m_fifty_hz_state != 0) |
| 217 | | { |
| 218 | | m_int_irq |= (1<<1); |
| 219 | | } |
| 220 | | } |
| 221 | 308 | |
| 222 | | m_one_hz_count--; |
| 309 | //------------------------------------------------- |
| 310 | // program_w - program space write |
| 311 | //------------------------------------------------- |
| 223 | 312 | |
| 224 | | if (m_one_hz_count == 0) |
| 313 | WRITE8_MEMBER( dave_device::program_w ) |
| 314 | { |
| 315 | UINT8 segment = m_segment[offset >> 14]; |
| 316 | offset = (segment << 14) | (offset & 0x3fff); |
| 317 | |
| 318 | m_addrspace[0]->write_byte(offset, data); |
| 319 | } |
| 320 | |
| 321 | |
| 322 | //------------------------------------------------- |
| 323 | // io_r - I/O space read |
| 324 | //------------------------------------------------- |
| 325 | |
| 326 | READ8_MEMBER( dave_device::io_r ) |
| 327 | { |
| 328 | UINT8 data = 0; |
| 329 | |
| 330 | switch (offset & 0xff) |
| 225 | 331 | { |
| 226 | | /* reload counter */ |
| 227 | | m_one_hz_count = DAVE_ONE_HZ_COUNTER_RELOAD; |
| 332 | case 0xa0: |
| 333 | case 0xa1: |
| 334 | case 0xa2: |
| 335 | case 0xa3: |
| 336 | case 0xa4: |
| 337 | case 0xa5: |
| 338 | case 0xa6: |
| 339 | case 0xa7: |
| 340 | case 0xa8: |
| 341 | case 0xa9: |
| 342 | case 0xaa: |
| 343 | case 0xab: |
| 344 | case 0xac: |
| 345 | case 0xad: |
| 346 | case 0xae: |
| 347 | case 0xaf: |
| 348 | case 0xb8: |
| 349 | case 0xb9: |
| 350 | case 0xba: |
| 351 | case 0xbb: |
| 352 | case 0xbc: |
| 353 | case 0xbd: |
| 354 | case 0xbe: |
| 355 | case 0xbf: |
| 356 | data = 0xff; |
| 357 | break; |
| 228 | 358 | |
| 229 | | /* change state */ |
| 230 | | m_int_input ^= (1<<2); |
| 359 | case 0xb0: case 0xb1: case 0xb2: case 0xb3: |
| 360 | data = m_segment[offset & 0x03]; |
| 361 | break; |
| 231 | 362 | |
| 232 | | if (m_int_input & (1<<2)) |
| 233 | | { |
| 234 | | /* transition from 0->1 */ |
| 235 | | /* int requested */ |
| 236 | | m_int_latch |=(1<<3); |
| 237 | | } |
| 363 | case 0xb4: |
| 364 | data = m_irq_status; |
| 365 | break; |
| 366 | |
| 367 | default: |
| 368 | data = m_addrspace[1]->read_byte(offset); |
| 238 | 369 | } |
| 239 | 370 | |
| 240 | | refresh_selectable_int(); |
| 371 | return data; |
| 241 | 372 | } |
| 242 | 373 | |
| 243 | 374 | |
| 244 | | /*------------------------------------------------- |
| 245 | | dave_sound_w - used to update sound output |
| 246 | | based on data writes |
| 247 | | -------------------------------------------------*/ |
| 375 | //------------------------------------------------- |
| 376 | // io_w - I/O space write |
| 377 | //------------------------------------------------- |
| 248 | 378 | |
| 249 | | WRITE8_MEMBER(dave_sound_device::sound_w) |
| 379 | WRITE8_MEMBER( dave_device::io_w ) |
| 250 | 380 | { |
| 251 | | /* update stream */ |
| 252 | | m_sound_stream_var->update(); |
| 253 | | |
| 254 | | /* new write */ |
| 255 | | switch (offset) |
| 381 | switch (offset & 0xff) |
| 256 | 382 | { |
| 257 | 383 | /* channel 0 down-counter */ |
| 258 | | case 0: |
| 259 | | case 1: |
| 384 | case 0xa0: |
| 385 | case 0xa1: |
| 260 | 386 | /* channel 1 down-counter */ |
| 261 | | case 2: |
| 262 | | case 3: |
| 387 | case 0xa2: |
| 388 | case 0xa3: |
| 263 | 389 | /* channel 2 down-counter */ |
| 264 | | case 4: |
| 265 | | case 5: |
| 266 | | { |
| 267 | | int count = 0; |
| 268 | | int channel_index = offset>>1; |
| 390 | case 0xa4: |
| 391 | case 0xa5: |
| 392 | { |
| 393 | int count = 0; |
| 394 | int channel_index = offset>>1; |
| 269 | 395 | |
| 270 | | /* Fout = 125,000 / (n+1) Hz */ |
| 396 | /* Fout = 125,000 / (n+1) Hz */ |
| 271 | 397 | |
| 272 | | /* sample rate/clock */ |
| 398 | /* sample rate/clock */ |
| 273 | 399 | |
| 274 | 400 | |
| 275 | | /* get down-count */ |
| 276 | | switch (offset & 0x01) |
| 277 | | { |
| 278 | | case 0: |
| 401 | /* get down-count */ |
| 402 | switch (offset & 0x01) |
| 279 | 403 | { |
| 280 | | count = (data & 0x0ff) | ((m_regs[offset + 1] & 0x0f)<<8); |
| 281 | | } |
| 282 | | break; |
| 404 | case 0: |
| 405 | { |
| 406 | count = (data & 0x0ff) | ((m_regs[offset + 1] & 0x0f)<<8); |
| 407 | } |
| 408 | break; |
| 283 | 409 | |
| 284 | | case 1: |
| 285 | | { |
| 286 | | count = (m_regs[offset - 1] & 0x0ff) | ((data & 0x0f)<<8); |
| 410 | case 1: |
| 411 | { |
| 412 | count = (m_regs[offset - 1] & 0x0ff) | ((data & 0x0f)<<8); |
| 287 | 413 | |
| 414 | } |
| 415 | break; |
| 288 | 416 | } |
| 289 | | break; |
| 290 | | } |
| 291 | 417 | |
| 292 | | count++; |
| 418 | count++; |
| 293 | 419 | |
| 294 | 420 | |
| 295 | | m_period[channel_index] = ((STEP * machine().sample_rate())/125000) * count; |
| 421 | m_period[channel_index] = ((STEP * machine().sample_rate())/125000) * count; |
| 296 | 422 | |
| 297 | | } |
| 298 | | break; |
| 423 | m_regs[offset & 0x01f] = data; |
| 424 | } |
| 425 | break; |
| 299 | 426 | |
| 300 | 427 | /* channel 0 left volume */ |
| 301 | | case 8: |
| 428 | case 0xa8: |
| 302 | 429 | /* channel 1 left volume */ |
| 303 | | case 9: |
| 430 | case 0xa9: |
| 304 | 431 | /* channel 2 left volume */ |
| 305 | | case 10: |
| 432 | case 0xaa: |
| 306 | 433 | /* noise channel left volume */ |
| 307 | | case 11: |
| 434 | case 0xab: |
| 308 | 435 | /* channel 0 right volume */ |
| 309 | | case 12: |
| 436 | case 0xac: |
| 310 | 437 | /* channel 1 right volume */ |
| 311 | | case 13: |
| 438 | case 0xad: |
| 312 | 439 | /* channel 2 right volume */ |
| 313 | | case 14: |
| 440 | case 0xae: |
| 314 | 441 | /* noise channel right volume */ |
| 315 | | case 15: |
| 316 | | { |
| 317 | | /* update mame version of volume from data written */ |
| 318 | | /* 0x03f->0x07e00. Max is 0x07fff */ |
| 319 | | /* I believe the volume is linear - to be checked! */ |
| 320 | | m_mame_volumes[offset - 8] = (data & 0x03f) << 9; |
| 321 | | } |
| 322 | | break; |
| 442 | case 0xaf: |
| 443 | { |
| 444 | /* update mame version of volume from data written */ |
| 445 | /* 0x03f->0x07e00. Max is 0x07fff */ |
| 446 | /* I believe the volume is linear - to be checked! */ |
| 447 | m_mame_volumes[offset - 8] = (data & 0x03f) << 9; |
| 323 | 448 | |
| 324 | | case 7: |
| 449 | m_regs[offset & 0x01f] = data; |
| 450 | } |
| 451 | break; |
| 452 | |
| 453 | case 0xa6: |
| 454 | break; |
| 455 | |
| 456 | case 0xa7: |
| 325 | 457 | { |
| 326 | 458 | /* force => the value of this register is forced regardless of the wave |
| 327 | 459 | state, |
| r23493 | r23494 | |
| 330 | 462 | use => the volume value is dependant on the wave state and is included |
| 331 | 463 | in the final volume calculation */ |
| 332 | 464 | |
| 333 | | logerror("selectable int "); |
| 465 | //logerror("selectable int "); |
| 334 | 466 | switch ((data>>5) & 0x03) |
| 335 | 467 | { |
| 336 | 468 | case 0: |
| 337 | 469 | { |
| 338 | | logerror("1kHz\n"); |
| 470 | //logerror("1kHz\n"); |
| 471 | m_timer_50hz->adjust(attotime::from_hz(2000), 0, attotime::from_hz(2000)); |
| 339 | 472 | } |
| 340 | 473 | break; |
| 341 | 474 | |
| 342 | 475 | case 1: |
| 343 | 476 | { |
| 344 | | logerror("50Hz\n"); |
| 477 | //logerror("50Hz\n"); |
| 478 | m_timer_50hz->adjust(attotime::from_hz(100), 0, attotime::from_hz(100)); |
| 345 | 479 | } |
| 346 | 480 | break; |
| 347 | 481 | |
| 348 | 482 | case 2: |
| 349 | 483 | { |
| 350 | | logerror("tone channel 0\n"); |
| 484 | //logerror("tone channel 0\n"); |
| 351 | 485 | } |
| 352 | 486 | break; |
| 353 | 487 | |
| 354 | 488 | case 3: |
| 355 | 489 | { |
| 356 | | logerror("tone channel 1\n"); |
| 490 | //logerror("tone channel 1\n"); |
| 357 | 491 | } |
| 358 | 492 | break; |
| 359 | 493 | } |
| r23493 | r23494 | |
| 435 | 569 | m_level_or[7] = 0x000; |
| 436 | 570 | m_level_and[7] = 0xffff; |
| 437 | 571 | } |
| 572 | |
| 573 | m_regs[offset & 0x01f] = data; |
| 438 | 574 | } |
| 439 | 575 | break; |
| 440 | 576 | |
| 441 | | default: |
| 442 | | break; |
| 443 | | } |
| 444 | | } |
| 577 | case 0xb0: case 0xb1: case 0xb2: case 0xb3: |
| 578 | m_segment[offset & 0x03] = data; |
| 445 | 579 | |
| 580 | m_regs[offset & 0x01f] = data; |
| 581 | break; |
| 446 | 582 | |
| 447 | | /*------------------------------------------------- |
| 448 | | dave_reg_w |
| 449 | | -------------------------------------------------*/ |
| 583 | case 0xb4: |
| 584 | m_irq_enable = data; |
| 585 | m_irq_status &= ~(m_irq_enable & IRQ_LATCH); |
| 586 | update_interrupt(); |
| 450 | 587 | |
| 451 | | WRITE8_MEMBER( dave_sound_device::reg_w ) |
| 452 | | { |
| 453 | | logerror("dave w: %04x %02x\n",offset,data); |
| 454 | | |
| 455 | | sound_w(space, offset, data, mem_mask); |
| 456 | | |
| 457 | | m_regs[offset & 0x01f] = data; |
| 458 | | |
| 459 | | switch (offset) |
| 460 | | { |
| 461 | | case 0x07: |
| 462 | | refresh_selectable_int(); |
| 463 | | break; |
| 464 | | |
| 465 | | case 0x014: |
| 466 | | /* enabled ints */ |
| 467 | | m_int_enable = data & 0x055; |
| 468 | | /* clear latches */ |
| 469 | | m_int_latch &=~(data & 0x0aa); |
| 470 | | |
| 471 | | /* reset 1kHz, 50Hz latch */ |
| 472 | | if (data & (1<<1)) |
| 473 | | { |
| 474 | | m_int_irq = 0; |
| 475 | | } |
| 476 | | |
| 477 | | /* refresh ints */ |
| 478 | | refresh_ints(); |
| 479 | | break; |
| 480 | | |
| 481 | | default: |
| 482 | | break; |
| 483 | | } |
| 484 | | |
| 485 | | m_reg_w(offset, data); |
| 486 | | } |
| 487 | | |
| 488 | | |
| 489 | | /*------------------------------------------------- |
| 490 | | dave_set_reg |
| 491 | | -------------------------------------------------*/ |
| 492 | | |
| 493 | | void dave_sound_device::set_reg(offs_t offset, UINT8 data) |
| 494 | | { |
| 495 | | m_regs[offset & 0x01f] = data; |
| 496 | | } |
| 497 | | |
| 498 | | |
| 499 | | /*------------------------------------------------- |
| 500 | | dave_reg_r |
| 501 | | -------------------------------------------------*/ |
| 502 | | |
| 503 | | READ8_MEMBER( dave_sound_device::reg_r ) |
| 504 | | { |
| 505 | | logerror("dave r: %04x\n",offset); |
| 506 | | |
| 507 | | m_reg_r(offset); |
| 508 | | |
| 509 | | switch (offset) |
| 510 | | { |
| 511 | | case 0x000: |
| 512 | | case 0x001: |
| 513 | | case 0x002: |
| 514 | | case 0x003: |
| 515 | | case 0x004: |
| 516 | | case 0x005: |
| 517 | | case 0x006: |
| 518 | | case 0x007: |
| 519 | | case 0x008: |
| 520 | | case 0x009: |
| 521 | | case 0x00a: |
| 522 | | case 0x00b: |
| 523 | | case 0x00c: |
| 524 | | case 0x00d: |
| 525 | | case 0x00e: |
| 526 | | case 0x00f: |
| 527 | | case 0x018: |
| 528 | | case 0x019: |
| 529 | | case 0x01a: |
| 530 | | case 0x01b: |
| 531 | | case 0x01c: |
| 532 | | case 0x01d: |
| 533 | | case 0x01e: |
| 534 | | case 0x01f: |
| 535 | | return 0x0ff; |
| 536 | | |
| 537 | | case 0x014: |
| 538 | | return (m_int_latch & 0x0aa) | (m_int_input & 0x055); |
| 539 | | |
| 540 | | |
| 541 | | default: |
| 542 | | break; |
| 543 | | } |
| 544 | | |
| 545 | | return m_regs[offset & 0x01f]; |
| 546 | | } |
| 547 | | |
| 548 | | |
| 549 | | /*------------------------------------------------- |
| 550 | | dave_set_external_int_state - negative edge |
| 551 | | triggered |
| 552 | | -------------------------------------------------*/ |
| 553 | | |
| 554 | | void dave_sound_device::set_external_int_state(int int_id, int state) |
| 555 | | { |
| 556 | | switch (int_id) |
| 557 | | { |
| 558 | | /* connected to Nick virq */ |
| 559 | | case DAVE_INT1_ID: |
| 560 | | { |
| 561 | | int previous_state; |
| 562 | | |
| 563 | | previous_state = m_int_input; |
| 564 | | |
| 565 | | m_int_input &= ~(1<<4); |
| 566 | | |
| 567 | | if (state) |
| 568 | | { |
| 569 | | m_int_input |= (1<<4); |
| 570 | | } |
| 571 | | |
| 572 | | if ((previous_state ^ m_int_input) & (1<<4)) |
| 573 | | { |
| 574 | | /* changed state */ |
| 575 | | |
| 576 | | if (m_int_input & (1<<4)) |
| 577 | | { |
| 578 | | /* int request */ |
| 579 | | m_int_latch |= (1<<5); |
| 580 | | |
| 581 | | refresh_ints(); |
| 582 | | } |
| 583 | | } |
| 584 | | |
| 585 | | } |
| 588 | m_regs[offset & 0x01f] = data; |
| 586 | 589 | break; |
| 587 | 590 | |
| 588 | | case DAVE_INT2_ID: |
| 589 | | { |
| 590 | | int previous_state; |
| 591 | | |
| 592 | | previous_state = m_int_input; |
| 593 | | |
| 594 | | m_int_input &= ~(1<<6); |
| 595 | | |
| 596 | | if (state) |
| 597 | | { |
| 598 | | m_int_input |= (1<<6); |
| 599 | | } |
| 600 | | |
| 601 | | if ((previous_state ^ m_int_input) & (1<<6)) |
| 602 | | { |
| 603 | | /* changed state */ |
| 604 | | |
| 605 | | if (m_int_input & (1<<6)) |
| 606 | | { |
| 607 | | /* int request */ |
| 608 | | m_int_latch |= (1<<7); |
| 609 | | |
| 610 | | refresh_ints(); |
| 611 | | } |
| 612 | | } |
| 613 | | } |
| 591 | case 0xbf: |
| 592 | m_regs[offset & 0x01f] = data; |
| 614 | 593 | break; |
| 615 | 594 | |
| 616 | | default: |
| 617 | | break; |
| 595 | default: |
| 596 | m_addrspace[1]->write_byte(offset, data); |
| 618 | 597 | } |
| 619 | 598 | } |
| 620 | 599 | |
| 621 | | /* |
| 622 | | Reg 4 READ: |
| 623 | 600 | |
| 624 | | b7 = 1: INT2 latch set |
| 625 | | b6 = INT2 input pin |
| 626 | | b5 = 1: INT1 latch set |
| 627 | | b4 = INT1 input pin |
| 628 | | b3 = 1: 1Hz latch set |
| 629 | | b2 = 1Hz input pin |
| 630 | | b1 = 1: 1kHz/50Hz/TG latch set |
| 631 | | b0 = 1kHz/50Hz/TG input |
| 632 | | |
| 633 | | Reg 4 WRITE: |
| 634 | | |
| 635 | | b7 = 1: Reset INT2 latch |
| 636 | | b6 = 1: Enable INT2 |
| 637 | | b5 = 1: Reset INT1 latch |
| 638 | | b4 = 1: Enable INT1 |
| 639 | | b3 = 1: Reset 1Hz interrupt latch |
| 640 | | b2 = 1: Enable 1Hz interrupt |
| 641 | | b1 = 1: Reset 1kHz/50Hz/TG latch |
| 642 | | b0 = 1: Enable 1kHz/50Hz/TG latch |
| 643 | | */ |
| 644 | | |
| 645 | | |
| 646 | | |
| 647 | 601 | //------------------------------------------------- |
| 648 | | // sound_stream_update - handle a stream update |
| 602 | // update_interrupt - |
| 649 | 603 | //------------------------------------------------- |
| 650 | 604 | |
| 651 | | void dave_sound_device::sound_stream_update(sound_stream &stream, stream_sample_t **inputs, stream_sample_t **outputs, int samples) |
| 605 | void dave_device::update_interrupt() |
| 652 | 606 | { |
| 653 | | stream_sample_t *buffer1, *buffer2; |
| 654 | | /* 0 = channel 0 left volume, 1 = channel 0 right volume, |
| 655 | | 2 = channel 1 left volume, 3 = channel 1 right volume, |
| 656 | | 4 = channel 2 left volume, 5 = channel 2 right volume |
| 657 | | 6 = noise channel left volume, 7 = noise channel right volume */ |
| 658 | | int output_volumes[8]; |
| 659 | | int left_volume; |
| 660 | | int right_volume; |
| 661 | | |
| 662 | | //logerror("sound update!\n"); |
| 663 | | |
| 664 | | buffer1 = outputs[0]; |
| 665 | | buffer2 = outputs[1]; |
| 666 | | |
| 667 | | while (samples) |
| 668 | | { |
| 669 | | int vol[4]; |
| 670 | | |
| 671 | | /* vol[] keeps track of how long each square wave stays */ |
| 672 | | /* in the 1 position during the sample period. */ |
| 673 | | vol[0] = vol[1] = vol[2] = vol[3] = 0; |
| 674 | | |
| 675 | | for (int i = 0; i < 3; i++) |
| 676 | | { |
| 677 | | if ((m_regs[7] & (1 << i))==0) |
| 678 | | { |
| 679 | | if (m_level[i]) vol[i] += m_count[i]; |
| 680 | | m_count[i] -= STEP; |
| 681 | | /* Period[i] is the half period of the square wave. Here, in each */ |
| 682 | | /* loop I add Period[i] twice, so that at the end of the loop the */ |
| 683 | | /* square wave is in the same status (0 or 1) it was at the start. */ |
| 684 | | /* vol[i] is also incremented by Period[i], since the wave has been 1 */ |
| 685 | | /* exactly half of the time, regardless of the initial position. */ |
| 686 | | /* If we exit the loop in the middle, Output[i] has to be inverted */ |
| 687 | | /* and vol[i] incremented only if the exit status of the square */ |
| 688 | | /* wave is 1. */ |
| 689 | | while (m_count[i] <= 0) |
| 690 | | { |
| 691 | | m_count[i] += m_period[i]; |
| 692 | | if (m_count[i] > 0) |
| 693 | | { |
| 694 | | m_level[i] ^= 0x0ffffffff; |
| 695 | | if (m_level[i]) vol[i] += m_period[i]; |
| 696 | | break; |
| 697 | | } |
| 698 | | m_count[i] += m_period[i]; |
| 699 | | vol[i] += m_period[i]; |
| 700 | | } |
| 701 | | if (m_level[i]) |
| 702 | | vol[i] -= m_count[i]; |
| 703 | | } |
| 704 | | } |
| 705 | | |
| 706 | | /* update volume outputs */ |
| 707 | | |
| 708 | | /* setup output volumes for each channel */ |
| 709 | | /* channel 0 */ |
| 710 | | output_volumes[0] = ((m_level[0] & m_level_and[0]) | m_level_or[0]) & m_mame_volumes[0]; |
| 711 | | output_volumes[1] = ((m_level[0] & m_level_and[1]) | m_level_or[1]) & m_mame_volumes[4]; |
| 712 | | /* channel 1 */ |
| 713 | | output_volumes[2] = ((m_level[1] & m_level_and[2]) | m_level_or[2]) & m_mame_volumes[1]; |
| 714 | | output_volumes[3] = ((m_level[1] & m_level_and[3]) | m_level_or[3]) & m_mame_volumes[5]; |
| 715 | | /* channel 2 */ |
| 716 | | output_volumes[4] = ((m_level[2] & m_level_and[4]) | m_level_or[4]) & m_mame_volumes[2]; |
| 717 | | output_volumes[5] = ((m_level[2] & m_level_and[5]) | m_level_or[5]) & m_mame_volumes[6]; |
| 718 | | /* channel 3 */ |
| 719 | | output_volumes[6] = ((m_level[3] & m_level_and[6]) | m_level_or[6]) & m_mame_volumes[3]; |
| 720 | | output_volumes[7] = ((m_level[3] & m_level_and[7]) | m_level_or[7]) & m_mame_volumes[7]; |
| 721 | | |
| 722 | | left_volume = (output_volumes[0] + output_volumes[2] + output_volumes[4] + output_volumes[6])>>2; |
| 723 | | right_volume = (output_volumes[1] + output_volumes[3] + output_volumes[5] + output_volumes[7])>>2; |
| 724 | | |
| 725 | | *(buffer1++) = left_volume; |
| 726 | | *(buffer2++) = right_volume; |
| 727 | | |
| 728 | | samples--; |
| 729 | | } |
| 607 | int state = ((m_irq_status & (m_irq_enable << 1)) & IRQ_LATCH) ? ASSERT_LINE : CLEAR_LINE; |
| 608 | |
| 609 | m_write_irq(state); |
| 730 | 610 | } |
trunk/src/mess/machine/ep64_exdos.c
| r0 | r23494 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Intelligent Software EXDOS Disk Controller Module emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | Floppy Drive Controller PCB Layout |
| 13 | ---------------------------------- |
| 14 | |
| 15 | INTELLIGENT SOFTWARE LTD DISK CONTROLLER |
| 16 | ISS1 |
| 17 | |--------------------------------------------| |
| 18 | | | |
| 19 | | | |
| 20 | |-| 7438 74LS273 WD1770 | |
| 21 | |I| | |
| 22 | |D| | |
| 23 | |C| EPROM.IC2| |
| 24 | |3| 74LS32 74LS02 74LS266 | |
| 25 | |4| 7438 | |
| 26 | |-| 74LS126 74LS10 74LS245 74LS266 | |
| 27 | | | |
| 28 | | | |
| 29 | |----------------------------||||||||||||||||| |
| 30 | |---------------| |
| 31 | Notes: (All IC's shown) |
| 32 | |
| 33 | This PCB plugs into the external expansion connector on the right side of the mainboard |
| 34 | |
| 35 | EPROM.IC2 - 16k x8-bit EPROM labelled 'EXDOS V1.0 P/N 08-60' (DIP28) |
| 36 | WD1770 - Western Digital WD1770 Floppy Drive Controller (DIP28) |
| 37 | 74LS02 - Quad 2-Input NOR Gate (DIP14) |
| 38 | 74LS10 - Triple 3-input NAND Gate (DIP14) |
| 39 | 74LS32 - Quad 2-Input Positive OR Gate (DIP14) |
| 40 | 7438 - Quad 2-input NAND Buffer (DIP14) |
| 41 | 74LS126 - Quad Bus Buffer (DIP14) |
| 42 | 74LS245 - Octal Bus Tranceiver with Tri-State Outputs (DIP20) |
| 43 | 74LS266 - Quad EXCLUSIVE-NOR Gate (DIP14) |
| 44 | 74LS273 - Octal D-Type Flip-Flop With Clear (DIP20) |
| 45 | IDC34 - IDC 34-way flat cable connector for floppy drive data cable |
| 46 | |
| 47 | */ |
| 48 | |
| 49 | #include "ep64_exdos.h" |
| 50 | |
| 51 | |
| 52 | |
| 53 | //************************************************************************** |
| 54 | // MACROS/CONSTANTS |
| 55 | //************************************************************************** |
| 56 | |
| 57 | #define WD1770_TAG "u1" |
| 58 | |
| 59 | |
| 60 | |
| 61 | //************************************************************************** |
| 62 | // DEVICE DEFINITIONS |
| 63 | //************************************************************************** |
| 64 | |
| 65 | const device_type EP64_EXDOS = &device_creator<ep64_exdos_device>; |
| 66 | |
| 67 | |
| 68 | //------------------------------------------------- |
| 69 | // ROM( ep64_exdos ) |
| 70 | //------------------------------------------------- |
| 71 | |
| 72 | ROM_START( ep64_exdos ) |
| 73 | ROM_REGION( 0x8000, "rom", 0 ) |
| 74 | ROM_LOAD( "exdos13.rom", 0x0000, 0x8000, CRC(d1d7e157) SHA1(31c8be089526aa8aa019c380cdf51ddd3ee76454) ) |
| 75 | ROM_END |
| 76 | |
| 77 | |
| 78 | //------------------------------------------------- |
| 79 | // rom_region - device-specific ROM region |
| 80 | //------------------------------------------------- |
| 81 | |
| 82 | const rom_entry *ep64_exdos_device::device_rom_region() const |
| 83 | { |
| 84 | return ROM_NAME( ep64_exdos ); |
| 85 | } |
| 86 | |
| 87 | |
| 88 | //------------------------------------------------- |
| 89 | // SLOT_INTERFACE( ep64_exdos_floppies ) |
| 90 | //------------------------------------------------- |
| 91 | |
| 92 | FLOPPY_FORMATS_MEMBER( ep64_exdos_device::floppy_formats ) |
| 93 | FLOPPY_EP64_FORMAT |
| 94 | FLOPPY_FORMATS_END |
| 95 | |
| 96 | static SLOT_INTERFACE_START( ep64_exdos_floppies ) |
| 97 | SLOT_INTERFACE( "35dd", FLOPPY_35_DD ) |
| 98 | SLOT_INTERFACE_END |
| 99 | |
| 100 | |
| 101 | //------------------------------------------------- |
| 102 | // MACHINE_CONFIG_FRAGMENT( ep64_exdos ) |
| 103 | //------------------------------------------------- |
| 104 | |
| 105 | static MACHINE_CONFIG_FRAGMENT( ep64_exdos ) |
| 106 | MCFG_WD1770x_ADD(WD1770_TAG, XTAL_8MHz) |
| 107 | |
| 108 | MCFG_FLOPPY_DRIVE_ADD(WD1770_TAG":0", ep64_exdos_floppies, "35dd", ep64_exdos_device::floppy_formats) |
| 109 | MCFG_FLOPPY_DRIVE_ADD(WD1770_TAG":1", ep64_exdos_floppies, NULL, ep64_exdos_device::floppy_formats) |
| 110 | MCFG_FLOPPY_DRIVE_ADD(WD1770_TAG":2", ep64_exdos_floppies, NULL, ep64_exdos_device::floppy_formats) |
| 111 | MCFG_FLOPPY_DRIVE_ADD(WD1770_TAG":3", ep64_exdos_floppies, NULL, ep64_exdos_device::floppy_formats) |
| 112 | MACHINE_CONFIG_END |
| 113 | |
| 114 | |
| 115 | //------------------------------------------------- |
| 116 | // machine_config_additions - device-specific |
| 117 | // machine configurations |
| 118 | //------------------------------------------------- |
| 119 | |
| 120 | machine_config_constructor ep64_exdos_device::device_mconfig_additions() const |
| 121 | { |
| 122 | return MACHINE_CONFIG_NAME( ep64_exdos ); |
| 123 | } |
| 124 | |
| 125 | |
| 126 | |
| 127 | //************************************************************************** |
| 128 | // LIVE DEVICE |
| 129 | //************************************************************************** |
| 130 | |
| 131 | //------------------------------------------------- |
| 132 | // ep64_exdos_device - constructor |
| 133 | //------------------------------------------------- |
| 134 | |
| 135 | ep64_exdos_device::ep64_exdos_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 136 | device_t(mconfig, EP64_EXDOS, "EXDOS", tag, owner, clock, "ep64_exdos", __FILE__), |
| 137 | device_ep64_expansion_bus_card_interface(mconfig, *this), |
| 138 | m_fdc(*this, WD1770_TAG), |
| 139 | m_floppy0(*this, WD1770_TAG":0"), |
| 140 | m_floppy1(*this, WD1770_TAG":1"), |
| 141 | m_floppy2(*this, WD1770_TAG":2"), |
| 142 | m_floppy3(*this, WD1770_TAG":3"), |
| 143 | m_floppy(NULL), |
| 144 | m_rom(*this, "rom") |
| 145 | { |
| 146 | } |
| 147 | |
| 148 | |
| 149 | //------------------------------------------------- |
| 150 | // device_start - device-specific startup |
| 151 | //------------------------------------------------- |
| 152 | |
| 153 | void ep64_exdos_device::device_start() |
| 154 | { |
| 155 | m_slot->program().install_rom(0x080000, 0x087fff, 0, 0, m_rom->base()); |
| 156 | |
| 157 | m_slot->io().install_readwrite_handler(0x10, 0x13, 0, 0x04, READ8_DEVICE_DELEGATE(wd_fdc_t, m_fdc, read), WRITE8_DEVICE_DELEGATE(wd_fdc_t, m_fdc, write)); |
| 158 | m_slot->io().install_readwrite_handler(0x18, 0x18, 0, 0x04, READ8_DELEGATE(ep64_exdos_device, read), WRITE8_DELEGATE(ep64_exdos_device, write)); |
| 159 | } |
| 160 | |
| 161 | |
| 162 | //------------------------------------------------- |
| 163 | // device_reset - device-specific reset |
| 164 | //------------------------------------------------- |
| 165 | |
| 166 | void ep64_exdos_device::device_reset() |
| 167 | { |
| 168 | m_fdc->reset(); |
| 169 | |
| 170 | m_floppy = NULL; |
| 171 | m_fdc->set_floppy(m_floppy); |
| 172 | m_fdc->dden_w(0); |
| 173 | } |
| 174 | |
| 175 | |
| 176 | //------------------------------------------------- |
| 177 | // read - |
| 178 | //------------------------------------------------- |
| 179 | |
| 180 | READ8_MEMBER( ep64_exdos_device::read ) |
| 181 | { |
| 182 | /* |
| 183 | |
| 184 | bit description |
| 185 | |
| 186 | 0 |
| 187 | 1 INTRQ |
| 188 | 2 |
| 189 | 3 |
| 190 | 4 |
| 191 | 5 |
| 192 | 6 DCHG |
| 193 | 7 DRQ |
| 194 | |
| 195 | */ |
| 196 | |
| 197 | UINT8 data = 0; |
| 198 | |
| 199 | data |= m_fdc->intrq_r(); |
| 200 | data |= m_fdc->drq_r() << 7; |
| 201 | |
| 202 | data |= (m_floppy ? m_floppy->dskchg_r() : 1) << 6; |
| 203 | |
| 204 | return data; |
| 205 | } |
| 206 | |
| 207 | |
| 208 | //------------------------------------------------- |
| 209 | // write - |
| 210 | //------------------------------------------------- |
| 211 | |
| 212 | WRITE8_MEMBER( ep64_exdos_device::write ) |
| 213 | { |
| 214 | /* |
| 215 | |
| 216 | bit description |
| 217 | |
| 218 | 0 SELECT 0 |
| 219 | 1 SELECT 1 |
| 220 | 2 SELECT 2 |
| 221 | 3 SELECT 3 |
| 222 | 4 SIDE 1 |
| 223 | 5 _DDEN |
| 224 | 6 DISK CHANGE RESET |
| 225 | 7 IN USE |
| 226 | |
| 227 | */ |
| 228 | |
| 229 | m_floppy = NULL; |
| 230 | |
| 231 | if (BIT(data, 0)) m_floppy = m_floppy0->get_device(); |
| 232 | if (BIT(data, 1)) m_floppy = m_floppy1->get_device(); |
| 233 | if (BIT(data, 2)) m_floppy = m_floppy2->get_device(); |
| 234 | if (BIT(data, 3)) m_floppy = m_floppy3->get_device(); |
| 235 | |
| 236 | m_fdc->set_floppy(m_floppy); |
| 237 | |
| 238 | if (m_floppy) |
| 239 | { |
| 240 | m_floppy->ss_w(BIT(data, 4)); |
| 241 | } |
| 242 | |
| 243 | m_fdc->dden_w(BIT(data, 5)); |
| 244 | } |
trunk/src/mess/video/epnick.c
| r23493 | r23494 | |
| 1 | | /***************************************************************************** |
| 2 | | * |
| 3 | | * video/epnick.c |
| 4 | | * |
| 5 | | * Nick Graphics Chip - found in Enterprise |
| 6 | | * |
| 7 | | * this is a display list graphics chip, with bitmap, |
| 8 | | * character and attribute graphics modes. Each entry in the |
| 9 | | * display list defines a char line, with variable number of |
| 10 | | * scanlines. Colour modes are 2,4, 16 and 256 colour. |
| 11 | | * Nick has 256 colours, 3 bits for R and G, with 2 bits for Blue. |
| 12 | | * It's a nice and flexible graphics processor.......... |
| 13 | | * |
| 14 | | ****************************************************************************/ |
| 15 | | |
| 16 | | #include "emu.h" |
| 17 | | #include "video/epnick.h" |
| 18 | | |
| 19 | | /* colour mode types */ |
| 20 | | #define NICK_2_COLOUR_MODE 0 |
| 21 | | #define NICK_4_COLOUR_MODE 1 |
| 22 | | #define NICK_16_COLOUR_MODE 2 |
| 23 | | #define NICK_256_COLOUR_MODE 3 |
| 24 | | |
| 25 | | /* Display mode types */ |
| 26 | | #define NICK_VSYNC_MODE 0 |
| 27 | | #define NICK_PIXEL_MODE 1 |
| 28 | | #define NICK_ATTR_MODE 2 |
| 29 | | #define NICK_CH256_MODE 3 |
| 30 | | #define NICK_CH128_MODE 4 |
| 31 | | #define NICK_CH64_MODE 5 |
| 32 | | #define NICK_UNUSED_MODE 6 |
| 33 | | #define NICK_LPIXEL_MODE 7 |
| 34 | | |
| 35 | | /* MODEBYTE defines */ |
| 36 | | #define NICK_MB_VIRQ (1<<7) |
| 37 | | #define NICK_MB_VRES (1<<4) |
| 38 | | #define NICK_MB_LPT_RELOAD (1<<0) |
| 39 | | |
| 40 | | /* Left margin defines */ |
| 41 | | #define NICK_LM_MSBALT (1<<7) |
| 42 | | #define NICK_LM_LSBALT (1<<6) |
| 43 | | |
| 44 | | /* Right margin defines */ |
| 45 | | #define NICK_RM_ALTIND1 (1<<7) |
| 46 | | #define NICK_RM_ALTIND0 (1<<6) |
| 47 | | |
| 48 | | /* useful macros */ |
| 49 | | #define NICK_GET_LEFT_MARGIN(x) (x & 0x03f) |
| 50 | | #define NICK_GET_RIGHT_MARGIN(x) (x & 0x03f) |
| 51 | | #define NICK_GET_DISPLAY_MODE(x) ((x>>1) & 0x07) |
| 52 | | #define NICK_GET_COLOUR_MODE(x) ((x>>5) & 0x03) |
| 53 | | |
| 54 | | #define NICK_RELOAD_LPT(x) (x & 0x080) |
| 55 | | #define NICK_CLOCK_LPT(x) (x & 0x040) |
| 56 | | |
| 57 | | /* Macros to generate memory address is CHx modes */ |
| 58 | | /* x = LD2, y = buf1 */ |
| 59 | | #define ADDR_CH256(x,y) (((x & 0x0ff)<<8) | (y & 0x0ff)) |
| 60 | | #define ADDR_CH128(x,y) (((x & 0x01ff)<<7) | (y & 0x07f)) |
| 61 | | #define ADDR_CH64(x,y) (((x & 0x03ff)<<6) | (y & 0x03f)) |
| 62 | | |
| 63 | | |
| 64 | | const device_type NICK = &device_creator<nick_device>; |
| 65 | | |
| 66 | | //------------------------------------------------- |
| 67 | | // stic_device - constructor |
| 68 | | //------------------------------------------------- |
| 69 | | |
| 70 | | nick_device::nick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) : |
| 71 | | device_t(mconfig, NICK, "Nick Graphics Chip", tag, owner, clock, "epnick", __FILE__), |
| 72 | | m_videoram(NULL) |
| 73 | | { |
| 74 | | } |
| 75 | | |
| 76 | | |
| 77 | | //------------------------------------------------- |
| 78 | | // ~stic_device - destructor |
| 79 | | //------------------------------------------------- |
| 80 | | |
| 81 | | nick_device::~nick_device() |
| 82 | | { |
| 83 | | } |
| 84 | | |
| 85 | | //------------------------------------------------- |
| 86 | | // device_start - device-specific startup |
| 87 | | //------------------------------------------------- |
| 88 | | |
| 89 | | void nick_device::device_start() |
| 90 | | { |
| 91 | | machine().primary_screen->register_screen_bitmap(m_bitmap); |
| 92 | | |
| 93 | | calc_visible_clocks(ENTERPRISE_SCREEN_WIDTH); |
| 94 | | |
| 95 | | bitmap_ind16 m_bitmap; |
| 96 | | |
| 97 | | save_item(NAME(m_scanline_count)); |
| 98 | | save_item(NAME(m_FIXBIAS)); |
| 99 | | save_item(NAME(m_BORDER)); |
| 100 | | save_item(NAME(m_LPL)); |
| 101 | | save_item(NAME(m_LPH)); |
| 102 | | save_item(NAME(m_LD1)); |
| 103 | | save_item(NAME(m_LD2)); |
| 104 | | save_item(NAME(m_LPT.SC)); |
| 105 | | save_item(NAME(m_LPT.MB)); |
| 106 | | save_item(NAME(m_LPT.LM)); |
| 107 | | save_item(NAME(m_LPT.RM)); |
| 108 | | save_item(NAME(m_LPT.LD1L)); |
| 109 | | save_item(NAME(m_LPT.LD1H)); |
| 110 | | save_item(NAME(m_LPT.LD2L)); |
| 111 | | save_item(NAME(m_LPT.LD2H)); |
| 112 | | save_item(NAME(m_LPT.COL)); |
| 113 | | save_item(NAME(m_dest_pos)); |
| 114 | | save_item(NAME(m_dest_max_pos)); |
| 115 | | save_item(NAME(m_reg)); |
| 116 | | save_item(NAME(m_first_visible_clock)); |
| 117 | | save_item(NAME(m_last_visible_clock)); |
| 118 | | } |
| 119 | | |
| 120 | | |
| 121 | | void nick_device::device_reset() |
| 122 | | { |
| 123 | | for (int i = 0; i < 256; i++) |
| 124 | | { |
| 125 | | int pen_index; |
| 126 | | |
| 127 | | pen_index = (BIT(i, 7) << 0) | (BIT(i, 3) << 1); |
| 128 | | m_pen_idx_4col[i] = pen_index; |
| 129 | | |
| 130 | | pen_index = (BIT(i, 7) << 0) | (BIT(i, 3) << 1) | (BIT(i, 5) << 2) | (BIT(i, 1) << 3); |
| 131 | | m_pen_idx_16col[i] = pen_index; |
| 132 | | } |
| 133 | | |
| 134 | | //m_BORDER = 0; |
| 135 | | //m_FIXBIAS = 0; |
| 136 | | } |
| 137 | | |
| 138 | | |
| 139 | | // MESS specific |
| 140 | | /* 8-bit pixel write! */ |
| 141 | | void nick_device::write_pixel(int ci) |
| 142 | | { |
| 143 | | if (m_dest_pos < m_dest_max_pos) |
| 144 | | { |
| 145 | | m_dest[m_dest_pos++] = ci; |
| 146 | | } |
| 147 | | } |
| 148 | | |
| 149 | | |
| 150 | | /* No of highest resolution pixels per "clock" */ |
| 151 | | #define NICK_PIXELS_PER_CLOCK 16 |
| 152 | | |
| 153 | | /* "clocks" per line */ |
| 154 | | #define NICK_TOTAL_CLOCKS_PER_LINE 64 |
| 155 | | |
| 156 | | /* we align based on the clocks */ |
| 157 | | void nick_device::calc_visible_clocks(int width) |
| 158 | | { |
| 159 | | /* number of clocks we can see */ |
| 160 | | int no_visible_clocks = width / NICK_PIXELS_PER_CLOCK; |
| 161 | | m_first_visible_clock = (NICK_TOTAL_CLOCKS_PER_LINE - no_visible_clocks) >> 1; |
| 162 | | m_last_visible_clock = m_first_visible_clock + no_visible_clocks; |
| 163 | | } |
| 164 | | |
| 165 | | |
| 166 | | /* write border colour */ |
| 167 | | void nick_device::write_border(int clocks) |
| 168 | | { |
| 169 | | int col_index = m_BORDER; |
| 170 | | |
| 171 | | for (int i = 0; i < (clocks << 4); i++) |
| 172 | | write_pixel(col_index); |
| 173 | | } |
| 174 | | |
| 175 | | |
| 176 | | void nick_device::do_left_margin() |
| 177 | | { |
| 178 | | UINT8 left = NICK_GET_LEFT_MARGIN(m_LPT.LM); |
| 179 | | |
| 180 | | if (left > m_first_visible_clock) |
| 181 | | { |
| 182 | | /* some of the left margin is visible */ |
| 183 | | UINT8 left_visible = left - m_first_visible_clock; |
| 184 | | |
| 185 | | /* render the border */ |
| 186 | | write_border(left_visible); |
| 187 | | } |
| 188 | | } |
| 189 | | |
| 190 | | void nick_device::do_right_margin() |
| 191 | | { |
| 192 | | UINT8 right = NICK_GET_RIGHT_MARGIN(m_LPT.RM); |
| 193 | | |
| 194 | | if (right < m_last_visible_clock) |
| 195 | | { |
| 196 | | /* some of the right margin is visible */ |
| 197 | | UINT8 right_visible = m_last_visible_clock - right; |
| 198 | | |
| 199 | | /* render the border */ |
| 200 | | write_border(right_visible); |
| 201 | | } |
| 202 | | } |
| 203 | | |
| 204 | | int nick_device::get_color_index(int pen_index) |
| 205 | | { |
| 206 | | if (pen_index & 0x08) |
| 207 | | return ((m_FIXBIAS & 0x01f) << 3) | (pen_index & 0x07); |
| 208 | | else |
| 209 | | return m_LPT.COL[pen_index]; |
| 210 | | } |
| 211 | | |
| 212 | | void nick_device::write_pixels2color(UINT8 pen0, UINT8 pen1, UINT8 data_byte) |
| 213 | | { |
| 214 | | int col_index[2]; |
| 215 | | int pen_index; |
| 216 | | UINT8 data = data_byte; |
| 217 | | |
| 218 | | col_index[0] = get_color_index(pen0); |
| 219 | | col_index[1] = get_color_index(pen1); |
| 220 | | |
| 221 | | for (int i = 0; i < 8; i++) |
| 222 | | { |
| 223 | | pen_index = col_index[BIT(data, 7)]; |
| 224 | | write_pixel(pen_index); |
| 225 | | data <<= 1; |
| 226 | | } |
| 227 | | } |
| 228 | | |
| 229 | | void nick_device::write_pixels2color_lpixel(UINT8 pen0, UINT8 pen1, UINT8 data_byte) |
| 230 | | { |
| 231 | | int col_index[2]; |
| 232 | | int pen_index; |
| 233 | | UINT8 data = data_byte; |
| 234 | | |
| 235 | | col_index[0] = get_color_index(pen0); |
| 236 | | col_index[1] = get_color_index(pen1); |
| 237 | | |
| 238 | | for (int i = 0; i < 8; i++) |
| 239 | | { |
| 240 | | pen_index = col_index[BIT(data, 7)]; |
| 241 | | write_pixel(pen_index); |
| 242 | | write_pixel(pen_index); |
| 243 | | data <<= 1; |
| 244 | | } |
| 245 | | } |
| 246 | | |
| 247 | | |
| 248 | | void nick_device::write_pixels(UINT8 data_byte, UINT8 char_idx) |
| 249 | | { |
| 250 | | /* pen index colour 2-C (0,1), 4-C (0..3) 16-C (0..16) */ |
| 251 | | int pen_idx; |
| 252 | | /* Col index = EP colour value */ |
| 253 | | int pal_idx; |
| 254 | | UINT8 color_mode = NICK_GET_COLOUR_MODE(m_LPT.MB); |
| 255 | | UINT8 data = data_byte; |
| 256 | | |
| 257 | | switch (color_mode) |
| 258 | | { |
| 259 | | case NICK_2_COLOUR_MODE: |
| 260 | | { |
| 261 | | int pen_offs = 0; |
| 262 | | |
| 263 | | /* do before displaying byte */ |
| 264 | | |
| 265 | | /* left margin attributes */ |
| 266 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 267 | | { |
| 268 | | if (data & 0x080) |
| 269 | | { |
| 270 | | pen_offs |= 2; |
| 271 | | } |
| 272 | | |
| 273 | | data &=~0x080; |
| 274 | | } |
| 275 | | |
| 276 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 277 | | { |
| 278 | | if (data & 0x001) |
| 279 | | { |
| 280 | | pen_offs |= 4; |
| 281 | | } |
| 282 | | |
| 283 | | data &=~0x01; |
| 284 | | } |
| 285 | | |
| 286 | | if (m_LPT.RM & NICK_RM_ALTIND1) |
| 287 | | { |
| 288 | | if (char_idx & 0x080) |
| 289 | | { |
| 290 | | pen_offs |= 0x02; |
| 291 | | } |
| 292 | | } |
| 293 | | |
| 294 | | #if 0 |
| 295 | | if (m_LPT.RM & NICK_RM_ALTIND0) |
| 296 | | { |
| 297 | | if (data & 0x040) |
| 298 | | { |
| 299 | | pen_offs |= 0x04; |
| 300 | | } |
| 301 | | } |
| 302 | | #endif |
| 303 | | |
| 304 | | |
| 305 | | write_pixels2color(pen_offs, (pen_offs | 0x01), data); |
| 306 | | } |
| 307 | | break; |
| 308 | | |
| 309 | | case NICK_4_COLOUR_MODE: |
| 310 | | { |
| 311 | | //mame_printf_info("4 colour\r\n"); |
| 312 | | |
| 313 | | /* left margin attributes */ |
| 314 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 315 | | { |
| 316 | | data &= ~0x080; |
| 317 | | } |
| 318 | | |
| 319 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 320 | | { |
| 321 | | data &= ~0x01; |
| 322 | | } |
| 323 | | |
| 324 | | |
| 325 | | for (int i = 0; i < 4; i++) |
| 326 | | { |
| 327 | | pen_idx = m_pen_idx_4col[data]; |
| 328 | | pal_idx = m_LPT.COL[pen_idx & 0x03]; |
| 329 | | |
| 330 | | write_pixel(pal_idx); |
| 331 | | write_pixel(pal_idx); |
| 332 | | |
| 333 | | data <<= 1; |
| 334 | | } |
| 335 | | } |
| 336 | | break; |
| 337 | | |
| 338 | | case NICK_16_COLOUR_MODE: |
| 339 | | { |
| 340 | | //mame_printf_info("16 colour\r\n"); |
| 341 | | |
| 342 | | /* left margin attributes */ |
| 343 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 344 | | { |
| 345 | | data &= ~0x080; |
| 346 | | } |
| 347 | | |
| 348 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 349 | | { |
| 350 | | data &= ~0x01; |
| 351 | | } |
| 352 | | |
| 353 | | |
| 354 | | for (int i = 0; i < 2; i++) |
| 355 | | { |
| 356 | | pen_idx = m_pen_idx_16col[data]; |
| 357 | | |
| 358 | | pal_idx = get_color_index(pen_idx); |
| 359 | | |
| 360 | | write_pixel(pal_idx); |
| 361 | | write_pixel(pal_idx); |
| 362 | | write_pixel(pal_idx); |
| 363 | | write_pixel(pal_idx); |
| 364 | | |
| 365 | | data <<= 1; |
| 366 | | } |
| 367 | | } |
| 368 | | break; |
| 369 | | |
| 370 | | case NICK_256_COLOUR_MODE: |
| 371 | | { |
| 372 | | /* left margin attributes */ |
| 373 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 374 | | { |
| 375 | | data &= ~0x080; |
| 376 | | } |
| 377 | | |
| 378 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 379 | | { |
| 380 | | data &= ~0x01; |
| 381 | | } |
| 382 | | |
| 383 | | |
| 384 | | pal_idx = data; |
| 385 | | |
| 386 | | write_pixel(pal_idx); |
| 387 | | write_pixel(pal_idx); |
| 388 | | write_pixel(pal_idx); |
| 389 | | write_pixel(pal_idx); |
| 390 | | write_pixel(pal_idx); |
| 391 | | write_pixel(pal_idx); |
| 392 | | write_pixel(pal_idx); |
| 393 | | write_pixel(pal_idx); |
| 394 | | |
| 395 | | |
| 396 | | } |
| 397 | | break; |
| 398 | | } |
| 399 | | } |
| 400 | | |
| 401 | | void nick_device::write_pixels_lpixel(UINT8 data_byte, UINT8 char_idx) |
| 402 | | { |
| 403 | | /* pen index colour 2-C (0,1), 4-C (0..3) 16-C (0..16) */ |
| 404 | | int pen_idx; |
| 405 | | /* Col index = EP colour value */ |
| 406 | | int pal_idx; |
| 407 | | UINT8 color_mode = NICK_GET_COLOUR_MODE(m_LPT.MB); |
| 408 | | UINT8 data = data_byte; |
| 409 | | |
| 410 | | switch (color_mode) |
| 411 | | { |
| 412 | | case NICK_2_COLOUR_MODE: |
| 413 | | { |
| 414 | | int pen_offs = 0; |
| 415 | | |
| 416 | | /* do before displaying byte */ |
| 417 | | |
| 418 | | /* left margin attributes */ |
| 419 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 420 | | { |
| 421 | | if (data & 0x080) |
| 422 | | { |
| 423 | | pen_offs |= 2; |
| 424 | | } |
| 425 | | |
| 426 | | data &=~0x080; |
| 427 | | } |
| 428 | | |
| 429 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 430 | | { |
| 431 | | if (data & 0x001) |
| 432 | | { |
| 433 | | pen_offs |= 4; |
| 434 | | } |
| 435 | | |
| 436 | | data &=~0x01; |
| 437 | | } |
| 438 | | |
| 439 | | if (m_LPT.RM & NICK_RM_ALTIND1) |
| 440 | | { |
| 441 | | if (char_idx & 0x080) |
| 442 | | { |
| 443 | | pen_offs |= 0x02; |
| 444 | | } |
| 445 | | } |
| 446 | | |
| 447 | | #if 0 |
| 448 | | if (m_LPT.RM & NICK_RM_ALTIND0) |
| 449 | | { |
| 450 | | if (data & 0x040) |
| 451 | | { |
| 452 | | pen_offs |= 0x04; |
| 453 | | } |
| 454 | | } |
| 455 | | #endif |
| 456 | | |
| 457 | | |
| 458 | | write_pixels2color_lpixel(pen_offs, (pen_offs | 0x01), data); |
| 459 | | } |
| 460 | | break; |
| 461 | | |
| 462 | | case NICK_4_COLOUR_MODE: |
| 463 | | { |
| 464 | | //mame_printf_info("4 colour\r\n"); |
| 465 | | |
| 466 | | /* left margin attributes */ |
| 467 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 468 | | { |
| 469 | | data &= ~0x080; |
| 470 | | } |
| 471 | | |
| 472 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 473 | | { |
| 474 | | data &= ~0x01; |
| 475 | | } |
| 476 | | |
| 477 | | |
| 478 | | for (int i = 0; i < 4; i++) |
| 479 | | { |
| 480 | | pen_idx = m_pen_idx_4col[data]; |
| 481 | | pal_idx = m_LPT.COL[pen_idx & 0x03]; |
| 482 | | |
| 483 | | write_pixel(pal_idx); |
| 484 | | write_pixel(pal_idx); |
| 485 | | write_pixel(pal_idx); |
| 486 | | write_pixel(pal_idx); |
| 487 | | |
| 488 | | data <<= 1; |
| 489 | | } |
| 490 | | } |
| 491 | | break; |
| 492 | | |
| 493 | | case NICK_16_COLOUR_MODE: |
| 494 | | { |
| 495 | | //mame_printf_info("16 colour\r\n"); |
| 496 | | |
| 497 | | /* left margin attributes */ |
| 498 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 499 | | { |
| 500 | | data &= ~0x080; |
| 501 | | } |
| 502 | | |
| 503 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 504 | | { |
| 505 | | data &= ~0x01; |
| 506 | | } |
| 507 | | |
| 508 | | |
| 509 | | for (int i = 0; i < 2; i++) |
| 510 | | { |
| 511 | | pen_idx = m_pen_idx_16col[data]; |
| 512 | | pal_idx = get_color_index(pen_idx); |
| 513 | | |
| 514 | | write_pixel(pal_idx); |
| 515 | | write_pixel(pal_idx); |
| 516 | | write_pixel(pal_idx); |
| 517 | | write_pixel(pal_idx); |
| 518 | | write_pixel(pal_idx); |
| 519 | | write_pixel(pal_idx); |
| 520 | | write_pixel(pal_idx); |
| 521 | | write_pixel(pal_idx); |
| 522 | | |
| 523 | | data <<= 1; |
| 524 | | } |
| 525 | | } |
| 526 | | break; |
| 527 | | |
| 528 | | case NICK_256_COLOUR_MODE: |
| 529 | | { |
| 530 | | /* left margin attributes */ |
| 531 | | if (m_LPT.LM & NICK_LM_MSBALT) |
| 532 | | { |
| 533 | | data &= ~0x080; |
| 534 | | } |
| 535 | | |
| 536 | | if (m_LPT.LM & NICK_LM_LSBALT) |
| 537 | | { |
| 538 | | data &= ~0x01; |
| 539 | | } |
| 540 | | |
| 541 | | |
| 542 | | pal_idx = data; |
| 543 | | |
| 544 | | write_pixel(pal_idx); |
| 545 | | write_pixel(pal_idx); |
| 546 | | write_pixel(pal_idx); |
| 547 | | write_pixel(pal_idx); |
| 548 | | write_pixel(pal_idx); |
| 549 | | write_pixel(pal_idx); |
| 550 | | write_pixel(pal_idx); |
| 551 | | write_pixel(pal_idx); |
| 552 | | |
| 553 | | write_pixel(pal_idx); |
| 554 | | write_pixel(pal_idx); |
| 555 | | write_pixel(pal_idx); |
| 556 | | write_pixel(pal_idx); |
| 557 | | write_pixel(pal_idx); |
| 558 | | write_pixel(pal_idx); |
| 559 | | write_pixel(pal_idx); |
| 560 | | write_pixel(pal_idx); |
| 561 | | |
| 562 | | |
| 563 | | } |
| 564 | | break; |
| 565 | | } |
| 566 | | } |
| 567 | | |
| 568 | | |
| 569 | | void nick_device::do_pixel(int clocks_visible) |
| 570 | | { |
| 571 | | UINT8 buf1, buf2; |
| 572 | | |
| 573 | | for (int i = 0; i < clocks_visible; i++) |
| 574 | | { |
| 575 | | buf1 = fetch_byte(m_LD1); |
| 576 | | m_LD1++; |
| 577 | | |
| 578 | | buf2 = fetch_byte(m_LD1); |
| 579 | | m_LD1++; |
| 580 | | |
| 581 | | write_pixels(buf1, buf1); |
| 582 | | write_pixels(buf2, buf1); |
| 583 | | } |
| 584 | | } |
| 585 | | |
| 586 | | |
| 587 | | void nick_device::do_lpixel(int clocks_visible) |
| 588 | | { |
| 589 | | UINT8 buf1; |
| 590 | | |
| 591 | | for (int i = 0; i < clocks_visible; i++) |
| 592 | | { |
| 593 | | buf1 = fetch_byte(m_LD1); |
| 594 | | m_LD1++; |
| 595 | | |
| 596 | | write_pixels_lpixel(buf1, buf1); |
| 597 | | } |
| 598 | | } |
| 599 | | |
| 600 | | void nick_device::do_attr(int clocks_visible) |
| 601 | | { |
| 602 | | UINT8 buf1, buf2; |
| 603 | | |
| 604 | | for (int i = 0; i < clocks_visible; i++) |
| 605 | | { |
| 606 | | buf1 = fetch_byte(m_LD1); |
| 607 | | m_LD1++; |
| 608 | | |
| 609 | | buf2 = fetch_byte(m_LD2); |
| 610 | | m_LD2++; |
| 611 | | |
| 612 | | { |
| 613 | | UINT8 bg_color = ((buf1 >> 4) & 0x0f); |
| 614 | | UINT8 fg_color = (buf1 & 0x0f); |
| 615 | | |
| 616 | | write_pixels2color_lpixel(bg_color, fg_color, buf2); |
| 617 | | } |
| 618 | | } |
| 619 | | } |
| 620 | | |
| 621 | | void nick_device::do_ch256(int clocks_visible) |
| 622 | | { |
| 623 | | UINT8 buf1, buf2; |
| 624 | | |
| 625 | | for (int i = 0; i < clocks_visible; i++) |
| 626 | | { |
| 627 | | buf1 = fetch_byte(m_LD1); |
| 628 | | m_LD1++; |
| 629 | | buf2 = fetch_byte(ADDR_CH256(m_LD2, buf1)); |
| 630 | | |
| 631 | | write_pixels_lpixel(buf2, buf1); |
| 632 | | } |
| 633 | | } |
| 634 | | |
| 635 | | void nick_device::do_ch128(int clocks_visible) |
| 636 | | { |
| 637 | | UINT8 buf1, buf2; |
| 638 | | |
| 639 | | for (int i = 0; i < clocks_visible; i++) |
| 640 | | { |
| 641 | | buf1 = fetch_byte(m_LD1); |
| 642 | | m_LD1++; |
| 643 | | buf2 = fetch_byte(ADDR_CH128(m_LD2, buf1)); |
| 644 | | |
| 645 | | write_pixels_lpixel(buf2, buf1); |
| 646 | | } |
| 647 | | } |
| 648 | | |
| 649 | | void nick_device::do_ch64(int clocks_visible) |
| 650 | | { |
| 651 | | UINT8 buf1, buf2; |
| 652 | | |
| 653 | | for (int i = 0; i < clocks_visible; i++) |
| 654 | | { |
| 655 | | buf1 = fetch_byte(m_LD1); |
| 656 | | m_LD1++; |
| 657 | | buf2 = fetch_byte(ADDR_CH64(m_LD2, buf1)); |
| 658 | | |
| 659 | | write_pixels_lpixel(buf2, buf1); |
| 660 | | } |
| 661 | | } |
| 662 | | |
| 663 | | |
| 664 | | void nick_device::do_display() |
| 665 | | { |
| 666 | | LPT_ENTRY *pLPT = &m_LPT; |
| 667 | | UINT8 clocks_visible; |
| 668 | | UINT8 right_margin = NICK_GET_RIGHT_MARGIN(pLPT->RM); |
| 669 | | UINT8 left_margin = NICK_GET_LEFT_MARGIN(pLPT->LM); |
| 670 | | |
| 671 | | clocks_visible = right_margin - left_margin; |
| 672 | | |
| 673 | | if (clocks_visible) |
| 674 | | { |
| 675 | | /* get display mode */ |
| 676 | | UINT8 display_mode = NICK_GET_DISPLAY_MODE(pLPT->MB); |
| 677 | | |
| 678 | | if (m_scanline_count == 0) // || |
| 679 | | //((pLPT->MB & NICK_MB_VRES)==0)) |
| 680 | | { |
| 681 | | /* doing first line */ |
| 682 | | /* reload LD1, and LD2 (if necessary) regardless of display mode */ |
| 683 | | m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); |
| 684 | | |
| 685 | | if ((display_mode != NICK_LPIXEL_MODE) && (display_mode != NICK_PIXEL_MODE)) |
| 686 | | { |
| 687 | | /* lpixel and pixel modes don't use LD2 */ |
| 688 | | m_LD2 = (pLPT->LD2L & 0xff) | ((pLPT->LD2H & 0xff) << 8); |
| 689 | | } |
| 690 | | } |
| 691 | | else |
| 692 | | { |
| 693 | | /* not first line */ |
| 694 | | switch (display_mode) |
| 695 | | { |
| 696 | | case NICK_ATTR_MODE: |
| 697 | | { |
| 698 | | /* reload LD1 */ |
| 699 | | m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); |
| 700 | | } |
| 701 | | break; |
| 702 | | |
| 703 | | case NICK_CH256_MODE: |
| 704 | | case NICK_CH128_MODE: |
| 705 | | case NICK_CH64_MODE: |
| 706 | | { |
| 707 | | /* reload LD1 */ |
| 708 | | m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); |
| 709 | | m_LD2++; |
| 710 | | } |
| 711 | | break; |
| 712 | | |
| 713 | | default: |
| 714 | | break; |
| 715 | | } |
| 716 | | } |
| 717 | | |
| 718 | | switch (display_mode) |
| 719 | | { |
| 720 | | case NICK_PIXEL_MODE: |
| 721 | | { |
| 722 | | do_pixel(clocks_visible); |
| 723 | | } |
| 724 | | break; |
| 725 | | |
| 726 | | case NICK_ATTR_MODE: |
| 727 | | { |
| 728 | | //mame_printf_info("attr mode\r\n"); |
| 729 | | do_attr(clocks_visible); |
| 730 | | } |
| 731 | | break; |
| 732 | | |
| 733 | | case NICK_CH256_MODE: |
| 734 | | { |
| 735 | | //mame_printf_info("ch256 mode\r\n"); |
| 736 | | do_ch256(clocks_visible); |
| 737 | | } |
| 738 | | break; |
| 739 | | |
| 740 | | case NICK_CH128_MODE: |
| 741 | | { |
| 742 | | do_ch128(clocks_visible); |
| 743 | | } |
| 744 | | break; |
| 745 | | |
| 746 | | case NICK_CH64_MODE: |
| 747 | | { |
| 748 | | //mame_printf_info("ch64 mode\r\n"); |
| 749 | | do_ch64(clocks_visible); |
| 750 | | } |
| 751 | | break; |
| 752 | | |
| 753 | | case NICK_LPIXEL_MODE: |
| 754 | | { |
| 755 | | do_lpixel(clocks_visible); |
| 756 | | } |
| 757 | | break; |
| 758 | | |
| 759 | | default: |
| 760 | | break; |
| 761 | | } |
| 762 | | } |
| 763 | | } |
| 764 | | |
| 765 | | void nick_device::update_lpt() |
| 766 | | { |
| 767 | | UINT16 CurLPT = (m_LPL & 0x0ff) | ((m_LPH & 0x0f) << 8); |
| 768 | | CurLPT++; |
| 769 | | m_LPL = CurLPT & 0x0ff; |
| 770 | | m_LPH = (m_LPH & 0x0f0) | ((CurLPT >> 8) & 0x0f); |
| 771 | | } |
| 772 | | |
| 773 | | |
| 774 | | void nick_device::reload_lpt() |
| 775 | | { |
| 776 | | /* get addr of LPT */ |
| 777 | | UINT32 LPT_Addr = ((m_LPL & 0x0ff) << 4) | ((m_LPH & 0x0f) << (8+4)); |
| 778 | | |
| 779 | | /* update internal LPT state */ |
| 780 | | m_LPT.SC = fetch_byte(LPT_Addr); |
| 781 | | m_LPT.MB = fetch_byte(LPT_Addr + 1); |
| 782 | | m_LPT.LM = fetch_byte(LPT_Addr + 2); |
| 783 | | m_LPT.RM = fetch_byte(LPT_Addr + 3); |
| 784 | | m_LPT.LD1L = fetch_byte(LPT_Addr + 4); |
| 785 | | m_LPT.LD1H = fetch_byte(LPT_Addr + 5); |
| 786 | | m_LPT.LD2L = fetch_byte(LPT_Addr + 6); |
| 787 | | m_LPT.LD2H = fetch_byte(LPT_Addr + 7); |
| 788 | | m_LPT.COL[0] = fetch_byte(LPT_Addr + 8); |
| 789 | | m_LPT.COL[1] = fetch_byte(LPT_Addr + 9); |
| 790 | | m_LPT.COL[2] = fetch_byte(LPT_Addr + 10); |
| 791 | | m_LPT.COL[3] = fetch_byte(LPT_Addr + 11); |
| 792 | | m_LPT.COL[4] = fetch_byte(LPT_Addr + 12); |
| 793 | | m_LPT.COL[5] = fetch_byte(LPT_Addr + 13); |
| 794 | | m_LPT.COL[6] = fetch_byte(LPT_Addr + 14); |
| 795 | | m_LPT.COL[7] = fetch_byte(LPT_Addr + 15); |
| 796 | | } |
| 797 | | |
| 798 | | /* call here to render a line of graphics */ |
| 799 | | void nick_device::do_line() |
| 800 | | { |
| 801 | | UINT8 scanline; |
| 802 | | |
| 803 | | if ((m_LPT.MB & NICK_MB_LPT_RELOAD)!=0) |
| 804 | | { |
| 805 | | /* reload LPT */ |
| 806 | | |
| 807 | | m_LPL = m_reg[2]; |
| 808 | | m_LPH = m_reg[3]; |
| 809 | | |
| 810 | | reload_lpt(); |
| 811 | | } |
| 812 | | |
| 813 | | /* left border */ |
| 814 | | do_left_margin(); |
| 815 | | |
| 816 | | /* do visible part */ |
| 817 | | do_display(); |
| 818 | | |
| 819 | | /* right border */ |
| 820 | | do_right_margin(); |
| 821 | | |
| 822 | | // 0x0f7 is first! |
| 823 | | /* scan line count for this LPT */ |
| 824 | | scanline = ((~m_LPT.SC) + 1) & 0x0ff; |
| 825 | | |
| 826 | | //printf("scanline %02x\r\n", scanline); |
| 827 | | |
| 828 | | /* update count of scanlines done so far */ |
| 829 | | m_scanline_count++; |
| 830 | | |
| 831 | | if (m_scanline_count == scanline) |
| 832 | | { |
| 833 | | /* done all scanlines of this Line Parameter Table, get next */ |
| 834 | | |
| 835 | | m_scanline_count = 0; |
| 836 | | |
| 837 | | update_lpt(); |
| 838 | | reload_lpt(); |
| 839 | | } |
| 840 | | } |
| 841 | | |
| 842 | | WRITE8_MEMBER( nick_device::reg_w ) |
| 843 | | { |
| 844 | | //mame_printf_info("Nick write %02x %02x\r\n",offset, data); |
| 845 | | |
| 846 | | /* write to a nick register */ |
| 847 | | m_reg[offset & 0x0f] = data; |
| 848 | | |
| 849 | | if ((offset == 0x03) || (offset == 0x02)) |
| 850 | | { |
| 851 | | /* write LPH */ |
| 852 | | |
| 853 | | /* reload LPT base? */ |
| 854 | | //if (NICK_RELOAD_LPT(data)) |
| 855 | | { |
| 856 | | /* reload LPT base pointer */ |
| 857 | | m_LPL = m_reg[2]; |
| 858 | | m_LPH = m_reg[3]; |
| 859 | | |
| 860 | | reload_lpt(); |
| 861 | | } |
| 862 | | } |
| 863 | | |
| 864 | | if (offset == 0x01) |
| 865 | | { |
| 866 | | m_BORDER = data; |
| 867 | | } |
| 868 | | |
| 869 | | if (offset == 0x00) |
| 870 | | { |
| 871 | | m_FIXBIAS = data; |
| 872 | | } |
| 873 | | } |
| 874 | | |
| 875 | | void nick_device::do_screen(bitmap_ind16 &bm) |
| 876 | | { |
| 877 | | int line = 0; |
| 878 | | |
| 879 | | do |
| 880 | | { |
| 881 | | /* set write address for line */ |
| 882 | | m_dest = &bm.pix16(line); |
| 883 | | m_dest_pos = 0; |
| 884 | | m_dest_max_pos = bm.width(); |
| 885 | | |
| 886 | | /* write line */ |
| 887 | | do_line(); |
| 888 | | |
| 889 | | /* next line */ |
| 890 | | line++; |
| 891 | | } |
| 892 | | while (((m_LPT.MB & 0x080) == 0) && (line < ENTERPRISE_SCREEN_HEIGHT)); |
| 893 | | |
| 894 | | } |
| 895 | | |
| 896 | | |
| 897 | | UINT32 nick_device::screen_update_epnick(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 898 | | { |
| 899 | | do_screen(m_bitmap); |
| 900 | | copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); |
| 901 | | return 0; |
| 902 | | } |
trunk/src/mess/video/nick.c
| r0 | r23494 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Intelligent Designs NICK emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | #include "nick.h" |
| 11 | |
| 12 | |
| 13 | |
| 14 | //************************************************************************** |
| 15 | // MACROS / CONSTANTS |
| 16 | //************************************************************************** |
| 17 | |
| 18 | #define LOG 0 |
| 19 | |
| 20 | /* colour mode types */ |
| 21 | #define NICK_2_COLOUR_MODE 0 |
| 22 | #define NICK_4_COLOUR_MODE 1 |
| 23 | #define NICK_16_COLOUR_MODE 2 |
| 24 | #define NICK_256_COLOUR_MODE 3 |
| 25 | |
| 26 | /* Display mode types */ |
| 27 | #define NICK_VSYNC_MODE 0 |
| 28 | #define NICK_PIXEL_MODE 1 |
| 29 | #define NICK_ATTR_MODE 2 |
| 30 | #define NICK_CH256_MODE 3 |
| 31 | #define NICK_CH128_MODE 4 |
| 32 | #define NICK_CH64_MODE 5 |
| 33 | #define NICK_UNUSED_MODE 6 |
| 34 | #define NICK_LPIXEL_MODE 7 |
| 35 | |
| 36 | /* MODEBYTE defines */ |
| 37 | #define NICK_MB_VIRQ (1<<7) |
| 38 | #define NICK_MB_VRES (1<<4) |
| 39 | #define NICK_MB_LPT_RELOAD (1<<0) |
| 40 | |
| 41 | /* Left margin defines */ |
| 42 | #define NICK_LM_MSBALT (1<<7) |
| 43 | #define NICK_LM_LSBALT (1<<6) |
| 44 | |
| 45 | /* Right margin defines */ |
| 46 | #define NICK_RM_ALTIND1 (1<<7) |
| 47 | #define NICK_RM_ALTIND0 (1<<6) |
| 48 | |
| 49 | /* useful macros */ |
| 50 | #define NICK_GET_LEFT_MARGIN(x) (x & 0x03f) |
| 51 | #define NICK_GET_RIGHT_MARGIN(x) (x & 0x03f) |
| 52 | #define NICK_GET_DISPLAY_MODE(x) ((x>>1) & 0x07) |
| 53 | #define NICK_GET_COLOUR_MODE(x) ((x>>5) & 0x03) |
| 54 | |
| 55 | #define NICK_RELOAD_LPT(x) (x & 0x080) |
| 56 | #define NICK_CLOCK_LPT(x) (x & 0x040) |
| 57 | |
| 58 | /* Macros to generate memory address is CHx modes */ |
| 59 | /* x = LD2, y = buf1 */ |
| 60 | #define ADDR_CH256(x,y) (((x & 0x0ff)<<8) | (y & 0x0ff)) |
| 61 | #define ADDR_CH128(x,y) (((x & 0x01ff)<<7) | (y & 0x07f)) |
| 62 | #define ADDR_CH64(x,y) (((x & 0x03ff)<<6) | (y & 0x03f)) |
| 63 | |
| 64 | /* No of highest resolution pixels per "clock" */ |
| 65 | #define NICK_PIXELS_PER_CLOCK 16 |
| 66 | |
| 67 | /* "clocks" per line */ |
| 68 | #define NICK_TOTAL_CLOCKS_PER_LINE 64 |
| 69 | |
| 70 | /* Enterprise has 256 colours, all may be on the screen at once! |
| 71 | the NICK_GET_RED8, NICK_GET_GREEN8, NICK_GET_BLUE8 macros |
| 72 | return a 8-bit colour value for the index specified. */ |
| 73 | |
| 74 | /* given a colour index in range 0..255 gives the Red component */ |
| 75 | #define NICK_GET_RED8(x) \ |
| 76 | (( \ |
| 77 | (BIT(x, 0) << 2) | \ |
| 78 | (BIT(x, 3) << 1) | \ |
| 79 | (BIT(x, 6) << 0) \ |
| 80 | ) << 5) |
| 81 | |
| 82 | /* given a colour index in range 0..255 gives the Red component */ |
| 83 | #define NICK_GET_GREEN8(x) \ |
| 84 | (( \ |
| 85 | (BIT(x, 1) << 2) | \ |
| 86 | (BIT(x, 4) << 1) | \ |
| 87 | (BIT(x, 7) << 0) \ |
| 88 | ) << 5) |
| 89 | |
| 90 | /* given a colour index in range 0..255 gives the Red component */ |
| 91 | #define NICK_GET_BLUE8(x) \ |
| 92 | (( \ |
| 93 | (BIT(x, 2) << 1) | \ |
| 94 | (BIT(x, 5) << 0) \ |
| 95 | ) << 6) |
| 96 | |
| 97 | |
| 98 | |
| 99 | //************************************************************************** |
| 100 | // DEVICE DEFINITIONS |
| 101 | //************************************************************************** |
| 102 | |
| 103 | const device_type NICK = &device_creator<nick_device>; |
| 104 | |
| 105 | |
| 106 | DEVICE_ADDRESS_MAP_START( vram_map, 8, nick_device ) |
| 107 | AM_RANGE(0x0000, 0xffff) AM_READWRITE(vram_r, vram_w) |
| 108 | ADDRESS_MAP_END |
| 109 | |
| 110 | DEVICE_ADDRESS_MAP_START( vio_map, 8, nick_device ) |
| 111 | AM_RANGE(0x00, 0x00) AM_WRITE(fixbias_w) |
| 112 | AM_RANGE(0x01, 0x01) AM_WRITE(border_w) |
| 113 | AM_RANGE(0x02, 0x02) AM_WRITE(lpl_w) |
| 114 | AM_RANGE(0x03, 0x03) AM_WRITE(lph_w) |
| 115 | ADDRESS_MAP_END |
| 116 | |
| 117 | static ADDRESS_MAP_START( nick_map, AS_0, 8, nick_device ) |
| 118 | AM_RANGE(0x0000, 0xffff) AM_RAM |
| 119 | ADDRESS_MAP_END |
| 120 | |
| 121 | |
| 122 | |
| 123 | //************************************************************************** |
| 124 | // LIVE DEVICE |
| 125 | //************************************************************************** |
| 126 | |
| 127 | //------------------------------------------------- |
| 128 | // nick_device - constructor |
| 129 | //------------------------------------------------- |
| 130 | |
| 131 | nick_device::nick_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 132 | : device_t(mconfig, NICK, "NICK", tag, owner, clock), |
| 133 | device_memory_interface(mconfig, *this), |
| 134 | m_space_config("vram", ENDIANNESS_LITTLE, 8, 16, 0, *ADDRESS_MAP_NAME(nick_map)), |
| 135 | m_write_virq(*this) |
| 136 | { |
| 137 | } |
| 138 | |
| 139 | |
| 140 | //------------------------------------------------- |
| 141 | // device_start - device-specific startup |
| 142 | //------------------------------------------------- |
| 143 | |
| 144 | void nick_device::device_start() |
| 145 | { |
| 146 | screen_device *screen = machine().first_screen(); |
| 147 | |
| 148 | screen->register_screen_bitmap(m_bitmap); |
| 149 | calc_visible_clocks(ENTERPRISE_SCREEN_WIDTH); |
| 150 | |
| 151 | // initialize palette |
| 152 | for (int i = 0; i < 256; i++) |
| 153 | palette_set_color_rgb(machine(), i, NICK_GET_RED8(i), NICK_GET_GREEN8(i), NICK_GET_BLUE8(i)); |
| 154 | |
| 155 | // resolve callbacks |
| 156 | m_write_virq.resolve_safe(); |
| 157 | |
| 158 | // allocate timers |
| 159 | m_timer_scanline = timer_alloc(); |
| 160 | m_timer_scanline->adjust(screen->time_until_pos(0, 0), 0, screen->scan_period()); |
| 161 | |
| 162 | // state saving |
| 163 | save_item(NAME(m_scanline_count)); |
| 164 | save_item(NAME(m_FIXBIAS)); |
| 165 | save_item(NAME(m_BORDER)); |
| 166 | save_item(NAME(m_LPL)); |
| 167 | save_item(NAME(m_LPH)); |
| 168 | save_item(NAME(m_LD1)); |
| 169 | save_item(NAME(m_LD2)); |
| 170 | save_item(NAME(m_LPT.SC)); |
| 171 | save_item(NAME(m_LPT.MB)); |
| 172 | save_item(NAME(m_LPT.LM)); |
| 173 | save_item(NAME(m_LPT.RM)); |
| 174 | save_item(NAME(m_LPT.LD1L)); |
| 175 | save_item(NAME(m_LPT.LD1H)); |
| 176 | save_item(NAME(m_LPT.LD2L)); |
| 177 | save_item(NAME(m_LPT.LD2H)); |
| 178 | save_item(NAME(m_LPT.COL)); |
| 179 | save_item(NAME(m_dest_pos)); |
| 180 | save_item(NAME(m_dest_max_pos)); |
| 181 | save_item(NAME(m_reg)); |
| 182 | save_item(NAME(m_first_visible_clock)); |
| 183 | save_item(NAME(m_last_visible_clock)); |
| 184 | } |
| 185 | |
| 186 | |
| 187 | //------------------------------------------------- |
| 188 | // device_reset - device-specific reset |
| 189 | //------------------------------------------------- |
| 190 | |
| 191 | void nick_device::device_reset() |
| 192 | { |
| 193 | m_write_virq(CLEAR_LINE); |
| 194 | m_virq = 0; |
| 195 | |
| 196 | for (int i = 0; i < 256; i++) |
| 197 | { |
| 198 | int pen_index; |
| 199 | |
| 200 | pen_index = (BIT(i, 7) << 0) | (BIT(i, 3) << 1); |
| 201 | m_pen_idx_4col[i] = pen_index; |
| 202 | |
| 203 | pen_index = (BIT(i, 7) << 0) | (BIT(i, 3) << 1) | (BIT(i, 5) << 2) | (BIT(i, 1) << 3); |
| 204 | m_pen_idx_16col[i] = pen_index; |
| 205 | } |
| 206 | |
| 207 | m_scanline_count = 0; |
| 208 | } |
| 209 | |
| 210 | |
| 211 | //------------------------------------------------- |
| 212 | // device_timer - handler timer events |
| 213 | //------------------------------------------------- |
| 214 | |
| 215 | void nick_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) |
| 216 | { |
| 217 | int scanline = machine().first_screen()->vpos(); |
| 218 | |
| 219 | if (scanline < ENTERPRISE_SCREEN_HEIGHT) |
| 220 | { |
| 221 | /* set write address for line */ |
| 222 | m_dest = &m_bitmap.pix16(scanline); |
| 223 | m_dest_pos = 0; |
| 224 | m_dest_max_pos = m_bitmap.width(); |
| 225 | |
| 226 | /* write line */ |
| 227 | do_line(); |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | |
| 232 | //------------------------------------------------- |
| 233 | // memory_space_config - return a description of |
| 234 | // any address spaces owned by this device |
| 235 | //------------------------------------------------- |
| 236 | |
| 237 | const address_space_config *nick_device::memory_space_config(address_spacenum spacenum) const |
| 238 | { |
| 239 | return (spacenum == 0) ? &m_space_config : NULL; |
| 240 | } |
| 241 | |
| 242 | |
| 243 | //------------------------------------------------- |
| 244 | // update_screen - update screen |
| 245 | //------------------------------------------------- |
| 246 | |
| 247 | UINT32 nick_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 248 | { |
| 249 | copybitmap(bitmap, m_bitmap, 0, 0, 0, 0, cliprect); |
| 250 | |
| 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | |
| 255 | //------------------------------------------------- |
| 256 | // vram_r - video RAM read |
| 257 | //------------------------------------------------- |
| 258 | |
| 259 | READ8_MEMBER( nick_device::vram_r ) |
| 260 | { |
| 261 | return m_addrspace[0]->read_byte(offset); |
| 262 | } |
| 263 | |
| 264 | |
| 265 | //------------------------------------------------- |
| 266 | // vram_w - video RAM write |
| 267 | //------------------------------------------------- |
| 268 | |
| 269 | WRITE8_MEMBER( nick_device::vram_w ) |
| 270 | { |
| 271 | m_addrspace[0]->write_byte(offset, data); |
| 272 | } |
| 273 | |
| 274 | |
| 275 | //------------------------------------------------- |
| 276 | // fixbias_w - |
| 277 | //------------------------------------------------- |
| 278 | |
| 279 | WRITE8_MEMBER( nick_device::fixbias_w ) |
| 280 | { |
| 281 | m_FIXBIAS = data; |
| 282 | } |
| 283 | |
| 284 | |
| 285 | //------------------------------------------------- |
| 286 | // border_w - |
| 287 | //------------------------------------------------- |
| 288 | |
| 289 | WRITE8_MEMBER( nick_device::border_w ) |
| 290 | { |
| 291 | m_BORDER = data; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | //------------------------------------------------- |
| 296 | // lpl_w - |
| 297 | //------------------------------------------------- |
| 298 | |
| 299 | WRITE8_MEMBER( nick_device::lpl_w ) |
| 300 | { |
| 301 | m_LPL = m_reg[2] = data; |
| 302 | |
| 303 | update_lpt(); |
| 304 | } |
| 305 | |
| 306 | |
| 307 | //------------------------------------------------- |
| 308 | // lph_w - |
| 309 | //------------------------------------------------- |
| 310 | |
| 311 | WRITE8_MEMBER( nick_device::lph_w ) |
| 312 | { |
| 313 | m_LPH = m_reg[3] = data; |
| 314 | |
| 315 | update_lpt(); |
| 316 | } |
| 317 | |
| 318 | |
| 319 | // MESS specific |
| 320 | /* 8-bit pixel write! */ |
| 321 | void nick_device::write_pixel(int ci) |
| 322 | { |
| 323 | if (m_dest_pos < m_dest_max_pos) |
| 324 | { |
| 325 | m_dest[m_dest_pos++] = ci; |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | /* we align based on the clocks */ |
| 330 | void nick_device::calc_visible_clocks(int width) |
| 331 | { |
| 332 | /* number of clocks we can see */ |
| 333 | int no_visible_clocks = width / NICK_PIXELS_PER_CLOCK; |
| 334 | m_first_visible_clock = (NICK_TOTAL_CLOCKS_PER_LINE - no_visible_clocks) >> 1; |
| 335 | m_last_visible_clock = m_first_visible_clock + no_visible_clocks; |
| 336 | } |
| 337 | |
| 338 | |
| 339 | /* write border colour */ |
| 340 | void nick_device::write_border(int clocks) |
| 341 | { |
| 342 | int col_index = m_BORDER; |
| 343 | |
| 344 | for (int i = 0; i < (clocks << 4); i++) |
| 345 | write_pixel(col_index); |
| 346 | } |
| 347 | |
| 348 | |
| 349 | void nick_device::do_left_margin() |
| 350 | { |
| 351 | UINT8 left = NICK_GET_LEFT_MARGIN(m_LPT.LM); |
| 352 | |
| 353 | if (left > m_first_visible_clock) |
| 354 | { |
| 355 | /* some of the left margin is visible */ |
| 356 | UINT8 left_visible = left - m_first_visible_clock; |
| 357 | |
| 358 | /* render the border */ |
| 359 | write_border(left_visible); |
| 360 | } |
| 361 | } |
| 362 | |
| 363 | void nick_device::do_right_margin() |
| 364 | { |
| 365 | UINT8 right = NICK_GET_RIGHT_MARGIN(m_LPT.RM); |
| 366 | |
| 367 | if (right < m_last_visible_clock) |
| 368 | { |
| 369 | /* some of the right margin is visible */ |
| 370 | UINT8 right_visible = m_last_visible_clock - right; |
| 371 | |
| 372 | /* render the border */ |
| 373 | write_border(right_visible); |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | int nick_device::get_color_index(int pen_index) |
| 378 | { |
| 379 | if (pen_index & 0x08) |
| 380 | return ((m_FIXBIAS & 0x01f) << 3) | (pen_index & 0x07); |
| 381 | else |
| 382 | return m_LPT.COL[pen_index]; |
| 383 | } |
| 384 | |
| 385 | void nick_device::write_pixels2color(UINT8 pen0, UINT8 pen1, UINT8 data_byte) |
| 386 | { |
| 387 | int col_index[2]; |
| 388 | int pen_index; |
| 389 | UINT8 data = data_byte; |
| 390 | |
| 391 | col_index[0] = get_color_index(pen0); |
| 392 | col_index[1] = get_color_index(pen1); |
| 393 | |
| 394 | for (int i = 0; i < 8; i++) |
| 395 | { |
| 396 | pen_index = col_index[BIT(data, 7)]; |
| 397 | write_pixel(pen_index); |
| 398 | data <<= 1; |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | void nick_device::write_pixels2color_lpixel(UINT8 pen0, UINT8 pen1, UINT8 data_byte) |
| 403 | { |
| 404 | int col_index[2]; |
| 405 | int pen_index; |
| 406 | UINT8 data = data_byte; |
| 407 | |
| 408 | col_index[0] = get_color_index(pen0); |
| 409 | col_index[1] = get_color_index(pen1); |
| 410 | |
| 411 | for (int i = 0; i < 8; i++) |
| 412 | { |
| 413 | pen_index = col_index[BIT(data, 7)]; |
| 414 | write_pixel(pen_index); |
| 415 | write_pixel(pen_index); |
| 416 | data <<= 1; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | |
| 421 | void nick_device::write_pixels(UINT8 data_byte, UINT8 char_idx) |
| 422 | { |
| 423 | /* pen index colour 2-C (0,1), 4-C (0..3) 16-C (0..16) */ |
| 424 | int pen_idx; |
| 425 | /* Col index = EP colour value */ |
| 426 | int pal_idx; |
| 427 | UINT8 color_mode = NICK_GET_COLOUR_MODE(m_LPT.MB); |
| 428 | UINT8 data = data_byte; |
| 429 | |
| 430 | switch (color_mode) |
| 431 | { |
| 432 | case NICK_2_COLOUR_MODE: |
| 433 | { |
| 434 | int pen_offs = 0; |
| 435 | |
| 436 | /* do before displaying byte */ |
| 437 | |
| 438 | /* left margin attributes */ |
| 439 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 440 | { |
| 441 | if (data & 0x080) |
| 442 | { |
| 443 | pen_offs |= 2; |
| 444 | } |
| 445 | |
| 446 | data &=~0x080; |
| 447 | } |
| 448 | |
| 449 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 450 | { |
| 451 | if (data & 0x001) |
| 452 | { |
| 453 | pen_offs |= 4; |
| 454 | } |
| 455 | |
| 456 | data &=~0x01; |
| 457 | } |
| 458 | |
| 459 | if (m_LPT.RM & NICK_RM_ALTIND1) |
| 460 | { |
| 461 | if (char_idx & 0x080) |
| 462 | { |
| 463 | pen_offs |= 0x02; |
| 464 | } |
| 465 | } |
| 466 | |
| 467 | #if 0 |
| 468 | if (m_LPT.RM & NICK_RM_ALTIND0) |
| 469 | { |
| 470 | if (data & 0x040) |
| 471 | { |
| 472 | pen_offs |= 0x04; |
| 473 | } |
| 474 | } |
| 475 | #endif |
| 476 | |
| 477 | |
| 478 | write_pixels2color(pen_offs, (pen_offs | 0x01), data); |
| 479 | } |
| 480 | break; |
| 481 | |
| 482 | case NICK_4_COLOUR_MODE: |
| 483 | { |
| 484 | //mame_printf_info("4 colour\r\n"); |
| 485 | |
| 486 | /* left margin attributes */ |
| 487 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 488 | { |
| 489 | data &= ~0x080; |
| 490 | } |
| 491 | |
| 492 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 493 | { |
| 494 | data &= ~0x01; |
| 495 | } |
| 496 | |
| 497 | |
| 498 | for (int i = 0; i < 4; i++) |
| 499 | { |
| 500 | pen_idx = m_pen_idx_4col[data]; |
| 501 | pal_idx = m_LPT.COL[pen_idx & 0x03]; |
| 502 | |
| 503 | write_pixel(pal_idx); |
| 504 | write_pixel(pal_idx); |
| 505 | |
| 506 | data <<= 1; |
| 507 | } |
| 508 | } |
| 509 | break; |
| 510 | |
| 511 | case NICK_16_COLOUR_MODE: |
| 512 | { |
| 513 | //mame_printf_info("16 colour\r\n"); |
| 514 | |
| 515 | /* left margin attributes */ |
| 516 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 517 | { |
| 518 | data &= ~0x080; |
| 519 | } |
| 520 | |
| 521 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 522 | { |
| 523 | data &= ~0x01; |
| 524 | } |
| 525 | |
| 526 | |
| 527 | for (int i = 0; i < 2; i++) |
| 528 | { |
| 529 | pen_idx = m_pen_idx_16col[data]; |
| 530 | |
| 531 | pal_idx = get_color_index(pen_idx); |
| 532 | |
| 533 | write_pixel(pal_idx); |
| 534 | write_pixel(pal_idx); |
| 535 | write_pixel(pal_idx); |
| 536 | write_pixel(pal_idx); |
| 537 | |
| 538 | data <<= 1; |
| 539 | } |
| 540 | } |
| 541 | break; |
| 542 | |
| 543 | case NICK_256_COLOUR_MODE: |
| 544 | { |
| 545 | /* left margin attributes */ |
| 546 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 547 | { |
| 548 | data &= ~0x080; |
| 549 | } |
| 550 | |
| 551 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 552 | { |
| 553 | data &= ~0x01; |
| 554 | } |
| 555 | |
| 556 | |
| 557 | pal_idx = data; |
| 558 | |
| 559 | write_pixel(pal_idx); |
| 560 | write_pixel(pal_idx); |
| 561 | write_pixel(pal_idx); |
| 562 | write_pixel(pal_idx); |
| 563 | write_pixel(pal_idx); |
| 564 | write_pixel(pal_idx); |
| 565 | write_pixel(pal_idx); |
| 566 | write_pixel(pal_idx); |
| 567 | |
| 568 | |
| 569 | } |
| 570 | break; |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | void nick_device::write_pixels_lpixel(UINT8 data_byte, UINT8 char_idx) |
| 575 | { |
| 576 | /* pen index colour 2-C (0,1), 4-C (0..3) 16-C (0..16) */ |
| 577 | int pen_idx; |
| 578 | /* Col index = EP colour value */ |
| 579 | int pal_idx; |
| 580 | UINT8 color_mode = NICK_GET_COLOUR_MODE(m_LPT.MB); |
| 581 | UINT8 data = data_byte; |
| 582 | |
| 583 | switch (color_mode) |
| 584 | { |
| 585 | case NICK_2_COLOUR_MODE: |
| 586 | { |
| 587 | int pen_offs = 0; |
| 588 | |
| 589 | /* do before displaying byte */ |
| 590 | |
| 591 | /* left margin attributes */ |
| 592 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 593 | { |
| 594 | if (data & 0x080) |
| 595 | { |
| 596 | pen_offs |= 2; |
| 597 | } |
| 598 | |
| 599 | data &=~0x080; |
| 600 | } |
| 601 | |
| 602 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 603 | { |
| 604 | if (data & 0x001) |
| 605 | { |
| 606 | pen_offs |= 4; |
| 607 | } |
| 608 | |
| 609 | data &=~0x01; |
| 610 | } |
| 611 | |
| 612 | if (m_LPT.RM & NICK_RM_ALTIND1) |
| 613 | { |
| 614 | if (char_idx & 0x080) |
| 615 | { |
| 616 | pen_offs |= 0x02; |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | #if 0 |
| 621 | if (m_LPT.RM & NICK_RM_ALTIND0) |
| 622 | { |
| 623 | if (data & 0x040) |
| 624 | { |
| 625 | pen_offs |= 0x04; |
| 626 | } |
| 627 | } |
| 628 | #endif |
| 629 | |
| 630 | |
| 631 | write_pixels2color_lpixel(pen_offs, (pen_offs | 0x01), data); |
| 632 | } |
| 633 | break; |
| 634 | |
| 635 | case NICK_4_COLOUR_MODE: |
| 636 | { |
| 637 | //mame_printf_info("4 colour\r\n"); |
| 638 | |
| 639 | /* left margin attributes */ |
| 640 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 641 | { |
| 642 | data &= ~0x080; |
| 643 | } |
| 644 | |
| 645 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 646 | { |
| 647 | data &= ~0x01; |
| 648 | } |
| 649 | |
| 650 | |
| 651 | for (int i = 0; i < 4; i++) |
| 652 | { |
| 653 | pen_idx = m_pen_idx_4col[data]; |
| 654 | pal_idx = m_LPT.COL[pen_idx & 0x03]; |
| 655 | |
| 656 | write_pixel(pal_idx); |
| 657 | write_pixel(pal_idx); |
| 658 | write_pixel(pal_idx); |
| 659 | write_pixel(pal_idx); |
| 660 | |
| 661 | data <<= 1; |
| 662 | } |
| 663 | } |
| 664 | break; |
| 665 | |
| 666 | case NICK_16_COLOUR_MODE: |
| 667 | { |
| 668 | //mame_printf_info("16 colour\r\n"); |
| 669 | |
| 670 | /* left margin attributes */ |
| 671 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 672 | { |
| 673 | data &= ~0x080; |
| 674 | } |
| 675 | |
| 676 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 677 | { |
| 678 | data &= ~0x01; |
| 679 | } |
| 680 | |
| 681 | |
| 682 | for (int i = 0; i < 2; i++) |
| 683 | { |
| 684 | pen_idx = m_pen_idx_16col[data]; |
| 685 | pal_idx = get_color_index(pen_idx); |
| 686 | |
| 687 | write_pixel(pal_idx); |
| 688 | write_pixel(pal_idx); |
| 689 | write_pixel(pal_idx); |
| 690 | write_pixel(pal_idx); |
| 691 | write_pixel(pal_idx); |
| 692 | write_pixel(pal_idx); |
| 693 | write_pixel(pal_idx); |
| 694 | write_pixel(pal_idx); |
| 695 | |
| 696 | data <<= 1; |
| 697 | } |
| 698 | } |
| 699 | break; |
| 700 | |
| 701 | case NICK_256_COLOUR_MODE: |
| 702 | { |
| 703 | /* left margin attributes */ |
| 704 | if (m_LPT.LM & NICK_LM_MSBALT) |
| 705 | { |
| 706 | data &= ~0x080; |
| 707 | } |
| 708 | |
| 709 | if (m_LPT.LM & NICK_LM_LSBALT) |
| 710 | { |
| 711 | data &= ~0x01; |
| 712 | } |
| 713 | |
| 714 | |
| 715 | pal_idx = data; |
| 716 | |
| 717 | write_pixel(pal_idx); |
| 718 | write_pixel(pal_idx); |
| 719 | write_pixel(pal_idx); |
| 720 | write_pixel(pal_idx); |
| 721 | write_pixel(pal_idx); |
| 722 | write_pixel(pal_idx); |
| 723 | write_pixel(pal_idx); |
| 724 | write_pixel(pal_idx); |
| 725 | |
| 726 | write_pixel(pal_idx); |
| 727 | write_pixel(pal_idx); |
| 728 | write_pixel(pal_idx); |
| 729 | write_pixel(pal_idx); |
| 730 | write_pixel(pal_idx); |
| 731 | write_pixel(pal_idx); |
| 732 | write_pixel(pal_idx); |
| 733 | write_pixel(pal_idx); |
| 734 | |
| 735 | |
| 736 | } |
| 737 | break; |
| 738 | } |
| 739 | } |
| 740 | |
| 741 | |
| 742 | void nick_device::do_pixel(int clocks_visible) |
| 743 | { |
| 744 | UINT8 buf1, buf2; |
| 745 | |
| 746 | for (int i = 0; i < clocks_visible; i++) |
| 747 | { |
| 748 | buf1 = m_addrspace[0]->read_byte(m_LD1); |
| 749 | m_LD1++; |
| 750 | |
| 751 | buf2 = m_addrspace[0]->read_byte(m_LD1); |
| 752 | m_LD1++; |
| 753 | |
| 754 | write_pixels(buf1, buf1); |
| 755 | write_pixels(buf2, buf1); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | |
| 760 | void nick_device::do_lpixel(int clocks_visible) |
| 761 | { |
| 762 | UINT8 buf1; |
| 763 | |
| 764 | for (int i = 0; i < clocks_visible; i++) |
| 765 | { |
| 766 | buf1 = m_addrspace[0]->read_byte(m_LD1); |
| 767 | m_LD1++; |
| 768 | |
| 769 | write_pixels_lpixel(buf1, buf1); |
| 770 | } |
| 771 | } |
| 772 | |
| 773 | void nick_device::do_attr(int clocks_visible) |
| 774 | { |
| 775 | UINT8 buf1, buf2; |
| 776 | |
| 777 | for (int i = 0; i < clocks_visible; i++) |
| 778 | { |
| 779 | buf1 = m_addrspace[0]->read_byte(m_LD1); |
| 780 | m_LD1++; |
| 781 | |
| 782 | buf2 = m_addrspace[0]->read_byte(m_LD2); |
| 783 | m_LD2++; |
| 784 | |
| 785 | { |
| 786 | UINT8 bg_color = ((buf1 >> 4) & 0x0f); |
| 787 | UINT8 fg_color = (buf1 & 0x0f); |
| 788 | |
| 789 | write_pixels2color_lpixel(bg_color, fg_color, buf2); |
| 790 | } |
| 791 | } |
| 792 | } |
| 793 | |
| 794 | void nick_device::do_ch256(int clocks_visible) |
| 795 | { |
| 796 | UINT8 buf1, buf2; |
| 797 | |
| 798 | for (int i = 0; i < clocks_visible; i++) |
| 799 | { |
| 800 | buf1 = m_addrspace[0]->read_byte(m_LD1); |
| 801 | m_LD1++; |
| 802 | buf2 = m_addrspace[0]->read_byte(ADDR_CH256(m_LD2, buf1)); |
| 803 | |
| 804 | write_pixels_lpixel(buf2, buf1); |
| 805 | } |
| 806 | } |
| 807 | |
| 808 | void nick_device::do_ch128(int clocks_visible) |
| 809 | { |
| 810 | UINT8 buf1, buf2; |
| 811 | |
| 812 | for (int i = 0; i < clocks_visible; i++) |
| 813 | { |
| 814 | buf1 = m_addrspace[0]->read_byte(m_LD1); |
| 815 | m_LD1++; |
| 816 | buf2 = m_addrspace[0]->read_byte(ADDR_CH128(m_LD2, buf1)); |
| 817 | |
| 818 | write_pixels_lpixel(buf2, buf1); |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | void nick_device::do_ch64(int clocks_visible) |
| 823 | { |
| 824 | UINT8 buf1, buf2; |
| 825 | |
| 826 | for (int i = 0; i < clocks_visible; i++) |
| 827 | { |
| 828 | buf1 = m_addrspace[0]->read_byte(m_LD1); |
| 829 | m_LD1++; |
| 830 | buf2 = m_addrspace[0]->read_byte(ADDR_CH64(m_LD2, buf1)); |
| 831 | |
| 832 | write_pixels_lpixel(buf2, buf1); |
| 833 | } |
| 834 | } |
| 835 | |
| 836 | |
| 837 | void nick_device::do_display() |
| 838 | { |
| 839 | LPT_ENTRY *pLPT = &m_LPT; |
| 840 | UINT8 clocks_visible; |
| 841 | UINT8 right_margin = NICK_GET_RIGHT_MARGIN(pLPT->RM); |
| 842 | UINT8 left_margin = NICK_GET_LEFT_MARGIN(pLPT->LM); |
| 843 | |
| 844 | clocks_visible = right_margin - left_margin; |
| 845 | |
| 846 | if (clocks_visible) |
| 847 | { |
| 848 | /* get display mode */ |
| 849 | UINT8 display_mode = NICK_GET_DISPLAY_MODE(pLPT->MB); |
| 850 | |
| 851 | if (m_scanline_count == 0) // || |
| 852 | //((pLPT->MB & NICK_MB_VRES)==0)) |
| 853 | { |
| 854 | /* doing first line */ |
| 855 | /* reload LD1, and LD2 (if necessary) regardless of display mode */ |
| 856 | m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); |
| 857 | |
| 858 | if ((display_mode != NICK_LPIXEL_MODE) && (display_mode != NICK_PIXEL_MODE)) |
| 859 | { |
| 860 | /* lpixel and pixel modes don't use LD2 */ |
| 861 | m_LD2 = (pLPT->LD2L & 0xff) | ((pLPT->LD2H & 0xff) << 8); |
| 862 | } |
| 863 | } |
| 864 | else |
| 865 | { |
| 866 | /* not first line */ |
| 867 | switch (display_mode) |
| 868 | { |
| 869 | case NICK_ATTR_MODE: |
| 870 | { |
| 871 | /* reload LD1 */ |
| 872 | m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); |
| 873 | } |
| 874 | break; |
| 875 | |
| 876 | case NICK_CH256_MODE: |
| 877 | case NICK_CH128_MODE: |
| 878 | case NICK_CH64_MODE: |
| 879 | { |
| 880 | /* reload LD1 */ |
| 881 | m_LD1 = (pLPT->LD1L & 0xff) | ((pLPT->LD1H & 0xff) << 8); |
| 882 | m_LD2++; |
| 883 | } |
| 884 | break; |
| 885 | |
| 886 | default: |
| 887 | break; |
| 888 | } |
| 889 | } |
| 890 | |
| 891 | switch (display_mode) |
| 892 | { |
| 893 | case NICK_PIXEL_MODE: |
| 894 | { |
| 895 | do_pixel(clocks_visible); |
| 896 | } |
| 897 | break; |
| 898 | |
| 899 | case NICK_ATTR_MODE: |
| 900 | { |
| 901 | //mame_printf_info("attr mode\r\n"); |
| 902 | do_attr(clocks_visible); |
| 903 | } |
| 904 | break; |
| 905 | |
| 906 | case NICK_CH256_MODE: |
| 907 | { |
| 908 | //mame_printf_info("ch256 mode\r\n"); |
| 909 | do_ch256(clocks_visible); |
| 910 | } |
| 911 | break; |
| 912 | |
| 913 | case NICK_CH128_MODE: |
| 914 | { |
| 915 | do_ch128(clocks_visible); |
| 916 | } |
| 917 | break; |
| 918 | |
| 919 | case NICK_CH64_MODE: |
| 920 | { |
| 921 | //mame_printf_info("ch64 mode\r\n"); |
| 922 | do_ch64(clocks_visible); |
| 923 | } |
| 924 | break; |
| 925 | |
| 926 | case NICK_LPIXEL_MODE: |
| 927 | { |
| 928 | do_lpixel(clocks_visible); |
| 929 | } |
| 930 | break; |
| 931 | |
| 932 | default: |
| 933 | break; |
| 934 | } |
| 935 | } |
| 936 | } |
| 937 | |
| 938 | void nick_device::update_lpt() |
| 939 | { |
| 940 | UINT16 CurLPT = (m_LPL & 0x0ff) | ((m_LPH & 0x0f) << 8); |
| 941 | CurLPT++; |
| 942 | m_LPL = CurLPT & 0x0ff; |
| 943 | m_LPH = (m_LPH & 0x0f0) | ((CurLPT >> 8) & 0x0f); |
| 944 | } |
| 945 | |
| 946 | |
| 947 | void nick_device::reload_lpt() |
| 948 | { |
| 949 | /* get addr of LPT */ |
| 950 | UINT32 LPT_Addr = ((m_LPL & 0x0ff) << 4) | ((m_LPH & 0x0f) << (8+4)); |
| 951 | |
| 952 | /* update internal LPT state */ |
| 953 | m_LPT.SC = m_addrspace[0]->read_byte(LPT_Addr); |
| 954 | m_LPT.MB = m_addrspace[0]->read_byte(LPT_Addr + 1); |
| 955 | m_LPT.LM = m_addrspace[0]->read_byte(LPT_Addr + 2); |
| 956 | m_LPT.RM = m_addrspace[0]->read_byte(LPT_Addr + 3); |
| 957 | m_LPT.LD1L = m_addrspace[0]->read_byte(LPT_Addr + 4); |
| 958 | m_LPT.LD1H = m_addrspace[0]->read_byte(LPT_Addr + 5); |
| 959 | m_LPT.LD2L = m_addrspace[0]->read_byte(LPT_Addr + 6); |
| 960 | m_LPT.LD2H = m_addrspace[0]->read_byte(LPT_Addr + 7); |
| 961 | m_LPT.COL[0] = m_addrspace[0]->read_byte(LPT_Addr + 8); |
| 962 | m_LPT.COL[1] = m_addrspace[0]->read_byte(LPT_Addr + 9); |
| 963 | m_LPT.COL[2] = m_addrspace[0]->read_byte(LPT_Addr + 10); |
| 964 | m_LPT.COL[3] = m_addrspace[0]->read_byte(LPT_Addr + 11); |
| 965 | m_LPT.COL[4] = m_addrspace[0]->read_byte(LPT_Addr + 12); |
| 966 | m_LPT.COL[5] = m_addrspace[0]->read_byte(LPT_Addr + 13); |
| 967 | m_LPT.COL[6] = m_addrspace[0]->read_byte(LPT_Addr + 14); |
| 968 | m_LPT.COL[7] = m_addrspace[0]->read_byte(LPT_Addr + 15); |
| 969 | } |
| 970 | |
| 971 | /* call here to render a line of graphics */ |
| 972 | void nick_device::do_line() |
| 973 | { |
| 974 | UINT8 scanline; |
| 975 | |
| 976 | m_write_virq((m_LPT.MB & NICK_MB_VIRQ) ? ASSERT_LINE : CLEAR_LINE); |
| 977 | |
| 978 | if (m_virq && !(m_LPT.MB & NICK_MB_VIRQ)) |
| 979 | { |
| 980 | screen_device *screen = machine().first_screen(); |
| 981 | m_timer_scanline->adjust(screen->time_until_pos(0, 0), 0, screen->scan_period()); |
| 982 | } |
| 983 | |
| 984 | m_virq = (m_LPT.MB & NICK_MB_VIRQ) ? 1 : 0; |
| 985 | |
| 986 | if ((m_LPT.MB & NICK_MB_LPT_RELOAD)!=0) |
| 987 | { |
| 988 | /* reload LPT */ |
| 989 | |
| 990 | m_LPL = m_reg[2]; |
| 991 | m_LPH = m_reg[3]; |
| 992 | |
| 993 | reload_lpt(); |
| 994 | } |
| 995 | |
| 996 | /* left border */ |
| 997 | do_left_margin(); |
| 998 | |
| 999 | /* do visible part */ |
| 1000 | do_display(); |
| 1001 | |
| 1002 | /* right border */ |
| 1003 | do_right_margin(); |
| 1004 | |
| 1005 | // 0x0f7 is first! |
| 1006 | /* scan line count for this LPT */ |
| 1007 | scanline = ((~m_LPT.SC) + 1) & 0x0ff; |
| 1008 | |
| 1009 | //printf("scanline %02x\r\n", scanline); |
| 1010 | |
| 1011 | /* update count of scanlines done so far */ |
| 1012 | m_scanline_count++; |
| 1013 | |
| 1014 | if (m_scanline_count == scanline) |
| 1015 | { |
| 1016 | /* done all scanlines of this Line Parameter Table, get next */ |
| 1017 | |
| 1018 | m_scanline_count = 0; |
| 1019 | |
| 1020 | update_lpt(); |
| 1021 | reload_lpt(); |
| 1022 | } |
| 1023 | } |
trunk/src/mess/drivers/enterp.c
| r23493 | r23494 | |
| 1 | | /* |
| 2 | | |
| 3 | | Enterprise Sixty Four / Enterprise One Two Eight |
| 4 | | Enterprise Computers Ltd. 1985 |
| 5 | | |
| 6 | | MAIN PCB Layout |
| 7 | | --------------- |
| 8 | | DUAL |
| 9 | | |-----------| 9V TAPE_IN/OUT RES |
| 10 | | |HEATSINK | DC_IN MON1 AND REMOTE SR1 PR1 CN2A CN1A |-| |
| 11 | | | |--||---|--||--|--| |--| |-||-||-||-||-| |----| |-----| |--| |--| |-|-|------| |
| 12 | | |-----------|7805 | MOD | |-| |-| |-| |-| |-| |-| |-| EXP2 --|EXTERNAL |
| 13 | | |---+7805 | | 74LS06 74LS273 74LS86 74LS32 --|EXPANSION |
| 14 | | | | |------| 74LS244 --|CONNECTOR |
| 15 | | | |78L12 POT1 LM386 |-----| |-----| EXP1 --| |
| 16 | | CART | | LM1889 LM1886 74LS04|NICK | |DAVE | --| |
| 17 | | CONN | | KEYB_8 POT2 KEYB_10 | | | | --| |
| 18 | | | | 4.433619MHz 74LS145 POT3 LED |-----| |-----| --| |
| 19 | | |---+ --| |
| 20 | | | 74LS74 74LS244 74LS244 74LS245 |---------| |
| 21 | | | | |
| 22 | | | 74LS373 4164 4164 74F157 | |
| 23 | | | | |
| 24 | | | 16-2-103 LM339 LM324 4164 4164 74F157 EXOS.IC2 | |
| 25 | | | 8MHz | |
| 26 | | | 74LS373 4164 4164 | |
| 27 | | | 74LS04 Z80A | |
| 28 | | | 74LS273 4164 4164 | |
| 29 | | |------------------------------------------------------------------| |
| 30 | | Notes: (all IC's shown) |
| 31 | | Z80A - Z80A CPU, clock input 4MHz [8/2] |
| 32 | | EXOS.IC2 - 32k x8-bit mask ROM usually 23256 manufactured by GI (DIP24). Contains EXOS operating |
| 33 | | system and built-in word processor software. A few official revisions were made and |
| 34 | | there were a few unofficial revision made with additional capabilities and bug-fixes |
| 35 | | ROM labelling of some official versions found.... |
| 36 | | 9256DS-0019 (C)1984 INTELLIGENT SOFTWARE LTD ENTER 08-45-A GI |
| 37 | | 9256DS-0036 (C)1984 INTELLIGENT SOFTWARE LTD ENTER 05-23-A GI |
| 38 | | 4164 - 64k x1-bit Dynamic RAM with Page Mode (DIP16) |
| 39 | | NICK - Custom graphics chip (QFP72) |
| 40 | | DAVE - Custom sound chip (QFP72) |
| 41 | | LM386 - National Semiconductor LM386 Low Voltage Audio Power Amplifier (DIP8) |
| 42 | | LM1889 - National Semiconductor LM1889 TV Video Modulator (DIP18) |
| 43 | | LM1886 - National Semiconductor LM1886 TV Video Matrix DAC (DIP20) |
| 44 | | LM339 - SGS LM339 Low Power Low Offset Voltage Quad Comparator (DIP8) |
| 45 | | LM324 - SGS LM324 Quad Operational Amplifier (DIP8) |
| 46 | | 74LS04 - Hex Inverter (DIP14) |
| 47 | | 74LS06 - Hex Inverter/Buffer with Open-Collector Outputs (DIP14) |
| 48 | | 74LS32 - Quad 2-Input Positive OR Gate (DIP14) |
| 49 | | 74LS74 - Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs (DIP14) |
| 50 | | 74LS86 - Quad 2-Input Exclusive OR Gate (DIP14) |
| 51 | | 74LS145 - BCD to Deccimal Decoder/Driver (DIP16) |
| 52 | | 74F157 - Quad 2-Line to 1-Line Data Selector/Multiplexer (DIP16). Early rev mainboards use 74LS158 instead |
| 53 | | 74LS244 - Octal 3-State Noninverting Buffer/Line Driver/Line Receiver (DIP20) |
| 54 | | 74LS245 - Octal Bus Tranceiver with Tri-State Outputs (DIP20) |
| 55 | | 74LS273 - Octal D-Type Flip-Flop With Clear (DIP20) |
| 56 | | 74LS373 - Octal D-Type Transparent Latches and Edge-Triggered Flip-Flops (DIP20) |
| 57 | | 7805 - Voltage regulator. +9V DC input from DC power pack, +5V DC output |
| 58 | | 78L12 - Voltage regulator. Voltage input via small transformer on PCB. +12V DC output |
| 59 | | POT1 - Potentiometer located near modulator and video output circuitry |
| 60 | | POT2 - Potentiometer located near video output circuitry. Probably used to fine-tune the video clock |
| 61 | | POT3 - Potentiometer. Possibly for video/NICK-related adjustments |
| 62 | | LED - LED to show +5V is present |
| 63 | | 16-2-103 - Resistor Array (DIP16) |
| 64 | | KEYB_8 - 8 pin keyboard connector |
| 65 | | KEYB_10 - 10 pin keyboard connector |
| 66 | | EXP1 - 28 pin internal expansion connector (solder holes only) used for internal 64k memory expansion card |
| 67 | | EXP2 - 10 pin internal expansion connector (solder holes only) used for internal 64k memory expansion card |
| 68 | | MOD - Astec UM1233 TV modulator |
| 69 | | RES - Reset push button switch |
| 70 | | MON1 - Monitor output connector. Pinout is.... |
| 71 | | |
| 72 | | Green A1 B1 NC |
| 73 | | Ground A2 B2 Ground |
| 74 | | Mono Comp. Video A3 B3 Blue |
| 75 | | HSync A4 B4 Red |
| 76 | | VSync A5 B5 Composite Sync |
| 77 | | NC A6 B6 Mode Switch |
| 78 | | Left Audio A7 B7 Right Audio |
| 79 | | |
| 80 | | SR1 - Serial/Network connector. Pinout is.... |
| 81 | | |
| 82 | | Reference A1 B1 Ground |
| 83 | | - A2 B2 - |
| 84 | | RTS A3 B3 Data Out |
| 85 | | CTS A4 B4 Data In |
| 86 | | |
| 87 | | PR1 - Printer connector. Pinout is.... |
| 88 | | |
| 89 | | Ground A1 B1 Ground |
| 90 | | Strobe A2 B2 Ready |
| 91 | | Data 3 A3 B3 Data 4 |
| 92 | | - A4 B4 - |
| 93 | | Data 2 A5 B5 Data 5 |
| 94 | | Data 1 A6 B6 Data 6 |
| 95 | | Data 0 A7 B7 Data 7 |
| 96 | | |
| 97 | | CN2A - Joystick 2 connector |
| 98 | | CN1A - Joystick 1 connector |
| 99 | | Pinout is.... |
| 100 | | |
| 101 | | Keyboard J A1 B1 Ground |
| 102 | | Keyboard L A2 B2 Keyboard K |
| 103 | | - A3 B3 - |
| 104 | | Right A4 B4 +5V |
| 105 | | Down A5 B5 Left |
| 106 | | Fire A6 B6 Up |
| 107 | | |
| 108 | | |
| 109 | | Floppy Drive Controller PCB Layout |
| 110 | | ---------------------------------- |
| 111 | | |
| 112 | | INTELLIGENT SOFTWARE LTD DISK CONTROLLER |
| 113 | | ISS1 |
| 114 | | |--------------------------------------------| |
| 115 | | | | |
| 116 | | | | |
| 117 | | |-| 7438 74LS273 WD1770 | |
| 118 | | |I| | |
| 119 | | |D| | |
| 120 | | |C| EPROM.IC2| |
| 121 | | |3| 74LS32 74LS02 74LS266 | |
| 122 | | |4| 7438 | |
| 123 | | |-| 74LS126 74LS10 74LS245 74LS266 | |
| 124 | | | | |
| 125 | | | | |
| 126 | | |----------------------------||||||||||||||||| |
| 127 | | |---------------| |
| 128 | | Notes: (All IC's shown) |
| 129 | | |
| 130 | | This PCB plugs into the external expansion connector on the right side of the mainboard |
| 131 | | |
| 132 | | EPROM.IC2 - 16k x8-bit EPROM labelled 'EXDOS V1.0 P/N 08-60' (DIP28) |
| 133 | | WD1770 - Western Digital WD1770 Floppy Drive Controller (DIP28) |
| 134 | | 74LS02 - Quad 2-Input NOR Gate (DIP14) |
| 135 | | 74LS10 - Triple 3-input NAND Gate (DIP14) |
| 136 | | 74LS32 - Quad 2-Input Positive OR Gate (DIP14) |
| 137 | | 7438 - Quad 2-input NAND Buffer (DIP14) |
| 138 | | 74LS126 - Quad Bus Buffer (DIP14) |
| 139 | | 74LS245 - Octal Bus Tranceiver with Tri-State Outputs (DIP20) |
| 140 | | 74LS266 - Quad EXCLUSIVE-NOR Gate (DIP14) |
| 141 | | 74LS273 - Octal D-Type Flip-Flop With Clear (DIP20) |
| 142 | | IDC34 - IDC 34-way flat cable connector for floppy drive data cable |
| 143 | | |
| 144 | | |
| 145 | | Internal Memory Expansion PCB Layout |
| 146 | | ------------------------------------ |
| 147 | | |
| 148 | | |---------------------| |
| 149 | | | 4164 74LS00 PL3 PL2| |
| 150 | | |4164 74LS30 74F157 | |
| 151 | | |4164 4164 | |
| 152 | | |4164 4164 74F157 | |
| 153 | | |4164 4164 74LS32 PL1| |
| 154 | | |---------------------| |
| 155 | | Notes: (All IC's shown) |
| 156 | | PL1 - 28-pin connector (solder pads only) hard-wired to solder pads EXP1 on mainboard |
| 157 | | PL2/PL3 - 5-pin connectors (solder pads only) hard-wired to solder pads EXP2 on mainboard |
| 158 | | 4164 - 64k x1-bit Dynamic RAM with Page Mode (DIP16) |
| 159 | | 74LS00 - Quad 2-Input NAND Gate (DIP14) |
| 160 | | 74LS30 - 8-input NAND Gate (DIP14) |
| 161 | | 74LS32 - Quad 2-Input Positive OR Gate (DIP14) |
| 162 | | 74F157 - Quad 2-Line to 1-Line Data Selector/Multiplexer (DIP16). Early rev memory boards use 74LS158 instead |
| 163 | | |
| 164 | | */ |
| 165 | | |
| 166 | | /****************************************************************************** |
| 167 | | * Enterprise 128k driver |
| 168 | | * |
| 169 | | * Kevin Thacker 1999. |
| 170 | | * |
| 171 | | * James Boulton [EP help] |
| 172 | | * Jean-Pierre Malisse [EP help] |
| 173 | | * |
| 174 | | * EP Hardware: Z80 (CPU), Dave (Sound Chip + I/O) |
| 175 | | * Nick (Graphics), WD1772 (FDC). 128k ram. |
| 176 | | * |
| 177 | | * For an 8-bit machine, this kicks ass! A sound |
| 178 | | * Chip which is as powerful, or more powerful than |
| 179 | | * the C64 SID, and a graphics chip capable of some |
| 180 | | * really nice graphics. Pity it doesn't have HW sprites! |
| 181 | | ******************************************************************************/ |
| 182 | | |
| 183 | | #include "emu.h" |
| 184 | | #include "cpu/z80/z80.h" |
| 185 | | #include "machine/wd17xx.h" |
| 186 | | #include "imagedev/flopdrv.h" |
| 187 | | #include "formats/basicdsk.h" |
| 188 | | #include "includes/enterp.h" |
| 189 | | |
| 190 | | #define ENTERPRISE_XTAL_X1 XTAL_8MHz |
| 191 | | |
| 192 | | |
| 193 | | /*************************************************************************** |
| 194 | | MEMORY / I/O |
| 195 | | ***************************************************************************/ |
| 196 | | |
| 197 | | void ep_state::enterprise_update_memory_page(address_space &space, offs_t page, int index) |
| 198 | | { |
| 199 | | int start = (page - 1) * 0x4000; |
| 200 | | int end = (page - 1) * 0x4000 + 0x3fff; |
| 201 | | char page_num[10]; |
| 202 | | sprintf(page_num,"bank%d",page); |
| 203 | | |
| 204 | | switch (index) |
| 205 | | { |
| 206 | | case 0x00: |
| 207 | | case 0x01: |
| 208 | | case 0x02: |
| 209 | | case 0x03: |
| 210 | | space.install_read_bank(start, end, page_num); |
| 211 | | space.nop_write(start, end); |
| 212 | | membank(page_num)->set_base(memregion("exos")->base() + (index * 0x4000)); |
| 213 | | break; |
| 214 | | |
| 215 | | case 0x04: |
| 216 | | case 0x05: |
| 217 | | case 0x06: |
| 218 | | case 0x07: |
| 219 | | space.install_read_bank(start, end, page_num); |
| 220 | | space.nop_write(start, end); |
| 221 | | membank(page_num)->set_base(memregion("cartridges")->base() + ((index - 0x04) * 0x4000)); |
| 222 | | break; |
| 223 | | |
| 224 | | case 0x20: |
| 225 | | case 0x21: |
| 226 | | space.install_read_bank(start, end, page_num); |
| 227 | | space.nop_write(start, end); |
| 228 | | membank(page_num)->set_base(memregion("exdos")->base() + ((index - 0x20) * 0x4000)); |
| 229 | | break; |
| 230 | | |
| 231 | | case 0xf8: |
| 232 | | case 0xf9: |
| 233 | | case 0xfa: |
| 234 | | case 0xfb: |
| 235 | | /* additional 64k ram */ |
| 236 | | if (m_ram->size() == 128*1024) |
| 237 | | { |
| 238 | | space.install_readwrite_bank(start, end, page_num); |
| 239 | | membank(page_num)->set_base(m_ram->pointer() + (index - 0xf4) * 0x4000); |
| 240 | | } |
| 241 | | else |
| 242 | | { |
| 243 | | space.unmap_readwrite(start, end); |
| 244 | | } |
| 245 | | break; |
| 246 | | |
| 247 | | case 0xfc: |
| 248 | | case 0xfd: |
| 249 | | case 0xfe: |
| 250 | | case 0xff: |
| 251 | | /* basic 64k ram */ |
| 252 | | space.install_readwrite_bank(start, end, page_num); |
| 253 | | membank(page_num)->set_base(m_ram->pointer() + (index - 0xfc) * 0x4000); |
| 254 | | break; |
| 255 | | |
| 256 | | default: |
| 257 | | space.unmap_readwrite(start, end); |
| 258 | | } |
| 259 | | } |
| 260 | | |
| 261 | | |
| 262 | | /* EP specific handling of dave register write */ |
| 263 | | WRITE8_MEMBER(ep_state::enterprise_dave_reg_write) |
| 264 | | { |
| 265 | | switch (offset) |
| 266 | | { |
| 267 | | case 0x10: |
| 268 | | case 0x11: |
| 269 | | case 0x12: |
| 270 | | case 0x13: |
| 271 | | enterprise_update_memory_page(m_maincpu->space(AS_PROGRAM), offset - 0x0f, data); |
| 272 | | break; |
| 273 | | |
| 274 | | case 0x15: |
| 275 | | keyboard_line = data & 15; |
| 276 | | break; |
| 277 | | } |
| 278 | | } |
| 279 | | |
| 280 | | |
| 281 | | READ8_MEMBER(ep_state::enterprise_dave_reg_read) |
| 282 | | { |
| 283 | | switch (offset) |
| 284 | | { |
| 285 | | case 0x015: |
| 286 | | /* read keyboard line */ |
| 287 | | m_dave->set_reg(0x015, m_key[keyboard_line]->read()); |
| 288 | | break; |
| 289 | | |
| 290 | | case 0x016: |
| 291 | | { |
| 292 | | int ExternalJoystickInputs; |
| 293 | | int ExternalJoystickPortInput = m_joy->read(); |
| 294 | | |
| 295 | | if (keyboard_line <= 4) |
| 296 | | { |
| 297 | | ExternalJoystickInputs = ExternalJoystickPortInput>>(4-(keyboard_line)); |
| 298 | | } |
| 299 | | else |
| 300 | | { |
| 301 | | ExternalJoystickInputs = 1; |
| 302 | | } |
| 303 | | |
| 304 | | m_dave->set_reg(0x016, (0x0fe | (ExternalJoystickInputs & 0x01))); |
| 305 | | } |
| 306 | | break; |
| 307 | | |
| 308 | | default: |
| 309 | | break; |
| 310 | | } |
| 311 | | return 0; |
| 312 | | } |
| 313 | | |
| 314 | | /* enterprise interface to dave - ok, so Dave chip is unique |
| 315 | | to Enterprise. But these functions make it nice and easy to see |
| 316 | | whats going on. */ |
| 317 | | static const dave_interface enterprise_dave_interface = |
| 318 | | { |
| 319 | | DEVCB_DRIVER_MEMBER(ep_state,enterprise_dave_reg_read), |
| 320 | | DEVCB_DRIVER_MEMBER(ep_state,enterprise_dave_reg_write), |
| 321 | | DEVCB_CPU_INPUT_LINE("maincpu", 0) |
| 322 | | }; |
| 323 | | |
| 324 | | |
| 325 | | void ep_state::machine_start() |
| 326 | | { |
| 327 | | m_maincpu->set_input_line_vector(0, 0xff); |
| 328 | | m_nick->set_vram(m_ram->pointer()); |
| 329 | | |
| 330 | | for (int i = 0; i < 10; i++) |
| 331 | | { |
| 332 | | char str[6]; |
| 333 | | sprintf(str, "LINE%i", i); |
| 334 | | m_key[i] = ioport(str); |
| 335 | | } |
| 336 | | } |
| 337 | | |
| 338 | | void ep_state::machine_reset() |
| 339 | | { |
| 340 | | m_maincpu->set_input_line_vector(0, 0xff); |
| 341 | | } |
| 342 | | |
| 343 | | |
| 344 | | UINT32 ep_state::screen_update_enterp(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect) |
| 345 | | { |
| 346 | | m_nick->screen_update_epnick(screen, bitmap, cliprect); |
| 347 | | return 0; |
| 348 | | } |
| 349 | | |
| 350 | | // FIXME: Should this be here or in the Nick device?!? |
| 351 | | |
| 352 | | /* Enterprise has 256 colours, all may be on the screen at once! |
| 353 | | the NICK_GET_RED8, NICK_GET_GREEN8, NICK_GET_BLUE8 macros |
| 354 | | return a 8-bit colour value for the index specified. */ |
| 355 | | |
| 356 | | /* given a colour index in range 0..255 gives the Red component */ |
| 357 | | #define NICK_GET_RED8(x) \ |
| 358 | | (( \ |
| 359 | | (BIT(x, 0) << 2) | \ |
| 360 | | (BIT(x, 3) << 1) | \ |
| 361 | | (BIT(x, 6) << 0) \ |
| 362 | | ) << 5) |
| 363 | | |
| 364 | | /* given a colour index in range 0..255 gives the Red component */ |
| 365 | | #define NICK_GET_GREEN8(x) \ |
| 366 | | (( \ |
| 367 | | (BIT(x, 1) << 2) | \ |
| 368 | | (BIT(x, 4) << 1) | \ |
| 369 | | (BIT(x, 7) << 0) \ |
| 370 | | ) << 5) |
| 371 | | |
| 372 | | /* given a colour index in range 0..255 gives the Red component */ |
| 373 | | #define NICK_GET_BLUE8(x) \ |
| 374 | | (( \ |
| 375 | | (BIT(x, 2) << 1) | \ |
| 376 | | (BIT(x, 5) << 0) \ |
| 377 | | ) << 6) |
| 378 | | |
| 379 | | |
| 380 | | /* initial the palette */ |
| 381 | | void ep_state::palette_init() |
| 382 | | { |
| 383 | | for (int i = 0; i < 256; i++) |
| 384 | | palette_set_color_rgb(machine(), i, NICK_GET_RED8(i), NICK_GET_GREEN8(i), NICK_GET_BLUE8(i)); |
| 385 | | } |
| 386 | | |
| 387 | | |
| 388 | | /*************************************************************************** |
| 389 | | FLOPPY/EXDOS |
| 390 | | ***************************************************************************/ |
| 391 | | |
| 392 | | WRITE_LINE_MEMBER(ep_state::enterp_wd1770_intrq_w) |
| 393 | | { |
| 394 | | if (state) |
| 395 | | exdos_card_value |= 0x02; |
| 396 | | else |
| 397 | | exdos_card_value &= ~0x02; |
| 398 | | } |
| 399 | | |
| 400 | | WRITE_LINE_MEMBER(ep_state::enterp_wd1770_drq_w) |
| 401 | | { |
| 402 | | if (state) |
| 403 | | exdos_card_value |= 0x80; |
| 404 | | else |
| 405 | | exdos_card_value &= ~0x80; |
| 406 | | } |
| 407 | | |
| 408 | | |
| 409 | | /* bit 0 - ?? |
| 410 | | bit 1 - IRQ from WD1770 |
| 411 | | bit 2 - ?? |
| 412 | | bit 3 - ?? |
| 413 | | bit 4 - ?? |
| 414 | | bit 5 - ?? |
| 415 | | bit 6 - Disk change signal from disk drive |
| 416 | | bit 7 - DRQ from WD1770 |
| 417 | | */ |
| 418 | | READ8_MEMBER(ep_state::exdos_card_r) |
| 419 | | { |
| 420 | | return exdos_card_value; |
| 421 | | } |
| 422 | | |
| 423 | | |
| 424 | | /* bit 0 - select drive 0, |
| 425 | | bit 1 - select drive 1, |
| 426 | | bit 2 - select drive 2, |
| 427 | | bit 3 - select drive 3 |
| 428 | | bit 4 - side |
| 429 | | bit 5 - mfm/fm select |
| 430 | | bit 6 - disk change reset |
| 431 | | bit 7 - in use |
| 432 | | */ |
| 433 | | WRITE8_MEMBER(ep_state::exdos_card_w) |
| 434 | | { |
| 435 | | device_t *fdc = machine().device("wd1770"); |
| 436 | | |
| 437 | | /* drive */ |
| 438 | | if (BIT(data, 0)) wd17xx_set_drive(fdc, 0); |
| 439 | | if (BIT(data, 1)) wd17xx_set_drive(fdc, 1); |
| 440 | | if (BIT(data, 2)) wd17xx_set_drive(fdc, 2); |
| 441 | | if (BIT(data, 3)) wd17xx_set_drive(fdc, 3); |
| 442 | | |
| 443 | | wd17xx_set_side(fdc, BIT(data, 4)); |
| 444 | | wd17xx_dden_w(fdc, BIT(data, 5)); |
| 445 | | } |
| 446 | | |
| 447 | | /*************************************************************************** |
| 448 | | ADDRESS MAPS |
| 449 | | ***************************************************************************/ |
| 450 | | |
| 451 | | static ADDRESS_MAP_START( enterprise_mem, AS_PROGRAM, 8, ep_state ) |
| 452 | | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK("bank1") |
| 453 | | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK("bank2") |
| 454 | | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK("bank3") |
| 455 | | AM_RANGE(0xc000, 0xffff) AM_RAMBANK("bank4") |
| 456 | | ADDRESS_MAP_END |
| 457 | | |
| 458 | | |
| 459 | | static ADDRESS_MAP_START( enterprise_io, AS_IO, 8, ep_state ) |
| 460 | | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 461 | | AM_RANGE(0x10, 0x13) AM_MIRROR(0x04) AM_DEVREADWRITE_LEGACY("wd1770", wd17xx_r, wd17xx_w) |
| 462 | | AM_RANGE(0x18, 0x18) AM_MIRROR(0x04) AM_READWRITE(exdos_card_r, exdos_card_w) |
| 463 | | AM_RANGE(0x80, 0x8f) AM_DEVWRITE("nick", nick_device, reg_w) |
| 464 | | AM_RANGE(0xa0, 0xbf) AM_DEVREADWRITE("custom", dave_sound_device, reg_r, reg_w) |
| 465 | | ADDRESS_MAP_END |
| 466 | | |
| 467 | | |
| 468 | | /*************************************************************************** |
| 469 | | INPUT PORTS |
| 470 | | ***************************************************************************/ |
| 471 | | |
| 472 | | /* |
| 473 | | Enterprise Keyboard Matrix |
| 474 | | |
| 475 | | Bit |
| 476 | | Line 0 1 2 3 4 5 6 7 |
| 477 | | 0 n \ b c v x z SHFT |
| 478 | | 1 h N/C g d f s a CTRL |
| 479 | | 2 u q y r t e w TAB |
| 480 | | 3 7 1 6 4 5 3 2 N/C |
| 481 | | 4 F4 F8 F3 F6 F5 F7 F2 F1 |
| 482 | | 5 8 N/C 9 - 0 ^ DEL N/C |
| 483 | | 6 j N/C k ; l : ] N/C |
| 484 | | 7 STOP DOWN RGHT UP HOLD LEFT RETN ALT |
| 485 | | 8 m ERSE , / . SHFT SPCE INS |
| 486 | | 9 i N/C o @ p [ N/C N/C |
| 487 | | |
| 488 | | N/C - Not connected or just dont know! |
| 489 | | |
| 490 | | 2008-05 FP: |
| 491 | | Notice that I updated the matrix above with the following new info: |
| 492 | | l1:b1 is LOCK: you press it with CTRL to switch to Caps, you press it again to switch back |
| 493 | | (you can also use it with ALT) |
| 494 | | l3:b7 is ESC: you use it to exit from nested programs (e.g. if you start to write a program in BASIC, |
| 495 | | then start EXDOS, you can use ESC to go back to BASIC without losing the program you were writing) |
| 496 | | |
| 497 | | According to pictures and manuals, there seem to be no more keys connected, so I label the remaining N/C |
| 498 | | as IPT_UNUSED. |
| 499 | | |
| 500 | | Small note about natural keyboard support: currently |
| 501 | | - "Lock" is mapped to 'F9' (it acts like a CAPSLOCK, but no IPT_TOGGLE) |
| 502 | | - "Stop" is mapped to 'F10' |
| 503 | | - "Hold" is mapped to 'F11' |
| 504 | | */ |
| 505 | | |
| 506 | | |
| 507 | | static INPUT_PORTS_START( ep64 ) |
| 508 | | PORT_START("LINE0") /* keyboard line 0 */ |
| 509 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 510 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('\\') PORT_CHAR('|') |
| 511 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 512 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 513 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 514 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') |
| 515 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 516 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 517 | | |
| 518 | | PORT_START("LINE1") /* keyboard line 1 */ |
| 519 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') |
| 520 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LOCK") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 521 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') |
| 522 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 523 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') |
| 524 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 525 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 526 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 527 | | |
| 528 | | PORT_START("LINE2") /* keyboard line 2 */ |
| 529 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 530 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') |
| 531 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 532 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') |
| 533 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') |
| 534 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 535 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') |
| 536 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') |
| 537 | | |
| 538 | | PORT_START("LINE3") /* keyboard line 3 */ |
| 539 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 540 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 541 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 542 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 543 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 544 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3 \xC2\xA3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('\xA3') |
| 545 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 546 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 547 | | |
| 548 | | PORT_START("LINE4") /* keyboard line 4 */ |
| 549 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 550 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 551 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 552 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 553 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 554 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 555 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 556 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 557 | | |
| 558 | | PORT_START("LINE5") /* keyboard line 5 */ |
| 559 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 560 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) |
| 561 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 562 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') |
| 563 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('_') |
| 564 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') PORT_CHAR('~') |
| 565 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ERASE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 566 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 567 | | |
| 568 | | PORT_START("LINE6") /* keyboard line 6 */ |
| 569 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 570 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) |
| 571 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 572 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') |
| 573 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') |
| 574 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') |
| 575 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']') PORT_CHAR('}') |
| 576 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 577 | | |
| 578 | | /* Notice that, in fact, ep128 only had the built-in joystick and no cursor arrow keys on the keyboard */ |
| 579 | | PORT_START("LINE7") /* keyboard line 7 */ |
| 580 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("STOP") PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 581 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 582 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 583 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 584 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("HOLD") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(F11)) |
| 585 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 586 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 587 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ALT") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) |
| 588 | | |
| 589 | | PORT_START("LINE8") /* keyboard line 8 */ |
| 590 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 591 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) |
| 592 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 593 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 594 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 595 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT (right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 596 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 597 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 598 | | |
| 599 | | PORT_START("LINE9") /* keyboard line 9 */ |
| 600 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 601 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) |
| 602 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 603 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') PORT_CHAR('`') |
| 604 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 605 | | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('[') PORT_CHAR('{') |
| 606 | | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) |
| 607 | | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 608 | | |
| 609 | | PORT_START("JOY1") /* external joystick 1 */ |
| 610 | | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXTERNAL JOYSTICK 1 RIGHT") PORT_CODE(KEYCODE_RIGHT) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) |
| 611 | | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXTERNAL JOYSTICK 1 LEFT") PORT_CODE(KEYCODE_LEFT) PORT_CODE(JOYCODE_X_LEFT_SWITCH) |
| 612 | | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXTERNAL JOYSTICK 1 DOWN") PORT_CODE(KEYCODE_DOWN) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) |
| 613 | | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXTERNAL JOYSTICK 1 UP") PORT_CODE(KEYCODE_UP) PORT_CODE(JOYCODE_Y_UP_SWITCH) |
| 614 | | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("EXTERNAL JOYSTICK 1 FIRE") PORT_CODE(KEYCODE_SPACE) PORT_CODE(JOYCODE_BUTTON1) |
| 615 | | INPUT_PORTS_END |
| 616 | | |
| 617 | | |
| 618 | | /*************************************************************************** |
| 619 | | MACHINE DRIVERS |
| 620 | | ***************************************************************************/ |
| 621 | | |
| 622 | | static const wd17xx_interface enterp_wd1770_interface = |
| 623 | | { |
| 624 | | DEVCB_NULL, |
| 625 | | DEVCB_DRIVER_LINE_MEMBER(ep_state,enterp_wd1770_intrq_w), |
| 626 | | DEVCB_DRIVER_LINE_MEMBER(ep_state,enterp_wd1770_drq_w), |
| 627 | | {FLOPPY_0, FLOPPY_1, FLOPPY_2, FLOPPY_3} |
| 628 | | }; |
| 629 | | |
| 630 | | static LEGACY_FLOPPY_OPTIONS_START(enterprise) |
| 631 | | LEGACY_FLOPPY_OPTION(enterprise, "dsk,img", "Enterprise disk image", basicdsk_identify_default, basicdsk_construct_default, NULL, |
| 632 | | HEADS([2]) |
| 633 | | TRACKS([80]) |
| 634 | | SECTORS([9]) |
| 635 | | SECTOR_LENGTH([512]) |
| 636 | | FIRST_SECTOR_ID([1])) |
| 637 | | LEGACY_FLOPPY_OPTIONS_END |
| 638 | | |
| 639 | | static const floppy_interface enterprise_floppy_interface = |
| 640 | | { |
| 641 | | DEVCB_NULL, |
| 642 | | DEVCB_NULL, |
| 643 | | DEVCB_NULL, |
| 644 | | DEVCB_NULL, |
| 645 | | DEVCB_NULL, |
| 646 | | FLOPPY_STANDARD_3_5_DSDD, |
| 647 | | LEGACY_FLOPPY_OPTIONS_NAME(enterprise), |
| 648 | | "floppy_3_5", |
| 649 | | NULL |
| 650 | | }; |
| 651 | | |
| 652 | | static MACHINE_CONFIG_START( ep64, ep_state ) |
| 653 | | /* basic machine hardware */ |
| 654 | | MCFG_CPU_ADD("maincpu", Z80, ENTERPRISE_XTAL_X1/2) /* 4 MHz, generated by DAVE */ |
| 655 | | MCFG_CPU_PROGRAM_MAP(enterprise_mem) |
| 656 | | MCFG_CPU_IO_MAP(enterprise_io) |
| 657 | | |
| 658 | | /* video hardware */ |
| 659 | | MCFG_SCREEN_ADD("screen", RASTER) |
| 660 | | MCFG_SCREEN_REFRESH_RATE(50) |
| 661 | | MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 662 | | MCFG_SCREEN_SIZE(ENTERPRISE_SCREEN_WIDTH, ENTERPRISE_SCREEN_HEIGHT) |
| 663 | | MCFG_SCREEN_VISIBLE_AREA(0, ENTERPRISE_SCREEN_WIDTH-1, 0, ENTERPRISE_SCREEN_HEIGHT-1) |
| 664 | | MCFG_SCREEN_UPDATE_DRIVER(ep_state, screen_update_enterp) |
| 665 | | |
| 666 | | MCFG_PALETTE_LENGTH(NICK_PALETTE_SIZE) |
| 667 | | |
| 668 | | MCFG_NICK_ADD("nick") |
| 669 | | |
| 670 | | /* sound hardware */ |
| 671 | | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 672 | | MCFG_SOUND_ADD("custom", DAVE, 0) |
| 673 | | MCFG_DEVICE_CONFIG( enterprise_dave_interface ) |
| 674 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 675 | | |
| 676 | | MCFG_WD1770_ADD("wd1770", enterp_wd1770_interface ) |
| 677 | | |
| 678 | | MCFG_LEGACY_FLOPPY_4_DRIVES_ADD(enterprise_floppy_interface) |
| 679 | | |
| 680 | | /* internal ram */ |
| 681 | | MCFG_RAM_ADD(RAM_TAG) |
| 682 | | MCFG_RAM_DEFAULT_SIZE("64K") |
| 683 | | |
| 684 | | // software list |
| 685 | | MCFG_SOFTWARE_LIST_ADD("cass_list", "ep64_cass") |
| 686 | | MCFG_SOFTWARE_LIST_ADD("flop_list", "ep64_flop") |
| 687 | | MACHINE_CONFIG_END |
| 688 | | |
| 689 | | static MACHINE_CONFIG_DERIVED( ep128, ep64 ) |
| 690 | | /* internal ram */ |
| 691 | | MCFG_RAM_MODIFY(RAM_TAG) |
| 692 | | MCFG_RAM_DEFAULT_SIZE("128K") |
| 693 | | MACHINE_CONFIG_END |
| 694 | | |
| 695 | | |
| 696 | | /*************************************************************************** |
| 697 | | ROM DEFINITIONS |
| 698 | | ***************************************************************************/ |
| 699 | | |
| 700 | | ROM_START( ep64 ) |
| 701 | | ROM_REGION(0x8000, "exos", 0) |
| 702 | | ROM_LOAD("9256ds-0038_enter05-23-a.u2", 0x0000, 0x8000, CRC(d421795f) SHA1(6033a0535136c40c47137e4d1cd9273c06d5fdff)) |
| 703 | | |
| 704 | | /* 4 cartridge slots */ |
| 705 | | ROM_REGION(0x10000, "cartridges", 0) |
| 706 | | ROM_LOAD("basic20.rom", 0x0000, 0x4000, CRC(d62e4fb7) SHA1(36e12c4ea782ca769225178f61b55bc9a9afb927)) |
| 707 | | ROM_FILL(0x4000, 0xc000, 0xff) |
| 708 | | |
| 709 | | ROM_REGION(0x8000, "exdos", 0) |
| 710 | | ROM_LOAD("exdos13.rom", 0x0000, 0x8000, CRC(d1d7e157) SHA1(31c8be089526aa8aa019c380cdf51ddd3ee76454)) |
| 711 | | ROM_END |
| 712 | | |
| 713 | | ROM_START( ep128 ) |
| 714 | | ROM_REGION(0x10000, "exos", 0) |
| 715 | | ROM_SYSTEM_BIOS(0, "exos21", "EXOS 2.1") |
| 716 | | ROMX_LOAD("9256ds-0019_enter08-45-a.u2", 0x0000, 0x8000, CRC(982a3b44) SHA1(55315b20fecb4441a07ee4bc5dc7153f396e0a2e), ROM_BIOS(1)) |
| 717 | | ROM_FILL(0x8000, 0x8000, 0xff) |
| 718 | | ROM_SYSTEM_BIOS(1, "exos22", "EXOS 2.2 (unofficial)") |
| 719 | | ROMX_LOAD("exos22.rom", 0x0000, 0x10000, CRC(c82e699f) SHA1(40cda9573e0c20e6287d27105759e23b9025fa52), ROM_BIOS(2)) |
| 720 | | ROM_SYSTEM_BIOS(2, "exos23", "EXOS 2.3 (unofficial)") |
| 721 | | ROMX_LOAD("exos23.rom", 0x0000, 0x10000, CRC(24838410) SHA1(c6241e1c248193108ce38b9a8e9dd33972cf47ba), ROM_BIOS(3)) |
| 722 | | ROM_SYSTEM_BIOS(3, "exos231", "EXOS 2.31 (unofficial)") |
| 723 | | ROMX_LOAD("exos231.rom", 0x0000, 0x10000, CRC(d0ecee0d) SHA1(bd0ff3c46f57c88b82b71b0d94a8bda18ea9bafe), ROM_BIOS(4)) |
| 724 | | |
| 725 | | /* 4 cartridge slots */ |
| 726 | | ROM_REGION(0x10000, "cartridges", 0) |
| 727 | | ROM_LOAD("9128ds-0237_enter08-46-a.u1", 0x0000, 0x4000, CRC(683cf455) SHA1(50a548d1df3ea86f9b5fa669afd8ff124050e776)) /* BASIC V2.1 */ |
| 728 | | ROM_FILL(0x4000, 0xc000, 0xff) |
| 729 | | |
| 730 | | ROM_REGION(0x8000, "exdos", 0) |
| 731 | | ROM_LOAD("exdos13.rom", 0x0000, 0x8000, CRC(d1d7e157) SHA1(31c8be089526aa8aa019c380cdf51ddd3ee76454)) |
| 732 | | ROM_END |
| 733 | | |
| 734 | | ROM_START( phc64 ) |
| 735 | | ROM_REGION(0x8000, "exos", 0) |
| 736 | | ROM_LOAD("9256ds-0038_enter05-23-a.u2", 0x0000, 0x8000, CRC(d421795f) SHA1(6033a0535136c40c47137e4d1cd9273c06d5fdff)) |
| 737 | | |
| 738 | | /* 4 cartridge slots */ |
| 739 | | ROM_REGION(0x10000, "cartridges", 0) |
| 740 | | ROM_LOAD("basic20.rom", 0x0000, 0x4000, CRC(d62e4fb7) SHA1(36e12c4ea782ca769225178f61b55bc9a9afb927)) |
| 741 | | ROM_LOAD("brd.rom", 0x4000, 0x4000, CRC(f45a7454) SHA1(096c91fad6a4d10323cd67e133b3ebc5c50e2bb2)) |
| 742 | | ROM_FILL(0x8000, 0x8000, 0xff) |
| 743 | | |
| 744 | | ROM_REGION(0x8000, "exdos", 0) |
| 745 | | ROM_LOAD("exdos13.rom", 0x0000, 0x8000, CRC(d1d7e157) SHA1(31c8be089526aa8aa019c380cdf51ddd3ee76454)) |
| 746 | | ROM_END |
| 747 | | |
| 748 | | /*************************************************************************** |
| 749 | | GAME DRIVERS |
| 750 | | ***************************************************************************/ |
| 751 | | |
| 752 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME */ |
| 753 | | COMP( 1985, ep64, 0, 0, ep64, ep64, driver_device, 0, "Enterprise Computers", "Enterprise Sixty Four", GAME_IMPERFECT_SOUND ) |
| 754 | | COMP( 1985, ep128, ep64, 0, ep128, ep64, driver_device, 0, "Enterprise Computers", "Enterprise One Two Eight", GAME_IMPERFECT_SOUND ) |
| 755 | | COMP( 1985, phc64, ep64, 0, ep64, ep64, driver_device, 0, "Hegener & Glaser", "Mephisto PHC 64", GAME_IMPERFECT_SOUND ) |
| | No newline at end of file |
trunk/src/mess/drivers/ep64.c
| r0 | r23494 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | Enterprise Sixty Four / One Two Eight emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | Enterprise Sixty Four / Enterprise One Two Eight |
| 13 | Enterprise Computers Ltd. 1985 |
| 14 | |
| 15 | MAIN PCB Layout |
| 16 | --------------- |
| 17 | DUAL |
| 18 | |-----------| 9V TAPE_IN/OUT RES |
| 19 | |HEATSINK | DC_IN MON1 AND REMOTE SR1 PR1 CN2A CN1A |-| |
| 20 | | |--||---|--||--|--| |--| |-||-||-||-||-| |----| |-----| |--| |--| |-|-|------| |
| 21 | |-----------|7805 | MOD | |-| |-| |-| |-| |-| |-| |-| EXP2 --|EXTERNAL |
| 22 | |---+7805 | | 74LS06 74LS273 74LS86 74LS32 --|EXPANSION |
| 23 | | | |------| 74LS244 --|CONNECTOR |
| 24 | | |78L12 POT1 LM386 |-----| |-----| EXP1 --| |
| 25 | CART | | LM1889 LM1886 74LS04|NICK | |DAVE | --| |
| 26 | CONN | | KEYB_8 POT2 KEYB_10 | | | | --| |
| 27 | | | 4.433619MHz 74LS145 POT3 LED |-----| |-----| --| |
| 28 | |---+ --| |
| 29 | | 74LS74 74LS244 74LS244 74LS245 |---------| |
| 30 | | | |
| 31 | | 74LS373 4164 4164 74F157 | |
| 32 | | | |
| 33 | | 16-2-103 LM339 LM324 4164 4164 74F157 EXOS.IC2 | |
| 34 | | 8MHz | |
| 35 | | 74LS373 4164 4164 | |
| 36 | | 74LS04 Z80A | |
| 37 | | 74LS273 4164 4164 | |
| 38 | |------------------------------------------------------------------| |
| 39 | Notes: (all IC's shown) |
| 40 | Z80A - Z80A CPU, clock input 4MHz [8/2] |
| 41 | EXOS.IC2 - 32k x8-bit mask ROM usually 23256 manufactured by GI (DIP24). Contains EXOS operating |
| 42 | system and built-in word processor software. A few official revisions were made and |
| 43 | there were a few unofficial revision made with additional capabilities and bug-fixes |
| 44 | ROM labelling of some official versions found.... |
| 45 | 9256DS-0019 (C)1984 INTELLIGENT SOFTWARE LTD ENTER 08-45-A GI |
| 46 | 9256DS-0036 (C)1984 INTELLIGENT SOFTWARE LTD ENTER 05-23-A GI |
| 47 | 4164 - 64k x1-bit Dynamic RAM with Page Mode (DIP16) |
| 48 | NICK - Custom graphics chip (QFP72) |
| 49 | DAVE - Custom sound chip (QFP72) |
| 50 | LM386 - National Semiconductor LM386 Low Voltage Audio Power Amplifier (DIP8) |
| 51 | LM1889 - National Semiconductor LM1889 TV Video Modulator (DIP18) |
| 52 | LM1886 - National Semiconductor LM1886 TV Video Matrix DAC (DIP20) |
| 53 | LM339 - SGS LM339 Low Power Low Offset Voltage Quad Comparator (DIP8) |
| 54 | LM324 - SGS LM324 Quad Operational Amplifier (DIP8) |
| 55 | 74LS04 - Hex Inverter (DIP14) |
| 56 | 74LS06 - Hex Inverter/Buffer with Open-Collector Outputs (DIP14) |
| 57 | 74LS32 - Quad 2-Input Positive OR Gate (DIP14) |
| 58 | 74LS74 - Dual Positive-Edge-Triggered D Flip-Flops with Preset, Clear and Complementary Outputs (DIP14) |
| 59 | 74LS86 - Quad 2-Input Exclusive OR Gate (DIP14) |
| 60 | 74LS145 - BCD to Deccimal Decoder/Driver (DIP16) |
| 61 | 74F157 - Quad 2-Line to 1-Line Data Selector/Multiplexer (DIP16). Early rev mainboards use 74LS158 instead |
| 62 | 74LS244 - Octal 3-State Noninverting Buffer/Line Driver/Line Receiver (DIP20) |
| 63 | 74LS245 - Octal Bus Tranceiver with Tri-State Outputs (DIP20) |
| 64 | 74LS273 - Octal D-Type Flip-Flop With Clear (DIP20) |
| 65 | 74LS373 - Octal D-Type Transparent Latches and Edge-Triggered Flip-Flops (DIP20) |
| 66 | 7805 - Voltage regulator. +9V DC input from DC power pack, +5V DC output |
| 67 | 78L12 - Voltage regulator. Voltage input via small transformer on PCB. +12V DC output |
| 68 | POT1 - Potentiometer located near modulator and video output circuitry |
| 69 | POT2 - Potentiometer located near video output circuitry. Probably used to fine-tune the video clock |
| 70 | POT3 - Potentiometer. Possibly for video/NICK-related adjustments |
| 71 | LED - LED to show +5V is present |
| 72 | 16-2-103 - Resistor Array (DIP16) |
| 73 | KEYB_8 - 8 pin keyboard connector |
| 74 | KEYB_10 - 10 pin keyboard connector |
| 75 | EXP1 - 28 pin internal expansion connector (solder holes only) used for internal 64k memory expansion card |
| 76 | EXP2 - 10 pin internal expansion connector (solder holes only) used for internal 64k memory expansion card |
| 77 | MOD - Astec UM1233 TV modulator |
| 78 | RES - Reset push button switch |
| 79 | MON1 - Monitor output connector. Pinout is.... |
| 80 | |
| 81 | Green A1 B1 NC |
| 82 | Ground A2 B2 Ground |
| 83 | Mono Comp. Video A3 B3 Blue |
| 84 | HSync A4 B4 Red |
| 85 | VSync A5 B5 Composite Sync |
| 86 | NC A6 B6 Mode Switch |
| 87 | Left Audio A7 B7 Right Audio |
| 88 | |
| 89 | SR1 - Serial/Network connector. Pinout is.... |
| 90 | |
| 91 | Reference A1 B1 Ground |
| 92 | - A2 B2 - |
| 93 | RTS A3 B3 Data Out |
| 94 | CTS A4 B4 Data In |
| 95 | |
| 96 | PR1 - Printer connector. Pinout is.... |
| 97 | |
| 98 | Ground A1 B1 Ground |
| 99 | Strobe A2 B2 Ready |
| 100 | Data 3 A3 B3 Data 4 |
| 101 | - A4 B4 - |
| 102 | Data 2 A5 B5 Data 5 |
| 103 | Data 1 A6 B6 Data 6 |
| 104 | Data 0 A7 B7 Data 7 |
| 105 | |
| 106 | CN2A - Joystick 2 connector |
| 107 | CN1A - Joystick 1 connector |
| 108 | Pinout is.... |
| 109 | |
| 110 | Keyboard J A1 B1 Ground |
| 111 | Keyboard L A2 B2 Keyboard K |
| 112 | - A3 B3 - |
| 113 | Right A4 B4 +5V |
| 114 | Down A5 B5 Left |
| 115 | Fire A6 B6 Up |
| 116 | |
| 117 | |
| 118 | Internal Memory Expansion PCB Layout |
| 119 | ------------------------------------ |
| 120 | |
| 121 | |---------------------| |
| 122 | | 4164 74LS00 PL3 PL2| |
| 123 | |4164 74LS30 74F157 | |
| 124 | |4164 4164 | |
| 125 | |4164 4164 74F157 | |
| 126 | |4164 4164 74LS32 PL1| |
| 127 | |---------------------| |
| 128 | Notes: (All IC's shown) |
| 129 | PL1 - 28-pin connector (solder pads only) hard-wired to solder pads EXP1 on mainboard |
| 130 | PL2/PL3 - 5-pin connectors (solder pads only) hard-wired to solder pads EXP2 on mainboard |
| 131 | 4164 - 64k x1-bit Dynamic RAM with Page Mode (DIP16) |
| 132 | 74LS00 - Quad 2-Input NAND Gate (DIP14) |
| 133 | 74LS30 - 8-input NAND Gate (DIP14) |
| 134 | 74LS32 - Quad 2-Input Positive OR Gate (DIP14) |
| 135 | 74F157 - Quad 2-Line to 1-Line Data Selector/Multiplexer (DIP16). Early rev memory boards use 74LS158 instead |
| 136 | |
| 137 | */ |
| 138 | |
| 139 | /* |
| 140 | |
| 141 | TODO: |
| 142 | |
| 143 | - POST RAM errors |
| 144 | - rewrite DAVE to output to discrete DAC |
| 145 | - rewrite NICK |
| 146 | - cassette |
| 147 | - external joysticks |
| 148 | |
| 149 | http://ep.homeserver.hu/Dokumentacio/Konyvek/ |
| 150 | |
| 151 | */ |
| 152 | |
| 153 | #include "includes/ep64.h" |
| 154 | |
| 155 | |
| 156 | |
| 157 | //************************************************************************** |
| 158 | // READ/WRITE HANDLERS |
| 159 | //************************************************************************** |
| 160 | |
| 161 | //------------------------------------------------- |
| 162 | // rd0_r - |
| 163 | //------------------------------------------------- |
| 164 | |
| 165 | READ8_MEMBER( ep64_state::rd0_r ) |
| 166 | { |
| 167 | UINT8 data = 0xff; |
| 168 | |
| 169 | switch (m_key) |
| 170 | { |
| 171 | case 0: data &= m_y0->read(); break; |
| 172 | case 1: data &= m_y1->read(); break; |
| 173 | case 2: data &= m_y2->read(); break; |
| 174 | case 3: data &= m_y3->read(); break; |
| 175 | case 4: data &= m_y4->read(); break; |
| 176 | case 5: data &= m_y5->read(); break; |
| 177 | case 6: data &= m_y6->read(); break; |
| 178 | case 7: data &= m_y7->read(); break; |
| 179 | case 8: data &= m_y8->read(); break; |
| 180 | case 9: data &= m_y9->read(); break; |
| 181 | } |
| 182 | |
| 183 | return data; |
| 184 | } |
| 185 | |
| 186 | |
| 187 | //------------------------------------------------- |
| 188 | // rd0_r - |
| 189 | //------------------------------------------------- |
| 190 | |
| 191 | WRITE8_MEMBER( ep64_state::wr0_w ) |
| 192 | { |
| 193 | /* |
| 194 | |
| 195 | bit description |
| 196 | |
| 197 | 0 KEY A |
| 198 | 1 KEY B |
| 199 | 2 KEY C |
| 200 | 3 KEY D |
| 201 | 4 PRINTER _STB |
| 202 | 5 CASSETTE OUT |
| 203 | 6 REMOTE 1 |
| 204 | 7 REMOTE 2 |
| 205 | |
| 206 | */ |
| 207 | |
| 208 | // keyboard |
| 209 | m_key = data & 0x0f; |
| 210 | |
| 211 | // printer |
| 212 | m_centronics->strobe_w(!BIT(data, 4)); |
| 213 | |
| 214 | // cassette |
| 215 | m_cassette1->output(BIT(data, 5) ? -1.0 : +1.0); |
| 216 | m_cassette2->output(BIT(data, 5) ? -1.0 : +1.0); |
| 217 | |
| 218 | // cassette |
| 219 | m_cassette1->change_state(BIT(data, 6) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 220 | m_cassette2->change_state(BIT(data, 7) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 221 | } |
| 222 | |
| 223 | |
| 224 | //------------------------------------------------- |
| 225 | // rd1_r - |
| 226 | //------------------------------------------------- |
| 227 | |
| 228 | READ8_MEMBER( ep64_state::rd1_r ) |
| 229 | { |
| 230 | /* |
| 231 | |
| 232 | bit description |
| 233 | |
| 234 | 0 KBJ |
| 235 | 1 KBK |
| 236 | 2 KBL |
| 237 | 3 PRINTER _RDY |
| 238 | 4 SERIAL/NET DATA IN |
| 239 | 5 SERIAL/NET STATUS IN |
| 240 | 6 CASSETTE IN |
| 241 | 7 ? |
| 242 | |
| 243 | */ |
| 244 | |
| 245 | UINT8 data = 0; |
| 246 | |
| 247 | // printer |
| 248 | data |= m_centronics->not_busy_r() << 3; |
| 249 | |
| 250 | // serial |
| 251 | data |= m_rs232->rx() << 4; |
| 252 | data |= m_rs232->cts_r() << 5; |
| 253 | |
| 254 | // cassette |
| 255 | data |= ((m_cassette1->input() < 0) || (m_cassette2->input() < 0)) << 6; |
| 256 | |
| 257 | return data; |
| 258 | } |
| 259 | |
| 260 | |
| 261 | //------------------------------------------------- |
| 262 | // wr2_w - |
| 263 | //------------------------------------------------- |
| 264 | |
| 265 | WRITE8_MEMBER( ep64_state::wr2_w ) |
| 266 | { |
| 267 | /* |
| 268 | |
| 269 | bit description |
| 270 | |
| 271 | 0 SERIAL/NET DATA OUT |
| 272 | 1 SERIAL/NET STATUS OUT |
| 273 | 2 |
| 274 | 3 |
| 275 | 4 |
| 276 | 5 |
| 277 | 6 |
| 278 | 7 |
| 279 | |
| 280 | */ |
| 281 | |
| 282 | // serial |
| 283 | m_rs232->tx(!BIT(data, 0)); |
| 284 | m_rs232->rts_w(!BIT(data, 1)); |
| 285 | } |
| 286 | |
| 287 | |
| 288 | |
| 289 | //************************************************************************** |
| 290 | // ADDRESS MAPS |
| 291 | //************************************************************************** |
| 292 | |
| 293 | //------------------------------------------------- |
| 294 | // ADDRESS_MAP( ep64_mem ) |
| 295 | //------------------------------------------------- |
| 296 | |
| 297 | static ADDRESS_MAP_START( ep64_mem, AS_PROGRAM, 8, ep64_state ) |
| 298 | AM_RANGE(0x0000, 0xffff) AM_DEVICE(DAVE_TAG, dave_device, z80_program_map) |
| 299 | ADDRESS_MAP_END |
| 300 | |
| 301 | |
| 302 | //------------------------------------------------- |
| 303 | // ADDRESS_MAP( ep64_io ) |
| 304 | //------------------------------------------------- |
| 305 | |
| 306 | static ADDRESS_MAP_START( ep64_io, AS_IO, 8, ep64_state ) |
| 307 | AM_RANGE(0x0000, 0xffff) AM_DEVICE(DAVE_TAG, dave_device, z80_io_map) |
| 308 | ADDRESS_MAP_END |
| 309 | |
| 310 | |
| 311 | //------------------------------------------------- |
| 312 | // ADDRESS_MAP( dave_64k_mem ) |
| 313 | //------------------------------------------------- |
| 314 | |
| 315 | static ADDRESS_MAP_START( dave_64k_mem, DAVE_AS_PROGRAM, 8, ep64_state ) |
| 316 | AM_RANGE(0x000000, 0x007fff) AM_ROM AM_REGION(Z80_TAG, 0) |
| 317 | AM_RANGE(0x010000, 0x01ffff) AM_ROM AM_REGION("cart", 0) |
| 318 | AM_RANGE(0x3f0000, 0x3fffff) AM_DEVICE(NICK_TAG, nick_device, vram_map) |
| 319 | ADDRESS_MAP_END |
| 320 | |
| 321 | |
| 322 | //------------------------------------------------- |
| 323 | // ADDRESS_MAP( dave_128k_mem ) |
| 324 | //------------------------------------------------- |
| 325 | |
| 326 | static ADDRESS_MAP_START( dave_128k_mem, DAVE_AS_PROGRAM, 8, ep64_state ) |
| 327 | AM_IMPORT_FROM(dave_64k_mem) |
| 328 | AM_RANGE(0x3e0000, 0x3effff) AM_RAM |
| 329 | ADDRESS_MAP_END |
| 330 | |
| 331 | |
| 332 | //------------------------------------------------- |
| 333 | // ADDRESS_MAP( dave_io ) |
| 334 | //------------------------------------------------- |
| 335 | |
| 336 | static ADDRESS_MAP_START( dave_io, DAVE_AS_IO, 8, ep64_state ) |
| 337 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 338 | AM_RANGE(0x80, 0x8f) AM_DEVICE(NICK_TAG, nick_device, vio_map) |
| 339 | AM_RANGE(0xb5, 0xb5) AM_READWRITE(rd0_r, wr0_w) |
| 340 | AM_RANGE(0xb6, 0xb6) AM_READ(rd1_r) AM_DEVWRITE(CENTRONICS_TAG, centronics_device, write) |
| 341 | AM_RANGE(0xb7, 0xb7) AM_WRITE(wr2_w) |
| 342 | ADDRESS_MAP_END |
| 343 | |
| 344 | |
| 345 | |
| 346 | //************************************************************************** |
| 347 | // INPUT PORTS |
| 348 | //************************************************************************** |
| 349 | |
| 350 | //------------------------------------------------- |
| 351 | // INPUT_PORTS( ep64 ) |
| 352 | //------------------------------------------------- |
| 353 | |
| 354 | static INPUT_PORTS_START( ep64 ) |
| 355 | PORT_START("Y0") |
| 356 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_N) PORT_CHAR('n') PORT_CHAR('N') |
| 357 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TILDE) PORT_CHAR('\\') PORT_CHAR('|') |
| 358 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_B) PORT_CHAR('b') PORT_CHAR('B') |
| 359 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_C) PORT_CHAR('c') PORT_CHAR('C') |
| 360 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_V) PORT_CHAR('v') PORT_CHAR('V') |
| 361 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_X) PORT_CHAR('x') PORT_CHAR('X') |
| 362 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Z) PORT_CHAR('z') PORT_CHAR('Z') |
| 363 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 364 | |
| 365 | PORT_START("Y1") |
| 366 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_H) PORT_CHAR('h') PORT_CHAR('H') |
| 367 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("LOCK") PORT_CODE(KEYCODE_F9) PORT_CHAR(UCHAR_MAMEKEY(F9)) |
| 368 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_G) PORT_CHAR('g') PORT_CHAR('G') |
| 369 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_D) PORT_CHAR('d') PORT_CHAR('D') |
| 370 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F) PORT_CHAR('f') PORT_CHAR('F') |
| 371 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_S) PORT_CHAR('s') PORT_CHAR('S') |
| 372 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_A) PORT_CHAR('a') PORT_CHAR('A') |
| 373 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LCONTROL) PORT_CHAR(UCHAR_SHIFT_2) |
| 374 | |
| 375 | PORT_START("Y2") |
| 376 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_U) PORT_CHAR('u') PORT_CHAR('U') |
| 377 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Q) PORT_CHAR('q') PORT_CHAR('Q') |
| 378 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_Y) PORT_CHAR('y') PORT_CHAR('Y') |
| 379 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_R) PORT_CHAR('r') PORT_CHAR('R') |
| 380 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_T) PORT_CHAR('t') PORT_CHAR('T') |
| 381 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_E) PORT_CHAR('e') PORT_CHAR('E') |
| 382 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_W) PORT_CHAR('w') PORT_CHAR('W') |
| 383 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_TAB) PORT_CHAR('\t') |
| 384 | |
| 385 | PORT_START("Y3") |
| 386 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_7) PORT_CHAR('7') PORT_CHAR('\'') |
| 387 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_1) PORT_CHAR('1') PORT_CHAR('!') |
| 388 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_6) PORT_CHAR('6') PORT_CHAR('&') |
| 389 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_4) PORT_CHAR('4') PORT_CHAR('$') |
| 390 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_5) PORT_CHAR('5') PORT_CHAR('%') |
| 391 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3 \xC2\xA3") PORT_CODE(KEYCODE_3) PORT_CHAR('3') PORT_CHAR('\xA3') |
| 392 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_2) PORT_CHAR('2') PORT_CHAR('"') |
| 393 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ESC) PORT_CHAR(UCHAR_MAMEKEY(ESC)) |
| 394 | |
| 395 | PORT_START("Y4") |
| 396 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F4) PORT_CHAR(UCHAR_MAMEKEY(F4)) |
| 397 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F8) PORT_CHAR(UCHAR_MAMEKEY(F8)) |
| 398 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F3) PORT_CHAR(UCHAR_MAMEKEY(F3)) |
| 399 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(F6)) |
| 400 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F5) PORT_CHAR(UCHAR_MAMEKEY(F5)) |
| 401 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F7) PORT_CHAR(UCHAR_MAMEKEY(F7)) |
| 402 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F2) PORT_CHAR(UCHAR_MAMEKEY(F2)) |
| 403 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_F1) PORT_CHAR(UCHAR_MAMEKEY(F1)) |
| 404 | |
| 405 | PORT_START("Y5") |
| 406 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_8) PORT_CHAR('8') PORT_CHAR('(') |
| 407 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) |
| 408 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_9) PORT_CHAR('9') PORT_CHAR(')') |
| 409 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_MINUS) PORT_CHAR('-') PORT_CHAR('=') |
| 410 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_0) PORT_CHAR('0') PORT_CHAR('_') |
| 411 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_EQUALS) PORT_CHAR('^') PORT_CHAR('~') |
| 412 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ERASE") PORT_CODE(KEYCODE_BACKSPACE) PORT_CHAR(8) |
| 413 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 414 | |
| 415 | PORT_START("Y6") |
| 416 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_J) PORT_CHAR('j') PORT_CHAR('J') |
| 417 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) |
| 418 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_K) PORT_CHAR('k') PORT_CHAR('K') |
| 419 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COLON) PORT_CHAR(';') PORT_CHAR('+') |
| 420 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_L) PORT_CHAR('l') PORT_CHAR('L') |
| 421 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_QUOTE) PORT_CHAR(':') PORT_CHAR('*') |
| 422 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_BACKSLASH) PORT_CHAR(']') PORT_CHAR('}') |
| 423 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 424 | |
| 425 | /* Notice that, in fact, ep128 only had the built-in joystick and no cursor arrow keys on the keyboard */ |
| 426 | PORT_START("Y7") |
| 427 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("STOP") PORT_CODE(KEYCODE_END) PORT_CHAR(UCHAR_MAMEKEY(F10)) |
| 428 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DOWN) PORT_CODE(JOYCODE_Y_DOWN_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(DOWN)) |
| 429 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_RIGHT) PORT_CODE(JOYCODE_X_RIGHT_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(RIGHT)) |
| 430 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_UP) PORT_CODE(JOYCODE_Y_UP_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(UP)) |
| 431 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("HOLD") PORT_CODE(KEYCODE_HOME) PORT_CHAR(UCHAR_MAMEKEY(F11)) |
| 432 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LEFT) PORT_CODE(JOYCODE_X_LEFT_SWITCH) PORT_CHAR(UCHAR_MAMEKEY(LEFT)) |
| 433 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13) |
| 434 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ALT") PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_MAMEKEY(LALT)) |
| 435 | |
| 436 | PORT_START("Y8") |
| 437 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_M) PORT_CHAR('m') PORT_CHAR('M') |
| 438 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_DEL) PORT_CHAR(UCHAR_MAMEKEY(DEL)) |
| 439 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_COMMA) PORT_CHAR(',') PORT_CHAR('<') |
| 440 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SLASH) PORT_CHAR('/') PORT_CHAR('?') |
| 441 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_STOP) PORT_CHAR('.') PORT_CHAR('>') |
| 442 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT (right)") PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| 443 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ') |
| 444 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_INSERT) PORT_CHAR(UCHAR_MAMEKEY(INSERT)) |
| 445 | |
| 446 | PORT_START("Y9") |
| 447 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_I) PORT_CHAR('i') PORT_CHAR('I') |
| 448 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNUSED) |
| 449 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_O) PORT_CHAR('o') PORT_CHAR('O') |
| 450 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_OPENBRACE) PORT_CHAR('@') PORT_CHAR('`') |
| 451 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_P) PORT_CHAR('p') PORT_CHAR('P') |
| 452 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_CLOSEBRACE) PORT_CHAR('[') PORT_CHAR('{') |
| 453 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_UNUSED) |
| 454 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_UNUSED) |
| 455 | INPUT_PORTS_END |
| 456 | |
| 457 | |
| 458 | |
| 459 | //************************************************************************** |
| 460 | // DEVICE CONFIGURATION |
| 461 | //************************************************************************** |
| 462 | |
| 463 | //------------------------------------------------- |
| 464 | // rs232_port_interface rs232_intf |
| 465 | //------------------------------------------------- |
| 466 | |
| 467 | static const rs232_port_interface rs232_intf = |
| 468 | { |
| 469 | DEVCB_NULL, |
| 470 | DEVCB_NULL, |
| 471 | DEVCB_NULL, |
| 472 | DEVCB_NULL, |
| 473 | DEVCB_DEVICE_LINE_MEMBER(DAVE_TAG, dave_device, int2_w) |
| 474 | }; |
| 475 | |
| 476 | |
| 477 | //------------------------------------------------- |
| 478 | // cassette_interface cass_intf |
| 479 | //------------------------------------------------- |
| 480 | |
| 481 | static const cassette_interface cass_intf = |
| 482 | { |
| 483 | cassette_default_formats, |
| 484 | NULL, |
| 485 | (cassette_state)(CASSETTE_STOPPED | CASSETTE_MOTOR_DISABLED | CASSETTE_SPEAKER_MUTED), |
| 486 | "ep64_cass", |
| 487 | NULL |
| 488 | }; |
| 489 | |
| 490 | |
| 491 | |
| 492 | //************************************************************************** |
| 493 | // MACHINE INITIALIZATION |
| 494 | //************************************************************************** |
| 495 | |
| 496 | //------------------------------------------------- |
| 497 | // MACHINE_START( ep64 ) |
| 498 | //------------------------------------------------- |
| 499 | |
| 500 | void ep64_state::machine_start() |
| 501 | { |
| 502 | // state saving |
| 503 | save_item(NAME(m_key)); |
| 504 | } |
| 505 | |
| 506 | |
| 507 | //------------------------------------------------- |
| 508 | // MACHINE_RESET( ep64 ) |
| 509 | //------------------------------------------------- |
| 510 | |
| 511 | void ep64_state::machine_reset() |
| 512 | { |
| 513 | m_dave->reset(); |
| 514 | m_nick->reset(); |
| 515 | |
| 516 | address_space &program = m_maincpu->space(AS_PROGRAM); |
| 517 | wr0_w(program, 0, 0); |
| 518 | m_centronics->write(0); |
| 519 | wr2_w(program, 0, 0); |
| 520 | } |
| 521 | |
| 522 | |
| 523 | |
| 524 | //************************************************************************** |
| 525 | // MACHINE CONFIGURATION |
| 526 | //************************************************************************** |
| 527 | |
| 528 | //------------------------------------------------- |
| 529 | // MACHINE_CONFIG( ep64 ) |
| 530 | //------------------------------------------------- |
| 531 | |
| 532 | static MACHINE_CONFIG_START( ep64, ep64_state ) |
| 533 | // basic machine hardware |
| 534 | MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_8MHz/2) |
| 535 | MCFG_CPU_PROGRAM_MAP(ep64_mem) |
| 536 | MCFG_CPU_IO_MAP(ep64_io) |
| 537 | |
| 538 | // video hardware |
| 539 | MCFG_NICK_ADD(NICK_TAG, SCREEN_TAG, XTAL_8MHz, DEVWRITELINE(DAVE_TAG, dave_device, int1_w)) |
| 540 | |
| 541 | // sound hardware |
| 542 | MCFG_DAVE_ADD(DAVE_TAG, XTAL_8MHz, INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0), dave_64k_mem, dave_io) |
| 543 | |
| 544 | // devices |
| 545 | MCFG_EP64_EXPANSION_BUS_SLOT_ADD(EP64_EXPANSION_BUS_TAG, DAVE_TAG, NULL) |
| 546 | MCFG_EP64_EXPANSION_BUS_CALLBACKS(INPUTLINE(Z80_TAG, INPUT_LINE_IRQ0), INPUTLINE(Z80_TAG, INPUT_LINE_NMI), INPUTLINE(Z80_TAG, Z80_INPUT_LINE_WAIT)) |
| 547 | MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, standard_centronics) |
| 548 | MCFG_RS232_PORT_ADD(RS232_TAG, rs232_intf, default_rs232_devices, NULL) |
| 549 | MCFG_CASSETTE_ADD(CASSETTE1_TAG, cass_intf) |
| 550 | MCFG_CASSETTE_ADD(CASSETTE2_TAG, cass_intf) |
| 551 | |
| 552 | // internal RAM |
| 553 | MCFG_RAM_ADD(RAM_TAG) |
| 554 | MCFG_RAM_DEFAULT_SIZE("64K") |
| 555 | |
| 556 | // cartridge |
| 557 | MCFG_CARTSLOT_ADD("cart") |
| 558 | MCFG_CARTSLOT_EXTENSION_LIST("rom,bin") |
| 559 | MCFG_CARTSLOT_NOT_MANDATORY |
| 560 | MCFG_CARTSLOT_INTERFACE("ep64_cart") |
| 561 | |
| 562 | // software lists |
| 563 | MCFG_SOFTWARE_LIST_ADD("cart_list", "ep64_cart") |
| 564 | MCFG_SOFTWARE_LIST_ADD("cass_list", "ep64_cass") |
| 565 | MCFG_SOFTWARE_LIST_ADD("flop_list", "ep64_flop") |
| 566 | MACHINE_CONFIG_END |
| 567 | |
| 568 | |
| 569 | //------------------------------------------------- |
| 570 | // MACHINE_CONFIG( ep128 ) |
| 571 | //------------------------------------------------- |
| 572 | |
| 573 | static MACHINE_CONFIG_DERIVED( ep128, ep64 ) |
| 574 | MCFG_DEVICE_MODIFY(DAVE_TAG) |
| 575 | MCFG_DEVICE_ADDRESS_MAP(AS_0, dave_128k_mem) |
| 576 | |
| 577 | // internal RAM |
| 578 | MCFG_RAM_MODIFY(RAM_TAG) |
| 579 | MCFG_RAM_DEFAULT_SIZE("128K") |
| 580 | MACHINE_CONFIG_END |
| 581 | |
| 582 | |
| 583 | |
| 584 | //************************************************************************** |
| 585 | // ROMS |
| 586 | //************************************************************************** |
| 587 | |
| 588 | //------------------------------------------------- |
| 589 | // ROM( ep64 ) |
| 590 | //------------------------------------------------- |
| 591 | |
| 592 | ROM_START( ep64 ) |
| 593 | ROM_REGION( 0x8000, Z80_TAG, 0 ) |
| 594 | ROM_LOAD( "9256ds-0038_enter05-23-a.u2", 0x0000, 0x8000, CRC(d421795f) SHA1(6033a0535136c40c47137e4d1cd9273c06d5fdff) ) |
| 595 | |
| 596 | ROM_REGION( 0x10000, "cart", 0 ) |
| 597 | ROM_CART_LOAD( "cart", 0x00000, 0x10000, ROM_MIRROR ) |
| 598 | ROM_END |
| 599 | |
| 600 | #define rom_phc64 rom_ep64 |
| 601 | |
| 602 | |
| 603 | //------------------------------------------------- |
| 604 | // ROM( ep128 ) |
| 605 | //------------------------------------------------- |
| 606 | |
| 607 | ROM_START( ep128 ) |
| 608 | ROM_REGION( 0x8000, Z80_TAG, 0 ) |
| 609 | ROM_LOAD( "9256ds-0019_enter08-45-a.u2", 0x0000, 0x8000, CRC(982a3b44) SHA1(55315b20fecb4441a07ee4bc5dc7153f396e0a2e) ) |
| 610 | |
| 611 | ROM_REGION( 0x10000, "cart", 0 ) |
| 612 | ROM_CART_LOAD( "cart", 0x00000, 0x10000, ROM_MIRROR ) |
| 613 | ROM_END |
| 614 | |
| 615 | |
| 616 | |
| 617 | //************************************************************************** |
| 618 | // SYSTEM DRIVERS |
| 619 | //************************************************************************** |
| 620 | |
| 621 | // YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS |
| 622 | COMP( 1985, ep64, 0, 0, ep64, ep64, driver_device, 0, "Enterprise Computers", "Enterprise Sixty Four", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 623 | COMP( 1985, phc64, ep64, 0, ep64, ep64, driver_device, 0, "Hegener & Glaser", "Mephisto PHC 64 (Germany)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 624 | COMP( 1986, ep128, ep64, 0, ep128, ep64, driver_device, 0, "Enterprise Computers", "Enterprise One Two Eight", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |