From f916d26f7c27f14b323f4109d25c1064d8a6cb0e Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Wed, 22 Apr 2015 12:39:56 -0500 Subject: [PATCH] Doc updates; .s -> .asm. --- README.md | 38 +++++++++++++++++++++----------------- src/assembler.c | 4 +++- src/assembler/preprocessor.c | 2 +- src/config.c | 8 ++++---- 4 files changed, 29 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 4b2dcf8..f203c7c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ crater ====== -**crater** is an emulator for the [Sega Game Gear][game gear], written in C. +**crater** is an emulator for the [Sega Game Gear][game gear], with an included +[Z80][z80] assembler/disassembler, written in C. [game gear]: https://en.wikipedia.org/wiki/Sega_Game_Gear +[z80]: https://en.wikipedia.org/wiki/Zilog_Z80 Why? ---- @@ -21,40 +23,42 @@ codename for the Game Gear during development. Installing ---------- -Only OS X and Linux are tested. You'll need a decent compiler that supports C11 +Only OS X and Linux are tested. You'll need a modern compiler that supports C11 (clang preferred) and SDL 2. Using Homebrew, you can `brew install sdl2`; using apt, you can `apt-get install libsdl2-dev`. Run `make` to create `./crater`. To build the development version with debug symbols (they can exist simultaneously), run `make DEBUG=1`, which creates -`./crater-dev`. +`./crater-dev`. This also enables the printing of debugging info to stdout. Usage ----- -Running `./crater` without arguments will display a list of ROM images located +Running `./crater` without arguments will display a list of ROM images located in the `roms/` directory, and then ask the user to pick one, or enter their own ROM path. You can provide a path directly with `./crater path/to/rom`. -Add or symlink ROMs to `roms/` at your leisure. Note that they should end in -`.gg` or `.bin`. +Add or symlink ROMs to `roms/` at your leisure. Note that they must end in +`.gg` or `.bin` to be auto-detected. Add `--fullscreen` (`-f`) to enable fullscreen mode, or `--scale ` (`-s `) to scale the game screen by an integer factor. +Add `--debug` (`-g`) to display detailed information about emulation state +while running, including register values and memory contents. You can also +pause emulation to set breakpoints and change state. + `./crater -h` gives (fairly basic) command-line usage, and `./crater -v` gives the current version. -### Advanced options +### Assembler/Disassembler -crater supports several advanced features. Add `--debug` (`-g`) to display -detailed information about emulation state while running, including register -values and memory contents. You can also pause emulation to set breakpoints and -change state. +crater has built-in support for converting Z80 assembly into ROM images, as +well as attempting the reverse process (i.e., disassembling). -`--assemble []` (`-a`) converts z80 assembly source code into a -`.gg` binary that can be run by crater. `--disassemble []` -(`-d`) executes the opposite operation. If no output file is given, crater will -use the name of the input file, with the extension replaced with `.gg` for `-a` -and `.s` for `-d`. By default, this will never overwrite the original filename; -pass `--overwrite` (`-r`) to let crater do so. +`--assemble []` (`-a`) converts source code into a `.gg` binary +that can be run by crater. `--disassemble []` (`-d`) executes +the opposite operation. If no output file is given, crater will use the name of +the input file, with the extension replaced with `.gg` for `-a` and `.asm` for +`-d`. By default, this will never overwrite the original filename; pass +`--overwrite` (`-r`) to let crater do so. diff --git a/src/assembler.c b/src/assembler.c index e6cb86f..69f47a6 100644 --- a/src/assembler.c +++ b/src/assembler.c @@ -69,7 +69,9 @@ static ErrorInfo* tokenize(AssemblerState *state) origin = line; } else { - // TODO + // TODO: first parse data item, then do same bounded check as + // with instructions below, then increment offset and + // ASMData list pointers appropriate ei = error_info_create(line, ET_PREPROC, ED_PP_UNKNOWN); goto cleanup; } diff --git a/src/assembler/preprocessor.c b/src/assembler/preprocessor.c index c814977..5c5972f 100644 --- a/src/assembler/preprocessor.c +++ b/src/assembler/preprocessor.c @@ -242,7 +242,7 @@ static char* read_include_path(const ASMLine *line) if (line->data[i++] != ' ' || line->data[i++] != '"') goto error; - // TODO: parse escaped characters properly + // TODO: parse escaped characters properly <-- use new parse_util func here for (start = i, slashes = 0; i < line->length; i++) { if (line->data[i] == '"' && (slashes % 2) == 0) break; diff --git a/src/config.c b/src/config.c index 4e3077c..893f9f5 100644 --- a/src/config.c +++ b/src/config.c @@ -249,13 +249,13 @@ static int parse_args(Config *config, int argc, char *argv[]) /* If no output file is specified for the assembler, this function picks a - filename based on the input file, replacing its extension with '.gg' or - '.s' (or adding it, if none is present). + filename based on the input file, replacing its extension with ".gg" or + ".asm" (or adding it, if none is present). */ static void guess_assembler_output_file(Config* config) { char *src = config->src_path, *ptr = src + strlen(src) - 1, - *ext = config->assemble ? ".gg" : ".s"; + *ext = config->assemble ? ".gg" : ".asm"; size_t until_ext = ptr - src + 1; do { @@ -265,7 +265,7 @@ static void guess_assembler_output_file(Config* config) } } while (ptr-- >= src); - config->dst_path = malloc(sizeof(char) * (until_ext + 4)); + config->dst_path = malloc(sizeof(char) * (until_ext + 5)); if (!config->dst_path) OUT_OF_MEMORY() strcpy(stpncpy(config->dst_path, src, until_ext), ext);