summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/ap2_dsk.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/ap2_dsk.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/ap2_dsk.cpp')
-rw-r--r--src/lib/formats/ap2_dsk.cpp266
1 files changed, 133 insertions, 133 deletions
diff --git a/src/lib/formats/ap2_dsk.cpp b/src/lib/formats/ap2_dsk.cpp
index 774d4785735..6cba1db6757 100644
--- a/src/lib/formats/ap2_dsk.cpp
+++ b/src/lib/formats/ap2_dsk.cpp
@@ -22,25 +22,25 @@
/* used in for all Apple II images */
-static UINT32 apple2_get_track_size(floppy_image_legacy *floppy, int head, int track);
-static int disk_decode_nib(UINT8 *data, const UINT8 *nibble, int *volume, int *track, int *sector);
-static void disk_encode_nib(UINT8 *nibble, const UINT8 *data, int volume, int track, int sector);
+static uint32_t apple2_get_track_size(floppy_image_legacy *floppy, int head, int track);
+static int disk_decode_nib(uint8_t *data, const uint8_t *nibble, int *volume, int *track, int *sector);
+static void disk_encode_nib(uint8_t *nibble, const uint8_t *data, int volume, int track, int sector);
/* used in DOS/ProDOS order images */
static int apple2_do_translate_sector(floppy_image_legacy *floppy, int sector);
static int apple2_po_translate_sector(floppy_image_legacy *floppy, int sector);
-static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen);
-static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen);
+static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, void *buffer, size_t buflen);
+static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, const void *buffer, size_t buflen);
/* used in nibble order images */
-static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen);
-static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen);
+static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, void *buffer, size_t buflen);
+static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, const void *buffer, size_t buflen);
static floperr_t apple2_nib_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen);
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);
-static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length);
+static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, uint32_t *sector_length);
-static const UINT8 translate6[0x40] =
+static const uint8_t translate6[0x40] =
{
0x96, 0x97, 0x9a, 0x9b, 0x9d, 0x9e, 0x9f, 0xa6,
0xa7, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb2, 0xb3,
@@ -58,11 +58,11 @@ static const UINT8 translate6[0x40] =
* Utility code
* ----------------------------------------------------------------------- */
-static const UINT8 *get_untranslate6_map(void)
+static const uint8_t *get_untranslate6_map(void)
{
- static UINT8 map[256];
+ static uint8_t map[256];
static int map_inited = 0;
- UINT8 i;
+ uint8_t i;
if (!map_inited)
{
@@ -133,8 +133,8 @@ static floperr_t apple2_general_construct(floppy_image_legacy *floppy, int flopp
static FLOPPY_IDENTIFY(apple2_dsk_identify)
{
- UINT64 size;
- UINT64 expected_size;
+ uint64_t size;
+ uint64_t expected_size;
size = floppy_image_size(floppy);
expected_size = APPLE2_TRACK_COUNT * APPLE2_SECTOR_COUNT * APPLE2_SECTOR_SIZE;
@@ -154,7 +154,7 @@ static FLOPPY_IDENTIFY(apple2_dsk_identify)
static int apple2_do_translate_sector(floppy_image_legacy *floppy, int sector)
{
- static const UINT8 skewing[] =
+ static const uint8_t skewing[] =
{
/* DOS order (*.do) */
0x00, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04,
@@ -167,7 +167,7 @@ static int apple2_do_translate_sector(floppy_image_legacy *floppy, int sector)
static int apple2_po_translate_sector(floppy_image_legacy *floppy, int sector)
{
- static const UINT8 skewing[] =
+ static const uint8_t skewing[] =
{
/* ProDOS order (*.po) */
0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B,
@@ -192,11 +192,11 @@ static FLOPPY_CONSTRUCT(apple2_po_construct)
-static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
+static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, void *buffer, size_t buflen)
{
- UINT8 sector_buffer[APPLE2_SECTOR_SIZE];
+ uint8_t sector_buffer[APPLE2_SECTOR_SIZE];
int sector;
- UINT8 *nibble;
+ uint8_t *nibble;
if (buflen < APPLE2_NIBBLE_SIZE*APPLE2_SECTOR_COUNT)
return FLOPPY_ERROR_INTERNAL;
@@ -207,7 +207,7 @@ static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, in
for (sector = 0; sector < APPLE2_SECTOR_COUNT; sector++)
{
- nibble = (UINT8 *)buffer;
+ nibble = (uint8_t *)buffer;
nibble += sector * APPLE2_SMALL_NIBBLE_SIZE;
floppy_read_sector(floppy, head, track, sector, 0, sector_buffer, sizeof(sector_buffer));
@@ -218,18 +218,18 @@ static floperr_t apple2_dsk_read_track(floppy_image_legacy *floppy, int head, in
-static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen)
+static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, const void *buffer, size_t buflen)
{
int sector;
- UINT8 sector_buffer[APPLE2_SECTOR_SIZE];
- const UINT8 *nibble;
+ uint8_t sector_buffer[APPLE2_SECTOR_SIZE];
+ const uint8_t *nibble;
if (offset != 0)
return FLOPPY_ERROR_UNSUPPORTED;
for (sector = 0; sector < APPLE2_SECTOR_COUNT; sector++)
{
- nibble = (UINT8 *)buffer;
+ nibble = (uint8_t *)buffer;
nibble += sector * APPLE2_SMALL_NIBBLE_SIZE;
disk_decode_nib(sector_buffer, nibble, nullptr, nullptr, nullptr);
@@ -247,7 +247,7 @@ static floperr_t apple2_dsk_write_track(floppy_image_legacy *floppy, int head, i
static FLOPPY_IDENTIFY(apple2_nib_identify)
{
- UINT64 size;
+ uint64_t size;
size = floppy_image_size(floppy);
*vote = ((size == APPLE2_TRACK_COUNT * APPLE2_SECTOR_COUNT * APPLE2_NIBBLE_SIZE) || (size == (APPLE2_TRACK_COUNT + 1) * APPLE2_SECTOR_COUNT * APPLE2_NIBBLE_SIZE)) ? 100 : 0;
return FLOPPY_ERROR_SUCCESS;
@@ -262,7 +262,7 @@ static FLOPPY_CONSTRUCT(apple2_nib_construct)
-static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
+static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, void *buffer, size_t buflen)
{
if ((head != 0) || (track < 0) || (track > APPLE2_TRACK_COUNT))
return FLOPPY_ERROR_SEEKERROR;
@@ -274,7 +274,7 @@ static floperr_t apple2_nib_read_track(floppy_image_legacy *floppy, int head, in
-static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buflen)
+static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, int track, uint64_t offset, const void *buffer, size_t buflen)
{
if ((head != 0) || (track < 0) || (track > APPLE2_TRACK_COUNT))
return FLOPPY_ERROR_SEEKERROR;
@@ -290,7 +290,7 @@ static floperr_t apple2_nib_write_track(floppy_image_legacy *floppy, int head, i
* Track conversion
* ----------------------------------------------------------------------- */
-static int decode_nibbyte(UINT8 *nibint, const UINT8 *nibdata)
+static int decode_nibbyte(uint8_t *nibint, const uint8_t *nibdata)
{
if ((nibdata[0] & 0xAA) != 0xAA)
return 1;
@@ -304,16 +304,16 @@ static int decode_nibbyte(UINT8 *nibint, const UINT8 *nibdata)
-static int disk_decode_nib(UINT8 *data, const UINT8 *nibble, int *volume, int *track, int *sector)
+static int disk_decode_nib(uint8_t *data, const uint8_t *nibble, int *volume, int *track, int *sector)
{
- UINT8 read_volume;
- UINT8 read_track;
- UINT8 read_sector;
- UINT8 read_checksum;
+ uint8_t read_volume;
+ uint8_t read_track;
+ uint8_t read_sector;
+ uint8_t read_checksum;
int i;
- UINT8 b, xorvalue, newvalue;
+ uint8_t b, xorvalue, newvalue;
- const UINT8 *untranslate6 = get_untranslate6_map();
+ const uint8_t *untranslate6 = get_untranslate6_map();
/* pick apart the volume/track/sector info and checksum */
if (decode_nibbyte(&read_volume, &nibble[10]))
@@ -367,8 +367,8 @@ static int disk_decode_nib(UINT8 *data, const UINT8 *nibble, int *volume, int *t
static floperr_t apple2_nib_read_sector(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen)
{
floperr_t err;
- const UINT8 *nibble;
- UINT8 *track_data;
+ const uint8_t *nibble;
+ uint8_t *track_data;
void *track_data_v;
if ((sector < 0) || (sector >= APPLE2_SECTOR_COUNT))
@@ -379,11 +379,11 @@ static floperr_t apple2_nib_read_sector(floppy_image_legacy *floppy, int head, i
err = floppy_load_track(floppy, head, track, FALSE, &track_data_v, nullptr);
if (err)
return err;
- track_data = (UINT8 *) track_data_v;
+ track_data = (uint8_t *) track_data_v;
nibble = track_data + (sector * APPLE2_NIBBLE_SIZE);
- if (disk_decode_nib((UINT8 *)buffer, nibble, nullptr, nullptr, nullptr))
+ if (disk_decode_nib((uint8_t *)buffer, nibble, nullptr, nullptr, nullptr))
return FLOPPY_ERROR_INVALIDIMAGE;
return FLOPPY_ERROR_SUCCESS;
@@ -391,7 +391,7 @@ static floperr_t apple2_nib_read_sector(floppy_image_legacy *floppy, int head, i
-static void disk_encode_nib(UINT8 *nibble, const UINT8 *data, int volume, int track, int sector)
+static void disk_encode_nib(uint8_t *nibble, const uint8_t *data, int volume, int track, int sector)
{
int checksum, oldvalue, xorvalue, i;
@@ -457,7 +457,7 @@ static void disk_encode_nib(UINT8 *nibble, const UINT8 *data, int volume, int tr
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)
{
floperr_t err;
- UINT8 *track_data;
+ uint8_t *track_data;
void *track_data_v;
if ((sector < 0) || (sector >= APPLE2_SECTOR_COUNT))
@@ -468,15 +468,15 @@ static floperr_t apple2_nib_write_sector(floppy_image_legacy *floppy, int head,
err = floppy_load_track(floppy, head, track, TRUE, &track_data_v, nullptr);
if (err)
return err;
- track_data = (UINT8 *) track_data_v;
+ track_data = (uint8_t *) track_data_v;
- disk_encode_nib(track_data + sector * APPLE2_NIBBLE_SIZE, (const UINT8 *)buffer, 254, track, sector);
+ disk_encode_nib(track_data + sector * APPLE2_NIBBLE_SIZE, (const uint8_t *)buffer, 254, track, sector);
return FLOPPY_ERROR_SUCCESS;
}
-static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length)
+static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, uint32_t *sector_length)
{
*sector_length = APPLE2_SECTOR_SIZE;
return FLOPPY_ERROR_SUCCESS;
@@ -484,7 +484,7 @@ static floperr_t apple2_nib_get_sector_length(floppy_image_legacy *floppy, int h
-static UINT32 apple2_get_track_size(floppy_image_legacy *floppy, int head, int track)
+static uint32_t apple2_get_track_size(floppy_image_legacy *floppy, int head, int track)
{
return APPLE2_NIBBLE_SIZE * APPLE2_SECTOR_COUNT;
}
@@ -522,13 +522,13 @@ LEGACY_FLOPPY_OPTIONS_END
****************************************************************************/
-static const UINT8 dos_skewing[] =
+static const uint8_t dos_skewing[] =
{
0x00, 0x07, 0x0E, 0x06, 0x0D, 0x05, 0x0C, 0x04,
0x0B, 0x03, 0x0A, 0x02, 0x09, 0x01, 0x08, 0x0F
};
-static const UINT8 prodos_skewing[] =
+static const uint8_t prodos_skewing[] =
{
0x00, 0x08, 0x01, 0x09, 0x02, 0x0A, 0x03, 0x0B,
0x04, 0x0C, 0x05, 0x0D, 0x06, 0x0E, 0x07, 0x0F
@@ -559,10 +559,10 @@ bool a2_16sect_format::supports_save() const
return true;
}
-int a2_16sect_format::identify(io_generic *io, UINT32 form_factor)
+int a2_16sect_format::identify(io_generic *io, uint32_t form_factor)
{
- UINT64 size = io_generic_size(io);
- UINT32 expected_size = 35 * 16 * 256;
+ uint64_t size = io_generic_size(io);
+ uint32_t expected_size = 35 * 16 * 256;
// check standard size plus some oddball sizes in our softlist
if ((size == expected_size) || (size == 143403) || (size == 143363) || (size == 143358))
@@ -603,14 +603,14 @@ const floppy_image_format_t::desc_e a2_16sect_format::mac_gcr[] = {
{ END },
};
-bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
+bool a2_16sect_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
{
m_prodos_order = false;
int fpos = 0;
for(int track=0; track < 35; track++) {
- std::vector<UINT32> track_data;
- UINT8 sector_data[256*16];
+ std::vector<uint32_t> track_data;
+ uint8_t sector_data[256*16];
static const unsigned char pascal_block1[4] = { 0x08, 0xa5, 0x0f, 0x29 };
static const unsigned char pascal2_block1[4] = { 0xff, 0xa2, 0x00, 0x8e };
static const unsigned char dos33_block1[4] = { 0xa2, 0x02, 0x8e, 0x52 };
@@ -682,7 +682,7 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
sector = dos_skewing[i];
}
- const UINT8 *sdata = sector_data + 256 * sector;
+ const uint8_t *sdata = sector_data + 256 * sector;
for(int j=0; j<20; j++)
raw_w(track_data, 10, 0x3fc);
raw_w(track_data, 8, 0xff);
@@ -700,9 +700,9 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
raw_w(track_data, 24, 0xd5aaad);
raw_w(track_data, 1, 0);
- UINT8 pval = 0x00;
+ uint8_t pval = 0x00;
for(int i=0; i<342; i++) {
- UINT8 nval;
+ uint8_t nval;
if(i >= 0x56)
nval = sdata[i - 0x56] >> 2;
else {
@@ -730,9 +730,9 @@ bool a2_16sect_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
return true;
}
-UINT8 a2_16sect_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
+uint8_t a2_16sect_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);
@@ -745,7 +745,7 @@ UINT8 a2_16sect_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
return v;
}
-void a2_16sect_format::update_chk(const UINT8 *data, int size, UINT32 &chk)
+void a2_16sect_format::update_chk(const uint8_t *data, int size, uint32_t &chk)
{
}
@@ -786,10 +786,10 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
int pos_data = 0;
for(int track=0; track < 35; track++) {
- UINT8 sectdata[(256)*16];
+ uint8_t sectdata[(256)*16];
memset(sectdata, 0, sizeof(sectdata));
int nsect = 16;
- UINT8 buf[10000]; // normal is 51090 cells, e.g. 6387 bytes, add 50% and round up for denser than normal disks
+ uint8_t buf[10000]; // normal is 51090 cells, e.g. 6387 bytes, add 50% and round up for denser than normal disks
int ts;
#ifdef VERBOSE_SAVE
fprintf(stderr,"DEBUG: a2_16sect_format::save() about to generate bitstream from track %d...", track);
@@ -803,7 +803,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
int hb = 0;
int dosver = 0; // apple dos version; 0 = >=3.3, 1 = <3.3
for(;;) {
- UINT8 v = gb(buf, ts, pos, wrap);
+ uint8_t v = gb(buf, ts, pos, wrap);
if(v == 0xff) {
hb = 1;
}
@@ -821,16 +821,16 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
hb = 0;
if(hb == 4) {
- UINT8 h[11];
+ uint8_t h[11];
for(auto & elem : h)
elem = gb(buf, ts, pos, wrap);
- //UINT8 v2 = gcr6bw_tb[h[2]];
- UINT8 vl = gcr4_decode(h[0],h[1]);
- UINT8 tr = gcr4_decode(h[2],h[3]);
- UINT8 se = gcr4_decode(h[4],h[5]);
- UINT8 chk = gcr4_decode(h[6],h[7]);
+ //uint8_t v2 = gcr6bw_tb[h[2]];
+ uint8_t vl = gcr4_decode(h[0],h[1]);
+ uint8_t tr = gcr4_decode(h[2],h[3]);
+ uint8_t se = gcr4_decode(h[4],h[5]);
+ uint8_t chk = gcr4_decode(h[6],h[7]);
#ifdef VERBOSE_SAVE
- UINT32 post = (h[8]<<16)|(h[9]<<8)|h[10];
+ uint32_t post = (h[8]<<16)|(h[9]<<8)|h[10];
printf("Address Mark:\tVolume %d, Track %d, Sector %2d, Checksum %02X: %s, Postamble %03X: %s\n", vl, tr, se, chk, (chk ^ vl ^ tr ^ se)==0?"OK":"BAD", post, (post&0xFFFF00)==0xDEAA00?"OK":"BAD");
#endif
// sanity check
@@ -860,10 +860,10 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
}
if((hb == 4)&&(dosver == 0)) {
visualgrid[se][track] |= DATAFOUND;
- UINT8 *dest;
- UINT8 data[0x157];
- UINT32 dpost = 0;
- UINT8 c = 0;
+ uint8_t *dest;
+ uint8_t data[0x157];
+ uint32_t dpost = 0;
+ uint8_t c = 0;
if (m_prodos_order)
{
@@ -889,7 +889,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
dpost |= gb(buf, ts, pos, wrap);
}
// next combine in the upper 2 bits of each byte
- UINT8 bit_swap[4] = { 0, 2, 1, 3 };
+ uint8_t bit_swap[4] = { 0, 2, 1, 3 };
for(int i=0; i<0x56; i++)
data[i+0x056] = data[i+0x056]<<2 | bit_swap[data[i]&3];
for(int i=0; i<0x56; i++)
@@ -913,7 +913,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
(((data[0x156] != c) && (dpost&0xFFFF00)!=0xDEAA00) && (((visualgrid[se][track]&DATAGOOD)==0)&&(visualgrid[se][track]&DATAPOST)==0))
) {
for(int i=0x56; i<0x156; i++) {
- UINT8 dv = data[i];
+ uint8_t dv = data[i];
*dest++ = dv;
}
}
@@ -921,7 +921,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
#else
if ((visualgrid[se][track]&DATAGOOD)==0) {
for(int i=0x56; i<0x156; i++) {
- UINT8 dv = data[i];
+ uint8_t dv = data[i];
*dest++ = dv;
}
}
@@ -948,7 +948,7 @@ bool a2_16sect_format::save(io_generic *io, floppy_image *image)
}
for(int i=0; i<nsect; i++) {
//if(nsect>0) printf("t%d,", track);
- UINT8 *data = sectdata + (256)*i;
+ uint8_t *data = sectdata + (256)*i;
io_generic_write(io, data, pos_data, 256);
pos_data += 256;
}
@@ -1029,10 +1029,10 @@ bool a2_rwts18_format::supports_save() const
return true;
}
-int a2_rwts18_format::identify(io_generic *io, UINT32 form_factor)
+int a2_rwts18_format::identify(io_generic *io, uint32_t form_factor)
{
- UINT64 size = io_generic_size(io);
- UINT32 expected_size = 35 * 16 * 256;
+ uint64_t size = io_generic_size(io);
+ uint32_t expected_size = 35 * 16 * 256;
return size == expected_size;
}
@@ -1067,10 +1067,10 @@ const floppy_image_format_t::desc_e a2_rwts18_format::mac_gcr[] = {
};
-bool a2_rwts18_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
+bool a2_rwts18_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
{
/* TODO: rewrite me properly
- UINT8 sector_data[(256)*16];
+ uint8_t sector_data[(256)*16];
memset(sector_data, 0, sizeof(sector_data));
desc_s sectors[16];
@@ -1082,7 +1082,7 @@ bool a2_rwts18_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
for(int track=0; track < 35; track++) {
for(int head=0; head < head_count; head++) {
for(int si=0; si<16; si++) {
- UINT8 *data = sector_data + (256)*si;
+ uint8_t *data = sector_data + (256)*si;
sectors[si].data = data;
sectors[si].size = 256;
sectors[si].sector_id = si;
@@ -1097,9 +1097,9 @@ bool a2_rwts18_format::load(io_generic *io, UINT32 form_factor, floppy_image *im
return false; // I hope that throws an error...
}
-UINT8 a2_rwts18_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
+uint8_t a2_rwts18_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);
@@ -1112,7 +1112,7 @@ UINT8 a2_rwts18_format::gb(const UINT8 *buf, int ts, int &pos, int &wrap)
return v;
}
-void a2_rwts18_format::update_chk(const UINT8 *data, int size, UINT32 &chk)
+void a2_rwts18_format::update_chk(const uint8_t *data, int size, uint32_t &chk)
{
}
@@ -1152,10 +1152,10 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
int pos_data = 0;
// for track 0 ONLY:
- UINT8 sectdata[(768)*6];
+ uint8_t sectdata[(768)*6];
memset(sectdata, 0, sizeof(sectdata));
int nsect = 18;
- UINT8 buf[130000]; // originally 13000, multiread dfi disks need larger
+ uint8_t buf[130000]; // originally 13000, multiread dfi disks need larger
int ts;
//fprintf(stderr,"DEBUG: a2_rwts18_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2);
//~332 samples per cell, times 3+8+3 (14) for address mark, 24 for sync, 3+343+3 (349) for data mark, 24 for sync is around 743, near 776 expected
@@ -1166,7 +1166,7 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
int hb = 0;
int dosver = 0; // apple dos version; 0 = >=3.3, 1 = <3.3
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)
@@ -1181,15 +1181,15 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
hb = 0;
if(hb == 4) {
- UINT8 h[11];
+ uint8_t h[11];
for(auto & elem : h)
elem = gb(buf, ts, pos, wrap);
- //UINT8 v2 = gcr6bw_tb[h[2]];
- UINT8 vl = gcr4_decode(h[0],h[1]);
- UINT8 tr = gcr4_decode(h[2],h[3]);
- UINT8 se = gcr4_decode(h[4],h[5]);
- UINT8 chk = gcr4_decode(h[6],h[7]);
- UINT32 post = (h[8]<<16)|(h[9]<<8)|h[10];
+ //uint8_t v2 = gcr6bw_tb[h[2]];
+ uint8_t vl = gcr4_decode(h[0],h[1]);
+ uint8_t tr = gcr4_decode(h[2],h[3]);
+ uint8_t se = gcr4_decode(h[4],h[5]);
+ uint8_t chk = gcr4_decode(h[6],h[7]);
+ uint32_t post = (h[8]<<16)|(h[9]<<8)|h[10];
printf("Address Mark:\tVolume %d, Track %d, Sector %2d, Checksum %02X: %s, Postamble %03X: %s\n", vl, tr, se, chk, (chk ^ vl ^ tr ^ se)==0?"OK":"BAD", post, (post&0xFFFF00)==0xDEAA00?"OK":"BAD");
// sanity check
if (tr == 0 && se < nsect) {
@@ -1233,10 +1233,10 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
0x04, 0x0C, 0x05, 0x0D, 0x06, 0x0E, 0x07, 0x0F
#endif
};
- UINT8 *dest = sectdata+(256)*sector_translate[se];
- UINT8 data[0x157];
- UINT32 dpost = 0;
- UINT8 c = 0;
+ uint8_t *dest = sectdata+(256)*sector_translate[se];
+ uint8_t data[0x157];
+ uint32_t dpost = 0;
+ uint8_t c = 0;
// first read in sector and decode to 6bit form
for(int i=0; i<0x156; i++) {
data[i] = gcr6bw_tb[gb(buf, ts, pos, wrap)] ^ c;
@@ -1252,7 +1252,7 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
dpost |= gb(buf, ts, pos, wrap);
}
// next combine in the upper 2 bits of each byte
- UINT8 bit_swap[4] = { 0, 2, 1, 3 };
+ uint8_t bit_swap[4] = { 0, 2, 1, 3 };
for(int i=0; i<0x56; i++)
data[i+0x056] = data[i+0x056]<<2 | bit_swap[data[i]&3];
for(int i=0; i<0x56; i++)
@@ -1276,7 +1276,7 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
(((data[0x156] != c) && (dpost&0xFFFF00)!=0xDEAA00) && (((visualgrid[se][0]&DATAGOOD)==0)&&(visualgrid[se][0]&DATAPOST)==0))
) {
for(int i=0x56; i<0x156; i++) {
- UINT8 dv = data[i];
+ uint8_t dv = data[i];
*dest++ = dv;
}
}
@@ -1284,7 +1284,7 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
#else
if ((visualgrid[se][0]&DATAGOOD)==0) {
for(int i=0x56; i<0x156; i++) {
- UINT8 dv = data[i];
+ uint8_t dv = data[i];
*dest++ = dv;
}
}
@@ -1309,17 +1309,17 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
}
for(int i=0; i<nsect; i++) {
//if(nsect>0) printf("t%d,", track);
- UINT8 *data = sectdata + (256)*i;
+ uint8_t *data = sectdata + (256)*i;
io_generic_write(io, data, pos_data, 256);
pos_data += 256;
}
// for the rest of the tracks
for(int track=2; track < 70; track+=2) {
- UINT8 sectdata[(768)*6];
+ uint8_t sectdata[(768)*6];
memset(sectdata, 0, sizeof(sectdata));
int nsect = 18;
- UINT8 buf[130000]; // originally 13000, multiread dfi disks need larger
+ uint8_t buf[130000]; // originally 13000, multiread dfi disks need larger
int ts;
//fprintf(stderr,"DEBUG: a2_rwts18_format::save() about to generate bitstream from physical track %d (logical %d)...", track, track/2);
//~332 samples per cell, times 3+8+3 (14) for address mark, 24 for sync, 3+343+3 (349) for data mark, 24 for sync is around 743, near 776 expected
@@ -1330,7 +1330,7 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
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) || (v == 0x9a)) // note 0x9a varies per title! this is an LFSR? generated value intended to throw off copiers, and only appears after the track splice (before sector 5)
hb = 1;
else if(hb == 1 && v == 0xd5)
@@ -1343,15 +1343,15 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
if(hb == 3) {
printf("AM at offset: %d, relative: %d\n", pos, pos-oldpos);
oldpos=pos;
- UINT8 h[7];
+ uint8_t h[7];
// grab exactly 7 bytes: should be Track, Sector, Checksum, AA, FF and FF and the Br0derbund Title ID
for(auto & elem : h)
elem = gb(buf, ts, pos, wrap);
- UINT8 tr = gcr6bw_tb[h[0]];
- UINT8 se = gcr6bw_tb[h[1]];
- UINT8 chk = gcr6bw_tb[h[2]];
- UINT32 post = (h[3]<<16)|(h[4]<<8)|h[5];
- UINT8 bbundid = h[6];
+ uint8_t tr = gcr6bw_tb[h[0]];
+ uint8_t se = gcr6bw_tb[h[1]];
+ uint8_t chk = gcr6bw_tb[h[2]];
+ uint32_t post = (h[3]<<16)|(h[4]<<8)|h[5];
+ uint8_t bbundid = h[6];
printf("RWTS18 AM:\t Track %d, Sector %2d, Checksum %02X: %s, Postamble %03X: %s, BBUNDID %02x\n", tr, se, chk, (chk ^ tr ^ se)==0?"OK":"BAD", post, post==0xAAFFFF?"OK":"BAD", bbundid);
// sanity check
if (tr == track/2 && se < nsect) {
@@ -1366,10 +1366,10 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
//int owrap = wrap;
// RWTS18 doesn't have a true data mark, its part of the address header
visualgrid[se][track/2] |= DATAFOUND;
- UINT8 *dest = sectdata+(256)*se;
- UINT8 data[0x401];
- UINT32 dpost = 0;
- UINT8 c = 0;
+ uint8_t *dest = sectdata+(256)*se;
+ uint8_t data[0x401];
+ uint32_t dpost = 0;
+ uint8_t c = 0;
//dest = sectdata+(768)*se;
// now read in the sector and decode to 6bit form
for(int i=0; i<0x400; i++) {
@@ -1429,21 +1429,21 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
data[(4*i)+1] |= (data[4*i]&0x30)<<2;
//printf("%c", (data[4*i]&0x3F)+0x40);
//if (((i&0xf)+1)==0x10) printf("\n");
- UINT8 dv = data[(4*i)+1];
+ uint8_t dv = data[(4*i)+1];
*dest++ = dv;
}
// second sector:
dest = sectdata+(256)*(se+6);
for(int i=0; i<0x100; i++) {
data[(4*i)+2] |= (data[4*i]&0x0c)<<4;
- UINT8 dv = data[(4*i)+2];
+ uint8_t dv = data[(4*i)+2];
*dest++ = dv;
}
// third sector:
dest = sectdata+(256)*(se+12);
for(int i=0; i<0x100; i++) {
data[(4*i)+3] |= (data[4*i]&0x03)<<6;
- UINT8 dv = data[(4*i)+3];
+ uint8_t dv = data[(4*i)+3];
*dest++ = dv;
}
}
@@ -1459,21 +1459,21 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
data[(4*i)+1] |= (data[4*i]&0x30)<<2;
//printf("%c", (data[4*i]&0x3F)+0x40);
//if (((i&0xf)+1)==0x10) printf("\n");
- UINT8 dv = data[(4*i)+1];
+ uint8_t dv = data[(4*i)+1];
*dest++ = dv;
}
// second sector:
dest = sectdata+(256)*(se+6);
for(int i=0; i<0x100; i++) {
data[(4*i)+2] |= (data[4*i]&0x0c)<<4;
- UINT8 dv = data[(4*i)+2];
+ uint8_t dv = data[(4*i)+2];
*dest++ = dv;
}
// third sector:
dest = sectdata+(256)*(se+12);
for(int i=0; i<0x100; i++) {
data[(4*i)+3] |= (data[4*i]&0x03)<<6;
- UINT8 dv = data[(4*i)+3];
+ uint8_t dv = data[(4*i)+3];
*dest++ = dv;
}
}
@@ -1492,7 +1492,7 @@ bool a2_rwts18_format::save(io_generic *io, floppy_image *image)
}
for(int i=0; i<nsect; i++) {
//if(nsect>0) printf("t%d,", track);
- UINT8 *data = sectdata + (256)*i;
+ uint8_t *data = sectdata + (256)*i;
io_generic_write(io, data, pos_data, 256);
pos_data += 256;
}
@@ -1545,23 +1545,23 @@ bool a2_edd_format::supports_save() const
return true;
}
-int a2_edd_format::identify(io_generic *io, UINT32 form_factor)
+int a2_edd_format::identify(io_generic *io, uint32_t form_factor)
{
return ((io_generic_size(io) == 2244608) || (io_generic_size(io) == 2310144)) ? 50 : 0;
}
-UINT8 a2_edd_format::pick(const UINT8 *data, int pos)
+uint8_t a2_edd_format::pick(const uint8_t *data, int pos)
{
return ((data[pos>>3] << 8) | data[(pos>>3)+1]) >> (8-(pos & 7));
}
-bool a2_edd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image)
+bool a2_edd_format::load(io_generic *io, uint32_t form_factor, floppy_image *image)
{
- UINT8 *img;
- UINT8 nibble[16384], stream[16384];
+ uint8_t *img;
+ uint8_t nibble[16384], stream[16384];
int npos[16384];
- img = (UINT8 *) malloc(2244608);
+ img = (uint8_t *) malloc(2244608);
if (!img)
{
@@ -1571,11 +1571,11 @@ bool a2_edd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image
io_generic_read(io, img, 0, 2244608);
for(int i=0; i<137; i++) {
- const UINT8 *trk = img + 16384*i;
+ const uint8_t *trk = img + 16384*i;
int pos = 0;
int wpos = 0;
while(pos < 16383*8) {
- UINT8 acc = pick(trk, pos);
+ uint8_t acc = pick(trk, pos);
pos += 8;
while(!(acc & 0x80) && pos < 16384*8) {
acc <<= 1;
@@ -1633,7 +1633,7 @@ bool a2_edd_format::load(io_generic *io, UINT32 form_factor, floppy_image *image
stream[splice >> 3] ^= 0x80 >> (splice & 7);
generate_track_from_bitstream(i >> 2, 0, stream, len, image, i & 3);
- image->set_write_splice_position(i >> 2, 0, UINT32(U64(200000000)*splice/len), i & 3);
+ image->set_write_splice_position(i >> 2, 0, uint32_t(U64(200000000)*splice/len), i & 3);
}
free(img);
return true;