mirror of
https://github.com/TomHarte/CLK.git
synced 2024-11-26 08:49:37 +00:00
Register writes now reach the audio thread.
This commit is contained in:
parent
4b9fe805e9
commit
f3c7c11772
@ -31,15 +31,11 @@ void GLU::set_data(uint8_t data) {
|
|||||||
pending_store_write_ = (pending_store_write_ + 1) % (StoreBufferSize - 1);
|
pending_store_write_ = (pending_store_write_ + 1) % (StoreBufferSize - 1);
|
||||||
} else {
|
} else {
|
||||||
// Register access.
|
// Register access.
|
||||||
switch(address_ & 0xe0) {
|
const auto address = address_; // To make sure I don't inadvertently 'capture' address_.
|
||||||
case 0x00:
|
local_.set_register(address, data);
|
||||||
// oscillators_[address_ & 0x1f].velocity = (oscillators_[address_ & 0x1f].velocity & 0xff00) | (data << 8);
|
audio_queue_.defer([this, address, data] () {
|
||||||
break;
|
remote_.set_register(address, data);
|
||||||
case 0x20:
|
});
|
||||||
// oscillators_[address_ & 0x1f].velocity = (oscillators_[address_ & 0x1f].velocity & 0x00ff) | (data << 8);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
// printf("Register write %04x\n", address_);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(local_.control & 0x20) {
|
if(local_.control & 0x20) {
|
||||||
@ -47,7 +43,49 @@ void GLU::set_data(uint8_t data) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GLU::EnsoniqState::set_register(uint16_t address, uint8_t value) {
|
||||||
|
switch(address & 0xe0) {
|
||||||
|
case 0x00:
|
||||||
|
oscillators[address & 0x1f].velocity = uint16_t((oscillators[address & 0x1f].velocity & 0xff00) | (value << 0));
|
||||||
|
break;
|
||||||
|
case 0x20:
|
||||||
|
oscillators[address & 0x1f].velocity = uint16_t((oscillators[address & 0x1f].velocity & 0x00ff) | (value << 8));
|
||||||
|
break;
|
||||||
|
case 0x40:
|
||||||
|
oscillators[address & 0x1f].volume = value;
|
||||||
|
break;
|
||||||
|
case 0x60:
|
||||||
|
/* Does setting the last sample make any sense? */
|
||||||
|
break;
|
||||||
|
case 0x80:
|
||||||
|
oscillators[address & 0x1f].address = value;
|
||||||
|
break;
|
||||||
|
case 0xa0:
|
||||||
|
oscillators[address & 0x1f].control = value;
|
||||||
|
break;
|
||||||
|
case 0xc0:
|
||||||
|
oscillators[address & 0x1f].table_size = value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
switch(address & 0xff) {
|
||||||
|
case 0xe0:
|
||||||
|
/* Does setting the interrupt register really make any sense? */
|
||||||
|
interrupt_state = value;
|
||||||
|
break;
|
||||||
|
case 0xe1:
|
||||||
|
oscillator_count = (value >> 1) ? (value >> 1) : 1;
|
||||||
|
break;
|
||||||
|
case 0xe2:
|
||||||
|
/* Writing to the analogue to digital input definitely makes no sense. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t GLU::get_data() {
|
uint8_t GLU::get_data() {
|
||||||
|
// TODO: all of this. From local_, with just-in-time generation of the data sample and AD values.
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +75,14 @@ class GLU: public Outputs::Speaker::SampleSource {
|
|||||||
uint8_t address;
|
uint8_t address;
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
uint8_t table_size;
|
uint8_t table_size;
|
||||||
} oscillators_[32];
|
} oscillators[32];
|
||||||
|
|
||||||
// TODO: do all of these need to be on the audio thread?
|
// TODO: do all of these need to be on the audio thread?
|
||||||
uint8_t control;
|
uint8_t control;
|
||||||
uint8_t interrupt_state;
|
uint8_t interrupt_state;
|
||||||
uint8_t oscillator_enable;
|
int oscillator_count;
|
||||||
|
|
||||||
|
void set_register(uint16_t address, uint8_t value);
|
||||||
} local_, remote_;
|
} local_, remote_;
|
||||||
|
|
||||||
// Functions to update an EnsoniqState; these don't belong to the state itself
|
// Functions to update an EnsoniqState; these don't belong to the state itself
|
||||||
|
Loading…
Reference in New Issue
Block a user