'---- DRAW PSEUDO 3D FLOOR ----

SUB FLOOR_3D(X,Y,A,AB,W,R,G,B)
 
 'FLOOR_3D(RUN X,RUN Y,YA?,YB?,WALL?,R,G,B)

 LOCAL T,TT,TTT

 'BELOW?
 IF A<>0 THEN
  'HORIZONT
  BOX 0,A,MAXX,1,0,,RGB(R,G,B)   

  'VERTICAL LINES WITH FAKE PERSPECTIVE
  TT=MAXX/20
  FOR T=0 TO MAXX STEP TT
   LINE T+X MOD TT,A, (T+X MOD TT)*4-MAXX*1.5,MAXY, 1,RGB(R,G,B)
  NEXT T

  'HORIZONTAL LINES WITH FAKE PERSPECTIVE
  T=A: TT=MAXY/30:TTT=0
  DO WHILE T<MAXY
   TY=T+Y MOD TT
   BOX 0,TY,MAXX,1,0,,RGB(R,G,B)
   T=T+TT+(T-A)+Y MOD TT
  LOOP
 ENDIF

 'WALL?
 IF W<>0 THEN
  'VERTICAL LINES - FAKE WALL
  TT=MAXX/20
  FOR T=0 TO MAXX STEP TT
   BOX T+X MOD TT,AB, 1,A-AB, 0,,RGB(R,G,B)
  NEXT T
 ENDIF 

 'ABOVE?
 IF AB<>0 THEN 
  'HORIZONT
  A=AB

  BOX 0,A,MAXX,1,0,,RGB(R,G,B)

  'VERTICAL LINES WITH FAKE PERSPECTIVE
  TT=MAXX/20
  FOR T=0 TO MAXX STEP TT
   LINE T+X MOD TT,A, (T+X MOD TT)*4-MAXX*1.5,0, 1,RGB(R,G,B)
  NEXT T

  'HORIZONTAL LINES WITH FAKE PERSPECTIVE
  T=A: TT=MAXY/30:TTT=0
  DO WHILE T>0
   TY=T-Y MOD TT
   BOX 0,TY,MAXX,1,0,,RGB(R,G,B)
   T=T-(TT+(A-T)+Y MOD TT)
  LOOP
 ENDIF 

END SUB

