Tidy up makefile, fix VM memory bug

This commit is contained in:
Horseshoe Crab 2021-04-29 21:15:13 -04:00
parent a002c494b7
commit 736bc261c1
3 changed files with 16 additions and 10 deletions

View File

@ -8,16 +8,21 @@
# Note: I understand this makefile is not as optimal as it could/should be # Note: I understand this makefile is not as optimal as it could/should be
CC = gcc CC = gcc
CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99 CFLAGS ?= -Wall -Wpedantic -Wextra -std=c99
ROM = rom.bin DEBUG = -g -ggdb
ROM = rom.bin
TRACE_SUFFIX = TRACE_SUFFIX =
TARGET = hard
all: hard all: $(TARGET)
trace: CFLAGS += -g -ggdb -DTRACE -lreadline debug: CFLAGS += $(DEBUG)
debug: $(TARGET)
trace: CFLAGS += $(DEBUG) -DTRACE -lreadline
trace: TRACE_SUFFIX = -trace trace: TRACE_SUFFIX = -trace
trace: hard trace: $(TARGET)
disass: CFLAGS += -DTRACE -lreadline disass: CFLAGS += -DTRACE -lreadline
@ -37,7 +42,7 @@ rom: rom.bin
rom.bin: src/rom.asm src/zeropage.incbin rom.bin: src/rom.asm src/zeropage.incbin
./ass.sh 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) $^ $(CC) $(CFLAGS) -o bin/$@$(TRACE_SUFFIX) $^
clean: clean:
@ -45,5 +50,5 @@ clean:
cleano: cleano:
rm -f bin/*.o rm -f bin/*.o
.PHONY: all trace clean clean .PHONY: all debug trace clean cleano

View File

@ -303,9 +303,10 @@ void vm_trace(struct CPU *cpu, uint8_t *mem, struct TRACE_T *tstate)
break; break;
case 'm': case 'm':
if (sscanf(command+2,"%i %i", &mem_start, if (sscanf(command+2,"%i %i", &mem_start,
&num_bytes) == EOF) &num_bytes) == EOF) {
; // So far, sscanf always returns EOF ; // So far, sscanf always returns EOF
// (idk why). TODO: fix eventually // (idk why). TODO: fix eventually
}
printf("Dumping %d bytes of memory starting " printf("Dumping %d bytes of memory starting "
"at 0x%04x\n", num_bytes, mem_start); "at 0x%04x\n", num_bytes, mem_start);
print_vm_memory(mem, (uint16_t)mem_start, print_vm_memory(mem, (uint16_t)mem_start,

View File

@ -2,7 +2,7 @@
#pragma once // WAAAAAY better than a dumb header guard ;) #pragma once // WAAAAAY better than a dumb header guard ;)
#define RAM_SIZE 16384 // highest it can be given 16-bit addresses #define RAM_SIZE 65536 // highest it can be given 16-bit addresses
#define STACK_LIM 64 #define STACK_LIM 64