####################################################################
#
# CRTEST PS MAKEFILE
#
######################################################################

#
# MACROS
#

# used to     -DPALMODE=1 or 0
# now defines -DTERRIT=0 1 2 (and PALMODE is set up in GLOBAL.H)

!if $(PAL) == 1
VOPT = /p
!if $(MASTER) == 1
OPT = -Wall -Wno-unused -DTERRIT=1 -DGOLDCD=1 -c -O2 -mgpopt -G0 -X0$80010000 -comments-c++
LIBISL = c:\psx\isl\lib\release
!else
OPT = -Wall -Wno-unused -DDEBUG=1 -DTERRIT=1 -DGOLDCD=0 -c -O2 -g -mgpopt -G0 -X0$80010000 -comments-c++
LIBISL = c:\psx\isl\lib\debug
!endif
!endif


!if $(PAL) == 2
VOPT = /p
!if $(MASTER) == 1
OPT = -Wall -Wno-unused -DTERRIT=2 -DGOLDCD=1 -c -O2 -mgpopt -G0 -X0$80010000 -comments-c++
LIBISL = c:\psx\isl\lib\release
!else
OPT = -Wall -Wno-unused -DDEBUG=1 -DTERRIT=2 -DGOLDCD=0 -c -O2 -g -mgpopt -G0 -X0$80010000 -comments-c++
LIBISL = c:\psx\isl\lib\debug
!endif
!endif

!if $(PAL) == 0
VOPT = /n
!if $(MASTER) == 1
OPT = -Wall -Wno-unused -DTERRIT=0 -DGOLDCD=1 -c -O2 -mgpopt -G0 -X0$80010000 -comments-c++
LIBISL = c:\psx\isl\lib\release
!else
OPT = -Wall -Wno-unused -DDEBUG=1 -DTERRIT=0 -DGOLDCD=0 -c -O2 -mgpopt -G0 -g -X0$80010000 -comments-c++
LIBISL = c:\psx\isl\lib\debug
!endif
!endif



CCPSX   = c:\psx\bin\ccpsx
DMPSX   = c:\psx\bin\dmpsx
ASMPSX  = c:\psx\bin\asmpsx
PSYLINK = c:\psx\bin\slink


#
# DEFAULT BUILD RULE
#

.c.obj:
        $(CCPSX) $(OPT) $&.c -o$&.obj
		$(DMPSX) -b $&.obj


#
# MAIN TARGET
#

# I've taken "camera" out for now, coz it wasn't being called, and
# was broken in the version checked in
# (The attrib +r on the cd's gametext was screwing up the refresh)
#        attrib +R ..\cd\shell\gametext.txt

# strip knocks out 49k
# removing nostriplib knocks out 18k

#removals
# powerbar.obj fxtest.obj stilts.obj station.obj
# map_asm.obj overlay1.obj overlay2.obj fixed.obj 
# particle.obj fx.obj

# rearranged into alpha order, so I can see how far a make-all's got!

crtest.cpe: crtest.lnk makefile.txt text_ids.h gametext.txt \
        actor.obj \
        bff_load.obj \
		camera.obj card.obj catapult.obj charactr.obj \
		cntrscn.obj collide.obj construct.obj \
		crate.obj credits.obj cr_asm.obj curtains.obj \
		custom.obj custom2.obj cus_anim.obj cus_dyn.obj cus_full.obj \
		debris.obj demo.obj deth.obj dogchase.obj dualshock.obj \
		egglaying.obj enemies.obj engine.obj \
		fireworks.obj fma.obj \
		gallery.obj \
        help.obj \
        incbin.obj inventory.obj \
        islvideo.obj islutil.obj islxa.obj islfile.obj \
		language.obj lev_flow.obj lights.obj loadsnd.obj \
        main.obj map.obj map_draw.obj map_view.obj \
        menu.obj maths.obj map_play.obj \
        nme_dogs.obj nme_mrst.obj\
		options.obj overlays.obj \
        pad.obj pause.obj platform.obj platcoll.obj puzzles.obj \
		route.obj \
		scenics.obj seesaw.obj snapshot.obj sound.obj \
        sptstream.obj sprouts.obj startup.obj subgame.obj \
        timer.obj \
		viewer.obj \
		wings.obj

        $(PSYLINK) /l $(LIBISL) /psx /wo /v /c /strip /nostriplib @crtest.lnk,crtest.cpe,crtest.sym,crtest.map
#        $(PSYLINK) /l $(LIBISL) /psx /wo /v /c /strip @crtest.lnk,crtest.cpe,crtest.sym,crtest.map
        attrib -R ..\cd\shell\gametext.txt
        copy gametext.txt ..\cd\shell /Y

# copy overlay1.bin ..\cd\bin /Y
# copy overlay2.bin ..\cd\bin /Y
                copy vid_ovl.bin ..\cd\bin /Y
                copy sub1_ovl.bin ..\cd\bin /Y
                copy sub2_ovl.bin ..\cd\bin /Y
                copy sub4_ovl.bin ..\cd\bin /Y
                copy deb_ovl.bin ..\cd\bin /Y


#
# SECONDARY TARGET - download and run
#

run: crtest.cpe
        attrib -R ..\cd\shell\gametext.txt
        copy gametext.txt ..\cd\shell /Y
	resetps $(VOPT)
	delay 100
        run crtest.cpe
	testmess

run2000: crtest.cpe
	resetps /a1340
        run crtest.cpe
	testmess

run2700: crtest.cpe
	reset27 /r /f
        run crtest.cpe
	testmess

#
# SECONDARY TARGET - download and debug
#

debug: crtest.cpe
	resetps $(VOPT)
        dbugpsx crtest /e


#
# GAME COMPONENTS
#

cr_asm.obj:     cr_asm.s
        $(ASMPSX) /zd /l cr_asm.s, cr_asm.obj

# map_asm.obj:    map_draw.s
#        $(ASMPSX) /zd /l map_draw.s, map_asm.obj

incbin.obj:     incbin.s
        $(ASMPSX) /zd /l incbin.s, incbin.obj

text_ids.h:     gametext.txt
        CR_LANG gametext.txt text_ids.h

#
# EVERYTHING ELSE
#

