src/mess/formats/z80ne_dsk.c
| r5052 | r5053 | |
| 360 | 360 | return get_dmk_tag(floppy)->track_size; |
| 361 | 361 | } |
| 362 | 362 | |
| 363 | | void * my_memmem(UINT8 *haystack, size_t haystacklen, |
| 363 | UINT8 * my_memmem(UINT8 *haystack, size_t haystacklen, |
| 364 | 364 | UINT8 *needle, size_t needlelen) |
| 365 | 365 | { |
| 366 | 366 | register UINT8 *h = haystack; |
| r5052 | r5053 | |
| 369 | 369 | register size_t nl = needlelen; |
| 370 | 370 | register size_t i; |
| 371 | 371 | |
| 372 | | if (nl == 0) return (void *) haystack; /* The first occurrence of the empty string is deemed to occur at |
| 372 | if (nl == 0) return haystack; /* The first occurrence of the empty string is deemed to occur at |
| 373 | 373 | the beginning of the string. */ |
| 374 | 374 | if (hl < nl) |
| 375 | 375 | return NULL; |
| 376 | 376 | |
| 377 | 377 | for( i = 0; (i < hl) && (i + nl <= hl ); i++ ) |
| 378 | | if (h[i] == *n) /* first match */ |
| 379 | | if ( !memcmp(&h[i]+1, n + 1, nl - 1) ) |
| 380 | | return (void *)(haystack+i); /* returns a pointer to the substring */ |
| 378 | if (h[i] == *n) /* first match */ |
| 379 | if ( !memcmp(&h[i]+1, n + 1, nl - 1) ) |
| 380 | return (haystack+i); /* returns a pointer to the substring */ |
| 381 | 381 | |
| 382 | | return (void *)NULL; /* not found */ |
| 382 | return (UINT8 *)NULL; /* not found */ |
| 383 | 383 | } |
| 384 | 384 | |
| 385 | 385 | |
| r5052 | r5053 | |
| 483 | 483 | offs = idam_offset + 2 * DMK_IDAM_LEN; |
| 484 | 484 | |
| 485 | 485 | /* find pattern 0x0000FB; this represents the start of a data sector */ |
| 486 | | sec_data = my_memmem(&track_data[offs], 2 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_data, 10); |
| 486 | sec_data = my_memmem(&track_data[offs], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_data, 10); |
| 487 | 487 | if(!sec_data) |
| 488 | 488 | { |
| 489 | 489 | /* find pattern 0x0000FA; this represents the start of a deleted data sector (used for system sectors) */ |
| 490 | | sec_data = my_memmem(&track_data[offs], 2 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_fa, 10); |
| 490 | sec_data = my_memmem(&track_data[offs], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_fa, 10); |
| 491 | 491 | } |
| 492 | 492 | if(!sec_data) |
| 493 | 493 | { |
| 494 | 494 | /* find pattern 0x0000F8; this represents the start of a deleted data sector (used for system sectors) */ |
| 495 | | sec_data = my_memmem(&track_data[offs], 2 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_f8, 10); |
| 495 | sec_data = my_memmem(&track_data[offs], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_f8, 10); |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | if(sec_data) |
| r5052 | r5053 | |
| 557 | 557 | |
| 558 | 558 | /* determine type of data sector */ |
| 559 | 559 | /* find pattern 0x0000FB; this represents the start of a data sector */ |
| 560 | | if ( my_memmem(&track_data[idam_offset+14], 2 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_data, 10) ) |
| 560 | if ( my_memmem(&track_data[idam_offset+14], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_data, 10) ) |
| 561 | 561 | dam = 0; |
| 562 | 562 | /* find pattern 0x0000FA; this represents the start of a deleted data sector (used for system sectors) */ |
| 563 | | else if ( my_memmem(&track_data[idam_offset+14], 2 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_fa, 10) ) |
| 563 | else if ( my_memmem(&track_data[idam_offset+14], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_fa, 10) ) |
| 564 | 564 | dam = ID_FLAG_DELETED_DATA; |
| 565 | 565 | /* find pattern 0x0000F8; this represents the start of a deleted data sector (used for system sectors) */ |
| 566 | | else if ( my_memmem(&track_data[idam_offset+14], 2 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_f8, 10) ) |
| 566 | else if ( my_memmem(&track_data[idam_offset+14], 4 * (DMK_ID_GAP_LEN + DMK_DAM_LEN), (UINT8 *)needle_deleted_data_f8, 10) ) |
| 567 | 567 | dam = ID_FLAG_DELETED_DATA; |
| 568 | 568 | else |
| 569 | 569 | return FLOPPY_ERROR_SEEKERROR; |