summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/ap_dsk35.cpp
diff options
context:
space:
mode:
author Miodrag Milanovic <mmicko@gmail.com>2016-10-22 13:13:17 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2016-10-22 13:13:17 +0200
commitddb290d5f615019c33c42b8d94e5a5254cabcf33 (patch)
treea70f688b0df3acd19da7b1151e5902e3c6af3fa5 /src/lib/formats/ap_dsk35.cpp
parent333bff8de64dfaeb98134000412796b4fdef970b (diff)
NOTICE (TYPE NAME CONSOLIDATION)
Use standard uint64_t, uint32_t, uint16_t or uint8_t instead of UINT64, UINT32, UINT16 or UINT8 also use standard int64_t, int32_t, int16_t or int8_t instead of INT64, INT32, INT16 or INT8
Diffstat (limited to 'src/lib/formats/ap_dsk35.cpp')
-rw-r--r--src/lib/formats/ap_dsk35.cpp324
1 files changed, 162 insertions, 162 deletions
diff --git a/src/lib/formats/ap_dsk35.cpp b/src/lib/formats/ap_dsk35.cpp
index baa60254b4b..38a36a956ec 100644
--- a/src/lib/formats/ap_dsk35.cpp
+++ b/src/lib/formats/ap_dsk35.cpp
@@ -106,21 +106,21 @@
struct apple35_tag
{
- UINT32 data_offset;
- UINT32 data_size;
- UINT8 format_byte;
- UINT8 sides;
+ uint32_t data_offset;
+ uint32_t data_size;
+ uint8_t format_byte;
+ uint8_t sides;
unsigned int is_1440k : 1;
/* stuff used in DiskCopy images */
- UINT32 tag_offset;
- UINT32 tag_size;
+ uint32_t tag_offset;
+ uint32_t tag_size;
};
/* normal number of sector for each track */
-static const UINT8 apple35_tracklen_800kb[80] =
+static const uint8_t apple35_tracklen_800kb[80] =
{
12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
@@ -130,7 +130,7 @@ static const UINT8 apple35_tracklen_800kb[80] =
};
/* blocks of data used to nibblize tracks */
-static const UINT8 diskbytes[] =
+static const uint8_t diskbytes[] =
{
0x96, 0x97, 0x9A, 0x9B, 0x9D, 0x9E, 0x9F, 0xA6, /* 0x00 */
0xA7, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB2, 0xB3,
@@ -143,7 +143,7 @@ static const UINT8 diskbytes[] =
};
/* reverse lookup of diskbytes */
-static const INT16 rev_diskbytes[] =
+static const int16_t rev_diskbytes[] =
{
-1, -1, -1, -1, -1, -1, -1, -1, /* 0x00 */
-1, -1, -1, -1, -1, -1, -1, -1,
@@ -179,7 +179,7 @@ static const INT16 rev_diskbytes[] =
-1, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F
};
-static const UINT8 blk1[] =
+static const uint8_t blk1[] =
{
/*0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@@ -200,11 +200,11 @@ static const UINT8 blk1[] =
0xFF, 0x3F, 0xCF, 0xF3, 0xFC, 0xFF,
0xD5, 0xAA, 0x96
};
-static const UINT8 blk2[] =
+static const uint8_t blk2[] =
{
0xDE, 0xAA, 0xFF, 0xFF, 0x3F, 0xCF, 0xF3, 0xFC, 0xFF, 0xD5, 0xAA, 0xAD
};
-static const UINT8 blk3[] =
+static const uint8_t blk3[] =
{
0xDE, 0xAA, 0xFF
};
@@ -243,13 +243,13 @@ int apple35_sectors_per_track(floppy_image_legacy *image, int track)
tag data IS important, since it allows data recovery when the catalog is trashed
*/
-static void sony_nibblize35(const UINT8 *in, UINT8 *nib_ptr, UINT8 *csum)
+static void sony_nibblize35(const uint8_t *in, uint8_t *nib_ptr, uint8_t *csum)
{
int i, j;
- UINT32 c1, c2, c3, c4;
- UINT8 val;
- UINT8 w1, w2, w3, w4;
- UINT8 b1[175], b2[175], b3[175];
+ uint32_t c1, c2, c3, c4;
+ uint8_t val;
+ uint8_t w1, w2, w3, w4;
+ uint8_t b1[175], b2[175], b3[175];
/* Copy from the user's buffer to our buffer, while computing
* the three-byte data checksum
@@ -327,13 +327,13 @@ static void sony_nibblize35(const UINT8 *in, UINT8 *nib_ptr, UINT8 *csum)
/*
does the reverse process of sony_nibblize35
*/
-static void sony_denibblize35(UINT8 *out, const UINT8 *nib_ptr, UINT8 *checksum)
+static void sony_denibblize35(uint8_t *out, const uint8_t *nib_ptr, uint8_t *checksum)
{
int i, j;
- UINT32 c1,c2,c3,c4;
- UINT8 val;
- UINT8 w1,w2,w3=0,w4;
- UINT8 b1[175],b2[175],b3[175];
+ uint32_t c1,c2,c3,c4;
+ uint8_t val;
+ uint8_t w1,w2,w3=0,w4;
+ uint8_t b1[175],b2[175],b3[175];
j = 0;
for (i=0; i<=174; i++)
@@ -405,7 +405,7 @@ static void sony_denibblize35(UINT8 *out, const UINT8 *nib_ptr, UINT8 *checksum)
-void sony_filltrack(UINT8 *buffer, size_t buffer_len, size_t *pos, UINT8 data)
+void sony_filltrack(uint8_t *buffer, size_t buffer_len, size_t *pos, uint8_t data)
{
buffer[*pos / 8] &= 0xFF << (8 - (*pos % 8));
buffer[*pos / 8] |= data >> (*pos % 8);
@@ -419,9 +419,9 @@ void sony_filltrack(UINT8 *buffer, size_t buffer_len, size_t *pos, UINT8 data)
-UINT8 sony_fetchtrack(const UINT8 *buffer, size_t buffer_len, size_t *pos)
+uint8_t sony_fetchtrack(const uint8_t *buffer, size_t buffer_len, size_t *pos)
{
- UINT8 data;
+ uint8_t data;
data = buffer[*pos / 8] << (*pos % 8);
*pos += 8;
@@ -446,10 +446,10 @@ UINT8 sony_fetchtrack(const UINT8 *buffer, size_t buffer_len, size_t *pos)
-static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *tag_offset)
+static uint32_t apple35_get_offset(floppy_image_legacy *floppy, int head, int track, int sector, uint32_t *tag_offset)
{
int i;
- UINT32 sector_index = 0;
+ uint32_t sector_index = 0;
struct apple35_tag *tag;
tag = get_apple35_tag(floppy);
@@ -487,7 +487,7 @@ static UINT32 apple35_get_offset(floppy_image_legacy *floppy, int head, int trac
static floperr_t apple35_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
{
- UINT32 data_offset;
+ uint32_t data_offset;
data_offset = apple35_get_offset(floppy, head, track, sector, nullptr);
if (data_offset == ~0)
{
@@ -501,7 +501,7 @@ static floperr_t apple35_read_sector(floppy_image_legacy *floppy, int head, int
static floperr_t apple35_write_sector(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam)
{
- UINT32 data_offset;
+ uint32_t data_offset;
data_offset = apple35_get_offset(floppy, head, track, sector, nullptr);
if (data_offset == ~0)
@@ -515,12 +515,12 @@ static floperr_t apple35_write_sector(floppy_image_legacy *floppy, int head, int
static floperr_t apple35_read_sector_td(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
{
floperr_t err;
- UINT32 tag_offset = 0;
+ uint32_t tag_offset = 0;
assert(buflen == 524);
/* first read the sector */
- err = apple35_read_sector(floppy, head, track, sector, ((UINT8 *) buffer) + 12, 512);
+ err = apple35_read_sector(floppy, head, track, sector, ((uint8_t *) buffer) + 12, 512);
if (err)
{
return err;
@@ -542,12 +542,12 @@ static floperr_t apple35_read_sector_td(floppy_image_legacy *floppy, int head, i
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)
{
floperr_t err;
- UINT32 tag_offset = 0;
+ uint32_t tag_offset = 0;
assert(buflen == 524);
/* first write the sector */
- err = apple35_write_sector(floppy, head, track, sector, ((const UINT8 *) buffer) + 12, 512, 0);
+ err = apple35_write_sector(floppy, head, track, sector, ((const uint8_t *) buffer) + 12, 512, 0);
if (err)
return err;
@@ -561,7 +561,7 @@ static floperr_t apple35_write_sector_td(floppy_image_legacy *floppy, int head,
-static floperr_t apple35_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
+static floperr_t apple35_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, uint32_t *sector_length)
{
*sector_length = 512;
return FLOPPY_ERROR_SUCCESS;
@@ -583,7 +583,7 @@ static int apple35_get_tracks_per_disk(floppy_image_legacy *floppy)
-static UINT32 apple35_get_track_size(floppy_image_legacy *floppy, int head, int track)
+static uint32_t apple35_get_track_size(floppy_image_legacy *floppy, int head, int track)
{
if ((track < 0) || (track >= 80))
return 0;
@@ -592,9 +592,9 @@ static UINT32 apple35_get_track_size(floppy_image_legacy *floppy, int head, int
-static UINT8 calculate_side(int head, int track)
+static uint8_t calculate_side(int head, int track)
{
- UINT8 side;
+ uint8_t side;
side = head ? 0x20 : 0x00;
if (track & 0x40)
side |= 0x01;
@@ -603,16 +603,16 @@ static UINT8 calculate_side(int head, int track)
-static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
+static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, void *buffer, size_t buflen)
{
floperr_t err;
size_t pos = 0;
int sector_count, sector, i;
- UINT8 sum, side;
+ uint8_t sum, side;
struct apple35_tag *tag;
- UINT8 sector_data[524];
- UINT8 nibble_data[699];
- UINT8 checksum[4];
+ uint8_t sector_data[524];
+ uint8_t nibble_data[699];
+ uint8_t checksum[4];
tag = get_apple35_tag(floppy);
@@ -637,29 +637,29 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
sony_nibblize35(sector_data, nibble_data, checksum);
for (i = 0; i < ARRAY_LENGTH(blk1); i++)
- sony_filltrack((UINT8*)buffer, buflen, &pos, blk1[i]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, blk1[i]);
sum = (track ^ sector ^ side ^ tag->format_byte) & 0x3F;
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[track & 0x3f]);
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[sector]);
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[side]);
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[tag->format_byte]);
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[sum]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[track & 0x3f]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[sector]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[side]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[tag->format_byte]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[sum]);
for (i = 0; i < ARRAY_LENGTH(blk2); i++)
- sony_filltrack((UINT8*)buffer, buflen, &pos, blk2[i]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, blk2[i]);
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[sector]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[sector]);
for (i = 0; i < ARRAY_LENGTH(nibble_data); i++)
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[nibble_data[i]]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[nibble_data[i]]);
for (i = 3; i >= 0; i--)
- sony_filltrack((UINT8*)buffer, buflen, &pos, diskbytes[checksum[i]]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, diskbytes[checksum[i]]);
for (i = 0; i < ARRAY_LENGTH(blk3); i++)
- sony_filltrack((UINT8*)buffer, buflen, &pos, blk3[i]);
+ sony_filltrack((uint8_t*)buffer, buflen, &pos, blk3[i]);
}
return FLOPPY_ERROR_SUCCESS;
@@ -667,17 +667,17 @@ static floperr_t apple35_read_track(floppy_image_legacy *floppy, int head, int t
-static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen)
+static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, const void *buffer, size_t buflen)
{
floperr_t err;
size_t pos = 0;
int sector_count, sector, i, j;
struct apple35_tag *tag;
- UINT8 sum, format_byte, val, side;
- UINT32 found_sectors = 0;
- UINT8 sector_data[524];
- UINT8 nibble_data[699];
- UINT8 checksum[4];
+ uint8_t sum, format_byte, val, side;
+ uint32_t found_sectors = 0;
+ uint8_t sector_data[524];
+ uint8_t nibble_data[699];
+ uint8_t checksum[4];
tag = get_apple35_tag(floppy);
@@ -692,32 +692,32 @@ static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int
/* do 2 rotations, in case the bit slip stuff prevent us to read the first sector */
for (j = 0; j < (buflen * 2); j++)
{
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0xD5)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0xD5)
continue;
j++;
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0xAA)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0xAA)
continue;
j++;
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0x96)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0x96)
continue;
j++;
- if (rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)] != (track & 0x3F))
+ if (rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)] != (track & 0x3F))
continue;
j++;
- sector = rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)];
+ sector = rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)];
if ((sector < 0) || (sector >= sector_count))
continue;
j++;
- if (rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)] != side)
+ if (rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)] != side)
continue;
j++;
- format_byte = rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)];
+ format_byte = rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)];
if (format_byte != tag->format_byte)
{
/* this is an error, but not THAT critical, I guess */
@@ -725,52 +725,52 @@ static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int
j++;
sum = track ^ sector ^ side ^ format_byte;
- if (rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)] != sum)
+ if (rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)] != sum)
continue;
j++;
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0xDE)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0xDE)
continue;
j++;
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0xAA)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0xAA)
continue;
j++;
- while((val = sony_fetchtrack((UINT8*)buffer, buflen, &pos)) == 0xFF)
+ while((val = sony_fetchtrack((uint8_t*)buffer, buflen, &pos)) == 0xFF)
j++;
if (val != 0xD5)
continue; /* lost bit slip mark! */
j++;
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0xAA)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0xAA)
continue;
j++;
- if (sony_fetchtrack((UINT8*)buffer, buflen, &pos) != 0xAD)
+ if (sony_fetchtrack((uint8_t*)buffer, buflen, &pos) != 0xAD)
continue;
j++;
/* should this be regarded as a critical error ??? */
- if (rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)] != sector)
+ if (rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)] != sector)
continue;
j++;
for (i = 0; i < ARRAY_LENGTH(nibble_data); i++)
{
- nibble_data[i] = rev_diskbytes[sony_fetchtrack((UINT8*)buffer, buflen, &pos)];
+ nibble_data[i] = rev_diskbytes[sony_fetchtrack((uint8_t*)buffer, buflen, &pos)];
j++;
}
for (i = 3; i >= 0; i--)
{
/* should be checking checksum */
- sony_fetchtrack((UINT8*)buffer, buflen, &pos);
+ sony_fetchtrack((uint8_t*)buffer, buflen, &pos);
}
- sony_fetchtrack((UINT8*)buffer, buflen, &pos); /* should get 0xDE */
- sony_fetchtrack((UINT8*)buffer, buflen, &pos); /* should get 0xAA */
- sony_fetchtrack((UINT8*)buffer, buflen, &pos); /* should get 0xFF */
+ sony_fetchtrack((uint8_t*)buffer, buflen, &pos); /* should get 0xDE */
+ sony_fetchtrack((uint8_t*)buffer, buflen, &pos); /* should get 0xAA */
+ sony_fetchtrack((uint8_t*)buffer, buflen, &pos); /* should get 0xFF */
/* did we already write this sector? */
if ((found_sectors & (1 << sector)) == 0)
@@ -790,8 +790,8 @@ static floperr_t apple35_write_track(floppy_image_legacy *floppy, int head, int
-static floperr_t apple35_construct(floppy_image_legacy *floppy, UINT32 data_offset, UINT32 data_size,
- UINT32 tag_offset, UINT32 tag_size, INT16 format_byte, UINT8 sides, int is_1440k)
+static floperr_t apple35_construct(floppy_image_legacy *floppy, uint32_t data_offset, uint32_t data_size,
+ uint32_t tag_offset, uint32_t tag_size, int16_t format_byte, uint8_t sides, int is_1440k)
{
struct apple35_tag *tag;
struct FloppyCallbacks *format;
@@ -820,7 +820,7 @@ static floperr_t apple35_construct(floppy_image_legacy *floppy, UINT32 data_offs
tag->data_size = data_size;
tag->tag_offset = tag_offset;
tag->tag_size = tag_size;
- tag->format_byte = (UINT8) format_byte;
+ tag->format_byte = (uint8_t) format_byte;
tag->sides = sides;
tag->is_1440k = is_1440k ? 1 : 0;
@@ -843,7 +843,7 @@ static floperr_t apple35_construct(floppy_image_legacy *floppy, UINT32 data_offs
static FLOPPY_IDENTIFY(apple35_raw_identify)
{
- UINT64 size;
+ uint64_t size;
size = floppy_image_size(floppy);
*vote = ((size == 80*1*10*512) || (size == 80*2*10*512) || (size == (80*2*18*512)+84)
|| (size == 80*2*18*512)) ? 100 : 0;
@@ -855,8 +855,8 @@ static FLOPPY_IDENTIFY(apple35_raw_identify)
static FLOPPY_CONSTRUCT(apple35_raw_construct)
{
- UINT64 size;
- UINT8 sides;
+ uint64_t size;
+ uint8_t sides;
int is_1440k;
if (params)
@@ -884,7 +884,7 @@ static FLOPPY_CONSTRUCT(apple35_raw_construct)
return FLOPPY_ERROR_INVALIDIMAGE;
}
- return apple35_construct(floppy, 0, (UINT32) size, 0, 0, -1, sides, is_1440k);
+ return apple35_construct(floppy, 0, (uint32_t) size, 0, 0, -1, sides, is_1440k);
}
@@ -893,25 +893,25 @@ static FLOPPY_CONSTRUCT(apple35_raw_construct)
struct header_diskcopy
{
- UINT8 disk_name[64]; /* name of the disk */
- UINT32 data_size; /* total size of data for all sectors (512*number_of_sectors) */
- UINT32 tag_size; /* total size of tag data for all sectors (12*number_of_sectors for GCR 3.5" floppies, 20*number_of_sectors for HD20, 0 otherwise) */
- UINT32 data_checksum; /* CRC32 checksum of all sector data */
- UINT32 tag_checksum; /* CRC32 checksum of all tag data */
- UINT8 disk_format; /* 0 = 400K, 1 = 800K, 2 = 720K, 3 = 1440K (other values reserved) */
- UINT8 format_byte; /* should be $00 Apple II, $01 Lisa, $02 Mac MFS ??? */
+ uint8_t disk_name[64]; /* name of the disk */
+ uint32_t data_size; /* total size of data for all sectors (512*number_of_sectors) */
+ uint32_t tag_size; /* total size of tag data for all sectors (12*number_of_sectors for GCR 3.5" floppies, 20*number_of_sectors for HD20, 0 otherwise) */
+ uint32_t data_checksum; /* CRC32 checksum of all sector data */
+ uint32_t tag_checksum; /* CRC32 checksum of all tag data */
+ uint8_t disk_format; /* 0 = 400K, 1 = 800K, 2 = 720K, 3 = 1440K (other values reserved) */
+ uint8_t format_byte; /* should be $00 Apple II, $01 Lisa, $02 Mac MFS ??? */
/* $12 = 400K, $22 = >400K Macintosh (DiskCopy uses this value for
all Apple II disks not 800K in size, and even for some of those),
$24 = 800K Apple II disk */
- UINT16 magic; /* always $0100 (otherwise, the file may be in a different format. */
+ uint16_t magic; /* always $0100 (otherwise, the file may be in a different format. */
};
-static floperr_t apple35_diskcopy_headerdecode(floppy_image_legacy *floppy, UINT32 *data_offset,
- UINT32 *data_size, UINT32 *tag_offset, UINT32 *tag_size, UINT8 *format_byte, UINT8 *sides)
+static floperr_t apple35_diskcopy_headerdecode(floppy_image_legacy *floppy, uint32_t *data_offset,
+ uint32_t *data_size, uint32_t *tag_offset, uint32_t *tag_size, uint8_t *format_byte, uint8_t *sides)
{
- UINT64 size;
+ uint64_t size;
struct header_diskcopy header;
if (data_offset)
@@ -986,10 +986,10 @@ static FLOPPY_IDENTIFY(apple35_diskcopy_identify)
static FLOPPY_CONSTRUCT(apple35_diskcopy_construct)
{
floperr_t err;
- UINT8 format_byte, sides;
- UINT32 data_offset, data_size;
- UINT32 tag_offset, tag_size;
- INT16 format_byte_param = -1;
+ uint8_t format_byte, sides;
+ uint32_t data_offset, data_size;
+ uint32_t tag_offset, tag_size;
+ int16_t format_byte_param = -1;
struct header_diskcopy header;
if (params)
@@ -1030,18 +1030,18 @@ struct header_2img
{
char magic[4]; /* '2IMG' */
char creator[4]; /* signature; 'MESS' for MESS */
- UINT16 header_length;
- UINT16 version;
- UINT32 image_format;
- UINT32 flags;
- UINT32 block_count;
- UINT32 data_offset;
- UINT32 data_length;
- UINT32 comment_offset;
- UINT32 comment_length;
- UINT32 creator_offset;
- UINT32 creator_length;
- UINT32 padding[4];
+ uint16_t header_length;
+ uint16_t version;
+ uint32_t image_format;
+ uint32_t flags;
+ uint32_t block_count;
+ uint32_t data_offset;
+ uint32_t data_length;
+ uint32_t comment_offset;
+ uint32_t comment_length;
+ uint32_t creator_offset;
+ uint32_t creator_length;
+ uint32_t padding[4];
};
#define IMAGE_FORMAT_DO 0
@@ -1051,11 +1051,11 @@ struct header_2img
-static floperr_t apple35_2img_decode(floppy_image_legacy *floppy, UINT32 *image_format,
- UINT32 *data_offset, UINT32 *data_length)
+static floperr_t apple35_2img_decode(floppy_image_legacy *floppy, uint32_t *image_format,
+ uint32_t *data_offset, uint32_t *data_length)
{
struct header_2img header;
- UINT64 size;
+ uint64_t size;
if (image_format)
*image_format = 0;
@@ -1097,11 +1097,11 @@ static floperr_t apple35_2img_decode(floppy_image_legacy *floppy, UINT32 *image_
header.data_length = 0x0c8000;
}
- if ((((UINT64) header.data_offset) + header.data_length) > size)
+ if ((((uint64_t) header.data_offset) + header.data_length) > size)
return FLOPPY_ERROR_INVALIDIMAGE;
- if ((((UINT64) header.comment_offset) + header.comment_length) > size)
+ if ((((uint64_t) header.comment_offset) + header.comment_length) > size)
return FLOPPY_ERROR_INVALIDIMAGE;
- if ((((UINT64) header.creator_offset) + header.creator_length) > size)
+ if ((((uint64_t) header.creator_offset) + header.creator_length) > size)
return FLOPPY_ERROR_INVALIDIMAGE;
if ((header.image_format != IMAGE_FORMAT_DO) &&
(header.image_format != IMAGE_FORMAT_PO) &&
@@ -1130,10 +1130,10 @@ static FLOPPY_IDENTIFY(apple35_2img_identify)
static FLOPPY_CONSTRUCT(apple35_2img_construct)
{
floperr_t err;
- UINT32 image_format;
- UINT32 data_offset;
- UINT32 data_size;
- UINT8 sides = 2;
+ uint32_t image_format;
+ uint32_t data_offset;
+ uint32_t data_size;
+ uint8_t sides = 2;
struct header_2img header;
if (params)
@@ -1232,16 +1232,16 @@ bool dc42_format::supports_save() const
return true;
}
-int dc42_format::identify(io_generic *io, UINT32 form_factor)
+int dc42_format::identify(io_generic *io, uint32_t form_factor)
{
- UINT8 h[0x54];
- UINT64 size = io_generic_size(io);
+ uint8_t h[0x54];
+ uint64_t size = io_generic_size(io);
if(size < 0x54)
return 0;
io_generic_read(io, h, 0, 0x54);
- UINT32 dsize = (h[0x40] << 24) | (h[0x41] << 16) | (h[0x42] << 8) | h[0x43];
- UINT32 tsize = (h[0x44] << 24) | (h[0x45] << 16) | (h[0x46] << 8) | h[0x47];
+ uint32_t dsize = (h[0x40] << 24) | (h[0x41] << 16) | (h[0x42] << 8) | h[0x43];
+ uint32_t tsize = (h[0x44] << 24) | (h[0x45] << 16) | (h[0x46] << 8) | h[0x47];
return size == 0x54+tsize+dsize && h[0] < 64 && h[0x52] == 1 && h[0x53] == 0 ? 100 : 0;
}
@@ -1276,22 +1276,22 @@ const floppy_image_format_t::desc_e dc42_format::mac_gcr[] = {
};
-bool dc42_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
+bool dc42_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
{
- UINT8 h[0x54];
+ uint8_t h[0x54];
io_generic_read(io, h, 0, 0x54);
int dsize = (h[0x40] << 24) | (h[0x41] << 16) | (h[0x42] << 8) | h[0x43];
int tsize = (h[0x44] << 24) | (h[0x45] << 16) | (h[0x46] << 8) | h[0x47];
- UINT8 encoding = h[0x50];
- UINT8 format = h[0x51];
+ uint8_t encoding = h[0x50];
+ uint8_t format = h[0x51];
if((encoding != 0x00 || format != 0x02) && (encoding != 0x01 || format != 0x22)) {
osd_printf_error("dc42: Unsupported encoding/format combination %02x/%02x\n", encoding, format);
return false;
}
- UINT8 sector_data[(512+12)*12];
+ uint8_t sector_data[(512+12)*12];
memset(sector_data, 0, sizeof(sector_data));
desc_s sectors[12];
@@ -1306,7 +1306,7 @@ bool dc42_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
int ns = 12 - (track/16);
int si = 0;
for(int i=0; i<ns; i++) {
- UINT8 *data = sector_data + (512+12)*i;
+ uint8_t *data = sector_data + (512+12)*i;
sectors[si].data = data;
sectors[si].size = 512+12;
sectors[si].sector_id = i;
@@ -1327,9 +1327,9 @@ bool dc42_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
return true;
}
-UINT8 dc42_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
+uint8_t dc42_format::gb(const uint8_t *buf, int ts, int &pos, int &wrap)
{
- UINT8 v = 0;
+ uint8_t v = 0;
int w1 = wrap;
while(wrap != w1+2 && !(v & 0x80)) {
v = v << 1 | ((buf[pos >> 3] >> (7-(pos & 7))) & 1);
@@ -1342,7 +1342,7 @@ UINT8 dc42_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
return v;
}
-void dc42_format::update_chk(const UINT8 *data, int size, UINT32 &chk)
+void dc42_format::update_chk(const uint8_t *data, int size, uint32_t &chk)
{
for(int i=0; i<size; i+=2) {
chk += (data[i] << 8) | data[i+1];
@@ -1358,13 +1358,13 @@ bool dc42_format::save(io_generic *io, floppy_image *image)
if(g_heads == 0)
g_heads = 1;
- UINT8 h[0x54];
+ uint8_t h[0x54];
memset(h, 0, 0x54);
strcpy((char *)h+1, "Unnamed");
h[0] = 7;
int nsect = 16*(12+11+10+9+8)*g_heads;
- UINT32 dsize = nsect*512;
- UINT32 tsize = nsect*12;
+ uint32_t dsize = nsect*512;
+ uint32_t tsize = nsect*12;
h[0x40] = dsize >> 24;
h[0x41] = dsize >> 16;
h[0x42] = dsize >> 8;
@@ -1378,25 +1378,25 @@ bool dc42_format::save(io_generic *io, floppy_image *image)
h[0x52] = 0x01;
h[0x53] = 0x00;
- UINT32 dchk = 0;
- UINT32 tchk = 0;
+ uint32_t dchk = 0;
+ uint32_t tchk = 0;
int pos_data = 0x54;
int pos_tag = 0x54+dsize;
for(int track=0; track < 80; track++) {
for(int head=0; head < g_heads; head++) {
- UINT8 sectdata[(512+12)*12];
+ uint8_t sectdata[(512+12)*12];
memset(sectdata, 0, sizeof(sectdata));
int nsect = 12-(track/16);
- UINT8 buf[13000];
+ uint8_t buf[13000];
int ts;
generate_bitstream_from_track(track, head, 200000000/(6208*nsect), buf, ts, image);
int pos = 0;
int wrap = 0;
int hb = 0;
for(;;) {
- UINT8 v = gb(buf, ts, pos, wrap);
+ uint8_t v = gb(buf, ts, pos, wrap);
if(v == 0xff)
hb = 1;
else if(hb == 1 && v == 0xd5)
@@ -1409,18 +1409,18 @@ bool dc42_format::save(io_generic *io, floppy_image *image)
hb = 0;
if(hb == 4) {
- UINT8 h[7];
+ uint8_t h[7];
for(auto & elem : h)
elem = gb(buf, ts, pos, wrap);
- UINT8 v2 = gcr6bw_tb[h[2]];
- UINT8 v3 = gcr6bw_tb[h[3]];
- UINT8 tr = gcr6bw_tb[h[0]] | (v2 & 1 ? 0x40 : 0x00);
- UINT8 se = gcr6bw_tb[h[1]];
- UINT8 si = v2 & 0x20 ? 1 : 0;
- // UINT8 ds = v3 & 0x20 ? 1 : 0;
- // UINT8 fmt = v3 & 0x1f;
- UINT8 c1 = (tr^se^v2^v3) & 0x3f;
- UINT8 chk = gcr6bw_tb[h[4]];
+ uint8_t v2 = gcr6bw_tb[h[2]];
+ uint8_t v3 = gcr6bw_tb[h[3]];
+ uint8_t tr = gcr6bw_tb[h[0]] | (v2 & 1 ? 0x40 : 0x00);
+ uint8_t se = gcr6bw_tb[h[1]];
+ uint8_t si = v2 & 0x20 ? 1 : 0;
+ // uint8_t ds = v3 & 0x20 ? 1 : 0;
+ // uint8_t fmt = v3 & 0x1f;
+ uint8_t c1 = (tr^se^v2^v3) & 0x3f;
+ uint8_t chk = gcr6bw_tb[h[4]];
if(chk == c1 && tr == track && si == head && se < nsect) {
int opos = pos;
int owrap = wrap;
@@ -1439,15 +1439,15 @@ bool dc42_format::save(io_generic *io, floppy_image *image)
hb = 0;
}
if(hb == 4) {
- UINT8 *dest = sectdata+(512+12)*se;
+ uint8_t *dest = sectdata+(512+12)*se;
gb(buf, ts, pos, wrap); // Ignore the sector byte
- UINT8 ca = 0, cb = 0, cc = 0;
+ uint8_t ca = 0, cb = 0, cc = 0;
for(int i=0; i<522/3+1; i++) {
- UINT8 e0 = gb(buf, ts, pos, wrap);
- UINT8 e1 = gb(buf, ts, pos, wrap);
- UINT8 e2 = gb(buf, ts, pos, wrap);
- UINT8 e3 = i == 522/3 ? 0x96 : gb(buf, ts, pos, wrap);
- UINT8 va, vb, vc;
+ uint8_t e0 = gb(buf, ts, pos, wrap);
+ uint8_t e1 = gb(buf, ts, pos, wrap);
+ uint8_t e2 = gb(buf, ts, pos, wrap);
+ uint8_t e3 = i == 522/3 ? 0x96 : gb(buf, ts, pos, wrap);
+ uint8_t va, vb, vc;
gcr6_decode(e0, e1, e2, e3, va, vb, vc);
cc = (cc << 1) | (cc >> 7);
va = va ^ cc;
@@ -1474,7 +1474,7 @@ bool dc42_format::save(io_generic *io, floppy_image *image)
break;
}
for(int i=0; i<nsect; i++) {
- UINT8 *data = sectdata + (512+12)*i;
+ uint8_t *data = sectdata + (512+12)*i;
io_generic_write(io, data, pos_tag, 12);
io_generic_write(io, data+12, pos_data, 512);
pos_tag += 12;