diff options
Diffstat (limited to 'src/apple.c')
-rw-r--r-- | src/apple.c | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/apple.c b/src/apple.c index e69cbf8..c8fbb61 100644 --- a/src/apple.c +++ b/src/apple.c @@ -1,5 +1,7 @@ #include"apple.h" +int MemorySize; + // The Incredible Wozmon! const byte ROM[256] = { 0xd8, 0x58, 0xa0, 0x7f, 0x8c, 0x12, 0xd0, 0xa9, @@ -36,16 +38,20 @@ const byte ROM[256] = { 0x00, 0x00, 0x00, 0x0f, 0x00, 0xff, 0x00, 0x00 }; -void AppleOn() { - Memory = calloc(MEMORY_SIZE, sizeof(byte)); +void AppleOn(const int memory) { + MemorySize = memory * 0x0100; + Memory = calloc(MemorySize, sizeof(byte)); InitInstructionTable(); - PC = 0xFF00; + AppleReset(); } void AppleReset(){ - acc = 0; X = 0; Y = 0; P = 0; S = 0; - state.cycles = 0; state.length = 0; state.address = 0; state.value = 0; - PC = 0xFF00; + acc = 0; + X = 0; + Y = 0; + P = 0x20; // An unused bit exists which is always 'set'. + S = 0; + PC = 0xFF00; //free(Memory); //Memory = calloc(MEMORY_SIZE, sizeof(byte)); } @@ -70,7 +76,7 @@ byte GetMemory(address x){ return ROM[0x00FF & x]; } - if (x < MEMORY_SIZE) + if (x < MemorySize) return Memory[x]; return -1; @@ -83,7 +89,7 @@ void SetMemory(address x, byte y){ if (y & 0x80) DisplayInput(y); } - if (x < MEMORY_SIZE) { + if (x < MemorySize) { Memory[x] = y; } } |