started opcodes
This commit is contained in:
parent
4b22287ad0
commit
458500bd59
8 changed files with 240 additions and 5 deletions
|
@ -13,6 +13,9 @@ struct CPU* createCPU(struct Bus* parent)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
// TODO: THIS IS JUST FOR THE TEST ROM
|
||||
cpu->pc = 0xC000;
|
||||
|
||||
cpu->bus = parent;
|
||||
return cpu;
|
||||
}
|
||||
|
@ -21,3 +24,39 @@ void destroyCPU(struct CPU* cpu)
|
|||
{
|
||||
free(cpu);
|
||||
}
|
||||
|
||||
void tickCPU(struct CPU* cpu)
|
||||
{
|
||||
if (cpu->fetchedVal != 0)
|
||||
{
|
||||
cpu->fetchedVal--;
|
||||
return;
|
||||
}
|
||||
|
||||
fetch(cpu);
|
||||
execute(cpu);
|
||||
}
|
||||
|
||||
void tickInstr(struct CPU* cpu)
|
||||
{
|
||||
while (cpu->remainingCycles > 1)
|
||||
tickCPU(cpu);
|
||||
}
|
||||
|
||||
void fetch(struct CPU* cpu)
|
||||
{
|
||||
Byte opcodeVal = readBus(cpu->bus, cpu->pc);
|
||||
cpu->currentOpcode = OPCODE_TABLE + opcodeVal;
|
||||
|
||||
if (cpu->currentOpcode->op == Unknown)
|
||||
{
|
||||
fprintf(stderr, "Unknown opcode: %x", opcodeVal);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void execute(struct CPU* cpu)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue