summaryrefslogtreecommitdiff
path: root/src/apple.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/apple.c')
-rw-r--r--src/apple.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/apple.c b/src/apple.c
index b9fd6ae..1e82d0d 100644
--- a/src/apple.c
+++ b/src/apple.c
@@ -2,10 +2,14 @@
void AppleOn(){
Memory = calloc(MEMORY_SIZE, sizeof(byte));
- initInstructionTable();
+ InitInstructionTable();
- // Load ROM
+ // Load ROM.
FILE *ROM = fopen ("rom.bin", "rb");
+ if (ROM == NULL) {
+ printf("\n\rROM does not exist.\n");
+ abort();
+ }
for (int i = 0; i < 256; i++) {
Memory[0xFF00+i] = fgetc(ROM);
}
@@ -19,7 +23,7 @@ void AppleReset(){
Memory = calloc(MEMORY_SIZE, sizeof(byte));
}
-byte ToAppleASCII(char x)
+byte ToAppleAscii(char x)
{
if (x < 0x20 || x >= 0x60)
return -1;
@@ -28,7 +32,7 @@ byte ToAppleASCII(char x)
return x;
}
-byte ToRegularASCII(char x)
+byte ToAscii(char x)
{
if (x < 0x20)
x += 0x40;
@@ -36,20 +40,21 @@ byte ToRegularASCII(char x)
}
-byte getMemory(address x){
+byte GetMemory(address x){
switch(x)
{
// I opted to make the kbd return successfully at all times for the sake of simplicity.
- // This is not "accurate" behavior however.
+ // This is not technically "accurate" behavior however.
case KBD:
- return 0b10000000 | ToAppleASCII(UserInput());
+ return 0b10000000 | ToAppleAscii(UserInput());
case KBD_CR: case DSP:
return 0b10000000;
+ default:
+ return Memory[x];
}
- return Memory[x];
}
-void setMemory(address x, byte y){
+void SetMemory(address x, byte y){
Memory[x] = y;
}