1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-01-11 08:30:55 +00:00

Introduced a memory fuzzer, and ensured the Oric uses it.

This commit is contained in:
Thomas Harte 2016-10-19 21:31:50 -04:00
parent 734b575d30
commit 5c69728625
4 changed files with 56 additions and 0 deletions

27
Machines/MemoryFuzzer.cpp Normal file
View File

@ -0,0 +1,27 @@
//
// MemoryFuzzer.cpp
// Clock Signal
//
// Created by Thomas Harte on 19/10/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#include "MemoryFuzzer.hpp"
#include <cstdlib>
void Memory::Fuzz(uint8_t *buffer, size_t size)
{
unsigned int divider = ((unsigned int)RAND_MAX + 1) / 256;
unsigned int shift = 1, value = 1;
while(value < divider)
{
value <<= 1;
shift++;
}
for(size_t c = 0; c < size; c++)
{
buffer[c] = (uint8_t)(rand() >> shift);
}
}

21
Machines/MemoryFuzzer.hpp Normal file
View File

@ -0,0 +1,21 @@
//
// MemoryFuzzer.hpp
// Clock Signal
//
// Created by Thomas Harte on 19/10/2016.
// Copyright © 2016 Thomas Harte. All rights reserved.
//
#ifndef MemoryFuzzer_hpp
#define MemoryFuzzer_hpp
#include <cstdint>
#include <cstddef>
namespace Memory {
void Fuzz(uint8_t *buffer, size_t size);
}
#endif /* MemoryFuzzer_hpp */

View File

@ -7,6 +7,7 @@
//
#include "Oric.hpp"
#include "../MemoryFuzzer.hpp"
using namespace Oric;
@ -19,6 +20,7 @@ Machine::Machine() : _cycles_since_video_update(0)
_via.keyboard = _keyboard;
clear_all_keys();
_via.tape->set_delegate(this);
Memory::Fuzz(_ram, sizeof(_ram));
}
void Machine::configure_as_target(const StaticAnalyser::Target &target)

View File

@ -19,6 +19,7 @@
4B1E85751D170228001EF87D /* Typer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B1E85731D170228001EF87D /* Typer.cpp */; };
4B1E85811D176468001EF87D /* 6532Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B1E85801D176468001EF87D /* 6532Tests.swift */; };
4B2409551C45AB05004DA684 /* Speaker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2409531C45AB05004DA684 /* Speaker.cpp */; };
4B2A332A1DB8544D002876E3 /* MemoryFuzzer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A33281DB8544D002876E3 /* MemoryFuzzer.cpp */; };
4B2A539F1D117D36003C6002 /* CSAudioQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A53911D117D36003C6002 /* CSAudioQueue.m */; };
4B2A53A01D117D36003C6002 /* CSMachine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A53961D117D36003C6002 /* CSMachine.mm */; };
4B2A53A11D117D36003C6002 /* CSAtari2600.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B2A539A1D117D36003C6002 /* CSAtari2600.mm */; };
@ -419,6 +420,8 @@
4B2409531C45AB05004DA684 /* Speaker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Speaker.cpp; path = ../../Outputs/Speaker.cpp; sourceTree = "<group>"; };
4B2409541C45AB05004DA684 /* Speaker.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Speaker.hpp; path = ../../Outputs/Speaker.hpp; sourceTree = "<group>"; };
4B24095A1C45DF85004DA684 /* Stepper.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Stepper.hpp; sourceTree = "<group>"; };
4B2A33281DB8544D002876E3 /* MemoryFuzzer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MemoryFuzzer.cpp; sourceTree = "<group>"; };
4B2A33291DB8544D002876E3 /* MemoryFuzzer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = MemoryFuzzer.hpp; sourceTree = "<group>"; };
4B2A53901D117D36003C6002 /* CSAudioQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSAudioQueue.h; sourceTree = "<group>"; };
4B2A53911D117D36003C6002 /* CSAudioQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSAudioQueue.m; sourceTree = "<group>"; };
4B2A53931D117D36003C6002 /* CSKeyboardMachine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSKeyboardMachine.h; sourceTree = "<group>"; };
@ -1602,6 +1605,8 @@
4B4DC81D1D2C2425003C5BF8 /* Commodore */,
4B2E2D9E1C3A070900138695 /* Electron */,
4BCF1FA51DADC3E10039D2E7 /* Oric */,
4B2A33281DB8544D002876E3 /* MemoryFuzzer.cpp */,
4B2A33291DB8544D002876E3 /* MemoryFuzzer.hpp */,
);
name = Machines;
path = ../../Machines;
@ -2234,6 +2239,7 @@
4BD69F941D98760000243FE1 /* AcornADF.cpp in Sources */,
4BBF99181C8FBA6F0075DAFB /* TextureTarget.cpp in Sources */,
4BC76E691C98E31700E6EF73 /* FIRFilter.cpp in Sources */,
4B2A332A1DB8544D002876E3 /* MemoryFuzzer.cpp in Sources */,
4B55CE5F1C3B7D960093A61B /* MachineDocument.swift in Sources */,
4B2A53A11D117D36003C6002 /* CSAtari2600.mm in Sources */,
4BF829661D8F732B001BAE39 /* Disk.cpp in Sources */,