Add rule for making VM ROM
x1phosura x1phosura@x1phosura.zone
Tue, 27 Apr 2021 03:16:20 -0400
3 files changed,
10 insertions(+),
6 deletions(-)
M
Makefile
→
Makefile
@@ -24,14 +24,18 @@ 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 $^ 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) $^
M
src/main.c
→
src/main.c
@@ -23,8 +23,8 @@ memory = calloc(RAM_SIZE, sizeof(uint8_t));
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
M
src/rom.h
→
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 @@ 0x30, 0x0f, 0xd1, 0x02, 0x02, 0xff, 0xff, 0x30, 0x30, 0x30, 0x02, 0xff,
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;