
# CONFIGURATION

#PMODE=-dPMODE	#Uncomment this to compile the protected-mode version
BIOS=-dBIOS	#Uncomment this to use BIOS for disk & keyboard access

AFLAGS=$(PMODE) $(BIOS)
ASM=nasm $(AFLAGS)

################################################################

.PHONY: all
all: image

JUNK=*.bin *.lst setup kernel image

#Create a boot floppy on /dev/fd0
.PHONY: bdisk
bdisk: image
	dd if=image of=/dev/fd0

#Disk image file
image: boot.bin setup kernel
	cp boot.bin image
	dd if=setup >>image
	dd if=kernel bs=1k conv=sync >>image
	#dd if=startup.fb bs=1k conv=sync >>image

boot.bin: boot.asm segments.inc syssize.inc
	$(ASM) -o $@ $< -l boot.lst

#syssize.asm: setup
#	./syssize.sh

setup: setup.bin kernel
	dd if=setup.bin of=setup conv=sync

kernel: kernel.bin
	dd if=kernel.bin of=kernel conv=sync

KERNEL_PARTS=block.asm dict.inc flow.asm graphics.asm keyboard.asm logic.asm math.asm misc.asm stack.asm text.asm

kernel.bin: kernel.asm segments.inc macros.inc regs.inc $(KERNEL_PARTS)
	$(ASM) -o $@ $< -l kernel.lst

setup.bin: setup.asm segments.inc regs.inc
	$(ASM) -o $@ $< -l setup.lst

%.bin: %.asm
	$(ASM) -o $@ $<

.PHONY: clean bak
clean:
	rm -f $(JUNK)

zip:
	zip bak/retro * -x $(JUNK) *~ bak *.zip
