src/mess/tagpool.c
| r7012 | r7013 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | tagpool.c |
| 4 | | |
| 5 | | Utility code for maintaining tagged memory pools |
| 6 | | |
| 7 | | *********************************************************************/ |
| 8 | | |
| 9 | | #include <assert.h> |
| 10 | | #include <string.h> |
| 11 | | |
| 12 | | #include "tagpool.h" |
| 13 | | |
| 14 | | |
| 15 | | /*************************************************************************** |
| 16 | | |
| 17 | | Tagpool code |
| 18 | | |
| 19 | | ***************************************************************************/ |
| 20 | | |
| 21 | | struct tag_pool_header |
| 22 | | { |
| 23 | | struct tag_pool_header *next; |
| 24 | | const char *tagname; |
| 25 | | void *tagdata; |
| 26 | | }; |
| 27 | | |
| 28 | | void tagpool_init(tag_pool *tpool) |
| 29 | | { |
| 30 | | tpool->mempool = pool_alloc(NULL); |
| 31 | | tpool->header = NULL; |
| 32 | | } |
| 33 | | |
| 34 | | void tagpool_exit(tag_pool *tpool) |
| 35 | | { |
| 36 | | pool_free(tpool->mempool); |
| 37 | | tpool->header = NULL; |
| 38 | | } |
| 39 | | |
| 40 | | void *tagpool_alloc(tag_pool *tpool, const char *tag, size_t size) |
| 41 | | { |
| 42 | | struct tag_pool_header **header; |
| 43 | | struct tag_pool_header *newheader; |
| 44 | | |
| 45 | | newheader = (struct tag_pool_header *) pool_malloc(tpool->mempool, sizeof(struct tag_pool_header)); |
| 46 | | if (!newheader) |
| 47 | | return NULL; |
| 48 | | |
| 49 | | newheader->tagdata = pool_malloc(tpool->mempool, size); |
| 50 | | if (!newheader->tagdata) |
| 51 | | return NULL; |
| 52 | | |
| 53 | | newheader->next = NULL; |
| 54 | | newheader->tagname = tag; |
| 55 | | memset(newheader->tagdata, 0, size); |
| 56 | | |
| 57 | | header = &tpool->header; |
| 58 | | while (*header) |
| 59 | | header = &(*header)->next; |
| 60 | | *header = newheader; |
| 61 | | |
| 62 | | return newheader->tagdata; |
| 63 | | } |
| 64 | | |
| 65 | | void *tagpool_lookup(tag_pool *tpool, const char *tag) |
| 66 | | { |
| 67 | | struct tag_pool_header *header; |
| 68 | | |
| 69 | | assert(tpool); |
| 70 | | |
| 71 | | header = tpool->header; |
| 72 | | while(header && strcmp(header->tagname, tag)) |
| 73 | | header = header->next; |
| 74 | | |
| 75 | | /* a tagpool_lookup with an invalid tag is BAD */ |
| 76 | | assert(header); |
| 77 | | |
| 78 | | return header->tagdata; |
| 79 | | } |
src/mess/tagpool.h
| r7012 | r7013 | |
| 1 | | /********************************************************************* |
| 2 | | |
| 3 | | tagpool.h |
| 4 | | |
| 5 | | Utility code for maintaining tagged memory pools |
| 6 | | |
| 7 | | *********************************************************************/ |
| 8 | | |
| 9 | | #ifndef TAGPOOL_H |
| 10 | | #define TAGPOOL_H |
| 11 | | |
| 12 | | #include <stdlib.h> |
| 13 | | #include "pool.h" |
| 14 | | |
| 15 | | |
| 16 | | /*************************************************************************** |
| 17 | | |
| 18 | | Tagpool code |
| 19 | | |
| 20 | | ***************************************************************************/ |
| 21 | | |
| 22 | | typedef struct |
| 23 | | { |
| 24 | | object_pool *mempool; |
| 25 | | struct tag_pool_header *header; |
| 26 | | } tag_pool; |
| 27 | | |
| 28 | | void tagpool_init(tag_pool *tpool); |
| 29 | | void tagpool_exit(tag_pool *tpool); |
| 30 | | void *tagpool_alloc(tag_pool *tpool, const char *tag, size_t size); |
| 31 | | void *tagpool_lookup(tag_pool *tpool, const char *tag); |
| 32 | | |
| 33 | | #endif /* TAGPOOL_H */ |
src/mess/artworkx.c
| r7012 | r7013 | |
| 14 | 14 | #include "image.h" |
| 15 | 15 | #include "png.h" |
| 16 | 16 | |
| 17 | | |
| 18 | | /*************************************************************************** |
| 19 | | |
| 20 | | Local variables |
| 21 | | |
| 22 | | ***************************************************************************/ |
| 23 | | |
| 24 | | static char *override_artfile; |
| 25 | | |
| 26 | | |
| 27 | | |
| 28 | | /**************************************************************************/ |
| 29 | | |
| 30 | | void artwork_use_device_art(const device_config *img, const char *defaultartfile) |
| 31 | | { |
| 32 | | const char *strs[3]; |
| 33 | | int len, pos, i; |
| 34 | | |
| 35 | | /* This function builds the override_artfile string. This string is a |
| 36 | | * list of NUL terminated strings. These strings become the basename for |
| 37 | | * the .art file that we use. |
| 38 | | * |
| 39 | | * We use the following strings: |
| 40 | | * 1. The basename |
| 41 | | * 2. The goodname |
| 42 | | * 3. The file specified by defaultartfile |
| 43 | | */ |
| 44 | | |
| 45 | | strs[0] = image_basename_noext(img); |
| 46 | | strs[1] = strs[0] ? image_longname(img) : NULL; |
| 47 | | strs[2] = defaultartfile; |
| 48 | | |
| 49 | | /* concatenate the strings; first calculate length of the string */ |
| 50 | | len = 1; |
| 51 | | for (i = 0; i < ARRAY_LENGTH(strs); i++) |
| 52 | | { |
| 53 | | if (strs[i]) |
| 54 | | len += strlen(strs[i]) + 1; |
| 55 | | } |
| 56 | | |
| 57 | | override_artfile = auto_alloc_array(img->machine, char, len); |
| 58 | | override_artfile[len - 1] = '\0'; |
| 59 | | |
| 60 | | /* now actually concatenate the strings */ |
| 61 | | pos = 0; |
| 62 | | for (i = 0; i < ARRAY_LENGTH(strs); i++) |
| 63 | | { |
| 64 | | if (strs[i]) |
| 65 | | { |
| 66 | | strcpy(&override_artfile[pos], strs[i]); |
| 67 | | pos += strlen(strs[i]) + 1; |
| 68 | | } |
| 69 | | } |
| 70 | | |
| 71 | | /* small transformations */ |
| 72 | | for (i = 0; i < len; i++) |
| 73 | | { |
| 74 | | if (override_artfile[i] == ':') |
| 75 | | override_artfile[i] = '-'; |
| 76 | | } |
| 77 | | } |
| 78 | | |
| 79 | | |
| 80 | | |
| 81 | 17 | /********************************************************************/ |
| 82 | 18 | |
| 83 | 19 | int artwork_get_inputscreen_customizations(png_info *png, artwork_cust_type cust_type, |
src/mess/machine/99_dsk.c
| r7012 | r7013 | |
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | #define MAX_FLOPPIES 4 |
| 38 | | #define TI99DSK_TAG "ti99dsktag" |
| 39 | 38 | |
| 40 | | |
| 41 | 39 | static int use_80_track_drives; |
| 42 | 40 | |
| 43 | 41 | /* defines for DRQ_IRQ_status */ |
| r7012 | r7013 | |
| 137 | 135 | static int ti99_tracktranslate(const device_config *image, floppy_image *floppy, int physical_track) |
| 138 | 136 | { |
| 139 | 137 | struct ti99_geometry *geometry; |
| 140 | | geometry = floppy_tag(floppy, TI99DSK_TAG); |
| 138 | geometry = floppy_tag(floppy); |
| 141 | 139 | |
| 142 | 140 | if (use_80_track_drives && (geometry->tracksperside <= 40)) |
| 143 | 141 | return physical_track/2; |
| r7012 | r7013 | |
| 327 | 325 | int success; |
| 328 | 326 | floperr_t err; |
| 329 | 327 | |
| 330 | | geometry1 = floppy_create_tag(floppy, TI99DSK_TAG, sizeof(*geometry1)); |
| 328 | geometry1 = floppy_create_tag(floppy, sizeof(*geometry1)); |
| 331 | 329 | |
| 332 | 330 | ti99_guess_geometry(floppy, geometry1, NULL, &success); |
| 333 | 331 | if (! success) |
src/mess/formats/d88_dsk.c
| r7012 | r7013 | |
| 43 | 43 | |
| 44 | 44 | static struct d88_tag *get_d88_tag(floppy_image *floppy) |
| 45 | 45 | { |
| 46 | | return floppy_tag(floppy, "d88tag"); |
| 46 | return floppy_tag(floppy); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | static int d88_get_sector_id(floppy_image *floppy, int head, int track, int sector_index) |
| r7012 | r7013 | |
| 339 | 339 | d88_get_header(floppy,&size,&prot,&type,offs); |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | | tag = floppy_create_tag(floppy,"d88tag",sizeof(struct d88_tag)); |
| 342 | tag = floppy_create_tag(floppy,sizeof(struct d88_tag)); |
| 343 | 343 | if (!tag) |
| 344 | 344 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 345 | 345 | |
src/mess/formats/cqm_dsk.c
| r7012 | r7013 | |
| 11 | 11 | #include "formats/flopimg.h" |
| 12 | 12 | #include "devices/flopdrv.h" |
| 13 | 13 | |
| 14 | | #define CQM_DSK_TAG "cqmtag" |
| 15 | 14 | #define CQM_HEADER_SIZE 133 |
| 16 | 15 | |
| 17 | 16 | struct cqmdsk_tag |
| r7012 | r7013 | |
| 32 | 31 | static struct cqmdsk_tag *get_tag(floppy_image *floppy) |
| 33 | 32 | { |
| 34 | 33 | struct cqmdsk_tag *tag; |
| 35 | | tag = floppy_tag(floppy, CQM_DSK_TAG); |
| 34 | tag = floppy_tag(floppy ); |
| 36 | 35 | return tag; |
| 37 | 36 | } |
| 38 | 37 | |
| r7012 | r7013 | |
| 175 | 174 | return FLOPPY_ERROR_UNSUPPORTED; |
| 176 | 175 | } |
| 177 | 176 | |
| 178 | | tag = (struct cqmdsk_tag *) floppy_create_tag(floppy, CQM_DSK_TAG, sizeof(struct cqmdsk_tag)); |
| 177 | tag = (struct cqmdsk_tag *) floppy_create_tag(floppy, sizeof(struct cqmdsk_tag)); |
| 179 | 178 | if (!tag) |
| 180 | 179 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 181 | 180 | |
src/mess/formats/coco_dsk.c
| r7012 | r7013 | |
| 618 | 618 | UINT32 track_size; |
| 619 | 619 | }; |
| 620 | 620 | |
| 621 | | #define DMK_TAG "dmktag" |
| 622 | 621 | #define DMK_HEADER_LEN 16 |
| 623 | 622 | #define DMK_TOC_LEN 64 |
| 624 | 623 | #define DMK_IDAM_LENGTH 7 |
| r7012 | r7013 | |
| 637 | 636 | |
| 638 | 637 | static struct dmk_tag *get_dmk_tag(floppy_image *floppy) |
| 639 | 638 | { |
| 640 | | return floppy_tag(floppy, DMK_TAG); |
| 639 | return floppy_tag(floppy); |
| 641 | 640 | } |
| 642 | 641 | |
| 643 | 642 | |
| r7012 | r7013 | |
| 1128 | 1127 | coco_dmk_interpret_header(floppy, &heads, &tracks, &track_size); |
| 1129 | 1128 | } |
| 1130 | 1129 | |
| 1131 | | tag = floppy_create_tag(floppy, DMK_TAG, sizeof(struct dmk_tag)); |
| 1130 | tag = floppy_create_tag(floppy, sizeof(struct dmk_tag)); |
| 1132 | 1131 | if (!tag) |
| 1133 | 1132 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 1134 | 1133 | tag->heads = heads; |
src/mess/formats/flopimg.c
| r7012 | r7013 | |
| 15 | 15 | |
| 16 | 16 | #include "osdepend.h" |
| 17 | 17 | #include "formats/flopimg.h" |
| 18 | | #include "tagpool.h" |
| 18 | #include "pool.h" |
| 19 | 19 | #include "utils.h" |
| 20 | 20 | |
| 21 | 21 | #define TRACK_LOADED 0x01 |
| r7012 | r7013 | |
| 38 | 38 | UINT8 flags; |
| 39 | 39 | |
| 40 | 40 | /* tagging system */ |
| 41 | | tag_pool tags; |
| 41 | object_pool *tags; |
| 42 | void *tag_data; |
| 42 | 43 | }; |
| 43 | 44 | |
| 44 | 45 | |
| r7012 | r7013 | |
| 79 | 80 | return NULL; |
| 80 | 81 | |
| 81 | 82 | memset(floppy, 0, sizeof(*floppy)); |
| 82 | | tagpool_init(&floppy->tags); |
| 83 | floppy->tags = pool_alloc(NULL); |
| 84 | floppy->tag_data = NULL; |
| 83 | 85 | floppy->io.file = fp; |
| 84 | 86 | floppy->io.procs = procs; |
| 85 | 87 | floppy->io.filler = 0xFF; |
| r7012 | r7013 | |
| 321 | 323 | io_generic_close(&floppy->io); |
| 322 | 324 | if (floppy->loaded_track_data) |
| 323 | 325 | free(floppy->loaded_track_data); |
| 324 | | tagpool_exit(&floppy->tags); |
| 326 | pool_free(floppy->tags); |
| 325 | 327 | } |
| 326 | 328 | |
| 327 | 329 | free(floppy); |
| r7012 | r7013 | |
| 348 | 350 | |
| 349 | 351 | |
| 350 | 352 | |
| 351 | | void *floppy_tag(floppy_image *floppy, const char *tagname) |
| 353 | void *floppy_tag(floppy_image *floppy) |
| 352 | 354 | { |
| 353 | 355 | assert(floppy); |
| 354 | | return tagpool_lookup(&floppy->tags, tagname); |
| 356 | return floppy->tag_data; |
| 355 | 357 | } |
| 356 | 358 | |
| 357 | 359 | |
| 358 | 360 | |
| 359 | | void *floppy_create_tag(floppy_image *floppy, const char *tagname, size_t tagsize) |
| 361 | void *floppy_create_tag(floppy_image *floppy, size_t tagsize) |
| 360 | 362 | { |
| 361 | | return tagpool_alloc(&floppy->tags, tagname, tagsize); |
| 363 | floppy->tag_data = pool_malloc(floppy->tags,tagsize); |
| 364 | return floppy->tag_data; |
| 362 | 365 | } |
| 363 | 366 | |
| 364 | 367 | |
src/mess/formats/flopimg.h
| r7012 | r7013 | |
| 157 | 157 | const struct FloppyFormat *formats, int *identified_format); |
| 158 | 158 | |
| 159 | 159 | /* functions useful within format constructors */ |
| 160 | | void *floppy_tag(floppy_image *floppy, const char *tagname); |
| 161 | | void *floppy_create_tag(floppy_image *floppy, const char *tagname, size_t tagsize); |
| 160 | void *floppy_tag(floppy_image *floppy); |
| 161 | void *floppy_create_tag(floppy_image *floppy, size_t tagsize); |
| 162 | 162 | struct FloppyCallbacks *floppy_callbacks(floppy_image *floppy); |
| 163 | 163 | UINT8 floppy_get_filler(floppy_image *floppy); |
| 164 | 164 | void floppy_set_filler(floppy_image *floppy, UINT8 filler); |
src/mess/formats/ap_dsk35.c
| r7012 | r7013 | |
| 76 | 76 | |
| 77 | 77 | #include "formats/ap_dsk35.h" |
| 78 | 78 | |
| 79 | | |
| 80 | | #define APPLE35_TAG "a35_tag" |
| 81 | | |
| 82 | 79 | struct apple35_tag |
| 83 | 80 | { |
| 84 | 81 | UINT32 data_offset; |
| r7012 | r7013 | |
| 189 | 186 | static struct apple35_tag *get_apple35_tag(floppy_image *floppy) |
| 190 | 187 | { |
| 191 | 188 | struct apple35_tag *tag; |
| 192 | | tag = (struct apple35_tag *) floppy_tag(floppy, APPLE35_TAG); |
| 189 | tag = (struct apple35_tag *) floppy_tag(floppy); |
| 193 | 190 | return tag; |
| 194 | 191 | } |
| 195 | 192 | |
| r7012 | r7013 | |
| 769 | 766 | } |
| 770 | 767 | |
| 771 | 768 | /* create tag */ |
| 772 | | tag = (struct apple35_tag *) floppy_create_tag(floppy, APPLE35_TAG, sizeof(struct apple35_tag)); |
| 769 | tag = (struct apple35_tag *) floppy_create_tag(floppy, sizeof(struct apple35_tag)); |
| 773 | 770 | if (!tag) |
| 774 | 771 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 775 | 772 | tag->data_offset = data_offset; |
src/mess/formats/td0_dsk.c
| r7012 | r7013 | |
| 17 | 17 | #include "formats/flopimg.h" |
| 18 | 18 | #include "devices/flopdrv.h" |
| 19 | 19 | |
| 20 | | #define TD0_DSK_TAG "td0tag" |
| 21 | | |
| 22 | 20 | struct td0dsk_tag |
| 23 | 21 | { |
| 24 | 22 | int heads; |
| r7012 | r7013 | |
| 32 | 30 | static struct td0dsk_tag *get_tag(floppy_image *floppy) |
| 33 | 31 | { |
| 34 | 32 | struct td0dsk_tag *tag; |
| 35 | | tag = floppy_tag(floppy, TD0_DSK_TAG); |
| 33 | tag = floppy_tag(floppy); |
| 36 | 34 | return tag; |
| 37 | 35 | } |
| 38 | 36 | |
| r7012 | r7013 | |
| 657 | 655 | return FLOPPY_ERROR_UNSUPPORTED; |
| 658 | 656 | } |
| 659 | 657 | |
| 660 | | tag = (struct td0dsk_tag *) floppy_create_tag(floppy, TD0_DSK_TAG, sizeof(struct td0dsk_tag)); |
| 658 | tag = (struct td0dsk_tag *) floppy_create_tag(floppy, sizeof(struct td0dsk_tag)); |
| 661 | 659 | if (!tag) |
| 662 | 660 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 663 | 661 | |
src/mess/formats/g64_dsk.c
| r7012 | r7013 | |
| 42 | 42 | |
| 43 | 43 | #define LOG 0 |
| 44 | 44 | |
| 45 | | #define G64_DSK_TAG "g64tag" |
| 46 | | |
| 47 | 45 | #define HEADER_LENGTH 0x2ac /* standard length for 84 half tracks */ |
| 48 | 46 | #define HALF_TRACKS 84 |
| 49 | 47 | |
| r7012 | r7013 | |
| 64 | 62 | static struct g64dsk_tag *get_tag(floppy_image *floppy) |
| 65 | 63 | { |
| 66 | 64 | struct g64dsk_tag *tag; |
| 67 | | tag = floppy_tag(floppy, G64_DSK_TAG); |
| 65 | tag = floppy_tag(floppy); |
| 68 | 66 | return tag; |
| 69 | 67 | } |
| 70 | 68 | |
| r7012 | r7013 | |
| 169 | 167 | return FLOPPY_ERROR_UNSUPPORTED; |
| 170 | 168 | } |
| 171 | 169 | |
| 172 | | tag = (struct g64dsk_tag *) floppy_create_tag(floppy, G64_DSK_TAG, sizeof(struct g64dsk_tag)); |
| 170 | tag = (struct g64dsk_tag *) floppy_create_tag(floppy, sizeof(struct g64dsk_tag)); |
| 173 | 171 | |
| 174 | 172 | if (!tag) return FLOPPY_ERROR_OUTOFMEMORY; |
| 175 | 173 | |
src/mess/formats/thom_dsk.c
| r7012 | r7013 | |
| 13 | 13 | #include "formats/thom_dsk.h" |
| 14 | 14 | #include "formats/basicdsk.h" |
| 15 | 15 | |
| 16 | | #define SAP_DSK_TAG "sapdsktag" |
| 17 | | |
| 18 | 16 | static const int sap_magic_num = 0xB3; /* simple XOR crypt */ |
| 19 | 17 | |
| 20 | 18 | |
| r7012 | r7013 | |
| 51 | 49 | static struct sap_dsk_tag *get_tag(floppy_image *floppy) |
| 52 | 50 | { |
| 53 | 51 | struct sap_dsk_tag *tag; |
| 54 | | tag = floppy_tag(floppy, SAP_DSK_TAG); |
| 52 | tag = floppy_tag(floppy); |
| 55 | 53 | return tag; |
| 56 | 54 | } |
| 57 | 55 | |
| r7012 | r7013 | |
| 216 | 214 | int pos; |
| 217 | 215 | UINT8 buf[256], header[4]; |
| 218 | 216 | struct sap_dsk_tag *tag; |
| 219 | | tag = (struct sap_dsk_tag *) floppy_create_tag(floppy, SAP_DSK_TAG, sizeof(struct sap_dsk_tag)); |
| 217 | tag = (struct sap_dsk_tag *) floppy_create_tag(floppy, sizeof(struct sap_dsk_tag)); |
| 220 | 218 | |
| 221 | 219 | /* default options */ |
| 222 | 220 | if ( !tag->tracks ) |
| r7012 | r7013 | |
| 256 | 254 | struct sap_dsk_tag *tag; |
| 257 | 255 | int i,j; |
| 258 | 256 | UINT8 fmt; |
| 259 | | tag = (struct sap_dsk_tag *) floppy_create_tag(floppy, SAP_DSK_TAG, sizeof(struct sap_dsk_tag)); |
| 257 | tag = (struct sap_dsk_tag *) floppy_create_tag(floppy, sizeof(struct sap_dsk_tag)); |
| 260 | 258 | if (!tag) |
| 261 | 259 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 262 | 260 | |
src/mess/formats/imd_dsk.c
| r7012 | r7013 | |
| 11 | 11 | #include "formats/flopimg.h" |
| 12 | 12 | #include "devices/flopdrv.h" |
| 13 | 13 | |
| 14 | | #define IMD_DSK_TAG "imdtag" |
| 15 | | |
| 16 | 14 | struct imddsk_tag |
| 17 | 15 | { |
| 18 | 16 | int heads; |
| r7012 | r7013 | |
| 25 | 23 | static struct imddsk_tag *get_tag(floppy_image *floppy) |
| 26 | 24 | { |
| 27 | 25 | struct imddsk_tag *tag; |
| 28 | | tag = floppy_tag(floppy, IMD_DSK_TAG); |
| 26 | tag = floppy_tag(floppy); |
| 29 | 27 | return tag; |
| 30 | 28 | } |
| 31 | 29 | |
| r7012 | r7013 | |
| 229 | 227 | return FLOPPY_ERROR_UNSUPPORTED; |
| 230 | 228 | } |
| 231 | 229 | |
| 232 | | tag = (struct imddsk_tag *) floppy_create_tag(floppy, IMD_DSK_TAG, sizeof(struct imddsk_tag)); |
| 230 | tag = (struct imddsk_tag *) floppy_create_tag(floppy, sizeof(struct imddsk_tag)); |
| 233 | 231 | if (!tag) |
| 234 | 232 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 235 | 233 | |
src/mess/formats/dsk_dsk.c
| r7012 | r7013 | |
| 16 | 16 | #define MV_CPC "MV - CPC" |
| 17 | 17 | #define EXTENDED "EXTENDED" |
| 18 | 18 | |
| 19 | | #define dskDSK_TAG "dskdsktag" |
| 20 | | |
| 21 | 19 | struct dskdsk_tag |
| 22 | 20 | { |
| 23 | 21 | int disk_image_type; /* image type: standard or extended */ |
| r7012 | r7013 | |
| 32 | 30 | static struct dskdsk_tag *get_tag(floppy_image *floppy) |
| 33 | 31 | { |
| 34 | 32 | struct dskdsk_tag *tag; |
| 35 | | tag = floppy_tag(floppy, dskDSK_TAG); |
| 33 | tag = floppy_tag(floppy); |
| 36 | 34 | return tag; |
| 37 | 35 | } |
| 38 | 36 | |
| r7012 | r7013 | |
| 216 | 214 | |
| 217 | 215 | floppy_image_read(floppy, header, 0, 0x100); |
| 218 | 216 | |
| 219 | | tag = (struct dskdsk_tag *) floppy_create_tag(floppy, dskDSK_TAG, sizeof(struct dskdsk_tag)); |
| 217 | tag = (struct dskdsk_tag *) floppy_create_tag(floppy, sizeof(struct dskdsk_tag)); |
| 220 | 218 | if (!tag) |
| 221 | 219 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 222 | 220 | |
src/mess/formats/oric_dsk.c
| r7012 | r7013 | |
| 28 | 28 | UINT8 ddam; |
| 29 | 29 | }; |
| 30 | 30 | |
| 31 | | #define ORICDSK_TAG "oricdsktag" |
| 32 | 31 | struct oricdsk_tag |
| 33 | 32 | { |
| 34 | 33 | int tracks; |
| r7012 | r7013 | |
| 43 | 42 | static struct oricdsk_tag *get_tag(floppy_image *floppy) |
| 44 | 43 | { |
| 45 | 44 | struct oricdsk_tag *tag; |
| 46 | | tag = floppy_tag(floppy, ORICDSK_TAG); |
| 45 | tag = floppy_tag(floppy); |
| 47 | 46 | return tag; |
| 48 | 47 | } |
| 49 | 48 | |
| r7012 | r7013 | |
| 284 | 283 | |
| 285 | 284 | floppy_image_read(floppy, header, 0, mfm_disk_header_size); |
| 286 | 285 | |
| 287 | | tag = (struct oricdsk_tag *) floppy_create_tag(floppy, ORICDSK_TAG, sizeof(struct oricdsk_tag)); |
| 286 | tag = (struct oricdsk_tag *) floppy_create_tag(floppy, sizeof(struct oricdsk_tag)); |
| 288 | 287 | if (!tag) |
| 289 | 288 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 290 | 289 | |
src/mess/formats/z80ne_dsk.c
| r7012 | r7013 | |
| 60 | 60 | UINT32 track_size; |
| 61 | 61 | }; |
| 62 | 62 | |
| 63 | | #define DMK_TAG "z80nedmk" |
| 64 | | |
| 65 | 63 | /* DMK file structure |
| 66 | 64 | * See WD1711 documentation |
| 67 | 65 | */ |
| r7012 | r7013 | |
| 97 | 95 | |
| 98 | 96 | static struct dmk_tag *get_dmk_tag(floppy_image *floppy) |
| 99 | 97 | { |
| 100 | | return floppy_tag(floppy, DMK_TAG); |
| 98 | return floppy_tag(floppy); |
| 101 | 99 | } |
| 102 | 100 | |
| 103 | 101 | |
| r7012 | r7013 | |
| 785 | 783 | z80ne_dmk_interpret_header(floppy, &heads, &tracks, §ors, &track_size); |
| 786 | 784 | } |
| 787 | 785 | |
| 788 | | tag = floppy_create_tag(floppy, DMK_TAG, sizeof(struct dmk_tag)); |
| 786 | tag = floppy_create_tag(floppy, sizeof(struct dmk_tag)); |
| 789 | 787 | if (!tag) |
| 790 | 788 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 791 | 789 | tag->heads = heads; |
src/mess/formats/coupedsk.c
| r7012 | r7013 | |
| 13 | 13 | #define SAD_HEADER_LEN 22 |
| 14 | 14 | #define SAD_SIGNATURE "Aley's disk backup" |
| 15 | 15 | |
| 16 | | #define SDF_TAG "sdftag" |
| 17 | 16 | #define SDF_TRACKSIZE (512 * 12) |
| 18 | 17 | |
| 19 | 18 | |
| r7012 | r7013 | |
| 214 | 213 | |
| 215 | 214 | static int coupe_sdf_get_heads_per_disk(floppy_image *floppy) |
| 216 | 215 | { |
| 217 | | struct sdf_tag *tag = floppy_tag(floppy, SDF_TAG); |
| 216 | struct sdf_tag *tag = floppy_tag(floppy); |
| 218 | 217 | return tag->heads; |
| 219 | 218 | } |
| 220 | 219 | |
| 221 | 220 | |
| 222 | 221 | static int coupe_sdf_get_tracks_per_disk(floppy_image *floppy) |
| 223 | 222 | { |
| 224 | | struct sdf_tag *tag = floppy_tag(floppy, SDF_TAG); |
| 223 | struct sdf_tag *tag = floppy_tag(floppy); |
| 225 | 224 | return tag->tracks; |
| 226 | 225 | } |
| 227 | 226 | |
| r7012 | r7013 | |
| 235 | 234 | static floperr_t coupe_sdf_get_offset(floppy_image *floppy, |
| 236 | 235 | int head, int track, UINT64 *offset) |
| 237 | 236 | { |
| 238 | | struct sdf_tag *tag = floppy_tag(floppy, SDF_TAG); |
| 237 | struct sdf_tag *tag = floppy_tag(floppy); |
| 239 | 238 | |
| 240 | 239 | if (head > tag->heads || track > tag->tracks) |
| 241 | 240 | return FLOPPY_ERROR_SEEKERROR; |
| r7012 | r7013 | |
| 449 | 448 | coupe_sdf_interpret_header(floppy, &heads, &tracks); |
| 450 | 449 | } |
| 451 | 450 | |
| 452 | | tag = floppy_create_tag(floppy, SDF_TAG, sizeof(struct sdf_tag)); |
| 451 | tag = floppy_create_tag(floppy, sizeof(struct sdf_tag)); |
| 453 | 452 | |
| 454 | 453 | if (!tag) |
| 455 | 454 | return FLOPPY_ERROR_OUTOFMEMORY; |
src/mess/formats/basicdsk.c
| r7012 | r7013 | |
| 38 | 38 | static const struct basicdsk_geometry *get_geometry(floppy_image *floppy) |
| 39 | 39 | { |
| 40 | 40 | const struct basicdsk_tag *tag; |
| 41 | | tag = floppy_tag(floppy, BASICDSK_TAG); |
| 41 | tag = floppy_tag(floppy); |
| 42 | 42 | return &tag->geometry; |
| 43 | 43 | } |
| 44 | 44 | |
| r7012 | r7013 | |
| 53 | 53 | assert(geometry->tracks); |
| 54 | 54 | assert(geometry->sectors); |
| 55 | 55 | |
| 56 | | tag = (struct basicdsk_tag *) floppy_create_tag(floppy, BASICDSK_TAG, sizeof(struct basicdsk_tag)); |
| 56 | tag = (struct basicdsk_tag *) floppy_create_tag(floppy, sizeof(struct basicdsk_tag)); |
| 57 | 57 | if (!tag) |
| 58 | 58 | return FLOPPY_ERROR_OUTOFMEMORY; |
| 59 | 59 | tag->geometry = *geometry; |