summaryrefslogtreecommitdiff
path: root/src/video
diff options
context:
space:
mode:
Diffstat (limited to 'src/video')
-rw-r--r--src/video/interface.h1
-rw-r--r--src/video/mode.c29
-rw-r--r--src/video/ncurses.c66
-rw-r--r--src/video/sdl.c59
4 files changed, 103 insertions, 52 deletions
diff --git a/src/video/interface.h b/src/video/interface.h
index 16cc965..4597145 100644
--- a/src/video/interface.h
+++ b/src/video/interface.h
@@ -16,6 +16,5 @@ void DisplayClose();
// Display a character on the screen.
void DisplayInput(byte n);
-
// Print information on the video system.
void PrintInfo();
diff --git a/src/video/mode.c b/src/video/mode.c
new file mode 100644
index 0000000..81a314a
--- /dev/null
+++ b/src/video/mode.c
@@ -0,0 +1,29 @@
+#include "interface.h"
+
+int VideoMode;
+
+void SetDisplayMode(int x)
+{
+ if ((x == 0) || (x == 1)) {
+ VideoMode = x;
+ }
+ else {
+ printf("Failed to set video mode.");
+ }
+}
+
+void DisplayInit() {
+ VideoMode ? DisplayInit_SDL() : DisplayInit_Ncurses();
+}
+
+void DisplayClose() {
+ VideoMode ? DisplayClose_SDL() : DisplayClose_Ncurses();
+}
+
+void DisplayInput(byte n) {
+ VideoMode ? DisplayInput_SDL(n) : DisplayInput_Ncurses(n);
+}
+
+void PrintInfo() {
+ VideoMode ? PrintInfo_SDL() : PrintInfo_Ncurses();
+}
diff --git a/src/video/ncurses.c b/src/video/ncurses.c
index 3b22231..aafde9e 100644
--- a/src/video/ncurses.c
+++ b/src/video/ncurses.c
@@ -3,7 +3,6 @@
// Provides an in-terminal interface to the emulator.
#include<ncurses.h>
-#include"interface.h"
#include"../apple.h"
#include"../cpu/6502.h"
@@ -18,37 +17,8 @@ int vPosition = 0;
int vOffset = 0;
-void PrintInfo()
-{
- mvprintw(2, 43, " acc : %02x", acc);
- mvprintw(3, 43, " X : %02x", X );
- mvprintw(4, 43, " Y : %02x", Y );
- mvprintw(5, 43, " PC : %04x", PC);
- mvprintw(6, 43, " S : %02x", S );
- mvprintw(7, 43, "Flags : %c%c_%c%c%c%c%c",
- GetFlag(flag_N) ? 'N':'.' ,
- GetFlag(flag_V) ? 'V':'.' ,
- GetFlag(flag_B) ? 'B':'.' ,
- GetFlag(flag_D) ? 'D':'.' ,
- GetFlag(flag_I) ? 'I':'.' ,
- GetFlag(flag_Z) ? 'Z':'.' ,
- GetFlag(flag_C) ? 'C':'.'
- );
- mvprintw(2, 65, "Stack");
- int count = 3;
- for (int i = 0x1ff; i > 0x1e8; i--) {
- if (i == (0x1ff-S)) // Indicate the stack pointer!
- attron(A_REVERSE);
- mvprintw(count, 65, "%x : %x", i, GetMemory(i));
- attroff(A_REVERSE);
- count++;
- }
- refresh();
-}
-
-
-void DisplayInit()
+void DisplayInit_Ncurses()
{
// ncurses initialization functions.
initscr();
@@ -85,7 +55,7 @@ void DisplayInit()
-void DisplayClose()
+void DisplayClose_Ncurses()
{
free(VRAM);
curs_set(1);
@@ -94,7 +64,7 @@ void DisplayClose()
-void DisplayInput(byte n)
+void DisplayInput_Ncurses(byte n)
{
if (n == BS) {
return;
@@ -160,3 +130,33 @@ void DisplayInput(byte n)
mvwaddch(AppleWindow, TermY, TermX, '@' | A_BLINK);
wrefresh(AppleWindow);
}
+
+
+
+void PrintInfo_Ncurses()
+{
+ mvprintw(2, 43, " acc : %02x", acc);
+ mvprintw(3, 43, " X : %02x", X );
+ mvprintw(4, 43, " Y : %02x", Y );
+ mvprintw(5, 43, " PC : %04x", PC);
+ mvprintw(6, 43, " S : %02x", S );
+ mvprintw(7, 43, "Flags : %c%c_%c%c%c%c%c",
+ GetFlag(flag_N) ? 'N':'.' ,
+ GetFlag(flag_V) ? 'V':'.' ,
+ GetFlag(flag_B) ? 'B':'.' ,
+ GetFlag(flag_D) ? 'D':'.' ,
+ GetFlag(flag_I) ? 'I':'.' ,
+ GetFlag(flag_Z) ? 'Z':'.' ,
+ GetFlag(flag_C) ? 'C':'.'
+ );
+ mvprintw(2, 65, "Stack");
+ int count = 3;
+ for (int i = 0x1ff; i > 0x1e8; i--) {
+ if (i == (0x1ff-S)) // Indicate the stack pointer!
+ attron(A_REVERSE);
+ mvprintw(count, 65, "%x : %x", i, GetMemory(i));
+ attroff(A_REVERSE);
+ count++;
+ }
+ refresh();
+}
diff --git a/src/video/sdl.c b/src/video/sdl.c
index 7161a08..a0cb0af 100644
--- a/src/video/sdl.c
+++ b/src/video/sdl.c
@@ -2,8 +2,7 @@
// Implements interface.h
// Emulates the graphics of the Apple I computer with SDL.
-#include"interface.h"
-#include<SDL2/SDL.h>
+#include<SDL/SDL.h>
#define SCALE 2
@@ -15,24 +14,39 @@
#define MIN_WIDTH (40 * CHR_WIDTH) + 39*WIDTH_SPACE
#define MIN_HEIGHT (24 * CHR_HEIGHT)
-int TerminalInit(){
+
+
+SDL_Surface* MainWindow;
+SDL_Surface* Font;
+
+void PrintInfo_SDL()
+{
+
+
+}
+
+
+int DisplayInit_SDL()
+{
// INITIALIZATION
SDL_Init(SDL_INIT_TIMER | SDL_INIT_VIDEO);
- SDL_Window* window = SDL_CreateWindow(
- "Apple C",
+ MainWindow = SDL_SetVideoMode(MIN_WIDTH*SCALE, MIN_HEIGHT*SCALE, 8, NULL);
+
+
+ /*= 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);
+ );*/
+ Font = SDL_LoadBMP("font.bmp");
+
+ SDL_Surface* font_surface = SDL_LoadBMP("font.bmp");
+
SDL_Rect character = {
.x = 0,
.y = 0,
@@ -47,13 +61,22 @@ int TerminalInit(){
.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);
+ //SDL_SetRenderDrawColor (render, 0, 0, 0, 255);
+ //SDL_RenderClear (render);
+ //SDL_RenderCopy (render, font_texture, &character, &draw_character);
+ //SDL_RenderPresent (render);
+
+}
+void DisplayClose_SDL()
+{
+ SDL_FreeSurface(MainWindow);
+ SDL_FreeSurface(Font);
}
-void TerminalClose() {
- SDL_Quit();
-} \ No newline at end of file
+
+void DisplayInput_SDL()
+{
+
+
+}