mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 20:29:42 +00:00
Switched the typer to postfix underscores.
This commit is contained in:
parent
36bc558798
commit
2003b514aa
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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> _typer;
|
||||
std::unique_ptr<Typer> typer_;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user