src/mess/formats/flopimg.c
| r5814 | r5815 | |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
| 570 | | |
| 571 | | floperr_t floppy_clear_sector(floppy_image *floppy, int head, int track, int sector, UINT8 data) |
| 572 | | { |
| 573 | | floperr_t err; |
| 574 | | UINT32 length; |
| 575 | | UINT8 *buffer = NULL; |
| 576 | | |
| 577 | | err = floppy_get_sector_length(floppy, head, track, sector, &length); |
| 578 | | if (err) |
| 579 | | goto done; |
| 580 | | |
| 581 | | buffer = malloc(length); |
| 582 | | if (err) |
| 583 | | { |
| 584 | | err = FLOPPY_ERROR_OUTOFMEMORY; |
| 585 | | goto done; |
| 586 | | } |
| 587 | | |
| 588 | | memset(buffer, data, length); |
| 589 | | |
| 590 | | err = floppy_write_sector(floppy, head, track, sector, 0, buffer, length, 0); |
| 591 | | if (err) |
| 592 | | goto done; |
| 593 | | |
| 594 | | done: |
| 595 | | if (buffer) |
| 596 | | free(buffer); |
| 597 | | return err; |
| 598 | | } |
| 599 | | |
| 600 | | |
| 601 | | |
| 602 | 570 | static floperr_t floppy_get_track_data_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 603 | 571 | { |
| 604 | 572 | floperr_t err; |
src/mess/formats/flopimg.h
| r5814 | r5815 | |
| 166 | 166 | floperr_t floppy_write_sector(floppy_image *floppy, int head, int track, int sector, int offset, const void *buffer, size_t buffer_len, int ddam); |
| 167 | 167 | floperr_t floppy_read_indexed_sector(floppy_image *floppy, int head, int track, int sector_index, int offset, void *buffer, size_t buffer_len); |
| 168 | 168 | floperr_t floppy_write_indexed_sector(floppy_image *floppy, int head, int track, int sector_index, int offset, const void *buffer, size_t buffer_len, int ddam); |
| 169 | | floperr_t floppy_clear_sector(floppy_image *floppy, int head, int track, int sector, UINT8 data); |
| 170 | 169 | floperr_t floppy_read_track(floppy_image *floppy, int head, int track, void *buffer, size_t buffer_len); |
| 171 | 170 | floperr_t floppy_write_track(floppy_image *floppy, int head, int track, const void *buffer, size_t buffer_len); |
| 172 | 171 | floperr_t floppy_read_track_data(floppy_image *floppy, int head, int track, void *buffer, size_t buffer_len); |
src/mess/formats/td0_dsk.c
| r5814 | r5815 | |
| 90 | 90 | for(i=0;i < sector-1;i++) { |
| 91 | 91 | floppy_image_read(floppy, header, offs, 6); |
| 92 | 92 | offs+= 6; |
| 93 | | floppy_image_read(floppy, header+6, offs, 2); |
| 94 | | offs+= 2; |
| 95 | | offs+= header[6] + (header[7]<<8); |
| 93 | if ((header[4] & 0x30)==0) { |
| 94 | floppy_image_read(floppy, header+6, offs, 2); |
| 95 | offs+= 2; |
| 96 | offs+= header[6] + (header[7]<<8); |
| 97 | } |
| 96 | 98 | } |
| 97 | 99 | // read size of sector |
| 98 | 100 | floppy_image_read(floppy, header, offs, 6); |
| r5814 | r5815 | |
| 125 | 127 | // read sector header |
| 126 | 128 | floppy_image_read(floppy, header, offset, 6); |
| 127 | 129 | offset+=6; |
| 130 | // if there is no date just jump out |
| 131 | if ((header[4] & 0x30)!=0) return FLOPPY_ERROR_SUCCESS; |
| 132 | |
| 128 | 133 | floppy_image_read(floppy, header+6, offset, 3); |
| 129 | 134 | offset+=3; |
| 130 | 135 | // take data size |
| r5814 | r5815 | |
| 234 | 239 | if (sector_length) { |
| 235 | 240 | *sector_length = 1 << (sector_info[3] + 7); |
| 236 | 241 | } |
| 237 | | if (flags) |
| 242 | if (flags) { |
| 238 | 243 | *flags = 0; |
| 244 | if (sector_info[4] & 0x02) *flags |= ID_FLAG_CRC_ERROR_IN_DATA_FIELD; |
| 245 | if (sector_info[4] & 0x04) *flags |= ID_FLAG_DELETED_DATA; |
| 246 | } |
| 247 | |
| 239 | 248 | return retVal; |
| 240 | 249 | } |
| 241 | 250 | |
| r5814 | r5815 | |
| 284 | 293 | floppy_image_read(floppy, header, position, 6); |
| 285 | 294 | position+=6; |
| 286 | 295 | // read sector size |
| 287 | | floppy_image_read(floppy, header, position, 2); |
| 288 | | position+=2; |
| 289 | | // skip sector data |
| 290 | | position+= header[0] + (header[1]<<8); |
| 296 | if ((header[4] & 0x30)==0) { |
| 297 | // if there is sector data |
| 298 | floppy_image_read(floppy, header, position, 2); |
| 299 | position+=2; |
| 300 | // skip sector data |
| 301 | position+= header[0] + (header[1]<<8); |
| 302 | } |
| 291 | 303 | } |
| 292 | 304 | tag->tracks++; |
| 293 | 305 | } |