summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/img_dsk.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2020-04-13 19:14:36 +1000
committer Vas Crabb <vas@vastheman.com>2020-04-13 19:14:36 +1000
commitde72f97b90b885e7fa5b0aa237098c945e02f1b5 (patch)
treeccdebacc984f5298783ca8aa7b4ecfa38af23983 /src/lib/formats/img_dsk.cpp
parent404e7321a63548d2e77e50ec0dc7572b3298d5f4 (diff)
(nw) formats: reduce dependencies on libemu
The only link dependency left is emu_fatalerror. The format handlers really shouldn't be throwing fatal errors at all - they should just fail to load an image they can't handle. Maybe the interface should be enhanced to allow better propagation of errors up from the format handlers so they can be displayed in a UI rather than just logged. The only other two dependencies are on logmacro.h (pure macros) and the PAIR type from emucore.h (possibly worth moving to util).
Diffstat (limited to 'src/lib/formats/img_dsk.cpp')
-rw-r--r--src/lib/formats/img_dsk.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/lib/formats/img_dsk.cpp b/src/lib/formats/img_dsk.cpp
index 40093bee4aa..5921130003f 100644
--- a/src/lib/formats/img_dsk.cpp
+++ b/src/lib/formats/img_dsk.cpp
@@ -14,9 +14,11 @@
*********************************************************************/
-#include "emu.h"
#include "img_dsk.h"
+#include "coretmpl.h" // BIT
+
+
// Debugging
#define VERBOSE 0
#define LOG(...) do { if (VERBOSE) osd_printf_info(__VA_ARGS__); } while (false)
@@ -159,7 +161,7 @@ void img_format::write_mmfm_bit(std::vector<uint32_t> &buffer , bool data_bit ,
bit_w(buffer , clock_bit , CELL_SIZE);
bit_w(buffer , data_bit , CELL_SIZE);
- if (BIT(m_crc , 15) ^ data_bit) {
+ if (util::BIT(m_crc , 15) ^ data_bit) {
m_crc = (m_crc << 1) ^ CRC_POLY;
} else {
m_crc <<= 1;
@@ -169,7 +171,7 @@ void img_format::write_mmfm_bit(std::vector<uint32_t> &buffer , bool data_bit ,
void img_format::write_mmfm_byte(std::vector<uint32_t> &buffer , uint8_t data , uint8_t clock)
{
for (int i = 7; i >= 0; i--) {
- write_mmfm_bit(buffer , BIT(data , i) , BIT(clock , i));
+ write_mmfm_bit(buffer , util::BIT(data , i) , util::BIT(clock , i));
}
}
@@ -182,7 +184,7 @@ void img_format::write_crc(std::vector<uint32_t> &buffer , uint16_t crc)
{
// Note that CRC is stored with MSB (x^15) first
for (unsigned i = 0; i < 16; i++) {
- write_mmfm_bit(buffer , BIT(crc , 15 - i) , 0);
+ write_mmfm_bit(buffer , util::BIT(crc , 15 - i) , 0);
}
}
@@ -268,10 +270,10 @@ std::vector<uint8_t> img_format::get_next_id_n_block(const uint8_t *bitstream ,
do {
unsigned cnt_trans = 0;
while (pos < bitstream_size && cnt_trans < 34) {
- bool bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ bool bit = util::BIT(bitstream[ pos >> 3 ] , ~pos & 7);
pos++;
if (cnt_trans < 32) {
- if (!(BIT(cnt_trans , 0) ^ bit)) {
+ if (!(util::BIT(cnt_trans , 0) ^ bit)) {
cnt_trans++;
} else {
cnt_trans = 0;
@@ -298,10 +300,10 @@ std::vector<uint8_t> img_format::get_next_id_n_block(const uint8_t *bitstream ,
// Get AM
data_sr = clock_sr = 0;
for (unsigned i = 0; i < 7; ++i) {
- bool bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ bool bit = util::BIT(bitstream[ pos >> 3 ] , ~pos & 7);
pos++;
clock_sr = (clock_sr << 1) | bit;
- bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ bit = util::BIT(bitstream[ pos >> 3 ] , ~pos & 7);
pos++;
data_sr = (data_sr << 1) | bit;
}
@@ -327,7 +329,7 @@ std::vector<uint8_t> img_format::get_next_id_n_block(const uint8_t *bitstream ,
data_sr = 0;
unsigned j;
for (j = 0; j < 8 && pos < bitstream_size; j++) {
- bool bit = BIT(bitstream[ pos >> 3 ] , ~pos & 7);
+ bool bit = util::BIT(bitstream[ pos >> 3 ] , ~pos & 7);
pos += 2;
data_sr = (data_sr << 1) | bit;
}