<commit_before>#pragma once

#include "cpu.h"
#include "mmu.h"
#include "ram.h"
#include "cartrige.h"
#include "interrupts.h"
#include "gpu.h"
#include "timer.h"
#include "joypad.h"
#include "apu.h"
#include "debugger.h"

struct external_callbacks
{
	function<void(const u8*, u32)> save_ram;
	function<void(std::chrono::seconds, const u8*, u32)> save_rtc;

	function<void(const u32*)> draw_frame;

	function<u8**(u8**, u32)> swap_sample_buffer;
	function<void(bool)> audio_control;
	function<void()> audio_synchronize; //TODO: reserved for future use
};

struct TestReader final : public IMemory
{
	u8 a;

	TestReader() : a() {}

	u8 read_byte(u16 adress, u32 unused) override
	{
		UNUSED(adress);
		UNUSED(unused);

		return 0;
		//return 0xFF;
	}

	void write_byte(u16 adress, u8 val, u32 unused) override
	{
		UNUSED(unused);

		if (adress == 0xFF01)
			a = val;

		if (adress == 0xFF02 && val == 0x81)
			printf("%c", a);
	}
};

struct SpeedSwitch : public IMemory
{
	bool double_speed = false;
	bool switch_speed = false;

	u8 read_byte(u16 adress, u32 unused) override
	{
		UNUSED(unused);

		if (adress == 0xFF4D)
		{
			auto ret = change_bit(0xFF, double_speed, 7);
			return change_bit(ret, switch_speed, 0);
		}

		else
			return 0xFF;
	}

	void write_byte(u16 adress, u8 val, u32 key) override
	{
		if (adress == 0xFF4D)
		{
			if (key == 0xFFFFFFFF && val == 0xFF)
			{
				switch_speed = false;
				double_speed = !double_speed;
			}

			else
				switch_speed = check_bit(val, 0);
		}

		//else ignore
	}
<commit_msg>added reset for SpeedSwitch<commit_after>#pragma once

#include "cpu.h"
#include "mmu.h"
#include "ram.h"
#include "cartrige.h"
#include "interrupts.h"
#include "gpu.h"
#include "timer.h"
#include "joypad.h"
#include "apu.h"
#include "debugger.h"

struct external_callbacks
{
	function<void(const u8*, u32)> save_ram;
	function<void(std::chrono::seconds, const u8*, u32)> save_rtc;

	function<void(const u32*)> draw_frame;

	function<u8**(u8**, u32)> swap_sample_buffer;
	function<void(bool)> audio_control;
	function<void()> audio_synchronize; //TODO: reserved for future use
};

struct TestReader final : public IMemory
{
	u8 a;

	TestReader() : a() {}

	u8 read_byte(u16 adress, u32 unused) override
	{
		UNUSED(adress);
		UNUSED(unused);

		return 0;
		//return 0xFF;
	}

	void write_byte(u16 adress, u8 val, u32 unused) override
	{
		UNUSED(unused);

		if (adress == 0xFF01)
			a = val;

		if (adress == 0xFF02 && val == 0x81)
			printf("%c", a);
	}
};

struct SpeedSwitch : public IMemory
{
	bool double_speed = false;
	bool switch_speed = false;

	u8 read_byte(u16 adress, u32 unused) override
	{
		UNUSED(unused);

		if (adress == 0xFF4D)
		{
			auto ret = change_bit(0xFF, double_speed, 7);
			return change_bit(ret, switch_speed, 0);
		}

		else
			return 0xFF;
	}

	void write_byte(u16 adress, u8 val, u32 key) override
	{
		if (adress == 0xFF4D)
		{
			if (key == 0xFFFFFFFF && val == 0xFF)
			{
				switch_speed = false;
				double_speed = !double_speed;
			}

			else
				switch_speed = check_bit(val, 0);
		}

		//else ignore
	}

	void reset()
	{
		double_speed = false;
		switch_speed = false;
	}

{'fraction_non_alphanumeric': 0.1412663060769965, 'fraction_numerical': 0.034998409163219855, 'mean_word_length': 3.836923076923077, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '1319951', 'n_tokens_mistral': 1405, 'n_tokens_neox': 1241, 'n_words': 305}