src/mess/machine/applefdc.c
| r2543 | r2544 | |
| 58 | 58 | #define IWM_Q6 0x40 |
| 59 | 59 | #define IWM_Q7 0x80 |
| 60 | 60 | |
| 61 | typedef enum |
| 62 | { |
| 63 | APPLEFDC_APPLE2, /* classic Apple II disk controller (pre-IWM) */ |
| 64 | APPLEFDC_IWM, /* Integrated Woz Machine */ |
| 65 | APPLEFDC_SWIM /* Steve Woz Integrated Machine (NYI) */ |
| 66 | } applefdc_t; |
| 61 | 67 | |
| 62 | 68 | |
| 69 | |
| 63 | 70 | /*************************************************************************** |
| 64 | | LOCAL VARIABLES |
| 65 | | ***************************************************************************/ |
| 71 | IWM MODE |
| 66 | 72 | |
| 67 | | static UINT8 applefdc_writebyte=0; |
| 68 | | static UINT8 applefdc_lines; /* flags from IWM_MOTOR - IWM_Q7 */ |
| 73 | The IWM mode has the following values: |
| 69 | 74 | |
| 70 | | /* |
| 71 | | * IWM mode (iwm_mode): The IWM mode has the following values: |
| 72 | | * |
| 73 | | * Bit 7 Reserved |
| 74 | | * Bit 6 Reserved |
| 75 | | * Bit 5 Reserved |
| 76 | | * Bit 4 ! Clock speed |
| 77 | | * 0=7MHz; used by Apple IIgs |
| 78 | | * 1=8MHz; used by Mac (I believe) |
| 79 | | * Bit 3 ! Bit cell time |
| 80 | | * 0=4usec/bit (used for 5.25" drives) |
| 81 | | * 1=2usec/bit (used for 3.5" drives) |
| 82 | | * Bit 2 Motor-off delay |
| 83 | | * 0=leave on for 1 sec after system turns it off |
| 84 | | * 1=turn off immediately |
| 85 | | * Bit 1 ! Handshake protocol |
| 86 | | * 0=synchronous (software supplies timing for writing data; used for 5.25" drives) |
| 87 | | * 1=asynchronous (IWM supplies timing; used for 3.5" drives) |
| 88 | | * Bit 0 ! Latch mode |
| 89 | | * 0=read data stays valid for 7usec (used for 5.25" drives) |
| 90 | | * 1=read data stays valid for full byte time (used for 3.5" drives) |
| 91 | | */ |
| 75 | Bit 7 Reserved |
| 76 | Bit 6 Reserved |
| 77 | Bit 5 Reserved |
| 78 | Bit 4 ! Clock speed |
| 79 | 0=7MHz; used by Apple IIgs |
| 80 | 1=8MHz; used by Mac (I believe) |
| 81 | Bit 3 ! Bit cell time |
| 82 | 0=4usec/bit (used for 5.25" drives) |
| 83 | 1=2usec/bit (used for 3.5" drives) |
| 84 | Bit 2 Motor-off delay |
| 85 | 0=leave on for 1 sec after system turns it off |
| 86 | 1=turn off immediately |
| 87 | Bit 1 ! Handshake protocol |
| 88 | 0=synchronous (software supplies timing for writing data; used for 5.25" drives) |
| 89 | 1=asynchronous (IWM supplies timing; used for 3.5" drives) |
| 90 | Bit 0 ! Latch mode |
| 91 | 0=read data stays valid for 7usec (used for 5.25" drives) |
| 92 | 1=read data stays valid for full byte time (used for 3.5" drives) |
| 93 | |
| 94 | ***************************************************************************/ |
| 95 | |
| 92 | 96 | enum |
| 93 | 97 | { |
| 94 | 98 | IWM_MODE_CLOCKSPEED = 0x10, |
| r2543 | r2544 | |
| 98 | 102 | IWM_MODE_LATCHMODE = 0x01 |
| 99 | 103 | }; |
| 100 | 104 | |
| 101 | | static int iwm_mode; /* 0-31 */ |
| 102 | | static emu_timer *motor_timer; |
| 103 | | static applefdc_interface iwm_intf; |
| 104 | 105 | |
| 105 | 106 | |
| 107 | /*************************************************************************** |
| 108 | TYPE DEFINITIONS |
| 109 | ***************************************************************************/ |
| 106 | 110 | |
| 111 | typedef struct _applefdc_token applefdc_token; |
| 112 | struct _applefdc_token |
| 113 | { |
| 114 | /* data that is constant for the lifetime of the emulation */ |
| 115 | emu_timer *motor_timer; |
| 116 | applefdc_t type; |
| 117 | |
| 118 | /* data that changes at emulation time */ |
| 119 | UINT8 write_byte; |
| 120 | UINT8 lines; /* flags from IWM_MOTOR - IWM_Q7 */ |
| 121 | UINT8 mode; /* 0-31; see above */ |
| 122 | UINT8 handshake_hack; /* not sure what this is for */ |
| 123 | }; |
| 124 | |
| 125 | |
| 126 | |
| 107 | 127 | /*************************************************************************** |
| 108 | 128 | PROTOTYPES |
| 109 | 129 | ***************************************************************************/ |
| r2543 | r2544 | |
| 113 | 133 | |
| 114 | 134 | |
| 115 | 135 | /*************************************************************************** |
| 136 | INLINE FUNCTIONS |
| 137 | ***************************************************************************/ |
| 138 | |
| 139 | INLINE void assert_is_applefdc(const device_config *device) |
| 140 | { |
| 141 | assert(device != NULL); |
| 142 | assert((device->type == APPLEFDC) || (device->type == IWM) || (device->type == SWIM)); |
| 143 | } |
| 144 | |
| 145 | |
| 146 | |
| 147 | INLINE applefdc_token *get_token(const device_config *device) |
| 148 | { |
| 149 | assert_is_applefdc(device); |
| 150 | return (applefdc_token *) device->token; |
| 151 | } |
| 152 | |
| 153 | |
| 154 | |
| 155 | INLINE const applefdc_interface *get_interface(const device_config *device) |
| 156 | { |
| 157 | static const applefdc_interface dummy_interface = {0, }; |
| 158 | |
| 159 | assert_is_applefdc(device); |
| 160 | return (device->static_config != NULL) |
| 161 | ? (const applefdc_interface *) device->static_config |
| 162 | : &dummy_interface; |
| 163 | } |
| 164 | |
| 165 | |
| 166 | |
| 167 | /*************************************************************************** |
| 116 | 168 | CORE IMPLEMENTATION |
| 117 | 169 | ***************************************************************************/ |
| 118 | 170 | |
| 119 | | void applefdc_init(const applefdc_interface *intf) |
| 171 | /*------------------------------------------------- |
| 172 | applefdc_start - starts up an FDC |
| 173 | -------------------------------------------------*/ |
| 174 | |
| 175 | static void applefdc_start(const device_config *device, applefdc_t type) |
| 120 | 176 | { |
| 121 | | applefdc_lines = 0; |
| 122 | | iwm_mode = 0x1f; /* default value needed by Lisa 2 - no, I don't know if it is true */ |
| 123 | | motor_timer = timer_alloc(iwm_turnmotor_onoff, NULL); |
| 124 | | if (intf) |
| 125 | | iwm_intf = *intf; |
| 126 | | else |
| 127 | | memset(&iwm_intf, 0, sizeof(iwm_intf)); |
| 177 | applefdc_token *fdc = get_token(device); |
| 178 | |
| 179 | memset(fdc, 0, sizeof(*fdc)); |
| 180 | fdc->type = type; |
| 181 | fdc->motor_timer = timer_alloc(iwm_turnmotor_onoff, (void *) device); |
| 182 | fdc->lines = 0x00; |
| 183 | fdc->mode = 0x1F; /* default value needed by Lisa 2 - no, I don't know if it is true */ |
| 184 | |
| 185 | /* register save states */ |
| 186 | state_save_register_item("applefdc", 0, fdc->write_byte); |
| 187 | state_save_register_item("applefdc", 0, fdc->lines); |
| 188 | state_save_register_item("applefdc", 0, fdc->mode); |
| 189 | state_save_register_item("applefdc", 0, fdc->handshake_hack); |
| 128 | 190 | } |
| 129 | 191 | |
| 130 | 192 | |
| 131 | 193 | |
| 132 | 194 | /*------------------------------------------------- |
| 195 | DEVICE_RESET(applefdc) - resets an FDC |
| 196 | -------------------------------------------------*/ |
| 197 | |
| 198 | static DEVICE_RESET(applefdc) |
| 199 | { |
| 200 | applefdc_token *fdc = get_token(device); |
| 201 | |
| 202 | fdc->handshake_hack = 0x00; |
| 203 | fdc->write_byte = 0x00; |
| 204 | fdc->lines = 0x00; |
| 205 | fdc->mode = 0x1F; /* default value needed by Lisa 2 - no, I don't know if it is true */ |
| 206 | |
| 207 | timer_reset(fdc->motor_timer, attotime_never); |
| 208 | } |
| 209 | |
| 210 | |
| 211 | |
| 212 | /*------------------------------------------------- |
| 133 | 213 | iwm_enable2 - hackish function |
| 134 | 214 | -------------------------------------------------*/ |
| 135 | 215 | |
| 136 | | static int iwm_enable2(void) |
| 216 | static int iwm_enable2(const device_config *device) |
| 137 | 217 | { |
| 218 | applefdc_token *fdc = get_token(device); |
| 219 | |
| 138 | 220 | /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */ |
| 139 | 221 | /* it is not called from the Mac Plus driver */ |
| 140 | | return (applefdc_lines & APPLEFDC_PH1) && (applefdc_lines & APPLEFDC_PH3); |
| 222 | return (fdc->lines & APPLEFDC_PH1) && (fdc->lines & APPLEFDC_PH3); |
| 141 | 223 | } |
| 142 | 224 | |
| 143 | 225 | |
| r2543 | r2544 | |
| 146 | 228 | iwm_readenable2handshake - hackish function |
| 147 | 229 | -------------------------------------------------*/ |
| 148 | 230 | |
| 149 | | static int iwm_readenable2handshake(void) |
| 231 | static UINT8 iwm_readenable2handshake(const device_config *device) |
| 150 | 232 | { |
| 233 | applefdc_token *fdc = get_token(device); |
| 234 | |
| 151 | 235 | /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */ |
| 152 | 236 | /* it is not called from the Mac Plus driver */ |
| 153 | | |
| 154 | | static int val = 0; |
| 155 | | |
| 156 | | if (val++ > 3) |
| 157 | | val = 0; |
| 158 | | |
| 159 | | return val ? 0xc0 : 0x80; |
| 237 | fdc->handshake_hack++; |
| 238 | fdc->handshake_hack %= 4; |
| 239 | return (fdc->handshake_hack != 0) ? 0xc0 : 0x80; |
| 160 | 240 | } |
| 161 | 241 | |
| 162 | 242 | |
| r2543 | r2544 | |
| 165 | 245 | applefdc_statusreg_r - reads the status register |
| 166 | 246 | -------------------------------------------------*/ |
| 167 | 247 | |
| 168 | | static int applefdc_statusreg_r(void) |
| 248 | static UINT8 applefdc_statusreg_r(const device_config *device) |
| 169 | 249 | { |
| 250 | UINT8 result; |
| 251 | int status; |
| 252 | applefdc_token *fdc = get_token(device); |
| 253 | const applefdc_interface *intf = get_interface(device); |
| 254 | |
| 170 | 255 | /* IWM status: |
| 171 | 256 | * |
| 172 | 257 | * Bit 7 Sense input (write protect for 5.25" drive and general status line for 3.5") |
| r2543 | r2544 | |
| 175 | 260 | * Bits 4-0 Same as IWM mode bits 4-0 |
| 176 | 261 | */ |
| 177 | 262 | |
| 178 | | int result; |
| 179 | | int status; |
| 263 | status = iwm_enable2(device) ? 1 : (intf->read_status ? intf->read_status() : 0); |
| 180 | 264 | |
| 181 | | status = iwm_enable2() ? 1 : (iwm_intf.read_status ? iwm_intf.read_status() : 0); |
| 182 | | |
| 183 | 265 | result = (status ? 0x80 : 0x00); |
| 184 | 266 | |
| 185 | | if (iwm_intf.type != APPLEFDC_APPLE2) |
| 186 | | result |= (((applefdc_lines & IWM_MOTOR) ? 1 : 0) << 5) | iwm_mode; |
| 267 | if (fdc->type != APPLEFDC_APPLE2) |
| 268 | result |= (((fdc->lines & IWM_MOTOR) ? 1 : 0) << 5) | fdc->mode; |
| 187 | 269 | return result; |
| 188 | 270 | } |
| 189 | 271 | |
| r2543 | r2544 | |
| 193 | 275 | iwm_modereg_w - changes the mode register |
| 194 | 276 | -------------------------------------------------*/ |
| 195 | 277 | |
| 196 | | static void iwm_modereg_w(int data) |
| 278 | static void iwm_modereg_w(const device_config *device, UINT8 data) |
| 197 | 279 | { |
| 198 | | iwm_mode = data & 0x1f; /* Write mode register */ |
| 280 | applefdc_token *fdc = get_token(device); |
| 199 | 281 | |
| 282 | fdc->mode = data & 0x1f; /* write mode register */ |
| 283 | |
| 200 | 284 | if (LOG_APPLEFDC_EXTRA) |
| 201 | | logerror("iwm_modereg_w: iwm_mode=0x%02x\n", (int) iwm_mode); |
| 285 | logerror("iwm_modereg_w: iwm_mode=0x%02x\n", (unsigned) fdc->mode); |
| 202 | 286 | } |
| 203 | 287 | |
| 204 | 288 | |
| r2543 | r2544 | |
| 207 | 291 | applefdc_read_reg - reads a register |
| 208 | 292 | -------------------------------------------------*/ |
| 209 | 293 | |
| 210 | | static UINT8 applefdc_read_reg(int lines) |
| 294 | static UINT8 applefdc_read_reg(const device_config *device, int lines) |
| 211 | 295 | { |
| 296 | applefdc_token *fdc = get_token(device); |
| 297 | const applefdc_interface *intf = get_interface(device); |
| 212 | 298 | UINT8 result = 0; |
| 213 | 299 | |
| 214 | 300 | switch(lines) |
| 215 | 301 | { |
| 216 | 302 | case 0: |
| 217 | 303 | /* Read data register */ |
| 218 | | if ((iwm_intf.type != APPLEFDC_APPLE2) && (iwm_enable2() || !(applefdc_lines & IWM_MOTOR))) |
| 304 | if ((fdc->type != APPLEFDC_APPLE2) && (iwm_enable2(device) || !(fdc->lines & IWM_MOTOR))) |
| 219 | 305 | { |
| 220 | 306 | result = 0xFF; |
| 221 | 307 | } |
| r2543 | r2544 | |
| 228 | 314 | */ |
| 229 | 315 | if (LOG_APPLEFDC) |
| 230 | 316 | { |
| 231 | | if ((iwm_mode & IWM_MODE_LATCHMODE) == 0) |
| 317 | if ((fdc->mode & IWM_MODE_LATCHMODE) == 0x00) |
| 232 | 318 | logerror("applefdc_read_reg(): latch mode off not implemented\n"); |
| 233 | 319 | } |
| 234 | 320 | |
| 235 | | result = (iwm_intf.read_data ? iwm_intf.read_data() : 0); |
| 321 | result = (intf->read_data ? intf->read_data() : 0x00); |
| 236 | 322 | } |
| 237 | 323 | break; |
| 238 | 324 | |
| 239 | 325 | case IWM_Q6: |
| 240 | 326 | /* Read status register */ |
| 241 | | result = applefdc_statusreg_r(); |
| 327 | result = applefdc_statusreg_r(device); |
| 242 | 328 | break; |
| 243 | 329 | |
| 244 | 330 | case IWM_Q7: |
| 245 | 331 | /* Classic Apple II: Read status register |
| 246 | 332 | * IWM: Read handshake register |
| 247 | 333 | */ |
| 248 | | if (iwm_intf.type == APPLEFDC_APPLE2) |
| 249 | | result = applefdc_statusreg_r(); |
| 334 | if (fdc->type == APPLEFDC_APPLE2) |
| 335 | result = applefdc_statusreg_r(device); |
| 250 | 336 | else |
| 251 | | result = iwm_enable2() ? iwm_readenable2handshake() : 0x80; |
| 337 | result = iwm_enable2(device) ? iwm_readenable2handshake(device) : 0x80; |
| 252 | 338 | break; |
| 253 | 339 | } |
| 254 | 340 | return result; |
| r2543 | r2544 | |
| 260 | 346 | applefdc_write_reg - writes a register |
| 261 | 347 | -------------------------------------------------*/ |
| 262 | 348 | |
| 263 | | static void applefdc_write_reg(UINT8 data) |
| 349 | static void applefdc_write_reg(const device_config *device, UINT8 data) |
| 264 | 350 | { |
| 265 | | switch(applefdc_lines & (IWM_Q6 | IWM_Q7)) |
| 351 | applefdc_token *fdc = get_token(device); |
| 352 | const applefdc_interface *intf = get_interface(device); |
| 353 | |
| 354 | switch(fdc->lines & (IWM_Q6 | IWM_Q7)) |
| 266 | 355 | { |
| 267 | 356 | case IWM_Q6 | IWM_Q7: |
| 268 | | if (!(applefdc_lines & IWM_MOTOR)) |
| 357 | if (!(fdc->lines & IWM_MOTOR)) |
| 269 | 358 | { |
| 270 | | iwm_modereg_w(data); |
| 359 | iwm_modereg_w(device, data); |
| 271 | 360 | } |
| 272 | | else if (!iwm_enable2()) |
| 361 | else if (!iwm_enable2(device)) |
| 273 | 362 | { |
| 274 | 363 | /* |
| 275 | 364 | * Right now, this function assumes latch mode; which is always used for |
| r2543 | r2544 | |
| 278 | 367 | */ |
| 279 | 368 | if (LOG_APPLEFDC) |
| 280 | 369 | { |
| 281 | | if ((iwm_mode & IWM_MODE_LATCHMODE) == 0) |
| 370 | if ((fdc->mode & IWM_MODE_LATCHMODE) == 0) |
| 282 | 371 | logerror("applefdc_write_reg(): latch mode off not implemented\n"); |
| 283 | 372 | } |
| 284 | 373 | |
| 285 | | if (iwm_intf.write_data) |
| 286 | | iwm_intf.write_data(data); |
| 374 | if (intf->write_data != NULL) |
| 375 | intf->write_data(data); |
| 287 | 376 | } |
| 288 | 377 | break; |
| 289 | 378 | } |
| r2543 | r2544 | |
| 298 | 387 | |
| 299 | 388 | static TIMER_CALLBACK(iwm_turnmotor_onoff) |
| 300 | 389 | { |
| 390 | const device_config *device = (const device_config *) ptr; |
| 391 | applefdc_token *fdc = get_token(device); |
| 392 | const applefdc_interface *intf = get_interface(device); |
| 301 | 393 | int status = param; |
| 302 | 394 | int enable_lines; |
| 303 | 395 | |
| 304 | | if (status) |
| 396 | if (status != 0) |
| 305 | 397 | { |
| 306 | | applefdc_lines |= IWM_MOTOR; |
| 307 | | enable_lines = (applefdc_lines & IWM_DRIVE) ? 2 : 1; |
| 398 | fdc->lines |= IWM_MOTOR; |
| 399 | enable_lines = (fdc->lines & IWM_DRIVE) ? 2 : 1; |
| 308 | 400 | } |
| 309 | 401 | else |
| 310 | 402 | { |
| 311 | | applefdc_lines &= ~IWM_MOTOR; |
| 403 | fdc->lines &= ~IWM_MOTOR; |
| 312 | 404 | |
| 313 | | if (iwm_intf.type == APPLEFDC_APPLE2) |
| 314 | | enable_lines = (applefdc_lines & IWM_DRIVE) ? 2 : 1; |
| 405 | if (fdc->type == APPLEFDC_APPLE2) |
| 406 | enable_lines = (fdc->lines & IWM_DRIVE) ? 2 : 1; |
| 315 | 407 | else |
| 316 | 408 | enable_lines = 0; |
| 317 | 409 | } |
| 318 | 410 | |
| 319 | 411 | /* invoke callback, if present */ |
| 320 | | if (iwm_intf.set_enable_lines) |
| 321 | | iwm_intf.set_enable_lines(enable_lines); |
| 412 | if (intf->set_enable_lines != NULL) |
| 413 | intf->set_enable_lines(enable_lines); |
| 322 | 414 | |
| 323 | 415 | if (LOG_APPLEFDC_EXTRA) |
| 324 | 416 | logerror("iwm_turnmotor_onoff(): Turning motor %s\n", status ? "on" : "off"); |
| r2543 | r2544 | |
| 330 | 422 | iwm_access |
| 331 | 423 | -------------------------------------------------*/ |
| 332 | 424 | |
| 333 | | static void iwm_access(int offset) |
| 425 | static void iwm_access(const device_config *device, int offset) |
| 334 | 426 | { |
| 335 | 427 | static const char *const lines[] = |
| 336 | 428 | { |
| r2543 | r2544 | |
| 344 | 436 | "Q7" |
| 345 | 437 | }; |
| 346 | 438 | |
| 439 | applefdc_token *fdc = get_token(device); |
| 440 | const applefdc_interface *intf = get_interface(device); |
| 441 | |
| 347 | 442 | if (LOG_APPLEFDC_EXTRA) |
| 348 | 443 | { |
| 349 | 444 | logerror("iwm_access(): %s line %s\n", |
| r2543 | r2544 | |
| 351 | 446 | } |
| 352 | 447 | |
| 353 | 448 | if (offset & 1) |
| 354 | | applefdc_lines |= (1 << (offset >> 1)); |
| 449 | fdc->lines |= (1 << (offset >> 1)); |
| 355 | 450 | else |
| 356 | | applefdc_lines &= ~(1 << (offset >> 1)); |
| 451 | fdc->lines &= ~(1 << (offset >> 1)); |
| 357 | 452 | |
| 358 | | if ((offset < 0x08) && iwm_intf.set_lines) |
| 359 | | iwm_intf.set_lines(applefdc_lines & 0x0f); |
| 453 | if ((offset < 0x08) && (intf->set_lines != NULL)) |
| 454 | intf->set_lines(fdc->lines & 0x0f); |
| 360 | 455 | |
| 361 | 456 | switch(offset) |
| 362 | 457 | { |
| 363 | 458 | case 0x08: |
| 364 | | /* Turn off motor */ |
| 365 | | timer_adjust_oneshot(motor_timer, |
| 366 | | (iwm_mode & IWM_MODE_MOTOROFFDELAY) ? attotime_zero : ATTOTIME_IN_SEC(1), 0); |
| 459 | /* turn off motor */ |
| 460 | timer_adjust_oneshot(fdc->motor_timer, |
| 461 | (fdc->mode & IWM_MODE_MOTOROFFDELAY) ? attotime_zero : ATTOTIME_IN_SEC(1), 0); |
| 367 | 462 | break; |
| 368 | 463 | |
| 369 | 464 | case 0x09: |
| 370 | | /* Turn on motor */ |
| 371 | | timer_adjust_oneshot(motor_timer, attotime_zero, 1); |
| 465 | /* turn on motor */ |
| 466 | timer_adjust_oneshot(fdc->motor_timer, attotime_zero, 1); |
| 372 | 467 | break; |
| 373 | 468 | |
| 374 | 469 | case 0x0A: |
| 375 | 470 | /* turn off IWM_DRIVE */ |
| 376 | | if ((applefdc_lines & IWM_MOTOR) && iwm_intf.set_enable_lines) |
| 377 | | iwm_intf.set_enable_lines(1); |
| 471 | if ((fdc->lines & IWM_MOTOR) && (intf->set_enable_lines != NULL)) |
| 472 | intf->set_enable_lines(1); |
| 378 | 473 | break; |
| 379 | 474 | |
| 380 | 475 | case 0x0B: |
| 381 | 476 | /* turn on IWM_DRIVE */ |
| 382 | | if ((applefdc_lines & IWM_MOTOR) && iwm_intf.set_enable_lines) |
| 383 | | iwm_intf.set_enable_lines(2); |
| 477 | if ((fdc->lines & IWM_MOTOR) && (intf->set_enable_lines != NULL)) |
| 478 | intf->set_enable_lines(2); |
| 384 | 479 | break; |
| 385 | 480 | } |
| 386 | 481 | } |
| r2543 | r2544 | |
| 391 | 486 | applefdc_r - reads a byte from the FDC |
| 392 | 487 | -------------------------------------------------*/ |
| 393 | 488 | |
| 394 | | READ8_HANDLER( applefdc_r ) |
| 489 | READ8_DEVICE_HANDLER( applefdc_r ) |
| 395 | 490 | { |
| 491 | applefdc_token *fdc = get_token(device); |
| 492 | const applefdc_interface *intf = get_interface(device); |
| 396 | 493 | UINT8 result = 0; |
| 397 | 494 | |
| 398 | 495 | /* normalize offset */ |
| r2543 | r2544 | |
| 401 | 498 | if (LOG_APPLEFDC_EXTRA) |
| 402 | 499 | logerror("applefdc_r: offset=%i\n", offset); |
| 403 | 500 | |
| 404 | | iwm_access(offset); |
| 501 | iwm_access(device, offset); |
| 405 | 502 | |
| 406 | | switch(iwm_intf.type) |
| 503 | switch(fdc->type) |
| 407 | 504 | { |
| 408 | 505 | case APPLEFDC_APPLE2: |
| 409 | 506 | switch(offset) |
| 410 | 507 | { |
| 411 | 508 | case 0x0C: |
| 412 | | if (applefdc_lines & IWM_Q7) |
| 509 | if (fdc->lines & IWM_Q7) |
| 413 | 510 | { |
| 414 | | if (iwm_intf.write_data) |
| 415 | | iwm_intf.write_data(applefdc_writebyte); |
| 511 | if (intf->write_data != NULL) |
| 512 | intf->write_data(fdc->write_byte); |
| 416 | 513 | result = 0; |
| 417 | 514 | } |
| 418 | 515 | else |
| 419 | | result = applefdc_read_reg(0); |
| 516 | result = applefdc_read_reg(device, 0); |
| 420 | 517 | |
| 421 | 518 | break; |
| 422 | 519 | case 0x0D: |
| 423 | | result = applefdc_read_reg(IWM_Q6); |
| 520 | result = applefdc_read_reg(device, IWM_Q6); |
| 424 | 521 | break; |
| 425 | 522 | case 0x0E: |
| 426 | | result = applefdc_read_reg(IWM_Q7); |
| 523 | result = applefdc_read_reg(device, IWM_Q7); |
| 427 | 524 | break; |
| 428 | 525 | case 0x0F: |
| 429 | | result = applefdc_read_reg(IWM_Q7 | IWM_Q6); |
| 526 | result = applefdc_read_reg(device, IWM_Q7 | IWM_Q6); |
| 430 | 527 | break; |
| 431 | 528 | } |
| 432 | 529 | break; |
| 433 | 530 | |
| 434 | 531 | case APPLEFDC_IWM: |
| 435 | 532 | if ((offset & 1) == 0) |
| 436 | | result = applefdc_read_reg(applefdc_lines & (IWM_Q6 | IWM_Q7)); |
| 533 | result = applefdc_read_reg(device, fdc->lines & (IWM_Q6 | IWM_Q7)); |
| 437 | 534 | break; |
| 438 | 535 | |
| 439 | 536 | case APPLEFDC_SWIM: |
| r2543 | r2544 | |
| 449 | 546 | applefdc_w - writes a byte to the FDC |
| 450 | 547 | -------------------------------------------------*/ |
| 451 | 548 | |
| 452 | | WRITE8_HANDLER( applefdc_w ) |
| 549 | WRITE8_DEVICE_HANDLER( applefdc_w ) |
| 453 | 550 | { |
| 551 | applefdc_token *fdc = get_token(device); |
| 552 | const applefdc_interface *intf = get_interface(device); |
| 553 | |
| 454 | 554 | /* normalize offset */ |
| 455 | 555 | offset &= 15; |
| 456 | 556 | |
| 457 | 557 | if (LOG_APPLEFDC_EXTRA) |
| 458 | 558 | logerror("applefdc_w: offset=%i data=0x%02x\n", offset, data); |
| 459 | 559 | |
| 460 | | iwm_access(offset); |
| 560 | iwm_access(device, offset); |
| 461 | 561 | |
| 462 | | switch(iwm_intf.type) |
| 562 | switch(fdc->type) |
| 463 | 563 | { |
| 464 | 564 | case APPLEFDC_APPLE2: |
| 465 | 565 | switch(offset) |
| 466 | 566 | { |
| 467 | 567 | case 0x0C: |
| 468 | | if (applefdc_lines & IWM_Q7) |
| 568 | if (fdc->lines & IWM_Q7) |
| 469 | 569 | { |
| 470 | | if (iwm_intf.write_data) |
| 471 | | iwm_intf.write_data(applefdc_writebyte); |
| 570 | if (intf->write_data != NULL) |
| 571 | intf->write_data(fdc->write_byte); |
| 472 | 572 | } |
| 473 | 573 | break; |
| 474 | 574 | |
| 475 | 575 | case 0x0D: |
| 476 | | applefdc_writebyte = data; |
| 576 | fdc->write_byte = data; |
| 477 | 577 | break; |
| 478 | 578 | } |
| 479 | 579 | break; |
| 480 | 580 | |
| 481 | 581 | case APPLEFDC_IWM: |
| 482 | 582 | if (offset & 1) |
| 483 | | applefdc_write_reg(data); |
| 583 | applefdc_write_reg(device, data); |
| 484 | 584 | break; |
| 485 | 585 | |
| 486 | 586 | case APPLEFDC_SWIM: |
| r2543 | r2544 | |
| 495 | 595 | applefdc_w - writes a byte to the FDC |
| 496 | 596 | -------------------------------------------------*/ |
| 497 | 597 | |
| 498 | | UINT8 applefdc_get_lines(void) |
| 598 | UINT8 applefdc_get_lines(const device_config *device) |
| 499 | 599 | { |
| 500 | | return applefdc_lines & 0x0f; |
| 600 | applefdc_token *fdc = get_token(device); |
| 601 | return fdc->lines & 0x0f; |
| 501 | 602 | } |
| 603 | |
| 604 | |
| 605 | |
| 606 | /*************************************************************************** |
| 607 | INTERFACE |
| 608 | ***************************************************************************/ |
| 609 | |
| 610 | /*------------------------------------------------- |
| 611 | DEVICE_GET_INFO(applefdc_base) - device get info |
| 612 | callback |
| 613 | -------------------------------------------------*/ |
| 614 | |
| 615 | static DEVICE_GET_INFO(applefdc_base) |
| 616 | { |
| 617 | switch (state) |
| 618 | { |
| 619 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 620 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(applefdc_token); break; |
| 621 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 622 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 623 | |
| 624 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 625 | case DEVINFO_FCT_START: /* Nothing */ break; |
| 626 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 627 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(applefdc); break; |
| 628 | |
| 629 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 630 | case DEVINFO_STR_FAMILY: info->s = "Apple FDC"; break; |
| 631 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 632 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 633 | } |
| 634 | } |
| 635 | |
| 636 | |
| 637 | |
| 638 | /*------------------------------------------------- |
| 639 | DEVICE_START(oldfdc) - device start |
| 640 | callback |
| 641 | -------------------------------------------------*/ |
| 642 | |
| 643 | static DEVICE_START(oldfdc) |
| 644 | { |
| 645 | applefdc_start(device, APPLEFDC_APPLE2); |
| 646 | } |
| 647 | |
| 648 | |
| 649 | |
| 650 | /*------------------------------------------------- |
| 651 | DEVICE_GET_INFO(applefdc) - device get info |
| 652 | callback |
| 653 | -------------------------------------------------*/ |
| 654 | |
| 655 | DEVICE_GET_INFO(applefdc) |
| 656 | { |
| 657 | switch (state) |
| 658 | { |
| 659 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 660 | case DEVINFO_STR_NAME: info->s = "Apple FDC"; break; |
| 661 | |
| 662 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 663 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(oldfdc); break; |
| 664 | |
| 665 | default: DEVICE_GET_INFO_CALL(applefdc_base); break; |
| 666 | } |
| 667 | } |
| 668 | |
| 669 | |
| 670 | |
| 671 | /*------------------------------------------------- |
| 672 | DEVICE_START(iwm) - device start |
| 673 | callback |
| 674 | -------------------------------------------------*/ |
| 675 | |
| 676 | static DEVICE_START(iwm) |
| 677 | { |
| 678 | applefdc_start(device, APPLEFDC_IWM); |
| 679 | } |
| 680 | |
| 681 | |
| 682 | |
| 683 | /*------------------------------------------------- |
| 684 | DEVICE_GET_INFO(iwm) - device get info |
| 685 | callback |
| 686 | -------------------------------------------------*/ |
| 687 | |
| 688 | DEVICE_GET_INFO(iwm) |
| 689 | { |
| 690 | switch (state) |
| 691 | { |
| 692 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 693 | case DEVINFO_STR_NAME: info->s = "Apple IWM (Integrated Woz Machine)"; break; |
| 694 | |
| 695 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 696 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(iwm); break; |
| 697 | |
| 698 | default: DEVICE_GET_INFO_CALL(applefdc_base); break; |
| 699 | } |
| 700 | } |
| 701 | |
| 702 | |
| 703 | |
| 704 | /*------------------------------------------------- |
| 705 | DEVICE_START(iwm) - device start |
| 706 | callback |
| 707 | -------------------------------------------------*/ |
| 708 | |
| 709 | static DEVICE_START(swim) |
| 710 | { |
| 711 | applefdc_start(device, APPLEFDC_SWIM); |
| 712 | } |
| 713 | |
| 714 | |
| 715 | |
| 716 | /*------------------------------------------------- |
| 717 | DEVICE_GET_INFO(swim) - device get info |
| 718 | callback |
| 719 | -------------------------------------------------*/ |
| 720 | |
| 721 | DEVICE_GET_INFO(swim) |
| 722 | { |
| 723 | switch (state) |
| 724 | { |
| 725 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 726 | case DEVINFO_STR_NAME: info->s = "Apple SWIM (Steve Woz Integrated Machine)"; break; |
| 727 | |
| 728 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 729 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(swim); break; |
| 730 | |
| 731 | default: DEVICE_GET_INFO_CALL(applefdc_base); break; |
| 732 | } |
| 733 | } |
src/mess/machine/ap2_slot.c
| r0 | r2544 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | ap2_slot.c |
| 4 | |
| 5 | Implementation of Apple II device slots |
| 6 | |
| 7 | *********************************************************************/ |
| 8 | |
| 9 | #include "ap2_slot.h" |
| 10 | |
| 11 | |
| 12 | /*************************************************************************** |
| 13 | TYPE DEFINITIONS |
| 14 | ***************************************************************************/ |
| 15 | |
| 16 | typedef struct _apple2_slot_token apple2_slot_token; |
| 17 | struct _apple2_slot_token |
| 18 | { |
| 19 | const device_config *slot_device; |
| 20 | }; |
| 21 | |
| 22 | |
| 23 | |
| 24 | /*************************************************************************** |
| 25 | INLINE FUNCTIONS |
| 26 | ***************************************************************************/ |
| 27 | |
| 28 | INLINE void assert_valid(const device_config *device) |
| 29 | { |
| 30 | assert(device != NULL); |
| 31 | assert(device->type == APPLE2_SLOT); |
| 32 | } |
| 33 | |
| 34 | |
| 35 | |
| 36 | INLINE const apple2_slot_config *get_config(const device_config *device) |
| 37 | { |
| 38 | assert_valid(device); |
| 39 | return (const apple2_slot_config *) device->inline_config; |
| 40 | } |
| 41 | |
| 42 | |
| 43 | |
| 44 | INLINE apple2_slot_token *get_token(const device_config *device) |
| 45 | { |
| 46 | assert_valid(device); |
| 47 | return (apple2_slot_token *) device->token; |
| 48 | } |
| 49 | |
| 50 | |
| 51 | |
| 52 | /*************************************************************************** |
| 53 | CORE IMPLEMENTATION |
| 54 | ***************************************************************************/ |
| 55 | |
| 56 | /*------------------------------------------------- |
| 57 | apple2_slot - looks up a slot |
| 58 | -------------------------------------------------*/ |
| 59 | |
| 60 | const device_config *apple2_slot(running_machine *machine, int slotnum) |
| 61 | { |
| 62 | char buffer[7]; |
| 63 | |
| 64 | assert((slotnum >= 0) && (slotnum <= 7)); |
| 65 | snprintf(buffer, ARRAY_LENGTH(buffer), "slot_%d", slotnum); |
| 66 | |
| 67 | return device_list_find_by_tag( |
| 68 | machine->config->devicelist, |
| 69 | APPLE2_SLOT, |
| 70 | buffer); |
| 71 | } |
| 72 | |
| 73 | |
| 74 | |
| 75 | /*------------------------------------------------- |
| 76 | DEVICE_START(apple2_slot) - device start |
| 77 | function |
| 78 | -------------------------------------------------*/ |
| 79 | |
| 80 | static DEVICE_START(apple2_slot) |
| 81 | { |
| 82 | const apple2_slot_config *config = get_config(device); |
| 83 | apple2_slot_token *token = get_token(device); |
| 84 | |
| 85 | if (config->tag != NULL) |
| 86 | { |
| 87 | /* locate the device */ |
| 88 | token->slot_device = device_list_find_by_tag( |
| 89 | device->machine->config->devicelist, |
| 90 | DEVICE_TYPE_WILDCARD, |
| 91 | config->tag); |
| 92 | |
| 93 | assert(token->slot_device != NULL); |
| 94 | } |
| 95 | else |
| 96 | { |
| 97 | token->slot_device = NULL; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | |
| 103 | /*------------------------------------------------- |
| 104 | apple2_slot_r - slot read function |
| 105 | -------------------------------------------------*/ |
| 106 | |
| 107 | READ8_DEVICE_HANDLER(apple2_slot_r) |
| 108 | { |
| 109 | UINT8 result = 0x00; |
| 110 | const apple2_slot_config *config = get_config(device); |
| 111 | apple2_slot_token *token = get_token(device); |
| 112 | |
| 113 | /* do we actually have a device, and can we read? */ |
| 114 | if ((token->slot_device != NULL) && (config->rh != NULL)) |
| 115 | { |
| 116 | result = (*config->rh)(token->slot_device, offset); |
| 117 | } |
| 118 | |
| 119 | return result; |
| 120 | } |
| 121 | |
| 122 | |
| 123 | |
| 124 | /*------------------------------------------------- |
| 125 | apple2_slot_w - slot write function |
| 126 | -------------------------------------------------*/ |
| 127 | |
| 128 | WRITE8_DEVICE_HANDLER(apple2_slot_w) |
| 129 | { |
| 130 | const apple2_slot_config *config = get_config(device); |
| 131 | apple2_slot_token *token = get_token(device); |
| 132 | |
| 133 | /* do we actually have a device, and can we read? */ |
| 134 | if ((token->slot_device != NULL) && (config->wh != NULL)) |
| 135 | { |
| 136 | (*config->wh)(token->slot_device, offset, data); |
| 137 | } |
| 138 | } |
| 139 | |
| 140 | |
| 141 | |
| 142 | /*------------------------------------------------- |
| 143 | DEVICE_GET_INFO(apple2_slot) - device get info |
| 144 | function |
| 145 | -------------------------------------------------*/ |
| 146 | |
| 147 | DEVICE_GET_INFO(apple2_slot) |
| 148 | { |
| 149 | switch (state) |
| 150 | { |
| 151 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 152 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(apple2_slot_token); break; |
| 153 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = sizeof(apple2_slot_config); break; |
| 154 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 155 | |
| 156 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 157 | case DEVINFO_FCT_SET_INFO: /* Nothing */ break; |
| 158 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(apple2_slot); break; |
| 159 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 160 | case DEVINFO_FCT_RESET: /* Nothing */ break; |
| 161 | |
| 162 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 163 | case DEVINFO_STR_NAME: info->s = "Apple II Slot"; break; |
| 164 | case DEVINFO_STR_FAMILY: info->s = "Apple II Slot"; break; |
| 165 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 166 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 167 | } |
| 168 | } |
src/mess/machine/mockngbd.c
| r0 | r2544 | |
| 1 | /********************************************************************* |
| 2 | |
| 3 | mockngbd.c |
| 4 | |
| 5 | Implementation of the Apple II Mockingboard |
| 6 | |
| 7 | TODO - When sound cores and the 6522 VIA become devices, and devices |
| 8 | can contain other devices, start containing AY8910 and 6522VIA |
| 9 | implementations |
| 10 | |
| 11 | *********************************************************************/ |
| 12 | |
| 13 | #include "mockngbd.h" |
| 14 | #include "sound/ay8910.h" |
| 15 | |
| 16 | |
| 17 | /*************************************************************************** |
| 18 | PARAMETERS |
| 19 | ***************************************************************************/ |
| 20 | |
| 21 | #define LOG_MOCKINGBOARD 0 |
| 22 | |
| 23 | |
| 24 | /*************************************************************************** |
| 25 | TYPE DEFINITIONS |
| 26 | ***************************************************************************/ |
| 27 | |
| 28 | typedef struct _mockingboard_token mockingboard_token; |
| 29 | struct _mockingboard_token |
| 30 | { |
| 31 | UINT8 flip1; |
| 32 | UINT8 flip2; |
| 33 | UINT8 latch0; |
| 34 | UINT8 latch1; |
| 35 | }; |
| 36 | |
| 37 | |
| 38 | /*************************************************************************** |
| 39 | INLINE FUNCTIONS |
| 40 | ***************************************************************************/ |
| 41 | |
| 42 | INLINE mockingboard_token *get_token(const device_config *device) |
| 43 | { |
| 44 | assert(device != NULL); |
| 45 | assert(device->type == MOCKINGBOARD); |
| 46 | return (mockingboard_token *) device->token; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | |
| 51 | /*************************************************************************** |
| 52 | FUNCTION PROTOTYPES |
| 53 | ***************************************************************************/ |
| 54 | |
| 55 | /*------------------------------------------------- |
| 56 | DEVICE_START(mockingboard) - device start |
| 57 | function |
| 58 | -------------------------------------------------*/ |
| 59 | |
| 60 | static DEVICE_START(mockingboard) |
| 61 | { |
| 62 | } |
| 63 | |
| 64 | |
| 65 | |
| 66 | /*------------------------------------------------- |
| 67 | DEVICE_RESET(mockingboard) - device reset |
| 68 | function |
| 69 | -------------------------------------------------*/ |
| 70 | |
| 71 | static DEVICE_RESET(mockingboard) |
| 72 | { |
| 73 | mockingboard_token *token = get_token(device); |
| 74 | token->flip1 = 0x00; |
| 75 | token->flip2 = 0x00; |
| 76 | token->latch0 = 0x00; |
| 77 | token->latch1 = 0x00; |
| 78 | |
| 79 | /* TODO: fix this */ |
| 80 | /* What follows is pure filth. It abuses the core like an angry pimp on a bad hair day. */ |
| 81 | |
| 82 | /* Since we know that the Mockingboard has no code ROM, we'll copy into the slot ROM space |
| 83 | an image of the onboard ROM so that when an IRQ bankswitches to the onboard ROM, we read |
| 84 | the proper stuff. Without this, it will choke and try to use the memory handler above, and |
| 85 | fail miserably. That should really be fixed. I beg you -- if you are reading this comment, |
| 86 | fix this :) */ |
| 87 | // memcpy (apple2_slotrom(slot), &apple_rom[0x0000 + (slot * 0x100)], 0x100); |
| 88 | } |
| 89 | |
| 90 | |
| 91 | |
| 92 | /*------------------------------------------------- |
| 93 | mockingboard_r - device read function |
| 94 | -------------------------------------------------*/ |
| 95 | |
| 96 | READ8_DEVICE_HANDLER(mockingboard_r) |
| 97 | { |
| 98 | UINT8 result = 0x00; |
| 99 | mockingboard_token *token = get_token(device); |
| 100 | |
| 101 | switch (offset) |
| 102 | { |
| 103 | /* This is used to ID the board */ |
| 104 | case 0x04: |
| 105 | token->flip1 ^= 0x08; |
| 106 | result = token->flip1; |
| 107 | break; |
| 108 | |
| 109 | case 0x84: |
| 110 | token->flip2 ^= 0x08; |
| 111 | result = token->flip2; |
| 112 | break; |
| 113 | |
| 114 | default: |
| 115 | if (LOG_MOCKINGBOARD) |
| 116 | logerror("mockingboard_r unmapped, offset: %02x, pc: %04x\n", offset, (unsigned) cpunum_get_reg(0, REG_PC)); |
| 117 | break; |
| 118 | } |
| 119 | return 0x00; |
| 120 | } |
| 121 | |
| 122 | |
| 123 | |
| 124 | /*------------------------------------------------- |
| 125 | mockingboard_w - device write function |
| 126 | -------------------------------------------------*/ |
| 127 | |
| 128 | WRITE8_DEVICE_HANDLER(mockingboard_w) |
| 129 | { |
| 130 | mockingboard_token *token = get_token(device); |
| 131 | |
| 132 | if (LOG_MOCKINGBOARD) |
| 133 | logerror("mockingboard_w, $%02x:%02x\n", offset, data); |
| 134 | |
| 135 | /* There is a 6522 in here which interfaces to the 8910s */ |
| 136 | switch (offset) |
| 137 | { |
| 138 | case 0x00: /* ORB1 */ |
| 139 | switch (data) |
| 140 | { |
| 141 | case 0x00: /* reset */ |
| 142 | sndti_reset(SOUND_AY8910, 0); |
| 143 | break; |
| 144 | case 0x04: /* make inactive */ |
| 145 | break; |
| 146 | case 0x06: /* write data */ |
| 147 | AY8910_write_port_0_w(device->machine, 0, token->latch0); |
| 148 | break; |
| 149 | case 0x07: /* set register */ |
| 150 | AY8910_control_port_0_w(device->machine, 0, token->latch0); |
| 151 | break; |
| 152 | } |
| 153 | break; |
| 154 | |
| 155 | case 0x01: /* ORA1 */ |
| 156 | token->latch0 = data; |
| 157 | break; |
| 158 | |
| 159 | case 0x02: /* DDRB1 */ |
| 160 | case 0x03: /* DDRA1 */ |
| 161 | break; |
| 162 | |
| 163 | case 0x80: /* ORB2 */ |
| 164 | switch (data) |
| 165 | { |
| 166 | case 0x00: /* reset */ |
| 167 | sndti_reset(SOUND_AY8910, 1); |
| 168 | break; |
| 169 | case 0x04: /* make inactive */ |
| 170 | break; |
| 171 | case 0x06: /* write data */ |
| 172 | AY8910_write_port_1_w(device->machine, 0, token->latch1); |
| 173 | break; |
| 174 | case 0x07: /* set register */ |
| 175 | AY8910_control_port_1_w(device->machine, 0, token->latch1); |
| 176 | break; |
| 177 | } |
| 178 | break; |
| 179 | |
| 180 | case 0x81: /* ORA2 */ |
| 181 | token->latch1 = data; |
| 182 | break; |
| 183 | |
| 184 | case 0x82: /* DDRB2 */ |
| 185 | case 0x83: /* DDRA2 */ |
| 186 | break; |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | |
| 191 | |
| 192 | /*------------------------------------------------- |
| 193 | DEVICE_GET_INFO(mockingboard) - device get info |
| 194 | function |
| 195 | -------------------------------------------------*/ |
| 196 | |
| 197 | DEVICE_GET_INFO(mockingboard) |
| 198 | { |
| 199 | switch (state) |
| 200 | { |
| 201 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 202 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(mockingboard_token); break; |
| 203 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 204 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 205 | |
| 206 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 207 | case DEVINFO_FCT_SET_INFO: /* Nothing */ break; |
| 208 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(mockingboard); break; |
| 209 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 210 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(mockingboard); break; |
| 211 | |
| 212 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 213 | case DEVINFO_STR_NAME: info->s = "Apple II Mockingboard"; break; |
| 214 | case DEVINFO_STR_FAMILY: info->s = "Apple II Mockingboard"; break; |
| 215 | case DEVINFO_STR_VERSION: info->s = "1.0"; break; |
| 216 | case DEVINFO_STR_SOURCE_FILE: info->s = __FILE__; break; |
| 217 | } |
| 218 | } |
src/mess/machine/oric.c
| r2543 | r2544 | |
| 495 | 495 | |
| 496 | 496 | static void oric_install_apple2_interface(running_machine *machine) |
| 497 | 497 | { |
| 498 | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 499 | APPLEFDC, |
| 500 | "fdc"); |
| 501 | |
| 498 | 502 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0300, 0x030f, 0, 0, oric_IO_r); |
| 499 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_r); |
| 503 | memory_install_read8_device_handler(fdc, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_r); |
| 500 | 504 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0320, 0x03ff, 0, 0, SMH_BANK4); |
| 501 | 505 | |
| 502 | 506 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0300, 0x030f, 0, 0, oric_IO_w); |
| 503 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_w); |
| 507 | memory_install_write8_device_handler(fdc, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_w); |
| 504 | 508 | memory_set_bankptr(4, memory_region(REGION_CPU1) + 0x014000 + 0x020); |
| 505 | 509 | } |
| 506 | 510 | |
| r2543 | r2544 | |
| 585 | 589 | /* APPLE 2 INTERFACE V2 */ |
| 586 | 590 | static void oric_install_apple2_v2_interface(running_machine *machine) |
| 587 | 591 | { |
| 592 | const device_config *fdc = device_list_find_by_tag(machine->config->devicelist, |
| 593 | APPLEFDC, |
| 594 | "fdc"); |
| 595 | |
| 588 | 596 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0300, 0x030f, 0, 0, oric_IO_r); |
| 589 | | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_r); |
| 597 | memory_install_read8_device_handler(fdc, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_r); |
| 590 | 598 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0320, 0x03ff, 0, 0, SMH_BANK4); |
| 591 | 599 | |
| 592 | 600 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0300, 0x030f, 0, 0, oric_IO_w); |
| 593 | | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_w); |
| 601 | memory_install_write8_device_handler(fdc, 0, ADDRESS_SPACE_PROGRAM, 0x0310, 0x031f, 0, 0, applefdc_w); |
| 594 | 602 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0380, 0x0383, 0, 0, apple2_v2_interface_w); |
| 595 | 603 | |
| 596 | 604 | apple2_v2_interface_w(machine, 0, 0); |
src/mess/machine/apple2.c
| r2543 | r2544 | |
| 15 | 15 | #include "deprecat.h" |
| 16 | 16 | #include "cpu/m6502/m6502.h" |
| 17 | 17 | #include "includes/apple2.h" |
| 18 | #include "machine/ap2_slot.h" |
| 18 | 19 | #include "machine/ay3600.h" |
| 19 | 20 | #include "machine/applefdc.h" |
| 20 | 21 | #include "devices/sonydriv.h" |
| 21 | 22 | #include "devices/appldriv.h" |
| 22 | 23 | #include "devices/flopdrv.h" |
| 23 | 24 | #include "sound/dac.h" |
| 24 | | #include "sound/ay8910.h" |
| 25 | 25 | #include "profiler.h" |
| 26 | 26 | |
| 27 | 27 | #ifdef MAME_DEBUG |
| r2543 | r2544 | |
| 46 | 46 | |
| 47 | 47 | |
| 48 | 48 | /* local */ |
| 49 | | static apple2_config *a2_config; |
| 50 | | static void **a2_slot_tokens; |
| 51 | 49 | static int a2_speaker_state; |
| 52 | 50 | |
| 53 | 51 | static double joystick_x1_time; |
| r2543 | r2544 | |
| 318 | 316 | apple2_c07x_r |
| 319 | 317 | }; |
| 320 | 318 | UINT8 result = 0x00; |
| 321 | | int slot; |
| 319 | int slotnum; |
| 320 | const device_config *slotdevice; |
| 322 | 321 | |
| 323 | 322 | offset &= 0xFF; |
| 324 | 323 | |
| 325 | 324 | if (offset < 0x80) |
| 326 | 325 | { |
| 326 | /* normal handler */ |
| 327 | 327 | if (handlers[offset / 0x10]) |
| 328 | 328 | result = handlers[offset / 0x10](machine, offset % 0x10); |
| 329 | 329 | } |
| 330 | 330 | else |
| 331 | 331 | { |
| 332 | | slot = (offset - 0x80) / 0x10; |
| 333 | | if (a2_config->slots[slot] && a2_config->slots[slot]->read) |
| 334 | | result = a2_config->slots[slot]->read(machine, a2_slot_tokens[slot], offset % 0x10); |
| 332 | /* slot handler; identify the slot number */ |
| 333 | slotnum = (offset - 0x80) / 0x10; |
| 334 | |
| 335 | /* now identify the device */ |
| 336 | slotdevice = apple2_slot(machine, slotnum); |
| 337 | |
| 338 | /* and if we can, read from the slot */ |
| 339 | if (slotdevice != NULL) |
| 340 | result = apple2_slot_r(slotdevice, offset % 0x10); |
| 335 | 341 | } |
| 336 | 342 | return result; |
| 337 | 343 | } |
| r2543 | r2544 | |
| 351 | 357 | NULL, |
| 352 | 358 | apple2_c07x_w |
| 353 | 359 | }; |
| 354 | | int slot; |
| 360 | int slotnum; |
| 361 | const device_config *slotdevice; |
| 355 | 362 | |
| 356 | 363 | offset &= 0xFF; |
| 357 | 364 | |
| 358 | 365 | if (offset < 0x80) |
| 359 | 366 | { |
| 367 | /* normal handler */ |
| 360 | 368 | if (handlers[offset / 0x10]) |
| 361 | 369 | handlers[offset / 0x10](machine, offset % 0x10, data); |
| 362 | 370 | } |
| 363 | 371 | else |
| 364 | 372 | { |
| 365 | | slot = (offset - 0x80) / 0x10; |
| 366 | | if (a2_config->slots[slot] && a2_config->slots[slot]->write) |
| 367 | | a2_config->slots[slot]->write(machine, a2_slot_tokens[slot], offset % 0x10, data); |
| 373 | /* slot handler; identify the slot number */ |
| 374 | slotnum = (offset - 0x80) / 0x10; |
| 375 | |
| 376 | /* now identify the device */ |
| 377 | slotdevice = apple2_slot(machine, slotnum); |
| 378 | |
| 379 | /* and if we can, write to the slot */ |
| 380 | if (slotdevice != NULL) |
| 381 | apple2_slot_w(slotdevice, offset % 0x10, data); |
| 368 | 382 | } |
| 369 | 383 | } |
| 370 | 384 | |
| r2543 | r2544 | |
| 727 | 741 | |
| 728 | 742 | static void apple2_reset(running_machine *machine) |
| 729 | 743 | { |
| 730 | | int need_intcxrom, i; |
| 744 | int need_intcxrom; |
| 731 | 745 | |
| 732 | 746 | need_intcxrom = !strcmp(machine->gamedrv->name, "apple2c") |
| 733 | 747 | || !strcmp(machine->gamedrv->name, "apple2c0") |
| r2543 | r2544 | |
| 744 | 758 | |
| 745 | 759 | a2_speaker_state = 0; |
| 746 | 760 | |
| 747 | | /* reset slots */ |
| 748 | | for (i = 0; i < APPLE2_SLOT_COUNT; i++) |
| 749 | | { |
| 750 | | if (a2_config->slots[i]) |
| 751 | | { |
| 752 | | if (a2_config->slots[i]->reset) |
| 753 | | a2_config->slots[i]->reset(machine, a2_slot_tokens[i]); |
| 754 | | } |
| 755 | | } |
| 756 | | |
| 757 | 761 | joystick_x1_time = joystick_y1_time = 0; |
| 758 | 762 | joystick_x2_time = joystick_y2_time = 0; |
| 759 | 763 | } |
| r2543 | r2544 | |
| 1091 | 1095 | |
| 1092 | 1096 | |
| 1093 | 1097 | |
| 1094 | | /*************************************************************************** |
| 1095 | | apple2_c08x_r |
| 1096 | | ***************************************************************************/ |
| 1097 | | |
| 1098 | | static READ8_HANDLER ( apple2_c08x_r ) |
| 1099 | | { |
| 1100 | | UINT32 val, mask; |
| 1101 | | |
| 1102 | | profiler_mark(PROFILER_C08X); |
| 1103 | | LOG(("language card bankswitch read, offset: $c08%0x\n", offset)); |
| 1104 | | |
| 1105 | | mask = VAR_LCWRITE | VAR_LCRAM | VAR_LCRAM2; |
| 1106 | | val = 0; |
| 1107 | | |
| 1108 | | if (offset & 0x01) |
| 1109 | | val |= VAR_LCWRITE; |
| 1110 | | |
| 1111 | | switch(offset & 0x03) |
| 1112 | | { |
| 1113 | | case 0x03: |
| 1114 | | case 0x00: |
| 1115 | | val |= VAR_LCRAM; |
| 1116 | | break; |
| 1117 | | } |
| 1118 | | |
| 1119 | | if ((offset & 0x08) == 0) |
| 1120 | | val |= VAR_LCRAM2; |
| 1121 | | |
| 1122 | | apple2_setvar(val, mask); |
| 1123 | | |
| 1124 | | profiler_mark(PROFILER_END); |
| 1125 | | return 0; |
| 1126 | | } |
| 1127 | | |
| 1128 | | |
| 1129 | | |
| 1130 | | /*************************************************************************** |
| 1131 | | apple2_c08x_w |
| 1132 | | ***************************************************************************/ |
| 1133 | | |
| 1134 | | static WRITE8_HANDLER ( apple2_c08x_w ) |
| 1135 | | { |
| 1136 | | apple2_c08x_r(machine, offset); |
| 1137 | | } |
| 1138 | | |
| 1139 | | |
| 1140 | | |
| 1141 | 1098 | /* ----------------------------------------------------------------------- |
| 1142 | | * Language Card |
| 1099 | * Floppy disk controller |
| 1143 | 1100 | * ----------------------------------------------------------------------- */ |
| 1144 | 1101 | |
| 1145 | | static UINT8 apple2_langcard_read(running_machine *machine, void *token, offs_t offset) |
| 1146 | | { |
| 1147 | | return apple2_c08x_r(machine, offset); |
| 1102 | static int apple2_fdc_diskreg; |
| 1148 | 1103 | |
| 1149 | | } |
| 1150 | | |
| 1151 | | |
| 1152 | | |
| 1153 | | static void apple2_langcard_write(running_machine *machine, void *token, offs_t offset, UINT8 data) |
| 1104 | static int apple2_fdc_has_35(void) |
| 1154 | 1105 | { |
| 1155 | | apple2_c08x_w(machine, offset, data); |
| 1106 | return device_count_tag_from_machine(Machine, "sonydriv") > 0; |
| 1156 | 1107 | } |
| 1157 | 1108 | |
| 1158 | | |
| 1159 | | |
| 1160 | | const apple2_slotdevice apple2_slot_langcard = |
| 1109 | static int apple2_fdc_has_525(void) |
| 1161 | 1110 | { |
| 1162 | | "langcard", |
| 1163 | | "Language Card", |
| 1164 | | NULL, |
| 1165 | | NULL, |
| 1166 | | apple2_langcard_read, |
| 1167 | | apple2_langcard_write |
| 1168 | | }; |
| 1169 | | |
| 1170 | | |
| 1171 | | |
| 1172 | | /* ----------------------------------------------------------------------- |
| 1173 | | * Mockingboard |
| 1174 | | * ----------------------------------------------------------------------- */ |
| 1175 | | |
| 1176 | | static void apple2_mockingboard_reset(running_machine *machine, void *token) |
| 1177 | | { |
| 1178 | | /* TODO: fix this */ |
| 1179 | | /* What follows is pure filth. It abuses the core like an angry pimp on a bad hair day. */ |
| 1180 | | |
| 1181 | | /* Since we know that the Mockingboard has no code ROM, we'll copy into the slot ROM space |
| 1182 | | an image of the onboard ROM so that when an IRQ bankswitches to the onboard ROM, we read |
| 1183 | | the proper stuff. Without this, it will choke and try to use the memory handler above, and |
| 1184 | | fail miserably. That should really be fixed. I beg you -- if you are reading this comment, |
| 1185 | | fix this :) */ |
| 1186 | | // memcpy (apple2_slotrom(slot), &apple_rom[0x0000 + (slot * 0x100)], 0x100); |
| 1111 | return device_count_tag_from_machine(Machine, "apple525driv") > 0; |
| 1187 | 1112 | } |
| 1188 | 1113 | |
| 1189 | | |
| 1190 | | |
| 1191 | | static UINT8 apple2_mockingboard_read(running_machine *machine, void *token, offs_t offset) |
| 1192 | | { |
| 1193 | | static int flip1 = 0, flip2 = 0; |
| 1194 | | |
| 1195 | | switch (offset) |
| 1196 | | { |
| 1197 | | /* This is used to ID the board */ |
| 1198 | | case 0x04: |
| 1199 | | flip1 ^= 0x08; |
| 1200 | | return flip1; |
| 1201 | | break; |
| 1202 | | case 0x84: |
| 1203 | | flip2 ^= 0x08; |
| 1204 | | return flip2; |
| 1205 | | break; |
| 1206 | | default: |
| 1207 | | LOG(("mockingboard_r unmapped, offset: %02x, pc: %04x\n", offset, (unsigned) cpunum_get_reg(0, REG_PC))); |
| 1208 | | break; |
| 1209 | | } |
| 1210 | | return 0x00; |
| 1211 | | } |
| 1212 | | |
| 1213 | | |
| 1214 | | |
| 1215 | | static void apple2_mockingboard_write(running_machine *machine, void *token, offs_t offset, UINT8 data) |
| 1216 | | { |
| 1217 | | static int latch0, latch1; |
| 1218 | | |
| 1219 | | LOG(("mockingboard_w, $%02x:%02x\n", offset, data)); |
| 1220 | | |
| 1221 | | /* There is a 6522 in here which interfaces to the 8910s */ |
| 1222 | | switch (offset) |
| 1223 | | { |
| 1224 | | case 0x00: /* ORB1 */ |
| 1225 | | switch (data) |
| 1226 | | { |
| 1227 | | case 0x00: /* reset */ |
| 1228 | | sndti_reset(SOUND_AY8910, 0); |
| 1229 | | break; |
| 1230 | | case 0x04: /* make inactive */ |
| 1231 | | break; |
| 1232 | | case 0x06: /* write data */ |
| 1233 | | AY8910_write_port_0_w (machine, 0, latch0); |
| 1234 | | break; |
| 1235 | | case 0x07: /* set register */ |
| 1236 | | AY8910_control_port_0_w (machine, 0, latch0); |
| 1237 | | break; |
| 1238 | | } |
| 1239 | | break; |
| 1240 | | |
| 1241 | | case 0x01: /* ORA1 */ |
| 1242 | | latch0 = data; |
| 1243 | | break; |
| 1244 | | |
| 1245 | | case 0x02: /* DDRB1 */ |
| 1246 | | case 0x03: /* DDRA1 */ |
| 1247 | | break; |
| 1248 | | |
| 1249 | | case 0x80: /* ORB2 */ |
| 1250 | | switch (data) |
| 1251 | | { |
| 1252 | | case 0x00: /* reset */ |
| 1253 | | sndti_reset(SOUND_AY8910, 1); |
| 1254 | | break; |
| 1255 | | case 0x04: /* make inactive */ |
| 1256 | | break; |
| 1257 | | case 0x06: /* write data */ |
| 1258 | | AY8910_write_port_1_w (machine, 0, latch1); |
| 1259 | | break; |
| 1260 | | case 0x07: /* set register */ |
| 1261 | | AY8910_control_port_1_w (machine, 0, latch1); |
| 1262 | | break; |
| 1263 | | } |
| 1264 | | break; |
| 1265 | | |
| 1266 | | case 0x81: /* ORA2 */ |
| 1267 | | latch1 = data; |
| 1268 | | break; |
| 1269 | | |
| 1270 | | case 0x82: /* DDRB2 */ |
| 1271 | | case 0x83: /* DDRA2 */ |
| 1272 | | break; |
| 1273 | | } |
| 1274 | | } |
| 1275 | | |
| 1276 | | |
| 1277 | | |
| 1278 | | const apple2_slotdevice apple2_slot_mockingboard = |
| 1279 | | { |
| 1280 | | "mockingboard", |
| 1281 | | "Mockingboard", |
| 1282 | | NULL, |
| 1283 | | apple2_mockingboard_reset, |
| 1284 | | apple2_mockingboard_read, |
| 1285 | | apple2_mockingboard_write |
| 1286 | | }; |
| 1287 | | |
| 1288 | | |
| 1289 | | |
| 1290 | | /* ----------------------------------------------------------------------- |
| 1291 | | * Floppy disk controller |
| 1292 | | * ----------------------------------------------------------------------- */ |
| 1293 | | |
| 1294 | | static int apple2_fdc_has_35; |
| 1295 | | static int apple2_fdc_has_525; |
| 1296 | | static int apple2_fdc_diskreg; |
| 1297 | | |
| 1298 | 1114 | static void apple2_fdc_set_lines(UINT8 lines) |
| 1299 | 1115 | { |
| 1300 | 1116 | if (apple2_fdc_diskreg & 0x40) |
| 1301 | 1117 | { |
| 1302 | | if (apple2_fdc_has_35) |
| 1118 | if (apple2_fdc_has_35()) |
| 1303 | 1119 | { |
| 1304 | 1120 | /* slot 5: 3.5" disks */ |
| 1305 | 1121 | sony_set_lines(lines); |
| r2543 | r2544 | |
| 1307 | 1123 | } |
| 1308 | 1124 | else |
| 1309 | 1125 | { |
| 1310 | | if (apple2_fdc_has_525) |
| 1126 | if (apple2_fdc_has_525()) |
| 1311 | 1127 | { |
| 1312 | 1128 | /* slot 6: 5.25" disks */ |
| 1313 | 1129 | apple525_set_lines(lines); |
| r2543 | r2544 | |
| 1327 | 1143 | else |
| 1328 | 1144 | slot6_enable_mask = enable_mask; |
| 1329 | 1145 | |
| 1330 | | if (apple2_fdc_has_35) |
| 1146 | if (apple2_fdc_has_35()) |
| 1331 | 1147 | { |
| 1332 | 1148 | /* set the 3.5" enable lines */ |
| 1333 | 1149 | sony_set_enable_lines(slot5_enable_mask); |
| 1334 | 1150 | } |
| 1335 | 1151 | |
| 1336 | | if (apple2_fdc_has_525) |
| 1152 | if (apple2_fdc_has_525()) |
| 1337 | 1153 | { |
| 1338 | 1154 | /* set the 5.25" enable lines */ |
| 1339 | 1155 | apple525_set_enable_lines(slot6_enable_mask); |
| r2543 | r2544 | |
| 1348 | 1164 | |
| 1349 | 1165 | if (apple2_fdc_diskreg & 0x40) |
| 1350 | 1166 | { |
| 1351 | | if (apple2_fdc_has_35) |
| 1167 | if (apple2_fdc_has_35()) |
| 1352 | 1168 | { |
| 1353 | 1169 | /* slot 5: 3.5" disks */ |
| 1354 | 1170 | result = sony_read_data(); |
| r2543 | r2544 | |
| 1356 | 1172 | } |
| 1357 | 1173 | else |
| 1358 | 1174 | { |
| 1359 | | if (apple2_fdc_has_525) |
| 1175 | if (apple2_fdc_has_525()) |
| 1360 | 1176 | { |
| 1361 | 1177 | /* slot 6: 5.25" disks */ |
| 1362 | 1178 | result = apple525_read_data(); |
| r2543 | r2544 | |
| 1371 | 1187 | { |
| 1372 | 1188 | if (apple2_fdc_diskreg & 0x40) |
| 1373 | 1189 | { |
| 1374 | | if (apple2_fdc_has_35) |
| 1190 | if (apple2_fdc_has_35()) |
| 1375 | 1191 | { |
| 1376 | 1192 | /* slot 5: 3.5" disks */ |
| 1377 | 1193 | sony_write_data(data); |
| r2543 | r2544 | |
| 1379 | 1195 | } |
| 1380 | 1196 | else |
| 1381 | 1197 | { |
| 1382 | | if (apple2_fdc_has_525) |
| 1198 | if (apple2_fdc_has_525()) |
| 1383 | 1199 | { |
| 1384 | 1200 | /* slot 6: 5.25" disks */ |
| 1385 | 1201 | apple525_write_data(data); |
| r2543 | r2544 | |
| 1395 | 1211 | |
| 1396 | 1212 | if (apple2_fdc_diskreg & 0x40) |
| 1397 | 1213 | { |
| 1398 | | if (apple2_fdc_has_35) |
| 1214 | if (apple2_fdc_has_35()) |
| 1399 | 1215 | { |
| 1400 | 1216 | /* slot 5: 3.5" disks */ |
| 1401 | 1217 | result = sony_read_status(); |
| r2543 | r2544 | |
| 1403 | 1219 | } |
| 1404 | 1220 | else |
| 1405 | 1221 | { |
| 1406 | | if (apple2_fdc_has_525) |
| 1222 | if (apple2_fdc_has_525()) |
| 1407 | 1223 | { |
| 1408 | 1224 | /* slot 6: 5.25" disks */ |
| 1409 | 1225 | result = apple525_read_status(); |
| r2543 | r2544 | |
| 1417 | 1233 | void apple2_iwm_setdiskreg(UINT8 data) |
| 1418 | 1234 | { |
| 1419 | 1235 | apple2_fdc_diskreg = data & 0xC0; |
| 1420 | | if (apple2_fdc_has_35) |
| 1236 | if (apple2_fdc_has_35()) |
| 1421 | 1237 | sony_set_sel_line(apple2_fdc_diskreg & 0x80); |
| 1422 | 1238 | } |
| 1423 | 1239 | |
| r2543 | r2544 | |
| 1430 | 1246 | |
| 1431 | 1247 | |
| 1432 | 1248 | |
| 1433 | | static void *apple2_fdc_init(running_machine *machine, int slot, applefdc_t fdc_type) |
| 1434 | | { |
| 1435 | | const device_config *dev; |
| 1436 | | const struct IODevice *iodev; |
| 1437 | | applefdc_interface intf; |
| 1438 | 1249 | |
| 1439 | | apple2_fdc_has_35 = FALSE; |
| 1440 | | apple2_fdc_has_525 = FALSE; |
| 1441 | | apple2_fdc_diskreg = 0x00; |
| 1442 | | |
| 1443 | | /* setup interface */ |
| 1444 | | memset(&intf, 0, sizeof(intf)); |
| 1445 | | intf.type = fdc_type; |
| 1446 | | intf.set_lines = apple2_fdc_set_lines; |
| 1447 | | intf.set_enable_lines = apple2_fdc_set_enable_lines; |
| 1448 | | intf.read_status = apple2_fdc_read_status; |
| 1449 | | intf.read_data = apple2_fdc_read_data; |
| 1450 | | intf.write_data = apple2_fdc_write_data; |
| 1451 | | |
| 1452 | | for (dev = image_device_first(machine->config); dev != NULL; dev = image_device_next(dev)) |
| 1453 | | { |
| 1454 | | iodev = mess_device_from_core_device(dev); |
| 1455 | | if (iodev != NULL) |
| 1456 | | { |
| 1457 | | if (!strcmp(iodev->tag, "sonydriv")) |
| 1458 | | apple2_fdc_has_35 = 1; |
| 1459 | | else if (!strcmp(iodev->tag, "apple525driv")) |
| 1460 | | apple2_fdc_has_525 = 1; |
| 1461 | | } |
| 1462 | | } |
| 1463 | | |
| 1464 | | applefdc_init(&intf); |
| 1465 | | return (void *) ~0; |
| 1466 | | } |
| 1467 | | |
| 1468 | | |
| 1469 | | |
| 1470 | | static void *apple2_fdc_apple2_init(running_machine *machine, int slot) |
| 1250 | const applefdc_interface apple2_fdc_interface = |
| 1471 | 1251 | { |
| 1472 | | return apple2_fdc_init(machine, slot, APPLEFDC_APPLE2); |
| 1473 | | } |
| 1252 | apple2_fdc_set_lines, /* set_lines */ |
| 1253 | apple2_fdc_set_enable_lines, /* set_enable_lines */ |
| 1474 | 1254 | |
| 1475 | | |
| 1476 | | |
| 1477 | | static void *apple2_fdc_iwm_init(running_machine *machine, int slot) |
| 1478 | | { |
| 1479 | | return apple2_fdc_init(machine, slot, APPLEFDC_IWM); |
| 1480 | | } |
| 1481 | | |
| 1482 | | |
| 1483 | | |
| 1484 | | static UINT8 apple2_fdc_read(running_machine *machine, void *token, offs_t offset) |
| 1485 | | { |
| 1486 | | return applefdc_r(machine, offset); |
| 1487 | | } |
| 1488 | | |
| 1489 | | |
| 1490 | | |
| 1491 | | static void apple2_fdc_write(running_machine *machine, void *token, offs_t offset, UINT8 data) |
| 1492 | | { |
| 1493 | | applefdc_w(machine, offset, data); |
| 1494 | | } |
| 1495 | | |
| 1496 | | |
| 1497 | | |
| 1498 | | const apple2_slotdevice apple2_slot_floppy525 = |
| 1499 | | { |
| 1500 | | "floppy525", |
| 1501 | | "5.25\" Floppy Drive", |
| 1502 | | apple2_fdc_apple2_init, |
| 1503 | | NULL, |
| 1504 | | apple2_fdc_read, |
| 1505 | | apple2_fdc_write |
| 1255 | apple2_fdc_read_data, /* read_data */ |
| 1256 | apple2_fdc_write_data, /* write_data */ |
| 1257 | apple2_fdc_read_status /* read_status */ |
| 1506 | 1258 | }; |
| 1507 | 1259 | |
| 1508 | 1260 | |
| 1509 | 1261 | |
| 1510 | | const apple2_slotdevice apple2_slot_iwm = |
| 1511 | | { |
| 1512 | | "iwm", |
| 1513 | | "IWM", |
| 1514 | | apple2_fdc_iwm_init, |
| 1515 | | NULL, |
| 1516 | | apple2_fdc_read, |
| 1517 | | apple2_fdc_write |
| 1518 | | }; |
| 1519 | | |
| 1520 | | |
| 1521 | | |
| 1522 | 1262 | /* ----------------------------------------------------------------------- |
| 1523 | 1263 | * Driver init |
| 1524 | 1264 | * ----------------------------------------------------------------------- */ |
| 1525 | 1265 | |
| 1526 | | void apple2_init_common(running_machine *machine, const apple2_config *config) |
| 1266 | void apple2_init_common(running_machine *machine) |
| 1527 | 1267 | { |
| 1528 | | int i; |
| 1529 | | void *token; |
| 1530 | | |
| 1531 | 1268 | a2 = 0; |
| 1269 | apple2_fdc_diskreg = 0; |
| 1532 | 1270 | |
| 1533 | 1271 | AY3600_init(); |
| 1534 | 1272 | add_reset_callback(machine, apple2_reset); |
| 1535 | 1273 | |
| 1536 | | /* copy configuration */ |
| 1537 | | a2_config = auto_malloc(sizeof(*config)); |
| 1538 | | memcpy(a2_config, config, sizeof(*config)); |
| 1539 | | |
| 1540 | 1274 | /* state save registers */ |
| 1541 | 1275 | state_save_register_global(a2); |
| 1542 | 1276 | state_save_register_postload(machine, apple2_update_memory_postload, NULL); |
| r2543 | r2544 | |
| 1544 | 1278 | /* apple2 behaves much better when the default memory is zero */ |
| 1545 | 1279 | memset(mess_ram, 0, mess_ram_size); |
| 1546 | 1280 | |
| 1547 | | /* initialize slots */ |
| 1548 | | a2_slot_tokens = auto_malloc(sizeof(*a2_slot_tokens) * APPLE2_SLOT_COUNT); |
| 1549 | | memset(a2_slot_tokens, 0, sizeof(*a2_slot_tokens) * APPLE2_SLOT_COUNT); |
| 1550 | | for (i = 0; i < APPLE2_SLOT_COUNT; i++) |
| 1551 | | { |
| 1552 | | if (a2_config->slots[i]) |
| 1553 | | { |
| 1554 | | if (a2_config->slots[i]->init) |
| 1555 | | token = a2_config->slots[i]->init(machine, i); |
| 1556 | | else |
| 1557 | | token = (void *) ~0; |
| 1558 | | |
| 1559 | | a2_slot_tokens[i] = token; |
| 1560 | | } |
| 1561 | | } |
| 1562 | | |
| 1563 | 1281 | /* --------------------------------------------- * |
| 1564 | 1282 | * set up the softswitch mask/set * |
| 1565 | 1283 | * --------------------------------------------- */ |
| r2543 | r2544 | |
| 1579 | 1297 | MACHINE_START( apple2 ) |
| 1580 | 1298 | { |
| 1581 | 1299 | apple2_memmap_config mem_cfg; |
| 1582 | | apple2_config a2_cfg; |
| 1583 | 1300 | void *apple2cp_ce00_ram = NULL; |
| 1584 | 1301 | |
| 1585 | | memset(&a2_cfg, 0, sizeof(a2_cfg)); |
| 1586 | | |
| 1587 | | /* specify slots */ |
| 1588 | | if (!strcmp(machine->gamedrv->name, "apple2c0") || |
| 1589 | | !strcmp(machine->gamedrv->name, "apple2c3") || |
| 1590 | | !strcmp(machine->gamedrv->name, "apple2cp")) |
| 1591 | | { |
| 1592 | | a2_cfg.slots[0] = &apple2_slot_langcard; |
| 1593 | | a2_cfg.slots[4] = &apple2_slot_mockingboard; |
| 1594 | | a2_cfg.slots[6] = &apple2_slot_iwm; |
| 1595 | | } |
| 1596 | | else |
| 1597 | | { |
| 1598 | | a2_cfg.slots[0] = &apple2_slot_langcard; |
| 1599 | | a2_cfg.slots[4] = &apple2_slot_mockingboard; |
| 1600 | | a2_cfg.slots[6] = &apple2_slot_floppy525; |
| 1601 | | } |
| 1602 | | |
| 1603 | 1302 | /* there appears to be some hidden RAM that is swapped in on the Apple |
| 1604 | 1303 | * IIc plus; I have not found any official documentation but the BIOS |
| 1605 | 1304 | * clearly uses this area as writeable memory */ |
| 1606 | 1305 | if (!strcmp(machine->gamedrv->name, "apple2cp")) |
| 1607 | 1306 | apple2cp_ce00_ram = auto_malloc(0x200); |
| 1608 | 1307 | |
| 1609 | | apple2_init_common(machine, &a2_cfg); |
| 1308 | apple2_init_common(machine); |
| 1610 | 1309 | |
| 1611 | 1310 | /* setup memory */ |
| 1612 | 1311 | memset(&mem_cfg, 0, sizeof(mem_cfg)); |
| r2543 | r2544 | |
| 1618 | 1317 | /* perform initial reset */ |
| 1619 | 1318 | apple2_reset(machine); |
| 1620 | 1319 | } |
| 1621 | | |
src/mess/drivers/apple2.c
| r2543 | r2544 | |
| 184 | 184 | |
| 185 | 185 | #include "driver.h" |
| 186 | 186 | #include "deprecat.h" |
| 187 | | #include "includes/apple2.h" |
| 188 | | #include "machine/ay3600.h" |
| 189 | 187 | #include "devices/appldriv.h" |
| 190 | 188 | #include "devices/mflopimg.h" |
| 191 | 189 | #include "formats/ap2_dsk.h" |
| 190 | #include "includes/apple2.h" |
| 191 | #include "machine/ay3600.h" |
| 192 | #include "machine/ap2_slot.h" |
| 193 | #include "machine/ap2_lang.h" |
| 194 | #include "machine/applefdc.h" |
| 195 | #include "machine/mockngbd.h" |
| 192 | 196 | #include "sound/ay8910.h" |
| 193 | 197 | |
| 194 | 198 | |
| 195 | | static ADDRESS_MAP_START( apple2_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 196 | | ADDRESS_MAP_END |
| 197 | 199 | |
| 198 | | |
| 199 | | /************************************************************************** |
| 200 | /*************************************************************************** |
| 201 | PARAMETERS |
| 200 | 202 | ***************************************************************************/ |
| 201 | 203 | |
| 202 | 204 | #define JOYSTICK_DELTA 80 |
| r2543 | r2544 | |
| 206 | 208 | #define PADDLE_SENSITIVITY 10 |
| 207 | 209 | #define PADDLE_AUTOCENTER 0 |
| 208 | 210 | |
| 211 | |
| 212 | |
| 213 | /*************************************************************************** |
| 214 | ADDRESS MAP |
| 215 | ***************************************************************************/ |
| 216 | |
| 217 | static ADDRESS_MAP_START( apple2_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| 218 | /* nothing in the address map - everything is added dynamically */ |
| 219 | ADDRESS_MAP_END |
| 220 | |
| 221 | |
| 222 | |
| 223 | /*************************************************************************** |
| 224 | INPUT PORTS |
| 225 | ***************************************************************************/ |
| 226 | |
| 209 | 227 | static INPUT_PORTS_START( apple2_joystick ) |
| 210 | 228 | PORT_START_TAG("joystick_1_x") /* Joystick 1 X Axis */ |
| 211 | 229 | PORT_BIT( 0xff, 0x80, IPT_AD_STICK_X) PORT_NAME("P1 Joystick X") |
| r2543 | r2544 | |
| 571 | 589 | MDRV_SOUND_ADD(AY8913, 1022727) |
| 572 | 590 | MDRV_SOUND_CONFIG(ay8910_interface) |
| 573 | 591 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00) |
| 592 | |
| 593 | /* slot devices */ |
| 594 | MDRV_DEVICE_ADD("langcard", APPLE2_LANGCARD) |
| 595 | MDRV_DEVICE_ADD("mockingboard", MOCKINGBOARD) |
| 596 | MDRV_DEVICE_ADD("fdc", APPLEFDC) |
| 597 | MDRV_DEVICE_CONFIG(apple2_fdc_interface) |
| 598 | |
| 599 | /* slots */ |
| 600 | MDRV_APPLE2_SLOT_ADD(0, "langcard", apple2_langcard_r, apple2_langcard_w) |
| 601 | MDRV_APPLE2_SLOT_ADD(4, "mockingboard", mockingboard_r, mockingboard_w) |
| 602 | MDRV_APPLE2_SLOT_ADD(6, "fdc", applefdc_r, applefdc_w) |
| 574 | 603 | MACHINE_DRIVER_END |
| 575 | 604 | |
| 576 | 605 | static MACHINE_DRIVER_START( apple2 ) |
| r2543 | r2544 | |
| 582 | 611 | MDRV_VIDEO_START(apple2p) |
| 583 | 612 | MACHINE_DRIVER_END |
| 584 | 613 | |
| 585 | | #ifdef UNUSED_FUNCTION |
| 586 | | static MACHINE_DRIVER_START( ace100 ) |
| 587 | | MDRV_IMPORT_FROM( apple2_common ) |
| 588 | | MDRV_VIDEO_START(apple2p) |
| 589 | | MACHINE_DRIVER_END |
| 590 | | #endif |
| 591 | | |
| 592 | 614 | ROM_START(las3000) |
| 593 | 615 | ROM_REGION(0x0800,REGION_GFX1,0) |
| 594 | 616 | ROM_LOAD ( "a2.chr", 0x0000, 0x0800, CRC(64f415c6) SHA1(f9d312f128c9557d9d6ac03bfad6c3ddf83e5659)) |
| r2543 | r2544 | |
| 612 | 634 | MDRV_IMPORT_FROM( apple2ee ) |
| 613 | 635 | MACHINE_DRIVER_END |
| 614 | 636 | |
| 637 | static MACHINE_DRIVER_START( apple2c_iwm ) |
| 638 | MDRV_IMPORT_FROM( apple2c ) |
| 615 | 639 | |
| 640 | /* replace the old-style FDC with an IWM */ |
| 641 | MDRV_DEVICE_REMOVE("fdc", APPLEFDC) |
| 642 | MDRV_DEVICE_ADD("fdc", IWM) |
| 643 | MDRV_DEVICE_CONFIG(apple2_fdc_interface) |
| 644 | MACHINE_DRIVER_END |
| 645 | |
| 646 | |
| 616 | 647 | /*************************************************************************** |
| 617 | 648 | |
| 618 | 649 | Game driver(s) |
| r2543 | r2544 | |
| 829 | 860 | |
| 830 | 861 | |
| 831 | 862 | |
| 832 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 833 | | COMP( 1977, apple2, 0, 0, apple2, apple2, 0, apple2, "Apple Computer", "Apple ][" , 0) |
| 834 | | COMP( 1979, apple2p, apple2, 0, apple2p, apple2p, 0, apple2p, "Apple Computer", "Apple ][+" , 0) |
| 835 | | COMP( 1980, apple2jp, apple2, 0, apple2p, apple2p, 0, apple2p, "Apple Computer", "Apple ][j+" , 0) |
| 836 | | COMP( 1982, ace100, apple2, 0, apple2, apple2e, 0, apple2, "Franklin Computer", "Franklin Ace 100" , 0) |
| 837 | | COMP( 1983, apple2e, 0, apple2, apple2e, apple2e, 0, apple2e, "Apple Computer", "Apple //e" , 0) |
| 838 | | COMP( 1985, apple2ee, apple2e, 0, apple2ee, apple2e, 0, apple2e, "Apple Computer", "Apple //e (enhanced)" , 0) |
| 839 | | COMP( 1987, apple2ep, apple2e, 0, apple2ee, apple2ep, 0, apple2e, "Apple Computer", "Apple //e (Platinum)" , 0) |
| 840 | | COMP( 1984, apple2c, 0, apple2, apple2c, apple2e, 0, apple2e, "Apple Computer", "Apple //c" , 0) |
| 841 | | COMP( 1983, las3000, apple2, 0, apple2p, apple2p, 0, apple2p, "Video Technology", "Laser 3000", GAME_NOT_WORKING ) |
| 842 | | COMP( 1987, laser128, 0, apple2c0, apple2c, apple2e, 0, apple2e, "Video Technology", "Laser 128 (rev 4)", GAME_NOT_WORKING ) |
| 843 | | COMP( 1987, las128ex, apple2c, 0, apple2c, apple2e, 0, apple2e, "Video Technology", "Laser 128ex (rev 4a)", GAME_NOT_WORKING ) |
| 844 | | COMP( 1985, apple2c0, apple2c, 0, apple2c, apple2e, 0, apple2e, "Apple Computer", "Apple //c (UniDisk 3.5)" , 0) |
| 845 | | COMP( 1986, apple2c3, apple2c, 0, apple2c, apple2e, 0, apple2e, "Apple Computer", "Apple //c (Original Memory Expansion)" , 0) |
| 846 | | COMP( 1986, apple2c4, apple2c, 0, apple2c, apple2e, 0, apple2e, "Apple Computer", "Apple //c (rev 4)" , GAME_NOT_WORKING ) |
| 847 | | COMP( 1988, apple2cp, apple2c, 0, apple2c, apple2e, 0, apple2e, "Apple Computer", "Apple //c Plus" , 0) |
| 863 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 864 | COMP( 1977, apple2, 0, 0, apple2, apple2, 0, apple2, "Apple Computer", "Apple ][" , 0) |
| 865 | COMP( 1979, apple2p, apple2, 0, apple2p, apple2p, 0, apple2p, "Apple Computer", "Apple ][+" , 0) |
| 866 | COMP( 1980, apple2jp, apple2, 0, apple2p, apple2p, 0, apple2p, "Apple Computer", "Apple ][j+" , 0) |
| 867 | COMP( 1982, ace100, apple2, 0, apple2, apple2e, 0, apple2, "Franklin Computer", "Franklin Ace 100" , 0) |
| 868 | COMP( 1983, apple2e, 0, apple2, apple2e, apple2e, 0, apple2e, "Apple Computer", "Apple //e" , 0) |
| 869 | COMP( 1985, apple2ee, apple2e, 0, apple2ee, apple2e, 0, apple2e, "Apple Computer", "Apple //e (enhanced)" , 0) |
| 870 | COMP( 1987, apple2ep, apple2e, 0, apple2ee, apple2ep, 0, apple2e, "Apple Computer", "Apple //e (Platinum)" , 0) |
| 871 | COMP( 1984, apple2c, 0, apple2, apple2c, apple2e, 0, apple2e, "Apple Computer", "Apple //c" , 0) |
| 872 | COMP( 1983, las3000, apple2, 0, apple2p, apple2p, 0, apple2p, "Video Technology", "Laser 3000", GAME_NOT_WORKING ) |
| 873 | COMP( 1987, laser128, 0, apple2c0, apple2c, apple2e, 0, apple2e, "Video Technology", "Laser 128 (rev 4)", GAME_NOT_WORKING ) |
| 874 | COMP( 1987, las128ex, apple2c, 0, apple2c, apple2e, 0, apple2e, "Video Technology", "Laser 128ex (rev 4a)", GAME_NOT_WORKING ) |
| 875 | COMP( 1985, apple2c0, apple2c, 0, apple2c_iwm, apple2e, 0, apple2e, "Apple Computer", "Apple //c (UniDisk 3.5)" , 0) |
| 876 | COMP( 1986, apple2c3, apple2c, 0, apple2c_iwm, apple2e, 0, apple2e, "Apple Computer", "Apple //c (Original Memory Expansion)" , 0) |
| 877 | COMP( 1986, apple2c4, apple2c, 0, apple2c_iwm, apple2e, 0, apple2e, "Apple Computer", "Apple //c (rev 4)" , GAME_NOT_WORKING ) |
| 878 | COMP( 1988, apple2cp, apple2c, 0, apple2c_iwm, apple2e, 0, apple2e, "Apple Computer", "Apple //c Plus" , 0) |