瀏覽代碼

Add to README, finish makefile; project structure.

master
Ben Kurtovic 10 年之前
父節點
當前提交
4ac596fd88
共有 6 個文件被更改,包括 97 次插入2 次删除
  1. +2
    -0
      .gitignore
  2. +27
    -2
      README.md
  3. +10
    -0
      crater.c
  4. +46
    -0
      makefile
  5. +4
    -0
      src/z80.c
  6. +8
    -0
      src/z80.h

+ 2
- 0
.gitignore 查看文件

@@ -1,3 +1,5 @@
build
roms/*
!roms/README
crater
crater-dev

+ 27
- 2
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`.

+ 10
- 0
crater.c 查看文件

@@ -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;
}

+ 46
- 0
makefile 查看文件

@@ -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)

+ 4
- 0
src/z80.c 查看文件

@@ -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"

+ 8
- 0
src/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;
};

Loading…
取消
儲存