summaryrefslogtreecommitdiff
path: root/addressing.h
diff options
context:
space:
mode:
Diffstat (limited to 'addressing.h')
-rw-r--r--addressing.h65
1 files changed, 38 insertions, 27 deletions
diff --git a/addressing.h b/addressing.h
index 3d67b33..1a80466 100644
--- a/addressing.h
+++ b/addressing.h
@@ -3,33 +3,22 @@
enum Addressing {
eImmediate,
+ eAccumulator,
eAbsolute,
- eZeroPage,
- eImplied,
- eIndirectAbsolute,
eAbsoluteIndexedX,
eAbsoluteIndexedY,
+ eZeroPage,
eZeroPageIndexedX,
eZeroPageIndexedY,
eIndexedIndirect,
eIndirectIndexed,
- eRelative,
- eAccumulator
+ eImplied,
+ eIndirectAbsolute,
+ eRelative
};
typedef int Addressing;
-int getLength(Addressing addr){
- switch(addr){
- case eAbsolute: case eAbsoluteIndexedX: case eAbsoluteIndexedY:
- return 3;
- case eAccumulator:
- return 1;
- default:
- return 2;
- }
-}
-
/*
* Any addressing method which is single line commented out without definition
* implies that handling should be hard-coded in the switch case of the
@@ -37,26 +26,48 @@ int getLength(Addressing addr){
*/
-int fAddressing(Addressing addr, short x) {
+
+struct AddData{
+ int cycles;
+ int length;
+ byte value;
+};
+
+AddData fAddress(Addressing addr, short x) {
+ AddData ret;
switch(addr){
- case eImmediate: return x;
- case eAccumulator: return acc;
+ case eImmediate: ret.value = x; break;
+ case eAccumulator: ret.value = acc; break;
- case eAbsolute: return Memory[x];
- case eAbsoluteIndexedX: return Memory[(x + X)];
- case eAbsoluteIndexedY: return Memory[(x + Y)];
+ case eAbsolute: ret.value = Memory[x]; break;
+ case eAbsoluteIndexedX: ret.value = Memory[(x + X)]; break;
+ case eAbsoluteIndexedY: ret.value = Memory[(x + Y)]; break;
- case eZeroPage: return Memory[(x & 0x00FF)];
- case eZeroPageIndexedX: return Memory[((x = X) & 0x00FF)];
- case eZeroPageIndexedY: return Memory[((x = Y) & 0x00FF)];
+ case eZeroPage: ret.value = Memory[(x & 0x00FF)]; break;
+ case eZeroPageIndexedX: ret.value = Memory[((x = X) & 0x00FF)]; break;
+ case eZeroPageIndexedY: ret.value = Memory[((x = Y) & 0x00FF)]; break;
- case eIndexedIndirect: return Memory[((x + X) << 8) + ((x + X) + 1)];
- case eIndirectIndexed: return ((Memory[x] + Memory[(x+1 << 8)]) + Y);
+ case eIndexedIndirect: ret.value = Memory[((x + X) << 8) + ((x + X) + 1)]; break;
+ case eIndirectIndexed: ret.value = ((Memory[x] + Memory[(x+1 << 8)]) + Y); break;
//case eImplied: No reference
//case eIndirectAbsolute: Only used in the JMP instruction
//case eRelative: Only used in branch instructions
}
+ switch(addr){
+ case eAbsolute: case eAbsoluteIndexedX: case eAbsoluteIndexedY:
+ ret.length = 3; break;
+ case eAccumulator:
+ ret.length = 1; break;
+ default:
+ ret.length = 2; break;
+ }
+
+
+ // FOR TIME, FIND THE PARTICULAR VALUE SET FOR THE FIRST TYPE,
+ // APPLY RELATIVE MOVEMENT
+ // THEN LET THE FUNCTION WHICH CALLED fAddress HANDLE A NON-TYPICAL VALUE.
+
}