started opcodes

This commit is contained in:
Lauchmelder 2021-10-21 19:24:53 +02:00
parent 4b22287ad0
commit 458500bd59
8 changed files with 240 additions and 5 deletions

View file

@ -5,6 +5,35 @@
struct Bus;
typedef enum
{
XXX = 0,
ADC, AND, ASL, BCC, BCS, BEQ, BIT, BMI,
BNE, BPL, BRK, BVC, BVS, CLC, CLD, CLI,
CLV, CMP, CPX, CPY, DEC, DEX, DEY, EOR,
INC, INX, INY, JMP, JSR, LDA, LDX, LDY,
LSR, NOP, ORA, PHA, PHP, PLA, PLP, ROL,
ROR, RTI, RTS, SBC, SEC, SED, SEI, STA,
STX, STY, TAX, TAY, TSX, TXA, TXS, TYA
} Operation;
typedef enum
{
ACC, ABS, ABX, ABY, IMM, IMP, IND, XIN, INY, REL, ZPG, ZPX, ZPY
} AddrMode;
struct Opcode
{
Operation op;
AddrMode addr;
Byte cycles;
const char str[4];
};
const struct Opcode OPCODE_MATRIX[512];
struct CPU
{
Byte acc;
@ -29,10 +58,21 @@ struct CPU
Word pc;
Byte remainingCycles;
Byte fetchedVal;
Word fetchedAddress;
const struct Opcode* currentOpcode;
struct Bus* bus;
};
struct CPU* createCPU(struct Bus* parent);
void destroyCPU(struct CPU* cpu);
void tickCPU(struct CPU* cpu);
void tickInstr(struct CPU* cpu);
void fetch(struct CPU* cpu);
void execute(struct CPU* cpu);
#endif // _CPU_H_