diff options
Diffstat (limited to 'src/lib/formats/flopimg.cpp')
-rw-r--r-- | src/lib/formats/flopimg.cpp | 294 |
1 files changed, 147 insertions, 147 deletions
diff --git a/src/lib/formats/flopimg.cpp b/src/lib/formats/flopimg.cpp index 72786f6422e..c924050ac08 100644 --- a/src/lib/formats/flopimg.cpp +++ b/src/lib/formats/flopimg.cpp @@ -36,10 +36,10 @@ struct floppy_image_legacy /* loaded track stuff */ int loaded_track_head; int loaded_track_index; - UINT32 loaded_track_size; + uint32_t loaded_track_size; void *loaded_track_data; - UINT8 loaded_track_status; - UINT8 flags; + uint8_t loaded_track_status; + uint8_t flags; /* tagging system */ object_pool *tags; @@ -89,7 +89,7 @@ static floppy_image_legacy *floppy_init(void *fp, const struct io_procs *procs, floppy->io.file = fp; floppy->io.procs = procs; floppy->io.filler = 0xFF; - floppy->flags = (UINT8) flags; + floppy->flags = (uint8_t) flags; return floppy; } @@ -337,14 +337,14 @@ void *floppy_create_tag(floppy_image_legacy *floppy, size_t tagsize) -UINT8 floppy_get_filler(floppy_image_legacy *floppy) +uint8_t floppy_get_filler(floppy_image_legacy *floppy) { return floppy->io.filler; } -void floppy_set_filler(floppy_image_legacy *floppy, UINT8 filler) +void floppy_set_filler(floppy_image_legacy *floppy, uint8_t filler) { floppy->io.filler = filler; } @@ -355,28 +355,28 @@ void floppy_set_filler(floppy_image_legacy *floppy, UINT8 filler) calls for accessing the raw disk image *********************************************************************/ -void floppy_image_read(floppy_image_legacy *floppy, void *buffer, UINT64 offset, size_t length) +void floppy_image_read(floppy_image_legacy *floppy, void *buffer, uint64_t offset, size_t length) { io_generic_read(&floppy->io, buffer, offset, length); } -void floppy_image_write(floppy_image_legacy *floppy, const void *buffer, UINT64 offset, size_t length) +void floppy_image_write(floppy_image_legacy *floppy, const void *buffer, uint64_t offset, size_t length) { io_generic_write(&floppy->io, buffer, offset, length); } -void floppy_image_write_filler(floppy_image_legacy *floppy, UINT8 filler, UINT64 offset, size_t length) +void floppy_image_write_filler(floppy_image_legacy *floppy, uint8_t filler, uint64_t offset, size_t length) { io_generic_write_filler(&floppy->io, filler, offset, length); } -UINT64 floppy_image_size(floppy_image_legacy *floppy) +uint64_t floppy_image_size(floppy_image_legacy *floppy) { return io_generic_size(&floppy->io); } @@ -393,9 +393,9 @@ static floperr_t floppy_readwrite_sector(floppy_image_legacy *floppy, int head, floperr_t err; const struct FloppyCallbacks *fmt; size_t this_buffer_len; - std::vector<UINT8> alloc_buf; - UINT32 sector_length; - UINT8 *buffer_ptr = (UINT8 *)buffer; + std::vector<uint8_t> alloc_buf; + uint32_t sector_length; + uint8_t *buffer_ptr = (uint8_t *)buffer; floperr_t (*read_sector)(floppy_image_legacy *floppy, int head, int track, int sector, void *buffer, size_t buflen); floperr_t (*write_sector)(floppy_image_legacy *floppy, int head, int track, int sector, const void *buffer, size_t buflen, int ddam); @@ -532,7 +532,7 @@ floperr_t floppy_write_indexed_sector(floppy_image_legacy *floppy, int head, int } -static floperr_t floppy_get_track_data_offset(floppy_image_legacy *floppy, int head, int track, UINT64 *offset) +static floperr_t floppy_get_track_data_offset(floppy_image_legacy *floppy, int head, int track, uint64_t *offset) { floperr_t err; const struct FloppyCallbacks *callbacks; @@ -550,7 +550,7 @@ static floperr_t floppy_get_track_data_offset(floppy_image_legacy *floppy, int h -static floperr_t floppy_read_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 offset, void *buffer, size_t buffer_len) +static floperr_t floppy_read_track_offset(floppy_image_legacy *floppy, int head, int track, uint64_t offset, void *buffer, size_t buffer_len) { floperr_t err; const struct FloppyCallbacks *format; @@ -583,7 +583,7 @@ floperr_t floppy_read_track(floppy_image_legacy *floppy, int head, int track, vo floperr_t floppy_read_track_data(floppy_image_legacy *floppy, int head, int track, void *buffer, size_t buffer_len) { floperr_t err; - UINT64 offset; + uint64_t offset; err = floppy_get_track_data_offset(floppy, head, track, &offset); if (err) @@ -594,7 +594,7 @@ floperr_t floppy_read_track_data(floppy_image_legacy *floppy, int head, int trac -static floperr_t floppy_write_track_offset(floppy_image_legacy *floppy, int head, int track, UINT64 offset, const void *buffer, size_t buffer_len) +static floperr_t floppy_write_track_offset(floppy_image_legacy *floppy, int head, int track, uint64_t offset, const void *buffer, size_t buffer_len) { floperr_t err; @@ -629,7 +629,7 @@ floperr_t floppy_write_track(floppy_image_legacy *floppy, int head, int track, c floperr_t floppy_write_track_data(floppy_image_legacy *floppy, int head, int track, const void *buffer, size_t buffer_len) { floperr_t err; - UINT64 offset; + uint64_t offset; err = floppy_get_track_data_offset(floppy, head, track, &offset); if (err) @@ -690,7 +690,7 @@ int floppy_get_heads_per_disk(floppy_image_legacy *floppy) -UINT32 floppy_get_track_size(floppy_image_legacy *floppy, int head, int track) +uint32_t floppy_get_track_size(floppy_image_legacy *floppy, int head, int track) { const struct FloppyCallbacks *fmt; @@ -703,7 +703,7 @@ UINT32 floppy_get_track_size(floppy_image_legacy *floppy, int head, int track) -floperr_t floppy_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, UINT32 *sector_length) +floperr_t floppy_get_sector_length(floppy_image_legacy *floppy, int head, int track, int sector, uint32_t *sector_length) { const struct FloppyCallbacks *fmt; @@ -716,7 +716,7 @@ floperr_t floppy_get_sector_length(floppy_image_legacy *floppy, int head, int tr -floperr_t floppy_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags) +floperr_t floppy_get_indexed_sector_info(floppy_image_legacy *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, uint32_t *sector_length, unsigned long *flags) { const struct FloppyCallbacks *fmt; @@ -758,7 +758,7 @@ int floppy_is_read_only(floppy_image_legacy *floppy) -UINT8 floppy_random_byte(floppy_image_legacy *floppy) +uint8_t floppy_random_byte(floppy_image_legacy *floppy) { /* can't use mame_rand(); this might not be in the core */ #ifdef rand @@ -777,7 +777,7 @@ floperr_t floppy_load_track(floppy_image_legacy *floppy, int head, int track, in { floperr_t err; void *new_loaded_track_data; - UINT32 track_size; + uint32_t track_size; /* have we already loaded this track? */ if (((floppy->loaded_track_status & TRACK_LOADED) == 0) || (head != floppy->loaded_track_head) || (track != floppy->loaded_track_index)) @@ -892,7 +892,7 @@ LEGACY_FLOPPY_OPTIONS_END ****************************************************************************/ -floppy_image::floppy_image(int _tracks, int _heads, UINT32 _form_factor) +floppy_image::floppy_image(int _tracks, int _heads, uint32_t _form_factor) { tracks = _tracks; heads = _heads; @@ -952,7 +952,7 @@ int floppy_image::get_resolution() const return 0; } -const char *floppy_image::get_variant_name(UINT32 form_factor, UINT32 variant) +const char *floppy_image::get_variant_name(uint32_t form_factor, uint32_t variant) { switch(variant) { case SSSD: return "Single side, single density"; @@ -1105,42 +1105,42 @@ int floppy_image_format_t::crc_cells_size(int type) const } } -bool floppy_image_format_t::bit_r(const std::vector<UINT32> &buffer, int offset) +bool floppy_image_format_t::bit_r(const std::vector<uint32_t> &buffer, int offset) { return (buffer[offset] & floppy_image::MG_MASK) == MG_1; } -UINT32 floppy_image_format_t::bitn_r(const std::vector<UINT32> &buffer, int offset, int count) +uint32_t floppy_image_format_t::bitn_r(const std::vector<uint32_t> &buffer, int offset, int count) { - UINT32 r = 0; + uint32_t r = 0; for(int i=0; i<count; i++) - r = (r << 1) | (UINT32) bit_r(buffer, offset+i); + r = (r << 1) | (uint32_t) bit_r(buffer, offset+i); return r; } -void floppy_image_format_t::bit_w(std::vector<UINT32> &buffer, bool val, UINT32 size, int offset) +void floppy_image_format_t::bit_w(std::vector<uint32_t> &buffer, bool val, uint32_t size, int offset) { buffer[offset] = (val ? MG_1 : MG_0) | size; } -void floppy_image_format_t::bit_w(std::vector<UINT32> &buffer, bool val, UINT32 size) +void floppy_image_format_t::bit_w(std::vector<uint32_t> &buffer, bool val, uint32_t size) { buffer.push_back((val ? MG_1 : MG_0) | size); } -void floppy_image_format_t::raw_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) +void floppy_image_format_t::raw_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size) { for(int i=n-1; i>=0; i--) bit_w(buffer, (val >> i) & 1, size); } -void floppy_image_format_t::raw_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset) +void floppy_image_format_t::raw_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size, int offset) { for(int i=n-1; i>=0; i--) bit_w(buffer, (val >> i) & 1, size, offset++); } -void floppy_image_format_t::mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) +void floppy_image_format_t::mfm_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size) { int prec = buffer.empty() ? 0 : bit_r(buffer, buffer.size()-1); for(int i=n-1; i>=0; i--) { @@ -1151,7 +1151,7 @@ void floppy_image_format_t::mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val } } -void floppy_image_format_t::mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset) +void floppy_image_format_t::mfm_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size, int offset) { int prec = offset ? bit_r(buffer, offset-1) : 0; for(int i=n-1; i>=0; i--) { @@ -1162,7 +1162,7 @@ void floppy_image_format_t::mfm_w(std::vector<UINT32> &buffer, int n, UINT32 val } } -void floppy_image_format_t::fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) +void floppy_image_format_t::fm_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size) { for(int i=n-1; i>=0; i--) { int bit = (val >> i) & 1; @@ -1171,7 +1171,7 @@ void floppy_image_format_t::fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, } } -void floppy_image_format_t::fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size, int offset) +void floppy_image_format_t::fm_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size, int offset) { for(int i=n-1; i>=0; i--) { int bit = (val >> i) & 1; @@ -1180,7 +1180,7 @@ void floppy_image_format_t::fm_w(std::vector<UINT32> &buffer, int n, UINT32 val, } } -void floppy_image_format_t::mfm_half_w(std::vector<UINT32> &buffer, int start_bit, UINT32 val, UINT32 size) +void floppy_image_format_t::mfm_half_w(std::vector<uint32_t> &buffer, int start_bit, uint32_t val, uint32_t size) { int prec = buffer.empty() ? 0 : bit_r(buffer, buffer.size()-1); for(int i=start_bit; i>=0; i-=2) { @@ -1191,23 +1191,23 @@ void floppy_image_format_t::mfm_half_w(std::vector<UINT32> &buffer, int start_bi } } -void floppy_image_format_t::gcr5_w(std::vector<UINT32> &buffer, UINT8 val, UINT32 size) +void floppy_image_format_t::gcr5_w(std::vector<uint32_t> &buffer, uint8_t val, uint32_t size) { - UINT32 e0 = gcr5fw_tb[val >> 4]; - UINT32 e1 = gcr5fw_tb[val & 0x0f]; + uint32_t e0 = gcr5fw_tb[val >> 4]; + uint32_t e1 = gcr5fw_tb[val & 0x0f]; raw_w(buffer, 5, e0, size); raw_w(buffer, 5, e1, size); } -void floppy_image_format_t::gcr5_w(std::vector<UINT32> &buffer, UINT8 val, UINT32 size, int offset) +void floppy_image_format_t::gcr5_w(std::vector<uint32_t> &buffer, uint8_t val, uint32_t size, int offset) { - UINT32 e0 = gcr5fw_tb[val >> 4]; - UINT32 e1 = gcr5fw_tb[val & 0x0f]; + uint32_t e0 = gcr5fw_tb[val >> 4]; + uint32_t e1 = gcr5fw_tb[val & 0x0f]; raw_w(buffer, 5, e0, size, offset); raw_w(buffer, 5, e1, size, offset+5); } -void floppy_image_format_t::_8n1_w(std::vector<UINT32> &buffer, int n, UINT32 val, UINT32 size) +void floppy_image_format_t::_8n1_w(std::vector<uint32_t> &buffer, int n, uint32_t val, uint32_t size) { bit_w(buffer, 0, size); for(int i=n-1; i>=0; i--) { @@ -1217,9 +1217,9 @@ void floppy_image_format_t::_8n1_w(std::vector<UINT32> &buffer, int n, UINT32 va bit_w(buffer, 1, size); } -void floppy_image_format_t::fixup_crc_amiga(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_amiga(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { - UINT16 res = 0; + uint16_t res = 0; int size = crc->end - crc->start; for(int i=1; i<size; i+=2) if(bit_r(buffer, crc->start + i)) @@ -1228,9 +1228,9 @@ void floppy_image_format_t::fixup_crc_amiga(std::vector<UINT32> &buffer, const g mfm_w(buffer, 16, res, 1000, crc->write+32); } -void floppy_image_format_t::fixup_crc_cbm(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_cbm(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { - UINT8 v = 0; + uint8_t v = 0; for(int o = crc->start; o < crc->end; o+=10) { v = v ^ (gcr5bw_tb[bitn_r(buffer, o, 5)] << 4); v = v ^ gcr5bw_tb[bitn_r(buffer, o+5, 5)]; @@ -1238,9 +1238,9 @@ void floppy_image_format_t::fixup_crc_cbm(std::vector<UINT32> &buffer, const gen gcr5_w(buffer, v, 1000, crc->write); } -UINT16 floppy_image_format_t::calc_crc_ccitt(const std::vector<UINT32> &buffer, int start, int end) +uint16_t floppy_image_format_t::calc_crc_ccitt(const std::vector<uint32_t> &buffer, int start, int end) { - UINT32 res = 0xffff; + uint32_t res = 0xffff; int size = end - start; for(int i=1; i<size; i+=2) { res <<= 1; @@ -1252,47 +1252,47 @@ UINT16 floppy_image_format_t::calc_crc_ccitt(const std::vector<UINT32> &buffer, return res; } -void floppy_image_format_t::fixup_crc_ccitt(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_ccitt(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { mfm_w(buffer, 16, calc_crc_ccitt(buffer, crc->start, crc->end), 1000, crc->write); } -void floppy_image_format_t::fixup_crc_ccitt_fm(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_ccitt_fm(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { fm_w(buffer, 16, calc_crc_ccitt(buffer, crc->start, crc->end), 1000, crc->write); } -void floppy_image_format_t::fixup_crc_machead(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_machead(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { - UINT8 v = 0; + uint8_t v = 0; for(int o = crc->start; o < crc->end; o+=8) v = v ^ gcr6bw_tb[bitn_r(buffer, o, 8)]; raw_w(buffer, 8, gcr6fw_tb[v], 1000, crc->write); } -void floppy_image_format_t::fixup_crc_fcs(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_fcs(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { // TODO } -void floppy_image_format_t::fixup_crc_victor_header(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_victor_header(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { - UINT8 v = 0; + uint8_t v = 0; for(int o = crc->start; o < crc->end; o+=10) v += ((gcr5bw_tb[bitn_r(buffer, o, 5)] << 4) | gcr5bw_tb[bitn_r(buffer, o+5, 5)]); gcr5_w(buffer, v, 1000, crc->write); } -void floppy_image_format_t::fixup_crc_victor_data(std::vector<UINT32> &buffer, const gen_crc_info *crc) +void floppy_image_format_t::fixup_crc_victor_data(std::vector<uint32_t> &buffer, const gen_crc_info *crc) { - UINT16 v = 0; + uint16_t v = 0; for(int o = crc->start; o < crc->end; o+=10) v += ((gcr5bw_tb[bitn_r(buffer, o, 5)] << 4) | gcr5bw_tb[bitn_r(buffer, o+5, 5)]); gcr5_w(buffer, v & 0xff, 1000, crc->write); gcr5_w(buffer, v >> 8, 1000, crc->write+10); } -void floppy_image_format_t::fixup_crcs(std::vector<UINT32> &buffer, gen_crc_info *crcs) +void floppy_image_format_t::fixup_crcs(std::vector<uint32_t> &buffer, gen_crc_info *crcs) { for(int i=0; i != MAX_CRC_COUNT; i++) if(crcs[i].write != -1) { @@ -1314,9 +1314,9 @@ void floppy_image_format_t::fixup_crcs(std::vector<UINT32> &buffer, gen_crc_info } } -UINT32 floppy_image_format_t::gcr6_encode(UINT8 va, UINT8 vb, UINT8 vc) +uint32_t floppy_image_format_t::gcr6_encode(uint8_t va, uint8_t vb, uint8_t vc) { - UINT32 r; + uint32_t r; r = gcr6fw_tb[((va >> 2) & 0x30) | ((vb >> 4) & 0x0c) | ((vc >> 6) & 0x03)] << 24; r |= gcr6fw_tb[va & 0x3f] << 16; r |= gcr6fw_tb[vb & 0x3f] << 8; @@ -1324,7 +1324,7 @@ UINT32 floppy_image_format_t::gcr6_encode(UINT8 va, UINT8 vb, UINT8 vc) return r; } -void floppy_image_format_t::gcr6_decode(UINT8 e0, UINT8 e1, UINT8 e2, UINT8 e3, UINT8 &va, UINT8 &vb, UINT8 &vc) +void floppy_image_format_t::gcr6_decode(uint8_t e0, uint8_t e1, uint8_t e2, uint8_t e3, uint8_t &va, uint8_t &vb, uint8_t &vc) { e0 = gcr6bw_tb[e0]; e1 = gcr6bw_tb[e1]; @@ -1336,12 +1336,12 @@ void floppy_image_format_t::gcr6_decode(UINT8 e0, UINT8 e1, UINT8 e2, UINT8 e3, vc = ((e0 << 6) & 0xc0) | e3; } -UINT16 floppy_image_format_t::gcr4_encode(UINT8 va) +uint16_t floppy_image_format_t::gcr4_encode(uint8_t va) { return (va << 7) | va | 0xaaaa; } -UINT8 floppy_image_format_t::gcr4_decode(UINT8 e0, UINT8 e1) +uint8_t floppy_image_format_t::gcr4_decode(uint8_t e0, uint8_t e1) { return ((e0 << 1) & 0xaa) | (e1 & 0x55); } @@ -1371,7 +1371,7 @@ int floppy_image_format_t::calc_sector_index(int num, int interleave, int skew, void floppy_image_format_t::generate_track(const desc_e *desc, int track, int head, const desc_s *sect, int sect_count, int track_size, floppy_image *image) { - std::vector<UINT32> buffer; + std::vector<uint32_t> buffer; gen_crc_info crcs[MAX_CRC_COUNT]; collect_crcs(desc, crcs); @@ -1617,14 +1617,14 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he case SECTOR_DATA_MAC: { const desc_s *csect = sect + (desc[index].p1 >= 0 ? desc[index].p1 : sector_idx); - const UINT8 *data = csect->data; + const uint8_t *data = csect->data; int size = csect->size; - UINT8 ca = 0, cb = 0, cc = 0; + uint8_t ca = 0, cb = 0, cc = 0; for(int i=0; i < size; i+=3) { int dt = size-i; - UINT8 va = data[i]; - UINT8 vb = dt > 1 ? data[i+1] : 0; - UINT8 vc = dt > 2 ? data[i+2] : 0; + uint8_t va = data[i]; + uint8_t vb = dt > 1 ? data[i+1] : 0; + uint8_t vc = dt > 2 ? data[i+2] : 0; cc = (cc << 1) | (cc >> 7); int suma = ca + va + (cc & 1); @@ -1665,7 +1665,7 @@ void floppy_image_format_t::generate_track(const desc_e *desc, int track, int he generate_track_from_levels(track, head, buffer, 0, image); } -void floppy_image_format_t::normalize_times(std::vector<UINT32> &buffer) +void floppy_image_format_t::normalize_times(std::vector<uint32_t> &buffer) { unsigned int total_sum = 0; for(unsigned int i=0; i != buffer.size(); i++) @@ -1673,20 +1673,20 @@ void floppy_image_format_t::normalize_times(std::vector<UINT32> &buffer) unsigned int current_sum = 0; for(unsigned int i=0; i != buffer.size(); i++) { - UINT32 time = buffer[i] & floppy_image::TIME_MASK; + uint32_t time = buffer[i] & floppy_image::TIME_MASK; buffer[i] = (buffer[i] & floppy_image::MG_MASK) | (200000000ULL * current_sum / total_sum); current_sum += time; } } -void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const UINT8 *trackbuf, int track_size, floppy_image *image, int subtrack) +void floppy_image_format_t::generate_track_from_bitstream(int track, int head, const uint8_t *trackbuf, int track_size, floppy_image *image, int subtrack) { // Maximal number of cells which happens when the buffer is all 1 - std::vector<UINT32> &dest = image->get_buffer(track, head, subtrack); + std::vector<uint32_t> &dest = image->get_buffer(track, head, subtrack); dest.clear(); - UINT32 cbit = floppy_image::MG_A; - UINT32 count = 0; + uint32_t cbit = floppy_image::MG_A; + uint32_t count = 0; for(int i=0; i != track_size; i++) if(trackbuf[i >> 3] & (0x80 >> (i & 7))) { dest.push_back(cbit | (count+1)); @@ -1702,11 +1702,11 @@ void floppy_image_format_t::generate_track_from_bitstream(int track, int head, c image->set_write_splice_position(track, head, 0, subtrack); } -void floppy_image_format_t::generate_track_from_levels(int track, int head, std::vector<UINT32> &trackbuf, int splice_pos, floppy_image *image) +void floppy_image_format_t::generate_track_from_levels(int track, int head, std::vector<uint32_t> &trackbuf, int splice_pos, floppy_image *image) { // Retrieve the angular splice pos before messing with the data splice_pos = splice_pos % trackbuf.size(); - UINT32 splice_angular_pos = trackbuf[splice_pos] & floppy_image::TIME_MASK; + uint32_t splice_angular_pos = trackbuf[splice_pos] & floppy_image::TIME_MASK; // Check if we need to invert a cell to get an even number of // transitions on the whole track @@ -1755,14 +1755,14 @@ void floppy_image_format_t::generate_track_from_levels(int track, int head, std: } // Maximal number of cells which happens when the buffer is all MG_1/MG_N alternated, which would be 3/2 - std::vector<UINT32> &dest = image->get_buffer(track, head); + std::vector<uint32_t> &dest = image->get_buffer(track, head); dest.clear(); - UINT32 cbit = floppy_image::MG_A; - UINT32 count = 0; + uint32_t cbit = floppy_image::MG_A; + uint32_t count = 0; for(auto & elem : trackbuf) { - UINT32 bit = elem & floppy_image::MG_MASK; - UINT32 time = elem & floppy_image::TIME_MASK; + uint32_t bit = elem & floppy_image::MG_MASK; + uint32_t time = elem & floppy_image::TIME_MASK; if(bit == MG_0) { count += time; continue; @@ -1786,13 +1786,13 @@ void floppy_image_format_t::generate_track_from_levels(int track, int head, std: image->set_write_splice_position(track, head, splice_angular_pos); } -const UINT8 floppy_image_format_t::gcr5fw_tb[0x10] = +const uint8_t floppy_image_format_t::gcr5fw_tb[0x10] = { 0x0a, 0x0b, 0x12, 0x13, 0x0e, 0x0f, 0x16, 0x17, 0x09, 0x19, 0x1a, 0x1b, 0x0d, 0x1d, 0x1e, 0x15 }; -const UINT8 floppy_image_format_t::gcr5bw_tb[0x20] = +const uint8_t floppy_image_format_t::gcr5bw_tb[0x20] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x00, 0x0c, 0x04, 0x05, @@ -1800,7 +1800,7 @@ const UINT8 floppy_image_format_t::gcr5bw_tb[0x20] = 0x00, 0x09, 0x0a, 0x0b, 0x00, 0x0d, 0x0e, 0x00 }; -const UINT8 floppy_image_format_t::gcr6fw_tb[0x40] = +const uint8_t floppy_image_format_t::gcr6fw_tb[0x40] = { 0x96, 0x97, 0x9a, 0x9b, 0x9d, 0x9e, 0x9f, 0xa6, 0xa7, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb2, 0xb3, @@ -1812,7 +1812,7 @@ const UINT8 floppy_image_format_t::gcr6fw_tb[0x40] = 0xf7, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, }; -const UINT8 floppy_image_format_t::gcr6bw_tb[0x100] = +const uint8_t floppy_image_format_t::gcr6bw_tb[0x100] = { // 0 1 2 3 4 5 6 7 8 9 a b c d e f 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -2192,9 +2192,9 @@ const floppy_image_format_t::desc_e floppy_image_format_t::amiga_22[] = { { END } }; -void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, UINT8 *trackbuf, int &track_size, floppy_image *image, int subtrack) +void floppy_image_format_t::generate_bitstream_from_track(int track, int head, int cell_size, uint8_t *trackbuf, int &track_size, floppy_image *image, int subtrack) { - std::vector<UINT32> &tbuf = image->get_buffer(track, head, subtrack); + std::vector<uint32_t> &tbuf = image->get_buffer(track, head, subtrack); if(tbuf.size() <= 1) { // Unformatted track track_size = 200000000/cell_size; @@ -2203,7 +2203,7 @@ void floppy_image_format_t::generate_bitstream_from_track(int track, int head, i } // Start at the write splice - UINT32 splice = image->get_write_splice_position(track, head, subtrack); + uint32_t splice = image->get_write_splice_position(track, head, subtrack); int cur_pos = splice; int cur_entry = 0; while(cur_entry < int(tbuf.size())-1 && (tbuf[cur_entry+1] & floppy_image::TIME_MASK) < cur_pos) @@ -2219,7 +2219,7 @@ void floppy_image_format_t::generate_bitstream_from_track(int track, int head, i int phase_adjust = 0; int freq_hist = 0; - UINT32 scanned = 0; + uint32_t scanned = 0; while(scanned < 200000000) { // Note that all magnetic cell type changes are considered // edges. No randomness added for neutral/damaged cells @@ -2294,12 +2294,12 @@ void floppy_image_format_t::generate_bitstream_from_track(int track, int head, i track_size = cur_bit; } -int floppy_image_format_t::sbit_r(const UINT8 *bitstream, int pos) +int floppy_image_format_t::sbit_r(const uint8_t *bitstream, int pos) { return (bitstream[pos >> 3] & (0x80 >> (pos & 7))) != 0; } -int floppy_image_format_t::sbit_rp(const UINT8 *bitstream, int &pos, int track_size) +int floppy_image_format_t::sbit_rp(const uint8_t *bitstream, int &pos, int track_size) { int res = sbit_r(bitstream, pos); pos ++; @@ -2308,9 +2308,9 @@ int floppy_image_format_t::sbit_rp(const UINT8 *bitstream, int &pos, int track_s return res; } -UINT8 floppy_image_format_t::sbyte_mfm_r(const UINT8 *bitstream, int &pos, int track_size) +uint8_t floppy_image_format_t::sbyte_mfm_r(const uint8_t *bitstream, int &pos, int track_size) { - UINT8 res = 0; + uint8_t res = 0; for(int i=0; i<8; i++) { sbit_rp(bitstream, pos, track_size); if(sbit_rp(bitstream, pos, track_size)) @@ -2319,9 +2319,9 @@ UINT8 floppy_image_format_t::sbyte_mfm_r(const UINT8 *bitstream, int &pos, int t return res; } -UINT8 floppy_image_format_t::sbyte_gcr5_r(const UINT8 *bitstream, int &pos, int track_size) +uint8_t floppy_image_format_t::sbyte_gcr5_r(const uint8_t *bitstream, int &pos, int track_size) { - UINT16 gcr = 0; + uint16_t gcr = 0; for(int i=0; i<10; i++) { if(sbit_rp(bitstream, pos, track_size)) gcr |= 0x200 >> i; @@ -2330,7 +2330,7 @@ UINT8 floppy_image_format_t::sbyte_gcr5_r(const UINT8 *bitstream, int &pos, int return (gcr5bw_tb[gcr >> 5] << 4) | gcr5bw_tb[gcr & 0x1f]; } -void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const UINT8 *bitstream, int track_size, desc_xs *sectors, UINT8 *sectdata, int sectdata_size) +void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const uint8_t *bitstream, int track_size, desc_xs *sectors, uint8_t *sectdata, int sectdata_size) { memset(sectors, 0, 256*sizeof(desc_xs)); @@ -2347,7 +2347,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const UINT8 *b int idblk_count = 0, dblk_count = 0; // Precharge the shift register to detect over-the-index stuff - UINT16 shift_reg = 0; + uint16_t shift_reg = 0; for(int i=0; i<16; i++) if(sbit_r(bitstream, track_size-16+i)) shift_reg |= 0x8000 >> i; @@ -2357,7 +2357,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const UINT8 *b for(int i=0; i<track_size; i++) { shift_reg = (shift_reg << 1) | sbit_r(bitstream, i); if(shift_reg == 0x4489) { - UINT16 header; + uint16_t header; int pos = i+1; do { header = 0; @@ -2389,10 +2389,10 @@ void floppy_image_format_t::extract_sectors_from_bitstream_mfm_pc(const UINT8 *b int sectdata_pos = 0; for(int i=0; i<idblk_count; i++) { int pos = idblk[i]; - UINT8 track = sbyte_mfm_r(bitstream, pos, track_size); - UINT8 head = sbyte_mfm_r(bitstream, pos, track_size); - UINT8 sector = sbyte_mfm_r(bitstream, pos, track_size); - UINT8 size = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t track = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t head = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t sector = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t size = sbyte_mfm_r(bitstream, pos, track_size); if(size >= 8) continue; @@ -2436,8 +2436,8 @@ void floppy_image_format_t::get_geometry_mfm_pc(floppy_image *image, int cell_si return; } - UINT8 bitstream[500000/8]; - UINT8 sectdata[50000]; + uint8_t bitstream[500000/8]; + uint8_t sectdata[50000]; desc_xs sectors[256]; int track_size; @@ -2455,17 +2455,17 @@ void floppy_image_format_t::get_geometry_mfm_pc(floppy_image *image, int cell_si } -void floppy_image_format_t::get_track_data_mfm_pc(int track, int head, floppy_image *image, int cell_size, int sector_size, int sector_count, UINT8 *sectdata) +void floppy_image_format_t::get_track_data_mfm_pc(int track, int head, floppy_image *image, int cell_size, int sector_size, int sector_count, uint8_t *sectdata) { - UINT8 bitstream[500000/8]; - UINT8 sectbuf[50000]; + uint8_t bitstream[500000/8]; + uint8_t sectbuf[50000]; desc_xs sectors[256]; int track_size; generate_bitstream_from_track(track, head, cell_size, bitstream, track_size, image); extract_sectors_from_bitstream_mfm_pc(bitstream, track_size, sectors, sectbuf, sizeof(sectbuf)); for(int sector=1; sector <= sector_count; sector++) { - UINT8 *sd = sectdata + (sector-1)*sector_size; + uint8_t *sd = sectdata + (sector-1)*sector_size; if(sectors[sector].data && sectors[sector].track == track && sectors[sector].head == head) { int asize = sectors[sector].size; if(asize > sector_size) @@ -2479,7 +2479,7 @@ void floppy_image_format_t::get_track_data_mfm_pc(int track, int head, floppy_im } -void floppy_image_format_t::extract_sectors_from_bitstream_fm_pc(const UINT8 *bitstream, int track_size, desc_xs *sectors, UINT8 *sectdata, int sectdata_size) +void floppy_image_format_t::extract_sectors_from_bitstream_fm_pc(const uint8_t *bitstream, int track_size, desc_xs *sectors, uint8_t *sectdata, int sectdata_size) { memset(sectors, 0, 256*sizeof(desc_xs)); @@ -2496,7 +2496,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_fm_pc(const UINT8 *bi int idblk_count = 0, dblk_count = 0; // Precharge the shift register to detect over-the-index stuff - UINT16 shift_reg = 0; + uint16_t shift_reg = 0; for(int i=0; i<16; i++) if(sbit_r(bitstream, track_size-16+i)) shift_reg |= 0x8000 >> i; @@ -2526,10 +2526,10 @@ void floppy_image_format_t::extract_sectors_from_bitstream_fm_pc(const UINT8 *bi int sectdata_pos = 0; for(int i=0; i<idblk_count; i++) { int pos = idblk[i]; - UINT8 track = sbyte_mfm_r(bitstream, pos, track_size); - UINT8 head = sbyte_mfm_r(bitstream, pos, track_size); - UINT8 sector = sbyte_mfm_r(bitstream, pos, track_size); - UINT8 size = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t track = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t head = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t sector = sbyte_mfm_r(bitstream, pos, track_size); + uint8_t size = sbyte_mfm_r(bitstream, pos, track_size); if(size >= 8) continue; int ssize = 128 << size; @@ -2571,8 +2571,8 @@ void floppy_image_format_t::get_geometry_fm_pc(floppy_image *image, int cell_siz return; } - UINT8 bitstream[500000/8]; - UINT8 sectdata[50000]; + uint8_t bitstream[500000/8]; + uint8_t sectdata[50000]; desc_xs sectors[256]; int track_size; @@ -2590,17 +2590,17 @@ void floppy_image_format_t::get_geometry_fm_pc(floppy_image *image, int cell_siz } -void floppy_image_format_t::get_track_data_fm_pc(int track, int head, floppy_image *image, int cell_size, int sector_size, int sector_count, UINT8 *sectdata) +void floppy_image_format_t::get_track_data_fm_pc(int track, int head, floppy_image *image, int cell_size, int sector_size, int sector_count, uint8_t *sectdata) { - UINT8 bitstream[500000/8]; - UINT8 sectbuf[50000]; + uint8_t bitstream[500000/8]; + uint8_t sectbuf[50000]; desc_xs sectors[256]; int track_size; generate_bitstream_from_track(track, head, cell_size, bitstream, track_size, image); extract_sectors_from_bitstream_fm_pc(bitstream, track_size, sectors, sectbuf, sizeof(sectbuf)); for(int sector=1; sector <= sector_count; sector++) { - UINT8 *sd = sectdata + (sector-1)*sector_size; + uint8_t *sd = sectdata + (sector-1)*sector_size; if(sectors[sector].data && sectors[sector].track == track && sectors[sector].head == head) { int asize = sectors[sector].size; if(asize > sector_size) @@ -2613,7 +2613,7 @@ void floppy_image_format_t::get_track_data_fm_pc(int track, int head, floppy_ima } } -int floppy_image_format_t::calc_default_pc_gap3_size(UINT32 form_factor, int sector_size) +int floppy_image_format_t::calc_default_pc_gap3_size(uint32_t form_factor, int sector_size) { return form_factor == floppy_image::FF_8 ? 25 : @@ -2634,7 +2634,7 @@ void floppy_image_format_t::build_wd_track_mfm(int track, int head, floppy_image void floppy_image_format_t::build_pc_track_fm(int track, int head, floppy_image *image, int cell_count, int sector_count, const desc_pc_sector *sects, int gap_3, int gap_4a, int gap_1, int gap_2) { - std::vector<UINT32> track_data; + std::vector<uint32_t> track_data; // gap 4a , IAM and gap 1 if(gap_4a != -1) { @@ -2658,7 +2658,7 @@ void floppy_image_format_t::build_pc_track_fm(int track, int head, floppy_image // Build the track for(int i=0; i<sector_count; i++) { - UINT16 crc; + uint16_t crc; // sync and IDAM and gap 2 for(int j=0; j< 6; j++) fm_w(track_data, 8, 0x00); @@ -2700,7 +2700,7 @@ void floppy_image_format_t::build_pc_track_fm(int track, int head, floppy_image void floppy_image_format_t::build_pc_track_mfm(int track, int head, floppy_image *image, int cell_count, int sector_count, const desc_pc_sector *sects, int gap_3, int gap_4a, int gap_1, int gap_2) { - std::vector<UINT32> track_data; + std::vector<uint32_t> track_data; // gap 4a , IAM and gap 1 if(gap_4a != -1) { @@ -2725,7 +2725,7 @@ void floppy_image_format_t::build_pc_track_mfm(int track, int head, floppy_image // Build the track for(int i=0; i<sector_count; i++) { - UINT16 crc; + uint16_t crc; // sync and IDAM and gap 2 for(int j=0; j<12; j++) mfm_w(track_data, 8, 0x00); unsigned int cpos = track_data.size(); @@ -2766,7 +2766,7 @@ void floppy_image_format_t::build_pc_track_mfm(int track, int head, floppy_image generate_track_from_levels(track, head, track_data, 0, image); } -void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const UINT8 *bitstream, int track_size, desc_xs *sectors, UINT8 *sectdata, int sectdata_size, int head, int tracks) +void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const uint8_t *bitstream, int track_size, desc_xs *sectors, uint8_t *sectdata, int sectdata_size, int head, int tracks) { memset(sectors, 0, 256*sizeof(desc_xs)); @@ -2779,7 +2779,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const UINT8 *bit int hblk_count = 0, dblk_count = 0; // Precharge the shift register to detect over-the-index stuff - UINT16 shift_reg = 0; + uint16_t shift_reg = 0; for(int i=0; i<16; i++) if(sbit_r(bitstream, track_size-16+i)) shift_reg |= 0x8000 >> i; @@ -2791,7 +2791,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const UINT8 *bit shift_reg = ((shift_reg << 1) | bit) & 0x3ff; if (sync && !bit) { - UINT8 id = sbyte_gcr5_r(bitstream, i, track_size); + uint8_t id = sbyte_gcr5_r(bitstream, i, track_size); switch (id) { case 0x08: @@ -2813,12 +2813,12 @@ void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const UINT8 *bit int sectdata_pos = 0; for(int i=0; i<hblk_count; i++) { int pos = hblk[i]; - ATTR_UNUSED UINT8 block_id = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 crc = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 sector = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 track = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 id2 = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 id1 = sbyte_gcr5_r(bitstream, pos, track_size); + ATTR_UNUSED uint8_t block_id = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t crc = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t sector = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t track = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t id2 = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t id1 = sbyte_gcr5_r(bitstream, pos, track_size); if (crc ^ sector ^ track ^ id2 ^ id1) { // header crc mismatch @@ -2832,9 +2832,9 @@ void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const UINT8 *bit sectors[sector].head = head; sectors[sector].size = 256; sectors[sector].data = sectdata + sectdata_pos; - UINT8 data_crc = 0; + uint8_t data_crc = 0; for(int j=0; j<sectors[sector].size; j++) { - UINT8 data = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t data = sbyte_gcr5_r(bitstream, pos, track_size); data_crc ^= data; sectdata[sectdata_pos++] = data; } @@ -2845,7 +2845,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_gcr5(const UINT8 *bit } } -void floppy_image_format_t::extract_sectors_from_bitstream_victor_gcr5(const UINT8 *bitstream, int track_size, desc_xs *sectors, UINT8 *sectdata, int sectdata_size) +void floppy_image_format_t::extract_sectors_from_bitstream_victor_gcr5(const uint8_t *bitstream, int track_size, desc_xs *sectors, uint8_t *sectdata, int sectdata_size) { memset(sectors, 0, 256*sizeof(desc_xs)); @@ -2858,7 +2858,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_victor_gcr5(const UIN int hblk_count = 0, dblk_count = 0; // Precharge the shift register to detect over-the-index stuff - UINT16 shift_reg = 0; + uint16_t shift_reg = 0; for(int i=0; i<16; i++) if(sbit_r(bitstream, track_size-16+i)) shift_reg |= 0x8000 >> i; @@ -2870,7 +2870,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_victor_gcr5(const UIN shift_reg = ((shift_reg << 1) | bit) & 0x3ff; if (sync && !bit) { - UINT8 id = sbyte_gcr5_r(bitstream, i, track_size); + uint8_t id = sbyte_gcr5_r(bitstream, i, track_size); switch (id) { case 0x07: @@ -2892,9 +2892,9 @@ void floppy_image_format_t::extract_sectors_from_bitstream_victor_gcr5(const UIN int sectdata_pos = 0; for(int i=0; i<hblk_count; i++) { int pos = hblk[i]; - ATTR_UNUSED UINT8 block_id = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 track = sbyte_gcr5_r(bitstream, pos, track_size); - UINT8 sector = sbyte_gcr5_r(bitstream, pos, track_size); + ATTR_UNUSED uint8_t block_id = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t track = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t sector = sbyte_gcr5_r(bitstream, pos, track_size); pos = dblk[i]; block_id = sbyte_gcr5_r(bitstream, pos, track_size); @@ -2904,7 +2904,7 @@ void floppy_image_format_t::extract_sectors_from_bitstream_victor_gcr5(const UIN sectors[sector].size = 512; sectors[sector].data = sectdata + sectdata_pos; for(int j=0; j<sectors[sector].size; j++) { - UINT8 data = sbyte_gcr5_r(bitstream, pos, track_size); + uint8_t data = sbyte_gcr5_r(bitstream, pos, track_size); sectdata[sectdata_pos++] = data; } } |