116 lines
2.5 KiB
C
116 lines
2.5 KiB
C
#ifndef CPU_H
|
|
#define CPU_H
|
|
|
|
#include <stdint.h>
|
|
|
|
struct cpu_flags {
|
|
uint8_t carry : 1;
|
|
uint8_t zero : 1;
|
|
uint8_t interrupt_disable : 1;
|
|
uint8_t decimal_mode : 1;
|
|
uint8_t brk : 1;
|
|
uint8_t unused : 1;
|
|
uint8_t overflow : 1;
|
|
uint8_t negative : 1;
|
|
};
|
|
|
|
struct registers {
|
|
uint8_t a, x, y, sp;
|
|
struct cpu_flags status;
|
|
uint16_t pc;
|
|
};
|
|
struct registers regs = {0};
|
|
|
|
/* 64K address space, 16bit words */
|
|
uint8_t memory[0x16000];
|
|
|
|
/* OFFICIAL OPCODES */
|
|
void ADC(uint16_t arg);
|
|
void AND(uint16_t arg);
|
|
void ASL_acc(uint16_t arg);
|
|
void ASL(uint16_t arg);
|
|
void BCC(uint16_t arg);
|
|
void BCS(uint16_t arg);
|
|
void BEQ(uint16_t arg);
|
|
void BIT(uint16_t arg);
|
|
void BMI(uint16_t arg);
|
|
void BNE(uint16_t arg);
|
|
void BPL(uint16_t arg);
|
|
void BRK(uint16_t arg);
|
|
void BVC(uint16_t arg);
|
|
void BVS(uint16_t arg);
|
|
void CLC(uint16_t arg);
|
|
void CLD(uint16_t arg);
|
|
void CLI(uint16_t arg);
|
|
void CLV(uint16_t arg);
|
|
void CMP(uint16_t arg);
|
|
void CPX(uint16_t arg);
|
|
void CPY(uint16_t arg);
|
|
void DEC(uint16_t arg);
|
|
void DEX(uint16_t arg);
|
|
void DEY(uint16_t arg);
|
|
void EOR(uint16_t arg);
|
|
void INC(uint16_t arg);
|
|
void INX(uint16_t arg);
|
|
void INY(uint16_t arg);
|
|
void JMP(uint16_t arg);
|
|
void JSR(uint16_t arg);
|
|
void LDA(uint16_t arg);
|
|
void LDX(uint16_t arg);
|
|
void LDY(uint16_t arg);
|
|
void LSR_acc(uint16_t arg);
|
|
void LSR(uint16_t arg);
|
|
void NOP(uint16_t arg);
|
|
void ORA(uint16_t arg);
|
|
void PHA(uint16_t arg);
|
|
void PHP(uint16_t arg);
|
|
void PLA(uint16_t arg);
|
|
void PLP(uint16_t arg);
|
|
void ROL_acc(uint16_t arg);
|
|
void ROL(uint16_t arg);
|
|
void ROR_acc(uint16_t arg);
|
|
void ROR(uint16_t arg);
|
|
void RTI(uint16_t arg);
|
|
void RTS(uint16_t arg);
|
|
void SBC(uint16_t arg);
|
|
void SEC(uint16_t arg);
|
|
void SED(uint16_t arg);
|
|
void SEI(uint16_t arg);
|
|
void STA(uint16_t arg);
|
|
void STX(uint16_t arg);
|
|
void STY(uint16_t arg);
|
|
void TAX(uint16_t arg);
|
|
void TAY(uint16_t arg);
|
|
void TSX(uint16_t arg);
|
|
void TXA(uint16_t arg);
|
|
void TXS(uint16_t arg);
|
|
void TYA(uint16_t arg);
|
|
|
|
/* UNOFFICIAL OPCODES */
|
|
void AAC(uint16_t arg);
|
|
void SAX(uint16_t arg);
|
|
void ARR(uint16_t arg);
|
|
void ASR(uint16_t arg);
|
|
void ATX(uint16_t arg);
|
|
void AXA(uint16_t arg);
|
|
void AXS(uint16_t arg);
|
|
void DCP(uint16_t arg);
|
|
void DOP(uint16_t arg);
|
|
void ISB(uint16_t arg);
|
|
void KIL(uint16_t arg);
|
|
void LAR(uint16_t arg);
|
|
void LAX(uint16_t arg);
|
|
void NOP(uint16_t arg);
|
|
void RLA(uint16_t arg);
|
|
void RRA(uint16_t arg);
|
|
void SBC(uint16_t arg);
|
|
void SLO(uint16_t arg);
|
|
void SRE(uint16_t arg);
|
|
void SXA(uint16_t arg);
|
|
void SYA(uint16_t arg);
|
|
void TOP(uint16_t arg);
|
|
void XAA(uint16_t arg);
|
|
void XAS(uint16_t arg);
|
|
|
|
#endif /* CPU_H */
|