src/mess/machine/mos6530.c
| r0 | r7184 | |
| 1 | /********************************************************************** |
| 2 | |
| 3 | MOS Technology 6530 Memory, I/O, Timer Array emulation |
| 4 | |
| 5 | Copyright MESS Team. |
| 6 | Visit http://mamedev.org for licensing and usage restrictions. |
| 7 | |
| 8 | **********************************************************************/ |
| 9 | |
| 10 | /* |
| 11 | |
| 12 | TODO: |
| 13 | |
| 14 | - interrupt flag register |
| 15 | - internal RAM |
| 16 | - internal ROM |
| 17 | |
| 18 | */ |
| 19 | |
| 20 | #include "mos6530.h" |
| 21 | |
| 22 | /*************************************************************************** |
| 23 | PARAMETERS |
| 24 | ***************************************************************************/ |
| 25 | |
| 26 | #define LOG 1 |
| 27 | |
| 28 | enum |
| 29 | { |
| 30 | REGISTER_PORT_A = 0, |
| 31 | REGISTER_PORT_A_DDR, |
| 32 | REGISTER_PORT_B, |
| 33 | REGISTER_PORT_B_DDR, |
| 34 | REGISTER_TIMER_1T, REGISTER_TIMER = REGISTER_TIMER_1T, |
| 35 | REGISTER_TIMER_8T, REGISTER_INTERRUPT_FLAG = REGISTER_TIMER_8T, |
| 36 | REGISTER_TIMER_64T, |
| 37 | REGISTER_TIMER_1024T |
| 38 | }; |
| 39 | |
| 40 | enum |
| 41 | { |
| 42 | PORT_A = 0, |
| 43 | PORT_B, |
| 44 | PORT_COUNT |
| 45 | }; |
| 46 | |
| 47 | static const int PRESCALER[] = { 1, 8, 64, 1024 }; |
| 48 | |
| 49 | /*************************************************************************** |
| 50 | TYPE DEFINITIONS |
| 51 | ***************************************************************************/ |
| 52 | |
| 53 | typedef struct _mos6530_t mos6530_t; |
| 54 | struct _mos6530_t |
| 55 | { |
| 56 | devcb_resolved_write_line out_irq_func; |
| 57 | |
| 58 | devcb_resolved_read8 in_port_func[PORT_COUNT]; |
| 59 | devcb_resolved_write8 out_port_func[PORT_COUNT]; |
| 60 | |
| 61 | /* registers */ |
| 62 | UINT8 output[PORT_COUNT]; /* output latches */ |
| 63 | UINT8 ddr[PORT_COUNT]; /* DDR latches */ |
| 64 | UINT8 counter; /* counter */ |
| 65 | int irq_enabled; |
| 66 | |
| 67 | /* timers */ |
| 68 | emu_timer *timer; /* timer */ |
| 69 | }; |
| 70 | |
| 71 | /*************************************************************************** |
| 72 | INLINE FUNCTIONS |
| 73 | ***************************************************************************/ |
| 74 | |
| 75 | INLINE mos6530_t *get_safe_token(const device_config *device) |
| 76 | { |
| 77 | assert(device != NULL); |
| 78 | assert(device->token != NULL); |
| 79 | return (mos6530_t *)device->token; |
| 80 | } |
| 81 | |
| 82 | INLINE const mos6530_interface *get_interface(const device_config *device) |
| 83 | { |
| 84 | assert(device != NULL); |
| 85 | assert(device->type == MOS6530); |
| 86 | return (const mos6530_interface *) device->static_config; |
| 87 | } |
| 88 | |
| 89 | INLINE UINT8 read_port(mos6530_t *mos6530, int port) |
| 90 | { |
| 91 | UINT8 data = mos6530->output[port] & mos6530->ddr[port]; |
| 92 | |
| 93 | if (mos6530->ddr[port] != 0xff) |
| 94 | { |
| 95 | data |= devcb_call_read8(&mos6530->in_port_func[port], 0) & ~mos6530->ddr[port]; |
| 96 | } |
| 97 | |
| 98 | return data; |
| 99 | } |
| 100 | |
| 101 | INLINE void write_port(mos6530_t *mos6530, int port, UINT8 data) |
| 102 | { |
| 103 | mos6530->output[port] = data; |
| 104 | |
| 105 | devcb_call_write8(&mos6530->out_port_func[port], 0, mos6530->output[port] & mos6530->ddr[port]); |
| 106 | } |
| 107 | |
| 108 | /*************************************************************************** |
| 109 | IMPLEMENTATION |
| 110 | ***************************************************************************/ |
| 111 | |
| 112 | /*------------------------------------------------- |
| 113 | TIMER_CALLBACK( timer_tick ) |
| 114 | -------------------------------------------------*/ |
| 115 | |
| 116 | static TIMER_CALLBACK( timer_tick ) |
| 117 | { |
| 118 | const device_config *device = (const device_config *)ptr; |
| 119 | mos6530_t *mos6530 = get_safe_token(device); |
| 120 | |
| 121 | if (mos6530->counter == 0xff) |
| 122 | { |
| 123 | if (mos6530->irq_enabled) |
| 124 | { |
| 125 | /* interrupt */ |
| 126 | logerror("MOS6530 '%s' Interrupt\n", device->tag.cstr()); |
| 127 | devcb_call_write_line(&mos6530->out_irq_func, ASSERT_LINE); |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | mos6530->counter--; |
| 132 | } |
| 133 | |
| 134 | /*------------------------------------------------- |
| 135 | mos6530_register_r - register read |
| 136 | -------------------------------------------------*/ |
| 137 | |
| 138 | READ8_DEVICE_HANDLER( mos6530_r ) |
| 139 | { |
| 140 | mos6530_t *mos6530 = get_safe_token(device); |
| 141 | int port = BIT(offset, 1); |
| 142 | |
| 143 | UINT8 data = 0; |
| 144 | |
| 145 | switch (offset & 0x07) |
| 146 | { |
| 147 | case REGISTER_PORT_A: |
| 148 | case REGISTER_PORT_B: |
| 149 | data = read_port(mos6530, port); |
| 150 | break; |
| 151 | |
| 152 | case REGISTER_PORT_A_DDR: |
| 153 | case REGISTER_PORT_B_DDR: |
| 154 | data = mos6530->ddr[port]; |
| 155 | break; |
| 156 | |
| 157 | default: |
| 158 | switch (offset & 0x05) |
| 159 | { |
| 160 | case REGISTER_TIMER: |
| 161 | data = mos6530->counter; |
| 162 | devcb_call_write_line(&mos6530->out_irq_func, CLEAR_LINE); |
| 163 | logerror("MOS6530 '%s' Interrupt Cleared\n", device->tag.cstr()); |
| 164 | break; |
| 165 | |
| 166 | case REGISTER_INTERRUPT_FLAG: |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | return data; |
| 172 | } |
| 173 | |
| 174 | /*------------------------------------------------- |
| 175 | mos6530_register_w - register write |
| 176 | -------------------------------------------------*/ |
| 177 | |
| 178 | WRITE8_DEVICE_HANDLER( mos6530_w ) |
| 179 | { |
| 180 | mos6530_t *mos6530 = get_safe_token(device); |
| 181 | int port = BIT(offset, 1); |
| 182 | |
| 183 | switch (offset & 0x07) |
| 184 | { |
| 185 | case REGISTER_PORT_A: |
| 186 | case REGISTER_PORT_B: |
| 187 | if (LOG) logerror("MOS6530 '%s' Port %c Write %02x\n", device->tag.cstr(), 'A' + port, data); |
| 188 | write_port(mos6530, port, data); |
| 189 | break; |
| 190 | |
| 191 | case REGISTER_PORT_A_DDR: |
| 192 | case REGISTER_PORT_B_DDR: |
| 193 | if (LOG) logerror("MOS6530 '%s' Port %c DDR: %02x\n", device->tag.cstr(), 'A' + port, data); |
| 194 | mos6530->ddr[port] = data; |
| 195 | write_port(mos6530, port, data); |
| 196 | break; |
| 197 | |
| 198 | case REGISTER_TIMER_1T: |
| 199 | case REGISTER_TIMER_8T: |
| 200 | case REGISTER_TIMER_64T: |
| 201 | case REGISTER_TIMER_1024T: |
| 202 | if (LOG) logerror("MOS6530 '%s' Timer: %02x, %uT, IRQ %s\n", device->tag.cstr(), data, PRESCALER[offset & 0x03], BIT(offset, 3) ? "enabled" : "disabled"); |
| 203 | mos6530->counter = data; |
| 204 | mos6530->irq_enabled = BIT(offset, 3); |
| 205 | timer_adjust_periodic(mos6530->timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / PRESCALER[offset & 0x03])); |
| 206 | devcb_call_write_line(&mos6530->out_irq_func, CLEAR_LINE); |
| 207 | break; |
| 208 | } |
| 209 | } |
| 210 | |
| 211 | /*------------------------------------------------- |
| 212 | DEVICE_START( mos6530 ) |
| 213 | -------------------------------------------------*/ |
| 214 | |
| 215 | static DEVICE_START( mos6530 ) |
| 216 | { |
| 217 | mos6530_t *mos6530 = (mos6530_t *)device->token; |
| 218 | const mos6530_interface *intf = get_interface(device); |
| 219 | |
| 220 | /* resolve callbacks */ |
| 221 | devcb_resolve_write_line(&mos6530->out_irq_func, &intf->out_irq_func, device); |
| 222 | devcb_resolve_read8(&mos6530->in_port_func[PORT_A], &intf->in_pa_func, device); |
| 223 | devcb_resolve_read8(&mos6530->in_port_func[PORT_B], &intf->in_pb_func, device); |
| 224 | devcb_resolve_write8(&mos6530->out_port_func[PORT_A], &intf->out_pa_func, device); |
| 225 | devcb_resolve_write8(&mos6530->out_port_func[PORT_B], &intf->out_pb_func, device); |
| 226 | |
| 227 | /* allocate timer */ |
| 228 | mos6530->timer = timer_alloc(device->machine, timer_tick, (void *)device); |
| 229 | |
| 230 | /* register for state saving */ |
| 231 | state_save_register_device_item_array(device, 0, mos6530->output); |
| 232 | state_save_register_device_item_array(device, 0, mos6530->ddr); |
| 233 | } |
| 234 | |
| 235 | /*------------------------------------------------- |
| 236 | DEVICE_RESET( mos6530 ) |
| 237 | -------------------------------------------------*/ |
| 238 | |
| 239 | static DEVICE_RESET( mos6530 ) |
| 240 | { |
| 241 | mos6530_t *mos6530 = (mos6530_t *)device->token; |
| 242 | |
| 243 | /* set ports to input mode */ |
| 244 | mos6530->ddr[PORT_A] = 0; |
| 245 | mos6530->ddr[PORT_B] = 0; |
| 246 | } |
| 247 | |
| 248 | /*------------------------------------------------- |
| 249 | DEVICE_GET_INFO( mos6530 ) |
| 250 | -------------------------------------------------*/ |
| 251 | |
| 252 | DEVICE_GET_INFO( mos6530 ) |
| 253 | { |
| 254 | switch (state) |
| 255 | { |
| 256 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 257 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 258 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 259 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(mos6530_t); break; |
| 260 | |
| 261 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 262 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mos6530); break; |
| 263 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 264 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(mos6530); break; |
| 265 | |
| 266 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 267 | case DEVINFO_STR_NAME: strcpy(info->s, "MOS6530"); break; |
| 268 | case DEVINFO_STR_FAMILY: strcpy(info->s, "MOS6500"); break; |
| 269 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 270 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 271 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 272 | } |
| 273 | } |
src/mess/machine/c2040.c
| r7183 | r7184 | |
| 12 | 12 | TODO: |
| 13 | 13 | |
| 14 | 14 | - find GCR rom region |
| 15 | - read from disk |
| 15 | 16 | - write to disk |
| 16 | 17 | |
| 17 | 18 | */ |
| r7183 | r7184 | |
| 24 | 25 | #include "formats/g64_dsk.h" |
| 25 | 26 | #include "machine/6522via.h" |
| 26 | 27 | #include "machine/6532riot.h" |
| 28 | #include "machine/mos6530.h" |
| 27 | 29 | #include "machine/ieee488.h" |
| 28 | 30 | |
| 29 | 31 | /*************************************************************************** |
| 30 | 32 | PARAMETERS |
| 31 | 33 | ***************************************************************************/ |
| 32 | 34 | |
| 33 | | #define LOG |
| 35 | #define LOG 1 |
| 34 | 36 | |
| 35 | 37 | #define M6502_DOS_TAG "un1" |
| 36 | 38 | #define M6532_0_TAG "uc1" |
| r7183 | r7184 | |
| 54 | 56 | #define TRACK_DATA_START 2 |
| 55 | 57 | |
| 56 | 58 | #define SYNC ((c2040->sr & SYNC_MARK) == SYNC_MARK) |
| 57 | | #define ERROR (!c2040->ready & !BIT(c2040->gcr_data, 3)) |
| 59 | #define ERROR (!c2040->ready & !BIT(c2040->e, 3)) |
| 58 | 60 | |
| 59 | 61 | /*************************************************************************** |
| 60 | 62 | TYPE DEFINITIONS |
| r7183 | r7184 | |
| 87 | 89 | UINT16 sr; /* data shift register */ |
| 88 | 90 | int ds; /* density select */ |
| 89 | 91 | UINT8* gcr; /* GCR encoder/decoder ROM */ |
| 90 | | UINT8 gcr_data; /* GCR encoder/decoded ROM data */ |
| 92 | UINT8 i; /* GCR encoder/decoded ROM address */ |
| 93 | UINT8 e; /* GCR encoder/decoded ROM data */ |
| 91 | 94 | UINT8 pi; /* parallel data input */ |
| 92 | 95 | |
| 93 | 96 | /* IEEE-488 bus */ |
| r7183 | r7184 | |
| 153 | 156 | |
| 154 | 157 | INLINE void update_gcr_data(c2040_t *c2040) |
| 155 | 158 | { |
| 156 | | UINT16 gcr_addr; |
| 157 | | |
| 158 | 159 | if (c2040->rw) |
| 159 | 160 | { |
| 160 | 161 | /* |
| r7183 | r7184 | |
| 175 | 176 | |
| 176 | 177 | */ |
| 177 | 178 | |
| 178 | | gcr_addr = (c2040->rw << 10) | (c2040->sr & 0x3ff); |
| 179 | c2040->i = (c2040->rw << 10) | (c2040->sr & 0x3ff); |
| 179 | 180 | } |
| 180 | 181 | else |
| 181 | 182 | { |
| r7183 | r7184 | |
| 197 | 198 | |
| 198 | 199 | */ |
| 199 | 200 | |
| 200 | | gcr_addr = (c2040->rw << 10) | ((c2040->pi & 0xf0) << 1) | (c2040->mode << 4) | (c2040->pi & 0x0f); |
| 201 | c2040->i = (c2040->rw << 10) | ((c2040->pi & 0xf0) << 1) | (c2040->mode << 4) | (c2040->pi & 0x0f); |
| 201 | 202 | } |
| 202 | 203 | |
| 203 | | // c2040->gcr_data = c2040->gcr[gcr_addr]; |
| 204 | //c2040->e = c2040->gcr[c2040->i]; |
| 204 | 205 | |
| 206 | if (LOG) |
| 207 | { |
| 208 | UINT16 i = c2040->i; |
| 209 | UINT8 e = c2040->e; |
| 210 | UINT8 pa = (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x30) | (BIT(e, 2) << 3) | (i & 0x04) | (e & 0x03); |
| 211 | |
| 212 | logerror("offs %04x G64 %02x READY %u PA %02x DATA %03x GCR %02x SYNC %u ERROR %u\n", c2040->unit[c2040->drive].buffer_pos, |
| 213 | c2040->unit[c2040->drive].track_buffer[c2040->unit[c2040->drive].buffer_pos], |
| 214 | c2040->ready, pa, c2040->sr & 0x3ff, c2040->e, SYNC, ERROR); |
| 215 | } |
| 216 | |
| 205 | 217 | via_cb1_w(c2040->via, ERROR); |
| 206 | 218 | } |
| 207 | 219 | |
| r7183 | r7184 | |
| 243 | 255 | c2040->bit_count = 0; |
| 244 | 256 | } |
| 245 | 257 | |
| 246 | | if (c2040->bit_count > 7) |
| 258 | if (c2040->bit_count == 10) |
| 247 | 259 | { |
| 248 | 260 | /* byte ready */ |
| 249 | 261 | c2040->bit_count = 0; |
| 250 | 262 | ready = 0; |
| 251 | | |
| 252 | | if (!(c2040->sr & 0xff)) |
| 253 | | { |
| 254 | | /* simulate weak bits with randomness */ |
| 255 | | c2040->sr = (c2040->sr & 0xff00) | (mame_rand(machine) & 0xff); |
| 256 | | } |
| 257 | 263 | } |
| 258 | 264 | |
| 259 | 265 | if (c2040->ready != ready) |
| r7183 | r7184 | |
| 301 | 307 | ADDRESS_MAP_GLOBAL_MASK(0x7fff) |
| 302 | 308 | AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1 |
| 303 | 309 | AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2 |
| 304 | | AM_RANGE(0x0200, 0x020f) AM_MIRROR(0x0d70) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 305 | | AM_RANGE(0x0280, 0x028f) AM_MIRROR(0x0d70) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 310 | AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 311 | AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 306 | 312 | AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1") |
| 307 | 313 | AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2") |
| 308 | 314 | AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 318 | 324 | ADDRESS_MAP_GLOBAL_MASK(0x1fff) |
| 319 | 325 | AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530 |
| 320 | 326 | AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w) |
| 321 | | AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, riot6532_r, riot6532_w) |
| 327 | AM_RANGE(0x0080, 0x009f) AM_MIRROR(0x0320) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w) |
| 322 | 328 | AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1") |
| 323 | 329 | AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2") |
| 324 | 330 | AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 334 | 340 | ADDRESS_MAP_GLOBAL_MASK(0x7fff) |
| 335 | 341 | AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1 |
| 336 | 342 | AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2 |
| 337 | | AM_RANGE(0x0200, 0x020f) /*AM_MIRROR(0x0d70)*/ AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 338 | | AM_RANGE(0x0280, 0x028f) /*AM_MIRROR(0x0d70)*/ AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 339 | | AM_RANGE(0x1000, 0x13ff) /*AM_MIRROR(0x0c00)*/ AM_RAM AM_SHARE("share1") |
| 340 | | AM_RANGE(0x2000, 0x23ff) /*AM_MIRROR(0x0c00)*/ AM_RAM AM_SHARE("share2") |
| 341 | | AM_RANGE(0x3000, 0x33ff) /*AM_MIRROR(0x0c00)*/ AM_RAM AM_SHARE("share3") |
| 342 | | AM_RANGE(0x4000, 0x43ff) /*AM_MIRROR(0x0c00)*/ AM_RAM AM_SHARE("share4") |
| 343 | AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 344 | AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 345 | AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1") |
| 346 | AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2") |
| 347 | AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3") |
| 348 | AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share4") |
| 343 | 349 | AM_RANGE(0x5000, 0x7fff) AM_ROM AM_REGION("c4040", 0x0000) |
| 344 | 350 | ADDRESS_MAP_END |
| 345 | 351 | |
| r7183 | r7184 | |
| 349 | 355 | |
| 350 | 356 | static ADDRESS_MAP_START( c4040_fdc_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 351 | 357 | ADDRESS_MAP_GLOBAL_MASK(0x1fff) |
| 352 | | AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0100) AM_RAM // 6530 |
| 353 | | AM_RANGE(0x0040, 0x004f) /*AM_MIRROR(0x0330)*/ AM_DEVREADWRITE(M6522_TAG, via_r, via_w) |
| 354 | | AM_RANGE(0x0080, 0x008f) /*AM_MIRROR(0x0330)*/ AM_DEVREADWRITE(M6530_TAG, riot6532_r, riot6532_w) |
| 358 | AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530 |
| 359 | AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w) |
| 360 | AM_RANGE(0x0080, 0x009f) AM_MIRROR(0x0320) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w) |
| 355 | 361 | AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1") |
| 356 | 362 | AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2") |
| 357 | 363 | AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 364 | 370 | -------------------------------------------------*/ |
| 365 | 371 | |
| 366 | 372 | static ADDRESS_MAP_START( c8050_dos_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 367 | | AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0f00) AM_RAM // 6532 #1 |
| 368 | | AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0f00) AM_RAM // 6532 #2 |
| 369 | | AM_RANGE(0x0200, 0x020f) AM_MIRROR(0x0d70) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 370 | | AM_RANGE(0x0280, 0x028f) AM_MIRROR(0x0d70) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 373 | AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1 |
| 374 | AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2 |
| 375 | AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 376 | AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 371 | 377 | AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1") |
| 372 | 378 | AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2") |
| 373 | 379 | AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 383 | 389 | ADDRESS_MAP_GLOBAL_MASK(0x1fff) |
| 384 | 390 | AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530 |
| 385 | 391 | AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w) |
| 386 | | AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, riot6532_r, riot6532_w) |
| 392 | AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w) |
| 387 | 393 | AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1") |
| 388 | 394 | AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2") |
| 389 | 395 | AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 396 | 402 | -------------------------------------------------*/ |
| 397 | 403 | |
| 398 | 404 | static ADDRESS_MAP_START( sfd1001_dos_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 399 | | AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0f00) AM_RAM // 6532 #1 |
| 400 | | AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0f00) AM_RAM // 6532 #2 |
| 401 | | AM_RANGE(0x0200, 0x020f) AM_MIRROR(0x0d70) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 402 | | AM_RANGE(0x0280, 0x028f) AM_MIRROR(0x0d70) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 405 | AM_RANGE(0x0000, 0x007f) AM_MIRROR(0x0100) AM_RAM // 6532 #1 |
| 406 | AM_RANGE(0x0080, 0x00ff) AM_MIRROR(0x0100) AM_RAM // 6532 #2 |
| 407 | AM_RANGE(0x0200, 0x021f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_0_TAG, riot6532_r, riot6532_w) |
| 408 | AM_RANGE(0x0280, 0x029f) AM_MIRROR(0x0d60) AM_DEVREADWRITE(M6532_1_TAG, riot6532_r, riot6532_w) |
| 403 | 409 | AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share1") |
| 404 | 410 | AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share2") |
| 405 | 411 | AM_RANGE(0x3000, 0x33ff) AM_MIRROR(0x0c00) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 415 | 421 | ADDRESS_MAP_GLOBAL_MASK(0x1fff) |
| 416 | 422 | AM_RANGE(0x0000, 0x003f) AM_MIRROR(0x0300) AM_RAM // 6530 |
| 417 | 423 | AM_RANGE(0x0040, 0x004f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6522_TAG, via_r, via_w) |
| 418 | | AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, riot6532_r, riot6532_w) |
| 424 | AM_RANGE(0x0080, 0x008f) AM_MIRROR(0x0330) AM_DEVREADWRITE(M6530_TAG, mos6530_r, mos6530_w) |
| 419 | 425 | AM_RANGE(0x0400, 0x07ff) AM_RAM AM_SHARE("share1") |
| 420 | 426 | AM_RANGE(0x0800, 0x0bff) AM_RAM AM_SHARE("share2") |
| 421 | 427 | AM_RANGE(0x0c00, 0x0fff) AM_RAM AM_SHARE("share3") |
| r7183 | r7184 | |
| 650 | 656 | |
| 651 | 657 | c2040_t *c2040 = get_safe_token(device->owner); |
| 652 | 658 | |
| 653 | | UINT16 i = c2040->sr; |
| 654 | | UINT8 e = c2040->gcr_data; |
| 659 | UINT16 i = c2040->i; |
| 660 | UINT8 e = c2040->e; |
| 655 | 661 | |
| 656 | 662 | return (BIT(e, 6) << 7) | (BIT(i, 7) << 6) | (e & 0x30) | (BIT(e, 2) << 3) | (i & 0x04) | (e & 0x03); |
| 657 | 663 | } |
| r7183 | r7184 | |
| 706 | 712 | /* extract track length */ |
| 707 | 713 | c2040->unit[unit].track_len = (c2040->unit[unit].track_buffer[1] << 8) | c2040->unit[unit].track_buffer[0]; |
| 708 | 714 | } |
| 715 | |
| 716 | c2040->unit[unit].stp = stp; |
| 709 | 717 | } |
| 710 | 718 | } |
| 711 | 719 | |
| r7183 | r7184 | |
| 731 | 739 | /* stepper motor 1 */ |
| 732 | 740 | int s1 = data & 0x03; |
| 733 | 741 | step_motor(c2040, 1, s1); |
| 734 | | logerror("S1 %u\n", s1); |
| 735 | 742 | |
| 736 | 743 | /* stepper motor 0 */ |
| 737 | 744 | int s0 = (data >> 2) & 0x03; |
| 738 | 745 | step_motor(c2040, 0, s0); |
| 739 | | logerror("S0 %u\n", s1); |
| 740 | 746 | |
| 741 | 747 | /* spindle motor 1 */ |
| 742 | 748 | int mtr1 = BIT(data, 4); |
| 743 | 749 | floppy_mon_w(c2040->unit[1].image, !mtr1); |
| 744 | | logerror("MTR1 %u\n", mtr1); |
| 745 | 750 | |
| 746 | 751 | /* spindle motor 0 */ |
| 747 | 752 | int mtr0 = BIT(data, 5); |
| 748 | 753 | floppy_mon_w(c2040->unit[0].image, !mtr0); |
| 749 | | logerror("MTR0 %u\n", mtr0); |
| 750 | 754 | |
| 751 | 755 | timer_enable(c2040->bit_timer, mtr1 | mtr0); |
| 752 | 756 | } |
| r7183 | r7184 | |
| 871 | 875 | }; |
| 872 | 876 | |
| 873 | 877 | /*------------------------------------------------- |
| 874 | | riot6532_interface c2040_riot2_intf uk3 |
| 878 | mos6530_interface c2040_riot2_intf uk3 |
| 875 | 879 | -------------------------------------------------*/ |
| 876 | 880 | |
| 877 | 881 | static READ8_DEVICE_HANDLER( pi_r ) |
| r7183 | r7184 | |
| 1042 | 1046 | cpu_set_input_line(c2040->cpu_fdc, M6502_IRQ_LINE, state); |
| 1043 | 1047 | } |
| 1044 | 1048 | |
| 1045 | | static const riot6532_interface c2040_riot2_intf = |
| 1049 | static MOS6530_INTERFACE( c2040_riot2_intf ) |
| 1046 | 1050 | { |
| 1051 | DEVCB_LINE(c2040_riot2_irq_w), |
| 1047 | 1052 | DEVCB_HANDLER(pi_r), |
| 1053 | DEVCB_HANDLER(pi_w), |
| 1048 | 1054 | DEVCB_HANDLER(c2040_riot2_pb_r), |
| 1049 | | DEVCB_HANDLER(pi_w), |
| 1050 | | DEVCB_HANDLER(c2040_riot2_pb_w), |
| 1051 | | DEVCB_LINE(c2040_riot2_irq_w) |
| 1055 | DEVCB_HANDLER(c2040_riot2_pb_w) |
| 1052 | 1056 | }; |
| 1053 | 1057 | |
| 1054 | | static const riot6532_interface c8050_riot2_intf = |
| 1058 | static MOS6530_INTERFACE( c8050_riot2_intf ) |
| 1055 | 1059 | { |
| 1060 | DEVCB_LINE(c2040_riot2_irq_w), |
| 1056 | 1061 | DEVCB_HANDLER(pi_r), |
| 1062 | DEVCB_HANDLER(pi_w), |
| 1057 | 1063 | DEVCB_HANDLER(c8050_riot2_pb_r), |
| 1058 | | DEVCB_HANDLER(pi_w), |
| 1059 | | DEVCB_HANDLER(c8050_riot2_pb_w), |
| 1060 | | DEVCB_LINE(c2040_riot2_irq_w) |
| 1064 | DEVCB_HANDLER(c8050_riot2_pb_w) |
| 1061 | 1065 | }; |
| 1062 | 1066 | |
| 1063 | 1067 | /*------------------------------------------------- |
| r7183 | r7184 | |
| 1175 | 1179 | MDRV_CPU_PROGRAM_MAP(c2040_fdc_map) |
| 1176 | 1180 | |
| 1177 | 1181 | MDRV_VIA6522_ADD(M6522_TAG, XTAL_16MHz/16, c2040_via_intf) |
| 1178 | | MDRV_RIOT6532_ADD(M6530_TAG, XTAL_16MHz/16, c2040_riot2_intf) |
| 1182 | MDRV_MOS6530_ADD(M6530_TAG, XTAL_16MHz/16, c2040_riot2_intf) |
| 1179 | 1183 | |
| 1180 | 1184 | MDRV_FLOPPY_2_DRIVES_ADD(c2040_floppy_config) |
| 1181 | 1185 | MACHINE_DRIVER_END |
| r7183 | r7184 | |
| 1197 | 1201 | MDRV_CPU_PROGRAM_MAP(c4040_fdc_map) |
| 1198 | 1202 | |
| 1199 | 1203 | MDRV_VIA6522_ADD(M6522_TAG, XTAL_16MHz/16, c2040_via_intf) |
| 1200 | | MDRV_RIOT6532_ADD(M6530_TAG, XTAL_16MHz/16, c2040_riot2_intf) |
| 1204 | MDRV_MOS6530_ADD(M6530_TAG, XTAL_16MHz/16, c2040_riot2_intf) |
| 1201 | 1205 | |
| 1202 | 1206 | MDRV_FLOPPY_2_DRIVES_ADD(c4040_floppy_config) |
| 1203 | 1207 | MACHINE_DRIVER_END |
| r7183 | r7184 | |
| 1219 | 1223 | MDRV_CPU_PROGRAM_MAP(c8050_fdc_map) |
| 1220 | 1224 | |
| 1221 | 1225 | MDRV_VIA6522_ADD(M6522_TAG, XTAL_12MHz/3, c8050_via_intf) |
| 1222 | | MDRV_RIOT6532_ADD(M6530_TAG, XTAL_12MHz/3, c8050_riot2_intf) |
| 1226 | MDRV_MOS6530_ADD(M6530_TAG, XTAL_12MHz/3, c8050_riot2_intf) |
| 1223 | 1227 | |
| 1224 | 1228 | MDRV_FLOPPY_2_DRIVES_ADD(c8050_floppy_config) |
| 1225 | 1229 | MACHINE_DRIVER_END |
| r7183 | r7184 | |
| 1241 | 1245 | MDRV_CPU_PROGRAM_MAP(c8050_fdc_map) |
| 1242 | 1246 | |
| 1243 | 1247 | MDRV_VIA6522_ADD(M6522_TAG, XTAL_12MHz/3, c8050_via_intf) |
| 1244 | | MDRV_RIOT6532_ADD(M6530_TAG, XTAL_12MHz/3, c8050_riot2_intf) |
| 1248 | MDRV_MOS6530_ADD(M6530_TAG, XTAL_12MHz/3, c8050_riot2_intf) |
| 1245 | 1249 | |
| 1246 | 1250 | MDRV_FLOPPY_2_DRIVES_ADD(c8250_floppy_config) |
| 1247 | 1251 | MACHINE_DRIVER_END |
| r7183 | r7184 | |
| 1263 | 1267 | MDRV_CPU_PROGRAM_MAP(sfd1001_fdc_map) |
| 1264 | 1268 | |
| 1265 | 1269 | MDRV_VIA6522_ADD(M6522_TAG, XTAL_12MHz/3, c8050_via_intf) |
| 1266 | | MDRV_RIOT6532_ADD(M6530_TAG, XTAL_12MHz/3, c8050_riot2_intf) |
| 1270 | MDRV_MOS6530_ADD(M6530_TAG, XTAL_12MHz/3, c8050_riot2_intf) |
| 1267 | 1271 | |
| 1268 | 1272 | MDRV_FLOPPY_DRIVE_ADD(FLOPPY_0, c8250_floppy_config) |
| 1269 | 1273 | MACHINE_DRIVER_END |
| r7183 | r7184 | |
| 1392 | 1396 | c2040->unit[1].image = device_find_child_by_tag(device, FLOPPY_1); |
| 1393 | 1397 | |
| 1394 | 1398 | /* find GCR ROM */ |
| 1399 | //c2040->gcr = memory_region(device->machine, "c4040:c4040") + 0x3400; |
| 1395 | 1400 | |
| 1396 | 1401 | /* allocate data timer */ |
| 1397 | 1402 | c2040->bit_timer = timer_alloc(device->machine, bit_tick, (void *)device); |