From 4ac596fd88573a69b2c9545ba6e7e40a280952e5 Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 8 Jul 2014 22:07:34 -0400 Subject: [PATCH] Add to README, finish makefile; project structure. --- .gitignore | 2 ++ README.md | 30 +++++++++++++++++++++++++++--- crater.c | 10 ++++++++++ makefile | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/z80.c | 4 ++++ src/z80.h | 8 ++++++++ 6 files changed, 97 insertions(+), 3 deletions(-) create mode 100644 crater.c create mode 100644 src/z80.c create mode 100644 src/z80.h diff --git a/.gitignore b/.gitignore index 580979b..18eb94a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ build roms/* !roms/README +crater +crater-dev diff --git a/README.md b/README.md index 277a547..bec4b7a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,30 @@ crater ------- +====== -**crater** is an emulator for the Sega Game Gear, written in C. +**crater** is an emulator for the [Sega Game Gear](game gear), written in C. -... +[game gear]: https://en.wikipedia.org/wiki/Sega_Game_Gear + +Why? +---- + +While the internet is full of emulators for retro game systems, writing one is +nevertheless a fun learning project. + +Crater is named after [31 Crateris](crateris), a star that was – for a short +time in 1974 – misidentified as [a moon of Mercury](moon). Mercury was Sega's +codename for the Game Gear during development. + +[crateris]: http://www.astrostudio.org/xhip.php?hip=58587 +[moon]: https://en.wikipedia.org/wiki/Mercury%27s_moon + +Installing +---------- + +Only OS X and Linux are tested. You'll need a decent compiler that supports C11 +(gcc, clang) and SDL 2. Using Homebrew, you can `brew install sdl2`; using apt, +you can `apt-get install libsdl2-dev`. + +Run `make` and then `./crater`. To build the development version with debug +symbols (they can exist simultaneously), run `make DEBUG=1` and then +`./crater-dev`. diff --git a/crater.c b/crater.c new file mode 100644 index 0000000..94ff8e6 --- /dev/null +++ b/crater.c @@ -0,0 +1,10 @@ +/* Copyright (C) 2014 Ben Kurtovic + Released under the terms of the MIT License. See LICENSE for details. */ + +#include +#include + +int main(int argc, char* argv[]) { + printf("Hello, world!\n"); + return 0; +} diff --git a/makefile b/makefile index e69de29..cefea9c 100644 --- a/makefile +++ b/makefile @@ -0,0 +1,46 @@ +# Copyright (C) 2014 Ben Kurtovic +# Released under the terms of the MIT License. See LICENSE for details. + +PROGRAM = crater +SOURCES = src +BUILD = build +DEVEXT = -dev + +CC = gcc +FLAGS = -O2 -Wall -pedantic -std=c11 +CFLAGS = $(shell sdl2-config --cflags) +LIBS = $(shell sdl2-config --libs) +MKDIR = mkdir -p +RM = rm -rf + +MODE = release +SRCS = $(foreach d,.,$(wildcard *.c)) $(foreach d,$(SOURCES),$(wildcard $(addprefix $(d)/*,.c))) +OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS))) +DEPS = $(OBJS:%.o=%.d) +DIRS = $(sort $(dir $(OBJS))) + +ifdef DEBUG + PROGRAM := $(PROGRAM)$(DEVEXT) + FLAGS += -g + MODE = debug +endif + +.PHONY: all clean + +all: $(PROGRAM) + +clean: + $(RM) $(PROGRAM) $(PROGRAM)$(DEVEXT) $(BUILD) + +$(DIRS): + $(MKDIR) $@ + +$(PROGRAM): $(OBJS) + $(CC) $(FLAGS) $(LIBS) $(OBJS) -o $@ + +$(OBJS): | $(DIRS) + +$(BUILD)/$(MODE)/%.o: %.c + $(CC) $(FLAGS) $(CFLAGS) -MMD -MP -c $< -o $@ + +-include $(DEPS) diff --git a/src/z80.c b/src/z80.c new file mode 100644 index 0000000..6e05461 --- /dev/null +++ b/src/z80.c @@ -0,0 +1,4 @@ +/* Copyright (C) 2014 Ben Kurtovic + Released under the terms of the MIT License. See LICENSE for details. */ + +#include "z80.h" diff --git a/src/z80.h b/src/z80.h new file mode 100644 index 0000000..9916cad --- /dev/null +++ b/src/z80.h @@ -0,0 +1,8 @@ +/* Copyright (C) 2014 Ben Kurtovic + Released under the terms of the MIT License. See LICENSE for details. */ + +#pragma once + +struct register_t { + int pc; +};