1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-07-11 04:28:58 +00:00

Merge pull request #700 from TomHarte/NoNew

Embraces std::make_[unique/shared] in place of .reset(new .
This commit is contained in:
Thomas Harte 2019-12-23 22:05:57 -05:00 committed by GitHub
commit 1db7c7989b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
40 changed files with 89 additions and 68 deletions

View File

@ -22,7 +22,7 @@ class CommodoreGCRParser: public Storage::Disk::Controller {
std::shared_ptr<Storage::Disk::Drive> drive; std::shared_ptr<Storage::Disk::Drive> drive;
CommodoreGCRParser() : Storage::Disk::Controller(4000000), shift_register_(0), track_(1) { CommodoreGCRParser() : Storage::Disk::Controller(4000000), shift_register_(0), track_(1) {
drive.reset(new Storage::Disk::Drive(4000000, 300, 2)); drive = std::make_shared<Storage::Disk::Drive>(4000000, 300, 2);
set_drive(drive); set_drive(drive);
drive->set_motor_on(true); drive->set_motor_on(true);
} }

View File

@ -91,11 +91,15 @@ uint8_t WD1770::get_register(int address) {
if(status_.type == Status::One) if(status_.type == Status::One)
status |= (status_.spin_up ? Flag::SpinUp : 0); status |= (status_.spin_up ? Flag::SpinUp : 0);
} }
// LOG("Returned status " << PADHEX(2) << int(status) << " of type " << 1+int(status_.type)); LOG("Returned status " << PADHEX(2) << int(status) << " of type " << 1+int(status_.type));
return status; return status;
} }
case 1: return track_; case 1:
case 2: return sector_; LOG("Returned track " << int(track_));
return track_;
case 2:
LOG("Returned sector " << int(sector_));
return sector_;
case 3: case 3:
update_status([] (Status &status) { update_status([] (Status &status) {
status.data_request = false; status.data_request = false;

View File

@ -12,7 +12,7 @@
#include <cstring> #include <cstring>
#define LOG_PREFIX "[MFP] " #define LOG_PREFIX "[MFP] "
//#define NDEBUG #define NDEBUG
#include "../../Outputs/Log.hpp" #include "../../Outputs/Log.hpp"
using namespace Motorola::MFP68901; using namespace Motorola::MFP68901;

View File

@ -18,7 +18,7 @@ AsyncTaskQueue::AsyncTaskQueue()
#ifdef __APPLE__ #ifdef __APPLE__
serial_dispatch_queue_ = dispatch_queue_create("com.thomasharte.clocksignal.asyntaskqueue", DISPATCH_QUEUE_SERIAL); serial_dispatch_queue_ = dispatch_queue_create("com.thomasharte.clocksignal.asyntaskqueue", DISPATCH_QUEUE_SERIAL);
#else #else
thread_.reset(new std::thread([this]() { thread_ = std::make_unique<std::thread>([this]() {
while(!should_destruct_) { while(!should_destruct_) {
std::function<void(void)> next_function; std::function<void(void)> next_function;
@ -39,7 +39,7 @@ AsyncTaskQueue::AsyncTaskQueue()
processing_condition_.wait(lock); processing_condition_.wait(lock);
} }
} }
})); });
#endif #endif
} }
@ -88,7 +88,7 @@ DeferringAsyncTaskQueue::~DeferringAsyncTaskQueue() {
void DeferringAsyncTaskQueue::defer(std::function<void(void)> function) { void DeferringAsyncTaskQueue::defer(std::function<void(void)> function) {
if(!deferred_tasks_) { if(!deferred_tasks_) {
deferred_tasks_.reset(new std::list<std::function<void(void)>>); deferred_tasks_ = std::make_shared<std::list<std::function<void(void)>>>();
} }
deferred_tasks_->push_back(function); deferred_tasks_->push_back(function);
} }

View File

@ -851,7 +851,7 @@ template <Analyser::Static::AppleII::Target::Model model> class ConcreteMachine:
} }
void type_string(const std::string &string) override { void type_string(const std::string &string) override {
string_serialiser_.reset(new Utility::StringSerialiser(string, true)); string_serialiser_ = std::make_unique<Utility::StringSerialiser>(string, true);
} }
// MARK:: Configuration options. // MARK:: Configuration options.

