mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-19 07:31:15 +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);
|
_userPortVIA->run_for_cycles(1);
|
||||||
_keyboardVIA->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();
|
clear_all_keys();
|
||||||
_typer.reset();
|
typer_.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_tape.run_for_cycles(1);
|
_tape.run_for_cycles(1);
|
||||||
|
@ -475,7 +475,7 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
|||||||
update_audio();
|
update_audio();
|
||||||
_tape.run_for_cycles(cycles);
|
_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);
|
if(_plus3) _plus3->run_for_cycles(4*cycles);
|
||||||
|
|
||||||
return 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
|
// 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
|
// do anything until at least the second, regardless of machine
|
||||||
if(!keyboard_read_count_) keyboard_read_count_++;
|
if(!keyboard_read_count_) keyboard_read_count_++;
|
||||||
else if(!_typer->type_next_character())
|
else if(!typer_->type_next_character())
|
||||||
{
|
{
|
||||||
clear_all_keys();
|
clear_all_keys();
|
||||||
_typer.reset();
|
typer_.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,32 +12,32 @@
|
|||||||
using namespace Utility;
|
using namespace Utility;
|
||||||
|
|
||||||
Typer::Typer(const char *string, int delay, int frequency, Delegate *delegate) :
|
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;
|
size_t string_size = strlen(string) + 3;
|
||||||
_string = (char *)malloc(string_size);
|
string_ = (char *)malloc(string_size);
|
||||||
snprintf(_string, strlen(string) + 3, "%c%s%c", Typer::BeginString, string, Typer::EndString);
|
snprintf(string_, strlen(string) + 3, "%c%s%c", Typer::BeginString, string, Typer::EndString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Typer::update(int duration)
|
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())
|
if(!type_next_character())
|
||||||
{
|
{
|
||||||
_delegate->typer_reset(this);
|
delegate_->typer_reset(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_counter += duration;
|
counter_ += duration;
|
||||||
while(_string && _counter > _frequency)
|
while(string_ && counter_ > frequency_)
|
||||||
{
|
{
|
||||||
_counter -= _frequency;
|
counter_ -= frequency_;
|
||||||
if(!type_next_character())
|
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()
|
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;
|
phase_ = 0;
|
||||||
if(!_string[_string_pointer])
|
if(!string_[string_pointer_])
|
||||||
{
|
{
|
||||||
free(_string);
|
free(string_);
|
||||||
_string = nullptr;
|
string_ = nullptr;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_string_pointer++;
|
string_pointer_++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_phase++;
|
phase_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -69,7 +69,7 @@ bool Typer::type_next_character()
|
|||||||
|
|
||||||
Typer::~Typer()
|
Typer::~Typer()
|
||||||
{
|
{
|
||||||
free(_string);
|
free(string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - Delegate
|
#pragma mark - Delegate
|
||||||
|
@ -35,31 +35,31 @@ class Typer {
|
|||||||
const char EndString = 0x03; // i.e. ASCII end of text
|
const char EndString = 0x03; // i.e. ASCII end of text
|
||||||
|
|
||||||
private:
|
private:
|
||||||
char *_string;
|
char *string_;
|
||||||
int _frequency;
|
int frequency_;
|
||||||
int _counter;
|
int counter_;
|
||||||
int _phase;
|
int phase_;
|
||||||
Delegate *_delegate;
|
Delegate *delegate_;
|
||||||
size_t _string_pointer;
|
size_t string_pointer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TypeRecipient: public Typer::Delegate {
|
class TypeRecipient: public Typer::Delegate {
|
||||||
public:
|
public:
|
||||||
void set_typer_for_string(const char *string)
|
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)
|
void typer_reset(Typer *typer)
|
||||||
{
|
{
|
||||||
clear_all_keys();
|
clear_all_keys();
|
||||||
_typer.reset();
|
typer_.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int get_typer_delay() { return 0; }
|
virtual int get_typer_delay() { return 0; }
|
||||||
virtual int get_typer_frequency() { return 0; }
|
virtual int get_typer_frequency() { return 0; }
|
||||||
std::unique_ptr<Typer> _typer;
|
std::unique_ptr<Typer> typer_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user