mirror of
https://github.com/cmosher01/Epple-II.git
synced 2025-01-15 18:30:43 +00:00
add configurable random 1-bit rate for MC3470
This commit is contained in:
parent
05d91f9a1b
commit
e2df466413
@ -226,7 +226,7 @@ void Config::tryParseLine(const std::string& line, MemoryRandomAccess& ram, Memo
|
||||
std::string sCardType;
|
||||
tok >> slot >> sCardType;
|
||||
|
||||
insertCard(sCardType,slot,slts,gui);
|
||||
insertCard(sCardType,slot,slts,gui,tok);
|
||||
}
|
||||
else if (cmd == "motherboard") {
|
||||
std::string op;
|
||||
@ -502,7 +502,7 @@ void Config::saveDisk(Slots& slts, int slot, int drive)
|
||||
slts.get(slot)->save(drive-1);
|
||||
}
|
||||
|
||||
void Config::insertCard(const std::string& cardType, int slot, Slots& slts, ScreenImage& gui)
|
||||
void Config::insertCard(const std::string& cardType, int slot, Slots& slts, ScreenImage& gui, std::istringstream& tok)
|
||||
{
|
||||
if (slot < 0 || 8 <= slot)
|
||||
{
|
||||
@ -523,12 +523,18 @@ void Config::insertCard(const std::string& cardType, int slot, Slots& slts, Scre
|
||||
}
|
||||
else if (cardType == "disk") // 16-sector LSS ROM
|
||||
{
|
||||
card = new DiskController(gui,slot,false);
|
||||
double random_ones_rate(0.3); // WOZ spec v2.0: 30%
|
||||
tok >> random_ones_rate;
|
||||
std::cerr << "MC3470: rate of 1 bits during random bit generation: " << random_ones_rate << std::endl;
|
||||
card = new DiskController(gui,slot,false,random_ones_rate);
|
||||
disk_mask |= (1 << slot);
|
||||
}
|
||||
else if (cardType == "disk13") // 13-sector LSS ROM
|
||||
{
|
||||
card = new DiskController(gui,slot,true);
|
||||
double random_ones_rate(0.3); // WOZ spec v2.0: 30%
|
||||
tok >> random_ones_rate;
|
||||
std::cerr << "MC3470: rate of 1 bits during random bit generation: " << random_ones_rate << std::endl;
|
||||
card = new DiskController(gui,slot,true,random_ones_rate);
|
||||
disk_mask |= (1 << slot);
|
||||
}
|
||||
else if (cardType == "clock")
|
||||
|
@ -40,7 +40,7 @@ private:
|
||||
static void loadDisk(Slots& slts, int slot, int drive, const std::string& fnib);
|
||||
static void unloadDisk(Slots& slts, int slot, int drive);
|
||||
static void saveDisk(Slots& slts, int slot, int drive);
|
||||
static void insertCard(const std::string& cardType, int slot, Slots& slts, ScreenImage& gui);
|
||||
static void insertCard(const std::string& cardType, int slot, Slots& slts, ScreenImage& gui, std::istringstream& tok);
|
||||
static void tryParseLine(const std::string& line, MemoryRandomAccess& ram, Memory& rom, Slots& slts, int& revision, ScreenImage& gui, CassetteIn& cassetteIn, CassetteOut& cassetteOut);
|
||||
|
||||
public:
|
||||
|
@ -17,9 +17,11 @@
|
||||
*/
|
||||
#include "diskcontroller.h"
|
||||
|
||||
DiskController::DiskController(ScreenImage& gui, int slot, bool lss13):
|
||||
DiskController::DiskController(ScreenImage& gui, int slot, bool lss13, double random_ones_rate):
|
||||
gui(gui),
|
||||
slot(slot),
|
||||
drive1(random_ones_rate),
|
||||
drive2(random_ones_rate),
|
||||
currentDrive(&this->drive1),
|
||||
load(false),
|
||||
write(false),
|
||||
|
@ -78,7 +78,7 @@ private:
|
||||
void stepLss();
|
||||
|
||||
public:
|
||||
DiskController(ScreenImage& gui, int slot, bool lss13);
|
||||
DiskController(ScreenImage& gui, int slot, bool lss13, double random_ones_rate);
|
||||
~DiskController();
|
||||
|
||||
void tick();
|
||||
|
@ -16,12 +16,13 @@
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "drive.h"
|
||||
Disk2Drive::Disk2Drive():
|
||||
Disk2Drive::Disk2Drive(double p_random_ones_rate):
|
||||
stepper(head),
|
||||
pulse(false),
|
||||
bitBufferRead(0),
|
||||
random_ones_rate(p_random_ones_rate),
|
||||
generator(std::chrono::system_clock::now().time_since_epoch().count()),
|
||||
distribution(0,1) {
|
||||
distribution(0.0,1.0) {
|
||||
}
|
||||
|
||||
bool Disk2Drive::loadDisk(const std::string& fnib) {
|
||||
|
@ -38,15 +38,16 @@ private:
|
||||
|
||||
|
||||
|
||||
const double random_ones_rate;
|
||||
std::default_random_engine generator;
|
||||
std::uniform_int_distribution<int> distribution;
|
||||
std::uniform_real_distribution<double> distribution;
|
||||
|
||||
bool randomBit() {
|
||||
return !distribution(generator);
|
||||
return distribution(generator) < random_ones_rate;
|
||||
}
|
||||
|
||||
public:
|
||||
Disk2Drive();
|
||||
Disk2Drive(double p_random_ones_rate);
|
||||
bool loadDisk(const std::string& fnib);
|
||||
void unloadDisk();
|
||||
bool isLoaded() const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user