summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-11-29 17:38:56 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-11-29 17:38:56 +1100
commit44a1ea6542c812b173fb9685837c0b2fdc6a7c61 (patch)
tree5ca86b97f79c38a07d4c532be6edcc12a887cbc1 /src
parent8d3aaacf14997bbac177ae37ccab4618264cf29c (diff)
bug fix apple.c:9 + inconsequential refactoring
Diffstat (limited to 'src')
-rw-r--r--src/apple.c23
-rw-r--r--src/apple.h7
-rw-r--r--src/cpu/6502.c54
-rw-r--r--src/cpu/6502.h31
-rw-r--r--src/cpu/addressing.c6
-rw-r--r--src/cpu/addressing.h12
-rw-r--r--src/cpu/core.h14
-rw-r--r--src/cpu/instructions.c138
-rw-r--r--src/cpu/instructions.h14
-rw-r--r--src/cpu/table.c314
-rw-r--r--src/cpu/table.h17
-rw-r--r--src/interpreter.c2
-rw-r--r--src/main.c6
-rw-r--r--src/video/interface.h10
-rw-r--r--src/video/ncurses.c17
-rw-r--r--src/video/signetics.c8
16 files changed, 331 insertions, 342 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;
}
diff --git a/src/apple.h b/src/apple.h
index 988a297..5f38265 100644
--- a/src/apple.h
+++ b/src/apple.h
@@ -1,5 +1,4 @@
-#ifndef APPLE_H
-#define APPLE_H
+#pragma once
#include "cpu/core.h"
#include <stdio.h>
@@ -25,6 +24,4 @@ void AppleOn();
void AppleReset();
byte ToAppleAscii(char);
-byte ToRegularAscii(char);
-
-#endif
+byte ToAscii(char); \ No newline at end of file
diff --git a/src/cpu/6502.c b/src/cpu/6502.c
index a5c47f5..a1d3a38 100644
--- a/src/cpu/6502.c
+++ b/src/cpu/6502.c
@@ -12,14 +12,14 @@ byte getFlag(byte flag) {
return ((P & flag) == flag) ? 1 : 0;
}
-void setFlag(byte flag, int x) {
+void SetFlag(byte flag, int x) {
if (x == 1){
if ((P & flag) == 0x0) P += flag;
}else if (x == 0){
if ((P & flag) == flag) P -= flag;
}
else{
- fprintf(stderr, "setFlag() passed arg neither 0 or 1");
+ fprintf(stderr, "SetFlag() passed arg neither 0 or 1");
}
}
@@ -33,61 +33,61 @@ void flagClear(byte flag){
// Functions which perform reusable routines for finding if a specific flag should be set.
-void setFlagN(byte x){
+void SetFlagN(byte x){
if ((x & flag_N) == flag_N)
- setFlag(flag_N, 1);
+ SetFlag(flag_N, 1);
else
- setFlag(flag_N, 0);
+ SetFlag(flag_N, 0);
}
//Perform prior to any changes
-void setFlagV(byte x, byte y){
+void SetFlagV(byte x, byte y){
if ((x & flag_N) == (y & flag_N)){
- if (((x + y) & (flag_N ^ 0xFF)) > 0x7F) setFlag(flag_V, 1);
- else setFlag(flag_V, 0);
+ if (((x + y) & (flag_N ^ 0xFF)) > 0x7F) SetFlag(flag_V, 1);
+ else SetFlag(flag_V, 0);
}else{
- if (((x - y) & (flag_N ^ 0xFF)) > 0x7F) setFlag(flag_V, 1);
- else setFlag(flag_V, 0);
+ if (((x - y) & (flag_N ^ 0xFF)) > 0x7F) SetFlag(flag_V, 1);
+ else SetFlag(flag_V, 0);
}
}
-/*void setFlagB(){ //WORK ON
- setFlag(flag_B, 1);
+/*void SetFlagB(){ //WORK ON
+ SetFlag(flag_B, 1);
}*/
-/*void setFlagD(){
- setFlag(flag_D, 1);
+/*void SetFlagD(){
+ SetFlag(flag_D, 1);
}*/
-/*void setFlagI(){ //WORK ON
- setFlag(flag_Z, 1);
+/*void SetFlagI(){ //WORK ON
+ SetFlag(flag_Z, 1);
}*/
-void setFlagZ(int x){
+void SetFlagZ(int x){
if (x == 0)
- setFlag(flag_Z, 1);
+ SetFlag(flag_Z, 1);
else
- setFlag(flag_Z, 0);
+ SetFlag(flag_Z, 0);
}
-/*void setFlagC(){
- setFlag(flag_Z, 1);
+/*void SetFlagC(){
+ SetFlag(flag_Z, 1);
}*/
-/*byte getMemory(address x){
+/*byte GetMemory(address x){
return Memory[x];
}
-void setMemory(address x, byte y){
+void SetMemory(address x, byte y){
Memory[x] = y;
}*/
-byte getStack() {
- return getMemory(0x01FF - S);
+byte GetStack() {
+ return GetMemory(0x01FF - S);
}
-void setStack(byte z) {
- setMemory(0x01FF - S, z);
+void SetStack(byte z) {
+ SetMemory(0x01FF - S, z);
} \ No newline at end of file
diff --git a/src/cpu/6502.h b/src/cpu/6502.h
index 14d65f3..bad36fb 100644
--- a/src/cpu/6502.h
+++ b/src/cpu/6502.h
@@ -1,8 +1,7 @@
// 6502.h
// Main elements of the 6502 CPU
-#ifndef CPU_H
-#define CPU_H
+#pragma once
#include"stdio.h"
#include"core.h"
@@ -19,7 +18,7 @@
byte getFlag(byte flag);
// Get the value of a flag.
-void setFlag(byte flag, int x);
+void SetFlag(byte flag, int x);
// Set a flag with some value.
void flagSet(byte flag);
@@ -30,38 +29,36 @@ void flagClear(byte flag);
// Functions which perform reusable routines for finding if a specific flag should be set.
-void setFlagN(byte x);
+void SetFlagN(byte x);
//Perform prior to any changes
-void setFlagV(byte x, byte y);
+void SetFlagV(byte x, byte y);
-//void setFlagB();
+//void SetFlagB();
//May not need since its dependent on the BRK insturction
-//void setFlagD();
+//void SetFlagD();
//Might not be necessary.
-//void setFlagI();
+//void SetFlagI();
//Need to work on.
-void setFlagZ(int x);
+void SetFlagZ(int x);
-//void setFlagC();
+//void SetFlagC();
//Only 6 instructions, 2 not including stack instructions, use the carry flag.
// The following two may be better defined within apple.c
-//byte getMemory(address x);
+//byte GetMemory(address x);
// Retrieve value from the computers address space.
// It is important not to directly access the memory array because some value hold special meaning.
-//void setMemory(address x, byte y);
+//void SetMemory(address x, byte y);
// Set a piece of memory to some value.
-byte getStack();
+byte GetStack();
// Get top value of the stack.
-void setStack(byte z);
-// Set top value of the stack.
-
-#endif \ No newline at end of file
+void SetStack(byte z);
+// Set top value of the stack. \ No newline at end of file
diff --git a/src/cpu/addressing.c b/src/cpu/addressing.c
index df632cf..f21e7da 100644
--- a/src/cpu/addressing.c
+++ b/src/cpu/addressing.c
@@ -29,9 +29,9 @@ address fAddressGetAddress(Addressing mode, short x) {
case eZeroPageIndexedY:
return ((x + Y) & 0x00FF);
case eIndexedIndirect:
- return ((getMemory(x+X+1))<<8) + (getMemory(x+X));
+ return ((GetMemory(x+X+1))<<8) + (GetMemory(x+X));
case eIndirectIndexed:
- return ((getMemory(x+1))<<8) + (getMemory(x)) + Y;
+ return ((GetMemory(x+1))<<8) + (GetMemory(x)) + Y;
}
}
@@ -57,7 +57,7 @@ byte fAddressGetValue(Addressing mode, short x, address addr) {
case eAccumulator:
return acc;
default:
- return getMemory(addr);
+ return GetMemory(addr);
}
}
diff --git a/src/cpu/addressing.h b/src/cpu/addressing.h
index 5fea2fb..e2c882e 100644
--- a/src/cpu/addressing.h
+++ b/src/cpu/addressing.h
@@ -1,21 +1,19 @@
// addressing.h
// Contains definitions relevant to addressing, as well as fAddress() which returns time, length, value, and address for an instruction function call.
-#ifndef ADDRESSING_H
-#define ADDRESSING_H
+#pragma once
#include"core.h"
#include"6502.h"
#include"instructions.h"
-#define getInstructionLength(c) fAddressGetLength(*getInstructionTableAddressing(c))
+#define getInstructionLength(c) fAddressGetLength(*GetInstructionTableAddressing(c))
+// For a given addressing mode and opcode, return data about the instruction.
+AddData fAddress (Addressing mode, short x );
address fAddressGetAddress (Addressing mode, short x );
int fAddressGetLength (Addressing mode );
byte fAddressGetValue (Addressing mode, short x, address addr);
-int fAddressGetCycles (Addressing mode, short x, address addr);
-AddData fAddress (Addressing mode, short x);
-
-#endif \ No newline at end of file
+int fAddressGetCycles (Addressing mode, short x, address addr); \ No newline at end of file
diff --git a/src/cpu/core.h b/src/cpu/core.h
index fb6bdf6..850f04b 100644
--- a/src/cpu/core.h
+++ b/src/cpu/core.h
@@ -1,5 +1,4 @@
-#ifndef CPU_CORE_H
-#define CPU_CORE_H
+#pragma once
typedef
unsigned char
@@ -51,15 +50,12 @@ AddData;
-// getMemory and setMemory are declared here, but defined in apple.c
+// GetMemory and SetMemory are declared here, but defined in apple.c
// This is because memory access of particular memory locations is influenced by the Apple I's specific setup, not by the CPU alone.
+byte GetMemory(address x);
+void SetMemory(address x, byte y);
-byte getMemory(address x);
-
-void setMemory(address x, byte y);
extern void *current_instruction;
extern AddData idata;
-extern void (*func)(Addressing, address);
-
-#endif
+extern void (*func)(Addressing, address); \ No newline at end of file
diff --git a/src/cpu/instructions.c b/src/cpu/instructions.c
index a4c96d6..c83a428 100644
--- a/src/cpu/instructions.c
+++ b/src/cpu/instructions.c
@@ -29,22 +29,22 @@ void fLDY(Addressing addr, address val){
}
void fSTA(Addressing addr, address val){
- setMemory(idata.add, acc);
+ SetMemory(idata.add, acc);
}
void fSTX(Addressing addr, address val){
- setMemory(idata.add, X);
+ SetMemory(idata.add, X);
}
void fSTY(Addressing addr, address val){
- setMemory(idata.add, Y);
+ SetMemory(idata.add, Y);
}
// Arithmetic Instructions
void fADC(Addressing addr, address val){
int buffer = acc + idata.value;
- setFlagV(buffer, acc);
+ SetFlagV(buffer, acc);
if (buffer > 255)
flagSet(flag_C);
@@ -52,13 +52,13 @@ void fADC(Addressing addr, address val){
flagClear(flag_C);
acc += idata.value;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fSBC(Addressing addr, address val){
int buffer = acc - idata.value;
- setFlagV(buffer, acc);
+ SetFlagV(buffer, acc);
if (buffer < 0)
flagSet(flag_C);
@@ -66,70 +66,70 @@ void fSBC(Addressing addr, address val){
flagClear(flag_C);
acc -= idata.value;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
//Increment and Decrement Instructions
void fINC(Addressing addr, address val){
- byte a = getMemory(idata.add);
+ byte a = GetMemory(idata.add);
a++;
- setMemory(idata.add, a);
- setFlagN(Memory[idata.add]);
- setFlagZ(Memory[idata.add]);
+ SetMemory(idata.add, a);
+ SetFlagN(Memory[idata.add]);
+ SetFlagZ(Memory[idata.add]);
}
void fINX(Addressing addr, address val){
X++;
- setFlagN(X);
- setFlagZ(X);
+ SetFlagN(X);
+ SetFlagZ(X);
}
void fINY(Addressing addr, address val){
Y++;
- setFlagN(Y);
- setFlagZ(Y);
+ SetFlagN(Y);
+ SetFlagZ(Y);
}
void fDEC(Addressing addr, address val){
- byte a = getMemory(idata.add);
+ byte a = GetMemory(idata.add);
a--;
- setMemory(idata.add, a);
- setFlagN(Memory[idata.add]);
- setFlagZ(Memory[idata.add]);
+ SetMemory(idata.add, a);
+ SetFlagN(Memory[idata.add]);
+ SetFlagZ(Memory[idata.add]);
}
void fDEX(Addressing addr, address val){
X--;
- setFlagN(X);
- setFlagZ(X);
+ SetFlagN(X);
+ SetFlagZ(X);
}
void fDEY(Addressing addr, address val){
Y--;
- setFlagN(Y);
- setFlagZ(Y);
+ SetFlagN(Y);
+ SetFlagZ(Y);
}
// Logical Instructions
void fAND(Addressing addr, address val){
acc &= idata.value;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fORA(Addressing addr, address val){
acc |= idata.value;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fEOR(Addressing addr, address val){
acc ^= idata.value;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
// Jump, Branch, Compare, and Test Bits
@@ -209,8 +209,8 @@ void fCPY(Addressing addr, address val){
//NEED TO DOUBLE CHECK THIS INSTRUCTION
void fBIT(Addressing addr, address val){
- setFlag(flag_N, (idata.value & flag_N));
- setFlag(flag_V, (idata.value & flag_V));
+ SetFlag(flag_N, (idata.value & flag_N));
+ SetFlag(flag_V, (idata.value & flag_V));
if (((idata.value & flag_N) & (idata.value & flag_V)) == 0) {
flagSet(flag_Z);
@@ -222,59 +222,59 @@ void fBIT(Addressing addr, address val){
// Shift and Rotate Instructions
void fASL(Addressing addr, address val){
- setFlag(flag_C, (idata.value & 0x80));
+ SetFlag(flag_C, (idata.value & 0x80));
acc = (idata.value << 1);
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fLSR(Addressing addr, address val){
- setFlag(flag_C, (idata.value & 0x01));
+ SetFlag(flag_C, (idata.value & 0x01));
acc = (idata.value >> 1);
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fROL(Addressing addr, address val){
- setFlag(flag_C, (val & 0x80));
+ SetFlag(flag_C, (val & 0x80));
acc = (val << 1);
acc |= (getFlag(flag_C) * 0x01);
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fROR(Addressing addr, address val){
- setFlag(flag_C, (val & 0x01));
+ SetFlag(flag_C, (val & 0x01));
acc = (val >> 1);
acc |= (getFlag(flag_C) * 0x80);
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
// Transfer Instructions
void fTAX(Addressing addr, address val){
X = acc;
- //setFlagN(X);
- //setFlagZ(X);
+ //SetFlagN(X);
+ //SetFlagZ(X);
}
void fTAY(Addressing addr, address val){
Y = acc;
- //setFlagN(Y);
- //setFlagZ(Y);
+ //SetFlagN(Y);
+ //SetFlagZ(Y);
}
void fTXA(Addressing addr, address val){
acc = X;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
void fTYA(Addressing addr, address val){
acc = Y;
- setFlagN(acc);
- setFlagZ(acc);
+ SetFlagN(acc);
+ SetFlagZ(acc);
}
// Stack Instructions
@@ -288,50 +288,50 @@ void fTXS(Addressing addr, address val){
}
void fPHA(Addressing addr, address val){
- setStack(acc);
+ SetStack(acc);
S++;
}
void fPHP(Addressing addr, address val){
- setStack(P);
+ SetStack(P);
S++;
}
void fPLA(Addressing addr, address val){
S--;
- acc = getStack();
+ acc = GetStack();
}
void fPLP(Addressing addr, address val){
S--;
- P = getStack();
+ P = GetStack();
}
// Subroutine Instructions
// NEED TO FINISH THESE
void fJSR(Addressing addr, address val){
- setStack(((PC-1) & 0xFF00) >> 8);
+ SetStack(((PC-1) & 0xFF00) >> 8);
S++;
- setStack((PC-1) & 0x00FF);
+ SetStack((PC-1) & 0x00FF);
S++;
PC = idata.add;
}
void fRTS(Addressing addr, address val){
S--;
- PC = (address)(getStack() + 1);
+ PC = (address)(GetStack() + 1);
S--;
- PC += ((address)(getStack())) << 8;
+ PC += ((address)(GetStack())) << 8;
}
void fRTI(Addressing addr, address val){
S--;
- P = getStack(); //NEED TO FIX
+ P = GetStack(); //NEED TO FIX
S--;
- PC = (address)(getStack());
+ PC = (address)(GetStack());
S--;
- PC += (address)(getStack() << 8);
+ PC += (address)(GetStack() << 8);
}
// Set/Reset Insutrctions
@@ -370,14 +370,14 @@ void fNOP(Addressing addr, address val){
}
void fBRK(Addressing addr, address val){
- setStack((((PC+2) & 0xFF00) >> 8));
+ SetStack((((PC+2) & 0xFF00) >> 8));
S++;
- setStack((PC+2) & 0x00FF);
+ SetStack((PC+2) & 0x00FF);
S++;
- setStack(P);
+ SetStack(P);
S++;
- PC = (address)(getMemory(0xFFFE));
- PC += ((address)(getMemory(0xFFFF)) << 8);
+ PC = (address)(GetMemory(0xFFFE));
+ PC += ((address)(GetMemory(0xFFFF)) << 8);
}
#ifdef ILLEGAL_INSTRUCTIONS
diff --git a/src/cpu/instructions.h b/src/cpu/instructions.h
index 33ba11d..1725d28 100644
--- a/src/cpu/instructions.h
+++ b/src/cpu/instructions.h
@@ -1,11 +1,8 @@
// instructions.h
-#ifndef INSTRUCTIONS_H
-#define INSTRUCTIONS_H
+#pragma once
#include"core.h"
#include"6502.h"
-//#include"addressing.h"
-
// Load and Store Instructions
void fLDA(Addressing, address);
@@ -83,11 +80,4 @@ void fSEI(Addressing, address);
// NOP/BRK Instructions
void fNOP(Addressing, address);
-void fBRK(Addressing, address);
-
-#endif
-
-#ifdef ILLEGAL_INSTRUCTIONS
-
-
-#endif \ No newline at end of file
+void fBRK(Addressing, address); \ No newline at end of file
diff --git a/src/cpu/table.c b/src/cpu/table.c
index cdbe995..7ec0891 100644
--- a/src/cpu/table.c
+++ b/src/cpu/table.c
@@ -7,25 +7,25 @@ void* InstructionTable;
void (*func)(Addressing, address);
-uintptr_t* getInstructionTableFunction(int i){ //Segmentation fault is occurring here, likely in next one too
+uintptr_t* GetInstructionTableFunction(int i){ //Segmentation fault is occurring here, likely in next one too
uintptr_t* r = (InstructionTable + (sizeof(uintptr_t)*i));
return r;
}
-Addressing* getInstructionTableAddressing(int i){
+Addressing* GetInstructionTableAddressing(int i){
Addressing* r = (InstructionTable + (sizeof(uintptr_t)*256) + (sizeof(Addressing)*i));
return r;
}
-void callInstructionTable(int i, address val){
- uintptr_t a = getInstructionTableFunction(i);
+void CallInstructionTable(int i, address val){
+ uintptr_t a = GetInstructionTableFunction(i);
memcpy(&func, a, sizeof(uintptr_t));
Addressing* r = (InstructionTable + ((sizeof(uintptr_t)*256) + (sizeof(Addressing) * i)));
idata = fAddress(*r, val);
func(*r, val);
}
-void setInstructionTable(int i, uintptr_t p, Addressing r){
+void SetInstructionTable(int i, uintptr_t p, Addressing r){
uintptr_t* p1 = ( InstructionTable + (sizeof(uintptr_t) * i) );
*p1 = p;
@@ -33,235 +33,235 @@ void setInstructionTable(int i, uintptr_t p, Addressing r){
*r1 = r;
}
-void initInstructionTable(){
+void InitInstructionTable(){
InstructionTable = malloc(InstructionTableSize);
// Load and Store Instructions
// fLDA(Addressing, address);
- setInstructionTable(0xA9, (uintptr_t)&fLDA, eImmediate);
- setInstructionTable(0xA5, (uintptr_t)&fLDA, eZeroPage);
- setInstructionTable(0xB5, (uintptr_t)&fLDA, eZeroPageIndexedX);
- setInstructionTable(0xAD, (uintptr_t)&fLDA, eAbsolute);
- setInstructionTable(0xBD, (uintptr_t)&fLDA, eAbsoluteIndexedX);
- setInstructionTable(0xB9, (uintptr_t)&fLDA, eAbsoluteIndexedY);
- setInstructionTable(0xA1, (uintptr_t)&fLDA, eIndexedIndirect);
- setInstructionTable(0xB1, (uintptr_t)&fLDA, eIndirectIndexed);
+ SetInstructionTable(0xA9, (uintptr_t)&fLDA, eImmediate);
+ SetInstructionTable(0xA5, (uintptr_t)&fLDA, eZeroPage);
+ SetInstructionTable(0xB5, (uintptr_t)&fLDA, eZeroPageIndexedX);
+ SetInstructionTable(0xAD, (uintptr_t)&fLDA, eAbsolute);
+ SetInstructionTable(0xBD, (uintptr_t)&fLDA, eAbsoluteIndexedX);
+ SetInstructionTable(0xB9, (uintptr_t)&fLDA, eAbsoluteIndexedY);
+ SetInstructionTable(0xA1, (uintptr_t)&fLDA, eIndexedIndirect);
+ SetInstructionTable(0xB1, (uintptr_t)&fLDA, eIndirectIndexed);
// fLDX(Addressing, address);
- setInstructionTable(0xA2, (uintptr_t)&fLDX, eImmediate);
- setInstructionTable(0xA6, (uintptr_t)&fLDX, eZeroPage);
- setInstructionTable(0xB6, (uintptr_t)&fLDX, eZeroPageIndexedY);
- setInstructionTable(0xAE, (uintptr_t)&fLDX, eAbsolute);
- setInstructionTable(0xBE, (uintptr_t)&fLDX, eAbsoluteIndexedY);
+ SetInstructionTable(0xA2, (uintptr_t)&fLDX, eImmediate);
+ SetInstructionTable(0xA6, (uintptr_t)&fLDX, eZeroPage);
+ SetInstructionTable(0xB6, (uintptr_t)&fLDX, eZeroPageIndexedY);
+ SetInstructionTable(0xAE, (uintptr_t)&fLDX, eAbsolute);
+ SetInstructionTable(0xBE, (uintptr_t)&fLDX, eAbsoluteIndexedY);
// fLDY(Addressing, address);
- setInstructionTable(0xA0, (uintptr_t)&fLDY, eImmediate);
- setInstructionTable(0xA4, (uintptr_t)&fLDY, eZeroPage);
- setInstructionTable(0xB4, (uintptr_t)&fLDY, eZeroPageIndexedX);
- setInstructionTable(0xAC, (uintptr_t)&fLDY, eAbsolute);
- setInstructionTable(0xBC, (uintptr_t)&fLDY, eAbsoluteIndexedX);
+ SetInstructionTable(0xA0, (uintptr_t)&fLDY, eImmediate);
+ SetInstructionTable(0xA4, (uintptr_t)&fLDY, eZeroPage);
+ SetInstructionTable(0xB4, (uintptr_t)&fLDY, eZeroPageIndexedX);
+ SetInstructionTable(0xAC, (uintptr_t)&fLDY, eAbsolute);
+ SetInstructionTable(0xBC, (uintptr_t)&fLDY, eAbsoluteIndexedX);
// fSTA(Addressing, address);
- setInstructionTable(0x85, (uintptr_t)&fSTA, eZeroPage);
- setInstructionTable(0x95, (uintptr_t)&fSTA, eZeroPageIndexedX);
- setInstructionTable(0x8D, (uintptr_t)&fSTA, eAbsolute);
- setInstructionTable(0x9D, (uintptr_t)&fSTA, eAbsoluteIndexedX);
- setInstructionTable(0x99, (uintptr_t)&fSTA, eAbsoluteIndexedY);
- setInstructionTable(0x81, (uintptr_t)&fSTA, eIndexedIndirect);
- setInstructionTable(0x91, (uintptr_t)&fSTA, eIndirectIndexed);
+ SetInstructionTable(0x85, (uintptr_t)&fSTA, eZeroPage);
+ SetInstructionTable(0x95, (uintptr_t)&fSTA, eZeroPageIndexedX);
+ SetInstructionTable(0x8D, (uintptr_t)&fSTA, eAbsolute);
+ SetInstructionTable(0x9D, (uintptr_t)&fSTA, eAbsoluteIndexedX);
+ SetInstructionTable(0x99, (uintptr_t)&fSTA, eAbsoluteIndexedY);
+ SetInstructionTable(0x81, (uintptr_t)&fSTA, eIndexedIndirect);
+ SetInstructionTable(0x91, (uintptr_t)&fSTA, eIndirectIndexed);
// fSTX(Addressing, address);
- setInstructionTable(0x86, (uintptr_t)&fSTX, eZeroPage);
- setInstructionTable(0x96, (uintptr_t)&fSTX, eZeroPageIndexedX);
- setInstructionTable(0x8E, (uintptr_t)&fSTX, eAbsolute);
+ SetInstructionTable(0x86, (uintptr_t)&fSTX, eZeroPage);
+ SetInstructionTable(0x96, (uintptr_t)&fSTX, eZeroPageIndexedX);
+ SetInstructionTable(0x8E, (uintptr_t)&fSTX, eAbsolute);
// fSTY(Addressing, address);
- setInstructionTable(0x84, (uintptr_t)&fSTY, eZeroPage);
- setInstructionTable(0x94, (uintptr_t)&fSTY, eZeroPageIndexedY);
- setInstructionTable(0x8C, (uintptr_t)&fSTY, eAbsolute);
+ SetInstructionTable(0x84, (uintptr_t)&fSTY, eZeroPage);
+ SetInstructionTable(0x94, (uintptr_t)&fSTY, eZeroPageIndexedY);
+ SetInstructionTable(0x8C, (uintptr_t)&fSTY, eAbsolute);
// Arithmetic Instructions
// fADC(Addressing, address);
- setInstructionTable(0x69, (uintptr_t)&fADC, eImmediate);
- setInstructionTable(0x65, (uintptr_t)&fADC, eZeroPage);
- setInstructionTable(0x75, (uintptr_t)&fADC, eZeroPageIndexedX);
- setInstructionTable(0x6D, (uintptr_t)&fADC, eAbsolute);
- setInstructionTable(0x7D, (uintptr_t)&fADC, eAbsoluteIndexedX);
- setInstructionTable(0x79, (uintptr_t)&fADC, eAbsoluteIndexedY);
- setInstructionTable(0x61, (uintptr_t)&fADC, eIndexedIndirect);
- setInstructionTable(0x71, (uintptr_t)&fADC, eIndirectIndexed);
+ SetInstructionTable(0x69, (uintptr_t)&fADC, eImmediate);
+ SetInstructionTable(0x65, (uintptr_t)&fADC, eZeroPage);
+ SetInstructionTable(0x75, (uintptr_t)&fADC, eZeroPageIndexedX);
+ SetInstructionTable(0x6D, (uintptr_t)&fADC, eAbsolute);
+ SetInstructionTable(0x7D, (uintptr_t)&fADC, eAbsoluteIndexedX);
+ SetInstructionTable(0x79, (uintptr_t)&fADC, eAbsoluteIndexedY);
+ SetInstructionTable(0x61, (uintptr_t)&fADC, eIndexedIndirect);
+ SetInstructionTable(0x71, (uintptr_t)&fADC, eIndirectIndexed);
// fSBC(Addressing, address);
- setInstructionTable(0xE9, (uintptr_t)&fSBC, eImmediate);
- setInstructionTable(0xE5, (uintptr_t)&fSBC, eZeroPage);
- setInstructionTable(0xF5, (uintptr_t)&fSBC, eZeroPageIndexedX);
- setInstructionTable(0xED, (uintptr_t)&fSBC, eAbsolute);
- setInstructionTable(0xFD, (uintptr_t)&fSBC, eAbsoluteIndexedX);
- setInstructionTable(0xF9, (uintptr_t)&fSBC, eAbsoluteIndexedY);
- setInstructionTable(0xE1, (uintptr_t)&fSBC, eIndexedIndirect);
- setInstructionTable(0xF1, (uintptr_t)&fSBC, eIndirectIndexed);
+ SetInstructionTable(0xE9, (uintptr_t)&fSBC, eImmediate);
+ SetInstructionTable(0xE5, (uintptr_t)&fSBC, eZeroPage);
+ SetInstructionTable(0xF5, (uintptr_t)&fSBC, eZeroPageIndexedX);
+ SetInstructionTable(0xED, (uintptr_t)&fSBC, eAbsolute);
+ SetInstructionTable(0xFD, (uintptr_t)&fSBC, eAbsoluteIndexedX);
+ SetInstructionTable(0xF9, (uintptr_t)&fSBC, eAbsoluteIndexedY);
+ SetInstructionTable(0xE1, (uintptr_t)&fSBC, eIndexedIndirect);
+ SetInstructionTable(0xF1, (uintptr_t)&fSBC, eIndirectIndexed);
//Increment and Decrement Instructions
//INC(Addressing, address);
- setInstructionTable(0xE6, (uintptr_t)&fINC, eZeroPage);
- setInstructionTable(0xF6, (uintptr_t)&fINC, eZeroPageIndexedX);
- setInstructionTable(0xEE, (uintptr_t)&fINC, eAbsolute);
- setInstructionTable(0xFE, (uintptr_t)&fINC, eAbsoluteIndexedX);
+ SetInstructionTable(0xE6, (uintptr_t)&fINC, eZeroPage);
+ SetInstructionTable(0xF6, (uintptr_t)&fINC, eZeroPageIndexedX);
+ SetInstructionTable(0xEE, (uintptr_t)&fINC, eAbsolute);
+ SetInstructionTable(0xFE, (uintptr_t)&fINC, eAbsoluteIndexedX);
//INX(Addressing, address);
- setInstructionTable(0xE8, (uintptr_t)&fINX, eImplied);
+ SetInstructionTable(0xE8, (uintptr_t)&fINX, eImplied);
//INY(Addressing, address);
- setInstructionTable(0xC8, (uintptr_t)&fINY, eImplied);
+ SetInstructionTable(0xC8, (uintptr_t)&fINY, eImplied);
//DEC(Addressing, address);
- setInstructionTable(0xC6, (uintptr_t)&fDEC, eZeroPage);
- setInstructionTable(0xD6, (uintptr_t)&fDEC, eZeroPageIndexedX);
- setInstructionTable(0xCE, (uintptr_t)&fDEC, eAbsolute);
- setInstructionTable(0xDE, (uintptr_t)&fDEC, eAbsoluteIndexedX);
+ SetInstructionTable(0xC6, (uintptr_t)&fDEC, eZeroPage);
+ SetInstructionTable(0xD6, (uintptr_t)&fDEC, eZeroPageIndexedX);
+ SetInstructionTable(0xCE, (uintptr_t)&fDEC, eAbsolute);
+ SetInstructionTable(0xDE, (uintptr_t)&fDEC, eAbsoluteIndexedX);
//DEX(Addressing, address);
- setInstructionTable(0xCA, (uintptr_t)&fDEX, eImplied);
+ SetInstructionTable(0xCA, (uintptr_t)&fDEX, eImplied);
//DEY(Addressing, address);
- setInstructionTable(0x88, (uintptr_t)&fDEY, eImplied);
+ SetInstructionTable(0x88, (uintptr_t)&fDEY, eImplied);
// Logical Instructions
//AND(Addressing, address);
- setInstructionTable(0x29, (uintptr_t)&fAND, eImmediate);
- setInstructionTable(0x25, (uintptr_t)&fAND, eZeroPage);
- setInstructionTable(0x35, (uintptr_t)&fAND, eZeroPageIndexedX);
- setInstructionTable(0x2D, (uintptr_t)&fAND, eAbsolute);
- setInstructionTable(0x3D, (uintptr_t)&fAND, eAbsoluteIndexedX);
- setInstructionTable(0x39, (uintptr_t)&fAND, eAbsoluteIndexedY);
- setInstructionTable(0x21, (uintptr_t)&fAND, eIndexedIndirect);
- setInstructionTable(0x31, (uintptr_t)&fAND, eIndirectIndexed);
+ SetInstructionTable(0x29, (uintptr_t)&fAND, eImmediate);
+ SetInstructionTable(0x25, (uintptr_t)&fAND, eZeroPage);
+ SetInstructionTable(0x35, (uintptr_t)&fAND, eZeroPageIndexedX);
+ SetInstructionTable(0x2D, (uintptr_t)&fAND, eAbsolute);
+ SetInstructionTable(0x3D, (uintptr_t)&fAND, eAbsoluteIndexedX);
+ SetInstructionTable(0x39, (uintptr_t)&fAND, eAbsoluteIndexedY);
+ SetInstructionTable(0x21, (uintptr_t)&fAND, eIndexedIndirect);
+ SetInstructionTable(0x31, (uintptr_t)&fAND, eIndirectIndexed);
//ORA(Addressing, address);
- setInstructionTable(0x09, (uintptr_t)&fORA, eImmediate);
- setInstructionTable(0x05, (uintptr_t)&fORA, eZeroPage);
- setInstructionTable(0x15, (uintptr_t)&fORA, eZeroPageIndexedX);
- setInstructionTable(0x0D, (uintptr_t)&fORA, eAbsolute);
- setInstructionTable(0x1D, (uintptr_t)&fORA, eAbsoluteIndexedX);
- setInstructionTable(0x19, (uintptr_t)&fORA, eAbsoluteIndexedY);
- setInstructionTable(0x01, (uintptr_t)&fORA, eIndexedIndirect);
- setInstructionTable(0x11, (uintptr_t)&fORA, eIndirectIndexed);
+ SetInstructionTable(0x09, (uintptr_t)&fORA, eImmediate);
+ SetInstructionTable(0x05, (uintptr_t)&fORA, eZeroPage);
+ SetInstructionTable(0x15, (uintptr_t)&fORA, eZeroPageIndexedX);
+ SetInstructionTable(0x0D, (uintptr_t)&fORA, eAbsolute);
+ SetInstructionTable(0x1D, (uintptr_t)&fORA, eAbsoluteIndexedX);
+ SetInstructionTable(0x19, (uintptr_t)&fORA, eAbsoluteIndexedY);
+ SetInstructionTable(0x01, (uintptr_t)&fORA, eIndexedIndirect);
+ SetInstructionTable(0x11, (uintptr_t)&fORA, eIndirectIndexed);
//EOR(Addressing, address);
- setInstructionTable(0x49, (uintptr_t)&fEOR, eImmediate);
- setInstructionTable(0x45, (uintptr_t)&fEOR, eZeroPage);
- setInstructionTable(0x55, (uintptr_t)&fEOR, eZeroPageIndexedX);
- setInstructionTable(0x4D, (uintptr_t)&fEOR, eAbsolute);
- setInstructionTable(0x5D, (uintptr_t)&fEOR, eAbsoluteIndexedX);
- setInstructionTable(0x59, (uintptr_t)&fEOR, eAbsoluteIndexedY);
- setInstructionTable(0x41, (uintptr_t)&fEOR, eIndexedIndirect);
- setInstructionTable(0x51, (uintptr_t)&fEOR, eIndirectIndexed);
+ SetInstructionTable(0x49, (uintptr_t)&fEOR, eImmediate);
+ SetInstructionTable(0x45, (uintptr_t)&fEOR, eZeroPage);
+ SetInstructionTable(0x55, (uintptr_t)&fEOR, eZeroPageIndexedX);
+ SetInstructionTable(0x4D, (uintptr_t)&fEOR, eAbsolute);
+ SetInstructionTable(0x5D, (uintptr_t)&fEOR, eAbsoluteIndexedX);
+ SetInstructionTable(0x59, (uintptr_t)&fEOR, eAbsoluteIndexedY);
+ SetInstructionTable(0x41, (uintptr_t)&fEOR, eIndexedIndirect);
+ SetInstructionTable(0x51, (uintptr_t)&fEOR, eIndirectIndexed);
// Jump, Branch, Compare, and Test Bits
//JMP(Addressing, address);
- setInstructionTable(0x4C, (uintptr_t)&fJMP, eAbsolute);
- setInstructionTable(0x6C, (uintptr_t)&fJMP, eIndirectAbsolute);
+ SetInstructionTable(0x4C, (uintptr_t)&fJMP, eAbsolute);
+ SetInstructionTable(0x6C, (uintptr_t)&fJMP, eIndirectAbsolute);
//BCC(Addressing, address);
- setInstructionTable(0x90, (uintptr_t)&fBCC, eRelative);
+ SetInstructionTable(0x90, (uintptr_t)&fBCC, eRelative);
//BCS(Addressing, address);
- setInstructionTable(0xB0, (uintptr_t)&fBCS, eRelative);
+ SetInstructionTable(0xB0, (uintptr_t)&fBCS, eRelative);
//BEQ(Addressing, address);
- setInstructionTable(0xF0, (uintptr_t)&fBEQ, eRelative);
+ SetInstructionTable(0xF0, (uintptr_t)&fBEQ, eRelative);
//BNE(Addressing, address);
- setInstructionTable(0xD0, (uintptr_t)&fBNE, eRelative);
+ SetInstructionTable(0xD0, (uintptr_t)&fBNE, eRelative);
//BMI(Addressing, address);
- setInstructionTable(0x30, (uintptr_t)&fBMI, eRelative);
+ SetInstructionTable(0x30, (uintptr_t)&fBMI, eRelative);
//BPL(Addressing, address);
- setInstructionTable(0x10, (uintptr_t)&fBPL, eRelative);
+ SetInstructionTable(0x10, (uintptr_t)&fBPL, eRelative);
//BVS(Addressing, address);
- setInstructionTable(0x70, (uintptr_t)&fBVS, eRelative);
+ SetInstructionTable(0x70, (uintptr_t)&fBVS, eRelative);
//BVC(Addressing, address);
- setInstructionTable(0x50, (uintptr_t)&fBVC, eRelative);
+ SetInstructionTable(0x50, (uintptr_t)&fBVC, eRelative);
//CMP(Addressing, address);
- setInstructionTable(0xC9, (uintptr_t)&fCMP, eImmediate);
- setInstructionTable(0xC5, (uintptr_t)&fCMP, eZeroPage);
- setInstructionTable(0xD5, (uintptr_t)&fCMP, eZeroPageIndexedX);
- setInstructionTable(0xCD, (uintptr_t)&fCMP, eAbsolute);
- setInstructionTable(0xDD, (uintptr_t)&fCMP, eAbsoluteIndexedX);
- setInstructionTable(0xD9, (uintptr_t)&fCMP, eAbsoluteIndexedY);
- setInstructionTable(0xC1, (uintptr_t)&fCMP, eIndexedIndirect);
- setInstructionTable(0xD1, (uintptr_t)&fCMP, eIndirectIndexed);
+ SetInstructionTable(0xC9, (uintptr_t)&fCMP, eImmediate);
+ SetInstructionTable(0xC5, (uintptr_t)&fCMP, eZeroPage);
+ SetInstructionTable(0xD5, (uintptr_t)&fCMP, eZeroPageIndexedX);
+ SetInstructionTable(0xCD, (uintptr_t)&fCMP, eAbsolute);
+ SetInstructionTable(0xDD, (uintptr_t)&fCMP, eAbsoluteIndexedX);
+ SetInstructionTable(0xD9, (uintptr_t)&fCMP, eAbsoluteIndexedY);
+ SetInstructionTable(0xC1, (uintptr_t)&fCMP, eIndexedIndirect);
+ SetInstructionTable(0xD1, (uintptr_t)&fCMP, eIndirectIndexed);
//CPX(Addressing, address);
- setInstructionTable(0xE0, (uintptr_t)&fCPX, eImmediate);
- setInstructionTable(0xE4, (uintptr_t)&fCPX, eZeroPage);
- setInstructionTable(0xEC, (uintptr_t)&fCPX, eAbsolute);
+ SetInstructionTable(0xE0, (uintptr_t)&fCPX, eImmediate);
+ SetInstructionTable(0xE4, (uintptr_t)&fCPX, eZeroPage);
+ SetInstructionTable(0xEC, (uintptr_t)&fCPX, eAbsolute);
//CPY(Addressing, address);
- setInstructionTable(0xC0, (uintptr_t)&fCPY, eImmediate);
- setInstructionTable(0xC4, (uintptr_t)&fCPY, eZeroPage);
- setInstructionTable(0xCC, (uintptr_t)&fCPY, eAbsolute);
+ SetInstructionTable(0xC0, (uintptr_t)&fCPY, eImmediate);
+ SetInstructionTable(0xC4, (uintptr_t)&fCPY, eZeroPage);
+ SetInstructionTable(0xCC, (uintptr_t)&fCPY, eAbsolute);
//BIT(Addressing, address);
- setInstructionTable(0x4C, (uintptr_t)&fBIT, eZeroPage);
- setInstructionTable(0x6C, (uintptr_t)&fBIT, eAbsolute);
+ SetInstructionTable(0x4C, (uintptr_t)&fBIT, eZeroPage);
+ SetInstructionTable(0x6C, (uintptr_t)&fBIT, eAbsolute);
// Shift and Rotate Instructions
//ASL(Addressing, address);
- setInstructionTable(0x0A, (uintptr_t)&fASL, eAccumulator);
- setInstructionTable(0x06, (uintptr_t)&fASL, eZeroPage);
- setInstructionTable(0x16, (uintptr_t)&fASL, eZeroPageIndexedX);
- setInstructionTable(0x0E, (uintptr_t)&fASL, eAbsolute);
- setInstructionTable(0x1E, (uintptr_t)&fASL, eAbsoluteIndexedX);
+ SetInstructionTable(0x0A, (uintptr_t)&fASL, eAccumulator);
+ SetInstructionTable(0x06, (uintptr_t)&fASL, eZeroPage);
+ SetInstructionTable(0x16, (uintptr_t)&fASL, eZeroPageIndexedX);
+ SetInstructionTable(0x0E, (uintptr_t)&fASL, eAbsolute);
+ SetInstructionTable(0x1E, (uintptr_t)&fASL, eAbsoluteIndexedX);
//LSR(Addressing, address);
- setInstructionTable(0x4A, (uintptr_t)&fLSR, eAccumulator);
- setInstructionTable(0x46, (uintptr_t)&fLSR, eZeroPage);
- setInstructionTable(0x56, (uintptr_t)&fLSR, eZeroPageIndexedX);
- setInstructionTable(0x4E, (uintptr_t)&fLSR, eAbsolute);
- setInstructionTable(0x5E, (uintptr_t)&fLSR, eAbsoluteIndexedX);
+ SetInstructionTable(0x4A, (uintptr_t)&fLSR, eAccumulator);
+ SetInstructionTable(0x46, (uintptr_t)&fLSR, eZeroPage);
+ SetInstructionTable(0x56, (uintptr_t)&fLSR, eZeroPageIndexedX);
+ SetInstructionTable(0x4E, (uintptr_t)&fLSR, eAbsolute);
+ SetInstructionTable(0x5E, (uintptr_t)&fLSR, eAbsoluteIndexedX);
//ROL(Addressing, address);
- setInstructionTable(0x2A, (uintptr_t)&fROL, eAccumulator);
- setInstructionTable(0x26, (uintptr_t)&fROL, eZeroPage);
- setInstructionTable(0x36, (uintptr_t)&fROL, eZeroPageIndexedX);
- setInstructionTable(0x2E, (uintptr_t)&fROL, eAbsolute);
- setInstructionTable(0x3E, (uintptr_t)&fROL, eAbsoluteIndexedX);
+ SetInstructionTable(0x2A, (uintptr_t)&fROL, eAccumulator);
+ SetInstructionTable(0x26, (uintptr_t)&fROL, eZeroPage);
+ SetInstructionTable(0x36, (uintptr_t)&fROL, eZeroPageIndexedX);
+ SetInstructionTable(0x2E, (uintptr_t)&fROL, eAbsolute);
+ SetInstructionTable(0x3E, (uintptr_t)&fROL, eAbsoluteIndexedX);
//ROR(Addressing, address);
- setInstructionTable(0x6A, (uintptr_t)&fROR, eAccumulator);
- setInstructionTable(0x66, (uintptr_t)&fROR, eZeroPage);
- setInstructionTable(0x76, (uintptr_t)&fROR, eZeroPageIndexedX);
- setInstructionTable(0x6E, (uintptr_t)&fROR, eAbsolute);
- setInstructionTable(0x7E, (uintptr_t)&fROR, eAbsoluteIndexedX);
+ SetInstructionTable(0x6A, (uintptr_t)&fROR, eAccumulator);
+ SetInstructionTable(0x66, (uintptr_t)&fROR, eZeroPage);
+ SetInstructionTable(0x76, (uintptr_t)&fROR, eZeroPageIndexedX);
+ SetInstructionTable(0x6E, (uintptr_t)&fROR, eAbsolute);
+ SetInstructionTable(0x7E, (uintptr_t)&fROR, eAbsoluteIndexedX);
// Transfer Instructions
//TAX(Addressing, address);
- setInstructionTable(0xAA, (uintptr_t)&fTAX, eImplied);
+ SetInstructionTable(0xAA, (uintptr_t)&fTAX, eImplied);
//TAY(Addressing, address);
- setInstructionTable(0xA8, (uintptr_t)&fTAY, eImplied);
+ SetInstructionTable(0xA8, (uintptr_t)&fTAY, eImplied);
//TXA(Addressing, address);
- setInstructionTable(0x8A, (uintptr_t)&fTXA, eImplied);
+ SetInstructionTable(0x8A, (uintptr_t)&fTXA, eImplied);
//TYA(Addressing, address);
- setInstructionTable(0x98, (uintptr_t)&fTYA, eImplied);
+ SetInstructionTable(0x98, (uintptr_t)&fTYA, eImplied);
// Stack Instructions
//TSX(Addressing, address);
- setInstructionTable(0xBA, (uintptr_t)&fTSX, eImplied);
+ SetInstructionTable(0xBA, (uintptr_t)&fTSX, eImplied);
//TXS(Addressing, address);
- setInstructionTable(0x9A, (uintptr_t)&fTXS, eImplied);
+ SetInstructionTable(0x9A, (uintptr_t)&fTXS, eImplied);
//PHA(Addressing, address);
- setInstructionTable(0x48, (uintptr_t)&fPHA, eImplied);
+ SetInstructionTable(0x48, (uintptr_t)&fPHA, eImplied);
//PHP(Addressing, address);
- setInstructionTable(0x08, (uintptr_t)&fPHP, eImplied);
+ SetInstructionTable(0x08, (uintptr_t)&fPHP, eImplied);
//PLA(Addressing, address);
- setInstructionTable(0x68, (uintptr_t)&fPLA, eImplied);
+ SetInstructionTable(0x68, (uintptr_t)&fPLA, eImplied);
//PLP(Addressing, address);
- setInstructionTable(0x28, (uintptr_t)&fPLP, eImplied);
+ SetInstructionTable(0x28, (uintptr_t)&fPLP, eImplied);
// Subroutine Instructions
//JSR(Addressing, address);
- setInstructionTable(0x20, (uintptr_t)&fJSR, eAbsolute);
+ SetInstructionTable(0x20, (uintptr_t)&fJSR, eAbsolute);
//RTS(Addressing, address);
- setInstructionTable(0x60, (uintptr_t)&fRTS, eImplied);
+ SetInstructionTable(0x60, (uintptr_t)&fRTS, eImplied);
//RTI(Addressing, address);
- setInstructionTable(0x40, (uintptr_t)&fRTI, eImplied);
+ SetInstructionTable(0x40, (uintptr_t)&fRTI, eImplied);
// Set/Reset Insutrctions
//CLC(Addressing, address);
- setInstructionTable(0x18, (uintptr_t)&fCLC, eImplied);
+ SetInstructionTable(0x18, (uintptr_t)&fCLC, eImplied);
//CLD(Addressing, address);
- setInstructionTable(0xD8, (uintptr_t)&fCLD, eImplied);
+ SetInstructionTable(0xD8, (uintptr_t)&fCLD, eImplied);
//CLI(Addressing, address);
- setInstructionTable(0x58, (uintptr_t)&fCLI, eImplied);
+ SetInstructionTable(0x58, (uintptr_t)&fCLI, eImplied);
//CLV(Addressing, address);
- setInstructionTable(0xB8, (uintptr_t)&fCLV, eImplied);
+ SetInstructionTable(0xB8, (uintptr_t)&fCLV, eImplied);
//SEC(Addressing, address);
- setInstructionTable(0x38, (uintptr_t)&fSEC, eImplied);
+ SetInstructionTable(0x38, (uintptr_t)&fSEC, eImplied);
//SED(Addressing, address);
- setInstructionTable(0xF8, (uintptr_t)&fSED, eImplied);
+ SetInstructionTable(0xF8, (uintptr_t)&fSED, eImplied);
//SEI(Addressing, address);
- setInstructionTable(0x78, (uintptr_t)&fSEI, eImplied);
+ SetInstructionTable(0x78, (uintptr_t)&fSEI, eImplied);
// NOP/BRK Instructions
//NOP(Addressing, address);
- setInstructionTable(0xEA, (uintptr_t)&fNOP, eImplied);
+ SetInstructionTable(0xEA, (uintptr_t)&fNOP, eImplied);
//BRK(Addressing, address);
- setInstructionTable(0x00, (uintptr_t)&fBRK, eImplied);
+ SetInstructionTable(0x00, (uintptr_t)&fBRK, eImplied);
}
diff --git a/src/cpu/table.h b/src/cpu/table.h
index c8ecb00..18cac90 100644
--- a/src/cpu/table.h
+++ b/src/cpu/table.h
@@ -1,7 +1,6 @@
// table.h
// Defines the instruction table, and the functions to access it.
-#ifndef TABLE_H
-#define TABLE_H
+#pragma once
#include"stdint.h"
#include"stdlib.h"
@@ -11,16 +10,14 @@
#define InstructionTableSize (256 * (sizeof(uintptr_t) + sizeof(Addressing)))
-uintptr_t* getInstructionTableFunction(int i);
+uintptr_t* GetInstructionTableFunction(int i);
-Addressing* getInstructionTableAddressing(int i);
+Addressing* GetInstructionTableAddressing(int i);
-void callInstructionTable(int i, address val);
+void CallInstructionTable(int i, address val);
-void setInstructionTable(int i, uintptr_t p, Addressing r);
// Sets an individual portion of an instruction set
+void SetInstructionTable(int i, uintptr_t p, Addressing r);
-void initInstructionTable();
-// Initializes entirety of the instruction table in memory.
-
-#endif \ No newline at end of file
+// Initializes instruction table in memory.
+void InitInstructionTable(); \ No newline at end of file
diff --git a/src/interpreter.c b/src/interpreter.c
index 200347e..d243e67 100644
--- a/src/interpreter.c
+++ b/src/interpreter.c
@@ -116,7 +116,7 @@ int main(int argc, char *argv[]){
i++;
}*/
}
- callInstructionTable(c, x);
+ CallInstructionTable(c, x);
}
}
diff --git a/src/main.c b/src/main.c
index 8b07189..6b235bb 100644
--- a/src/main.c
+++ b/src/main.c
@@ -8,9 +8,9 @@ int main() {
AppleOn();
- while(1) {
- TerminalInput(getch());
- }
+ //while(1) {
+ // UserInput();
+ //}
TerminalClose();
diff --git a/src/video/interface.h b/src/video/interface.h
index 5100032..e3244b0 100644
--- a/src/video/interface.h
+++ b/src/video/interface.h
@@ -1,11 +1,19 @@
// interface.h
// Provides the interface with which all video interactions must occur.
+#pragma once
+
+#include "../cpu/core.h"
+#include <stdlib.h>
+
// Common procedure for taking in user input.
char UserInput();
+// Initialization procedure for the terminal
void TerminalInit();
+// Exit procedure for the terminal.
void TerminalClose();
-void TerminalInput(char n);
+// Deliver an Apple ASCII character to the terminal.
+void TerminalInput(char n); \ No newline at end of file
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
index 380c57a..2e3e519 100644
--- a/src/video/ncurses.c
+++ b/src/video/ncurses.c
@@ -2,9 +2,10 @@
// Implements interface.h
// Provides an in-terminal interface to the emulator.
+#include<ncurses.h>
#include"interface.h"
#include"signetics.c"
-#include<ncurses.h>
+#include"../apple.h"
int TermX = 0;
@@ -56,7 +57,6 @@ void TerminalInit()
-
void TerminalClose()
{
free(TerminalShiftRegister);
@@ -64,10 +64,13 @@ void TerminalClose()
endwin();
}
+
+
// Takes an an Apple I ASCII character.
void TerminalInput(char n)
{
- mvwaddch(AppleWindow, TermY,TermX,n);
+ mvwaddch(AppleWindow, TermY, TermX, ' ');
+ mvwaddch(AppleWindow, TermY, TermX, n);
*TerminalShiftRegisterPosition = n;
TerminalShiftRegisterPosition++;
@@ -77,9 +80,9 @@ void TerminalInput(char n)
TermX++;
- if (n == KEY_ENTER) {
- TermY++;
- }
+ //if (n == KEY_ENTER) {
+ // TermY++;
+ //}
if (TermX >= 40) {
TermX = 0;
@@ -100,7 +103,7 @@ void TerminalInput(char n)
if (offset >= (TerminalShiftRegister + 960))
offset -= 960;
- mvwaddch(AppleWindow, i, j, *(offset));
+ mvwaddch(AppleWindow, i, j, ToAscii(*(offset)));
offset++;
}}
diff --git a/src/video/signetics.c b/src/video/signetics.c
index 4a996d8..09e9836 100644
--- a/src/video/signetics.c
+++ b/src/video/signetics.c
@@ -1,8 +1,6 @@
-// signetics.h
+// signetics.c
// Signetics refers to the various Signetics brand chips which the Apple I came with, including a character ROM, and a shift-register based video memory.
-
-#include"../cpu/core.h"
-#include"stdlib.h"
+// Intended to be included during pre-processing into the .c of the used video library.
const byte CharacterROM[0x40] = {
'@' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' ,
@@ -15,4 +13,4 @@ const byte* TerminalShiftRegister;
byte* TerminalShiftRegisterPosition;
-int TerminalShiftRegisterOffset;
+int TerminalShiftRegisterOffset; \ No newline at end of file