mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-23 20:29:42 +00:00
Resolved some errors.
This commit is contained in:
parent
49e89a4bcb
commit
439d452e23
@ -138,9 +138,8 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
case 0x6:
|
||||
if(!isReadOperation(operation))
|
||||
{
|
||||
if(_speaker.is_enabled)
|
||||
update_audio();
|
||||
_speaker.divider = *value;
|
||||
update_audio();
|
||||
_speaker.set_divider(*value);
|
||||
}
|
||||
break;
|
||||
case 0x7:
|
||||
@ -164,10 +163,10 @@ unsigned int Machine::perform_bus_operation(CPU6502::BusOperation operation, uin
|
||||
|
||||
// update speaker mode
|
||||
bool new_speaker_is_enabled = (*value & 6) == 2;
|
||||
if(new_speaker_is_enabled != _speaker.is_enabled)
|
||||
if(new_speaker_is_enabled != _speaker.get_is_enabled())
|
||||
{
|
||||
update_audio();
|
||||
_speaker.is_enabled = new_speaker_is_enabled;
|
||||
_speaker.set_is_enabled(new_speaker_is_enabled);
|
||||
}
|
||||
|
||||
// TODO: tape mode, tape motor, caps lock LED
|
||||
@ -496,5 +495,23 @@ void Machine::set_key_state(Key key, bool isPressed)
|
||||
|
||||
void Machine::Speaker::get_sample_range(uint64_t start_time, int number_of_samples, uint16_t *target)
|
||||
{
|
||||
*target = 0;
|
||||
if(!_is_enabled)
|
||||
{
|
||||
*target = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
*target = ((start_time / _divider)&1) ? 255 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Machine::Speaker::set_divider(uint8_t divider)
|
||||
{
|
||||
_divider = divider;
|
||||
_time_base = 0;
|
||||
}
|
||||
|
||||
void Machine::Speaker::set_is_enabled(bool is_enabled)
|
||||
{
|
||||
_is_enabled = false;
|
||||
}
|
||||
|
@ -98,10 +98,17 @@ class Machine: public CPU6502::Processor<Machine> {
|
||||
|
||||
class Speaker: public ::Outputs::Filter<Speaker> {
|
||||
public:
|
||||
uint8_t divider;
|
||||
bool is_enabled;
|
||||
void set_divider(uint8_t divider);
|
||||
|
||||
void set_is_enabled(bool is_enabled);
|
||||
inline bool get_is_enabled() { return _is_enabled; }
|
||||
|
||||
void get_sample_range(uint64_t start_time, int number_of_samples, uint16_t *target);
|
||||
|
||||
private:
|
||||
uint8_t _divider;
|
||||
bool _is_enabled;
|
||||
|
||||
} _speaker;
|
||||
};
|
||||
|
||||
|
@ -78,7 +78,7 @@ template <class T> class Filter: public Speaker {
|
||||
while(input_cycles--)
|
||||
{
|
||||
// get a sample for the current location
|
||||
static_cast<T *>(this)->get_sample_range(time_base, 1, &_buffer_in_progress[_buffer_in_progress_pointer]);
|
||||
static_cast<T *>(this)->get_sample_range(_time_base, 1, &_buffer_in_progress[_buffer_in_progress_pointer]);
|
||||
_buffer_in_progress_pointer++;
|
||||
|
||||
// announce to delegate if full
|
||||
@ -92,12 +92,12 @@ template <class T> class Filter: public Speaker {
|
||||
}
|
||||
|
||||
// determine how many source samples to step
|
||||
time_base += _stepper->update();
|
||||
_time_base += _stepper->update();
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
uint64_t time_base;
|
||||
uint64_t _time_base;
|
||||
|
||||
private:
|
||||
SignalProcessing::Stepper *_stepper;
|
||||
|
Loading…
Reference in New Issue
Block a user