From 2003b514aa54b742bd39dea0cc20f643cc46a200 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 3 Dec 2016 10:55:50 -0500 Subject: [PATCH] Switched the typer to postfix underscores. --- Machines/Commodore/Vic-20/Vic20.cpp | 6 ++--- Machines/Electron/Electron.cpp | 2 +- Machines/Oric/Oric.cpp | 6 ++--- Machines/Typer.cpp | 38 ++++++++++++++--------------- Machines/Typer.hpp | 18 +++++++------- 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/Machines/Commodore/Vic-20/Vic20.cpp b/Machines/Commodore/Vic-20/Vic20.cpp index 48617d124..872b4ce64 100644 --- a/Machines/Commodore/Vic-20/Vic20.cpp +++ b/Machines/Commodore/Vic-20/Vic20.cpp @@ -159,12 +159,12 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin _userPortVIA->run_for_cycles(1); _keyboardVIA->run_for_cycles(1); - if(_typer && operation == CPU6502::BusOperation::ReadOpcode && address == 0xEB1E) + if(typer_ && operation == CPU6502::BusOperation::ReadOpcode && address == 0xEB1E) { - if(!_typer->type_next_character()) + if(!typer_->type_next_character()) { clear_all_keys(); - _typer.reset(); + typer_.reset(); } } _tape.run_for_cycles(1); diff --git a/Machines/Electron/Electron.cpp b/Machines/Electron/Electron.cpp index 636c3faab..3df84e99a 100644 --- a/Machines/Electron/Electron.cpp +++ b/Machines/Electron/Electron.cpp @@ -475,7 +475,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin update_audio(); _tape.run_for_cycles(cycles); - if(_typer) _typer->update((int)cycles); + if(typer_) typer_->update((int)cycles); if(_plus3) _plus3->run_for_cycles(4*cycles); return cycles; diff --git a/Machines/Oric/Oric.cpp b/Machines/Oric/Oric.cpp index 724563faa..037519eb2 100644 --- a/Machines/Oric/Oric.cpp +++ b/Machines/Oric/Oric.cpp @@ -140,15 +140,15 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin } } - if(_typer && address == scan_keyboard_address_ && operation == CPU6502::BusOperation::ReadOpcode) + if(typer_ && address == scan_keyboard_address_ && operation == CPU6502::BusOperation::ReadOpcode) { // the Oric 1 misses any key pressed on the very first entry into the read keyboard routine, so don't // do anything until at least the second, regardless of machine if(!keyboard_read_count_) keyboard_read_count_++; - else if(!_typer->type_next_character()) + else if(!typer_->type_next_character()) { clear_all_keys(); - _typer.reset(); + typer_.reset(); } } diff --git a/Machines/Typer.cpp b/Machines/Typer.cpp index 43a527b0d..a6a502972 100644 --- a/Machines/Typer.cpp +++ b/Machines/Typer.cpp @@ -12,32 +12,32 @@ using namespace Utility; Typer::Typer(const char *string, int delay, int frequency, Delegate *delegate) : - _counter(-delay), _frequency(frequency), _string_pointer(0), _delegate(delegate), _phase(0) + counter_(-delay), frequency_(frequency), string_pointer_(0), delegate_(delegate), phase_(0) { size_t string_size = strlen(string) + 3; - _string = (char *)malloc(string_size); - snprintf(_string, strlen(string) + 3, "%c%s%c", Typer::BeginString, string, Typer::EndString); + string_ = (char *)malloc(string_size); + snprintf(string_, strlen(string) + 3, "%c%s%c", Typer::BeginString, string, Typer::EndString); } void Typer::update(int duration) { - if(_string) + if(string_) { - if(_counter < 0 && _counter + duration >= 0) + if(counter_ < 0 && counter_ + duration >= 0) { if(!type_next_character()) { - _delegate->typer_reset(this); + delegate_->typer_reset(this); } } - _counter += duration; - while(_string && _counter > _frequency) + counter_ += duration; + while(string_ && counter_ > frequency_) { - _counter -= _frequency; + counter_ -= frequency_; if(!type_next_character()) { - _delegate->typer_reset(this); + delegate_->typer_reset(this); } } } @@ -45,23 +45,23 @@ void Typer::update(int duration) bool Typer::type_next_character() { - if(_string == nullptr) return false; + if(string_ == nullptr) return false; - if(_delegate->typer_set_next_character(this, _string[_string_pointer], _phase)) + if(delegate_->typer_set_next_character(this, string_[string_pointer_], phase_)) { - _phase = 0; - if(!_string[_string_pointer]) + phase_ = 0; + if(!string_[string_pointer_]) { - free(_string); - _string = nullptr; + free(string_); + string_ = nullptr; return false; } - _string_pointer++; + string_pointer_++; } else { - _phase++; + phase_++; } return true; @@ -69,7 +69,7 @@ bool Typer::type_next_character() Typer::~Typer() { - free(_string); + free(string_); } #pragma mark - Delegate diff --git a/Machines/Typer.hpp b/Machines/Typer.hpp index 4a5958414..2604a6530 100644 --- a/Machines/Typer.hpp +++ b/Machines/Typer.hpp @@ -35,31 +35,31 @@ class Typer { const char EndString = 0x03; // i.e. ASCII end of text private: - char *_string; - int _frequency; - int _counter; - int _phase; - Delegate *_delegate; - size_t _string_pointer; + char *string_; + int frequency_; + int counter_; + int phase_; + Delegate *delegate_; + size_t string_pointer_; }; class TypeRecipient: public Typer::Delegate { public: void set_typer_for_string(const char *string) { - _typer.reset(new Typer(string, get_typer_delay(), get_typer_frequency(), this)); + typer_.reset(new Typer(string, get_typer_delay(), get_typer_frequency(), this)); } void typer_reset(Typer *typer) { clear_all_keys(); - _typer.reset(); + typer_.reset(); } protected: virtual int get_typer_delay() { return 0; } virtual int get_typer_frequency() { return 0; } - std::unique_ptr _typer; + std::unique_ptr typer_; }; }