summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/formats/hpi_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/hpi_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/hpi_dsk.cpp')
-rw-r--r--src/lib/formats/hpi_dsk.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/formats/hpi_dsk.cpp b/src/lib/formats/hpi_dsk.cpp
index 50d2653280d..7a4f8d1903a 100644
--- a/src/lib/formats/hpi_dsk.cpp
+++ b/src/lib/formats/hpi_dsk.cpp
@@ -45,12 +45,14 @@
*********************************************************************/
-#include "emu.h"
#include "hpi_dsk.h"
+#include "coretmpl.h" // BIT
+
+
// Debugging
#define VERBOSE 0
-#define LOG(...) do { if (VERBOSE) printf(__VA_ARGS__); } while (false)
+#define LOG(...) do { if (VERBOSE) osd_printf_info(__VA_ARGS__); } while (false)
constexpr unsigned IL_OFFSET = 0x12; // Position of interleave factor in HPI image (2 bytes, big-endian)
constexpr unsigned DEFAULT_IL = 7; // Default interleaving factor
@@ -260,7 +262,7 @@ void hpi_format::write_mmfm_bit(std::vector<uint32_t> &buffer , bool data_bit ,
void hpi_format::write_mmfm_byte(std::vector<uint32_t> &buffer , uint8_t data , uint8_t clock)
{
for (unsigned i = 0; i < 8; i++) {
- write_mmfm_bit(buffer , BIT(data , i) , BIT(clock , i));
+ write_mmfm_bit(buffer , util::BIT(data , i) , util::BIT(clock , i));
}
}
@@ -281,7 +283,7 @@ void hpi_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);
}
}
@@ -371,7 +373,7 @@ std::vector<uint8_t> hpi_format::get_next_id_n_block(const uint8_t *bitstream ,
uint32_t sr = 0;
// Look for either sync + ID AM or sync + DATA AM
while (pos < bitstream_size && sr != ID_CD_PATTERN && sr != DATA_CD_PATTERN) {
- bool bit = BIT(bitstream[ pos >> 3 ] , 7 - (pos & 7));
+ bool bit = util::BIT(bitstream[ pos >> 3 ] , 7 - (pos & 7));
pos++;
sr = (sr << 1) | bit;
}
@@ -396,7 +398,7 @@ std::vector<uint8_t> hpi_format::get_next_id_n_block(const uint8_t *bitstream ,
uint8_t byte = 0;
unsigned j;
for (j = 0; j < 8 && pos < bitstream_size; j++) {
- bool bit = BIT(bitstream[ pos >> 3 ] , 7 - (pos & 7));
+ bool bit = util::BIT(bitstream[ pos >> 3 ] , 7 - (pos & 7));
pos += 2;
byte >>= 1;
if (bit) {