1#ifndef YAZE_APP_EMU_SPC700_H
2#define YAZE_APP_EMU_SPC700_H
7#include <unordered_map>
22 virtual uint8_t
read(uint16_t address)
const = 0;
24 virtual void write(uint16_t address, uint8_t value) = 0;
39 uint8_t
read(uint16_t address)
const override {
47 void write(uint16_t address, uint8_t value)
override {
56 std::function<void(uint16_t, uint8_t)>
write;
57 std::function<uint8_t(uint16_t)>
read;
58 std::function<void(
bool)>
idle;
75 std::vector<std::string>
log_;
90 0xCD, 0xEF, 0xBD, 0xE8, 0x00, 0xC6, 0x1D, 0xD0, 0xFC, 0x8F, 0xAA,
91 0xF4, 0x8F, 0xBB, 0xF5, 0x78, 0xCC, 0xF4, 0xD0, 0xFB, 0x2F, 0x19,
92 0xEB, 0xF4, 0xD0, 0xFC, 0x7E, 0xF4, 0xD0, 0x0B, 0xE4, 0xF5, 0xCB,
93 0xF4, 0xD7, 0x00, 0xFC, 0xD0, 0xF3, 0xAB, 0x01, 0x10, 0xEF, 0x7E,
94 0xF4, 0x10, 0xEB, 0xBA, 0xF6, 0xDA, 0x00, 0xBA, 0xF4, 0xC4, 0xF4,
95 0xDD, 0x5D, 0xD0, 0xDB, 0x1F, 0x00, 0x00, 0xC0, 0xFF};
105 uint16_t
PC = 0xFFC0;
121 return (flags.
N << 7) | (flags.
V << 6) | (flags.
P << 5) | (flags.
B << 4) |
122 (flags.
H << 3) | (flags.
I << 2) | (flags.
Z << 1) | (flags.
C);
127 flags.
N = (
byte & 0x80) >> 7;
128 flags.
V = (
byte & 0x40) >> 6;
129 flags.
P = (
byte & 0x20) >> 5;
130 flags.
B = (
byte & 0x10) >> 4;
131 flags.
H = (
byte & 0x08) >> 3;
132 flags.
I = (
byte & 0x04) >> 2;
133 flags.
Z = (
byte & 0x02) >> 1;
134 flags.
C = (
byte & 0x01);
138 void Reset(
bool hard =
false);
149 uint8_t adrl = address;
150 uint8_t adrh = address + 1;
163 return low | (high << 8);
176 void write(uint16_t address, uint8_t value) {
214 uint16_t
dp_dp(uint8_t* src);
216 uint16_t
ind_ind(uint8_t* srcVal);
217 uint16_t
dp_word(uint16_t* low);
224 uint16_t
dp_imm(uint8_t* srcVal);
252 void MOV_ADDR(uint16_t address, uint8_t operand);
260 void ADCM(uint16_t& dest, uint8_t operand);
263 void SBCM(uint16_t& dest, uint8_t operand);
267 void CMPM(uint16_t dst, uint8_t value);
271 void ANDM(uint16_t dest, uint8_t operand);
273 void OR(uint16_t
adr);
274 void ORM(uint16_t dest, uint8_t operand);
277 void EORM(uint16_t dest, uint8_t operand);
279 void ASL(uint16_t operand);
282 void ROL(uint16_t operand);
285 void XCN(uint8_t operand,
bool isImmediate =
false);
287 void DEC(uint16_t operand);
288 void MOVW(uint16_t& dest, uint16_t operand);
289 void INCW(uint16_t& operand);
290 void DECW(uint16_t& operand);
291 void ADDW(uint16_t& dest, uint16_t operand);
292 void SUBW(uint16_t& dest, uint16_t operand);
293 void CMPW(uint16_t operand);
294 void MUL(uint8_t operand);
295 void DIV(uint8_t operand);
296 void BRA(int8_t offset);
297 void BEQ(int8_t offset);
298 void BNE(int8_t offset);
299 void BCS(int8_t offset);
300 void BCC(int8_t offset);
301 void BVS(int8_t offset);
302 void BVC(int8_t offset);
303 void BMI(int8_t offset);
304 void BPL(int8_t offset);
305 void BBS(uint8_t bit, uint8_t operand);
306 void BBC(uint8_t bit, uint8_t operand);
307 void JMP(uint16_t address);
308 void CALL(uint16_t address);
309 void PCALL(uint8_t offset);
310 void TCALL(uint8_t offset);
314 void PUSH(uint8_t operand);
315 void POP(uint8_t& operand);
316 void SET1(uint8_t bit, uint8_t& operand);
317 void CLR1(uint8_t bit, uint8_t& operand);
318 void TSET1(uint8_t bit, uint8_t& operand);
319 void TCLR1(uint8_t bit, uint8_t& operand);
320 void AND1(uint8_t bit, uint8_t& operand);
321 void OR1(uint8_t bit, uint8_t& operand);
322 void EOR1(uint8_t bit, uint8_t& operand);
323 void NOT1(uint8_t bit, uint8_t& operand);
324 void MOV1(uint8_t bit, uint8_t& operand);
AudioRamImpl is an implementation of the AudioRam interface.
uint8_t operator[](uint16_t address) const
void write(uint16_t address, uint8_t value) override
uint8_t read(uint16_t address) const override
uint8_t & mutable_read(uint16_t address) override
static const int ARAM_SIZE
std::vector< uint8_t > ram
AudioRam is an interface for the Audio RAM used by the SPC700.
uint8_t operator[](uint16_t address)
virtual uint8_t & mutable_read(uint16_t address)=0
virtual void write(uint16_t address, uint8_t value)=0
virtual uint8_t read(uint16_t address) const =0
virtual ~AudioRam()=default
The Spc700 class represents the SPC700 processor.
void PUSH(uint8_t operand)
void ANDM(uint16_t dest, uint8_t operand)
uint16_t dp_word(uint16_t *low)
void push_word(uint16_t value)
void EORM(uint16_t dest, uint8_t operand)
uint16_t addr_plus_i_indexed()
void JMP(uint16_t address)
void SET1(uint8_t bit, uint8_t &operand)
void TCLR1(uint8_t bit, uint8_t &operand)
void CALL(uint16_t address)
uint16_t dp_dp(uint8_t *src)
void POP(uint8_t &operand)
void LogInstruction(uint16_t initial_pc, uint8_t opcode)
uint16_t dp_plus_x_indirect()
Spc700(ApuCallbacks &callbacks)
void ExecuteInstructions(uint8_t opcode)
void MOV1(uint8_t bit, uint8_t &operand)
void XCN(uint8_t operand, bool isImmediate=false)
void ROL(uint16_t operand)
void INCW(uint16_t &operand)
void DEC(uint16_t operand)
void MOVW(uint16_t &dest, uint16_t operand)
Flags ByteToFlags(uint8_t byte)
void DIV(uint8_t operand)
void CMPM(uint16_t dst, uint8_t value)
void AND1(uint8_t bit, uint8_t &operand)
void TCALL(uint8_t offset)
uint16_t read_word(uint16_t address)
void PCALL(uint8_t offset)
void SBCM(uint16_t &dest, uint8_t operand)
void MOV_ADDR(uint16_t address, uint8_t operand)
uint8_t FlagsToByte(Flags flags)
uint16_t dp_indirect_plus_y()
void DECW(uint16_t &operand)
void Reset(bool hard=false)
void ADCM(uint16_t &dest, uint8_t operand)
void push_byte(uint8_t value)
void EOR1(uint8_t bit, uint8_t &operand)
void SUBW(uint16_t &dest, uint16_t operand)
void CLR1(uint8_t bit, uint8_t &operand)
void BBS(uint8_t bit, uint8_t operand)
uint8_t abs_bit(uint16_t *adr)
void CMPW(uint16_t operand)
uint16_t ind_ind(uint8_t *srcVal)
void ASL(uint16_t operand)
uint16_t dp_imm(uint8_t *srcVal)
void NOT1(uint8_t bit, uint8_t &operand)
void MUL(uint8_t operand)
const uint8_t ipl_rom_[64]
std::vector< std::string > log_
void OR1(uint8_t bit, uint8_t &operand)
void BBC(uint8_t bit, uint8_t operand)
void TSET1(uint8_t bit, uint8_t &operand)
void write(uint16_t address, uint8_t value)
void DoBranch(uint8_t value, bool check)
void ORM(uint16_t dest, uint8_t operand)
uint16_t ReadOpcodeWord()
uint8_t read(uint16_t address)
void ADDW(uint16_t &dest, uint16_t operand)
struct yaze::app::emu::audio::ApuCallbacks ApuCallbacks
std::function< void(uint16_t, uint8_t)> write
std::function< uint8_t(uint16_t)> read
std::function< void(bool)> idle