1#ifndef YAZE_APP_EMU_SPC700_H
2#define YAZE_APP_EMU_SPC700_H
19 virtual uint8_t
read(uint16_t address)
const = 0;
21 virtual void write(uint16_t address, uint8_t value) = 0;
36 uint8_t
read(uint16_t address)
const override {
44 void write(uint16_t address, uint8_t value)
override {
53 std::function<void(uint16_t, uint8_t)>
write;
54 std::function<uint8_t(uint16_t)>
read;
55 std::function<void(
bool)>
idle;
72 std::vector<std::string>
log_;
87 0xCD, 0xEF, 0xBD, 0xE8, 0x00, 0xC6, 0x1D, 0xD0, 0xFC, 0x8F, 0xAA,
88 0xF4, 0x8F, 0xBB, 0xF5, 0x78, 0xCC, 0xF4, 0xD0, 0xFB, 0x2F, 0x19,
89 0xEB, 0xF4, 0xD0, 0xFC, 0x7E, 0xF4, 0xD0, 0x0B, 0xE4, 0xF5, 0xCB,
90 0xF4, 0xD7, 0x00, 0xFC, 0xD0, 0xF3, 0xAB, 0x01, 0x10, 0xEF, 0x7E,
91 0xF4, 0x10, 0xEB, 0xBA, 0xF6, 0xDA, 0x00, 0xBA, 0xF4, 0xC4, 0xF4,
92 0xDD, 0x5D, 0xD0, 0xDB, 0x1F, 0x00, 0x00, 0xC0, 0xFF};
102 uint16_t
PC = 0xFFC0;
118 return (flags.
N << 7) | (flags.
V << 6) | (flags.
P << 5) | (flags.
B << 4) |
119 (flags.
H << 3) | (flags.
I << 2) | (flags.
Z << 1) | (flags.
C);
124 flags.
N = (
byte & 0x80) >> 7;
125 flags.
V = (
byte & 0x40) >> 6;
126 flags.
P = (
byte & 0x20) >> 5;
127 flags.
B = (
byte & 0x10) >> 4;
128 flags.
H = (
byte & 0x08) >> 3;
129 flags.
I = (
byte & 0x04) >> 2;
130 flags.
Z = (
byte & 0x02) >> 1;
131 flags.
C = (
byte & 0x01);
135 void Reset(
bool hard =
false);
146 uint8_t adrl = address;
147 uint8_t adrh = address + 1;
160 return low | (high << 8);
173 void write(uint16_t address, uint8_t value) {
211 uint16_t
dp_dp(uint8_t* src);
213 uint16_t
ind_ind(uint8_t* srcVal);
214 uint16_t
dp_word(uint16_t* low);
221 uint16_t
dp_imm(uint8_t* srcVal);
249 void MOV_ADDR(uint16_t address, uint8_t operand);
257 void ADCM(uint16_t& dest, uint8_t operand);
260 void SBCM(uint16_t& dest, uint8_t operand);
264 void CMPM(uint16_t dst, uint8_t value);
268 void ANDM(uint16_t dest, uint8_t operand);
270 void OR(uint16_t
adr);
271 void ORM(uint16_t dest, uint8_t operand);
274 void EORM(uint16_t dest, uint8_t operand);
276 void ASL(uint16_t operand);
279 void ROL(uint16_t operand);
282 void XCN(uint8_t operand,
bool isImmediate =
false);
284 void DEC(uint16_t operand);
285 void MOVW(uint16_t& dest, uint16_t operand);
286 void INCW(uint16_t& operand);
287 void DECW(uint16_t& operand);
288 void ADDW(uint16_t& dest, uint16_t operand);
289 void SUBW(uint16_t& dest, uint16_t operand);
290 void CMPW(uint16_t operand);
291 void MUL(uint8_t operand);
292 void DIV(uint8_t operand);
293 void BRA(int8_t offset);
294 void BEQ(int8_t offset);
295 void BNE(int8_t offset);
296 void BCS(int8_t offset);
297 void BCC(int8_t offset);
298 void BVS(int8_t offset);
299 void BVC(int8_t offset);
300 void BMI(int8_t offset);
301 void BPL(int8_t offset);
302 void BBS(uint8_t bit, uint8_t operand);
303 void BBC(uint8_t bit, uint8_t operand);
304 void JMP(uint16_t address);
305 void CALL(uint16_t address);
306 void PCALL(uint8_t offset);
307 void TCALL(uint8_t offset);
311 void PUSH(uint8_t operand);
312 void POP(uint8_t& operand);
313 void SET1(uint8_t bit, uint8_t& operand);
314 void CLR1(uint8_t bit, uint8_t& operand);
315 void TSET1(uint8_t bit, uint8_t& operand);
316 void TCLR1(uint8_t bit, uint8_t& operand);
317 void AND1(uint8_t bit, uint8_t& operand);
318 void OR1(uint8_t bit, uint8_t& operand);
319 void EOR1(uint8_t bit, uint8_t& operand);
320 void NOT1(uint8_t bit, uint8_t& operand);
321 void MOV1(uint8_t bit, uint8_t& operand);
uint8_t read(uint16_t address) const override
std::vector< uint8_t > ram
void write(uint16_t address, uint8_t value) override
uint8_t & mutable_read(uint16_t address) override
uint8_t operator[](uint16_t address) const
static const int ARAM_SIZE
AudioRam is an interface for the Audio RAM used by the SPC700.
uint8_t operator[](uint16_t address)
virtual void write(uint16_t address, uint8_t value)=0
virtual uint8_t & mutable_read(uint16_t address)=0
virtual uint8_t read(uint16_t address) const =0
virtual ~AudioRam()=default
void CMPM(uint16_t dst, uint8_t value)
void SUBW(uint16_t &dest, uint16_t operand)
std::vector< std::string > log_
void PCALL(uint8_t offset)
void JMP(uint16_t address)
uint8_t read(uint16_t address)
void NOT1(uint8_t bit, uint8_t &operand)
uint8_t abs_bit(uint16_t *adr)
void AND1(uint8_t bit, uint8_t &operand)
void ANDM(uint16_t dest, uint8_t operand)
void MOVW(uint16_t &dest, uint16_t operand)
void EORM(uint16_t dest, uint8_t operand)
uint16_t dp_indirect_plus_y()
uint16_t addr_plus_i_indexed()
void DEC(uint16_t operand)
uint16_t ind_ind(uint8_t *srcVal)
uint16_t dp_plus_x_indirect()
void DIV(uint8_t operand)
void EOR1(uint8_t bit, uint8_t &operand)
void SBCM(uint16_t &dest, uint8_t operand)
void Reset(bool hard=false)
void SET1(uint8_t bit, uint8_t &operand)
void push_byte(uint8_t value)
void TCLR1(uint8_t bit, uint8_t &operand)
uint8_t FlagsToByte(Flags flags)
void LogInstruction(uint16_t initial_pc, uint8_t opcode)
const uint8_t ipl_rom_[64]
uint16_t dp_imm(uint8_t *srcVal)
void TCALL(uint8_t offset)
uint16_t ReadOpcodeWord()
uint16_t dp_dp(uint8_t *src)
void ROL(uint16_t operand)
void MOV_ADDR(uint16_t address, uint8_t operand)
void write(uint16_t address, uint8_t value)
void XCN(uint8_t operand, bool isImmediate=false)
void PUSH(uint8_t operand)
void ADDW(uint16_t &dest, uint16_t operand)
void INCW(uint16_t &operand)
void BBC(uint8_t bit, uint8_t operand)
void CALL(uint16_t address)
uint16_t dp_word(uint16_t *low)
void DECW(uint16_t &operand)
void push_word(uint16_t value)
void BBS(uint8_t bit, uint8_t operand)
uint16_t read_word(uint16_t address)
void POP(uint8_t &operand)
void ASL(uint16_t operand)
void CLR1(uint8_t bit, uint8_t &operand)
void ADCM(uint16_t &dest, uint8_t operand)
void OR1(uint8_t bit, uint8_t &operand)
void DoBranch(uint8_t value, bool check)
void CMPW(uint16_t operand)
Spc700(ApuCallbacks &callbacks)
void MOV1(uint8_t bit, uint8_t &operand)
void TSET1(uint8_t bit, uint8_t &operand)
void ExecuteInstructions(uint8_t opcode)
void ORM(uint16_t dest, uint8_t operand)
Flags ByteToFlags(uint8_t byte)
void MUL(uint8_t operand)
SNES Emulation and debugging tools.
struct yaze::emu::ApuCallbacks ApuCallbacks
Main namespace for the application.
std::function< void(uint16_t, uint8_t)> write
std::function< void(bool)> idle
std::function< uint8_t(uint16_t)> read