src/mess/machine/atarifdc.c
| r6746 | r6747 | |
| 16 | 16 | #include "ataridev.h" |
| 17 | 17 | #include "sound/pokey.h" |
| 18 | 18 | #include "machine/6821pia.h" |
| 19 | #include "devices/flopdrv.h" |
| 19 | 20 | #include "image.h" |
| 20 | 21 | |
| 21 | 22 | #define VERBOSE_SERIAL 0 |
| 22 | 23 | #define VERBOSE_CHKSUM 0 |
| 23 | 24 | |
| 24 | | typedef struct { |
| 25 | | int serout_count; |
| 26 | | int serout_offs; |
| 27 | | UINT8 serout_buff[512]; |
| 28 | | UINT8 serout_chksum; |
| 29 | | int serout_delay; |
| 30 | | |
| 31 | | int serin_count; |
| 32 | | int serin_offs; |
| 33 | | UINT8 serin_buff[512]; |
| 34 | | UINT8 serin_chksum; |
| 35 | | int serin_delay; |
| 36 | | } ATARI_FDC; |
| 37 | | |
| 38 | | static ATARI_FDC atari_fdc; |
| 39 | | |
| 40 | 25 | typedef struct _atari_drive atari_drive; |
| 41 | 26 | struct _atari_drive |
| 42 | 27 | { |
| r6746 | r6747 | |
| 53 | 38 | int sectors; /* total sectors, ie. tracks x heads x spt */ |
| 54 | 39 | }; |
| 55 | 40 | |
| 56 | | static atari_drive drv[4]; |
| 41 | typedef struct _atari_fdc_t atari_fdc_t; |
| 42 | struct _atari_fdc_t |
| 43 | { |
| 44 | int serout_count; |
| 45 | int serout_offs; |
| 46 | UINT8 serout_buff[512]; |
| 47 | UINT8 serout_chksum; |
| 48 | int serout_delay; |
| 57 | 49 | |
| 50 | int serin_count; |
| 51 | int serin_offs; |
| 52 | UINT8 serin_buff[512]; |
| 53 | UINT8 serin_chksum; |
| 54 | int serin_delay; |
| 55 | |
| 56 | atari_drive drv[4]; |
| 57 | }; |
| 58 | |
| 58 | 59 | /************************************* |
| 59 | 60 | * |
| 60 | 61 | * Disk stuff |
| r6746 | r6747 | |
| 66 | 67 | #define FORMAT_DSK 2 |
| 67 | 68 | |
| 68 | 69 | /***************************************************************************** |
| 70 | INLINE FUNCTIONS |
| 71 | *****************************************************************************/ |
| 72 | INLINE atari_fdc_t *get_safe_token(const device_config *device) |
| 73 | { |
| 74 | assert(device != NULL); |
| 75 | assert(device->token != NULL); |
| 76 | |
| 77 | return (atari_fdc_t *)device->token; |
| 78 | } |
| 79 | |
| 80 | /***************************************************************************** |
| 69 | 81 | * This is the structure I used in my own Atari 800 emulator some years ago |
| 70 | 82 | * Though it's a bit overloaded, I used it as it is the maximum of all |
| 71 | 83 | * supported formats: |
| r6746 | r6747 | |
| 136 | 148 | *****************************************************************************/ |
| 137 | 149 | |
| 138 | 150 | #define MAXSIZE 5760 * 256 + 80 |
| 139 | | DEVICE_IMAGE_LOAD( a800_floppy ) |
| 151 | static void atari_load_proc(const device_config *image) |
| 140 | 152 | { |
| 153 | atari_fdc_t *fdc = get_safe_token(image->owner); |
| 154 | int id = floppy_get_drive(image); |
| 141 | 155 | int size, i; |
| 142 | 156 | const char *ext; |
| 143 | | int id = image_index_in_device(image); |
| 144 | 157 | |
| 145 | | drv[id].image = image_malloc(image, MAXSIZE); |
| 146 | | if (!drv[id].image) |
| 147 | | return INIT_FAIL; |
| 158 | fdc->drv[id].image = image_malloc(image, MAXSIZE); |
| 159 | if (!fdc->drv[id].image) |
| 160 | return; |
| 148 | 161 | |
| 149 | 162 | /* tell whether the image is writable */ |
| 150 | | drv[id].mode = image_is_writable(image); |
| 163 | fdc->drv[id].mode = image_is_writable(image); |
| 151 | 164 | /* set up image if it has been created */ |
| 152 | 165 | if (image_has_been_created(image)) |
| 153 | 166 | { |
| r6746 | r6747 | |
| 160 | 173 | image_fseek(image, 0, SEEK_SET); |
| 161 | 174 | } |
| 162 | 175 | |
| 163 | | size = image_fread(image, drv[id].image, MAXSIZE); |
| 176 | size = image_fread(image, fdc->drv[id].image, MAXSIZE); |
| 164 | 177 | if( size <= 0 ) |
| 165 | 178 | { |
| 166 | | drv[id].image = NULL; |
| 167 | | return INIT_FAIL; |
| 179 | fdc->drv[id].image = NULL; |
| 180 | return; |
| 168 | 181 | } |
| 169 | 182 | /* re allocate the buffer; we don't want to be too lazy ;) */ |
| 170 | | drv[id].image = image_realloc(image, drv[id].image, size); |
| 183 | fdc->drv[id].image = image_realloc(image, fdc->drv[id].image, size); |
| 171 | 184 | |
| 172 | 185 | ext = image_filetype(image); |
| 173 | 186 | /* no extension: assume XFD format (no header) */ |
| 174 | 187 | if (!ext) |
| 175 | 188 | { |
| 176 | | drv[id].type = FORMAT_XFD; |
| 177 | | drv[id].header_skip = 0; |
| 189 | fdc->drv[id].type = FORMAT_XFD; |
| 190 | fdc->drv[id].header_skip = 0; |
| 178 | 191 | } |
| 179 | 192 | else |
| 180 | 193 | /* XFD extension */ |
| 181 | 194 | if( toupper(ext[0])=='X' && toupper(ext[1])=='F' && toupper(ext[2])=='D' ) |
| 182 | 195 | { |
| 183 | | drv[id].type = FORMAT_XFD; |
| 184 | | drv[id].header_skip = 0; |
| 196 | fdc->drv[id].type = FORMAT_XFD; |
| 197 | fdc->drv[id].header_skip = 0; |
| 185 | 198 | } |
| 186 | 199 | else |
| 187 | 200 | /* ATR extension */ |
| 188 | 201 | if( toupper(ext[0])=='A' && toupper(ext[1])=='T' && toupper(ext[2])=='R' ) |
| 189 | 202 | { |
| 190 | | drv[id].type = FORMAT_ATR; |
| 191 | | drv[id].header_skip = 16; |
| 203 | fdc->drv[id].type = FORMAT_ATR; |
| 204 | fdc->drv[id].header_skip = 16; |
| 192 | 205 | } |
| 193 | 206 | else |
| 194 | 207 | /* DSK extension */ |
| 195 | 208 | if( toupper(ext[0])=='D' && toupper(ext[1])=='S' && toupper(ext[2])=='K' ) |
| 196 | 209 | { |
| 197 | | drv[id].type = FORMAT_DSK; |
| 198 | | drv[id].header_skip = sizeof(dsk_format); |
| 210 | fdc->drv[id].type = FORMAT_DSK; |
| 211 | fdc->drv[id].header_skip = sizeof(dsk_format); |
| 199 | 212 | } |
| 200 | 213 | else |
| 201 | 214 | { |
| 202 | | drv[id].type = FORMAT_XFD; |
| 203 | | drv[id].header_skip = 0; |
| 215 | fdc->drv[id].type = FORMAT_XFD; |
| 216 | fdc->drv[id].header_skip = 0; |
| 204 | 217 | } |
| 205 | 218 | |
| 206 | | if( drv[id].type == FORMAT_ATR && |
| 207 | | (drv[id].image[0] != 0x96 || drv[id].image[1] != 0x02) ) |
| 219 | if( fdc->drv[id].type == FORMAT_ATR && |
| 220 | (fdc->drv[id].image[0] != 0x96 || fdc->drv[id].image[1] != 0x02) ) |
| 208 | 221 | { |
| 209 | | drv[id].type = FORMAT_XFD; |
| 210 | | drv[id].header_skip = 0; |
| 222 | fdc->drv[id].type = FORMAT_XFD; |
| 223 | fdc->drv[id].header_skip = 0; |
| 211 | 224 | } |
| 212 | 225 | |
| 213 | | switch (drv[id].type) |
| 226 | switch (fdc->drv[id].type) |
| 214 | 227 | { |
| 215 | 228 | /* XFD or unknown format: find a matching size from the table */ |
| 216 | 229 | case FORMAT_XFD: |
| r6746 | r6747 | |
| 218 | 231 | { |
| 219 | 232 | if( size == xfd_formats[i].size ) |
| 220 | 233 | { |
| 221 | | drv[id].density = xfd_formats[i].dsk.density; |
| 222 | | drv[id].tracks = xfd_formats[i].dsk.tracks; |
| 223 | | drv[id].spt = xfd_formats[i].dsk.spt; |
| 224 | | drv[id].heads = (xfd_formats[i].dsk.doublesided) ? 2 : 1; |
| 225 | | drv[id].bseclen = 128; |
| 226 | | drv[id].seclen = 256 * xfd_formats[i].dsk.seclen_hi + xfd_formats[i].dsk.seclen_lo; |
| 227 | | drv[id].sectors = drv[id].tracks * drv[id].heads * drv[id].spt; |
| 234 | fdc->drv[id].density = xfd_formats[i].dsk.density; |
| 235 | fdc->drv[id].tracks = xfd_formats[i].dsk.tracks; |
| 236 | fdc->drv[id].spt = xfd_formats[i].dsk.spt; |
| 237 | fdc->drv[id].heads = (xfd_formats[i].dsk.doublesided) ? 2 : 1; |
| 238 | fdc->drv[id].bseclen = 128; |
| 239 | fdc->drv[id].seclen = 256 * xfd_formats[i].dsk.seclen_hi + xfd_formats[i].dsk.seclen_lo; |
| 240 | fdc->drv[id].sectors = fdc->drv[id].tracks * fdc->drv[id].heads * fdc->drv[id].spt; |
| 228 | 241 | break; |
| 229 | 242 | } |
| 230 | 243 | } |
| r6746 | r6747 | |
| 234 | 247 | { |
| 235 | 248 | int s; |
| 236 | 249 | |
| 237 | | drv[id].bseclen = 128; |
| 250 | fdc->drv[id].bseclen = 128; |
| 238 | 251 | /* get sectors from ATR header */ |
| 239 | 252 | s = (size - 16) / 128; |
| 240 | 253 | /* 3 + odd number of sectors ? */ |
| 241 | | if ( drv[id].image[4] == 128 || (s % 18) == 0 || (s % 26) == 0 || ((s - 3) % 1) != 0 ) |
| 254 | if ( fdc->drv[id].image[4] == 128 || (s % 18) == 0 || (s % 26) == 0 || ((s - 3) % 1) != 0 ) |
| 242 | 255 | { |
| 243 | | drv[id].sectors = s; |
| 244 | | drv[id].seclen = 128; |
| 256 | fdc->drv[id].sectors = s; |
| 257 | fdc->drv[id].seclen = 128; |
| 245 | 258 | /* sector size 128 or count not evenly dividable by 26 ? */ |
| 246 | | if( drv[id].seclen == 128 || (s % 26) != 0 ) |
| 259 | if( fdc->drv[id].seclen == 128 || (s % 26) != 0 ) |
| 247 | 260 | { |
| 248 | 261 | /* yup! single density */ |
| 249 | | drv[id].density = 0; |
| 250 | | drv[id].spt = 18; |
| 251 | | drv[id].heads = 1; |
| 252 | | drv[id].tracks = s / 18; |
| 262 | fdc->drv[id].density = 0; |
| 263 | fdc->drv[id].spt = 18; |
| 264 | fdc->drv[id].heads = 1; |
| 265 | fdc->drv[id].tracks = s / 18; |
| 253 | 266 | if( s % 18 != 0 ) |
| 254 | | drv[id].tracks += 1; |
| 255 | | if( drv[id].tracks % 2 == 0 && drv[id].tracks > 80 ) |
| 267 | fdc->drv[id].tracks += 1; |
| 268 | if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 ) |
| 256 | 269 | { |
| 257 | | drv[id].heads = 2; |
| 258 | | drv[id].tracks /= 2; |
| 270 | fdc->drv[id].heads = 2; |
| 271 | fdc->drv[id].tracks /= 2; |
| 259 | 272 | } |
| 260 | 273 | } |
| 261 | 274 | else |
| 262 | 275 | { |
| 263 | 276 | /* yes: medium density */ |
| 264 | | drv[id].density = 0; |
| 265 | | drv[id].spt = 26; |
| 266 | | drv[id].heads = 1; |
| 267 | | drv[id].tracks = s / 26; |
| 277 | fdc->drv[id].density = 0; |
| 278 | fdc->drv[id].spt = 26; |
| 279 | fdc->drv[id].heads = 1; |
| 280 | fdc->drv[id].tracks = s / 26; |
| 268 | 281 | if( s % 26 != 0 ) |
| 269 | | drv[id].tracks += 1; |
| 270 | | if( drv[id].tracks % 2 == 0 && drv[id].tracks > 80 ) |
| 282 | fdc->drv[id].tracks += 1; |
| 283 | if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 ) |
| 271 | 284 | { |
| 272 | | drv[id].heads = 2; |
| 273 | | drv[id].tracks /= 2; |
| 285 | fdc->drv[id].heads = 2; |
| 286 | fdc->drv[id].tracks /= 2; |
| 274 | 287 | } |
| 275 | 288 | } |
| 276 | 289 | } |
| r6746 | r6747 | |
| 278 | 291 | { |
| 279 | 292 | /* it's double density */ |
| 280 | 293 | s = (s - 3) / 2 + 3; |
| 281 | | drv[id].sectors = s; |
| 282 | | drv[id].density = 2; |
| 283 | | drv[id].seclen = 256; |
| 284 | | drv[id].spt = 18; |
| 285 | | drv[id].heads = 1; |
| 286 | | drv[id].tracks = s / 18; |
| 294 | fdc->drv[id].sectors = s; |
| 295 | fdc->drv[id].density = 2; |
| 296 | fdc->drv[id].seclen = 256; |
| 297 | fdc->drv[id].spt = 18; |
| 298 | fdc->drv[id].heads = 1; |
| 299 | fdc->drv[id].tracks = s / 18; |
| 287 | 300 | if( s % 18 != 0 ) |
| 288 | | drv[id].tracks += 1; |
| 289 | | if( drv[id].tracks % 2 == 0 && drv[id].tracks > 80 ) |
| 301 | fdc->drv[id].tracks += 1; |
| 302 | if( fdc->drv[id].tracks % 2 == 0 && fdc->drv[id].tracks > 80 ) |
| 290 | 303 | { |
| 291 | | drv[id].heads = 2; |
| 292 | | drv[id].tracks /= 2; |
| 304 | fdc->drv[id].heads = 2; |
| 305 | fdc->drv[id].tracks /= 2; |
| 293 | 306 | } |
| 294 | 307 | } |
| 295 | 308 | } |
| r6746 | r6747 | |
| 297 | 310 | /* DSK format: it's all in the header */ |
| 298 | 311 | case FORMAT_DSK: |
| 299 | 312 | { |
| 300 | | dsk_format *dsk = (dsk_format *) drv[id].image; |
| 313 | dsk_format *dsk = (dsk_format *) fdc->drv[id].image; |
| 301 | 314 | |
| 302 | | drv[id].tracks = dsk->tracks; |
| 303 | | drv[id].spt = dsk->spt; |
| 304 | | drv[id].heads = (dsk->doublesided) ? 2 : 1; |
| 305 | | drv[id].seclen = 256 * dsk->seclen_hi + dsk->seclen_lo; |
| 306 | | drv[id].bseclen = drv[id].seclen; |
| 307 | | drv[id].sectors = drv[id].tracks * drv[id].heads * drv[id].spt; |
| 315 | fdc->drv[id].tracks = dsk->tracks; |
| 316 | fdc->drv[id].spt = dsk->spt; |
| 317 | fdc->drv[id].heads = (dsk->doublesided) ? 2 : 1; |
| 318 | fdc->drv[id].seclen = 256 * dsk->seclen_hi + dsk->seclen_lo; |
| 319 | fdc->drv[id].bseclen = fdc->drv[id].seclen; |
| 320 | fdc->drv[id].sectors = fdc->drv[id].tracks * fdc->drv[id].heads * fdc->drv[id].spt; |
| 308 | 321 | } |
| 309 | 322 | break; |
| 310 | 323 | } |
| 311 | 324 | logerror("atari opened floppy '%s', %d sectors (%d %s%s) %d bytes/sector\n", |
| 312 | 325 | image_filename(image), |
| 313 | | drv[id].sectors, |
| 314 | | drv[id].tracks, |
| 315 | | (drv[id].heads == 1) ? "SS" : "DS", |
| 316 | | (drv[id].density == 0) ? "SD" : (drv[id].density == 1) ? "MD" : "DD", |
| 317 | | drv[id].seclen); |
| 318 | | return INIT_PASS; |
| 326 | fdc->drv[id].sectors, |
| 327 | fdc->drv[id].tracks, |
| 328 | (fdc->drv[id].heads == 1) ? "SS" : "DS", |
| 329 | (fdc->drv[id].density == 0) ? "SD" : (fdc->drv[id].density == 1) ? "MD" : "DD", |
| 330 | fdc->drv[id].seclen); |
| 331 | return; |
| 319 | 332 | } |
| 320 | 333 | |
| 321 | 334 | |
| r6746 | r6747 | |
| 375 | 388 | * F->A 128/256 byte CKS bad sector table |
| 376 | 389 | * |
| 377 | 390 | *****************************************************************************/ |
| 378 | | |
| 379 | 391 | static void make_chksum(UINT8 * chksum, UINT8 data) |
| 380 | 392 | { |
| 381 | 393 | UINT8 new; |
| r6746 | r6747 | |
| 389 | 401 | *chksum = new; |
| 390 | 402 | } |
| 391 | 403 | |
| 392 | | static void clr_serout(int expect_data) |
| 404 | static void clr_serout(const device_config *device,int expect_data) |
| 393 | 405 | { |
| 394 | | atari_fdc.serout_chksum = 0; |
| 395 | | atari_fdc.serout_offs = 0; |
| 396 | | atari_fdc.serout_count = expect_data + 1; |
| 406 | atari_fdc_t *fdc = get_safe_token(device); |
| 407 | |
| 408 | fdc->serout_chksum = 0; |
| 409 | fdc->serout_offs = 0; |
| 410 | fdc->serout_count = expect_data + 1; |
| 397 | 411 | } |
| 398 | 412 | |
| 399 | | static void add_serout(int expect_data) |
| 413 | static void add_serout(const device_config *device,int expect_data) |
| 400 | 414 | { |
| 401 | | atari_fdc.serout_chksum = 0; |
| 402 | | atari_fdc.serout_count = expect_data + 1; |
| 415 | atari_fdc_t *fdc = get_safe_token(device); |
| 416 | |
| 417 | fdc->serout_chksum = 0; |
| 418 | fdc->serout_count = expect_data + 1; |
| 403 | 419 | } |
| 404 | 420 | |
| 405 | | static void clr_serin(running_machine *machine, int ser_delay) |
| 421 | static void clr_serin(const device_config *device, int ser_delay) |
| 406 | 422 | { |
| 407 | | const device_config *pokey = devtag_get_device(machine, "pokey"); |
| 408 | | atari_fdc.serin_chksum = 0; |
| 409 | | atari_fdc.serin_offs = 0; |
| 410 | | atari_fdc.serin_count = 0; |
| 423 | atari_fdc_t *fdc = get_safe_token(device); |
| 424 | const device_config *pokey = devtag_get_device(device->machine, "pokey"); |
| 425 | fdc->serin_chksum = 0; |
| 426 | fdc->serin_offs = 0; |
| 427 | fdc->serin_count = 0; |
| 411 | 428 | pokey_serin_ready(pokey, ser_delay * 40); |
| 412 | 429 | } |
| 413 | 430 | |
| 414 | | static void add_serin(UINT8 data, int with_checksum) |
| 431 | static void add_serin(const device_config *device,UINT8 data, int with_checksum) |
| 415 | 432 | { |
| 416 | | atari_fdc.serin_buff[atari_fdc.serin_count++] = data; |
| 433 | atari_fdc_t *fdc = get_safe_token(device); |
| 434 | fdc->serin_buff[fdc->serin_count++] = data; |
| 417 | 435 | if (with_checksum) |
| 418 | | make_chksum(&atari_fdc.serin_chksum, data); |
| 436 | make_chksum(&fdc->serin_chksum, data); |
| 419 | 437 | } |
| 420 | 438 | |
| 421 | | static void ATTR_PRINTF(2,3) atari_set_frame_message(running_machine *machine, const char *fmt, ...) |
| 439 | static void ATTR_PRINTF(2,3) atari_set_frame_message(const device_config *device,const char *fmt, ...) |
| 422 | 440 | { |
| 423 | 441 | va_list arg; |
| 424 | 442 | va_start(arg, fmt); |
| r6746 | r6747 | |
| 429 | 447 | va_end(arg); |
| 430 | 448 | } |
| 431 | 449 | |
| 432 | | static void a800_serial_command(running_machine *machine) |
| 450 | static void a800_serial_command(const device_config *device) |
| 433 | 451 | { |
| 434 | 452 | int i, drive, sector, offset; |
| 435 | | |
| 436 | | if( !atari_fdc.serout_offs ) |
| 453 | atari_fdc_t *fdc = get_safe_token(device); |
| 454 | |
| 455 | if( !fdc->serout_offs ) |
| 437 | 456 | { |
| 438 | 457 | if (VERBOSE_SERIAL) |
| 439 | 458 | logerror("atari serout command offset = 0\n"); |
| 440 | 459 | return; |
| 441 | 460 | } |
| 442 | | clr_serin(machine, 10); |
| 461 | clr_serin(device, 10); |
| 443 | 462 | |
| 444 | 463 | if (VERBOSE_SERIAL) |
| 445 | 464 | { |
| 446 | 465 | logerror("atari serout command %d: %02X %02X %02X %02X %02X : %02X ", |
| 447 | | atari_fdc.serout_offs, |
| 448 | | atari_fdc.serout_buff[0], atari_fdc.serout_buff[1], atari_fdc.serout_buff[2], |
| 449 | | atari_fdc.serout_buff[3], atari_fdc.serout_buff[4], atari_fdc.serout_chksum); |
| 466 | fdc->serout_offs, |
| 467 | fdc->serout_buff[0], fdc->serout_buff[1], fdc->serout_buff[2], |
| 468 | fdc->serout_buff[3], fdc->serout_buff[4], fdc->serout_chksum); |
| 450 | 469 | } |
| 451 | 470 | |
| 452 | | if (atari_fdc.serout_chksum == 0) |
| 471 | if (fdc->serout_chksum == 0) |
| 453 | 472 | { |
| 454 | 473 | if (VERBOSE_SERIAL) |
| 455 | 474 | logerror("OK\n"); |
| 456 | 475 | |
| 457 | | drive = atari_fdc.serout_buff[0] - '1'; /* drive # */ |
| 476 | drive = fdc->serout_buff[0] - '1'; /* drive # */ |
| 458 | 477 | /* sector # */ |
| 459 | 478 | if (drive < 0 || drive > 3) /* ignore unknown drives */ |
| 460 | 479 | { |
| 461 | 480 | logerror("atari unsupported drive #%d\n", drive+1); |
| 462 | | atari_set_frame_message(machine, "DRIVE #%d not supported", drive+1); |
| 481 | atari_set_frame_message(device, "DRIVE #%d not supported", drive+1); |
| 463 | 482 | return; |
| 464 | 483 | } |
| 465 | 484 | |
| 466 | 485 | /* extract sector number from the command buffer */ |
| 467 | | sector = atari_fdc.serout_buff[2] + 256 * atari_fdc.serout_buff[3]; |
| 486 | sector = fdc->serout_buff[2] + 256 * fdc->serout_buff[3]; |
| 468 | 487 | |
| 469 | | switch (atari_fdc.serout_buff[1]) /* command ? */ |
| 488 | switch (fdc->serout_buff[1]) /* command ? */ |
| 470 | 489 | { |
| 471 | 490 | case 'S': /* status */ |
| 472 | | atari_set_frame_message(machine, "DRIVE #%d STATUS", drive+1); |
| 491 | atari_set_frame_message(device, "DRIVE #%d STATUS", drive+1); |
| 473 | 492 | |
| 474 | 493 | if (VERBOSE_SERIAL) |
| 475 | 494 | logerror("atari status\n"); |
| 476 | 495 | |
| 477 | | add_serin('A',0); |
| 478 | | add_serin('C',0); |
| 479 | | if (!drv[drive].mode) /* read only mode ? */ |
| 496 | add_serin(device,'A',0); |
| 497 | add_serin(device,'C',0); |
| 498 | if (!fdc->drv[drive].mode) /* read only mode ? */ |
| 480 | 499 | { |
| 481 | | if (drv[drive].spt == 26) |
| 482 | | add_serin(0x80,1); /* MD: 0x80 */ |
| 500 | if (fdc->drv[drive].spt == 26) |
| 501 | add_serin(device,0x80,1); /* MD: 0x80 */ |
| 483 | 502 | else |
| 484 | | if (drv[drive].seclen == 128) |
| 485 | | add_serin(0x00,1); /* SD: 0x00 */ |
| 503 | if (fdc->drv[drive].seclen == 128) |
| 504 | add_serin(device,0x00,1); /* SD: 0x00 */ |
| 486 | 505 | else |
| 487 | | add_serin(0x20,1); /* DD: 0x20 */ |
| 506 | add_serin(device,0x20,1); /* DD: 0x20 */ |
| 488 | 507 | } |
| 489 | 508 | else |
| 490 | 509 | { |
| 491 | | if (drv[drive].spt == 26) |
| 492 | | add_serin(0x84,1); /* MD: 0x84 */ |
| 510 | if (fdc->drv[drive].spt == 26) |
| 511 | add_serin(device,0x84,1); /* MD: 0x84 */ |
| 493 | 512 | else |
| 494 | | if (drv[drive].seclen == 128) |
| 495 | | add_serin(0x04,1); /* SD: 0x04 */ |
| 513 | if (fdc->drv[drive].seclen == 128) |
| 514 | add_serin(device,0x04,1); /* SD: 0x04 */ |
| 496 | 515 | else |
| 497 | | add_serin(0x24,1); /* DD: 0x24 */ |
| 516 | add_serin(device,0x24,1); /* DD: 0x24 */ |
| 498 | 517 | } |
| 499 | | if (drv[drive].image) |
| 500 | | add_serin(0xff,1); /* door closed: 0xff */ |
| 518 | if (fdc->drv[drive].image) |
| 519 | add_serin(device,0xff,1); /* door closed: 0xff */ |
| 501 | 520 | else |
| 502 | | add_serin(0x7f,1); /* door open: 0x7f */ |
| 503 | | add_serin(0xe0,1); /* dunno */ |
| 504 | | add_serin(0x00,1); /* dunno */ |
| 505 | | add_serin(atari_fdc.serin_chksum,0); |
| 521 | add_serin(device,0x7f,1); /* door open: 0x7f */ |
| 522 | add_serin(device,0xe0,1); /* dunno */ |
| 523 | add_serin(device,0x00,1); /* dunno */ |
| 524 | add_serin(device,fdc->serin_chksum,0); |
| 506 | 525 | break; |
| 507 | 526 | |
| 508 | 527 | case 'R': /* read sector */ |
| 509 | 528 | if (VERBOSE_SERIAL) |
| 510 | 529 | logerror("atari read sector #%d\n", sector); |
| 511 | 530 | |
| 512 | | if( sector < 1 || sector > drv[drive].sectors ) |
| 531 | if( sector < 1 || sector > fdc->drv[drive].sectors ) |
| 513 | 532 | { |
| 514 | | atari_set_frame_message(machine, "DRIVE #%d READ SECTOR #%3d - ERR", drive+1, sector); |
| 533 | atari_set_frame_message(device, "DRIVE #%d READ SECTOR #%3d - ERR", drive+1, sector); |
| 515 | 534 | |
| 516 | 535 | if (VERBOSE_SERIAL) |
| 517 | 536 | logerror("atari bad sector #\n"); |
| 518 | 537 | |
| 519 | | add_serin('E',0); |
| 538 | add_serin(device,'E',0); |
| 520 | 539 | break; |
| 521 | 540 | } |
| 522 | | add_serin('A',0); /* acknowledge */ |
| 523 | | add_serin('C',0); /* completed */ |
| 541 | add_serin(device,'A',0); /* acknowledge */ |
| 542 | add_serin(device,'C',0); /* completed */ |
| 524 | 543 | if (sector < 4) /* sector 1 .. 3 might be different length */ |
| 525 | 544 | { |
| 526 | | atari_set_frame_message(machine, "DRIVE #%d READ SECTOR #%3d - SD", drive+1, sector); |
| 527 | | offset = (sector - 1) * drv[drive].bseclen + drv[drive].header_skip; |
| 545 | atari_set_frame_message(device, "DRIVE #%d READ SECTOR #%3d - SD", drive+1, sector); |
| 546 | offset = (sector - 1) * fdc->drv[drive].bseclen + fdc->drv[drive].header_skip; |
| 528 | 547 | for (i = 0; i < 128; i++) |
| 529 | | add_serin(drv[drive].image[offset++],1); |
| 548 | add_serin(device,fdc->drv[drive].image[offset++],1); |
| 530 | 549 | } |
| 531 | 550 | else |
| 532 | 551 | { |
| 533 | | atari_set_frame_message(machine, "DRIVE #%d READ SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 534 | | offset = (sector - 1) * drv[drive].seclen + drv[drive].header_skip; |
| 535 | | for (i = 0; i < drv[drive].seclen; i++) |
| 536 | | add_serin(drv[drive].image[offset++],1); |
| 552 | atari_set_frame_message(device, "DRIVE #%d READ SECTOR #%3d - %cD", drive+1, sector, (fdc->drv[drive].seclen == 128) ? 'S' : 'D'); |
| 553 | offset = (sector - 1) * fdc->drv[drive].seclen + fdc->drv[drive].header_skip; |
| 554 | for (i = 0; i < fdc->drv[drive].seclen; i++) |
| 555 | add_serin(device,fdc->drv[drive].image[offset++],1); |
| 537 | 556 | } |
| 538 | | add_serin(atari_fdc.serin_chksum,0); |
| 557 | add_serin(device,fdc->serin_chksum,0); |
| 539 | 558 | break; |
| 540 | 559 | |
| 541 | 560 | case 'W': /* write sector with verify */ |
| 542 | 561 | if (VERBOSE_SERIAL) |
| 543 | 562 | logerror("atari write sector #%d\n", sector); |
| 544 | 563 | |
| 545 | | add_serin('A',0); |
| 564 | add_serin(device,'A',0); |
| 546 | 565 | if (sector < 4) /* sector 1 .. 3 might be different length */ |
| 547 | 566 | { |
| 548 | | add_serout(drv[drive].bseclen); |
| 549 | | atari_set_frame_message(machine, "DRIVE #%d WRITE SECTOR #%3d - SD", drive+1, sector); |
| 567 | add_serout(device,fdc->drv[drive].bseclen); |
| 568 | atari_set_frame_message(device, "DRIVE #%d WRITE SECTOR #%3d - SD", drive+1, sector); |
| 550 | 569 | } |
| 551 | 570 | else |
| 552 | 571 | { |
| 553 | | add_serout(drv[drive].seclen); |
| 554 | | atari_set_frame_message(machine, "DRIVE #%d WRITE SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 572 | add_serout(device,fdc->drv[drive].seclen); |
| 573 | atari_set_frame_message(device, "DRIVE #%d WRITE SECTOR #%3d - %cD", drive+1, sector, (fdc->drv[drive].seclen == 128) ? 'S' : 'D'); |
| 555 | 574 | } |
| 556 | 575 | break; |
| 557 | 576 | |
| r6746 | r6747 | |
| 559 | 578 | if (VERBOSE_SERIAL) |
| 560 | 579 | logerror("atari put sector #%d\n", sector); |
| 561 | 580 | |
| 562 | | add_serin('A',0); |
| 581 | add_serin(device,'A',0); |
| 563 | 582 | if (sector < 4) /* sector 1 .. 3 might be different length */ |
| 564 | 583 | { |
| 565 | | add_serout(drv[drive].bseclen); |
| 566 | | atari_set_frame_message(machine, "DRIVE #%d PUT SECTOR #%3d - SD", drive+1, sector); |
| 584 | add_serout(device,fdc->drv[drive].bseclen); |
| 585 | atari_set_frame_message(device, "DRIVE #%d PUT SECTOR #%3d - SD", drive+1, sector); |
| 567 | 586 | } |
| 568 | 587 | else |
| 569 | 588 | { |
| 570 | | add_serout(drv[drive].seclen); |
| 571 | | atari_set_frame_message(machine, "DRIVE #%d PUT SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 589 | add_serout(device,fdc->drv[drive].seclen); |
| 590 | atari_set_frame_message(device, "DRIVE #%d PUT SECTOR #%3d - %cD", drive+1, sector, (fdc->drv[drive].seclen == 128) ? 'S' : 'D'); |
| 572 | 591 | } |
| 573 | 592 | break; |
| 574 | 593 | |
| r6746 | r6747 | |
| 576 | 595 | if (VERBOSE_SERIAL) |
| 577 | 596 | logerror("atari format SD drive #%d\n", drive+1); |
| 578 | 597 | |
| 579 | | atari_set_frame_message(machine, "DRIVE #%d FORMAT SD", drive+1); |
| 580 | | add_serin('A',0); /* acknowledge */ |
| 581 | | add_serin('C',0); /* completed */ |
| 598 | atari_set_frame_message(device, "DRIVE #%d FORMAT SD", drive+1); |
| 599 | add_serin(device,'A',0); /* acknowledge */ |
| 600 | add_serin(device,'C',0); /* completed */ |
| 582 | 601 | for (i = 0; i < 128; i++) |
| 583 | | add_serin(0,1); |
| 584 | | add_serin(atari_fdc.serin_chksum,0); |
| 602 | add_serin(device,0,1); |
| 603 | add_serin(device,fdc->serin_chksum,0); |
| 585 | 604 | break; |
| 586 | 605 | |
| 587 | 606 | case '"': /* DD format */ |
| 588 | 607 | if (VERBOSE_SERIAL) |
| 589 | 608 | logerror("atari format DD drive #%d\n", drive+1); |
| 590 | 609 | |
| 591 | | atari_set_frame_message(machine, "DRIVE #%d FORMAT DD", drive+1); |
| 592 | | add_serin('A',0); /* acknowledge */ |
| 593 | | add_serin('C',0); /* completed */ |
| 610 | atari_set_frame_message(device, "DRIVE #%d FORMAT DD", drive+1); |
| 611 | add_serin(device,'A',0); /* acknowledge */ |
| 612 | add_serin(device,'C',0); /* completed */ |
| 594 | 613 | for (i = 0; i < 256; i++) |
| 595 | | add_serin(0,1); |
| 596 | | add_serin(atari_fdc.serin_chksum,0); |
| 614 | add_serin(device,0,1); |
| 615 | add_serin(device,fdc->serin_chksum,0); |
| 597 | 616 | break; |
| 598 | 617 | |
| 599 | 618 | default: |
| 600 | 619 | if (VERBOSE_SERIAL) |
| 601 | | logerror("atari unknown command #%c\n", atari_fdc.serout_buff[1]); |
| 620 | logerror("atari unknown command #%c\n", fdc->serout_buff[1]); |
| 602 | 621 | |
| 603 | | atari_set_frame_message(machine, "DRIVE #%d UNKNOWN CMD '%c'", drive+1, atari_fdc.serout_buff[1]); |
| 604 | | add_serin('N',0); /* negative acknowledge */ |
| 622 | atari_set_frame_message(device, "DRIVE #%d UNKNOWN CMD '%c'", drive+1, fdc->serout_buff[1]); |
| 623 | add_serin(device,'N',0); /* negative acknowledge */ |
| 605 | 624 | } |
| 606 | 625 | } |
| 607 | 626 | else |
| 608 | 627 | { |
| 609 | | atari_set_frame_message(machine, "serial cmd chksum error"); |
| 628 | atari_set_frame_message(device, "serial cmd chksum error"); |
| 610 | 629 | if (VERBOSE_SERIAL) |
| 611 | 630 | logerror("BAD\n"); |
| 612 | 631 | |
| 613 | | add_serin('E',0); |
| 632 | add_serin(device,'E',0); |
| 614 | 633 | } |
| 615 | 634 | if (VERBOSE_SERIAL) |
| 616 | | logerror("atari %d bytes to read\n", atari_fdc.serin_count); |
| 635 | logerror("atari %d bytes to read\n", fdc->serin_count); |
| 617 | 636 | } |
| 618 | 637 | |
| 619 | | static void a800_serial_write(running_machine *machine) |
| 638 | static void a800_serial_write(const device_config *device) |
| 620 | 639 | { |
| 621 | 640 | int i, drive, sector, offset; |
| 641 | atari_fdc_t *fdc = get_safe_token(device); |
| 622 | 642 | |
| 623 | 643 | if (VERBOSE_SERIAL) |
| 624 | 644 | { |
| 625 | 645 | logerror("atari serout %d bytes written : %02X ", |
| 626 | | atari_fdc.serout_offs, atari_fdc.serout_chksum); |
| 646 | fdc->serout_offs, fdc->serout_chksum); |
| 627 | 647 | } |
| 628 | 648 | |
| 629 | | clr_serin(machine, 80); |
| 630 | | if (atari_fdc.serout_chksum == 0) |
| 649 | clr_serin(device, 80); |
| 650 | if (fdc->serout_chksum == 0) |
| 631 | 651 | { |
| 632 | 652 | if (VERBOSE_SERIAL) |
| 633 | 653 | logerror("OK\n"); |
| 634 | 654 | |
| 635 | | add_serin('C',0); |
| 655 | add_serin(device,'C',0); |
| 636 | 656 | /* write the sector */ |
| 637 | | drive = atari_fdc.serout_buff[0] - '1'; /* drive # */ |
| 657 | drive = fdc->serout_buff[0] - '1'; /* drive # */ |
| 638 | 658 | /* not write protected and image available ? */ |
| 639 | | if (drv[drive].mode && drv[drive].image) |
| 659 | if (fdc->drv[drive].mode && fdc->drv[drive].image) |
| 640 | 660 | { |
| 641 | 661 | /* extract sector number from the command buffer */ |
| 642 | | sector = atari_fdc.serout_buff[2] + 256 * atari_fdc.serout_buff[3]; |
| 662 | sector = fdc->serout_buff[2] + 256 * fdc->serout_buff[3]; |
| 643 | 663 | if (sector < 4) /* sector 1 .. 3 might be different length */ |
| 644 | 664 | { |
| 645 | | offset = (sector - 1) * drv[drive].bseclen + drv[drive].header_skip; |
| 665 | offset = (sector - 1) * fdc->drv[drive].bseclen + fdc->drv[drive].header_skip; |
| 646 | 666 | |
| 647 | 667 | if (VERBOSE_SERIAL) |
| 648 | 668 | logerror("atari storing 128 byte sector %d at offset 0x%08X", sector, offset ); |
| 649 | 669 | |
| 650 | 670 | for (i = 0; i < 128; i++) |
| 651 | | drv[drive].image[offset++] = atari_fdc.serout_buff[5+i]; |
| 652 | | atari_set_frame_message(machine, "DRIVE #%d WROTE SECTOR #%3d - SD", drive+1, sector); |
| 671 | fdc->drv[drive].image[offset++] = fdc->serout_buff[5+i]; |
| 672 | atari_set_frame_message(device, "DRIVE #%d WROTE SECTOR #%3d - SD", drive+1, sector); |
| 653 | 673 | } |
| 654 | 674 | else |
| 655 | 675 | { |
| 656 | | offset = (sector - 1) * drv[drive].seclen + drv[drive].header_skip; |
| 676 | offset = (sector - 1) * fdc->drv[drive].seclen + fdc->drv[drive].header_skip; |
| 657 | 677 | |
| 658 | 678 | if (VERBOSE_SERIAL) |
| 659 | | logerror("atari storing %d byte sector %d at offset 0x%08X", drv[drive].seclen, sector, offset ); |
| 679 | logerror("atari storing %d byte sector %d at offset 0x%08X", fdc->drv[drive].seclen, sector, offset ); |
| 660 | 680 | |
| 661 | | for (i = 0; i < drv[drive].seclen; i++) |
| 662 | | drv[drive].image[offset++] = atari_fdc.serout_buff[5+i]; |
| 663 | | atari_set_frame_message(machine, "DRIVE #%d WROTE SECTOR #%3d - %cD", drive+1, sector, (drv[drive].seclen == 128) ? 'S' : 'D'); |
| 681 | for (i = 0; i < fdc->drv[drive].seclen; i++) |
| 682 | fdc->drv[drive].image[offset++] = fdc->serout_buff[5+i]; |
| 683 | atari_set_frame_message(device, "DRIVE #%d WROTE SECTOR #%3d - %cD", drive+1, sector, (fdc->drv[drive].seclen == 128) ? 'S' : 'D'); |
| 664 | 684 | } |
| 665 | | add_serin('C',0); |
| 685 | add_serin(device,'C',0); |
| 666 | 686 | } |
| 667 | 687 | else |
| 668 | 688 | { |
| 669 | | add_serin('E',0); |
| 689 | add_serin(device,'E',0); |
| 670 | 690 | } |
| 671 | 691 | } |
| 672 | 692 | else |
| r6746 | r6747 | |
| 674 | 694 | if (VERBOSE_SERIAL) |
| 675 | 695 | logerror("BAD\n"); |
| 676 | 696 | |
| 677 | | add_serin('E',0); |
| 697 | add_serin(device,'E',0); |
| 678 | 698 | } |
| 679 | 699 | } |
| 680 | 700 | |
| 681 | | READ8_HANDLER ( atari_serin_r ) |
| 701 | READ8_DEVICE_HANDLER ( atari_serin_r ) |
| 682 | 702 | { |
| 683 | 703 | int data = 0x00; |
| 684 | 704 | int ser_delay = 0; |
| 705 | atari_fdc_t *fdc = get_safe_token(device); |
| 685 | 706 | |
| 686 | | if (atari_fdc.serin_count) |
| 707 | if (fdc->serin_count) |
| 687 | 708 | { |
| 688 | | const device_config *pokey = devtag_get_device(space->machine, "pokey"); |
| 709 | const device_config *pokey = devtag_get_device(device->machine, "pokey"); |
| 689 | 710 | |
| 690 | | data = atari_fdc.serin_buff[atari_fdc.serin_offs]; |
| 711 | data = fdc->serin_buff[fdc->serin_offs]; |
| 691 | 712 | ser_delay = 2 * 40; |
| 692 | | if (atari_fdc.serin_offs < 3) |
| 713 | if (fdc->serin_offs < 3) |
| 693 | 714 | { |
| 694 | 715 | ser_delay = 4 * 40; |
| 695 | | if (atari_fdc.serin_offs < 2) |
| 716 | if (fdc->serin_offs < 2) |
| 696 | 717 | ser_delay = 200 * 40; |
| 697 | 718 | } |
| 698 | | atari_fdc.serin_offs++; |
| 699 | | if (--atari_fdc.serin_count == 0) |
| 700 | | atari_fdc.serin_offs = 0; |
| 719 | fdc->serin_offs++; |
| 720 | if (--fdc->serin_count == 0) |
| 721 | fdc->serin_offs = 0; |
| 701 | 722 | else |
| 702 | 723 | pokey_serin_ready(pokey, ser_delay); |
| 703 | 724 | } |
| 704 | 725 | |
| 705 | 726 | if (VERBOSE_SERIAL) |
| 706 | | logerror("atari serin[$%04x] -> $%02x; delay %d\n", atari_fdc.serin_offs, data, ser_delay); |
| 727 | logerror("atari serin[$%04x] -> $%02x; delay %d\n", fdc->serin_offs, data, ser_delay); |
| 707 | 728 | |
| 708 | 729 | return data; |
| 709 | 730 | } |
| 710 | 731 | |
| 711 | | WRITE8_HANDLER ( atari_serout_w ) |
| 732 | WRITE8_DEVICE_HANDLER ( atari_serout_w ) |
| 712 | 733 | { |
| 713 | | const device_config *pia = devtag_get_device( space->machine, "pia" ); |
| 734 | const device_config *pia = devtag_get_device( device->machine, "pia" ); |
| 735 | atari_fdc_t *fdc = get_safe_token(device); |
| 714 | 736 | |
| 715 | 737 | /* ignore serial commands if no floppy image is specified */ |
| 716 | | if( !drv[0].image ) |
| 738 | if( !fdc->drv[0].image ) |
| 717 | 739 | return; |
| 718 | | if (atari_fdc.serout_count) |
| 740 | if (fdc->serout_count) |
| 719 | 741 | { |
| 720 | 742 | /* store data */ |
| 721 | | atari_fdc.serout_buff[atari_fdc.serout_offs] = data; |
| 743 | fdc->serout_buff[fdc->serout_offs] = data; |
| 722 | 744 | |
| 723 | 745 | if (VERBOSE_SERIAL) |
| 724 | | logerror("atari serout[$%04x] <- $%02x; count %d\n", atari_fdc.serout_offs, data, atari_fdc.serout_count); |
| 746 | logerror("atari serout[$%04x] <- $%02x; count %d\n", fdc->serout_offs, data, fdc->serout_count); |
| 725 | 747 | |
| 726 | | atari_fdc.serout_offs++; |
| 727 | | if (--atari_fdc.serout_count == 0) |
| 748 | fdc->serout_offs++; |
| 749 | if (--fdc->serout_count == 0) |
| 728 | 750 | { |
| 729 | 751 | /* exclusive or written checksum with calculated */ |
| 730 | | atari_fdc.serout_chksum ^= data; |
| 752 | fdc->serout_chksum ^= data; |
| 731 | 753 | /* if the attention line is high, this should be data */ |
| 732 | 754 | if (pia6821_get_irq_b(pia)) |
| 733 | | a800_serial_write(space->machine); |
| 755 | a800_serial_write(device); |
| 734 | 756 | } |
| 735 | 757 | else |
| 736 | 758 | { |
| 737 | | make_chksum(&atari_fdc.serout_chksum, data); |
| 759 | make_chksum(&fdc->serout_chksum, data); |
| 738 | 760 | } |
| 739 | 761 | } |
| 740 | 762 | } |
| 741 | 763 | |
| 742 | 764 | WRITE_LINE_DEVICE_HANDLER(atarifdc_pia_cb2_w) |
| 743 | 765 | { |
| 766 | atari_fdc_t *fdc = get_safe_token(device); |
| 744 | 767 | if (!state) |
| 745 | 768 | { |
| 746 | | clr_serout(4); /* expect 4 command bytes + checksum */ |
| 769 | clr_serout(device,4); /* expect 4 command bytes + checksum */ |
| 747 | 770 | } |
| 748 | 771 | else |
| 749 | 772 | { |
| 750 | | atari_fdc.serin_delay = 0; |
| 751 | | a800_serial_command(device->machine); |
| 773 | fdc->serin_delay = 0; |
| 774 | a800_serial_command(device); |
| 752 | 775 | } |
| 753 | 776 | } |
| 777 | |
| 778 | static FLOPPY_IDENTIFY( atari_dsk_identify ) |
| 779 | { |
| 780 | *vote = 100; |
| 781 | return FLOPPY_ERROR_SUCCESS; |
| 782 | } |
| 783 | |
| 784 | |
| 785 | static FLOPPY_CONSTRUCT( atari_dsk_construct ) |
| 786 | { |
| 787 | return FLOPPY_ERROR_SUCCESS; |
| 788 | } |
| 789 | |
| 790 | FLOPPY_OPTIONS_START( atari_only ) |
| 791 | FLOPPY_OPTION( |
| 792 | atari_dsk, |
| 793 | "atr,dsk,xfd", |
| 794 | "Atari floppy disk image", |
| 795 | atari_dsk_identify, |
| 796 | atari_dsk_construct, |
| 797 | NULL |
| 798 | ) |
| 799 | { NULL } |
| 800 | }; |
| 801 | |
| 802 | static const floppy_config atari_floppy_config = |
| 803 | { |
| 804 | DEVCB_NULL, |
| 805 | DEVCB_NULL, |
| 806 | DEVCB_NULL, |
| 807 | DEVCB_NULL, |
| 808 | DEVCB_NULL, |
| 809 | FLOPPY_DRIVE_DS_80, |
| 810 | FLOPPY_OPTIONS_NAME(atari_only), |
| 811 | DO_NOT_KEEP_GEOMETRY |
| 812 | }; |
| 813 | |
| 814 | static MACHINE_DRIVER_START( atari_fdc ) |
| 815 | MDRV_FLOPPY_4_DRIVES_ADD(atari_floppy_config) |
| 816 | MACHINE_DRIVER_END |
| 817 | |
| 818 | const device_config *atari_floppy_get_device_child(const device_config *device,int drive) |
| 819 | { |
| 820 | switch(drive) { |
| 821 | case 0 : return device_find_child_by_tag(device,FLOPPY_0); |
| 822 | case 1 : return device_find_child_by_tag(device,FLOPPY_1); |
| 823 | case 2 : return device_find_child_by_tag(device,FLOPPY_2); |
| 824 | case 3 : return device_find_child_by_tag(device,FLOPPY_3); |
| 825 | } |
| 826 | return NULL; |
| 827 | } |
| 828 | |
| 829 | static DEVICE_START(atari_fdc) |
| 830 | { |
| 831 | int id; |
| 832 | for(id=0;id<4;id++) |
| 833 | { |
| 834 | floppy_install_load_proc(atari_floppy_get_device_child(device, id), atari_load_proc); |
| 835 | } |
| 836 | } |
| 837 | |
| 838 | static DEVICE_RESET(atari_fdc) |
| 839 | { |
| 840 | } |
| 841 | |
| 842 | DEVICE_GET_INFO( atari_fdc ) |
| 843 | { |
| 844 | switch (state) |
| 845 | { |
| 846 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 847 | case DEVINFO_INT_INLINE_CONFIG_BYTES: info->i = 0; break; |
| 848 | case DEVINFO_INT_TOKEN_BYTES: info->i = sizeof(atari_fdc_t); break; |
| 849 | case DEVINFO_INT_CLASS: info->i = DEVICE_CLASS_PERIPHERAL; break; |
| 850 | |
| 851 | /* --- the following bits of info are returned as pointers --- */ |
| 852 | case DEVINFO_PTR_MACHINE_CONFIG: info->machine_config = MACHINE_DRIVER_NAME(atari_fdc); break; |
| 853 | |
| 854 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 855 | case DEVINFO_FCT_START: info->start = DEVICE_START_NAME(atari_fdc); break; |
| 856 | case DEVINFO_FCT_STOP: /* Nothing */ break; |
| 857 | case DEVINFO_FCT_RESET: info->reset = DEVICE_RESET_NAME(atari_fdc); break; |
| 858 | |
| 859 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 860 | case DEVINFO_STR_NAME: strcpy(info->s, "Atari FDC"); break; |
| 861 | case DEVINFO_STR_FAMILY: strcpy(info->s, "Atari FDC"); break; |
| 862 | case DEVINFO_STR_VERSION: strcpy(info->s, "1.0"); break; |
| 863 | case DEVINFO_STR_SOURCE_FILE: strcpy(info->s, __FILE__); break; |
| 864 | case DEVINFO_STR_CREDITS: strcpy(info->s, "Copyright the MESS Team"); break; |
| 865 | } |
| 866 | } |
src/mess/drivers/atari.c
| r6746 | r6747 | |
| 856 | 856 | DEVCB_INPUT_PORT("analog_7") |
| 857 | 857 | }, |
| 858 | 858 | DEVCB_NULL, |
| 859 | | DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, atari_serin_r), |
| 860 | | DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, atari_serout_w), |
| 859 | DEVCB_DEVICE_HANDLER("fdc", atari_serin_r), |
| 860 | DEVCB_DEVICE_HANDLER("fdc", atari_serout_w), |
| 861 | 861 | atari_interrupt_cb, |
| 862 | 862 | }; |
| 863 | 863 | |
| r6746 | r6747 | |
| 873 | 873 | DEVCB_NULL, /* port A out */ |
| 874 | 874 | DEVCB_NULL, /* port B out */ |
| 875 | 875 | DEVCB_NULL, /* line CA2 out */ |
| 876 | | DEVCB_LINE(atarifdc_pia_cb2_w), /* port CB2 out */ |
| 876 | DEVCB_DEVICE_LINE("fdc",atarifdc_pia_cb2_w), /* port CB2 out */ |
| 877 | 877 | DEVCB_NULL, /* IRQA */ |
| 878 | 878 | DEVCB_NULL /* IRQB */ |
| 879 | 879 | }; |
| r6746 | r6747 | |
| 889 | 889 | DEVCB_NULL, /* port A out */ |
| 890 | 890 | DEVCB_HANDLER(a600xl_pia_pb_w), /* port B out */ |
| 891 | 891 | DEVCB_NULL, /* line CA2 out */ |
| 892 | | DEVCB_LINE(atarifdc_pia_cb2_w), /* port CB2 out */ |
| 892 | DEVCB_DEVICE_LINE("fdc",atarifdc_pia_cb2_w), /* port CB2 out */ |
| 893 | 893 | DEVCB_NULL, /* IRQA */ |
| 894 | 894 | DEVCB_NULL /* IRQB */ |
| 895 | 895 | }; |
| r6746 | r6747 | |
| 905 | 905 | DEVCB_NULL, /* port A out */ |
| 906 | 906 | DEVCB_HANDLER(a1200xl_pia_pb_w), /* port B out */ |
| 907 | 907 | DEVCB_NULL, /* line CA2 out */ |
| 908 | | DEVCB_LINE(atarifdc_pia_cb2_w), /* port CB2 out */ |
| 908 | DEVCB_DEVICE_LINE("fdc",atarifdc_pia_cb2_w), /* port CB2 out */ |
| 909 | 909 | DEVCB_NULL, /* IRQA */ |
| 910 | 910 | DEVCB_NULL /* IRQB */ |
| 911 | 911 | }; |
| r6746 | r6747 | |
| 921 | 921 | DEVCB_NULL, /* port A out */ |
| 922 | 922 | DEVCB_HANDLER(a800xl_pia_pb_w), /* port B out */ |
| 923 | 923 | DEVCB_NULL, /* line CA2 out */ |
| 924 | | DEVCB_LINE(atarifdc_pia_cb2_w), /* port CB2 out */ |
| 924 | DEVCB_DEVICE_LINE("fdc",atarifdc_pia_cb2_w), /* port CB2 out */ |
| 925 | 925 | DEVCB_NULL, /* IRQA */ |
| 926 | 926 | DEVCB_NULL /* IRQB */ |
| 927 | 927 | }; |
| r6746 | r6747 | |
| 981 | 981 | /* internal ram */ |
| 982 | 982 | MDRV_RAM_ADD("messram") |
| 983 | 983 | MDRV_RAM_DEFAULT_SIZE("40K") |
| 984 | |
| 985 | MDRV_ATARI_FDC_ADD("fdc") |
| 984 | 986 | MACHINE_DRIVER_END |
| 985 | 987 | |
| 986 | 988 | |
| r6746 | r6747 | |
| 1254 | 1256 | |
| 1255 | 1257 | /************************************************************** |
| 1256 | 1258 | * |
| 1257 | | * Configs |
| 1258 | | * |
| 1259 | | **************************************************************/ |
| 1260 | | |
| 1261 | | static void atari_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 1262 | | { |
| 1263 | | /* floppy */ |
| 1264 | | switch(state) |
| 1265 | | { |
| 1266 | | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 1267 | | case MESS_DEVINFO_INT_TYPE: info->i = IO_FLOPPY; break; |
| 1268 | | case MESS_DEVINFO_INT_READABLE: info->i = 1; break; |
| 1269 | | case MESS_DEVINFO_INT_WRITEABLE: info->i = 1; break; |
| 1270 | | case MESS_DEVINFO_INT_CREATABLE: info->i = 1; break; |
| 1271 | | case MESS_DEVINFO_INT_COUNT: info->i = 4; break; |
| 1272 | | |
| 1273 | | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 1274 | | case MESS_DEVINFO_PTR_LOAD: info->load = DEVICE_IMAGE_LOAD_NAME(a800_floppy); break; |
| 1275 | | |
| 1276 | | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 1277 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "atr,dsk,xfd"); break; |
| 1278 | | } |
| 1279 | | } |
| 1280 | | |
| 1281 | | static SYSTEM_CONFIG_START(atari) |
| 1282 | | CONFIG_DEVICE(atari_floppy_getinfo) |
| 1283 | | SYSTEM_CONFIG_END |
| 1284 | | |
| 1285 | | /************************************************************** |
| 1286 | | * |
| 1287 | 1259 | * Driver initializations |
| 1288 | 1260 | * |
| 1289 | 1261 | **************************************************************/ |
| r6746 | r6747 | |
| 1306 | 1278 | **************************************************************/ |
| 1307 | 1279 | |
| 1308 | 1280 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 1309 | | COMP ( 1979, a400, 0, 0, a400, a800, 0, atari, "Atari", "Atari 400 (NTSC)", 0) |
| 1310 | | COMP ( 1979, a400pal, a400, 0, a400pal, a800, 0, atari, "Atari", "Atari 400 (PAL)", 0) |
| 1311 | | COMP ( 1979, a800, 0, 0, a800, a800, 0, atari, "Atari", "Atari 800 (NTSC)", 0) |
| 1312 | | COMP ( 1979, a800pal, a800, 0, a800pal, a800, 0, atari, "Atari", "Atari 800 (PAL)", 0) |
| 1313 | | COMP ( 1982, a1200xl, a800, 0, a1200xl, a800xl, a800xl, atari, "Atari", "Atari 1200XL", GAME_NOT_WORKING ) // 64k RAM |
| 1314 | | COMP ( 1983, a600xl, a800xl, 0, a600xl, a800xl, a600xl, atari, "Atari", "Atari 600XL", GAME_NOT_WORKING ) // 16k RAM |
| 1315 | | COMP ( 1983, a800xl, 0, 0, a800xl, a800xl, a800xl, atari, "Atari", "Atari 800XL (NTSC)",GAME_IMPERFECT_GRAPHICS ) // 64k RAM |
| 1316 | | COMP ( 1983, a800xlp, a800xl, 0, a800xlpal, a800xl, a800xl, atari, "Atari", "Atari 800XL (PAL)", GAME_IMPERFECT_GRAPHICS ) // 64k RAM |
| 1317 | | COMP ( 1986, a65xe, a800xl, 0, a800xl, a800xl, a800xl, atari, "Atari", "Atari 65XE", GAME_NOT_WORKING ) // 64k RAM |
| 1318 | | COMP ( 1986, a65xea, a800xl, 0, a800xl, a800xl, a800xl, atari, "Atari", "Atari 65XE (Arabic)", GAME_NOT_WORKING ) |
| 1319 | | COMP ( 1986, a130xe, a800xl, 0, a800xl, a800xl, a800xl, atari, "Atari", "Atari 130XE", GAME_NOT_WORKING ) // 128k RAM |
| 1320 | | COMP ( 1986, a800xe, a800xl, 0, a800xl, a800xl, a800xl, atari, "Atari", "Atari 800XE", GAME_NOT_WORKING ) // 64k RAM |
| 1321 | | COMP ( 1987, xegs, 0, 0, a800xl, a800xl, a800xl, atari, "Atari", "Atari XE Game System", GAME_NOT_WORKING ) // 64k RAM |
| 1281 | COMP ( 1979, a400, 0, 0, a400, a800, 0, 0, "Atari", "Atari 400 (NTSC)", 0) |
| 1282 | COMP ( 1979, a400pal, a400, 0, a400pal, a800, 0, 0, "Atari", "Atari 400 (PAL)", 0) |
| 1283 | COMP ( 1979, a800, 0, 0, a800, a800, 0, 0, "Atari", "Atari 800 (NTSC)", 0) |
| 1284 | COMP ( 1979, a800pal, a800, 0, a800pal, a800, 0, 0, "Atari", "Atari 800 (PAL)", 0) |
| 1285 | COMP ( 1982, a1200xl, a800, 0, a1200xl, a800xl, a800xl, 0, "Atari", "Atari 1200XL", GAME_NOT_WORKING ) // 64k RAM |
| 1286 | COMP ( 1983, a600xl, a800xl, 0, a600xl, a800xl, a600xl, 0, "Atari", "Atari 600XL", GAME_NOT_WORKING ) // 16k RAM |
| 1287 | COMP ( 1983, a800xl, 0, 0, a800xl, a800xl, a800xl, 0, "Atari", "Atari 800XL (NTSC)",GAME_IMPERFECT_GRAPHICS ) // 64k RAM |
| 1288 | COMP ( 1983, a800xlp, a800xl, 0, a800xlpal, a800xl, a800xl, 0, "Atari", "Atari 800XL (PAL)", GAME_IMPERFECT_GRAPHICS ) // 64k RAM |
| 1289 | COMP ( 1986, a65xe, a800xl, 0, a800xl, a800xl, a800xl, 0, "Atari", "Atari 65XE", GAME_NOT_WORKING ) // 64k RAM |
| 1290 | COMP ( 1986, a65xea, a800xl, 0, a800xl, a800xl, a800xl, 0, "Atari", "Atari 65XE (Arabic)", GAME_NOT_WORKING ) |
| 1291 | COMP ( 1986, a130xe, a800xl, 0, a800xl, a800xl, a800xl, 0, "Atari", "Atari 130XE", GAME_NOT_WORKING ) // 128k RAM |
| 1292 | COMP ( 1986, a800xe, a800xl, 0, a800xl, a800xl, a800xl, 0, "Atari", "Atari 800XE", GAME_NOT_WORKING ) // 64k RAM |
| 1293 | COMP ( 1987, xegs, 0, 0, a800xl, a800xl, a800xl, 0, "Atari", "Atari XE Game System", GAME_NOT_WORKING ) // 64k RAM |
| 1322 | 1294 | |
| 1323 | | CONS ( 1982, a5200, 0, 0, a5200, a5200, 0, atari, "Atari", "Atari 5200", 0) |
| 1295 | CONS ( 1982, a5200, 0, 0, a5200, a5200, 0, 0, "Atari", "Atari 5200", 0) |