View File

@ -87,35 +87,35 @@ class ConcreteMachine:
using PagingModel = Target::PagingModel; using PagingModel = Target::PagingModel;
switch(target.paging_model) { switch(target.paging_model) {
case PagingModel::ActivisionStack: bus_.reset(new Cartridge::Cartridge<Cartridge::ActivisionStack>(rom)); break; case PagingModel::ActivisionStack: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::ActivisionStack>>(rom); break;
case PagingModel::CBSRamPlus: bus_.reset(new Cartridge::Cartridge<Cartridge::CBSRAMPlus>(rom)); break; case PagingModel::CBSRamPlus: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::CBSRAMPlus>>(rom); break;
case PagingModel::CommaVid: bus_.reset(new Cartridge::Cartridge<Cartridge::CommaVid>(rom)); break; case PagingModel::CommaVid: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::CommaVid>>(rom); break;
case PagingModel::MegaBoy: bus_.reset(new Cartridge::Cartridge<Cartridge::MegaBoy>(rom)); break; case PagingModel::MegaBoy: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::MegaBoy>>(rom); break;
case PagingModel::MNetwork: bus_.reset(new Cartridge::Cartridge<Cartridge::MNetwork>(rom)); break; case PagingModel::MNetwork: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::MNetwork>>(rom); break;
case PagingModel::None: bus_.reset(new Cartridge::Cartridge<Cartridge::Unpaged>(rom)); break; case PagingModel::None: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Unpaged>>(rom); break;
case PagingModel::ParkerBros: bus_.reset(new Cartridge::Cartridge<Cartridge::ParkerBros>(rom)); break; case PagingModel::ParkerBros: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::ParkerBros>>(rom); break;
case PagingModel::Pitfall2: bus_.reset(new Cartridge::Cartridge<Cartridge::Pitfall2>(rom)); break; case PagingModel::Pitfall2: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Pitfall2>>(rom); break;
case PagingModel::Tigervision: bus_.reset(new Cartridge::Cartridge<Cartridge::Tigervision>(rom)); break; case PagingModel::Tigervision: bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Tigervision>>(rom); break;
case PagingModel::Atari8k: case PagingModel::Atari8k:
if(target.uses_superchip) { if(target.uses_superchip) {
bus_.reset(new Cartridge::Cartridge<Cartridge::Atari8kSuperChip>(rom)); bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Atari8kSuperChip>>(rom);
} else { } else {
bus_.reset(new Cartridge::Cartridge<Cartridge::Atari8k>(rom)); bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Atari8k>>(rom);
} }
break; break;
case PagingModel::Atari16k: case PagingModel::Atari16k:
if(target.uses_superchip) { if(target.uses_superchip) {
bus_.reset(new Cartridge::Cartridge<Cartridge::Atari16kSuperChip>(rom)); bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Atari16kSuperChip>>(rom);
} else { } else {
bus_.reset(new Cartridge::Cartridge<Cartridge::Atari16k>(rom)); bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Atari16k>>(rom);
} }
break; break;
case PagingModel::Atari32k: case PagingModel::Atari32k:
if(target.uses_superchip) { if(target.uses_superchip) {
bus_.reset(new Cartridge::Cartridge<Cartridge::Atari32kSuperChip>(rom)); bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Atari32kSuperChip>>(rom);
} else { } else {
bus_.reset(new Cartridge::Cartridge<Cartridge::Atari32k>(rom)); bus_ = std::make_unique<Cartridge::Cartridge<Cartridge::Atari32k>>(rom);
} }
break; break;
} }

View File

