| @@ -1,3 +1,5 @@ | |||||
| build | build | ||||
| roms/* | roms/* | ||||
| !roms/README | !roms/README | ||||
| crater | |||||
| crater-dev | |||||
| @@ -1,6 +1,30 @@ | |||||
| crater | 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`. | |||||
| @@ -0,0 +1,10 @@ | |||||
| /* Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| Released under the terms of the MIT License. See LICENSE for details. */ | |||||
| #include <stdio.h> | |||||
| #include <SDL.h> | |||||
| int main(int argc, char* argv[]) { | |||||
| printf("Hello, world!\n"); | |||||
| return 0; | |||||
| } | |||||
| @@ -0,0 +1,46 @@ | |||||
| # Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| # 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) | |||||
| @@ -0,0 +1,4 @@ | |||||
| /* Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| Released under the terms of the MIT License. See LICENSE for details. */ | |||||
| #include "z80.h" | |||||
| @@ -0,0 +1,8 @@ | |||||
| /* Copyright (C) 2014 Ben Kurtovic <ben.kurtovic@gmail.com> | |||||
| Released under the terms of the MIT License. See LICENSE for details. */ | |||||
| #pragma once | |||||
| struct register_t { | |||||
| int pc; | |||||
| }; | |||||