####################################################################
#
# CRTEST DEMO 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 -DOPSM_DEMO=1 -comments-c++
LIBISL = c:\psx\isl\lib\release
!else
OPT = -Wall -Wno-unused -DDEBUG=1 -DTERRIT=1 -DGOLDCD=0 -c -O2 -g -mgpopt -G0 -DOPSM_DEMO=1 -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 -DOPSM_DEMO=1 -comments-c++
LIBISL = c:\psx\isl\lib\release
!else
OPT = -Wall -Wno-unused -DDEBUG=1 -DTERRIT=2 -DGOLDCD=0 -c -O2 -g -mgpopt -G0 -DOPSM_DEMO=1 -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 -DOPSM_DEMO=1 -comments-c++
LIBISL = c:\psx\isl\lib\release
!else
OPT = -Wall -Wno-unused -DDEBUG=1 -DTERRIT=0 -DGOLDCD=0 -c -O2 -mgpopt -G0 -DOPSM_DEMO=1 -g -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 ..\democd\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

#removals in the demo...
# wings.obj
# egglaying.obj 
# engine.obj
# catapult.obj 
# construct.obj 
# crate.obj
# seesaw.obj
# islvideo.obj 
# lev_flow.obj 
# gallery.obj
# cntrscn.obj
# card.obj 
# menu.obj cus_dyn.obj cus_full.obj viewer.obj
# curtains.obj 
# rearranged into alpha order, so I can see how far a make-all's got!


crdemo.cpe: crdemo.lnk makedemo.txt text_ids.h gametext.txt \
        actor.obj \
        bff_load.obj \
		camera.obj charactr.obj \
		collide.obj \
		credits.obj cr_asm.obj \
		custom.obj custom2.obj cus_anim.obj \
		debris.obj demo.obj deth.obj dogchase.obj dualshock.obj \
		demostub.obj \
		enemies.obj \
		fireworks.obj fmademo.obj \
        help.obj \
        incbin.obj inv_demo.obj \
        islutil.obj islxa.obj islfile.obj islfont.obj \
		language.obj lights.obj loadsnd.obj \
        maindemo.obj map.obj map_draw.obj map_view.obj \
        maths.obj map_play.obj \
        nme_dogs.obj nme_mrst.obj\
		overlays.obj options.obj \
        pad.obj pause.obj platform.obj platcoll.obj puzzles.obj \
		route.obj \
		scenics.obj snapshot.obj sound.obj \
        sptstream.obj sprouts.obj startup.obj subgame.obj \
        timer.obj

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

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


#
# SECONDARY TARGET - download and run
#

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

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

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

#
# SECONDARY TARGET - download and debug
#

debug: crdemo.cpe
	resetps $(VOPT)
        dbugpsx crdemo /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
#