@ -8,6 +8,9 @@
#include "DMAController.hpp" #include "DMAController.hpp"
#define LOG_PREFIX "[DMA] "
#include "../../../Outputs/Log.hpp"
#include <cstdio> #include <cstdio>
using namespace Atari::ST; using namespace Atari::ST;
@ -187,6 +190,12 @@ int DMAController::bus_grant(uint16_t *ram, size_t size) {
// Check that the older buffer is full; stop if not. // Check that the older buffer is full; stop if not.
if(!buffer_[active_buffer_ ^ 1].is_full) return 0; if(!buffer_[active_buffer_ ^ 1].is_full) return 0;
#define b(i, n) " " << PADHEX(2) << buffer_[i].contents[n]
#define b2(i, n) b(i, n) << b(i, n+1)
#define b4(i, n) b2(i, n) << b2(i, n+2)
#define b16(i) b4(i, 0) << b4(i, 4) << b4(i, 8) << b4(i, 12)
LOG("[1] to " << PADHEX(6) << address_ << b16(active_buffer_ ^ 1));
for(int c = 0; c < 8; ++c) { for(int c = 0; c < 8; ++c) {
if(size_t(address_) < size) { if(size_t(address_) < size) {
ram[address_ >> 1] = uint16_t( ram[address_ >> 1] = uint16_t(
@ -201,6 +210,12 @@ int DMAController::bus_grant(uint16_t *ram, size_t size) {
// Check that the newer buffer is full; stop if not. // Check that the newer buffer is full; stop if not.
if(!buffer_[active_buffer_ ].is_full) return 8; if(!buffer_[active_buffer_ ].is_full) return 8;
LOG("[2] to " << PADHEX(6) << address_ << b16(active_buffer_));
#undef b16
#undef b4
#undef b2
#undef b
for(int c = 0; c < 8; ++c) { for(int c = 0; c < 8; ++c) {
if(size_t(address_) < size) { if(size_t(address_) < size) {
ram[address_ >> 1] = uint16_t( ram[address_ >> 1] = uint16_t(

View File

@ -369,7 +369,7 @@ class ConcreteMachine:
if(target.has_c1540) { if(target.has_c1540) {
// construct the 1540 // construct the 1540
c1540_.reset(new ::Commodore::C1540::Machine(Commodore::C1540::Personality::C1540, rom_fetcher)); c1540_ = std::make_unique<::Commodore::C1540::Machine>(Commodore::C1540::Personality::C1540, rom_fetcher);
// attach it to the serial bus // attach it to the serial bus
c1540_->set_serial_bus(serial_bus_); c1540_->set_serial_bus(serial_bus_);

View File

@ -88,7 +88,7 @@ class ConcreteMachine:
set_rom(ROM::OS, *roms[1], false); set_rom(ROM::OS, *roms[1], false);
if(target.has_dfs || target.has_adfs) { if(target.has_dfs || target.has_adfs) {
plus3_.reset(new Plus3); plus3_ = std::make_unique<Plus3>();
if(target.has_dfs) { if(target.has_dfs) {
set_rom(ROM::Slot0, *roms[dfs_rom_position], true); set_rom(ROM::Slot0, *roms[dfs_rom_position], true);

View File

@ -13,8 +13,8 @@ using namespace MSX;
DiskROM::DiskROM(const std::vector<uint8_t> &rom) : DiskROM::DiskROM(const std::vector<uint8_t> &rom) :
WD1770(P1793), WD1770(P1793),
rom_(rom) { rom_(rom) {
drives_[0].reset(new Storage::Disk::Drive(8000000, 300, 2)); drives_[0] = std::make_shared<Storage::Disk::Drive>(8000000, 300, 2);
drives_[1].reset(new Storage::Disk::Drive(8000000, 300, 2)); drives_[1] = std::make_shared<Storage::Disk::Drive>(8000000, 300, 2);
set_is_double_density(true); set_is_double_density(true);
} }

View File

@ -24,7 +24,7 @@ Microdisc::Microdisc() : WD1770(P1793) {
void Microdisc::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, size_t drive) { void Microdisc::set_disk(std::shared_ptr<Storage::Disk::Disk> disk, size_t drive) {
if(!drives_[drive]) { if(!drives_[drive]) {
drives_[drive].reset(new Storage::Disk::Drive(8000000, 300, 2)); drives_[drive] = std::make_unique<Storage::Disk::Drive>(8000000, 300, 2);
if(drive == selected_drive_) set_drive(drives_[drive]); if(drive == selected_drive_) set_drive(drives_[drive]);
drives_[drive]->set_activity_observer(observer_, drive_name(drive), false); drives_[drive]->set_activity_observer(observer_, drive_name(drive), false);
} }

View File

@ -500,7 +500,7 @@ template <Analyser::Static::Oric::Target::DiskInterface disk_interface> class Co
// for Utility::TypeRecipient::Delegate // for Utility::TypeRecipient::Delegate
void type_string(const std::string &string) override final { void type_string(const std::string &string) override final {
string_serialiser_.reset(new Utility::StringSerialiser(string, true)); string_serialiser_ = std::make_unique<Utility::StringSerialiser>(string, true);
} }
// for Microdisc::Delegate // for Microdisc::Delegate

View File

@ -85,7 +85,7 @@ class TypeRecipient: public Typer::Delegate {
protected: protected:
/// Attaches a typer to this class that will type @c string using @c character_mapper as a source. /// Attaches a typer to this class that will type @c string using @c character_mapper as a source.
void add_typer(const std::string &string, std::unique_ptr<CharacterMapper> character_mapper) { void add_typer(const std::string &string, std::unique_ptr<CharacterMapper> character_mapper) {
typer_.reset(new Typer(string, get_typer_delay(), get_typer_frequency(), std::move(character_mapper), this)); typer_ = std::make_unique<Typer>(string, get_typer_delay(), get_typer_frequency(), std::move(character_mapper), this);
} }
/*! /*!

View File

@ -67,7 +67,7 @@
</Testables> </Testables>
</TestAction> </TestAction>
<LaunchAction <LaunchAction
buildConfiguration = "Release" buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
enableASanStackUseAfterReturn = "YES" enableASanStackUseAfterReturn = "YES"

View File

@ -321,7 +321,7 @@ struct ActivityObserver: public Activity::Observer {
} }
- (void)setupOutputWithAspectRatio:(float)aspectRatio { - (void)setupOutputWithAspectRatio:(float)aspectRatio {
_scanTarget.reset(new Outputs::Display::OpenGL::ScanTarget); _scanTarget = std::make_unique<Outputs::Display::OpenGL::ScanTarget>();
_machine->crt_machine()->set_scan_target(_scanTarget.get()); _machine->crt_machine()->set_scan_target(_scanTarget.get());
} }

View File

@ -23,7 +23,7 @@
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {

View File

@ -19,7 +19,7 @@
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {

View File

@ -19,7 +19,7 @@
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {

View File

@ -20,7 +20,7 @@
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {

View File

@ -19,7 +19,7 @@
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {

View File

@ -20,7 +20,7 @@
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {

View File

@ -111,7 +111,7 @@ class CPU::MC68000::ProcessorStorageTests {
} }
- (void)setUp { - (void)setUp {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
} }
- (void)tearDown { - (void)tearDown {
@ -120,7 +120,7 @@ class CPU::MC68000::ProcessorStorageTests {
- (void)testABCDLong { - (void)testABCDLong {
for(int d = 0; d < 100; ++d) { for(int d = 0; d < 100; ++d) {
_machine.reset(new RAM68000()); _machine = std::make_unique<RAM68000>();
_machine->set_program({ _machine->set_program({
0xc100 // ABCD D0, D0 0xc100 // ABCD D0, D0
}); });

View File

@ -11,6 +11,8 @@
#include "NSData+StdVector.h" #include "NSData+StdVector.h"
#include "CSROMFetcher.hpp" #include "CSROMFetcher.hpp"
#include <memory>
class VanillaSerialPort: public Commodore::Serial::Port { class VanillaSerialPort: public Commodore::Serial::Port {
public: public:
void set_input(Commodore::Serial::Line line, Commodore::Serial::LineLevel value) { void set_input(Commodore::Serial::Line line, Commodore::Serial::LineLevel value) {
@ -29,11 +31,11 @@ class VanillaSerialPort: public Commodore::Serial::Port {
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if(self) { if(self) {
_serialBus.reset(new ::Commodore::Serial::Bus); _serialBus = std::make_shared<::Commodore::Serial::Bus>();
_serialPort.reset(new VanillaSerialPort); _serialPort = std::make_shared<VanillaSerialPort>();
auto rom_fetcher = CSROMFetcher(); auto rom_fetcher = CSROMFetcher();
_c1540.reset(new Commodore::C1540::Machine(Commodore::C1540::Personality::C1540, rom_fetcher)); _c1540 = std::make_unique<Commodore::C1540::Machine>(Commodore::C1540::Personality::C1540, rom_fetcher);
_c1540->set_serial_bus(_serialBus); _c1540->set_serial_bus(_serialBus);
Commodore::Serial::AttachPortAndBus(_serialPort, _serialBus); Commodore::Serial::AttachPortAndBus(_serialPort, _serialBus);
} }

View File

@ -32,7 +32,7 @@ class DigitalPhaseLockedLoopDelegate: public Storage::DigitalPhaseLockedLoop::De
- (instancetype)initWithClocksPerBit:(NSUInteger)clocksPerBit historyLength:(NSUInteger)historyLength { - (instancetype)initWithClocksPerBit:(NSUInteger)clocksPerBit historyLength:(NSUInteger)historyLength {
self = [super init]; self = [super init];
if(self) { if(self) {
_digitalPhaseLockedLoop.reset(new Storage::DigitalPhaseLockedLoop((unsigned int)clocksPerBit, (unsigned int)historyLength)); _digitalPhaseLockedLoop = std::make_unique<Storage::DigitalPhaseLockedLoop>((unsigned int)clocksPerBit, (unsigned int)historyLength));
_delegate.bridge = self; _delegate.bridge = self;
_digitalPhaseLockedLoop->set_delegate(&_delegate); _digitalPhaseLockedLoop->set_delegate(&_delegate);
} }

View File

@ -46,7 +46,7 @@ class VanillaVIAPortHandler: public MOS::MOS6522::PortHandler {
- (instancetype)init { - (instancetype)init {
self = [super init]; self = [super init];
if(self) { if(self) {
_via.reset(new MOS::MOS6522::MOS6522<VanillaVIAPortHandler>(_viaPortHandler)); _via = std::make_unique<MOS::MOS6522::MOS6522<VanillaVIAPortHandler>(_viaPortHandler);
_viaPortHandler.bridge = self; _viaPortHandler.bridge = self;
} }
return self; return self;

View File

@ -107,7 +107,7 @@ class EmuTOS: public ComparativeBusHandler {
const std::vector<ROMMachine::ROM> rom_names = {{"AtariST", "", image.UTF8String, 0, 0 }}; const std::vector<ROMMachine::ROM> rom_names = {{"AtariST", "", image.UTF8String, 0, 0 }};
const auto roms = CSROMFetcher()(rom_names); const auto roms = CSROMFetcher()(rom_names);
NSString *const traceLocation = [[NSBundle bundleForClass:[self class]] pathForResource:trace ofType:@"trace.txt.gz"]; NSString *const traceLocation = [[NSBundle bundleForClass:[self class]] pathForResource:trace ofType:@"trace.txt.gz"];
_machine.reset(new EmuTOS(*roms[0], traceLocation.UTF8String)); _machine = std::make_unique<EmuTOS>(*roms[0], traceLocation.UTF8String);
_machine->run_for(HalfCycles(length)); _machine->run_for(HalfCycles(length));
} }

View File

@ -23,7 +23,7 @@
- (void)setUp { - (void)setUp {
// Put setup code here. This method is called before the invocation of each test method in the class. // Put setup code here. This method is called before the invocation of each test method in the class.
_video.reset(new Apple::Macintosh::Video(_dummy_audio, _dummy_drive_speed_accumulator)); _video = std::make_unique<Apple::Macintosh::Video>(_dummy_audio, _dummy_drive_speed_accumulator);
_video->set_ram(_ram, sizeof(_ram) - 1); _video->set_ram(_ram, sizeof(_ram) - 1);
} }

View File

@ -104,7 +104,7 @@ class QL: public ComparativeBusHandler {
const std::vector<ROMMachine::ROM> rom_names = {{"SinclairQL", "", "js.rom", 0, 0 }}; const std::vector<ROMMachine::ROM> rom_names = {{"SinclairQL", "", "js.rom", 0, 0 }};
const auto roms = CSROMFetcher()(rom_names); const auto roms = CSROMFetcher()(rom_names);
NSString *const traceLocation = [[NSBundle bundleForClass:[self class]] pathForResource:@"qltrace" ofType:@".txt.gz"]; NSString *const traceLocation = [[NSBundle bundleForClass:[self class]] pathForResource:@"qltrace" ofType:@".txt.gz"];
_machine.reset(new QL(*roms[0], traceLocation.UTF8String)); _machine = std::make_unique<QL>(*roms[0], traceLocation.UTF8String);
// This is how many cycles it takes to exhaust the supplied trace file. // This is how many cycles it takes to exhaust the supplied trace file.
_machine->run_for(HalfCycles(23923180)); _machine->run_for(HalfCycles(23923180));

View File

@ -27,7 +27,7 @@ static void receive_line(uint8_t *next_line)
{ {
[super setUp]; [super setUp];
std::function<void(uint8_t *)> function = receive_line; std::function<void(uint8_t *)> function = receive_line;
_tia.reset(new Atari2600::TIA(function)); _tia = std::make_unique<Atari2600::TIA>(function);
line = nullptr; line = nullptr;
_tia->set_playfield(0, 0x00); _tia->set_playfield(0, 0x00);

View File

@ -248,11 +248,11 @@ ParsedArguments parse_arguments(int argc, char *argv[]) {
std::size_t split_index = argument.find("="); std::size_t split_index = argument.find("=");
if(split_index == std::string::npos) { if(split_index == std::string::npos) {
arguments.selections[argument].reset(new Configurable::BooleanSelection(true)); arguments.selections[argument] = std::make_unique<Configurable::BooleanSelection>(true);
} else { } else {
std::string name = argument.substr(0, split_index); std::string name = argument.substr(0, split_index);
std::string value = argument.substr(split_index+1, std::string::npos); std::string value = argument.substr(split_index+1, std::string::npos);
arguments.selections[name].reset(new Configurable::ListSelection(value)); arguments.selections[name] = std::make_unique<Configurable::ListSelection>(value);
} }
} else { } else {
arguments.file_name = arg; arguments.file_name = arg;
@ -609,7 +609,7 @@ int main(int argc, char *argv[]) {
std::unique_ptr<ActivityObserver> activity_observer; std::unique_ptr<ActivityObserver> activity_observer;
Activity::Source *const activity_source = machine->activity_source(); Activity::Source *const activity_source = machine->activity_source();
if(activity_source) { if(activity_source) {
activity_observer.reset(new ActivityObserver(activity_source, 4.0f / 3.0f)); activity_observer = std::make_unique<ActivityObserver>(activity_source, 4.0f / 3.0f);
} }
// Run the main event loop until the OS tells us to quit. // Run the main event loop until the OS tells us to quit.

View File

@ -50,8 +50,8 @@ void CRT::set_new_timing(int cycles_per_line, int height_of_display, Outputs::Di
// The vertical slywheel has an ideal period of `multiplied_cycles_per_line * height_of_display`, // The vertical slywheel has an ideal period of `multiplied_cycles_per_line * height_of_display`,
// will accept syncs within 1/8th of that (i.e. tolerates 12.5% error) and takes scanlinesVerticalRetraceTime // will accept syncs within 1/8th of that (i.e. tolerates 12.5% error) and takes scanlinesVerticalRetraceTime
// to retrace. // to retrace.
horizontal_flywheel_.reset(new Flywheel(multiplied_cycles_per_line, (millisecondsHorizontalRetraceTime * multiplied_cycles_per_line) >> 6, multiplied_cycles_per_line >> 5)); horizontal_flywheel_ = std::make_unique<Flywheel>(multiplied_cycles_per_line, (millisecondsHorizontalRetraceTime * multiplied_cycles_per_line) >> 6, multiplied_cycles_per_line >> 5);
vertical_flywheel_.reset(new Flywheel(multiplied_cycles_per_line * height_of_display, scanlinesVerticalRetraceTime * multiplied_cycles_per_line, (multiplied_cycles_per_line * height_of_display) >> 3)); vertical_flywheel_ = std::make_unique<Flywheel>(multiplied_cycles_per_line * height_of_display, scanlinesVerticalRetraceTime * multiplied_cycles_per_line, (multiplied_cycles_per_line * height_of_display) >> 3);
// Figure out the divisor necessary to get the horizontal flywheel into a 16-bit range. // Figure out the divisor necessary to get the horizontal flywheel into a 16-bit range.
const int real_clock_scan_period = vertical_flywheel_->get_scan_period(); const int real_clock_scan_period = vertical_flywheel_->get_scan_period();

View File

@ -122,7 +122,7 @@ void TextureTarget::draw(float aspect_ratio, float colour_threshold) const {
"{" "{"
"fragColour = clamp(texture(texID, texCoordVarying), threshold, 1.0);" "fragColour = clamp(texture(texID, texCoordVarying), threshold, 1.0);"
"}"; "}";
pixel_shader_.reset(new Shader(vertex_shader, fragment_shader)); pixel_shader_ = std::make_unique<Shader>(vertex_shader, fragment_shader);
pixel_shader_->bind(); pixel_shader_->bind();
test_gl(glGenVertexArrays, 1, &drawing_vertex_array_); test_gl(glGenVertexArrays, 1, &drawing_vertex_array_);

View File

@ -369,7 +369,7 @@ void ScanTarget::setup_pipeline() {
const bool needs_qam_buffer = (modals_.display_type == DisplayType::CompositeColour || modals_.display_type == DisplayType::SVideo); const bool needs_qam_buffer = (modals_.display_type == DisplayType::CompositeColour || modals_.display_type == DisplayType::SVideo);
if(needs_qam_buffer) { if(needs_qam_buffer) {
if(!qam_chroma_texture_) { if(!qam_chroma_texture_) {
qam_chroma_texture_.reset(new TextureTarget(LineBufferWidth, LineBufferHeight, QAMChromaTextureUnit, GL_NEAREST, false)); qam_chroma_texture_ = std::make_unique<TextureTarget>(LineBufferWidth, LineBufferHeight, QAMChromaTextureUnit, GL_NEAREST, false);
} }
qam_separation_shader_ = qam_separation_shader(); qam_separation_shader_ = qam_separation_shader();

View File

@ -219,16 +219,16 @@ template <typename T> class LowpassSpeaker: public Speaker {
number_of_taps = (number_of_taps * 2) | 1; number_of_taps = (number_of_taps * 2) | 1;
output_buffer_pointer_ = 0; output_buffer_pointer_ = 0;
stepper_.reset(new SignalProcessing::Stepper( stepper_ = std::make_unique<SignalProcessing::Stepper>(
uint64_t(filter_parameters.input_cycles_per_second), uint64_t(filter_parameters.input_cycles_per_second),
uint64_t(filter_parameters.output_cycles_per_second))); uint64_t(filter_parameters.output_cycles_per_second));
filter_.reset(new SignalProcessing::FIRFilter( filter_ = std::make_unique<SignalProcessing::FIRFilter>(
static_cast<unsigned int>(number_of_taps), static_cast<unsigned int>(number_of_taps),
filter_parameters.input_cycles_per_second, filter_parameters.input_cycles_per_second,
0.0, 0.0,
high_pass_frequency, high_pass_frequency,
SignalProcessing::FIRFilter::DefaultAttenuation)); SignalProcessing::FIRFilter::DefaultAttenuation);
input_buffer_.resize(std::size_t(number_of_taps)); input_buffer_.resize(std::size_t(number_of_taps));
input_buffer_depth_ = 0; input_buffer_depth_ = 0;

View File

@ -67,7 +67,7 @@ void Controller::set_expected_bit_length(Time bit_length) {
// this conversion doesn't need to be exact because there's a lot of variation to be taken // this conversion doesn't need to be exact because there's a lot of variation to be taken
// account of in rotation speed, air turbulence, etc, so a direct conversion will do // account of in rotation speed, air turbulence, etc, so a direct conversion will do
int clocks_per_bit = cycles_per_bit.get<int>(); int clocks_per_bit = cycles_per_bit.get<int>();
pll_.reset(new DigitalPhaseLockedLoop(clocks_per_bit, 3)); pll_ = std::make_unique<DigitalPhaseLockedLoop>(clocks_per_bit, 3);
pll_->set_delegate(this); pll_->set_delegate(this);
} }

View File

@ -20,7 +20,7 @@ template <typename T> bool DiskImageHolder<T>::get_is_read_only() {
template <typename T> void DiskImageHolder<T>::flush_tracks() { template <typename T> void DiskImageHolder<T>::flush_tracks() {
if(!unwritten_tracks_.empty()) { if(!unwritten_tracks_.empty()) {
if(!update_queue_) update_queue_.reset(new Concurrency::AsyncTaskQueue); if(!update_queue_) update_queue_ = std::make_unique<Concurrency::AsyncTaskQueue>();
using TrackMap = std::map<Track::Address, std::shared_ptr<Track>>; using TrackMap = std::map<Track::Address, std::shared_ptr<Track>>;
std::shared_ptr<TrackMap> track_copies(new TrackMap); std::shared_ptr<TrackMap> track_copies(new TrackMap);

View File

@ -93,7 +93,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
} }
} }
resulting_track.reset(new PCMTrack(std::move(segments))); resulting_track = std::make_shared<PCMTrack>(std::move(segments));
} else { } else {
PCMSegment segment( PCMSegment segment(
Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(static_cast<unsigned int>(speed_zone_offset)), Encodings::CommodoreGCR::length_of_a_bit_in_time_zone(static_cast<unsigned int>(speed_zone_offset)),
@ -101,7 +101,7 @@ std::shared_ptr<Track> G64::get_track_at_position(Track::Address address) {
track_contents track_contents
); );
resulting_track.reset(new PCMTrack(std::move(segment))); resulting_track = std::make_shared<PCMTrack>(std::move(segment));
} }
// TODO: find out whether it's possible for a G64 to supply only a partial track. I don't think it is, which would make the // TODO: find out whether it's possible for a G64 to supply only a partial track. I don't think it is, which would make the

View File

@ -301,7 +301,7 @@ void Drive::set_track(const std::shared_ptr<Track> &track) {
void Drive::setup_track() { void Drive::setup_track() {
track_ = get_track(); track_ = get_track();
if(!track_) { if(!track_) {
track_.reset(new UnformattedTrack); track_ = std::make_shared<UnformattedTrack>();
} }
float offset = 0.0f; float offset = 0.0f;

View File

@ -85,7 +85,7 @@ std::map<std::size_t, Sector> Storage::Encodings::AppleGCR::sectors_from_segment
// If this is the start of a data section, and at least // If this is the start of a data section, and at least
// one header has been witnessed, start a sector. // one header has been witnessed, start a sector.
if(scanner[2] == data_prologue[2]) { if(scanner[2] == data_prologue[2]) {
new_sector.reset(new Sector); new_sector = std::make_unique<Sector>();
new_sector->data.reserve(710); new_sector->data.reserve(710);
} else { } else {
sector_location = static_cast<std::size_t>(bit % segment.data.size()); sector_location = static_cast<std::size_t>(bit % segment.data.size());

View File

@ -35,7 +35,7 @@ std::map<std::size_t, Storage::Encodings::MFM::Sector> Storage::Encodings::MFM::
break; break;
case Shifter::Token::ID: case Shifter::Token::ID:
new_sector.reset(new Storage::Encodings::MFM::Sector); new_sector = std::make_unique<Storage::Encodings::MFM::Sector>();
is_reading = true; is_reading = true;
start_location = bit_cursor; start_location = bit_cursor;
position = 0; position = 0;