@@ -2,7 +2,7 @@ | |||||
# Released under the terms of the MIT License. See LICENSE for details. | # Released under the terms of the MIT License. See LICENSE for details. | ||||
PROGRAM = crater | PROGRAM = crater | ||||
SOURCES = src src/assembler | |||||
SOURCES = src | |||||
BUILD = build | BUILD = build | ||||
DEVEXT = -dev | DEVEXT = -dev | ||||
@@ -15,7 +15,8 @@ RM = rm -rf | |||||
MODE = release | MODE = release | ||||
BNRY = $(PROGRAM) | BNRY = $(PROGRAM) | ||||
SRCS = $(filter-out %.inc.c,$(foreach d,. $(SOURCES),$(wildcard $(addprefix $(d)/*,.c)))) | |||||
SDRS = $(shell find $(SOURCES) -type d | xargs echo) | |||||
SRCS = $(filter-out %.inc.c,$(foreach d,. $(SDRS),$(wildcard $(addprefix $(d)/*,.c)))) | |||||
OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS))) | OBJS = $(patsubst %.c,%.o,$(addprefix $(BUILD)/$(MODE)/,$(SRCS))) | ||||
DEPS = $(OBJS:%.o=%.d) | DEPS = $(OBJS:%.o=%.d) | ||||
DIRS = $(sort $(dir $(OBJS))) | DIRS = $(sort $(dir $(OBJS))) | ||||
@@ -6,11 +6,10 @@ | |||||
#include <string.h> | #include <string.h> | ||||
#define DIRECTIVE_MARKER '.' | #define DIRECTIVE_MARKER '.' | ||||
#define NUM_DIRECTIVES 16 | |||||
#define NUM_DIRECTIVES 15 | |||||
#define DIR_INCLUDE ".include" | #define DIR_INCLUDE ".include" | ||||
#define DIR_OPTIMIZER ".optimizer" | |||||
#define DIR_ROM_SIZE ".rom_size" | #define DIR_ROM_SIZE ".rom_size" | ||||
#define DIR_ROM_HEADER ".rom_header" | #define DIR_ROM_HEADER ".rom_header" | ||||
#define DIR_ROM_CHECKSUM ".rom_checksum" | #define DIR_ROM_CHECKSUM ".rom_checksum" | ||||
@@ -8,9 +8,6 @@ | |||||
#include "../assembler.h" | #include "../assembler.h" | ||||
#include "../logging.h" | #include "../logging.h" | ||||
#define ERROR_TYPE(err_info) (asm_error_types[err_info->type]) | |||||
#define ERROR_DESC(err_info) (asm_error_descs[err_info->desc]) | |||||
/* Error strings */ | /* Error strings */ | ||||
static const char *asm_error_types[] = { | static const char *asm_error_types[] = { | ||||
@@ -132,7 +129,8 @@ void error_info_print(const ErrorInfo *einfo, FILE *file) | |||||
{ | { | ||||
ASMErrorLine *line = einfo->line; | ASMErrorLine *line = einfo->line; | ||||
fprintf(file, "error: %s: %s\n", ERROR_TYPE(einfo), ERROR_DESC(einfo)); | |||||
fprintf(file, "error: %s: %s\n", asm_error_types[einfo->type], | |||||
asm_error_descs[einfo->desc]); | |||||
while (line) { | while (line) { | ||||
fprintf(file, "%s:%zu:\n", line->filename, line->lineno); | fprintf(file, "%s:%zu:\n", line->filename, line->lineno); | ||||
fprintf(file, " %.*s\n", (int) line->length, line->data); | fprintf(file, " %.*s\n", (int) line->length, line->data); | ||||
@@ -429,10 +429,6 @@ ErrorInfo* preprocess(AssemblerState *state, const LineBuffer *source) | |||||
BEGIN_DIRECTIVE_BLOCK | BEGIN_DIRECTIVE_BLOCK | ||||
BEGIN_DIRECTIVE(DIR_OPTIMIZER, bool, state->optimizer, false) | |||||
USE_PARSER(bool) | |||||
END_DIRECTIVE | |||||
BEGIN_DIRECTIVE(DIR_ROM_SIZE, size_t, state->rom_size, 0) | BEGIN_DIRECTIVE(DIR_ROM_SIZE, size_t, state->rom_size, 0) | ||||
PARSER_BRANCH(uint32_t, {}, { | PARSER_BRANCH(uint32_t, {}, { | ||||
USE_PARSER(uint32_t, rom_size) | USE_PARSER(uint32_t, rom_size) | ||||
@@ -18,7 +18,6 @@ void state_init(AssemblerState *state) | |||||
state->header.version = 0; | state->header.version = 0; | ||||
state->header.region = DEFAULT_REGION; | state->header.region = DEFAULT_REGION; | ||||
state->header.rom_size = DEFAULT_DECLSIZE; | state->header.rom_size = DEFAULT_DECLSIZE; | ||||
state->optimizer = false; | |||||
state->cross_blocks = false; | state->cross_blocks = false; | ||||
state->rom_size = 0; | state->rom_size = 0; | ||||
@@ -77,7 +77,6 @@ typedef struct { | |||||
typedef struct { | typedef struct { | ||||
ASMHeaderInfo header; | ASMHeaderInfo header; | ||||
bool optimizer; | |||||
bool cross_blocks; | bool cross_blocks; | ||||
size_t rom_size; | size_t rom_size; | ||||
ASMLine *lines; | ASMLine *lines; | ||||
@@ -7,8 +7,6 @@ | |||||
; testing suite. It sets values for the ROM header, and contains basic test | ; testing suite. It sets values for the ROM header, and contains basic test | ||||
; runner code. | ; runner code. | ||||
.optimizer off ; Generate faithful rather than fast code | |||||
.rom_size auto ; Smallest possible ROM size >= 32 KB | .rom_size auto ; Smallest possible ROM size >= 32 KB | ||||
.rom_header auto ; Standard header location (0x7FF0) | .rom_header auto ; Standard header location (0x7FF0) | ||||
.rom_checksum off ; Don't write a ROM checksum to the header | .rom_checksum off ; Don't write a ROM checksum to the header | ||||
@@ -16,6 +14,7 @@ | |||||
.rom_version 0 ; Zero version number | .rom_version 0 ; Zero version number | ||||
.rom_region "GG Export" ; Common region code for Western ROMs | .rom_region "GG Export" ; Common region code for Western ROMs | ||||
.rom_declsize auto ; Set declared size to actual ROM size | .rom_declsize auto ; Set declared size to actual ROM size | ||||
.cross_blocks auto ; Do not allow data to cross between blocks | |||||
; Main routine (execution begins here) | ; Main routine (execution begins here) | ||||
.org $0000 | .org $0000 | ||||