1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Corrects out-of-bounds access.

This commit is contained in:
Thomas Harte 2018-02-27 22:45:45 -05:00
parent d4df101ab6
commit 5b854d51e7

View File

@ -84,25 +84,25 @@ void SN76489::get_samples(std::size_t number_of_samples, std::int16_t *target) {
while(c < number_of_samples) { while(c < number_of_samples) {
bool did_flip = false; bool did_flip = false;
#define step_channel(c) \ #define step_channel(x, s) \
if(channels_[c].counter) channels_[c].counter--;\ if(channels_[x].counter) channels_[x].counter--;\
else {\ else {\
channels_[c].level ^= 1;\ channels_[x].level ^= 1;\
channels_[c].counter = channels_[c].divider;\ channels_[x].counter = channels_[x].divider;\
did_flip = true;\ s;\
} }
step_channel(0); step_channel(0, /**/);
step_channel(1); step_channel(1, /**/);
step_channel(2); step_channel(2, did_flip = true);
#undef step_channel #undef step_channel
if(channels_[c].divider != 0xffff) { if(channels_[3].divider != 0xffff) {
if(channels_[3].counter) channels_[3].counter--; if(channels_[3].counter) channels_[3].counter--;
else { else {
did_flip = true; did_flip = true;
channels_[c].counter = channels_[c].divider; channels_[3].counter = channels_[3].divider;
} }
} }