src/lib/formats/d88_dsk.c
| r12282 | r12283 | |
| 41 | 41 | UINT8 heads; |
| 42 | 42 | }; |
| 43 | 43 | |
| 44 | | static struct d88_tag *get_d88_tag(floppy_image *floppy) |
| 44 | static struct d88_tag *get_d88_tag(floppy_image_legacy *floppy) |
| 45 | 45 | { |
| 46 | 46 | return (d88_tag *)floppy_tag(floppy); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | | static int d88_get_sector_id(floppy_image *floppy, int head, int track, int sector_index) |
| 49 | static int d88_get_sector_id(floppy_image_legacy *floppy, int head, int track, int sector_index) |
| 50 | 50 | { |
| 51 | 51 | struct d88_tag* tag = get_d88_tag(floppy); |
| 52 | 52 | UINT32 offset; |
| r12282 | r12283 | |
| 73 | 73 | return sector_hdr[2]; |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | | static int d88_get_tracks_per_disk(floppy_image *floppy) |
| 76 | static int d88_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 77 | 77 | { |
| 78 | 78 | return 82; // 82 tracks per side |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | | static int d88_get_heads_per_disk(floppy_image *floppy) |
| 81 | static int d88_get_heads_per_disk(floppy_image_legacy *floppy) |
| 82 | 82 | { |
| 83 | 83 | struct d88_tag* tag = get_d88_tag(floppy); |
| 84 | 84 | return tag->heads; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | | static int d88_get_sectors_per_track(floppy_image *floppy, int head, int track) |
| 87 | static int d88_get_sectors_per_track(floppy_image_legacy *floppy, int head, int track) |
| 88 | 88 | { |
| 89 | 89 | struct d88_tag* tag = get_d88_tag(floppy); |
| 90 | 90 | UINT32 offset; |
| r12282 | r12283 | |
| 97 | 97 | return sector_hdr[4]; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | | static floperr_t d88_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 100 | static floperr_t d88_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 101 | 101 | { |
| 102 | 102 | struct d88_tag* tag = get_d88_tag(floppy); |
| 103 | 103 | UINT32 offset; |
| r12282 | r12283 | |
| 127 | 127 | return FLOPPY_ERROR_SEEKERROR; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | | static floperr_t d88_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 130 | static floperr_t d88_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 131 | 131 | { |
| 132 | 132 | // floperr_t err; |
| 133 | 133 | |
| 134 | 134 | return FLOPPY_ERROR_UNSUPPORTED; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | | static UINT32 d88_get_sector_offset(floppy_image* floppy, int head, int track, int sector) |
| 137 | static UINT32 d88_get_sector_offset(floppy_image_legacy* floppy, int head, int track, int sector) |
| 138 | 138 | { |
| 139 | 139 | struct d88_tag* tag = get_d88_tag(floppy); |
| 140 | 140 | UINT32 offset = 0; |
| r12282 | r12283 | |
| 165 | 165 | return 0; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | | static floperr_t d88_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 168 | static floperr_t d88_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 169 | 169 | { |
| 170 | 170 | struct d88_tag* tag = get_d88_tag(floppy); |
| 171 | 171 | UINT32 offset; |
| r12282 | r12283 | |
| 210 | 210 | return FLOPPY_ERROR_SUCCESS; |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | | static floperr_t d88_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 213 | static floperr_t d88_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 214 | 214 | { |
| 215 | 215 | UINT64 offset; |
| 216 | 216 | UINT32 sector_length; |
| r12282 | r12283 | |
| 231 | 231 | return FLOPPY_ERROR_SUCCESS; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | | static floperr_t d88_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buffer_len) |
| 234 | static floperr_t d88_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buffer_len) |
| 235 | 235 | { |
| 236 | 236 | int sec; |
| 237 | 237 | |
| r12282 | r12283 | |
| 239 | 239 | return d88_read_sector(floppy,head,track,sec,buffer,buffer_len); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | | static floperr_t d88_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 242 | static floperr_t d88_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 243 | 243 | { |
| 244 | 244 | UINT64 offset; |
| 245 | 245 | UINT32 sector_length; |
| r12282 | r12283 | |
| 260 | 260 | return FLOPPY_ERROR_SUCCESS; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | | static floperr_t d88_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 263 | static floperr_t d88_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 264 | 264 | { |
| 265 | 265 | int sec; |
| 266 | 266 | |
| r12282 | r12283 | |
| 268 | 268 | return d88_write_sector(floppy,head,track,sec,buffer,buflen,ddam); |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | | static void d88_get_header(floppy_image* floppy,UINT32* size, UINT8* prot, UINT8* type, UINT32* offsets) |
| 271 | static void d88_get_header(floppy_image_legacy* floppy,UINT32* size, UINT8* prot, UINT8* type, UINT32* offsets) |
| 272 | 272 | { |
| 273 | 273 | UINT8 header[D88_HEADER_LEN]; |
| 274 | 274 | int x,s; |
src/lib/formats/cqm_dsk.c
| r12282 | r12283 | |
| 26 | 26 | }; |
| 27 | 27 | |
| 28 | 28 | |
| 29 | | static struct cqmdsk_tag *get_tag(floppy_image *floppy) |
| 29 | static struct cqmdsk_tag *get_tag(floppy_image_legacy *floppy) |
| 30 | 30 | { |
| 31 | 31 | struct cqmdsk_tag *tag; |
| 32 | 32 | tag = (cqmdsk_tag *)floppy_tag(floppy ); |
| r12282 | r12283 | |
| 48 | 48 | return FLOPPY_ERROR_SUCCESS; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | | static int cqm_get_heads_per_disk(floppy_image *floppy) |
| 51 | static int cqm_get_heads_per_disk(floppy_image_legacy *floppy) |
| 52 | 52 | { |
| 53 | 53 | return get_tag(floppy)->heads; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | | static int cqm_get_tracks_per_disk(floppy_image *floppy) |
| 56 | static int cqm_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 57 | 57 | { |
| 58 | 58 | return get_tag(floppy)->tracks; |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | | static UINT64 cqm_get_track_offset(floppy_image *floppy, int head, int track) |
| 61 | static UINT64 cqm_get_track_offset(floppy_image_legacy *floppy, int head, int track) |
| 62 | 62 | { |
| 63 | 63 | return get_tag(floppy)->track_offsets[(track<<1) + head]; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 66 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 67 | 67 | { |
| 68 | 68 | UINT64 pos = 0; |
| 69 | 69 | UINT8 data; |
| r12282 | r12283 | |
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | |
| 101 | | static floperr_t internal_cqm_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 101 | static floperr_t internal_cqm_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 102 | 102 | { |
| 103 | 103 | UINT64 offset; |
| 104 | 104 | floperr_t err; |
| r12282 | r12283 | |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | |
| 115 | | static floperr_t cqm_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 115 | static floperr_t cqm_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 116 | 116 | { |
| 117 | 117 | return internal_cqm_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | | static floperr_t cqm_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 120 | static floperr_t cqm_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 121 | 121 | { |
| 122 | 122 | return internal_cqm_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | | static floperr_t cqm_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 125 | static floperr_t cqm_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 126 | 126 | { |
| 127 | 127 | floperr_t err; |
| 128 | 128 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 135 | 135 | return FLOPPY_ERROR_SUCCESS; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | | static floperr_t cqm_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 138 | static floperr_t cqm_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 139 | 139 | { |
| 140 | 140 | if (sector_index >= get_tag(floppy)->sector_per_track) return FLOPPY_ERROR_SEEKERROR; |
| 141 | 141 | |
src/lib/formats/coco_dsk.c
| r12282 | r12283 | |
| 112 | 112 | * |
| 113 | 113 | * ----------------------------------------------------------------------- */ |
| 114 | 114 | |
| 115 | | static int coco_jvc_decode_header(floppy_image *floppy, UINT64 size, |
| 115 | static int coco_jvc_decode_header(floppy_image_legacy *floppy, UINT64 size, |
| 116 | 116 | struct basicdsk_geometry *geometry) |
| 117 | 117 | { |
| 118 | 118 | UINT8 header[256]; |
| r12282 | r12283 | |
| 294 | 294 | * $3F 1 value $02 LSN for start of this directory |
| 295 | 295 | * ----------------------------------------------------------------------- */ |
| 296 | 296 | |
| 297 | | static floperr_t coco_os9_readheader(floppy_image *floppy, struct basicdsk_geometry *geometry) |
| 297 | static floperr_t coco_os9_readheader(floppy_image_legacy *floppy, struct basicdsk_geometry *geometry) |
| 298 | 298 | { |
| 299 | 299 | UINT8 header[0x20]; |
| 300 | 300 | int total_sectors; |
| r12282 | r12283 | |
| 322 | 322 | |
| 323 | 323 | |
| 324 | 324 | |
| 325 | | static floperr_t coco_os9_post_format(floppy_image *floppy, option_resolution *params) |
| 325 | static floperr_t coco_os9_post_format(floppy_image_legacy *floppy, option_resolution *params) |
| 326 | 326 | { |
| 327 | 327 | UINT8 header[0x0400]; |
| 328 | 328 | floperr_t err; |
| r12282 | r12283 | |
| 484 | 484 | |
| 485 | 485 | |
| 486 | 486 | |
| 487 | | static int coco_vdk_decode_header(floppy_image *floppy, struct basicdsk_geometry *geometry) |
| 487 | static int coco_vdk_decode_header(floppy_image_legacy *floppy, struct basicdsk_geometry *geometry) |
| 488 | 488 | { |
| 489 | 489 | UINT8 header[12]; |
| 490 | 490 | int heads, tracks, sectors, sector_length, offset; |
| r12282 | r12283 | |
| 633 | 633 | #define dmk_idam_set_crc(x, crc) (x)[5] = ((crc) >> 8); (x)[6] = ((crc) >> 0); |
| 634 | 634 | |
| 635 | 635 | |
| 636 | | static struct dmk_tag *get_dmk_tag(floppy_image *floppy) |
| 636 | static struct dmk_tag *get_dmk_tag(floppy_image_legacy *floppy) |
| 637 | 637 | { |
| 638 | 638 | return (dmk_tag *)floppy_tag(floppy); |
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | |
| 642 | | static floperr_t coco_dmk_get_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 642 | static floperr_t coco_dmk_get_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) |
| 643 | 643 | { |
| 644 | 644 | struct dmk_tag *tag = get_dmk_tag(floppy); |
| 645 | 645 | |
| r12282 | r12283 | |
| 665 | 665 | |
| 666 | 666 | |
| 667 | 667 | |
| 668 | | static floperr_t coco_dmk_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 668 | static floperr_t coco_dmk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 669 | 669 | { |
| 670 | 670 | floperr_t err; |
| 671 | 671 | UINT64 track_offset; |
| r12282 | r12283 | |
| 680 | 680 | |
| 681 | 681 | |
| 682 | 682 | |
| 683 | | static floperr_t coco_dmk_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 683 | static floperr_t coco_dmk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 684 | 684 | { |
| 685 | 685 | floperr_t err; |
| 686 | 686 | UINT64 track_offset; |
| r12282 | r12283 | |
| 695 | 695 | |
| 696 | 696 | |
| 697 | 697 | |
| 698 | | static floperr_t coco_dmk_get_track_data_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 698 | static floperr_t coco_dmk_get_track_data_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) |
| 699 | 699 | { |
| 700 | 700 | *offset = DMK_TOC_LEN + 1; |
| 701 | 701 | return FLOPPY_ERROR_SUCCESS; |
| r12282 | r12283 | |
| 703 | 703 | |
| 704 | 704 | |
| 705 | 705 | |
| 706 | | static floperr_t coco_dmk_format_track(floppy_image *floppy, int head, int track, option_resolution *params) |
| 706 | static floperr_t coco_dmk_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params) |
| 707 | 707 | { |
| 708 | 708 | int sectors; |
| 709 | 709 | int sector_length; |
| r12282 | r12283 | |
| 843 | 843 | |
| 844 | 844 | |
| 845 | 845 | |
| 846 | | static int coco_dmk_get_heads_per_disk(floppy_image *floppy) |
| 846 | static int coco_dmk_get_heads_per_disk(floppy_image_legacy *floppy) |
| 847 | 847 | { |
| 848 | 848 | return get_dmk_tag(floppy)->heads; |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | |
| 852 | 852 | |
| 853 | | static int coco_dmk_get_tracks_per_disk(floppy_image *floppy) |
| 853 | static int coco_dmk_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 854 | 854 | { |
| 855 | 855 | return get_dmk_tag(floppy)->tracks; |
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | |
| 859 | 859 | |
| 860 | | static UINT32 coco_dmk_get_track_size(floppy_image *floppy, int head, int track) |
| 860 | static UINT32 coco_dmk_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 861 | 861 | { |
| 862 | 862 | return get_dmk_tag(floppy)->track_size; |
| 863 | 863 | } |
| 864 | 864 | |
| 865 | 865 | |
| 866 | 866 | |
| 867 | | static floperr_t coco_dmk_seek_sector_in_track(floppy_image *floppy, int head, int track, int sector, int sector_is_index, int dirtify, UINT8 **sector_data, UINT32 *sector_length) |
| 867 | static floperr_t coco_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, int dirtify, UINT8 **sector_data, UINT32 *sector_length) |
| 868 | 868 | { |
| 869 | 869 | struct dmk_tag *tag = get_dmk_tag(floppy); |
| 870 | 870 | floperr_t err; |
| r12282 | r12283 | |
| 962 | 962 | |
| 963 | 963 | |
| 964 | 964 | |
| 965 | | static floperr_t coco_dmk_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 965 | static floperr_t coco_dmk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 966 | 966 | { |
| 967 | 967 | return coco_dmk_seek_sector_in_track(floppy, head, track, sector, FALSE, FALSE, NULL, sector_length); |
| 968 | 968 | } |
| 969 | 969 | |
| 970 | 970 | |
| 971 | 971 | |
| 972 | | static floperr_t coco_dmk_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 972 | static floperr_t coco_dmk_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 973 | 973 | { |
| 974 | 974 | floperr_t err; |
| 975 | 975 | UINT32 idam_offset; |
| r12282 | r12283 | |
| 1008 | 1008 | |
| 1009 | 1009 | |
| 1010 | 1010 | |
| 1011 | | static floperr_t internal_coco_dmk_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 1011 | static floperr_t internal_coco_dmk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 1012 | 1012 | { |
| 1013 | 1013 | floperr_t err; |
| 1014 | 1014 | UINT32 sector_length; |
| r12282 | r12283 | |
| 1035 | 1035 | |
| 1036 | 1036 | |
| 1037 | 1037 | |
| 1038 | | static floperr_t internal_coco_dmk_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 1038 | static floperr_t internal_coco_dmk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 1039 | 1039 | { |
| 1040 | 1040 | floperr_t err; |
| 1041 | 1041 | UINT32 sector_length; |
| r12282 | r12283 | |
| 1059 | 1059 | |
| 1060 | 1060 | |
| 1061 | 1061 | |
| 1062 | | static floperr_t coco_dmk_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1062 | static floperr_t coco_dmk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1063 | 1063 | { |
| 1064 | 1064 | return internal_coco_dmk_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 1065 | 1065 | } |
| 1066 | 1066 | |
| 1067 | | static floperr_t coco_dmk_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 1067 | static floperr_t coco_dmk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 1068 | 1068 | { |
| 1069 | 1069 | return internal_coco_dmk_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 1070 | 1070 | } |
| 1071 | 1071 | |
| 1072 | | static floperr_t coco_dmk_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1072 | static floperr_t coco_dmk_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1073 | 1073 | { |
| 1074 | 1074 | return internal_coco_dmk_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 1075 | 1075 | } |
| 1076 | 1076 | |
| 1077 | | static floperr_t coco_dmk_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 1077 | static floperr_t coco_dmk_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 1078 | 1078 | { |
| 1079 | 1079 | return internal_coco_dmk_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 1080 | 1080 | } |
| 1081 | 1081 | |
| 1082 | 1082 | |
| 1083 | 1083 | |
| 1084 | | static void coco_dmk_interpret_header(floppy_image *floppy, int *heads, int *tracks, int *track_size) |
| 1084 | static void coco_dmk_interpret_header(floppy_image_legacy *floppy, int *heads, int *tracks, int *track_size) |
| 1085 | 1085 | { |
| 1086 | 1086 | UINT8 header[DMK_HEADER_LEN]; |
| 1087 | 1087 | |
src/lib/formats/flopimg.c
| r12282 | r12283 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | | static floperr_t floppy_track_unload(floppy_image *floppy); |
| 56 | static floperr_t floppy_track_unload(floppy_image_legacy *floppy); |
| 57 | 57 | |
| 58 | 58 | OPTION_GUIDE_START(floppy_option_guide) |
| 59 | 59 | OPTION_INT('H', "heads", "Heads") |
| r12282 | r12283 | |
| 65 | 65 | OPTION_GUIDE_END |
| 66 | 66 | |
| 67 | 67 | |
| 68 | | static void floppy_close_internal(floppy_image *floppy, int close_file); |
| 68 | static void floppy_close_internal(floppy_image_legacy *floppy, int close_file); |
| 69 | 69 | |
| 70 | 70 | /********************************************************************* |
| 71 | 71 | opening, closing and creating of floppy images |
| 72 | 72 | *********************************************************************/ |
| 73 | 73 | |
| 74 | | /* basic floppy_image initialization common to floppy_open() and floppy_create() */ |
| 75 | | static floppy_image *floppy_init(void *fp, const struct io_procs *procs, int flags) |
| 74 | /* basic floppy_image_legacy initialization common to floppy_open() and floppy_create() */ |
| 75 | static floppy_image_legacy *floppy_init(void *fp, const struct io_procs *procs, int flags) |
| 76 | 76 | { |
| 77 | | floppy_image *floppy; |
| 77 | floppy_image_legacy *floppy; |
| 78 | 78 | |
| 79 | | floppy = (floppy_image *)malloc(sizeof(struct _floppy_image)); |
| 79 | floppy = (floppy_image_legacy *)malloc(sizeof(struct _floppy_image)); |
| 80 | 80 | if (!floppy) |
| 81 | 81 | return NULL; |
| 82 | 82 | |
| r12282 | r12283 | |
| 95 | 95 | /* main code for identifying and maybe opening a disk image; not exposed |
| 96 | 96 | * directly because this function is big and hideous */ |
| 97 | 97 | static floperr_t floppy_open_internal(void *fp, const struct io_procs *procs, const char *extension, |
| 98 | | const struct FloppyFormat *floppy_options, int max_options, int flags, floppy_image **outfloppy, |
| 98 | const struct FloppyFormat *floppy_options, int max_options, int flags, floppy_image_legacy **outfloppy, |
| 99 | 99 | int *outoption) |
| 100 | 100 | { |
| 101 | 101 | floperr_t err; |
| 102 | | floppy_image *floppy; |
| 102 | floppy_image_legacy *floppy; |
| 103 | 103 | int best_option = -1; |
| 104 | 104 | int best_vote = 0; |
| 105 | 105 | int vote; |
| r12282 | r12283 | |
| 183 | 183 | |
| 184 | 184 | |
| 185 | 185 | floperr_t floppy_open(void *fp, const struct io_procs *procs, const char *extension, |
| 186 | | const struct FloppyFormat *format, int flags, floppy_image **outfloppy) |
| 186 | const struct FloppyFormat *format, int flags, floppy_image_legacy **outfloppy) |
| 187 | 187 | { |
| 188 | 188 | return floppy_open_internal(fp, procs, extension, format, 1, flags, outfloppy, NULL); |
| 189 | 189 | } |
| r12282 | r12283 | |
| 191 | 191 | |
| 192 | 192 | |
| 193 | 193 | floperr_t floppy_open_choices(void *fp, const struct io_procs *procs, const char *extension, |
| 194 | | const struct FloppyFormat *formats, int flags, floppy_image **outfloppy) |
| 194 | const struct FloppyFormat *formats, int flags, floppy_image_legacy **outfloppy) |
| 195 | 195 | { |
| 196 | 196 | return floppy_open_internal(fp, procs, extension, formats, INT_MAX, flags, outfloppy, NULL); |
| 197 | 197 | } |
| r12282 | r12283 | |
| 223 | 223 | |
| 224 | 224 | |
| 225 | 225 | |
| 226 | | floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, option_resolution *parameters, floppy_image **outfloppy) |
| 226 | floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, option_resolution *parameters, floppy_image_legacy **outfloppy) |
| 227 | 227 | { |
| 228 | | floppy_image *floppy = NULL; |
| 228 | floppy_image_legacy *floppy = NULL; |
| 229 | 229 | optreserr_t oerr; |
| 230 | 230 | floperr_t err; |
| 231 | 231 | int heads, tracks, h, t; |
| r12282 | r12283 | |
| 316 | 316 | |
| 317 | 317 | |
| 318 | 318 | |
| 319 | | static void floppy_close_internal(floppy_image *floppy, int close_file) |
| 319 | static void floppy_close_internal(floppy_image_legacy *floppy, int close_file) |
| 320 | 320 | { |
| 321 | 321 | if (floppy) { |
| 322 | 322 | floppy_track_unload(floppy); |
| r12282 | r12283 | |
| 335 | 335 | |
| 336 | 336 | |
| 337 | 337 | |
| 338 | | void floppy_close(floppy_image *floppy) |
| 338 | void floppy_close(floppy_image_legacy *floppy) |
| 339 | 339 | { |
| 340 | 340 | floppy_close_internal(floppy, TRUE); |
| 341 | 341 | } |
| r12282 | r12283 | |
| 346 | 346 | functions useful in format constructors |
| 347 | 347 | *********************************************************************/ |
| 348 | 348 | |
| 349 | | struct FloppyCallbacks *floppy_callbacks(floppy_image *floppy) |
| 349 | struct FloppyCallbacks *floppy_callbacks(floppy_image_legacy *floppy) |
| 350 | 350 | { |
| 351 | 351 | assert(floppy); |
| 352 | 352 | return &floppy->format; |
| r12282 | r12283 | |
| 354 | 354 | |
| 355 | 355 | |
| 356 | 356 | |
| 357 | | void *floppy_tag(floppy_image *floppy) |
| 357 | void *floppy_tag(floppy_image_legacy *floppy) |
| 358 | 358 | { |
| 359 | 359 | assert(floppy); |
| 360 | 360 | return floppy->tag_data; |
| r12282 | r12283 | |
| 362 | 362 | |
| 363 | 363 | |
| 364 | 364 | |
| 365 | | void *floppy_create_tag(floppy_image *floppy, size_t tagsize) |
| 365 | void *floppy_create_tag(floppy_image_legacy *floppy, size_t tagsize) |
| 366 | 366 | { |
| 367 | 367 | floppy->tag_data = pool_malloc_lib(floppy->tags,tagsize); |
| 368 | 368 | return floppy->tag_data; |
| r12282 | r12283 | |
| 370 | 370 | |
| 371 | 371 | |
| 372 | 372 | |
| 373 | | UINT8 floppy_get_filler(floppy_image *floppy) |
| 373 | UINT8 floppy_get_filler(floppy_image_legacy *floppy) |
| 374 | 374 | { |
| 375 | 375 | return floppy->io.filler; |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
| 379 | 379 | |
| 380 | | void floppy_set_filler(floppy_image *floppy, UINT8 filler) |
| 380 | void floppy_set_filler(floppy_image_legacy *floppy, UINT8 filler) |
| 381 | 381 | { |
| 382 | 382 | floppy->io.filler = filler; |
| 383 | 383 | } |
| r12282 | r12283 | |
| 388 | 388 | calls for accessing the raw disk image |
| 389 | 389 | *********************************************************************/ |
| 390 | 390 | |
| 391 | | void floppy_image_read(floppy_image *floppy, void *buffer, UINT64 offset, size_t length) |
| 391 | void floppy_image_read(floppy_image_legacy *floppy, void *buffer, UINT64 offset, size_t length) |
| 392 | 392 | { |
| 393 | 393 | io_generic_read(&floppy->io, buffer, offset, length); |
| 394 | 394 | } |
| 395 | 395 | |
| 396 | 396 | |
| 397 | 397 | |
| 398 | | void floppy_image_write(floppy_image *floppy, const void *buffer, UINT64 offset, size_t length) |
| 398 | void floppy_image_write(floppy_image_legacy *floppy, const void *buffer, UINT64 offset, size_t length) |
| 399 | 399 | { |
| 400 | 400 | io_generic_write(&floppy->io, buffer, offset, length); |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | |
| 405 | | void floppy_image_write_filler(floppy_image *floppy, UINT8 filler, UINT64 offset, size_t length) |
| 405 | void floppy_image_write_filler(floppy_image_legacy *floppy, UINT8 filler, UINT64 offset, size_t length) |
| 406 | 406 | { |
| 407 | 407 | io_generic_write_filler(&floppy->io, filler, offset, length); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | |
| 411 | 411 | |
| 412 | | UINT64 floppy_image_size(floppy_image *floppy) |
| 412 | UINT64 floppy_image_size(floppy_image_legacy *floppy) |
| 413 | 413 | { |
| 414 | 414 | return io_generic_size(&floppy->io); |
| 415 | 415 | } |
| r12282 | r12283 | |
| 420 | 420 | calls for accessing disk image data |
| 421 | 421 | *********************************************************************/ |
| 422 | 422 | |
| 423 | | static floperr_t floppy_readwrite_sector(floppy_image *floppy, int head, int track, int sector, int offset, |
| 423 | static floperr_t floppy_readwrite_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset, |
| 424 | 424 | void *buffer, size_t buffer_len, int writing, int indexed, int ddam) |
| 425 | 425 | { |
| 426 | 426 | floperr_t err; |
| r12282 | r12283 | |
| 429 | 429 | UINT8 *alloc_buf = NULL; |
| 430 | 430 | UINT32 sector_length; |
| 431 | 431 | UINT8 *buffer_ptr = (UINT8 *)buffer; |
| 432 | | floperr_t (*read_sector)(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 433 | | floperr_t (*write_sector)(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 432 | floperr_t (*read_sector)(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 433 | floperr_t (*write_sector)(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 434 | 434 | |
| 435 | 435 | fmt = floppy_callbacks(floppy); |
| 436 | 436 | |
| r12282 | r12283 | |
| 546 | 546 | |
| 547 | 547 | |
| 548 | 548 | |
| 549 | | floperr_t floppy_read_sector(floppy_image *floppy, int head, int track, int sector, int offset, void *buffer, size_t buffer_len) |
| 549 | floperr_t floppy_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset, void *buffer, size_t buffer_len) |
| 550 | 550 | { |
| 551 | 551 | return floppy_readwrite_sector(floppy, head, track, sector, offset, buffer, buffer_len, FALSE, FALSE, 0); |
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | |
| 555 | 555 | |
| 556 | | 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) |
| 556 | floperr_t floppy_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset, const void *buffer, size_t buffer_len, int ddam) |
| 557 | 557 | { |
| 558 | 558 | return floppy_readwrite_sector(floppy, head, track, sector, offset, (void *) buffer, buffer_len, TRUE, FALSE, ddam); |
| 559 | 559 | } |
| 560 | 560 | |
| 561 | 561 | |
| 562 | 562 | |
| 563 | | floperr_t floppy_read_indexed_sector(floppy_image *floppy, int head, int track, int sector_index, int offset, void *buffer, size_t buffer_len) |
| 563 | floperr_t floppy_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int offset, void *buffer, size_t buffer_len) |
| 564 | 564 | { |
| 565 | 565 | return floppy_readwrite_sector(floppy, head, track, sector_index, offset, buffer, buffer_len, FALSE, TRUE, 0); |
| 566 | 566 | } |
| 567 | 567 | |
| 568 | 568 | |
| 569 | 569 | |
| 570 | | 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) |
| 570 | floperr_t floppy_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int offset, const void *buffer, size_t buffer_len, int ddam) |
| 571 | 571 | { |
| 572 | 572 | return floppy_readwrite_sector(floppy, head, track, sector_index, offset, (void *) buffer, buffer_len, TRUE, TRUE, ddam); |
| 573 | 573 | } |
| 574 | 574 | |
| 575 | 575 | |
| 576 | | static floperr_t floppy_get_track_data_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 576 | static floperr_t floppy_get_track_data_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) |
| 577 | 577 | { |
| 578 | 578 | floperr_t err; |
| 579 | 579 | const struct FloppyCallbacks *callbacks; |
| r12282 | r12283 | |
| 591 | 591 | |
| 592 | 592 | |
| 593 | 593 | |
| 594 | | static floperr_t floppy_read_track_offset(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buffer_len) |
| 594 | static floperr_t floppy_read_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buffer_len) |
| 595 | 595 | { |
| 596 | 596 | floperr_t err; |
| 597 | 597 | const struct FloppyCallbacks *format; |
| r12282 | r12283 | |
| 614 | 614 | |
| 615 | 615 | |
| 616 | 616 | |
| 617 | | floperr_t floppy_read_track(floppy_image *floppy, int head, int track, void *buffer, size_t buffer_len) |
| 617 | floperr_t floppy_read_track(floppy_image_legacy *floppy, int head, int track, void *buffer, size_t buffer_len) |
| 618 | 618 | { |
| 619 | 619 | return floppy_read_track_offset(floppy, head, track, 0, buffer, buffer_len); |
| 620 | 620 | } |
| 621 | 621 | |
| 622 | 622 | |
| 623 | 623 | |
| 624 | | floperr_t floppy_read_track_data(floppy_image *floppy, int head, int track, void *buffer, size_t buffer_len) |
| 624 | floperr_t floppy_read_track_data(floppy_image_legacy *floppy, int head, int track, void *buffer, size_t buffer_len) |
| 625 | 625 | { |
| 626 | 626 | floperr_t err; |
| 627 | 627 | UINT64 offset; |
| r12282 | r12283 | |
| 635 | 635 | |
| 636 | 636 | |
| 637 | 637 | |
| 638 | | static floperr_t floppy_write_track_offset(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buffer_len) |
| 638 | static floperr_t floppy_write_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buffer_len) |
| 639 | 639 | { |
| 640 | 640 | floperr_t err; |
| 641 | 641 | |
| r12282 | r12283 | |
| 660 | 660 | |
| 661 | 661 | |
| 662 | 662 | |
| 663 | | floperr_t floppy_write_track(floppy_image *floppy, int head, int track, const void *buffer, size_t buffer_len) |
| 663 | floperr_t floppy_write_track(floppy_image_legacy *floppy, int head, int track, const void *buffer, size_t buffer_len) |
| 664 | 664 | { |
| 665 | 665 | return floppy_write_track_offset(floppy, head, track, 0, buffer, buffer_len); |
| 666 | 666 | } |
| 667 | 667 | |
| 668 | 668 | |
| 669 | 669 | |
| 670 | | floperr_t floppy_write_track_data(floppy_image *floppy, int head, int track, const void *buffer, size_t buffer_len) |
| 670 | floperr_t floppy_write_track_data(floppy_image_legacy *floppy, int head, int track, const void *buffer, size_t buffer_len) |
| 671 | 671 | { |
| 672 | 672 | floperr_t err; |
| 673 | 673 | UINT64 offset; |
| r12282 | r12283 | |
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | |
| 684 | | floperr_t floppy_format_track(floppy_image *floppy, int head, int track, option_resolution *parameters) |
| 684 | floperr_t floppy_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *parameters) |
| 685 | 685 | { |
| 686 | 686 | floperr_t err; |
| 687 | 687 | struct FloppyCallbacks *format; |
| r12282 | r12283 | |
| 727 | 727 | |
| 728 | 728 | |
| 729 | 729 | |
| 730 | | int floppy_get_tracks_per_disk(floppy_image *floppy) |
| 730 | int floppy_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 731 | 731 | { |
| 732 | 732 | return floppy_callbacks(floppy)->get_tracks_per_disk(floppy); |
| 733 | 733 | } |
| 734 | 734 | |
| 735 | 735 | |
| 736 | 736 | |
| 737 | | int floppy_get_heads_per_disk(floppy_image *floppy) |
| 737 | int floppy_get_heads_per_disk(floppy_image_legacy *floppy) |
| 738 | 738 | { |
| 739 | 739 | return floppy_callbacks(floppy)->get_heads_per_disk(floppy); |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | |
| 743 | 743 | |
| 744 | | UINT32 floppy_get_track_size(floppy_image *floppy, int head, int track) |
| 744 | UINT32 floppy_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 745 | 745 | { |
| 746 | 746 | const struct FloppyCallbacks *fmt; |
| 747 | 747 | |
| r12282 | r12283 | |
| 754 | 754 | |
| 755 | 755 | |
| 756 | 756 | |
| 757 | | floperr_t floppy_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 757 | floperr_t floppy_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 758 | 758 | { |
| 759 | 759 | const struct FloppyCallbacks *fmt; |
| 760 | 760 | |
| r12282 | r12283 | |
| 767 | 767 | |
| 768 | 768 | |
| 769 | 769 | |
| 770 | | floperr_t floppy_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 770 | floperr_t floppy_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 771 | 771 | { |
| 772 | 772 | const struct FloppyCallbacks *fmt; |
| 773 | 773 | |
| r12282 | r12283 | |
| 780 | 780 | |
| 781 | 781 | |
| 782 | 782 | |
| 783 | | floperr_t floppy_get_sector_count(floppy_image *floppy, int head, int track, int *sector_count) |
| 783 | floperr_t floppy_get_sector_count(floppy_image_legacy *floppy, int head, int track, int *sector_count) |
| 784 | 784 | { |
| 785 | 785 | floperr_t err; |
| 786 | 786 | int sector_index = 0; |
| r12282 | r12283 | |
| 802 | 802 | |
| 803 | 803 | |
| 804 | 804 | |
| 805 | | int floppy_is_read_only(floppy_image *floppy) |
| 805 | int floppy_is_read_only(floppy_image_legacy *floppy) |
| 806 | 806 | { |
| 807 | 807 | return floppy->flags & FLOPPY_FLAGS_READONLY; |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | |
| 811 | 811 | |
| 812 | | UINT8 floppy_random_byte(floppy_image *floppy) |
| 812 | UINT8 floppy_random_byte(floppy_image_legacy *floppy) |
| 813 | 813 | { |
| 814 | 814 | /* can't use mame_rand(); this might not be in the core */ |
| 815 | 815 | #ifdef rand |
| r12282 | r12283 | |
| 824 | 824 | calls for track based IO |
| 825 | 825 | *********************************************************************/ |
| 826 | 826 | |
| 827 | | floperr_t floppy_load_track(floppy_image *floppy, int head, int track, int dirtify, void **track_data, size_t *track_length) |
| 827 | floperr_t floppy_load_track(floppy_image_legacy *floppy, int head, int track, int dirtify, void **track_data, size_t *track_length) |
| 828 | 828 | { |
| 829 | 829 | floperr_t err; |
| 830 | 830 | void *new_loaded_track_data; |
| r12282 | r12283 | |
| 877 | 877 | |
| 878 | 878 | |
| 879 | 879 | |
| 880 | | static floperr_t floppy_track_unload(floppy_image *floppy) |
| 880 | static floperr_t floppy_track_unload(floppy_image_legacy *floppy) |
| 881 | 881 | { |
| 882 | 882 | int err; |
| 883 | 883 | if (floppy->loaded_track_status & TRACK_DIRTY) |
| r12282 | r12283 | |
| 897 | 897 | accessors for meta information about the image |
| 898 | 898 | *********************************************************************/ |
| 899 | 899 | |
| 900 | | const char *floppy_format_description(floppy_image *floppy) |
| 900 | const char *floppy_format_description(floppy_image_legacy *floppy) |
| 901 | 901 | { |
| 902 | 902 | return floppy->floppy_option->description; |
| 903 | 903 | } |
src/lib/formats/flopimg.h
| r12282 | r12283 | |
| 56 | 56 | } |
| 57 | 57 | floperr_t; |
| 58 | 58 | |
| 59 | | typedef struct _floppy_image floppy_image; |
| 59 | typedef struct _floppy_image floppy_image_legacy; |
| 60 | 60 | |
| 61 | 61 | struct FloppyCallbacks |
| 62 | 62 | { |
| 63 | | floperr_t (*read_sector)(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 64 | | floperr_t (*write_sector)(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 65 | | floperr_t (*read_indexed_sector)(floppy_image *floppy, int head, int track, int sector_index, void *buffer, size_t buflen); |
| 66 | | floperr_t (*write_indexed_sector)(floppy_image *floppy, int head, int track, int sector_index, const void *buffer, size_t buflen, int ddam); |
| 67 | | floperr_t (*read_track)(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen); |
| 68 | | floperr_t (*write_track)(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen); |
| 69 | | floperr_t (*format_track)(floppy_image *floppy, int head, int track, option_resolution *params); |
| 70 | | floperr_t (*post_format)(floppy_image *floppy, option_resolution *params); |
| 71 | | int (*get_heads_per_disk)(floppy_image *floppy); |
| 72 | | int (*get_tracks_per_disk)(floppy_image *floppy); |
| 73 | | int (*get_sectors_per_track)(floppy_image *floppy, int head, int track); |
| 74 | | UINT32 (*get_track_size)(floppy_image *floppy, int head, int track); |
| 75 | | floperr_t (*get_sector_length)(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 76 | | floperr_t (*get_indexed_sector_info)(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags); |
| 77 | | floperr_t (*get_track_data_offset)(floppy_image *floppy, int head, int track, UINT64 *offset); |
| 63 | floperr_t (*read_sector)(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 64 | floperr_t (*write_sector)(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 65 | floperr_t (*read_indexed_sector)(floppy_image_legacy *floppy, int head, int track, int sector_index, void *buffer, size_t buflen); |
| 66 | floperr_t (*write_indexed_sector)(floppy_image_legacy *floppy, int head, int track, int sector_index, const void *buffer, size_t buflen, int ddam); |
| 67 | floperr_t (*read_track)(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen); |
| 68 | floperr_t (*write_track)(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen); |
| 69 | floperr_t (*format_track)(floppy_image_legacy *floppy, int head, int track, option_resolution *params); |
| 70 | floperr_t (*post_format)(floppy_image_legacy *floppy, option_resolution *params); |
| 71 | int (*get_heads_per_disk)(floppy_image_legacy *floppy); |
| 72 | int (*get_tracks_per_disk)(floppy_image_legacy *floppy); |
| 73 | int (*get_sectors_per_track)(floppy_image_legacy *floppy, int head, int track); |
| 74 | UINT32 (*get_track_size)(floppy_image_legacy *floppy, int head, int track); |
| 75 | floperr_t (*get_sector_length)(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 76 | floperr_t (*get_indexed_sector_info)(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags); |
| 77 | floperr_t (*get_track_data_offset)(floppy_image_legacy *floppy, int head, int track, UINT64 *offset); |
| 78 | 78 | }; |
| 79 | 79 | |
| 80 | 80 | |
| r12282 | r12283 | |
| 84 | 84 | const char *name; |
| 85 | 85 | const char *extensions; |
| 86 | 86 | const char *description; |
| 87 | | floperr_t (*identify)(floppy_image *floppy, const struct FloppyFormat *format, int *vote); |
| 88 | | floperr_t (*construct)(floppy_image *floppy, const struct FloppyFormat *format, option_resolution *params); |
| 89 | | floperr_t (*destruct)(floppy_image *floppy, const struct FloppyFormat *format); |
| 87 | floperr_t (*identify)(floppy_image_legacy *floppy, const struct FloppyFormat *format, int *vote); |
| 88 | floperr_t (*construct)(floppy_image_legacy *floppy, const struct FloppyFormat *format, option_resolution *params); |
| 89 | floperr_t (*destruct)(floppy_image_legacy *floppy, const struct FloppyFormat *format); |
| 90 | 90 | const char *param_guidelines; |
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | | #define FLOPPY_IDENTIFY(name) floperr_t name(floppy_image *floppy, const struct FloppyFormat *format, int *vote) |
| 94 | | #define FLOPPY_CONSTRUCT(name) floperr_t name(floppy_image *floppy, const struct FloppyFormat *format, option_resolution *params) |
| 95 | | #define FLOPPY_DESTRUCT(name) floperr_t name(floppy_image *floppy, const struct FloppyFormat *format) |
| 93 | #define FLOPPY_IDENTIFY(name) floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format, int *vote) |
| 94 | #define FLOPPY_CONSTRUCT(name) floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format, option_resolution *params) |
| 95 | #define FLOPPY_DESTRUCT(name) floperr_t name(floppy_image_legacy *floppy, const struct FloppyFormat *format) |
| 96 | 96 | |
| 97 | 97 | FLOPPY_IDENTIFY(td0_dsk_identify); |
| 98 | 98 | FLOPPY_CONSTRUCT(td0_dsk_construct); |
| r12282 | r12283 | |
| 165 | 165 | OPTION_GUIDE_EXTERN(floppy_option_guide); |
| 166 | 166 | |
| 167 | 167 | /* opening, closing and creating of floppy images */ |
| 168 | | floperr_t floppy_open(void *fp, const struct io_procs *procs, const char *extension, const struct FloppyFormat *format, int flags, floppy_image **outfloppy); |
| 169 | | floperr_t floppy_open_choices(void *fp, const struct io_procs *procs, const char *extension, const struct FloppyFormat *formats, int flags, floppy_image **outfloppy); |
| 170 | | floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, option_resolution *parameters, floppy_image **outfloppy); |
| 171 | | void floppy_close(floppy_image *floppy); |
| 168 | floperr_t floppy_open(void *fp, const struct io_procs *procs, const char *extension, const struct FloppyFormat *format, int flags, floppy_image_legacy **outfloppy); |
| 169 | floperr_t floppy_open_choices(void *fp, const struct io_procs *procs, const char *extension, const struct FloppyFormat *formats, int flags, floppy_image_legacy **outfloppy); |
| 170 | floperr_t floppy_create(void *fp, const struct io_procs *procs, const struct FloppyFormat *format, option_resolution *parameters, floppy_image_legacy **outfloppy); |
| 171 | void floppy_close(floppy_image_legacy *floppy); |
| 172 | 172 | |
| 173 | 173 | /* useful for identifying a floppy image */ |
| 174 | 174 | floperr_t floppy_identify(void *fp, const struct io_procs *procs, const char *extension, |
| 175 | 175 | const struct FloppyFormat *formats, int *identified_format); |
| 176 | 176 | |
| 177 | 177 | /* functions useful within format constructors */ |
| 178 | | void *floppy_tag(floppy_image *floppy); |
| 179 | | void *floppy_create_tag(floppy_image *floppy, size_t tagsize); |
| 180 | | struct FloppyCallbacks *floppy_callbacks(floppy_image *floppy); |
| 181 | | UINT8 floppy_get_filler(floppy_image *floppy); |
| 182 | | void floppy_set_filler(floppy_image *floppy, UINT8 filler); |
| 178 | void *floppy_tag(floppy_image_legacy *floppy); |
| 179 | void *floppy_create_tag(floppy_image_legacy *floppy, size_t tagsize); |
| 180 | struct FloppyCallbacks *floppy_callbacks(floppy_image_legacy *floppy); |
| 181 | UINT8 floppy_get_filler(floppy_image_legacy *floppy); |
| 182 | void floppy_set_filler(floppy_image_legacy *floppy, UINT8 filler); |
| 183 | 183 | |
| 184 | 184 | /* calls for accessing disk image data */ |
| 185 | | floperr_t floppy_read_sector(floppy_image *floppy, int head, int track, int sector, int offset, void *buffer, size_t buffer_len); |
| 186 | | 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); |
| 187 | | floperr_t floppy_read_indexed_sector(floppy_image *floppy, int head, int track, int sector_index, int offset, void *buffer, size_t buffer_len); |
| 188 | | 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); |
| 189 | | floperr_t floppy_read_track(floppy_image *floppy, int head, int track, void *buffer, size_t buffer_len); |
| 190 | | floperr_t floppy_write_track(floppy_image *floppy, int head, int track, const void *buffer, size_t buffer_len); |
| 191 | | floperr_t floppy_read_track_data(floppy_image *floppy, int head, int track, void *buffer, size_t buffer_len); |
| 192 | | floperr_t floppy_write_track_data(floppy_image *floppy, int head, int track, const void *buffer, size_t buffer_len); |
| 193 | | floperr_t floppy_format_track(floppy_image *floppy, int head, int track, option_resolution *params); |
| 194 | | int floppy_get_tracks_per_disk(floppy_image *floppy); |
| 195 | | int floppy_get_heads_per_disk(floppy_image *floppy); |
| 196 | | UINT32 floppy_get_track_size(floppy_image *floppy, int head, int track); |
| 197 | | floperr_t floppy_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 198 | | floperr_t floppy_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags); |
| 199 | | floperr_t floppy_get_sector_count(floppy_image *floppy, int head, int track, int *sector_count); |
| 200 | | floperr_t floppy_load_track(floppy_image *floppy, int head, int track, int dirtify, void **track_data, size_t *track_length); |
| 201 | | int floppy_is_read_only(floppy_image *floppy); |
| 202 | | UINT8 floppy_random_byte(floppy_image *floppy); |
| 185 | floperr_t floppy_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset, void *buffer, size_t buffer_len); |
| 186 | floperr_t floppy_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int offset, const void *buffer, size_t buffer_len, int ddam); |
| 187 | floperr_t floppy_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int offset, void *buffer, size_t buffer_len); |
| 188 | floperr_t floppy_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int offset, const void *buffer, size_t buffer_len, int ddam); |
| 189 | floperr_t floppy_read_track(floppy_image_legacy *floppy, int head, int track, void *buffer, size_t buffer_len); |
| 190 | floperr_t floppy_write_track(floppy_image_legacy *floppy, int head, int track, const void *buffer, size_t buffer_len); |
| 191 | floperr_t floppy_read_track_data(floppy_image_legacy *floppy, int head, int track, void *buffer, size_t buffer_len); |
| 192 | floperr_t floppy_write_track_data(floppy_image_legacy *floppy, int head, int track, const void *buffer, size_t buffer_len); |
| 193 | floperr_t floppy_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params); |
| 194 | int floppy_get_tracks_per_disk(floppy_image_legacy *floppy); |
| 195 | int floppy_get_heads_per_disk(floppy_image_legacy *floppy); |
| 196 | UINT32 floppy_get_track_size(floppy_image_legacy *floppy, int head, int track); |
| 197 | floperr_t floppy_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 198 | floperr_t floppy_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags); |
| 199 | floperr_t floppy_get_sector_count(floppy_image_legacy *floppy, int head, int track, int *sector_count); |
| 200 | floperr_t floppy_load_track(floppy_image_legacy *floppy, int head, int track, int dirtify, void **track_data, size_t *track_length); |
| 201 | int floppy_is_read_only(floppy_image_legacy *floppy); |
| 202 | UINT8 floppy_random_byte(floppy_image_legacy *floppy); |
| 203 | 203 | |
| 204 | 204 | /* accessors for meta information about the image */ |
| 205 | | const char *floppy_format_description(floppy_image *floppy); |
| 205 | const char *floppy_format_description(floppy_image_legacy *floppy); |
| 206 | 206 | |
| 207 | 207 | /* calls for accessing the raw disk image */ |
| 208 | | void floppy_image_read(floppy_image *floppy, void *buffer, UINT64 offset, size_t length); |
| 209 | | void floppy_image_write(floppy_image *floppy, const void *buffer, UINT64 offset, size_t length); |
| 210 | | void floppy_image_write_filler(floppy_image *floppy, UINT8 filler, UINT64 offset, size_t length); |
| 211 | | UINT64 floppy_image_size(floppy_image *floppy); |
| 208 | void floppy_image_read(floppy_image_legacy *floppy, void *buffer, UINT64 offset, size_t length); |
| 209 | void floppy_image_write(floppy_image_legacy *floppy, const void *buffer, UINT64 offset, size_t length); |
| 210 | void floppy_image_write_filler(floppy_image_legacy *floppy, UINT8 filler, UINT64 offset, size_t length); |
| 211 | UINT64 floppy_image_size(floppy_image_legacy *floppy); |
| 212 | 212 | |
| 213 | 213 | /* misc */ |
| 214 | 214 | const char *floppy_error(floperr_t err); |
src/lib/formats/ap_dsk35.c
| r12282 | r12283 | |
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | |
| 211 | | static struct apple35_tag *get_apple35_tag(floppy_image *floppy) |
| 211 | static struct apple35_tag *get_apple35_tag(floppy_image_legacy *floppy) |
| 212 | 212 | { |
| 213 | 213 | struct apple35_tag *tag; |
| 214 | 214 | tag = (struct apple35_tag *) floppy_tag(floppy); |
| r12282 | r12283 | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | |
| 220 | | int apple35_sectors_per_track(floppy_image *image, int track) |
| 220 | int apple35_sectors_per_track(floppy_image_legacy *image, int track) |
| 221 | 221 | { |
| 222 | 222 | int sectors; |
| 223 | 223 | |
| r12282 | r12283 | |
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | |
| 443 | | static UINT32 apple35_get_offset(floppy_image *floppy, int head, int track, int sector, UINT32 *tag_offset) |
| 443 | static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *tag_offset) |
| 444 | 444 | { |
| 445 | 445 | int i; |
| 446 | 446 | UINT32 sector_index = 0; |
| r12282 | r12283 | |
| 473 | 473 | |
| 474 | 474 | |
| 475 | 475 | |
| 476 | | static floperr_t apple35_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 476 | static floperr_t apple35_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 477 | 477 | { |
| 478 | 478 | UINT32 data_offset; |
| 479 | 479 | // printf("Read sector: T %d S %d H %d\n", track, sector, head); |
| r12282 | r12283 | |
| 486 | 486 | |
| 487 | 487 | |
| 488 | 488 | |
| 489 | | static floperr_t apple35_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 489 | static floperr_t apple35_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 490 | 490 | { |
| 491 | 491 | UINT32 data_offset; |
| 492 | 492 | |
| r12282 | r12283 | |
| 499 | 499 | |
| 500 | 500 | |
| 501 | 501 | |
| 502 | | static floperr_t apple35_read_sector_td(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 502 | static floperr_t apple35_read_sector_td(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 503 | 503 | { |
| 504 | 504 | floperr_t err; |
| 505 | 505 | UINT32 tag_offset = 0; |
| r12282 | r12283 | |
| 524 | 524 | |
| 525 | 525 | |
| 526 | 526 | |
| 527 | | static floperr_t apple35_write_sector_td(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 527 | static floperr_t apple35_write_sector_td(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 528 | 528 | { |
| 529 | 529 | floperr_t err; |
| 530 | 530 | UINT32 tag_offset = 0; |
| r12282 | r12283 | |
| 546 | 546 | |
| 547 | 547 | |
| 548 | 548 | |
| 549 | | static floperr_t apple35_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 549 | static floperr_t apple35_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 550 | 550 | { |
| 551 | 551 | *sector_length = 512; |
| 552 | 552 | return FLOPPY_ERROR_SUCCESS; |
| r12282 | r12283 | |
| 554 | 554 | |
| 555 | 555 | |
| 556 | 556 | |
| 557 | | static int apple35_get_heads_per_disk(floppy_image *floppy) |
| 557 | static int apple35_get_heads_per_disk(floppy_image_legacy *floppy) |
| 558 | 558 | { |
| 559 | 559 | return get_apple35_tag(floppy)->sides; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | 562 | |
| 563 | 563 | |
| 564 | | static int apple35_get_tracks_per_disk(floppy_image *floppy) |
| 564 | static int apple35_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 565 | 565 | { |
| 566 | 566 | return 80; |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | 569 | |
| 570 | 570 | |
| 571 | | static UINT32 apple35_get_track_size(floppy_image *floppy, int head, int track) |
| 571 | static UINT32 apple35_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 572 | 572 | { |
| 573 | 573 | if ((track < 0) || (track >= 80)) |
| 574 | 574 | return 0; |
| r12282 | r12283 | |
| 588 | 588 | |
| 589 | 589 | |
| 590 | 590 | |
| 591 | | static floperr_t apple35_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 591 | static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 592 | 592 | { |
| 593 | 593 | floperr_t err; |
| 594 | 594 | size_t pos = 0; |
| r12282 | r12283 | |
| 648 | 648 | |
| 649 | 649 | |
| 650 | 650 | |
| 651 | | static floperr_t apple35_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 651 | static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 652 | 652 | { |
| 653 | 653 | floperr_t err; |
| 654 | 654 | size_t pos = 0; |
| r12282 | r12283 | |
| 771 | 771 | |
| 772 | 772 | |
| 773 | 773 | |
| 774 | | static floperr_t apple35_construct(floppy_image *floppy, UINT32 data_offset, UINT32 data_size, |
| 774 | static floperr_t apple35_construct(floppy_image_legacy *floppy, UINT32 data_offset, UINT32 data_size, |
| 775 | 775 | UINT32 tag_offset, UINT32 tag_size, INT16 format_byte, UINT8 sides, int is_1440k) |
| 776 | 776 | { |
| 777 | 777 | struct apple35_tag *tag; |
| r12282 | r12283 | |
| 889 | 889 | |
| 890 | 890 | |
| 891 | 891 | |
| 892 | | static floperr_t apple35_diskcopy_headerdecode(floppy_image *floppy, UINT32 *data_offset, |
| 892 | static floperr_t apple35_diskcopy_headerdecode(floppy_image_legacy *floppy, UINT32 *data_offset, |
| 893 | 893 | UINT32 *data_size, UINT32 *tag_offset, UINT32 *tag_size, UINT8 *format_byte, UINT8 *sides) |
| 894 | 894 | { |
| 895 | 895 | UINT64 size; |
| r12282 | r12283 | |
| 1032 | 1032 | |
| 1033 | 1033 | |
| 1034 | 1034 | |
| 1035 | | static floperr_t apple35_2img_decode(floppy_image *floppy, UINT32 *image_format, |
| 1035 | static floperr_t apple35_2img_decode(floppy_image_legacy *floppy, UINT32 *image_format, |
| 1036 | 1036 | UINT32 *data_offset, UINT32 *data_length) |
| 1037 | 1037 | { |
| 1038 | 1038 | struct header_2img header; |
src/lib/formats/d64_dsk.c
| r12282 | r12283 | |
| 170 | 170 | INLINE FUNCTIONS |
| 171 | 171 | ***************************************************************************/ |
| 172 | 172 | |
| 173 | | INLINE struct d64dsk_tag *get_tag(floppy_image *floppy) |
| 173 | INLINE struct d64dsk_tag *get_tag(floppy_image_legacy *floppy) |
| 174 | 174 | { |
| 175 | 175 | return (d64dsk_tag *)floppy_tag(floppy); |
| 176 | 176 | } |
| r12282 | r12283 | |
| 189 | 189 | of heads in the disk image |
| 190 | 190 | -------------------------------------------------*/ |
| 191 | 191 | |
| 192 | | static int d64_get_heads_per_disk(floppy_image *floppy) |
| 192 | static int d64_get_heads_per_disk(floppy_image_legacy *floppy) |
| 193 | 193 | { |
| 194 | 194 | return get_tag(floppy)->heads; |
| 195 | 195 | } |
| r12282 | r12283 | |
| 199 | 199 | of DOS tracks in the disk image |
| 200 | 200 | -------------------------------------------------*/ |
| 201 | 201 | |
| 202 | | static int d64_get_tracks_per_disk(floppy_image *floppy) |
| 202 | static int d64_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 203 | 203 | { |
| 204 | 204 | return get_tag(floppy)->tracks; |
| 205 | 205 | } |
| r12282 | r12283 | |
| 209 | 209 | of sectors per given track |
| 210 | 210 | -------------------------------------------------*/ |
| 211 | 211 | |
| 212 | | static int d64_get_sectors_per_track(floppy_image *floppy, int head, int track) |
| 212 | static int d64_get_sectors_per_track(floppy_image_legacy *floppy, int head, int track) |
| 213 | 213 | { |
| 214 | 214 | int sectors_per_track = 0; |
| 215 | 215 | |
| r12282 | r12283 | |
| 228 | 228 | the disk image for a given track |
| 229 | 229 | -------------------------------------------------*/ |
| 230 | 230 | |
| 231 | | static floperr_t get_track_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 231 | static floperr_t get_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) |
| 232 | 232 | { |
| 233 | 233 | struct d64dsk_tag *tag = get_tag(floppy); |
| 234 | 234 | UINT64 offs = 0; |
| r12282 | r12283 | |
| 248 | 248 | d64_get_track_size - returns the track size |
| 249 | 249 | -------------------------------------------------*/ |
| 250 | 250 | |
| 251 | | static UINT32 d64_get_track_size(floppy_image *floppy, int head, int track) |
| 251 | static UINT32 d64_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 252 | 252 | { |
| 253 | 253 | struct d64dsk_tag *tag = get_tag(floppy); |
| 254 | 254 | |
| r12282 | r12283 | |
| 269 | 269 | code for the given sector |
| 270 | 270 | -------------------------------------------------*/ |
| 271 | 271 | |
| 272 | | static int get_sector_error_code(floppy_image *floppy, int head, int dos_track, int sector) |
| 272 | static int get_sector_error_code(floppy_image_legacy *floppy, int head, int dos_track, int sector) |
| 273 | 273 | { |
| 274 | 274 | struct d64dsk_tag *tag = get_tag(floppy); |
| 275 | 275 | |
| r12282 | r12283 | |
| 375 | 375 | |
| 376 | 376 | */ |
| 377 | 377 | |
| 378 | | static floperr_t d64_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 378 | static floperr_t d64_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 379 | 379 | { |
| 380 | 380 | struct d64dsk_tag *tag = get_tag(floppy); |
| 381 | 381 | floperr_t err; |
| r12282 | r12283 | |
| 543 | 543 | disk image |
| 544 | 544 | -------------------------------------------------*/ |
| 545 | 545 | |
| 546 | | static floperr_t d64_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 546 | static floperr_t d64_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 547 | 547 | { |
| 548 | 548 | return FLOPPY_ERROR_UNSUPPORTED; |
| 549 | 549 | } |
| r12282 | r12283 | |
| 552 | 552 | d64_identify - identifies the disk image |
| 553 | 553 | -------------------------------------------------*/ |
| 554 | 554 | |
| 555 | | static void d64_identify(floppy_image *floppy, int *dos, int *heads, int *tracks, bool *has_errors) |
| 555 | static void d64_identify(floppy_image_legacy *floppy, int *dos, int *heads, int *tracks, bool *has_errors) |
| 556 | 556 | { |
| 557 | 557 | switch (floppy_image_size(floppy)) |
| 558 | 558 | { |
src/lib/formats/sorc_dsk.c
| r12282 | r12283 | |
| 17 | 17 | return FLOPPY_ERROR_SUCCESS; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | | static int exi_get_heads_per_disk(floppy_image *floppy) |
| 20 | static int exi_get_heads_per_disk(floppy_image_legacy *floppy) |
| 21 | 21 | { |
| 22 | 22 | return 1; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | | static int exi_get_tracks_per_disk(floppy_image *floppy) |
| 25 | static int exi_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 26 | 26 | { |
| 27 | 27 | return 77; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | | static UINT64 exi_translate_offset(floppy_image *floppy, int track, int head, int sector) |
| 30 | static UINT64 exi_translate_offset(floppy_image_legacy *floppy, int track, int head, int sector) |
| 31 | 31 | { |
| 32 | 32 | return 13+270*(16*track+sector); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 35 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 36 | 36 | { |
| 37 | 37 | UINT64 offs; |
| 38 | 38 | /* translate the sector to a raw sector */ |
| r12282 | r12283 | |
| 52 | 52 | |
| 53 | 53 | |
| 54 | 54 | |
| 55 | | static floperr_t internal_exi_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 55 | static floperr_t internal_exi_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 56 | 56 | { |
| 57 | 57 | UINT64 offset; |
| 58 | 58 | floperr_t err; |
| r12282 | r12283 | |
| 66 | 66 | |
| 67 | 67 | |
| 68 | 68 | |
| 69 | | static floperr_t internal_exi_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 69 | static floperr_t internal_exi_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 70 | 70 | { |
| 71 | 71 | UINT64 offset; |
| 72 | 72 | floperr_t err; |
| r12282 | r12283 | |
| 81 | 81 | |
| 82 | 82 | |
| 83 | 83 | |
| 84 | | static floperr_t exi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 84 | static floperr_t exi_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 85 | 85 | { |
| 86 | 86 | return internal_exi_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | | static floperr_t exi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 89 | static floperr_t exi_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 90 | 90 | { |
| 91 | 91 | return internal_exi_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 92 | 92 | } |
| 93 | 93 | |
| 94 | | static floperr_t exi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 94 | static floperr_t exi_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 95 | 95 | { |
| 96 | 96 | return internal_exi_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | | static floperr_t exi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 99 | static floperr_t exi_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 100 | 100 | { |
| 101 | 101 | return internal_exi_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 102 | 102 | } |
| 103 | 103 | |
| 104 | | static floperr_t exi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 104 | static floperr_t exi_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 105 | 105 | { |
| 106 | 106 | floperr_t err; |
| 107 | 107 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 116 | 116 | |
| 117 | 117 | |
| 118 | 118 | |
| 119 | | static floperr_t exi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 119 | static floperr_t exi_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 120 | 120 | { |
| 121 | 121 | sector_index += 1; |
| 122 | 122 | if (cylinder) |
src/lib/formats/thom_dsk.c
| r12282 | r12283 | |
| 45 | 45 | return crc; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | | static struct sap_dsk_tag *get_tag(floppy_image *floppy) |
| 48 | static struct sap_dsk_tag *get_tag(floppy_image_legacy *floppy) |
| 49 | 49 | { |
| 50 | 50 | struct sap_dsk_tag *tag; |
| 51 | 51 | tag = (sap_dsk_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 65 | 65 | } |
| 66 | 66 | return FLOPPY_ERROR_SUCCESS; |
| 67 | 67 | } |
| 68 | | static int sap_get_heads_per_disk(floppy_image *floppy) |
| 68 | static int sap_get_heads_per_disk(floppy_image_legacy *floppy) |
| 69 | 69 | { |
| 70 | 70 | return 1; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | | static int sap_get_tracks_per_disk(floppy_image *floppy) |
| 73 | static int sap_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 74 | 74 | { |
| 75 | 75 | return get_tag(floppy)->tracks; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 79 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 80 | 80 | { |
| 81 | 81 | UINT64 offs; |
| 82 | 82 | struct sap_dsk_tag *tag = get_tag(floppy); |
| r12282 | r12283 | |
| 101 | 101 | |
| 102 | 102 | |
| 103 | 103 | |
| 104 | | static floperr_t internal_sap_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 104 | static floperr_t internal_sap_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 105 | 105 | { |
| 106 | 106 | UINT64 offset; |
| 107 | 107 | floperr_t err; |
| r12282 | r12283 | |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | |
| 124 | | static floperr_t internal_sap_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 124 | static floperr_t internal_sap_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 125 | 125 | { |
| 126 | 126 | UINT64 offset; |
| 127 | 127 | floperr_t err; |
| r12282 | r12283 | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
| 152 | | static floperr_t sap_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 152 | static floperr_t sap_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 153 | 153 | { |
| 154 | 154 | return internal_sap_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | | static floperr_t sap_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 157 | static floperr_t sap_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 158 | 158 | { |
| 159 | 159 | return internal_sap_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | | static floperr_t sap_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 162 | static floperr_t sap_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 163 | 163 | { |
| 164 | 164 | return internal_sap_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | | static floperr_t sap_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 167 | static floperr_t sap_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 168 | 168 | { |
| 169 | 169 | return internal_sap_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | | static floperr_t sap_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 172 | static floperr_t sap_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 173 | 173 | { |
| 174 | 174 | floperr_t err; |
| 175 | 175 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 184 | 184 | |
| 185 | 185 | |
| 186 | 186 | |
| 187 | | static floperr_t sap_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 187 | static floperr_t sap_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 188 | 188 | { |
| 189 | 189 | floperr_t err; |
| 190 | 190 | UINT8 header[4]; |
| r12282 | r12283 | |
| 207 | 207 | return err; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | | static floperr_t sap_post_format(floppy_image *floppy, option_resolution *params) |
| 210 | static floperr_t sap_post_format(floppy_image_legacy *floppy, option_resolution *params) |
| 211 | 211 | { |
| 212 | 212 | int track,sector; |
| 213 | 213 | int pos; |
| r12282 | r12283 | |
| 300 | 300 | /* fixed interlacing map for QDDs */ |
| 301 | 301 | static int thom_qdd_map[400]; |
| 302 | 302 | |
| 303 | | static int qdd_translate_sector(floppy_image *floppy, int sector) |
| 303 | static int qdd_translate_sector(floppy_image_legacy *floppy, int sector) |
| 304 | 304 | { |
| 305 | 305 | return thom_qdd_map[sector-1]; |
| 306 | 306 | } |
src/lib/formats/dsk_dsk.c
| r12282 | r12283 | |
| 25 | 25 | }; |
| 26 | 26 | |
| 27 | 27 | |
| 28 | | static struct dskdsk_tag *get_tag(floppy_image *floppy) |
| 28 | static struct dskdsk_tag *get_tag(floppy_image_legacy *floppy) |
| 29 | 29 | { |
| 30 | 30 | struct dskdsk_tag *tag; |
| 31 | 31 | tag = (dskdsk_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 50 | 50 | return FLOPPY_ERROR_SUCCESS; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | | static int dsk_get_heads_per_disk(floppy_image *floppy) |
| 53 | static int dsk_get_heads_per_disk(floppy_image_legacy *floppy) |
| 54 | 54 | { |
| 55 | 55 | return get_tag(floppy)->heads; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | | static int dsk_get_tracks_per_disk(floppy_image *floppy) |
| 58 | static int dsk_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 59 | 59 | { |
| 60 | 60 | return get_tag(floppy)->tracks; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | | static UINT64 dsk_get_track_offset(floppy_image *floppy, int head, int track) |
| 63 | static UINT64 dsk_get_track_offset(floppy_image_legacy *floppy, int head, int track) |
| 64 | 64 | { |
| 65 | 65 | return get_tag(floppy)->track_offsets[(track<<1) + head]; |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 68 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 69 | 69 | { |
| 70 | 70 | UINT64 offs; |
| 71 | 71 | UINT64 track_offset; |
| r12282 | r12283 | |
| 108 | 108 | |
| 109 | 109 | |
| 110 | 110 | |
| 111 | | static floperr_t internal_dsk_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 111 | static floperr_t internal_dsk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 112 | 112 | { |
| 113 | 113 | UINT64 offset; |
| 114 | 114 | floperr_t err; |
| r12282 | r12283 | |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | |
| 124 | | static floperr_t internal_dsk_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 124 | static floperr_t internal_dsk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 125 | 125 | { |
| 126 | 126 | UINT64 offset; |
| 127 | 127 | floperr_t err; |
| r12282 | r12283 | |
| 136 | 136 | |
| 137 | 137 | |
| 138 | 138 | |
| 139 | | static floperr_t dsk_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 139 | static floperr_t dsk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 140 | 140 | { |
| 141 | 141 | return internal_dsk_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | | static floperr_t dsk_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 144 | static floperr_t dsk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 145 | 145 | { |
| 146 | 146 | return internal_dsk_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | | static floperr_t dsk_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 149 | static floperr_t dsk_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 150 | 150 | { |
| 151 | 151 | return internal_dsk_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | | static floperr_t dsk_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 154 | static floperr_t dsk_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 155 | 155 | { |
| 156 | 156 | return internal_dsk_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | | static floperr_t dsk_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 159 | static floperr_t dsk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 160 | 160 | { |
| 161 | 161 | floperr_t err; |
| 162 | 162 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 169 | 169 | return FLOPPY_ERROR_SUCCESS; |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | | static floperr_t dsk_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 172 | static floperr_t dsk_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 173 | 173 | { |
| 174 | 174 | floperr_t retVal; |
| 175 | 175 | UINT64 offset; |
src/lib/formats/z80ne_dsk.c
| r12282 | r12283 | |
| 92 | 92 | static const char needle_deleted_data_f8[] = "\x00\x00\x00\x00\x00\x00\x00\x00\xF8\xF8"; |
| 93 | 93 | |
| 94 | 94 | |
| 95 | | static struct dmk_tag *get_dmk_tag(floppy_image *floppy) |
| 95 | static struct dmk_tag *get_dmk_tag(floppy_image_legacy *floppy) |
| 96 | 96 | { |
| 97 | 97 | return (dmk_tag *)floppy_tag(floppy); |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | |
| 101 | | static floperr_t z80ne_dmk_get_track_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 101 | static floperr_t z80ne_dmk_get_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) |
| 102 | 102 | { |
| 103 | 103 | struct dmk_tag *tag = get_dmk_tag(floppy); |
| 104 | 104 | |
| r12282 | r12283 | |
| 123 | 123 | |
| 124 | 124 | |
| 125 | 125 | |
| 126 | | static floperr_t z80ne_dmk_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 126 | static floperr_t z80ne_dmk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 127 | 127 | { |
| 128 | 128 | floperr_t err; |
| 129 | 129 | UINT64 track_offset; |
| r12282 | r12283 | |
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | |
| 141 | | static floperr_t z80ne_dmk_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 141 | static floperr_t z80ne_dmk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 142 | 142 | { |
| 143 | 143 | floperr_t err; |
| 144 | 144 | UINT64 track_offset; |
| r12282 | r12283 | |
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | |
| 156 | | static floperr_t z80ne_dmk_get_track_data_offset(floppy_image *floppy, int head, int track, UINT64 *offset) |
| 156 | static floperr_t z80ne_dmk_get_track_data_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) |
| 157 | 157 | { |
| 158 | 158 | *offset = DMK_TOC_LEN + 1; |
| 159 | 159 | return FLOPPY_ERROR_SUCCESS; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | |
| 163 | | static floperr_t z80ne_dmk_format_track(floppy_image *floppy, int head, int track, option_resolution *params) |
| 163 | static floperr_t z80ne_dmk_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params) |
| 164 | 164 | { |
| 165 | 165 | int sectors; |
| 166 | 166 | int sector_length; |
| r12282 | r12283 | |
| 338 | 338 | |
| 339 | 339 | |
| 340 | 340 | |
| 341 | | static int z80ne_dmk_get_heads_per_disk(floppy_image *floppy) |
| 341 | static int z80ne_dmk_get_heads_per_disk(floppy_image_legacy *floppy) |
| 342 | 342 | { |
| 343 | 343 | return get_dmk_tag(floppy)->heads; |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
| 347 | 347 | |
| 348 | | static int z80ne_dmk_get_tracks_per_disk(floppy_image *floppy) |
| 348 | static int z80ne_dmk_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 349 | 349 | { |
| 350 | 350 | return get_dmk_tag(floppy)->tracks; |
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | |
| 354 | 354 | |
| 355 | | static UINT32 z80ne_dmk_get_track_size(floppy_image *floppy, int head, int track) |
| 355 | static UINT32 z80ne_dmk_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 356 | 356 | { |
| 357 | 357 | return get_dmk_tag(floppy)->track_size; |
| 358 | 358 | } |
| r12282 | r12283 | |
| 381 | 381 | |
| 382 | 382 | |
| 383 | 383 | |
| 384 | | static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image *floppy, int head, int track, int sector, int sector_is_index, int dirtify, UINT8 **sector_data, UINT32 *sector_length) |
| 384 | static floperr_t z80ne_dmk_seek_sector_in_track(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, int dirtify, UINT8 **sector_data, UINT32 *sector_length) |
| 385 | 385 | { |
| 386 | 386 | struct dmk_tag *tag = get_dmk_tag(floppy); |
| 387 | 387 | floperr_t err; |
| r12282 | r12283 | |
| 521 | 521 | |
| 522 | 522 | |
| 523 | 523 | |
| 524 | | static floperr_t z80ne_dmk_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 524 | static floperr_t z80ne_dmk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 525 | 525 | { |
| 526 | 526 | return z80ne_dmk_seek_sector_in_track(floppy, head, track, sector, FALSE, FALSE, NULL, sector_length); |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | |
| 530 | 530 | |
| 531 | | static floperr_t z80ne_dmk_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 531 | static floperr_t z80ne_dmk_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 532 | 532 | { |
| 533 | 533 | floperr_t err; |
| 534 | 534 | size_t idam_offset; |
| r12282 | r12283 | |
| 580 | 580 | |
| 581 | 581 | |
| 582 | 582 | |
| 583 | | static floperr_t internal_z80ne_dmk_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 583 | static floperr_t internal_z80ne_dmk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 584 | 584 | { |
| 585 | 585 | floperr_t err; |
| 586 | 586 | UINT32 sector_length; |
| r12282 | r12283 | |
| 636 | 636 | |
| 637 | 637 | |
| 638 | 638 | |
| 639 | | static floperr_t internal_z80ne_dmk_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 639 | static floperr_t internal_z80ne_dmk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 640 | 640 | { |
| 641 | 641 | floperr_t err; |
| 642 | 642 | UINT32 sector_length; |
| r12282 | r12283 | |
| 693 | 693 | |
| 694 | 694 | |
| 695 | 695 | |
| 696 | | static floperr_t z80ne_dmk_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 696 | static floperr_t z80ne_dmk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 697 | 697 | { |
| 698 | 698 | return internal_z80ne_dmk_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 699 | 699 | } |
| 700 | 700 | |
| 701 | | static floperr_t z80ne_dmk_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 701 | static floperr_t z80ne_dmk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 702 | 702 | { |
| 703 | 703 | return internal_z80ne_dmk_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 704 | 704 | } |
| 705 | 705 | |
| 706 | | static floperr_t z80ne_dmk_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 706 | static floperr_t z80ne_dmk_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 707 | 707 | { |
| 708 | 708 | return internal_z80ne_dmk_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 709 | 709 | } |
| 710 | 710 | |
| 711 | | static floperr_t z80ne_dmk_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 711 | static floperr_t z80ne_dmk_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 712 | 712 | { |
| 713 | 713 | return internal_z80ne_dmk_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | |
| 717 | 717 | |
| 718 | | static void z80ne_dmk_interpret_header(floppy_image *floppy, int *heads, int *tracks, int * sectors, int *track_size) |
| 718 | static void z80ne_dmk_interpret_header(floppy_image_legacy *floppy, int *heads, int *tracks, int * sectors, int *track_size) |
| 719 | 719 | { |
| 720 | 720 | UINT8 header[DMK_HEADER_LEN + DMK_TOC_LEN]; |
| 721 | 721 | int i; |
src/lib/formats/coupedsk.c
| r12282 | r12283 | |
| 114 | 114 | */ |
| 115 | 115 | |
| 116 | 116 | |
| 117 | | static UINT64 coupe_sad_translate_offset(floppy_image *floppy, |
| 117 | static UINT64 coupe_sad_translate_offset(floppy_image_legacy *floppy, |
| 118 | 118 | const struct basicdsk_geometry *geom, int track, int head, int sector) |
| 119 | 119 | { |
| 120 | 120 | return head * geom->tracks * geom->sectors + geom->sectors * track + sector; |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | |
| 124 | | static void coupe_sad_interpret_header(floppy_image *floppy, |
| 124 | static void coupe_sad_interpret_header(floppy_image_legacy *floppy, |
| 125 | 125 | int *heads, int *tracks, int *sectors, int *sector_size) |
| 126 | 126 | { |
| 127 | 127 | UINT8 header[SAD_HEADER_LEN]; |
| r12282 | r12283 | |
| 211 | 211 | * |
| 212 | 212 | *************************************/ |
| 213 | 213 | |
| 214 | | static int coupe_sdf_get_heads_per_disk(floppy_image *floppy) |
| 214 | static int coupe_sdf_get_heads_per_disk(floppy_image_legacy *floppy) |
| 215 | 215 | { |
| 216 | 216 | struct sdf_tag *tag = (sdf_tag *)floppy_tag(floppy); |
| 217 | 217 | return tag->heads; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | |
| 221 | | static int coupe_sdf_get_tracks_per_disk(floppy_image *floppy) |
| 221 | static int coupe_sdf_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 222 | 222 | { |
| 223 | 223 | struct sdf_tag *tag = (sdf_tag *)floppy_tag(floppy); |
| 224 | 224 | return tag->tracks; |
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | |
| 228 | | static UINT32 coupe_sdf_get_track_size(floppy_image *floppy, int head, int track) |
| 228 | static UINT32 coupe_sdf_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 229 | 229 | { |
| 230 | 230 | return SDF_TRACKSIZE; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | |
| 234 | | static floperr_t coupe_sdf_get_offset(floppy_image *floppy, |
| 234 | static floperr_t coupe_sdf_get_offset(floppy_image_legacy *floppy, |
| 235 | 235 | int head, int track, UINT64 *offset) |
| 236 | 236 | { |
| 237 | 237 | struct sdf_tag *tag = (sdf_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| 248 | | static floperr_t coupe_sdf_read_track(floppy_image *floppy, |
| 248 | static floperr_t coupe_sdf_read_track(floppy_image_legacy *floppy, |
| 249 | 249 | int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 250 | 250 | { |
| 251 | 251 | floperr_t err; |
| r12282 | r12283 | |
| 262 | 262 | } |
| 263 | 263 | |
| 264 | 264 | |
| 265 | | static floperr_t coupe_sdf_write_track(floppy_image *floppy, |
| 265 | static floperr_t coupe_sdf_write_track(floppy_image_legacy *floppy, |
| 266 | 266 | int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 267 | 267 | { |
| 268 | 268 | floperr_t err; |
| r12282 | r12283 | |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | |
| 282 | | static floperr_t coupe_sdf_get_sector_offset(floppy_image *floppy, |
| 282 | static floperr_t coupe_sdf_get_sector_offset(floppy_image_legacy *floppy, |
| 283 | 283 | int head, int track, int sector, UINT64 *offset) |
| 284 | 284 | { |
| 285 | 285 | floperr_t err; |
| r12282 | r12283 | |
| 312 | 312 | } |
| 313 | 313 | |
| 314 | 314 | |
| 315 | | static floperr_t coupe_sdf_get_total_sector_offset(floppy_image *floppy, |
| 315 | static floperr_t coupe_sdf_get_total_sector_offset(floppy_image_legacy *floppy, |
| 316 | 316 | int head, int track, int sector, UINT64 *offset) |
| 317 | 317 | { |
| 318 | 318 | floperr_t err; |
| r12282 | r12283 | |
| 332 | 332 | } |
| 333 | 333 | |
| 334 | 334 | |
| 335 | | static floperr_t coupe_sdf_get_sector_length(floppy_image *floppy, |
| 335 | static floperr_t coupe_sdf_get_sector_length(floppy_image_legacy *floppy, |
| 336 | 336 | int head, int track, int sector, UINT32 *sector_length) |
| 337 | 337 | { |
| 338 | 338 | floperr_t err; |
| r12282 | r12283 | |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | |
| 357 | | static floperr_t coupe_sdf_get_indexed_sector_info(floppy_image *floppy, |
| 357 | static floperr_t coupe_sdf_get_indexed_sector_info(floppy_image_legacy *floppy, |
| 358 | 358 | int head, int track, int sector_index, |
| 359 | 359 | int *cylinder, int *side, int *sector, UINT32 *sector_length, |
| 360 | 360 | unsigned long *flags) |
| r12282 | r12283 | |
| 382 | 382 | } |
| 383 | 383 | |
| 384 | 384 | |
| 385 | | static floperr_t coupe_sdf_read_indexed_sector(floppy_image *floppy, |
| 385 | static floperr_t coupe_sdf_read_indexed_sector(floppy_image_legacy *floppy, |
| 386 | 386 | int head, int track, int sector, void *buffer, size_t buflen) |
| 387 | 387 | { |
| 388 | 388 | floperr_t err; |
| r12282 | r12283 | |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | 400 | |
| 401 | | static floperr_t coupe_sdf_write_indexed_sector(floppy_image *floppy, |
| 401 | static floperr_t coupe_sdf_write_indexed_sector(floppy_image_legacy *floppy, |
| 402 | 402 | int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 403 | 403 | { |
| 404 | 404 | floperr_t err; |
| r12282 | r12283 | |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | |
| 417 | | static void coupe_sdf_interpret_header(floppy_image *floppy, int *heads, int *tracks) |
| 417 | static void coupe_sdf_interpret_header(floppy_image_legacy *floppy, int *heads, int *tracks) |
| 418 | 418 | { |
| 419 | 419 | UINT64 size = floppy_image_size(floppy); |
| 420 | 420 | |
src/lib/formats/svi_dsk.c
| r12282 | r12283 | |
| 17 | 17 | return FLOPPY_ERROR_SUCCESS; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | | static int svi_get_heads_per_disk(floppy_image *floppy) |
| 20 | static int svi_get_heads_per_disk(floppy_image_legacy *floppy) |
| 21 | 21 | { |
| 22 | 22 | return (floppy_image_size(floppy) == (172032)) ? 1 : 2; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | | static int svi_get_tracks_per_disk(floppy_image *floppy) |
| 25 | static int svi_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 26 | 26 | { |
| 27 | 27 | return 40; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | | static UINT64 svi_translate_offset(floppy_image *floppy, |
| 30 | static UINT64 svi_translate_offset(floppy_image_legacy *floppy, |
| 31 | 31 | int track, int head, int sector) |
| 32 | 32 | { |
| 33 | 33 | UINT64 o; |
| r12282 | r12283 | |
| 39 | 39 | return o; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 42 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 43 | 43 | { |
| 44 | 44 | UINT64 offs; |
| 45 | 45 | /* translate the sector to a raw sector */ |
| r12282 | r12283 | |
| 60 | 60 | |
| 61 | 61 | |
| 62 | 62 | |
| 63 | | static floperr_t internal_svi_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 63 | static floperr_t internal_svi_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 64 | 64 | { |
| 65 | 65 | UINT64 offset; |
| 66 | 66 | floperr_t err; |
| r12282 | r12283 | |
| 74 | 74 | |
| 75 | 75 | |
| 76 | 76 | |
| 77 | | static floperr_t internal_svi_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 77 | static floperr_t internal_svi_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 78 | 78 | { |
| 79 | 79 | UINT64 offset; |
| 80 | 80 | floperr_t err; |
| r12282 | r12283 | |
| 89 | 89 | |
| 90 | 90 | |
| 91 | 91 | |
| 92 | | static floperr_t svi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 92 | static floperr_t svi_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 93 | 93 | { |
| 94 | 94 | return internal_svi_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | | static floperr_t svi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 97 | static floperr_t svi_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 98 | 98 | { |
| 99 | 99 | return internal_svi_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | | static floperr_t svi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 102 | static floperr_t svi_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 103 | 103 | { |
| 104 | 104 | return internal_svi_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | | static floperr_t svi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 107 | static floperr_t svi_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 108 | 108 | { |
| 109 | 109 | return internal_svi_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | | static floperr_t svi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 112 | static floperr_t svi_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 113 | 113 | { |
| 114 | 114 | floperr_t err; |
| 115 | 115 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | |
| 127 | | static floperr_t svi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 127 | static floperr_t svi_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 128 | 128 | { |
| 129 | 129 | sector_index += 1; |
| 130 | 130 | if (cylinder) |
src/lib/formats/ti99_dsk.c
| r12282 | r12283 | |
| 152 | 152 | Queried by flopdrv. Instead of the image tracks, we return the tracks |
| 153 | 153 | of the floppy drive. We assume we always have two heads. |
| 154 | 154 | */ |
| 155 | | static int ti99_get_heads_per_disk(floppy_image *floppy) |
| 155 | static int ti99_get_heads_per_disk(floppy_image_legacy *floppy) |
| 156 | 156 | { |
| 157 | 157 | // struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 158 | 158 | // return tag->heads; |
| r12282 | r12283 | |
| 163 | 163 | Queried by flopdrv. Instead of the image tracks, we return the tracks |
| 164 | 164 | of the floppy drive. |
| 165 | 165 | */ |
| 166 | | static int ti99_get_tracks_per_disk(floppy_image *floppy) |
| 166 | static int ti99_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 167 | 167 | { |
| 168 | 168 | int drivetracks = 42; |
| 169 | 169 | |
| r12282 | r12283 | |
| 176 | 176 | return drivetracks; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | | static floperr_t ti99_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 179 | static floperr_t ti99_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 180 | 180 | { |
| 181 | 181 | *sector_length=SECTOR_SIZE; |
| 182 | 182 | return FLOPPY_ERROR_SUCCESS; |
| r12282 | r12283 | |
| 186 | 186 | Return the track size. We do not allow different track |
| 187 | 187 | sizes, so we store the track size in the tag. |
| 188 | 188 | */ |
| 189 | | static UINT32 ti99_get_track_size(floppy_image *floppy, int head, int track) |
| 189 | static UINT32 ti99_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 190 | 190 | { |
| 191 | 191 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 192 | 192 | return tag->track_size; |
| r12282 | r12283 | |
| 239 | 239 | Sector dump format |
| 240 | 240 | =========================================================================*/ |
| 241 | 241 | |
| 242 | | static floperr_t ti99_sdf_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 243 | | static floperr_t ti99_sdf_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 242 | static floperr_t ti99_sdf_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 243 | static floperr_t ti99_sdf_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 244 | 244 | |
| 245 | 245 | /* ----------------------------------------------------------------------- |
| 246 | 246 | * Guess the geometry of the sector dump disk. |
| r12282 | r12283 | |
| 270 | 270 | * returns 100 if recognized, 0 if not recognized |
| 271 | 271 | * ----------------------------------------------------------------------- */ |
| 272 | 272 | |
| 273 | | static int ti99_sdf_guess_geometry(floppy_image *floppy, UINT64 size, |
| 273 | static int ti99_sdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size, |
| 274 | 274 | struct ti99dsk_geometry *geometry) |
| 275 | 275 | { |
| 276 | 276 | int totsecs; |
| r12282 | r12283 | |
| 478 | 478 | Total length (FM) = 247 + sectors*334; (sectors=8 or 9) |
| 479 | 479 | Total length (MFM) = 752 + sectors*340; (sectors=16 or 18) |
| 480 | 480 | */ |
| 481 | | static floperr_t ti99_sdf_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 481 | static floperr_t ti99_sdf_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 482 | 482 | { |
| 483 | 483 | int sector; |
| 484 | 484 | int startstep; |
| r12282 | r12283 | |
| 621 | 621 | Bytes written to locations beyond the image end will be droppped |
| 622 | 622 | silently (as if the medium is unwritable from that point). |
| 623 | 623 | */ |
| 624 | | static floperr_t ti99_sdf_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 624 | static floperr_t ti99_sdf_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 625 | 625 | { |
| 626 | 626 | int current_pos = 0; |
| 627 | 627 | UINT8 *track_image; |
| r12282 | r12283 | |
| 763 | 763 | sector 0 = |
| 764 | 764 | sector 1 = 256* 0x00 |
| 765 | 765 | */ |
| 766 | | /* static floperr_t ti99_sdf_format_track(floppy_image *floppy, int head, int track, option_resolution *params) |
| 766 | /* static floperr_t ti99_sdf_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params) |
| 767 | 767 | { |
| 768 | 768 | UINT8 *sector0 = (UINT8*)malloc(SECTOR_SIZE); |
| 769 | 769 | create_vib(sector0, params); |
| r12282 | r12283 | |
| 796 | 796 | 1-0 |
| 797 | 797 | Note that we take the imgtrack, which may be half of the drive track. |
| 798 | 798 | */ |
| 799 | | static floperr_t ti99_sdf_get_offset(floppy_image *floppy, int head, int imgtrack, int sector, UINT64 *offset) |
| 799 | static floperr_t ti99_sdf_get_offset(floppy_image_legacy *floppy, int head, int imgtrack, int sector, UINT64 *offset) |
| 800 | 800 | { |
| 801 | 801 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 802 | 802 | |
| r12282 | r12283 | |
| 819 | 819 | /* |
| 820 | 820 | Read one sector at the specified position. |
| 821 | 821 | */ |
| 822 | | static floperr_t ti99_sdf_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 822 | static floperr_t ti99_sdf_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 823 | 823 | { |
| 824 | 824 | floperr_t err; |
| 825 | 825 | UINT64 offset; |
| r12282 | r12283 | |
| 846 | 846 | starting with the lowest numbered sector in each track. In other words, |
| 847 | 847 | we have nothing to calculate here. |
| 848 | 848 | */ |
| 849 | | static floperr_t ti99_sdf_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 849 | static floperr_t ti99_sdf_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 850 | 850 | { |
| 851 | 851 | return ti99_sdf_read_sector(floppy, head, track, sector, buffer, buflen); |
| 852 | 852 | } |
| r12282 | r12283 | |
| 854 | 854 | /* |
| 855 | 855 | Write one sector at the specified position. |
| 856 | 856 | */ |
| 857 | | static floperr_t ti99_sdf_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 857 | static floperr_t ti99_sdf_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 858 | 858 | { |
| 859 | 859 | UINT64 offset; |
| 860 | 860 | floperr_t err; |
| r12282 | r12283 | |
| 880 | 880 | /* |
| 881 | 881 | See above; indexing and numbering coincide. |
| 882 | 882 | */ |
| 883 | | static floperr_t ti99_sdf_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 883 | static floperr_t ti99_sdf_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 884 | 884 | { |
| 885 | 885 | return ti99_sdf_write_sector(floppy, head, track, sector, buffer, buflen, ddam); |
| 886 | 886 | } |
| r12282 | r12283 | |
| 888 | 888 | /* |
| 889 | 889 | Required for ReadAddress command |
| 890 | 890 | */ |
| 891 | | static floperr_t ti99_sdf_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 891 | static floperr_t ti99_sdf_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 892 | 892 | { |
| 893 | 893 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 894 | 894 | |
| r12282 | r12283 | |
| 1222 | 1222 | /* |
| 1223 | 1223 | Determine the position of this track in the image. |
| 1224 | 1224 | */ |
| 1225 | | static floperr_t ti99_tdf_get_offset(floppy_image *floppy, int head, int imgtrack, UINT64 *offset) |
| 1225 | static floperr_t ti99_tdf_get_offset(floppy_image_legacy *floppy, int head, int imgtrack, UINT64 *offset) |
| 1226 | 1226 | { |
| 1227 | 1227 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 1228 | 1228 | |
| r12282 | r12283 | |
| 1241 | 1241 | the CRC if it is the "blank" CRC as F7F7. |
| 1242 | 1242 | This method assumes that the track division be done already. |
| 1243 | 1243 | */ |
| 1244 | | static floperr_t ti99_tdf_read_track_internal(floppy_image *floppy, int head, int imgtrack, UINT64 offset, void *buffer, size_t buflen) |
| 1244 | static floperr_t ti99_tdf_read_track_internal(floppy_image_legacy *floppy, int head, int imgtrack, UINT64 offset, void *buffer, size_t buflen) |
| 1245 | 1245 | { |
| 1246 | 1246 | floperr_t err; |
| 1247 | 1247 | UINT64 track_offset; |
| r12282 | r12283 | |
| 1300 | 1300 | Reads a track. We just copy the contents from the format, without |
| 1301 | 1301 | changes. |
| 1302 | 1302 | */ |
| 1303 | | static floperr_t ti99_tdf_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 1303 | static floperr_t ti99_tdf_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 1304 | 1304 | { |
| 1305 | 1305 | int imgtrack = track; |
| 1306 | 1306 | |
| r12282 | r12283 | |
| 1315 | 1315 | /* |
| 1316 | 1316 | Writes a track. |
| 1317 | 1317 | */ |
| 1318 | | static floperr_t ti99_tdf_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 1318 | static floperr_t ti99_tdf_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 1319 | 1319 | { |
| 1320 | 1320 | floperr_t err; |
| 1321 | 1321 | UINT64 track_offset; |
| r12282 | r12283 | |
| 1339 | 1339 | } |
| 1340 | 1340 | |
| 1341 | 1341 | /* |
| 1342 | | static floperr_t ti99_tdf_format_track(floppy_image *floppy, int head, int track, option_resolution *params) |
| 1342 | static floperr_t ti99_tdf_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params) |
| 1343 | 1343 | { |
| 1344 | 1344 | int sectors; |
| 1345 | 1345 | int sector_length; |
| r12282 | r12283 | |
| 1364 | 1364 | distinguish them from ordinary data, as we do not store the clock), we |
| 1365 | 1365 | do not attempt to detect IDAM or DAM. |
| 1366 | 1366 | */ |
| 1367 | | static floperr_t ti99_tdf_seek_sector_in_track(floppy_image *floppy, int head, int track, int sector, UINT8 *track_data, UINT8 **sector_data) |
| 1367 | static floperr_t ti99_tdf_seek_sector_in_track(floppy_image_legacy *floppy, int head, int track, int sector, UINT8 *track_data, UINT8 **sector_data) |
| 1368 | 1368 | { |
| 1369 | 1369 | struct ti99dsk_tag *tag = (ti99dsk_tag*)floppy_tag(floppy); |
| 1370 | 1370 | |
| r12282 | r12283 | |
| 1411 | 1411 | return FLOPPY_ERROR_SEEKERROR; |
| 1412 | 1412 | } |
| 1413 | 1413 | |
| 1414 | | static floperr_t ti99_tdf_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1414 | static floperr_t ti99_tdf_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1415 | 1415 | { |
| 1416 | 1416 | floperr_t err; |
| 1417 | 1417 | UINT8 *sector_data; |
| r12282 | r12283 | |
| 1445 | 1445 | may be used instead of this method, according to the implementation |
| 1446 | 1446 | of flopimg/flopdrv. |
| 1447 | 1447 | */ |
| 1448 | | static floperr_t ti99_tdf_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 1448 | static floperr_t ti99_tdf_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 1449 | 1449 | { |
| 1450 | 1450 | floperr_t err; |
| 1451 | 1451 | UINT8 *sector_data; |
| r12282 | r12283 | |
| 1489 | 1489 | return FLOPPY_ERROR_SUCCESS; |
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | | static floperr_t ti99_tdf_write_indexed_sector(floppy_image *floppy, int head, int track, int sector_index, const void *buffer, size_t buflen, int ddam) |
| 1492 | static floperr_t ti99_tdf_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, const void *buffer, size_t buflen, int ddam) |
| 1493 | 1493 | { |
| 1494 | 1494 | /* Read track, head */ |
| 1495 | 1495 | int byte; |
| r12282 | r12283 | |
| 1594 | 1594 | } |
| 1595 | 1595 | |
| 1596 | 1596 | |
| 1597 | | static floperr_t ti99_tdf_find_indexed_sector(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, void *buffer, unsigned long *flags) |
| 1597 | static floperr_t ti99_tdf_find_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, void *buffer, unsigned long *flags) |
| 1598 | 1598 | { |
| 1599 | 1599 | /* Read track, head */ |
| 1600 | 1600 | int byte = 0; |
| r12282 | r12283 | |
| 1699 | 1699 | sector (and so on) from the track, not sector 1, 2, 3. That is, the |
| 1700 | 1700 | returned sector info depends on the interleave and the start sector. |
| 1701 | 1701 | */ |
| 1702 | | static floperr_t ti99_tdf_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 1702 | static floperr_t ti99_tdf_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 1703 | 1703 | { |
| 1704 | 1704 | return ti99_tdf_find_indexed_sector(floppy, head, track, sector_index, cylinder, side, sector, sector_length, NULL, flags); |
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | | static floperr_t ti99_tdf_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1707 | static floperr_t ti99_tdf_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 1708 | 1708 | { |
| 1709 | 1709 | return ti99_tdf_find_indexed_sector(floppy, head, track, sector, (int*)NULL, (int*)NULL, (int*)NULL, (UINT32*)NULL, buffer, (unsigned long*)NULL); |
| 1710 | 1710 | } |
| r12282 | r12283 | |
| 1739 | 1739 | DSDD80 = 1099520 |
| 1740 | 1740 | DSHD80 = 2078720 |
| 1741 | 1741 | */ |
| 1742 | | static int ti99_tdf_guess_geometry(floppy_image *floppy, UINT64 size, |
| 1742 | static int ti99_tdf_guess_geometry(floppy_image_legacy *floppy, UINT64 size, |
| 1743 | 1743 | struct ti99dsk_geometry *geometry) |
| 1744 | 1744 | { |
| 1745 | 1745 | int idamcnt, state, track, head, i, totalseclen = 0, format = 0, byte, tracklength, trackadd = 0; |
src/lib/formats/fdi_dsk.c
| r12282 | r12283 | |
| 128 | 128 | INLINE FUNCTIONS |
| 129 | 129 | ***************************************************************************/ |
| 130 | 130 | |
| 131 | | INLINE struct fdidsk_tag *get_tag(floppy_image *floppy) |
| 131 | INLINE struct fdidsk_tag *get_tag(floppy_image_legacy *floppy) |
| 132 | 132 | { |
| 133 | 133 | return (fdidsk_tag *)floppy_tag(floppy); |
| 134 | 134 | } |
| r12282 | r12283 | |
| 137 | 137 | IMPLEMENTATION |
| 138 | 138 | ***************************************************************************/ |
| 139 | 139 | |
| 140 | | static int fdi_get_heads_per_disk(floppy_image *floppy) |
| 140 | static int fdi_get_heads_per_disk(floppy_image_legacy *floppy) |
| 141 | 141 | { |
| 142 | 142 | return get_tag(floppy)->heads; |
| 143 | 143 | } |
| 144 | 144 | |
| 145 | | static int fdi_get_tracks_per_disk(floppy_image *floppy) |
| 145 | static int fdi_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 146 | 146 | { |
| 147 | 147 | return get_tag(floppy)->tracks; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | | static int fdi_get_sectors_per_track(floppy_image *floppy, int head, int track) |
| 150 | static int fdi_get_sectors_per_track(floppy_image_legacy *floppy, int head, int track) |
| 151 | 151 | { |
| 152 | 152 | return 0; |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | | static floperr_t fdi_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 155 | static floperr_t fdi_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 156 | 156 | { |
| 157 | 157 | return FLOPPY_ERROR_SUCCESS; |
| 158 | 158 | } |
| 159 | 159 | /* |
| 160 | | static UINT32 fdi_get_sector_offset(floppy_image* floppy, int head, int track, int sector) |
| 160 | static UINT32 fdi_get_sector_offset(floppy_image_legacy* floppy, int head, int track, int sector) |
| 161 | 161 | { |
| 162 | 162 | return 0; |
| 163 | 163 | } |
| 164 | 164 | */ |
| 165 | | static floperr_t fdi_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 165 | static floperr_t fdi_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 166 | 166 | { |
| 167 | 167 | return FLOPPY_ERROR_UNSUPPORTED; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | | static floperr_t fdi_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 170 | static floperr_t fdi_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 171 | 171 | { |
| 172 | 172 | return FLOPPY_ERROR_UNSUPPORTED; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | | static floperr_t fdi_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 175 | static floperr_t fdi_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 176 | 176 | { |
| 177 | 177 | return FLOPPY_ERROR_UNSUPPORTED; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | | static floperr_t fdi_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buffer_len) |
| 180 | static floperr_t fdi_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buffer_len) |
| 181 | 181 | { |
| 182 | 182 | return FLOPPY_ERROR_UNSUPPORTED; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | | static floperr_t fdi_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 185 | static floperr_t fdi_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 186 | 186 | { |
| 187 | 187 | return FLOPPY_ERROR_UNSUPPORTED; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | | static floperr_t fdi_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 190 | static floperr_t fdi_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 191 | 191 | { |
| 192 | 192 | return FLOPPY_ERROR_UNSUPPORTED; |
| 193 | 193 | } |
src/lib/formats/ap2_dsk.c
| r12282 | r12283 | |
| 20 | 20 | |
| 21 | 21 | |
| 22 | 22 | /* used in for all Apple II images */ |
| 23 | | static UINT32 apple2_get_track_size(floppy_image *floppy, int head, int track); |
| 23 | static UINT32 apple2_get_track_size(floppy_image_legacy *floppy, int head, int track); |
| 24 | 24 | static int disk_decode_nib(UINT8 *data, const UINT8 *nibble, int *volume, int *track, int *sector); |
| 25 | 25 | static void disk_encode_nib(UINT8 *nibble, const UINT8 *data, int volume, int track, int sector); |
| 26 | 26 | |
| 27 | 27 | /* used in DOS/ProDOS order images */ |
| 28 | | static int apple2_do_translate_sector(floppy_image *floppy, int sector); |
| 29 | | static int apple2_po_translate_sector(floppy_image *floppy, int sector); |
| 30 | | static floperr_t apple2_dsk_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen); |
| 31 | | static floperr_t apple2_dsk_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen); |
| 28 | static int apple2_do_translate_sector(floppy_image_legacy *floppy, int sector); |
| 29 | static int apple2_po_translate_sector(floppy_image_legacy *floppy, int sector); |
| 30 | static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen); |
| 31 | static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen); |
| 32 | 32 | |
| 33 | 33 | /* used in nibble order images */ |
| 34 | | static floperr_t apple2_nib_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen); |
| 35 | | static floperr_t apple2_nib_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen); |
| 36 | | static floperr_t apple2_nib_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 37 | | static floperr_t apple2_nib_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 38 | | static floperr_t apple2_nib_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 34 | static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen); |
| 35 | static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen); |
| 36 | static floperr_t apple2_nib_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 37 | static floperr_t apple2_nib_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 38 | static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | static const UINT8 translate6[0x40] = |
| r12282 | r12283 | |
| 79 | 79 | * ----------------------------------------------------------------------- */ |
| 80 | 80 | |
| 81 | 81 | |
| 82 | | static floperr_t apple2_general_construct(floppy_image *floppy, int floppy_type) |
| 82 | static floperr_t apple2_general_construct(floppy_image_legacy *floppy, int floppy_type) |
| 83 | 83 | { |
| 84 | 84 | floperr_t err; |
| 85 | 85 | struct basicdsk_geometry geometry; |
| r12282 | r12283 | |
| 148 | 148 | |
| 149 | 149 | |
| 150 | 150 | |
| 151 | | static int apple2_do_translate_sector(floppy_image *floppy, int sector) |
| 151 | static int apple2_do_translate_sector(floppy_image_legacy *floppy, int sector) |
| 152 | 152 | { |
| 153 | 153 | static const UINT8 skewing[] = |
| 154 | 154 | { |
| r12282 | r12283 | |
| 161 | 161 | |
| 162 | 162 | |
| 163 | 163 | |
| 164 | | static int apple2_po_translate_sector(floppy_image *floppy, int sector) |
| 164 | static int apple2_po_translate_sector(floppy_image_legacy *floppy, int sector) |
| 165 | 165 | { |
| 166 | 166 | static const UINT8 skewing[] = |
| 167 | 167 | { |
| r12282 | r12283 | |
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | |
| 191 | | static floperr_t apple2_dsk_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 191 | static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 192 | 192 | { |
| 193 | 193 | UINT8 sector_buffer[APPLE2_SECTOR_SIZE]; |
| 194 | 194 | int sector; |
| r12282 | r12283 | |
| 214 | 214 | |
| 215 | 215 | |
| 216 | 216 | |
| 217 | | static floperr_t apple2_dsk_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 217 | static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 218 | 218 | { |
| 219 | 219 | int sector; |
| 220 | 220 | UINT8 sector_buffer[APPLE2_SECTOR_SIZE]; |
| r12282 | r12283 | |
| 258 | 258 | |
| 259 | 259 | |
| 260 | 260 | |
| 261 | | static floperr_t apple2_nib_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 261 | static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen) |
| 262 | 262 | { |
| 263 | 263 | if ((head != 0) || (track < 0) || (track >= APPLE2_TRACK_COUNT)) |
| 264 | 264 | return FLOPPY_ERROR_SEEKERROR; |
| r12282 | r12283 | |
| 270 | 270 | |
| 271 | 271 | |
| 272 | 272 | |
| 273 | | static floperr_t apple2_nib_write_track(floppy_image *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 273 | static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen) |
| 274 | 274 | { |
| 275 | 275 | if ((head != 0) || (track < 0) || (track >= APPLE2_TRACK_COUNT)) |
| 276 | 276 | return FLOPPY_ERROR_SEEKERROR; |
| r12282 | r12283 | |
| 360 | 360 | |
| 361 | 361 | |
| 362 | 362 | |
| 363 | | static floperr_t apple2_nib_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 363 | static floperr_t apple2_nib_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 364 | 364 | { |
| 365 | 365 | floperr_t err; |
| 366 | 366 | const UINT8 *nibble; |
| r12282 | r12283 | |
| 450 | 450 | |
| 451 | 451 | |
| 452 | 452 | |
| 453 | | static floperr_t apple2_nib_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 453 | static floperr_t apple2_nib_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 454 | 454 | { |
| 455 | 455 | floperr_t err; |
| 456 | 456 | UINT8 *track_data; |
| r12282 | r12283 | |
| 472 | 472 | |
| 473 | 473 | |
| 474 | 474 | |
| 475 | | static floperr_t apple2_nib_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 475 | static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 476 | 476 | { |
| 477 | 477 | *sector_length = APPLE2_SECTOR_SIZE; |
| 478 | 478 | return FLOPPY_ERROR_SUCCESS; |
| r12282 | r12283 | |
| 480 | 480 | |
| 481 | 481 | |
| 482 | 482 | |
| 483 | | static UINT32 apple2_get_track_size(floppy_image *floppy, int head, int track) |
| 483 | static UINT32 apple2_get_track_size(floppy_image_legacy *floppy, int head, int track) |
| 484 | 484 | { |
| 485 | 485 | return APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT; |
| 486 | 486 | } |
src/lib/formats/td0_dsk.c
| r12282 | r12283 | |
| 55 | 55 | |
| 56 | 56 | struct td0dsk_t |
| 57 | 57 | { |
| 58 | | floppy_image *floppy_file; |
| 58 | floppy_image_legacy *floppy_file; |
| 59 | 59 | UINT64 floppy_file_offset; |
| 60 | 60 | |
| 61 | 61 | struct tdlzhuf tdctl; |
| r12282 | r12283 | |
| 90 | 90 | static td0dsk_t td0dsk; |
| 91 | 91 | |
| 92 | 92 | |
| 93 | | static struct td0dsk_tag *get_tag(floppy_image *floppy) |
| 93 | static struct td0dsk_tag *get_tag(floppy_image_legacy *floppy) |
| 94 | 94 | { |
| 95 | 95 | struct td0dsk_tag *tag; |
| 96 | 96 | tag = (td0dsk_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 114 | 114 | return FLOPPY_ERROR_SUCCESS; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | | static int td0_get_heads_per_disk(floppy_image *floppy) |
| 117 | static int td0_get_heads_per_disk(floppy_image_legacy *floppy) |
| 118 | 118 | { |
| 119 | 119 | return get_tag(floppy)->heads; |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | | static int td0_get_tracks_per_disk(floppy_image *floppy) |
| 122 | static int td0_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 123 | 123 | { |
| 124 | 124 | return get_tag(floppy)->tracks; |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | | static UINT64 td0_get_track_offset(floppy_image *floppy, int head, int track) |
| 127 | static UINT64 td0_get_track_offset(floppy_image_legacy *floppy, int head, int track) |
| 128 | 128 | { |
| 129 | 129 | return get_tag(floppy)->track_offsets[(track<<1) + head]; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 132 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 133 | 133 | { |
| 134 | 134 | UINT64 offs; |
| 135 | 135 | UINT8 *header; |
| r12282 | r12283 | |
| 176 | 176 | |
| 177 | 177 | |
| 178 | 178 | |
| 179 | | static floperr_t internal_td0_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 179 | static floperr_t internal_td0_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 180 | 180 | { |
| 181 | 181 | UINT64 offset; |
| 182 | 182 | floperr_t err; |
| r12282 | r12283 | |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | |
| 264 | | static floperr_t td0_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 264 | static floperr_t td0_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 265 | 265 | { |
| 266 | 266 | return internal_td0_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | | static floperr_t td0_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 269 | static floperr_t td0_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 270 | 270 | { |
| 271 | 271 | return internal_td0_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | | static floperr_t td0_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 274 | static floperr_t td0_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 275 | 275 | { |
| 276 | 276 | floperr_t err; |
| 277 | 277 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 284 | 284 | return FLOPPY_ERROR_SUCCESS; |
| 285 | 285 | } |
| 286 | 286 | |
| 287 | | static floperr_t td0_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 287 | static floperr_t td0_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 288 | 288 | { |
| 289 | 289 | floperr_t retVal; |
| 290 | 290 | UINT64 offset; |
src/lib/formats/imd_dsk.c
| r12282 | r12283 | |
| 18 | 18 | }; |
| 19 | 19 | |
| 20 | 20 | |
| 21 | | static struct imddsk_tag *get_tag(floppy_image *floppy) |
| 21 | static struct imddsk_tag *get_tag(floppy_image_legacy *floppy) |
| 22 | 22 | { |
| 23 | 23 | struct imddsk_tag *tag; |
| 24 | 24 | tag = (imddsk_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 40 | 40 | return FLOPPY_ERROR_SUCCESS; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | | static int imd_get_heads_per_disk(floppy_image *floppy) |
| 43 | static int imd_get_heads_per_disk(floppy_image_legacy *floppy) |
| 44 | 44 | { |
| 45 | 45 | return get_tag(floppy)->heads; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | | static int imd_get_tracks_per_disk(floppy_image *floppy) |
| 48 | static int imd_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 49 | 49 | { |
| 50 | 50 | return get_tag(floppy)->tracks; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | | static UINT64 imd_get_track_offset(floppy_image *floppy, int head, int track) |
| 53 | static UINT64 imd_get_track_offset(floppy_image_legacy *floppy, int head, int track) |
| 54 | 54 | { |
| 55 | 55 | return get_tag(floppy)->track_offsets[(track<<1) + head]; |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 58 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 59 | 59 | { |
| 60 | 60 | UINT64 offs = 0; |
| 61 | 61 | UINT8 header[5]; |
| r12282 | r12283 | |
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 | |
| 96 | | static floperr_t internal_imd_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 96 | static floperr_t internal_imd_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 97 | 97 | { |
| 98 | 98 | UINT64 offset; |
| 99 | 99 | floperr_t err; |
| r12282 | r12283 | |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | |
| 127 | | static floperr_t imd_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 127 | static floperr_t imd_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 128 | 128 | { |
| 129 | 129 | return internal_imd_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | | static floperr_t imd_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 132 | static floperr_t imd_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 133 | 133 | { |
| 134 | 134 | return internal_imd_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | | static floperr_t imd_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 137 | static floperr_t imd_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 138 | 138 | { |
| 139 | 139 | floperr_t err; |
| 140 | 140 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 147 | 147 | return FLOPPY_ERROR_SUCCESS; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | | static floperr_t imd_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 150 | static floperr_t imd_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 151 | 151 | { |
| 152 | 152 | UINT64 offset; |
| 153 | 153 | UINT8 header[5]; |
src/lib/formats/oric_dsk.c
| r12282 | r12283 | |
| 38 | 38 | }; |
| 39 | 39 | |
| 40 | 40 | |
| 41 | | static struct oricdsk_tag *get_tag(floppy_image *floppy) |
| 41 | static struct oricdsk_tag *get_tag(floppy_image_legacy *floppy) |
| 42 | 42 | { |
| 43 | 43 | struct oricdsk_tag *tag; |
| 44 | 44 | tag = (oricdsk_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 65 | 65 | } |
| 66 | 66 | return FLOPPY_ERROR_SUCCESS; |
| 67 | 67 | } |
| 68 | | static int oric_get_track_offset(floppy_image *floppy,int track, int head) |
| 68 | static int oric_get_track_offset(floppy_image_legacy *floppy,int track, int head) |
| 69 | 69 | { |
| 70 | 70 | if (get_tag(floppy)->geometry==1) { |
| 71 | 71 | return mfm_disk_header_size + (get_tag(floppy)->tracksize * track) + (head * get_tag(floppy)->tracksize * get_tag(floppy)->tracks); |
| r12282 | r12283 | |
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | | static int oric_get_heads_per_disk(floppy_image *floppy) |
| 77 | static int oric_get_heads_per_disk(floppy_image_legacy *floppy) |
| 78 | 78 | { |
| 79 | 79 | return get_tag(floppy)->heads; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | | static int oric_get_tracks_per_disk(floppy_image *floppy) |
| 82 | static int oric_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 83 | 83 | { |
| 84 | 84 | return get_tag(floppy)->tracks; |
| 85 | 85 | } |
| 86 | 86 | |
| 87 | | static void mfm_info_cache_sector_info(floppy_image *floppy,int track,int head) |
| 87 | static void mfm_info_cache_sector_info(floppy_image_legacy *floppy,int track,int head) |
| 88 | 88 | { |
| 89 | 89 | UINT8 track_data[TRACK_SIZE_MFM]; |
| 90 | 90 | |
| r12282 | r12283 | |
| 165 | 165 | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 168 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 169 | 169 | { |
| 170 | 170 | UINT64 offs; |
| 171 | 171 | |
| r12282 | r12283 | |
| 189 | 189 | |
| 190 | 190 | |
| 191 | 191 | |
| 192 | | static floperr_t internal_oric_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 192 | static floperr_t internal_oric_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 193 | 193 | { |
| 194 | 194 | UINT64 offset; |
| 195 | 195 | floperr_t err; |
| r12282 | r12283 | |
| 202 | 202 | |
| 203 | 203 | |
| 204 | 204 | |
| 205 | | static floperr_t internal_oric_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 205 | static floperr_t internal_oric_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 206 | 206 | { |
| 207 | 207 | UINT64 offset; |
| 208 | 208 | floperr_t err; |
| r12282 | r12283 | |
| 217 | 217 | |
| 218 | 218 | |
| 219 | 219 | |
| 220 | | static floperr_t oric_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 220 | static floperr_t oric_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 221 | 221 | { |
| 222 | 222 | return internal_oric_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | | static floperr_t oric_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 225 | static floperr_t oric_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 226 | 226 | { |
| 227 | 227 | return internal_oric_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | | static floperr_t oric_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 230 | static floperr_t oric_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 231 | 231 | { |
| 232 | 232 | return internal_oric_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | | static floperr_t oric_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 235 | static floperr_t oric_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 236 | 236 | { |
| 237 | 237 | return internal_oric_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | | static floperr_t oric_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 240 | static floperr_t oric_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 241 | 241 | { |
| 242 | 242 | floperr_t err; |
| 243 | 243 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 252 | 252 | |
| 253 | 253 | |
| 254 | 254 | |
| 255 | | static floperr_t oric_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 255 | static floperr_t oric_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 256 | 256 | { |
| 257 | 257 | floperr_t retVal; |
| 258 | 258 | |
src/lib/formats/smx_dsk.c
| r12282 | r12283 | |
| 17 | 17 | return FLOPPY_ERROR_SUCCESS; |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | | static int smx_get_heads_per_disk(floppy_image *floppy) |
| 20 | static int smx_get_heads_per_disk(floppy_image_legacy *floppy) |
| 21 | 21 | { |
| 22 | 22 | return 2; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | | static int smx_get_tracks_per_disk(floppy_image *floppy) |
| 25 | static int smx_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 26 | 26 | { |
| 27 | 27 | return 80; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | | static UINT64 smx_translate_offset(floppy_image *floppy, |
| 30 | static UINT64 smx_translate_offset(floppy_image_legacy *floppy, |
| 31 | 31 | int track, int head, int sector) |
| 32 | 32 | { |
| 33 | 33 | return (track * 1024 * 5 * 2) + (head * 1024 * 5) + 1024 * sector; |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 36 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 37 | 37 | { |
| 38 | 38 | UINT64 offs; |
| 39 | 39 | /* translate the sector to a raw sector */ |
| r12282 | r12283 | |
| 54 | 54 | |
| 55 | 55 | |
| 56 | 56 | |
| 57 | | static floperr_t internal_smx_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 57 | static floperr_t internal_smx_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 58 | 58 | { |
| 59 | 59 | UINT64 offset; |
| 60 | 60 | floperr_t err; |
| r12282 | r12283 | |
| 68 | 68 | |
| 69 | 69 | |
| 70 | 70 | |
| 71 | | static floperr_t internal_smx_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 71 | static floperr_t internal_smx_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 72 | 72 | { |
| 73 | 73 | UINT64 offset; |
| 74 | 74 | floperr_t err; |
| r12282 | r12283 | |
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | |
| 86 | | static floperr_t smx_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 86 | static floperr_t smx_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 87 | 87 | { |
| 88 | 88 | return internal_smx_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | | static floperr_t smx_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 91 | static floperr_t smx_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 92 | 92 | { |
| 93 | 93 | return internal_smx_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | | static floperr_t smx_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 96 | static floperr_t smx_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 97 | 97 | { |
| 98 | 98 | return internal_smx_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | | static floperr_t smx_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 101 | static floperr_t smx_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 102 | 102 | { |
| 103 | 103 | return internal_smx_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | | static floperr_t smx_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 106 | static floperr_t smx_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 107 | 107 | { |
| 108 | 108 | floperr_t err; |
| 109 | 109 | err = get_offset(floppy, head, track, sector, FALSE, NULL); |
| r12282 | r12283 | |
| 118 | 118 | |
| 119 | 119 | |
| 120 | 120 | |
| 121 | | static floperr_t smx_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 121 | static floperr_t smx_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 122 | 122 | { |
| 123 | 123 | sector_index += 1; |
| 124 | 124 | if (cylinder) |
src/lib/formats/basicdsk.c
| r12282 | r12283 | |
| 12 | 12 | |
| 13 | 13 | #include "basicdsk.h" |
| 14 | 14 | |
| 15 | | static floperr_t basicdsk_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 16 | | static floperr_t basicdsk_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 17 | | static floperr_t basicdsk_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 18 | | static floperr_t basicdsk_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 19 | | static floperr_t basicdsk_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 20 | | static floperr_t basicdsk_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags); |
| 21 | | static int basicdsk_get_heads_per_disk(floppy_image *floppy); |
| 22 | | static int basicdsk_get_tracks_per_disk(floppy_image *floppy); |
| 23 | | static floperr_t basicdsk_format_track(floppy_image *floppy, int head, int track, option_resolution *params); |
| 15 | static floperr_t basicdsk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 16 | static floperr_t basicdsk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 17 | static floperr_t basicdsk_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); |
| 18 | static floperr_t basicdsk_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); |
| 19 | static floperr_t basicdsk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length); |
| 20 | static floperr_t basicdsk_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags); |
| 21 | static int basicdsk_get_heads_per_disk(floppy_image_legacy *floppy); |
| 22 | static int basicdsk_get_tracks_per_disk(floppy_image_legacy *floppy); |
| 23 | static floperr_t basicdsk_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params); |
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | |
| r12282 | r12283 | |
| 35 | 35 | |
| 36 | 36 | /********************************************************************/ |
| 37 | 37 | |
| 38 | | static const struct basicdsk_geometry *get_geometry(floppy_image *floppy) |
| 38 | static const struct basicdsk_geometry *get_geometry(floppy_image_legacy *floppy) |
| 39 | 39 | { |
| 40 | 40 | const struct basicdsk_tag *tag; |
| 41 | 41 | tag = (const basicdsk_tag *)floppy_tag(floppy); |
| r12282 | r12283 | |
| 44 | 44 | |
| 45 | 45 | |
| 46 | 46 | |
| 47 | | floperr_t basicdsk_construct(floppy_image *floppy, const struct basicdsk_geometry *geometry) |
| 47 | floperr_t basicdsk_construct(floppy_image_legacy *floppy, const struct basicdsk_geometry *geometry) |
| 48 | 48 | { |
| 49 | 49 | struct basicdsk_tag *tag; |
| 50 | 50 | struct FloppyCallbacks *format; |
| r12282 | r12283 | |
| 75 | 75 | |
| 76 | 76 | |
| 77 | 77 | |
| 78 | | static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 78 | static floperr_t get_offset(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset) |
| 79 | 79 | { |
| 80 | 80 | const struct basicdsk_geometry *geom; |
| 81 | 81 | UINT64 offs; |
| r12282 | r12283 | |
| 117 | 117 | |
| 118 | 118 | |
| 119 | 119 | |
| 120 | | static int internal_basicdsk_translate_sector_interleave(floppy_image *floppy, int sector) |
| 120 | static int internal_basicdsk_translate_sector_interleave(floppy_image_legacy *floppy, int sector) |
| 121 | 121 | { |
| 122 | 122 | const struct basicdsk_geometry *geom = get_geometry(floppy); |
| 123 | 123 | if (sector >= geom->sectors) |
| r12282 | r12283 | |
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | |
| 130 | | static floperr_t internal_basicdsk_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 130 | static floperr_t internal_basicdsk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen) |
| 131 | 131 | { |
| 132 | 132 | UINT64 offset; |
| 133 | 133 | floperr_t err; |
| r12282 | r12283 | |
| 141 | 141 | |
| 142 | 142 | |
| 143 | 143 | |
| 144 | | static floperr_t internal_basicdsk_write_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 144 | static floperr_t internal_basicdsk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, int sector_is_index, const void *buffer, size_t buflen, int ddam) |
| 145 | 145 | { |
| 146 | 146 | UINT64 offset; |
| 147 | 147 | floperr_t err; |
| r12282 | r12283 | |
| 156 | 156 | |
| 157 | 157 | |
| 158 | 158 | |
| 159 | | static floperr_t basicdsk_read_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 159 | static floperr_t basicdsk_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 160 | 160 | { |
| 161 | 161 | return internal_basicdsk_read_sector(floppy, head, track, sector, FALSE, buffer, buflen); |
| 162 | 162 | } |
| 163 | 163 | |
| 164 | | static floperr_t basicdsk_write_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 164 | static floperr_t basicdsk_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 165 | 165 | { |
| 166 | 166 | return internal_basicdsk_write_sector(floppy, head, track, sector, FALSE, buffer, buflen, ddam); |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | | static floperr_t basicdsk_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 169 | static floperr_t basicdsk_read_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen) |
| 170 | 170 | { |
| 171 | 171 | return internal_basicdsk_read_sector(floppy, head, track, sector, TRUE, buffer, buflen); |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | | static floperr_t basicdsk_write_indexed_sector(floppy_image *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 174 | static floperr_t basicdsk_write_indexed_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam) |
| 175 | 175 | { |
| 176 | 176 | return internal_basicdsk_write_sector(floppy, head, track, sector, TRUE, buffer, buflen, ddam); |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | |
| 180 | 180 | |
| 181 | | static floperr_t basicdsk_format_track(floppy_image *floppy, int head, int track, option_resolution *params) |
| 181 | static floperr_t basicdsk_format_track(floppy_image_legacy *floppy, int head, int track, option_resolution *params) |
| 182 | 182 | { |
| 183 | 183 | floperr_t err = FLOPPY_ERROR_SUCCESS; |
| 184 | 184 | UINT8 local_buffer[512]; |
| r12282 | r12283 | |
| 225 | 225 | |
| 226 | 226 | |
| 227 | 227 | |
| 228 | | static int basicdsk_get_heads_per_disk(floppy_image *floppy) |
| 228 | static int basicdsk_get_heads_per_disk(floppy_image_legacy *floppy) |
| 229 | 229 | { |
| 230 | 230 | return get_geometry(floppy)->heads; |
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | |
| 234 | 234 | |
| 235 | | static int basicdsk_get_tracks_per_disk(floppy_image *floppy) |
| 235 | static int basicdsk_get_tracks_per_disk(floppy_image_legacy *floppy) |
| 236 | 236 | { |
| 237 | 237 | return get_geometry(floppy)->tracks; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
| 241 | 241 | |
| 242 | | static floperr_t basicdsk_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 242 | static floperr_t basicdsk_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) |
| 243 | 243 | { |
| 244 | 244 | floperr_t err; |
| 245 | 245 | |
| r12282 | r12283 | |
| 254 | 254 | |
| 255 | 255 | |
| 256 | 256 | |
| 257 | | static floperr_t basicdsk_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 257 | static floperr_t basicdsk_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) |
| 258 | 258 | { |
| 259 | 259 | const struct basicdsk_geometry *geom = get_geometry(floppy); |
| 260 | 260 | |