summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main.c46
-rw-r--r--src/signetics.h17
-rw-r--r--src/video/interface.h6
-rw-r--r--src/video/ncurses.c5
-rw-r--r--src/video/sdl.c60
5 files changed, 82 insertions, 52 deletions
diff --git a/src/main.c b/src/main.c
index b3c6dbb..d5d5ded 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,55 +1,13 @@
#include"include.h"
-#define SCALE 2
-
-#define CHR_WIDTH 5
-#define CHR_HEIGHT 8
-
-#define WIDTH_SPACE 1 * SCALE
-
-#define MIN_WIDTH (40 * CHR_WIDTH) + 39*WIDTH_SPACE
-#define MIN_HEIGHT (24 * CHR_HEIGHT)
+int main() {
+
-int main(){
- // INITIALIZATION
- SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
- SDL_Window* window = SDL_CreateWindow(
- "Apple C",
- SDL_WINDOWPOS_CENTERED,
- SDL_WINDOWPOS_CENTERED,
- MIN_WIDTH * SCALE,
- MIN_HEIGHT * SCALE,
- SDL_WINDOW_SHOWN
- );
- SDL_Renderer* render = SDL_CreateRenderer(window, -1, 0);
- SDL_Surface* font_surface = SDL_LoadBMP("font.bmp");
- SDL_Texture* font_texture = SDL_CreateTextureFromSurface(render, font_surface);
- SDL_FreeSurface(font_surface);
- SDL_Rect character = {
- .x = 0,
- .y = 0,
- .w = CHR_WIDTH,
- .h = CHR_HEIGHT
- };
- SDL_Rect draw_character = {
- .x = 0,
- .y = 0,
- .w = CHR_WIDTH * SCALE,
- .h = CHR_HEIGHT * SCALE
- };
-
- SDL_SetRenderDrawColor (render, 0, 0, 0, 255);
- SDL_RenderClear (render);
- SDL_RenderCopy (render, font_texture, &character, &draw_character);
- SDL_RenderPresent (render);
- // Just delay before it dies
- SDL_Delay(1000);
- SDL_Quit();
return 0;
} \ No newline at end of file
diff --git a/src/signetics.h b/src/signetics.h
index 8442f11..af25a98 100644
--- a/src/signetics.h
+++ b/src/signetics.h
@@ -1,22 +1,23 @@
// signetics.h
// The Apple I came with its own terminal on-board, with a Signetics 2513 character ROM.
-
+#include"cpu/core.h"
+#include"stdlib.h"
byte CharacterROM[0x40] = {
-'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
-'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '[', '\\', ']', '^', '_',
-' ', '!', '"', '#', '$', '%', '&', '\'', '(', ')', '*', '+', ',', '-', '.', '/',
-'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', ';', '<', '=', '>', '?'
+ '@' , 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' , 'H' , 'I' , 'J' , 'K' , 'L' , 'M' , 'N' , 'O' ,
+ 'P' , 'Q' , 'R' , 'S' , 'T' , 'U' , 'V' , 'W' , 'X' , 'Y' , 'Z' , '[' , '\\', ']' , '^' , '_' ,
+ ' ' , '!' , '"' , '#' , '$' , '%' , '&' , '\'', '(' , ')' , '*' , '+' , ',' , '-' , '.' , '/' ,
+ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' , ':' , ';' , '<' , '=' , '>' , '?'
};
byte* TerminalShiftRegister;
+
int TerminalShiftRegisterOffset = 0;
-void InitVideo(){
- TerminalShiftRegister = malloc(1024); //maybe 960
+void InitSignetics(){
+ TerminalShiftRegister = (byte*)malloc(1024); //maybe 960
}
-
byte ToAppleASCII(char x){
if (x < 32 || x > 95)
return -1;
diff --git a/src/video/interface.h b/src/video/interface.h
new file mode 100644
index 0000000..9c77de2
--- /dev/null
+++ b/src/video/interface.h
@@ -0,0 +1,6 @@
+// interface.h
+// Provides the interface with which all video interactions must occur.
+
+void VideoInit();
+
+void VideoClose(); \ No newline at end of file
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
new file mode 100644
index 0000000..a9221e1
--- /dev/null
+++ b/src/video/ncurses.c
@@ -0,0 +1,5 @@
+// ncurses.c
+// Implements interface.h
+// Provides an in-terminal interface to the emulator.
+
+#include"interface.h" \ No newline at end of file
diff --git a/src/video/sdl.c b/src/video/sdl.c
new file mode 100644
index 0000000..811b0d3
--- /dev/null
+++ b/src/video/sdl.c
@@ -0,0 +1,60 @@
+// sdl.c
+// Implements interface.h
+// Emulates the graphics of the Apple I computer with SDL.
+
+#include"interface.h"
+#include<SDL2/SDL.h>
+
+#define SCALE 2
+
+#define CHR_WIDTH 5
+#define CHR_HEIGHT 8
+
+#define WIDTH_SPACE 1 * SCALE
+
+#define MIN_WIDTH (40 * CHR_WIDTH) + 39*WIDTH_SPACE
+#define MIN_HEIGHT (24 * CHR_HEIGHT)
+
+int VideoInit(){
+ // INITIALIZATION
+ SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
+ SDL_Window* window = SDL_CreateWindow(
+ "Apple C",
+ SDL_WINDOWPOS_CENTERED,
+ SDL_WINDOWPOS_CENTERED,
+ MIN_WIDTH * SCALE,
+ MIN_HEIGHT * SCALE,
+ SDL_WINDOW_SHOWN
+ );
+
+ SDL_Renderer* render = SDL_CreateRenderer(window, -1, 0);
+ SDL_Surface* font_surface = SDL_LoadBMP("font.bmp");
+ SDL_Texture* font_texture = SDL_CreateTextureFromSurface(render, font_surface);
+ SDL_FreeSurface(font_surface);
+
+ SDL_Rect character = {
+ .x = 0,
+ .y = 0,
+ .w = CHR_WIDTH,
+ .h = CHR_HEIGHT
+ };
+
+ SDL_Rect draw_character = {
+ .x = 0,
+ .y = 0,
+ .w = CHR_WIDTH * SCALE,
+ .h = CHR_HEIGHT * SCALE
+ };
+
+ SDL_SetRenderDrawColor (render, 0, 0, 0, 255);
+ SDL_RenderClear (render);
+ SDL_RenderCopy (render, font_texture, &character, &draw_character);
+ SDL_RenderPresent (render);
+
+}
+
+void VideoClose() {
+
+
+ SDL_Quit();
+} \ No newline at end of file