mirror of
https://github.com/JorjBauer/aiie.git
synced 2024-09-11 01:56:59 +00:00
fixed bit length of tracks; added actual random fake bits. Passes most test Woz images now.
This commit is contained in:
parent
f895366ff7
commit
f333780348
@ -30,6 +30,7 @@ Woz::Woz()
|
|||||||
{
|
{
|
||||||
trackPointer = 0;
|
trackPointer = 0;
|
||||||
trackBitIdx = 0x80;
|
trackBitIdx = 0x80;
|
||||||
|
trackBitCounter = 0;
|
||||||
trackLoopCounter = 0;
|
trackLoopCounter = 0;
|
||||||
metaData = NULL;
|
metaData = NULL;
|
||||||
|
|
||||||
@ -39,6 +40,7 @@ Woz::Woz()
|
|||||||
memset(&quarterTrackMap, 255, sizeof(quarterTrackMap));
|
memset(&quarterTrackMap, 255, sizeof(quarterTrackMap));
|
||||||
memset(&di, 0, sizeof(diskInfo));
|
memset(&di, 0, sizeof(diskInfo));
|
||||||
memset(&tracks, 0, sizeof(tracks));
|
memset(&tracks, 0, sizeof(tracks));
|
||||||
|
randPtr = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Woz::~Woz()
|
Woz::~Woz()
|
||||||
@ -70,11 +72,16 @@ uint8_t Woz::getNextWozBit(uint8_t track)
|
|||||||
}
|
}
|
||||||
// need another byte out of the track stream
|
// need another byte out of the track stream
|
||||||
trackByte = tracks[track].trackData[trackPointer++];
|
trackByte = tracks[track].trackData[trackPointer++];
|
||||||
if (trackPointer >= tracks[track].bitCount / 8) {
|
}
|
||||||
|
|
||||||
|
if (trackBitCounter >= tracks[track].bitCount) {
|
||||||
trackPointer = 0;
|
trackPointer = 0;
|
||||||
|
trackBitIdx = 0x80;
|
||||||
trackLoopCounter++;
|
trackLoopCounter++;
|
||||||
|
trackByte = tracks[track].trackData[trackPointer++];
|
||||||
|
trackBitCounter = 0;
|
||||||
}
|
}
|
||||||
}
|
trackBitCounter++;
|
||||||
|
|
||||||
uint8_t ret = (trackByte & trackBitIdx) ? 1 : 0;
|
uint8_t ret = (trackByte & trackBitIdx) ? 1 : 0;
|
||||||
|
|
||||||
@ -88,8 +95,18 @@ uint8_t Woz::getNextWozBit(uint8_t track)
|
|||||||
|
|
||||||
uint8_t Woz::fakeBit()
|
uint8_t Woz::fakeBit()
|
||||||
{
|
{
|
||||||
// 30% should be 1s
|
// 30% should be 1s, but I'm not biasing the data here, so this is
|
||||||
return 0;
|
// more like 50% 1s.
|
||||||
|
|
||||||
|
if (randPtr == 0) {
|
||||||
|
randPtr = 0x80;
|
||||||
|
randData = (uint8_t) ((float)256*rand()/(RAND_MAX+1.0));
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ret = (randData & randPtr) ? 1 : 0;
|
||||||
|
randPtr >>= 1;
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Woz::nextDiskBit(uint8_t track)
|
uint8_t Woz::nextDiskBit(uint8_t track)
|
||||||
|
@ -90,10 +90,12 @@ class Woz {
|
|||||||
|
|
||||||
// cursor for track enumeration
|
// cursor for track enumeration
|
||||||
uint32_t trackPointer;
|
uint32_t trackPointer;
|
||||||
|
uint32_t trackBitCounter;
|
||||||
uint8_t trackByte;
|
uint8_t trackByte;
|
||||||
uint8_t trackBitIdx;
|
uint8_t trackBitIdx;
|
||||||
uint8_t trackLoopCounter;
|
uint8_t trackLoopCounter;
|
||||||
char *metaData;
|
char *metaData;
|
||||||
|
uint8_t randData, randPtr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user