#
# Makefile for new 3D package demo
# TOS/Unix version
#

#
# names of various commands
#
RM=rm -f
CC= gcc
CFLAGS= -mshort -O2 -Wall -fno-builtin -nostdinc -I$(INC)

#
# location of various directories
# These should not change; use the directories
# here rather than system directories.
#
INC=./include
LIB=./lib
FONTDIR=./fonts

#
# rules for making things
#
.SUFFIXES: .o .s .3ds .c
.SUFFIXES: .cry .tga

.c.o:
	$(CC) $(CFLAGS) -o $*.o -c $<
.3ds.o:
	3dsconv -o $*.s $<
	mac -fb -I$(INC) $*.s
	$(RM) $*.s
.s.o:
	mac -fb -I$(INC) $<

.tga.cry:
	tga2cry -binary $<

#
# C library objects
# Normally we would put these into an archive (a .a file) and let the linker sort out
# which ones we need; for demo purposes, though, here they all are explicitly
#
CRT0= $(LIB)/jagrt.o
LIBOBJS = $(LIB)/alloc.o $(LIB)/clock.o $(LIB)/ctype.o $(LIB)/font.o $(LIB)/gpulib.o \
	$(LIB)/joyinp.o $(LIB)/joypad.o $(LIB)/memset.o $(LIB)/olist.o \
	$(LIB)/sprintf.o $(LIB)/strcat.o $(LIB)/strcmp.o $(LIB)/strcpy.o $(LIB)/strdup.o \
	$(LIB)/strncmp.o $(LIB)/util.o $(LIB)/video.o

SRCOBJS = miscasm.o demo.o trig.o mkmat.o \
	wfrend.o gourrend.o gourphr.o \
	texrend.o flattex.o gstex.o \


MODELS = radar.o globe.o torus.o robot.o knight.o
TEXTURES = c1.cry c2.cry c3.cry u1.cry u2.cry u3.cry l1.cry l2.cry l3.cry \
	radar1a.cry radar1b.cry radar1d.cry radar1e.cry turret1b.cry

#
# the textures are arranged in decreasing order of size
#
FIXDATA = -ii c1.cry _c1 -ii c2.cry _c2 -ii c3.cry _c3 -ii u1.cry _u1 -ii u2.cry _u2 -ii u3.cry _u3 \
	-ii l1.cry _l1 -ii l2.cry _l2 -ii l3.cry _l3 \
	-ii radar1b.cry _radar1b -ii radar1d.cry _radar1d \
	-ii turret1b.cry _turret1b \
	-ii radar1a.cry _radar1a -ii radar1e.cry _radar1e \
	-ii $(FONTDIR)/clr6x12.jft _usefnt \

demo.cof: $(CRT0) $(SRCOBJS) $(MODELS) $(TEXTURES) $(LIBOBJS)
	aln -s -e -o demo.cof -rq -a 4000 x x $(FIXDATA) $(CRT0) $(SRCOBJS) $(MODELS) $(LIBOBJS)

clean:
	$(RM) $(SRCOBJS) $(TEXTURES) $(MODELS) $(LIBOBJS) $(CRT0)

wfrend.o: wfrend.s wfdraw.inc load.inc loadxpt.inc clip.inc init.inc clipsubs.inc
gourrend.o: gourrend.s drawpoly.inc load.inc loadxpt.inc clip.inc init.inc gourdraw.inc clipsubs.inc
gourphr.o: gourphr.s drawpoly.inc load.inc loadxpt.inc clip.inc init.inc phrdraw.inc clipsubs.inc
texrend.o: texrend.s drawpoly.inc load.inc loadxpt.inc clip.inc init.inc gourdraw.inc texdraw.inc clipsubs.inc
flattex.o: flattex.s drawpoly.inc load.inc loadxpt.inc clip.inc init.inc gourdraw.inc texdraw1.inc clipsubs.inc
gstex.o: gstex.s drawpoly.inc load.inc loadxpt.inc clip.inc init.inc gourdraw.inc texdraw2.inc clipsubs.inc
