' MAX DEMO
'
' A DEMO TO SHOW THE MAXIMUM COLOUR MAXIMITE 2 POWER WITH MMBASIC ONLY!

T=MM.INFO(VERSION)
IF T < 5.06 THEN
 CLS
 PRINT "THIS SOFTWARE REQUIRES FIRMWARE VERSION 5.06 OR ABOVE"
 PRINT
 PRINT "PLEASE, UPGRADE YOUR CMM2 AND TRY AGAIN"
 PRINT
 PRINT "YOUR CURRENT FIRMWARE IS " + STR$(T)
 END
ENDIF

OPTION BASE 0

' RUN ONLY A DEMO SECTION?
DEMOSEC=0

' DEBUG? (SHOW FPS AND SECONDS)
DEBUG=0

#INCLUDE "STARFIELD.INC"
#INCLUDE "LINES.INC"
#INCLUDE "FONTS.INC"
#INCLUDE "PLY.INC"
#INCLUDE "FLOOR_3D.INC"

#INCLUDE "DEMO_3D_X.INC"
#INCLUDE "DEMO_BOOT.INC"
#INCLUDE "DEMO_3D_MONITOR.INC"
#INCLUDE "DEMO_TLS.INC"
#INCLUDE "DEMO_BANG_BALLS.INC"
#INCLUDE "DEMO_FLOOR_PLY.INC"
#INCLUDE "DEMO_ROTATIVE_SQUARES.INC"
#INCLUDE "DEMO_3D_DODECAHEDRON.INC"
#INCLUDE "DEMO_RACING.INC"
#INCLUDE "DEMO_3D_EARTH_TEXT.INC"

TIFPS=Timer

'CALL RESOLUTION MODE - 640x400x16
MODE 2,16: CLS: PAUSE(2000) 

'CLEAR SCREEN PAGES
FOR T=0 TO 6: PAGE WRITE T: CLS: NEXT T

'-- SHOW FPS OR LIMIT IT --

SUB FPS(F)

 LOCAL TFPS,T

 IF DEBUG=1 THEN
  T=Timer-TIFPS
  IF T>1 THEN PRINT @(0,0) INT(1000/T)
  PRINT @(0,16) Timer\1000
 ENDIF

 TIFPS=Timer
 DO WHILE PAUSETIMER >= Timer
 LOOP
 PAUSETIMER=Timer+1000/F

END SUB


'-- ARRAYS FOR GENERAL PURPOSES --

SUB INIT_GENERAL_ARRAYS

 DIM X(2000),Y(2000),W(2000)
 DIM XX(2000),YY(2000),ZZ(2000)
 DIM SZ(220),SP(220),TXT$(20),SLINE(10),XD(30),YD(30)
 DIM TR(30),TG(30),TB(30)
 DIM XP%(100), YP%(100), CO%(2), NP%(2)

END SUB


'---- MAIN ----

INIT_PLY_ARRAYS
INIT_GENERAL_ARRAYS
MAXX=MM.HRES: MAXY=MM.VRES
MMAXX=MAXX/2: MMAXY=MAXY/2

'INIT BEFORE THE DEMO BOOT (LOADING IMAGE CAUSE STUTTERING ON DEMO 3D X MUSIC)
INIT_DEMO_BOOT

'GOTO EARTH
'GOTO ROTSQR
'GOTO DODEC
'GOTO RACING
'GOTO TLS
'GOTO BANGBALLS

'INIT DEMO 3D X
INIT_DEMO_3D_X

'RUN DEMO X
RUN_DEMO_3D_X

'RUN CMM2 BOOTING DEMO
RUN_DEMO_BOOT

'INIT_GENERAL_ARRAYS
CLEAR
INIT_PLY_ARRAYS
INIT_GENERAL_ARRAYS
MAXX=MM.HRES: MAXY=MM.VRES
MMAXX=MAXX/2: MMAXY=MAXY/2

'INIT AND RUN WIREFRAME 3D MONITOR DEMO
INIT_DEMO_3D_MONITOR
RUN_DEMO_3D_MONITOR

TLS:

'INIT_GENERAL_ARRAYS
CLEAR
INIT_PLY_ARRAYS
INIT_GENERAL_ARRAYS
MAXX=MM.HRES: MAXY=MM.VRES
MMAXX=MAXX/2: MMAXY=MAXY/2

'INIT AND RUN TEXT, LINES AND STARFIELD DEMO
INIT_DEMO_TLS
RUN_DEMO_TLS

BANGBALLS:

'INIT AND RUN BANG BALLS DEMO
INIT_DEMO_BANG_BALLS
RUN_DEMO_BANG_BALLS

'INIT_GENERAL_ARRAYS
CLEAR
INIT_PLY_ARRAYS
INIT_GENERAL_ARRAYS
MAXX=MM.HRES: MAXY=MM.VRES
MMAXX=MAXX/2: MMAXY=MAXY/2

'INIT AND RUN PSEUDO 3D FLOOR PLY DEMO
INIT_DEMO_FLOOR_PLY
RUN_DEMO_FLOOR_PLY
RUN_DEMO_ROTATIVE_SQUARES_SOFT

ROTSQR:

'INIT AND RUN ROTATIVE SQUARES DEMO
INIT_DEMO_ROTATIVE_SQUARES
RUN_DEMO_ROTATIVE_SQUARES_DANCE

DODEC:

'INIT AND RUN 3D DODECAHEDRON IN FAKE 3D TUNNEL DEMO
INIT_DEMO_3D_DODECAHEDRON
RUN_DEMO_3D_DODECAHEDRON

RACING:

'INIT_GENERAL_ARRAYS
CLEAR
INIT_PLY_ARRAYS
INIT_GENERAL_ARRAYS
MAXX=MM.HRES: MAXY=MM.VRES
MMAXX=MAXX/2: MMAXY=MAXY/2

PLAY STOP

INIT_DEMO_RACING
RUN_DEMO_RACING

EARTH:

'INIT AND RUN 3D EARTH WITH TEXT DEMO
INIT_DEMO_3D_EARTH_TEXT
RUN_DEMO_3D_EARTH_TEXT

MODE 1,8

? "SEE YOU LATER, THANKS FOR WATCHING!..."

