src/mess/machine/applefdc.c
| r2500 | r2501 | |
| 43 | 43 | ***************************************************************************/ |
| 44 | 44 | |
| 45 | 45 | /* logging */ |
| 46 | | #define LOG_IWM 0 |
| 47 | | #define LOG_IWM_EXTRA 0 |
| 46 | #define LOG_APPLEFDC 0 |
| 47 | #define LOG_APPLEFDC_EXTRA 0 |
| 48 | 48 | |
| 49 | 49 | |
| 50 | 50 | |
| r2500 | r2501 | |
| 129 | 129 | |
| 130 | 130 | |
| 131 | 131 | |
| 132 | | /* R. Nabet : Next two functions look more like a hack than a real feature of the IWM */ |
| 133 | | /* I left them there because I had no idea what they intend to do. |
| 134 | | They never get called when booting the Mac Plus driver. */ |
| 132 | /*------------------------------------------------- |
| 133 | iwm_enable2 - hackish function |
| 134 | -------------------------------------------------*/ |
| 135 | |
| 135 | 136 | static int iwm_enable2(void) |
| 136 | 137 | { |
| 138 | /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */ |
| 139 | /* it is not called from the Mac Plus driver */ |
| 137 | 140 | return (applefdc_lines & APPLEFDC_PH1) && (applefdc_lines & APPLEFDC_PH3); |
| 138 | 141 | } |
| 139 | 142 | |
| 140 | 143 | |
| 141 | 144 | |
| 145 | /*------------------------------------------------- |
| 146 | iwm_readenable2handshake - hackish function |
| 147 | -------------------------------------------------*/ |
| 148 | |
| 142 | 149 | static int iwm_readenable2handshake(void) |
| 143 | 150 | { |
| 151 | /* R. Nabet : This function looks more like a hack than a real feature of the IWM; */ |
| 152 | /* it is not called from the Mac Plus driver */ |
| 153 | |
| 144 | 154 | static int val = 0; |
| 145 | 155 | |
| 146 | 156 | if (val++ > 3) |
| r2500 | r2501 | |
| 151 | 161 | |
| 152 | 162 | |
| 153 | 163 | |
| 164 | /*------------------------------------------------- |
| 165 | applefdc_statusreg_r - reads the status register |
| 166 | -------------------------------------------------*/ |
| 167 | |
| 154 | 168 | static int applefdc_statusreg_r(void) |
| 155 | 169 | { |
| 156 | 170 | /* IWM status: |
| r2500 | r2501 | |
| 175 | 189 | |
| 176 | 190 | |
| 177 | 191 | |
| 192 | /*------------------------------------------------- |
| 193 | iwm_modereg_w - changes the mode register |
| 194 | -------------------------------------------------*/ |
| 195 | |
| 178 | 196 | static void iwm_modereg_w(int data) |
| 179 | 197 | { |
| 180 | 198 | iwm_mode = data & 0x1f; /* Write mode register */ |
| 181 | 199 | |
| 182 | | if (LOG_IWM_EXTRA) |
| 200 | if (LOG_APPLEFDC_EXTRA) |
| 183 | 201 | logerror("iwm_modereg_w: iwm_mode=0x%02x\n", (int) iwm_mode); |
| 184 | 202 | } |
| 185 | 203 | |
| 186 | 204 | |
| 187 | 205 | |
| 206 | /*------------------------------------------------- |
| 207 | applefdc_read_reg - reads a register |
| 208 | -------------------------------------------------*/ |
| 209 | |
| 188 | 210 | static UINT8 applefdc_read_reg(int lines) |
| 189 | 211 | { |
| 190 | 212 | UINT8 result = 0; |
| r2500 | r2501 | |
| 204 | 226 | * 3.5 inch drives. Eventually we should check to see if latch mode is |
| 205 | 227 | * off |
| 206 | 228 | */ |
| 207 | | if (LOG_IWM) |
| 229 | if (LOG_APPLEFDC) |
| 208 | 230 | { |
| 209 | 231 | if ((iwm_mode & IWM_MODE_LATCHMODE) == 0) |
| 210 | 232 | logerror("applefdc_read_reg(): latch mode off not implemented\n"); |
| r2500 | r2501 | |
| 234 | 256 | |
| 235 | 257 | |
| 236 | 258 | |
| 259 | /*------------------------------------------------- |
| 260 | applefdc_write_reg - writes a register |
| 261 | -------------------------------------------------*/ |
| 262 | |
| 237 | 263 | static void applefdc_write_reg(UINT8 data) |
| 238 | 264 | { |
| 239 | 265 | switch(applefdc_lines & (IWM_Q6 | IWM_Q7)) |
| r2500 | r2501 | |
| 250 | 276 | * 3.5 inch drives. Eventually we should check to see if latch mode is |
| 251 | 277 | * off |
| 252 | 278 | */ |
| 253 | | if (LOG_IWM) |
| 279 | if (LOG_APPLEFDC) |
| 254 | 280 | { |
| 255 | 281 | if ((iwm_mode & IWM_MODE_LATCHMODE) == 0) |
| 256 | 282 | logerror("applefdc_write_reg(): latch mode off not implemented\n"); |
| r2500 | r2501 | |
| 265 | 291 | |
| 266 | 292 | |
| 267 | 293 | |
| 294 | /*------------------------------------------------- |
| 295 | TIMER_CALLBACK(iwm_turnmotor_onoff) - timer |
| 296 | callback for turning motor on or off |
| 297 | -------------------------------------------------*/ |
| 298 | |
| 268 | 299 | static TIMER_CALLBACK(iwm_turnmotor_onoff) |
| 269 | 300 | { |
| 270 | 301 | int status = param; |
| r2500 | r2501 | |
| 289 | 320 | if (iwm_intf.set_enable_lines) |
| 290 | 321 | iwm_intf.set_enable_lines(enable_lines); |
| 291 | 322 | |
| 292 | | if (LOG_IWM_EXTRA) |
| 323 | if (LOG_APPLEFDC_EXTRA) |
| 293 | 324 | logerror("iwm_turnmotor_onoff(): Turning motor %s\n", status ? "on" : "off"); |
| 294 | 325 | } |
| 295 | 326 | |
| 296 | 327 | |
| 297 | 328 | |
| 329 | /*------------------------------------------------- |
| 330 | iwm_access |
| 331 | -------------------------------------------------*/ |
| 332 | |
| 298 | 333 | static void iwm_access(int offset) |
| 299 | 334 | { |
| 300 | 335 | static const char *const lines[] = |
| r2500 | r2501 | |
| 309 | 344 | "Q7" |
| 310 | 345 | }; |
| 311 | 346 | |
| 312 | | if (LOG_IWM_EXTRA) |
| 347 | if (LOG_APPLEFDC_EXTRA) |
| 313 | 348 | { |
| 314 | 349 | logerror("iwm_access(): %s line %s\n", |
| 315 | 350 | (offset & 1) ? "setting" : "clearing", lines[offset >> 1]); |
| r2500 | r2501 | |
| 352 | 387 | |
| 353 | 388 | |
| 354 | 389 | |
| 390 | /*------------------------------------------------- |
| 391 | applefdc_r - reads a byte from the FDC |
| 392 | -------------------------------------------------*/ |
| 393 | |
| 355 | 394 | READ8_HANDLER( applefdc_r ) |
| 356 | 395 | { |
| 357 | 396 | UINT8 result = 0; |
| 358 | 397 | |
| 398 | /* normalize offset */ |
| 359 | 399 | offset &= 15; |
| 360 | 400 | |
| 361 | | if (LOG_IWM_EXTRA) |
| 401 | if (LOG_APPLEFDC_EXTRA) |
| 362 | 402 | logerror("applefdc_r: offset=%i\n", offset); |
| 363 | 403 | |
| 364 | 404 | iwm_access(offset); |
| r2500 | r2501 | |
| 405 | 445 | |
| 406 | 446 | |
| 407 | 447 | |
| 448 | /*------------------------------------------------- |
| 449 | applefdc_w - writes a byte to the FDC |
| 450 | -------------------------------------------------*/ |
| 451 | |
| 408 | 452 | WRITE8_HANDLER( applefdc_w ) |
| 409 | 453 | { |
| 454 | /* normalize offset */ |
| 410 | 455 | offset &= 15; |
| 411 | 456 | |
| 412 | | if (LOG_IWM_EXTRA) |
| 457 | if (LOG_APPLEFDC_EXTRA) |
| 413 | 458 | logerror("applefdc_w: offset=%i data=0x%02x\n", offset, data); |
| 414 | 459 | |
| 415 | 460 | iwm_access(offset); |
| r2500 | r2501 | |
| 446 | 491 | |
| 447 | 492 | |
| 448 | 493 | |
| 494 | /*------------------------------------------------- |
| 495 | applefdc_w - writes a byte to the FDC |
| 496 | -------------------------------------------------*/ |
| 497 | |
| 449 | 498 | UINT8 applefdc_get_lines(void) |
| 450 | 499 | { |
| 451 | 500 | return applefdc_lines & 0x0f; |