summaryrefslogtreecommitdiff
path: root/src/cpu
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu')
-rw-r--r--src/cpu/core.h4
-rw-r--r--src/cpu/table.c10
2 files changed, 12 insertions, 2 deletions
diff --git a/src/cpu/core.h b/src/cpu/core.h
index 850f04b..5a73818 100644
--- a/src/cpu/core.h
+++ b/src/cpu/core.h
@@ -15,7 +15,7 @@ extern byte P;
extern byte S;
extern address PC;
extern byte* Memory;
-extern byte* ROM;
+extern const byte ROM[];
enum Addressing
@@ -58,4 +58,4 @@ void SetMemory(address x, byte y);
extern void *current_instruction;
extern AddData idata;
-extern void (*func)(Addressing, address); \ No newline at end of file
+extern void (*func)(Addressing, address);
diff --git a/src/cpu/table.c b/src/cpu/table.c
index 7ec0891..0af04f9 100644
--- a/src/cpu/table.c
+++ b/src/cpu/table.c
@@ -18,10 +18,20 @@ Addressing* GetInstructionTableAddressing(int i){
}
void CallInstructionTable(int i, address val){
+ val = 0; // TODO: Let the initial value of val be redundant for now so as to not break anything, but fix later
+ // Setup to call the correct function.
uintptr_t a = GetInstructionTableFunction(i);
memcpy(&func, a, sizeof(uintptr_t));
+ // Find the correct addressing mode.
Addressing* r = (InstructionTable + ((sizeof(uintptr_t)*256) + (sizeof(Addressing) * i)));
+ // Set idata
idata = fAddress(*r, val);
+ // Set val
+ if (idata.length > 0)
+ val += GetMemory(PC+1);
+ if (idata.length > 1)
+ val += GetMemory(PC+2) << 8;
+ // Perform function
func(*r, val);
}