summaryrefslogtreecommitdiff
path: root/headers
diff options
context:
space:
mode:
Diffstat (limited to 'headers')
-rw-r--r--headers/6502.h2
-rw-r--r--headers/addressing.h16
-rw-r--r--headers/apple.h7
-rw-r--r--headers/debug.h4
4 files changed, 24 insertions, 5 deletions
diff --git a/headers/6502.h b/headers/6502.h
index ea92479..0835f36 100644
--- a/headers/6502.h
+++ b/headers/6502.h
@@ -5,7 +5,7 @@ typedef unsigned char byte;
typedef unsigned short address;
byte acc, X, Y, P, S = 0x00;
address PC = 0x0000;
-byte Memory[4096]; // TO DO. Add expansion capability to memory.
+byte* Memory; // TO DO. Add expansion capability to memory.
// FLAGS
#define flag_N 0x80 // Negative
diff --git a/headers/addressing.h b/headers/addressing.h
index 58df3f5..d1b8371 100644
--- a/headers/addressing.h
+++ b/headers/addressing.h
@@ -33,7 +33,7 @@ typedef struct AddData AddData;
//Holds address of current instruction.
void* current_instruction;
-Addressing fAddressGetLength(Addressing addr){
+int fAddressGetLength(Addressing addr){
switch(addr){
case eAbsolute: case eAbsoluteIndexedX: case eAbsoluteIndexedY:
return 3;
@@ -44,6 +44,20 @@ Addressing fAddressGetLength(Addressing addr){
}
}
+int fAddressGetLengthPrempt(int i){ //Check the functions to make sure that there isnt some incorrect values being given for length.
+ switch(i){
+ case 0x6D: case 0x7D: case 0x79: case 0x2D: case 0x3D: case 0x39: case 0x0E: case 0x1E: case 0x2C: case 0xCD: case 0xD0: case 0xD9: case 0xEC:
+ case 0xCC: case 0xCE: case 0xDE: case 0x4D: case 0x5D: case 0x59: case 0xEE: case 0xFE: case 0x4C: case 0x20: case 0xAD: case 0xBD: case 0xB9:
+ case 0xAE: case 0xBE: case 0xAC: case 0xBC: case 0x4E: case 0x5E: case 0x0D: case 0x1D: case 0x19: case 0x2E: case 0x3E: case 0x6E: case 0x7E:
+ case 0xED: case 0xFD: case 0xF9: case 0x8D: case 0x9D: case 0x99: case 0x8E: case 0x8C:
+ return 3;
+ case 0x0A: case 0x2A: case 0x4A: case 0x6A:
+ return 1;
+ default:
+ return 2;
+ }
+}
+
AddData fAddress(Addressing addr, short x) {
AddData ret;
diff --git a/headers/apple.h b/headers/apple.h
index f5cac5c..cfcc879 100644
--- a/headers/apple.h
+++ b/headers/apple.h
@@ -1,6 +1,11 @@
#define MEMORY_SIZE 4096
void AppleOn(){
- //Memory = malloc(MEMORY_SIZE);
+ Memory = calloc(MEMORY_SIZE, sizeof(byte));
initInstructionTable();
+}
+
+void AppleReset(){ //Firt few Zp addresses have gibberish, need to fix
+ free(Memory);
+ Memory = calloc(MEMORY_SIZE, sizeof(byte));
} \ No newline at end of file
diff --git a/headers/debug.h b/headers/debug.h
index cb34dac..4b36710 100644
--- a/headers/debug.h
+++ b/headers/debug.h
@@ -1,7 +1,7 @@
// debug.h
// Various functions useful for use during development.
-// Converts a single character to hexadecimal
+// Converts a single character to hexadecimal
int dCharToNum(char c){
// 0x0 - 0x9
if (c != 0x20 && (c >= 0x30 && c <= 0x39)){
@@ -19,7 +19,7 @@ int dCharToNum(char c){
}
}
-// Dump a particular page in memory.
+// Dump page m from memory to stdout.
void dPageDump(short m){
m <<= 8;
for(int i = 0; i < 256; i+=16){