src/mess/formats/dsk_dsk.c
| r5682 | r5683 | |
| 20 | 20 | { |
| 21 | 21 | int disk_image_type; /* image type: standard or extended */ |
| 22 | 22 | int heads; |
| 23 | | int tracks; |
| 24 | | int tracksize; |
| 23 | int tracks; |
| 25 | 24 | int sector_size; |
| 25 | UINT64 track_offsets[84*2]; /* offset within data for each track */ |
| 26 | |
| 26 | 27 | }; |
| 27 | 28 | |
| 28 | 29 | |
| r5682 | r5683 | |
| 63 | 64 | |
| 64 | 65 | static UINT64 dsk_get_track_offset(floppy_image *floppy, int head, int track) |
| 65 | 66 | { |
| 66 | | return 0x100 + get_tag(floppy)->tracksize * ((track * get_tag(floppy)->heads) + head); |
| 67 | return get_tag(floppy)->track_offsets[(track<<1) + head]; |
| 67 | 68 | } |
| 68 | 69 | |
| 69 | 70 | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| r5682 | r5683 | |
| 180 | 181 | UINT8 sector_info[0x100]; |
| 181 | 182 | int pos; |
| 182 | 183 | |
| 183 | | retVal = get_offset(floppy, head, track, sector_index+1, TRUE, NULL); |
| 184 | retVal = get_offset(floppy, head, track, sector_index+1, FALSE, NULL); |
| 184 | 185 | offset = dsk_get_track_offset(floppy,head,track); |
| 185 | 186 | pos = 0x18 + (sector_index << 3); |
| 186 | 187 | floppy_image_read(floppy, sector_info, offset, 0x100); |
| r5682 | r5683 | |
| 192 | 193 | *sector = sector_info[pos + 2]; |
| 193 | 194 | if (sector_length) { |
| 194 | 195 | *sector_length = 1 << (sector_info[pos + 3] + 7); |
| 195 | | } |
| 196 | } |
| 197 | logerror("track : %d C %02x H %02x R %02x N %02x\n",track,sector_info[pos + 0],sector_info[pos + 1],sector_info[pos + 2],sector_info[pos + 3]); |
| 196 | 198 | if (flags) |
| 197 | 199 | *flags = (sector_info[pos + 5] & 0x40) ? ID_FLAG_DELETED_DATA : 0; |
| 198 | 200 | return retVal; |
| r5682 | r5683 | |
| 204 | 206 | struct FloppyCallbacks *callbacks; |
| 205 | 207 | struct dskdsk_tag *tag; |
| 206 | 208 | UINT8 header[0x100]; |
| 209 | UINT64 tmp = 0; |
| 210 | int i; |
| 211 | int skip,cnt; |
| 207 | 212 | |
| 208 | 213 | floppy_image_read(floppy, header, 0, 0x100); |
| 209 | 214 | |
| r5682 | r5683 | |
| 212 | 217 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 213 | 218 | |
| 214 | 219 | tag->heads = header[0x31]; |
| 220 | if (tag->heads==1) { |
| 221 | skip = 2; |
| 222 | } else { |
| 223 | skip = 1; |
| 224 | } |
| 215 | 225 | tag->tracks = header[0x30]; |
| 216 | | |
| 226 | cnt =0; |
| 217 | 227 | if ( memcmp( header, MV_CPC, 8 ) ==0) { |
| 218 | 228 | tag->disk_image_type = 0; |
| 219 | | tag->tracksize = pick_integer_le(header, 0x32, 2); |
| 229 | tmp = 0x100; |
| 230 | for (i=0; i<tag->tracks * tag->heads; i++) |
| 231 | { |
| 232 | tag->track_offsets[cnt] = tmp; |
| 233 | tmp += pick_integer_le(header, 0x32, 2); |
| 234 | cnt += skip; |
| 235 | } |
| 220 | 236 | } else { |
| 221 | 237 | tag->disk_image_type = 1; |
| 222 | | tag->tracksize = header[0x34] << 8; |
| 238 | tmp = 0x100; |
| 239 | for (i=0; i<tag->tracks * tag->heads; i++) |
| 240 | { |
| 241 | tag->track_offsets[cnt] = tmp; |
| 242 | tmp += header[0x34 + i] << 8; |
| 243 | cnt += skip; |
| 244 | } |
| 223 | 245 | } |
| 224 | 246 | |
| 225 | 247 | callbacks = floppy_callbacks(floppy); |