1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-29 15:29:36 +00:00

Fixed tone channels; made an attempt at loading PRGs that are supposed to go into RAM.

This commit is contained in:
Thomas Harte 2016-06-13 21:49:59 -04:00
parent efcb196ef7
commit fdc854c0c2
4 changed files with 23 additions and 9 deletions

View File

@ -312,30 +312,32 @@ void MOS6560::set_graphics_value(uint8_t value, uint8_t colour_value)
void MOS6560::update_audio()
{
_speaker.run_for_cycles(_cycles_since_speaker_update >> 4);
_cycles_since_speaker_update &= 15;
_speaker.run_for_cycles(_cycles_since_speaker_update >> 2);
_cycles_since_speaker_update &= 3;
}
#pragma mark - Audio
MOS6560Speaker::MOS6560Speaker()
MOS6560Speaker::MOS6560Speaker() :
_volume(0),
_control_registers{0, 0, 0, 0},
_shift_registers{0, 0, 0, 0},
_counters{0, 1, 2, 0}
{
}
void MOS6560Speaker::set_volume(uint8_t volume)
{
_volume = volume;
printf("Volume: %d\n", volume);
}
void MOS6560Speaker::set_control(int channel, uint8_t value)
{
_control_registers[channel] = value;
printf("Control %02x: %d\n", channel, value);
}
#define shift(r) _shift_registers[r] = (uint8_t)((_shift_registers[r] << 1) | (((_shift_registers[r]^0x80)&_control_registers[r]) >> 7));
#define update(r, m) _counters[r]++; if((_counters[r] >> m) == 0xff) { shift(r); _counters[r] = _control_registers[r]&0x7f; }
#define update(r, m) _counters[r]++; if((_counters[r] >> m) == 0x7f) { shift(r); _counters[r] = _control_registers[r]&0x7f; }
void MOS6560Speaker::get_samples(unsigned int number_of_samples, int16_t *target)
{
@ -360,3 +362,6 @@ void MOS6560Speaker::skip_samples(unsigned int number_of_samples)
update(2, 0);
}
}
#undef shift
#undef update

View File

@ -40,6 +40,8 @@ class MOS6560 {
uint16_t get_address();
void set_graphics_value(uint8_t value, uint8_t colour_value);
void synchronise() { update_audio(); }
void set_register(int address, uint8_t value);
uint8_t get_register(int address);

View File

@ -123,7 +123,14 @@ void Machine::add_prg(size_t length, const uint8_t *data)
{
_rom_address = (uint16_t)(data[0] | (data[1] << 8));
_rom_length = (uint16_t)(length - 2);
_rom = new uint8_t[length - 2];
memcpy(_rom, &data[2], length - 2);
if(_rom_address >= 0x1000 && _rom_address+_rom_length < 0x2000)
{
memcpy(&_screenMemory[_rom_address - 0x1000], &data[2], length - 2);
}
else
{
_rom = new uint8_t[length - 2];
memcpy(_rom, &data[2], length - 2);
}
}
}

View File

@ -100,7 +100,7 @@ class Machine: public CPU6502::Processor<Machine>, public CRTMachine::Machine, p
// to satisfy CPU6502::Processor
unsigned int perform_bus_operation(CPU6502::BusOperation operation, uint16_t address, uint8_t *value);
void synchronise() {}
void synchronise() { _mos6560->synchronise(); }
// to satisfy CRTMachine::Machine
virtual void setup_output(float aspect_ratio);