X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=ld45_start_nothing;a=blobdiff_plain;f=Makefile;h=1a2fcb44e034f6efc7e3b89325c7012d2221bb60;hp=90ea9dadd7798022a418ce6dfaba5dc2c00613b3;hb=8a43487117b23806e478603f3c8ab72e37cd1882;hpb=6a16a1c526937ee551f968901cb949d55e35ecda diff --git a/Makefile b/Makefile index 90ea9da..1a2fcb4 100644 --- a/Makefile +++ b/Makefile @@ -1,45 +1,72 @@ -src = $(wildcard src/*.asm) +src = $(wildcard src/boot/*.asm) $(wildcard src/*.asm) +obj = $(src:.asm=.o) data = data/sprsheet.inc -bin = game +name = game +elf = $(name).elf +bin = $(name).bin -QEMU_FLAGS = -fda floppy.img -serial file:serial.log -soundhw sb16 -d guest_errors +ASFLAGS = -f elf32 -i src/ +LDFLAGS = -m elf_i386 -T game.ld -print-gc-sections + +QEMU_FLAGS = -fda floppy.img -serial file:serial.log -d guest_errors .PHONY: all all: floppy.img -bootldr: src/boot/boot.asm $(bin) - nasm -o $@ -f bin -DBINSIZE=`ls -l $(bin) | awk '{print $$5}'` $< - -$(bin): $(src) $(data) - nasm -o $@ -f bin -i src/ src/main.asm +floppy.img: boot.img + dd of=$@ if=/dev/zero bs=512 count=2880 + dd of=$@ if=$< conv=notrunc -boot.img: bootldr $(bin) +boot.img: bootldr.bin $(bin) cat $^ >$@ -floppy.img: boot.img - dd of=$@ if=/dev/zero bs=512 count=2880 - dd of=$@ if=$< bs=1 conv=notrunc +bootldr.bin: $(elf) + objcopy -O binary -j '.boot*' $< $@ -data/sprsheet.inc: data/sprsheet.png - img2tiles -o $@ -n -t 32x32 $< +$(bin): $(elf) + objcopy -O binary -R '.boot*' $< $@ + +$(elf): $(obj) + $(LD) -o $@ $(obj) -Map link.map $(LDFLAGS) + +src/data.o: src/data.asm $(data) + +%.o: %.asm + nasm -o $@ $(ASFLAGS) $< .PHONY: clean clean: - rm -f $(bin) bootldr floppy.img boot.img + rm -f $(bin) $(obj) $(data) bootldr.bin floppy.img boot.img .PHONY: disasm -disasm: bootldr.disasm $(bin).disasm +disasm: bootldr.disasm $(name).disasm + +bootldr.disasm: $(elf) + objdump -d $< -j .boot -j .boot2 -m i8086 >$@ -bootldr.disasm: bootldr - ndisasm -b 16 -o 7c00h $< >$@ +$(name).disasm: $(elf) + objdump -d $< -j .text -m i386 >$@ -$(bin).disasm: $(bin) - ndisasm -b 16 -o 7e00h $< >$@ +$(name).sym: $(elf) + objcopy --only-keep-debug $< $@ .PHONY: run -run: $(bin) +run: floppy.img qemu-system-i386 $(QEMU_FLAGS) .PHONY: debug -debug: $(bin) +debug: floppy.img qemu-system-i386 $(QEMU_FLAGS) -s -S + +.PHONY: sym +sym: $(name).sym + + +tools/csprite/csprite: + $(MAKE) -C tools/csprite + +data/sprsheet.inc: data/sprsheet.png + tools/csprite/csprite -n sprsheet -s 32x32 $< >$@ + +#data/sprsheet.inc: data/sprsheet.png +# img2tiles -o $@ -n -t 32x32 $<