<commit_before>//
//  Audio.cpp
//  Clock Signal
//
//  Created by <NAME> on 09/11/2021.
//  Copyright © 2021 <NAME>. All rights reserved.
//

#include "Audio.hpp"

#include "Flags.hpp"

#define LOG_PREFIX "[Audio] "
#include "../../Outputs/Log.hpp"

#include <cassert>

using namespace Amiga;

bool Audio::advance_dma(int channel) {
	switch(channels_[channel].state) {
		case Channel::State::WaitingForDMA:
			set_data(channel, ram_[pointer_[size_t(channel)]]);
		return true;
		case Channel::State::WaitingForDummyDMA:
			channels_[channel].has_data = true;
		return true;
		default:
		return false;
	}
}

void Audio::set_length(int channel, uint16_t length) {
	assert(channel >= 0 && channel < 4);
	channels_[channel].length = length;
}<commit_msg>Avoids over-greedy DMA.<commit_after>//
//  Audio.cpp
//  Clock Signal
//
//  Created by <NAME> on 09/11/2021.
//  Copyright © 2021 <NAME>. All rights reserved.
//

#include "Audio.hpp"

#include "Flags.hpp"

#define LOG_PREFIX "[Audio] "
#include "../../Outputs/Log.hpp"

#include <cassert>

using namespace Amiga;

bool Audio::advance_dma(int channel) {
	switch(channels_[channel].state) {
		case Channel::State::WaitingForDMA:
			if(!channels_[channel].has_data) {
				set_data(channel, ram_[pointer_[size_t(channel)]]);
				return true;
			}
		break;

		case Channel::State::WaitingForDummyDMA:
			if(!channels_[channel].has_data) {
				channels_[channel].has_data = true;
				return true;
			}
		break;

		default: break;
	}

	return false;
}

void Audio::set_length(int channel, uint16_t length) {
	assert(channel >= 0 && channel < 4);
	channels_[channel].length = length;
}
{'fraction_non_alphanumeric': 0.15757204169221337, 'fraction_numerical': 0.019619865113427344, 'mean_word_length': 4.006134969325154, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3708600', 'n_tokens_mistral': 631, 'n_tokens_neox': 564, 'n_words': 127}