diff --git a/Makefile b/Makefile index 64b33e2..7271948 100644 --- a/Makefile +++ b/Makefile @@ -24,8 +24,6 @@ disass: CFLAGS += -DTRACE -lreadline disass: bin/disass.o bin/vm.o $(CC) $(CFLAGS) -o bin/$@ $^ -# TODO: add rule to make rom.h - bin/%.o: src/%.c $(CC) $(CFLAGS) -o $@ -c $^ @@ -33,6 +31,12 @@ bin/vm.o: bin/main.o: bin/disass.o: +rom: rom.bin + xxd -i src/$^ > src/$@.h + +rom.bin: src/rom.asm src/zeropage.incbin + ./ass.sh src/rom.asm src/zeropage.incbin + hard: bin/main.o bin/vm.o $(CC) $(CFLAGS) -o bin/$@$(TRACE_SUFFIX) $^ diff --git a/src/main.c b/src/main.c index 1c0f5ee..e6f0fb1 100644 --- a/src/main.c +++ b/src/main.c @@ -23,8 +23,8 @@ int main() if (memory == NULL) perror("Failed to allocate memory. Aborting..."); - // __src_rom_bin* comes from "rom.h", generated by make from rom.bin - vm_init(&cpu, memory, __src_rom_bin, __src_rom_bin_len); + // src_rom_bin* comes from "rom.h", generated by make from rom.bin + vm_init(&cpu, memory, src_rom_bin, src_rom_bin_len); printf("Fill in the rest of the flag: RS{"); fgets(flag_input, 20, stdin); flag_input[strcspn(flag_input, "\n")] = 0; // trim trailing newline diff --git a/src/rom.h b/src/rom.h index 1616f17..9c63a50 100644 --- a/src/rom.h +++ b/src/rom.h @@ -1,4 +1,4 @@ -unsigned char __src_rom_bin[] = { +unsigned char src_rom_bin[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -94,4 +94,4 @@ unsigned char __src_rom_bin[] = { 0xff, 0x0d, 0xcb, 0x02, 0x01, 0xcb, 0x02, 0x40, 0x77, 0x12, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30 }; -unsigned int __src_rom_bin_len = 1120; +unsigned int src_rom_bin_len = 1120;