~ubuntu-branches/ubuntu/precise/mame/precise-proposed

« back to all changes in this revision

Viewing changes to src/lib/formats/coco_dsk.c

  • Committer: Package Import Robot
  • Author(s): Cesare Falco
  • Date: 2011-11-30 18:50:10 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111130185010-02hcxybht1mn082w
Tags: 0.144-0ubuntu1
* New upstream release (LP: #913550)
* mame.install:
  - Added artwork/ images to be used with -effect switch
  - Be more selective with hash/ contents
* contrib/mame.ini: added /usr/share/games/mame/artwork/ to artpath

Show diffs side-by-side

added added

removed removed

Lines of Context:
92
92
 *      there are no extra bytes in front of the sector data.
93
93
 *
94
94
 *  H. Sector attribute byte
95
 
 *      This byte is put at the begining of every sector if the header flag
 
95
 *      This byte is put at the beginning of every sector if the header flag
96
96
 *      is turned on. The information this byte contains is the same as the
97
97
 *      status register (of the wd179x) would contain when a 'Read Sector'
98
98
 *      command was issued. The bit fields are defined as:
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];
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;
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;
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;
603
603
 *
604
604
 * Each track begins with a track TOC, consisting of 64 little endian 16-bit
605
605
 * integers.  Each integer has the following format:
606
 
 *      bit 0-13:   Offset from begining of track to 'FE' byte of IDAM
 
606
 *      bit 0-13:   Offset from beginning of track to 'FE' byte of IDAM
607
607
 *                  Note these are always sorted from first to last. All empty
608
608
 *                  entries are 0x00
609
609
 *      bit 14:     Undefined (reserved)
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
 
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;
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;
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;
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;
838
838
done:
839
839
        if (sector_map)
840
840
                free(sector_map);
841
 
        return FLOPPY_ERROR_SUCCESS;
 
841
        return err;
842
842
}
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;
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;
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;
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;
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
 
1169
1169
 
1170
1170
/* ----------------------------------------------------------------------- */
1171
1171
 
1172
 
FLOPPY_OPTIONS_START( coco )
1173
 
        FLOPPY_OPTION( coco_jvc, "dsk",                 "CoCo JVC disk image",  coco_jvc_identify,      coco_jvc_construct, NULL,
 
1172
LEGACY_FLOPPY_OPTIONS_START( coco )
 
1173
        LEGACY_FLOPPY_OPTION( coco_jvc, "dsk",                  "CoCo JVC disk image",  coco_jvc_identify,      coco_jvc_construct, NULL,
1174
1174
                HEADS([1]-2)
1175
1175
                TRACKS([35]-255)
1176
1176
                SECTORS(1-[18]-255)
1177
1177
                SECTOR_LENGTH(128/[256]/512/1024)
1178
1178
                FIRST_SECTOR_ID(0-[1]))
1179
 
        FLOPPY_OPTION( coco_os9, "os9",                 "CoCo OS-9 disk image", coco_os9_identify,      coco_os9_construct, NULL,
 
1179
        LEGACY_FLOPPY_OPTION( coco_os9, "os9",                  "CoCo OS-9 disk image", coco_os9_identify,      coco_os9_construct, NULL,
1180
1180
                HEADS([1]-2)
1181
1181
                TRACKS([35]-255)
1182
1182
                SECTORS(1-[18]-255)
1183
1183
                SECTOR_LENGTH([256])
1184
1184
                FIRST_SECTOR_ID([1]))
1185
 
        FLOPPY_OPTION( coco_vdk, "vdk",                 "CoCo VDK disk image",  coco_vdk_identify,      coco_vdk_construct, NULL,
 
1185
        LEGACY_FLOPPY_OPTION( coco_vdk, "vdk",                  "CoCo VDK disk image",  coco_vdk_identify,      coco_vdk_construct, NULL,
1186
1186
                HEADS([1]-2)
1187
1187
                TRACKS([35]-255)
1188
1188
                SECTORS([18])
1189
1189
                SECTOR_LENGTH([256])
1190
1190
                FIRST_SECTOR_ID([1]))
1191
 
        FLOPPY_OPTION( coco_dmk, "dsk,dmk",     "CoCo DMK disk image",  coco_dmk_identify,      coco_dmk_construct, NULL,
 
1191
        LEGACY_FLOPPY_OPTION( coco_dmk, "dsk,dmk",      "CoCo DMK disk image",  coco_dmk_identify,      coco_dmk_construct, NULL,
1192
1192
                HEADS([1]-2)
1193
1193
                TRACKS([35]-255)
1194
1194
                SECTORS(1-[18])
1195
1195
                SECTOR_LENGTH(128/[256]/512/1024/2048/4096/8192)
1196
1196
                INTERLEAVE(0-[6]-17)
1197
1197
                FIRST_SECTOR_ID(0-[1]))
1198
 
FLOPPY_OPTIONS_END
 
1198
LEGACY_FLOPPY_OPTIONS_END