summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoralekseiplusplus <alekseijeaves@protonmail.com>2023-12-08 11:48:26 +1100
committeralekseiplusplus <alekseijeaves@protonmail.com>2023-12-08 11:48:26 +1100
commit8968f471650d25c9df68347644e0e5c0ecdbda6e (patch)
tree2a85cf00b0b1b168a24a1f408d203b5517949a69 /src
parentd28ad56810b43cb3ea5d11e5e32042f69ee04562 (diff)
minor commit
Diffstat (limited to 'src')
-rw-r--r--src/apple.c19
-rw-r--r--src/apple.h9
-rw-r--r--src/cpu/core.h2
-rw-r--r--src/main.c15
-rw-r--r--src/test.c100
-rw-r--r--src/video/interface.h15
-rw-r--r--src/video/ncurses.c17
7 files changed, 32 insertions, 145 deletions
diff --git a/src/apple.c b/src/apple.c
index 6ff8a61..e69cbf8 100644
--- a/src/apple.c
+++ b/src/apple.c
@@ -1,7 +1,7 @@
#include"apple.h"
// The Incredible Wozmon!
-byte ROM[256] = {
+const byte ROM[256] = {
0xd8, 0x58, 0xa0, 0x7f, 0x8c, 0x12, 0xd0, 0xa9,
0xa7, 0x8d, 0x11, 0xd0, 0x8d, 0x13, 0xd0, 0xc9,
0xdf, 0xf0, 0x13, 0xc9, 0x9b, 0xf0, 0x03, 0xc8,
@@ -10,25 +10,25 @@ byte ROM[256] = {
0xf6, 0xad, 0x11, 0xd0, 0x10, 0xfb, 0xad, 0x10,
0xd0, 0x99, 0x00, 0x02, 0x20, 0xef, 0xff, 0xc9,
0x8d, 0xd0, 0xd4, 0xa0, 0xff, 0xa9, 0x00, 0xaa,
- 0x0a, 0x85, 0x2b, 0xc8, 0xb9, 0x00, 0x02, 0xc9, //0x40 ->
+ 0x0a, 0x85, 0x2b, 0xc8, 0xb9, 0x00, 0x02, 0xc9,
0x8d, 0xf0, 0xd4, 0xc9, 0xae, 0x90, 0xf4, 0xf0,
0xf0, 0xc9, 0xba, 0xf0, 0xeb, 0xc9, 0xd2, 0xf0,
0x3b, 0x86, 0x28, 0x86, 0x29, 0x84, 0x2a, 0xb9,
0x00, 0x02, 0x49, 0xb0, 0xc9, 0x0a, 0x90, 0x06,
0x69, 0x88, 0xc9, 0xfa, 0x90, 0x11, 0x0a, 0x0a,
- 0x0a, 0x0a, 0xa2, 0x04, 0x0a, 0x26, 0x28, 0x26, // 0x70->
+ 0x0a, 0x0a, 0xa2, 0x04, 0x0a, 0x26, 0x28, 0x26,
0x29, 0xca, 0xd0, 0xf8, 0xc8, 0xd0, 0xe0, 0xc4,
0x2a, 0xf0, 0x97, 0x24, 0x2b, 0x50, 0x10, 0xa5,
0x28, 0x81, 0x26, 0xe6, 0x26, 0xd0, 0xb5, 0xe6,
0x27, 0x4c, 0x44, 0xff, 0x6c, 0x24, 0x00, 0x30,
0x2b, 0xa2, 0x02, 0xb5, 0x27, 0x95, 0x25, 0x95,
- 0x23, 0xca, 0xd0, 0xf7, 0xd0, 0x14, 0xa9, 0x8d, // 0xA0->
+ 0x23, 0xca, 0xd0, 0xf7, 0xd0, 0x14, 0xa9, 0x8d,
0x20, 0xef, 0xff, 0xa5, 0x25, 0x20, 0xdc, 0xff,
0xa5, 0x24, 0x20, 0xdc, 0xff, 0xa9, 0xba, 0x20,
0xef, 0xff, 0xa9, 0xa0, 0x20, 0xef, 0xff, 0xa1,
0x24, 0x20, 0xdc, 0xff, 0x86, 0x2b, 0xa5, 0x24,
0xc5, 0x28, 0xa5, 0x25, 0xe5, 0x29, 0xb0, 0xc1,
- 0xe6, 0x24, 0xd0, 0x02, 0xe6, 0x25, 0xa5, 0x24, // 0xD0->
+ 0xe6, 0x24, 0xd0, 0x02, 0xe6, 0x25, 0xa5, 0x24,
0x29, 0x07, 0x10, 0xc8, 0x48, 0x4a, 0x4a, 0x4a,
0x4a, 0x20, 0xe5, 0xff, 0x68, 0x29, 0x0f, 0x09,
0xb0, 0xc9, 0xba, 0x90, 0x02, 0x69, 0x06, 0x2c,
@@ -38,7 +38,6 @@ byte ROM[256] = {
void AppleOn() {
Memory = calloc(MEMORY_SIZE, sizeof(byte));
- //ROM = calloc(256, sizeof(byte));
InitInstructionTable();
PC = 0xFF00;
}
@@ -47,13 +46,11 @@ 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;
- free(Memory);
- Memory = calloc(MEMORY_SIZE, sizeof(byte));
+ //free(Memory);
+ //Memory = calloc(MEMORY_SIZE, sizeof(byte));
}
-//byte KBD_CR_val;
-
byte GetMemory(address x){
switch(x)
{
@@ -82,8 +79,6 @@ byte GetMemory(address x){
void SetMemory(address x, byte y){
switch(x)
{
- //case KBD_CR:
- //KBD_CR_val = x;
case DSP:
if (y & 0x80)
DisplayInput(y);
diff --git a/src/apple.h b/src/apple.h
index 244f1b3..f7829e5 100644
--- a/src/apple.h
+++ b/src/apple.h
@@ -6,15 +6,6 @@
#define MEMORY_SIZE 0x0400
-#define XAML 0x24
-#define XAMH 0x25
-#define STL 0x26
-#define STH 0x27
-#define L 0x28
-#define H 0x29
-#define YSAV 0x2A
-#define MODE 0x2B
-
#define KBD 0xD010
#define KBD_CR 0xD011
#define DSP 0xD012
diff --git a/src/cpu/core.h b/src/cpu/core.h
index f83002f..4b8d7f1 100644
--- a/src/cpu/core.h
+++ b/src/cpu/core.h
@@ -12,7 +12,7 @@ extern byte P;
extern byte S;
extern address PC;
extern byte* Memory;
-extern byte ROM[];
+extern const byte ROM[];
enum Addressing
{
diff --git a/src/main.c b/src/main.c
index 801dba7..f1dfada 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,5 @@
#include "apple.h"
#include "video/interface.h"
-#include <ncurses.h>
#include <unistd.h>
#include "cpu/6502.h"
@@ -17,8 +16,13 @@ int main() {
while(1) {
// Computing
CallInstructionTable();
+
// Logging
- fprintf(Log,
+ if (Time >= 0x2000)
+ // Stop logging after an arbitrary amount of time, so as to not create a huge file.
+ fclose(Log);
+ else {
+ fprintf(Log,
"%04x : %04x : %02x : %02x : %02x : %c%c_%c%c%c%c%c : %02x\n",
Time, PC, acc, X, Y,
GetFlag(flag_N) ? 'N':'.' ,
@@ -29,11 +33,12 @@ int main() {
GetFlag(flag_Z) ? 'Z':'.' ,
GetFlag(flag_C) ? 'C':'.' ,
S);
- fflush(Log);
+ fflush(Log);
+ Time++;
+ }
+
// Display information
PrintInfo();
- // Logging
- Time++;
}
DisplayClose();
diff --git a/src/test.c b/src/test.c
deleted file mode 100644
index 0aec2ce..0000000
--- a/src/test.c
+++ /dev/null
@@ -1,100 +0,0 @@
-#include "cpu/core.h"
-#include "apple.h"
-#include "video/interface.h"
-#include <ncurses.h>
-#include <unistd.h>
-
-
-/*
- README
- Assumes that the definition of ROM in apple.c has
- been commented out.
-
- This program is a successor to my 'interpreter.c'
- utility, which unfortunately did not keep up with
- the progress of my program.
- This one works by letting you program the ROM with
- whatever machine code you want.
-
- */
-
-
-
-byte ROM[] = {
- // ADC : 0xFF00
- 0x18,
- 0xA5, 0x20,
- 0x65, 0x22,
- 0x85, 0x24,
- 0xA5, 0x21,
- 0x65, 0x23,
- 0x85, 0x25,
- // SBC : 0xFF0D
- 0x38,
- 0xA5, 0x30,
- 0xE5, 0x32,
- 0x85, 0x34,
- 0xA5, 0x31,
- 0xE5, 0x33,
- 0x85, 0x35
-};
-
-int main() {
-
-
- AppleOn();
-
- PC = 0xFF0D;
-
- // ADC Memory
- SetMemory(0x0020, 0x31);
- SetMemory(0x0021, 0x11);
- SetMemory(0x0022, 0xF9);
- SetMemory(0x0023, 0x0A);
- // SBC Memory
- SetMemory(0x0030, 0x34);
- SetMemory(0x0031, 0x12);
- SetMemory(0x0032, 0x43);
- SetMemory(0x0033, 0x01);
-
- DisplayInit();
-
- while(1) {
- // Computing
- CallInstructionTable(GetMemory(PC), 0);
- // Display information
- PrintInfo();
- // Wait to proceed
- WAIT_ON_USER:
- char c = getch();
- mvprintw(28, 4, " ");
- // If user presses enter, get input.
- if (c == 0x0A) {
- address a = 0x0000;
- mvprintw(28, 4, "Enter address: 0x");
- for (int i = 3; i >= 0; i--) {
- GET_HEX:
- c = getch();
- char cc;
- if ((c >= '0') && (c <= '9')) {
- cc = c-'0';
- }
- else if ((c >= 'A') && (c <= 'F')) {
- cc = c-'A'+10;
- }
- else {
- goto GET_HEX;
- // Direct all complaints to /dev/null
- }
- mvaddch(28, 24-i, c);
- a |= ((address)cc) << 4*i;
- }
- mvprintw(28, 25, " -> %02x", GetMemory(a));
- goto WAIT_ON_USER;
- }
- }
-
- DisplayClose();
-
- return 0;
-}
diff --git a/src/video/interface.h b/src/video/interface.h
index dc074b2..16cc965 100644
--- a/src/video/interface.h
+++ b/src/video/interface.h
@@ -6,17 +6,16 @@
#include "../cpu/core.h"
#include <stdlib.h>
-// Common procedure for taking in user input.
-byte UserInput();
-// Common way to print processor information.
-void PrintInfo();
-
-// Initialization procedure for the terminal
+// Initialize the video system.
void DisplayInit();
-// Exit procedure for the terminal.
+// Shut down the video system.
void DisplayClose();
-// Deliver an Apple ASCII character to the terminal.
+// Display a character on the screen.
void DisplayInput(byte n);
+
+
+// Print information on the video system.
+void PrintInfo();
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
index e9be9b2..3b22231 100644
--- a/src/video/ncurses.c
+++ b/src/video/ncurses.c
@@ -8,17 +8,14 @@
#include"../cpu/6502.h"
-int TermX = 0;
-int TermY = 0;
+int TermX = 0;
+int TermY = 0;
WINDOW *AppleWindow;
-
byte* VRAM;
-
-int vPosition = 0;
-
-int vOffset = 0;
+int vPosition = 0;
+int vOffset = 0;
void PrintInfo()
@@ -69,11 +66,11 @@ void DisplayInit()
mvaddch(i, 0, ' ');
mvaddch(i, 41, ' ');
}
- mvprintw(25, 0, " ~ ");
- mvprintw(26, 0, " Alekseis Apple I ");
- mvprintw(27, 0, " ");
+ mvprintw(25, 0, " ");
attroff(A_REVERSE);
+
+
// Create seperate Apple screen window.
AppleWindow = newwin(24, 40, 1, 1);