diff options
author | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-29 13:32:45 +1100 |
---|---|---|
committer | alekseiplusplus <alekseijeaves@protonmail.com> | 2023-11-29 13:32:45 +1100 |
commit | 8d3aaacf14997bbac177ae37ccab4618264cf29c (patch) | |
tree | 33cbf86fae08bc1bf97d5d38f1ac2ebebf6e7cd0 /src/apple.c | |
parent | cbd011fe442dfb520de7b51b61e9c4ef1eacae2f (diff) |
work on peripherals and display
Diffstat (limited to 'src/apple.c')
-rw-r--r-- | src/apple.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/apple.c b/src/apple.c index dae09cc..b9fd6ae 100644 --- a/src/apple.c +++ b/src/apple.c @@ -3,19 +3,53 @@ void AppleOn(){ Memory = calloc(MEMORY_SIZE, sizeof(byte)); initInstructionTable(); + + // Load ROM + FILE *ROM = fopen ("rom.bin", "rb"); + for (int i = 0; i < 256; i++) { + Memory[0xFF00+i] = fgetc(ROM); + } } void AppleReset(){ acc = 0; X = 0; Y = 0; P = 0; S = 0; idata.cycles = 0; idata.length = 0; idata.add = 0; idata.value = 0; + PC = 0xFF00; free(Memory); Memory = calloc(MEMORY_SIZE, sizeof(byte)); } +byte ToAppleASCII(char x) +{ + if (x < 0x20 || x >= 0x60) + return -1; + if (x >= 0x40) + x -= 0x40; + return x; +} + +byte ToRegularASCII(char x) +{ + if (x < 0x20) + x += 0x40; + return 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. + case KBD: + return 0b10000000 | ToAppleASCII(UserInput()); + case KBD_CR: case DSP: + return 0b10000000; + } + return Memory[x]; } void setMemory(address x, byte y){ Memory[x] = y; -}
\ No newline at end of file +} |