Tidy up makefile, fix VM memory bug
x1phosura x1phosura@x1phosura.zone
Thu, 29 Apr 2021 21:15:13 -0400
M
Makefile
→
Makefile
@@ -8,16 +8,21 @@ # For more, check out https://youtu.be/G5dNorAoeCM
# Note: I understand this makefile is not as optimal as it could/should be -CC = gcc -CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99 -ROM = rom.bin +CC = gcc +CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99 +DEBUG = -g -ggdb +ROM = rom.bin TRACE_SUFFIX = +TARGET = hard -all: hard +all: $(TARGET) + +debug: CFLAGS += $(DEBUG) +debug: $(TARGET) -trace: CFLAGS += -g -ggdb -DTRACE -lreadline +trace: CFLAGS += $(DEBUG) -DTRACE -lreadline trace: TRACE_SUFFIX = -trace -trace: hard +trace: $(TARGET) disass: CFLAGS += -DTRACE -lreadline@@ -37,7 +42,7 @@
rom.bin: src/rom.asm src/zeropage.incbin ./ass.sh src/rom.asm src/zeropage.incbin -hard: bin/main.o bin/vm.o +$(TARGET): bin/main.o bin/vm.o $(CC) $(CFLAGS) -o bin/$@$(TRACE_SUFFIX) $^ clean:@@ -45,5 +50,5 @@ rm -f bin/*
cleano: rm -f bin/*.o -.PHONY: all trace clean clean +.PHONY: all debug trace clean cleano
M
src/vm.c
→
src/vm.c
@@ -303,9 +303,10 @@ print_vm_memory(mem, 0, 0x100);
break; case 'm': if (sscanf(command+2,"%i %i", &mem_start, - &num_bytes) == EOF) + &num_bytes) == EOF) { ; // So far, sscanf always returns EOF // (idk why). TODO: fix eventually + } printf("Dumping %d bytes of memory starting " "at 0x%04x\n", num_bytes, mem_start); print_vm_memory(mem, (uint16_t)mem_start,