summaryrefslogtreecommitdiff
path: root/src/apple.c
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-12-12 10:29:53 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-12-12 10:29:53 +1100
commit79456640c548cff9125a5ba137538642e3c41141 (patch)
treefbfd474833b644b123e6f1d9dac78fedeceaf9bc /src/apple.c
parent8968f471650d25c9df68347644e0e5c0ecdbda6e (diff)
added cmd args; changed video implementation
Diffstat (limited to 'src/apple.c')
-rw-r--r--src/apple.c22
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;
}
}