TOOL = ../z_tools/
INC = $(TOOL)haribote/

BIM2BIN = $(TOOL)bim2bin.exe -osacmp
MAKE = $(TOOL)make.exe -r
EDIMG = $(TOOL)edimg.exe
IMGTOL = $(TOOL)imgtol.com

# ftHg
default:
	$(MAKE) img

# t@CK
tbitos.img: haribote/ipl.bin haribote/tbitos.sys Makefile \
	bball/bball.hrb invader/invader.hrb calc/calc.hrb \
	notepad/notepad.hrb mplay/mplay.hrb iviewer/iviewer.hrb
	$(BIM2BIN) in:readme_.txt out:readme.txt
	$(BIM2BIN) in:license_.txt out:license.txt
	$(BIM2BIN) in:back_.jpg out:back.jpg
	$(BIM2BIN) in:kirakira_.mml out:kirakira.mml
	$(EDIMG) imgin:../z_tools/fdimg0at.tek \
		wbinimg src:haribote/ipl.bin len:512 from:0 to:0 \
		copy from:haribote/tbitos.sys to:@:\
		copy from:nihongo.fnt to:@: \
		copy from:readme.txt to:@: \
		copy from:license.txt to:@: \
		copy from:back.jpg to:@: \
		copy from:kirakira.mml to:@: \
		copy from:bball/bball.hrb to:@: \
		copy from:invader/invader.hrb to:@: \
		copy from:calc/calc.hrb to:@: \
		copy from:notepad/notepad.hrb to:@: \
		copy from:mplay/mplay.hrb to:@: \
		copy from:iviewer/iviewer.hrb to:@: \
		imgout:tbitos.img
# R}h
img:
	$(MAKE) -C api
	$(MAKE) -C haribote
	$(MAKE) -C bball
	$(MAKE) -C invader
	$(MAKE) -C calc
	$(MAKE) -C notepad
	$(MAKE) -C mplay
	$(MAKE) -C iviewer
	$(MAKE) tbitos.img

run:
	$(MAKE) img
	copy tbitos.img ..\z_tools\qemu\fdimage0.bin
	$(MAKE) -C $(TOOL)qemu

install:
	$(MAKE) img
	$(IMGTOL) w a: tbitos.img

clean:
	$(MAKE) -C api clean
	$(MAKE) -C haribote clean
	$(MAKE) -C bball clean
	$(MAKE) -C invader clean
	$(MAKE) -C calc clean
	$(MAKE) -C notepad clean
	$(MAKE) -C mplay clean
	$(MAKE) -C iviewer clean
	del tbitos.img
