Create the FakeGPIO.hpp to be used as Mock for testing and Update the timing for the delays and also create the Write method on the HAL to choreograph the writing process in the YMF262

This commit is contained in:
Gustavo Henrique Santos Souza de Miranda 2026-06-03 12:23:00 -03:00
parent 7898563f39
commit 8e4fceec7e
3 changed files with 42 additions and 19 deletions

View File

@ -1,19 +0,0 @@
#ifndef FAKE_GPIO_HPP
#define FAKE_GPIO_HPP
#include <cstdint>
#include "GPIO.hpp"
struct FakeGpio {
void set_data_bus(uint8_t val){}
void set_a0(Port port){}
void set_a1(Bank address_bank){}
void set_cs(State state){}
void set_wr(State state){}
void set_ic(State state){}
void set_rd(State state){}
void delay_ticks(uint32_t n){}
};
#endif

View File

@ -0,0 +1,20 @@
#ifndef YMF262_HAL_H
#define YMF262_HAL_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef struct YMF262_HAL_Handle YMF262_HAL_Handle;
YMF262_HAL_Handle* YMF262_HAL_Create(uint32_t opl_clock, uint32_t cpu_clock);
void YMF262_HAL_Destroy(YMF262_HAL_Handle* handle);
#ifdef __cplusplus
}
#endif
#endif

22
Tests/FakeGPIO.hpp Normal file
View File

@ -0,0 +1,22 @@
#ifndef FAKE_GPIO_HPP
#define FAKE_GPIO_HPP
#include <cstdint>
#include <vector>
#include <string>
#include "GPIO.hpp"
struct FakeGpio {
std::vector<std::string> log;
void set_data_bus(uint8_t val) { log.push_back("data " + std::to_string(val)); }
void set_a0(Port port) { log.push_back(port == Port::ADDRESS ? "a0 ADDR" : "a0 DATA"); }
void set_a1(Bank bank) { log.push_back(bank == Bank::BANK_0 ? "a1 B0" : "a1 B1"); }
void set_cs(State s) { log.push_back(s == State::ACTIVE ? "cs ON" : "cs OFF"); }
void set_wr(State s) { log.push_back(s == State::ACTIVE ? "wr ON" : "wr OFF"); }
void set_ic(State s) { log.push_back(s == State::ACTIVE ? "ic ON" : "ic OFF"); }
void set_rd(State s) { log.push_back(s == State::ACTIVE ? "rd ON" : "rd OFF"); }
void delay_ticks(uint32_t n) { log.push_back("delay " + std::to_string(n)); }
};
#endif