DECLARE SUB makebi ()
DECLARE SUB showchosen ()
DECLARE SUB finishsub ()
DECLARE SUB quitsub ()
DECLARE SUB dispinfo ()
DECLARE SUB setinfo ()
DECLARE SUB makeqlb ()
DECLARE SUB makelib ()

DIM SHARED chosen%(13), choice%, info(14) AS STRING, choices(14) AS STRING, outfile$, libtemp$
setinfo

CLS
LOCATE 2, 1
COLOR 15, 0
PRINT "Choose which Dash modules you want in the library."
COLOR 7, 0
PRINT " [Enter] selects/unselects [Esc] quits [SPACE] selects all"
LOCATE 19, 1
FOR a% = 1 TO 80: PRINT "-"; : NEXT
choice% = 0
DO
   dispinfo
   WAIT &H3DA, 8, 8: WAIT &H3DA, 8
   LOCATE 4, 1
   COLOR 7, 0
   FOR a% = 0 TO 14: PRINT "  "; choices(a%): NEXT

   LOCATE choice% + 4, 1
   COLOR 15, 0
   PRINT "  "; choices(choice%)
  
   showchosen
   a$ = INKEY$
   IF a$ = " " THEN
      FOR temp% = 0 TO 12
         chosen%(temp%) = 1
      NEXT
   END IF
   IF a$ = CHR$(0) + "H" THEN
   choice% = (choice% + 14) MOD 15
   ELSEIF a$ = CHR$(0) + "P" THEN
      choice% = (choice% + 1) MOD 15
   ELSEIF a$ = CHR$(13) THEN
      IF choice% < 14 THEN
         chosen%(choice%) = (chosen%(choice%) + 1) MOD 2
      ELSE
         finishsub
      END IF
   ELSEIF a$ = CHR$(27) THEN
      quitsub
   END IF
LOOP

SUB dispinfo
   LOCATE 20, 1
   FOR a% = 1 TO 320: PRINT " "; : NEXT
   LOCATE 20, 1
   PRINT choices(choice%)
   PRINT SPACE$(3) + info(choice%)
END SUB

SUB finishsub
   FOR a% = 0 TO 13
      IF chosen%(a%) <> 0 THEN EXIT FOR
   NEXT
   IF a% < 14 THEN
      makeqlb
      makelib
      makebi
      PRINT "If there were no errors, the library has been made.  If you saw any errors, you may have been missing some files, so you will have to find them and run this    again.  (Note: Warnings do not matter.)"
      COLOR 7, 0
   ELSE
      quitsub
   END IF
   PRINT
   END
END SUB

SUB makebi
   OPEN outfile$ + ".bi" FOR OUTPUT AS #1
   PRINT #1, "'$DYNAMIC"
'***Subs/Functions***
   IF chosen%(0) THEN
      PRINT #1, "DECLARE SUB VSFadeToColor (r%, g%, b%, shades%)"
      PRINT #1, "DECLARE SUB VSFadeToPalette (file$, shades%)"
      PRINT #1, "DECLARE SUB VSFont (segment%, offset%, x%, y%, text$, col1%, col2%)"
      PRINT #1, "DECLARE SUB VSGrayScale"
      PRINT #1, "DECLARE SUB VSPalette (palfile$)"
      PRINT #1, "DECLARE SUB VSShadowFont (segment%, offset%, x%, y%, text$, col1%, col2%, col3%, col4%)"
      PRINT #1, "DECLARE SUB VSSavePalette (palfile$)"
   END IF
   IF chosen%(1) THEN
      PRINT #1, "DECLARE SUB VSFillPoly (BYVAL segment%, BYVAL offset%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL x3%, BYVAL y3%, BYVAL x4%, BYVAL y4%, BYVAL col%)"
      PRINT #1, "DECLARE SUB VSTexture (BYVAL segment1%, BYVAL offset1%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL x3%, BYVAL y3%, BYVAL x4%, BYVAL y4%, BYVAL segment2%, BYVAL offset2%, BYVAL flag%)"
      PRINT #1, "DECLARE SUB VSTri (BYVAL segment1%, BYVAL offset1%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL x3%, BYVAL y3%, BYVAL segment2%, BYVAL offset2%, BYVAL pixelVector%)"
      PRINT #1, "DECLARE sub VSWall (BYVAL segment1%, BYVAL offset1%, BYVAL x1%, BYVAL y1%, BYVAL y2%, BYVAL x2%, BYVAL y3%, BYVAL y4%, BYVAL segment2%, BYVAL offset2%)"
   END IF
   IF chosen%(2) THEN
      PRINT #1, "DECLARE FUNCTION MouseClickInBox% (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%)"
      PRINT #1, "DECLARE FUNCTION MouseClickOutBox% (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%)"
      PRINT #1, "DECLARE FUNCTION MouseX%"
      PRINT #1, "DECLARE FUNCTION MouseY%"
      PRINT #1, "DECLARE FUNCTION MouseL%"
      PRINT #1, "DECLARE FUNCTION MouseR%"
      PRINT #1, "DECLARE SUB MouseOff"
      PRINT #1, "DECLARE SUB MouseOn"
      PRINT #1, "DECLARE FUNCTION MouseOverBox% (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%)"
      PRINT #1, "DECLARE SUB MouseSetBounds (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%)"
      PRINT #1, "DECLARE SUB MouseSetXY (BYVAL x%, BYVAL y%)"
      PRINT #1, "DECLARE FUNCTION MouseDriver%"
      PRINT #1, "DECLARE FUNCTION JoyButton% (BYVAL buttonnum%)"
      PRINT #1, "DECLARE FUNCTION JoyStickX%"
      PRINT #1, "DECLARE FUNCTION JoyStickY%"
   END IF
   IF chosen%(3) THEN
      PRINT #1, "DECLARE SUB VSBox (BYVAL segment%, BYVAL offset%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL col%)"
      PRINT #1, "DECLARE SUB VSLine (BYVAL segment%, BYVAL offset%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL col%)"
      PRINT #1, "DECLARE SUB VSXLine (BYVAL segment%, BYVAL offset%, BYVAL x1%, BYVAL x2%, BYVAL y%, BYVAL col%)"
      PRINT #1, "DECLARE SUB VSYLine (BYVAL segment%, BYVAL offset%, BYVAL x%, BYVAL y1%, BYVAL y2%, BYVAL col%)"
   END IF
   IF chosen%(4) THEN
      PRINT #1, "DECLARE SUB VSClearKB"
      PRINT #1, "DECLARE SUB VSDelay (BYVAL time%)"
      PRINT #1, "DECLARE SUB VSFadeBlack (BYVAL x%)"
      PRINT #1, "DECLARE SUB VSFadeWhite (BYVAL x%)"
      PRINT #1, "DECLARE SUB VSGraphics"
      PRINT #1, "DECLARE SUB VSText"
      PRINT #1, "DECLARE SUB VSBorder (BYVAL segment%, BYVAL offset%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL col1%, BYVAL col2%, BYVAL col3%)"
      PRINT #1, "DECLARE SUB VSNegative"
      PRINT #1, "DECLARE SUB VSRotatePalF (BYVAL FirstColor%, BYVAL SecondColor%)"
      PRINT #1, "DECLARE SUB VSRotatePalB (BYVAL FirstColor%, BYVAL SecondColor%)"
   END IF
   IF chosen%(5) THEN
      PRINT #1, "DECLARE SUB VSFill (BYVAL segment%, BYVAL offset%, BYVAL col%)"
      PRINT #1, "DECLARE SUB VSPCopy (BYVAL segment1%, BYVAL offset%, BYVAL segment2%, BYVAL offset2%, BYVAL flag%)"
      PRINT #1, "DECLARE SUB VSScrollD (BYVAL segment%, BYVAL offset%, BYVAL y%)"
      PRINT #1, "DECLARE SUB VSScrollL (BYVAL segment%, BYVAL offset%, BYVAL x%)"
      PRINT #1, "DECLARE SUB VSScrollR (BYVAL segment%, BYVAL offset%, BYVAL x%)"
      PRINT #1, "DECLARE SUB VSScrollU (BYVAL segment%, BYVAL offset%, BYVAL y%)"
   END IF
   IF chosen%(6) THEN
      PRINT #1, "DECLARE FUNCTION VSCollide% (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE FUNCTION VSCollide2% (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL col%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSGet (BYVAL segment1%, BYVAL offset1%, BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSPut (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSPutT (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSSprite (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL segment2%, BYVAL offset2%, BYVAL flag%)"
      PRINT #1, "DECLARE SUB VSSpriteC (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL col%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSSpriteR (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL cosval%, BYVAL sinval%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSSpriteS (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL sx%, BYVAL sy%, BYVAL segment2%, BYVAL offset2%)"
   END IF
   IF chosen%(7) THEN
      PRINT #1, "DECLARE SUB VSParaStar (BYVAL segment1%, BYVAL offset1%, BYVAL x%, BYVAL y%, BYVAL col%, BYVAL segment2%, BYVAL offset2%)"
      PRINT #1, "DECLARE SUB VSPset (BYVAL segment%, BYVAL offset%, BYVAL x%, BYVAL y%, BYVAL col%)"
      PRINT #1, "DECLARE FUNCTION VSPoint% (BYVAL segment%, BYVAL offset%, BYVAL x%, BYVAL y%)"
   END IF
   IF chosen%(8) THEN
      PRINT #1, "DECLARE SUB VSBlit (BYVAL segment1%, BYVAL offset1%, BYVAL segment2%, BYVAL offset2%, BYVAL bytes%)"
      PRINT #1, "DECLARE SUB VSDefSeg (BYVAL segment%)"
      PRINT #1, "DECLARE SUB VSPoke16 (BYVAL offset%, BYVAL col%)"
      PRINT #1, "DECLARE SUB VSPoke32 (BYVAL offset%, BYVAL col&)"
      PRINT #1, "DECLARE FUNCTION VSPeek16% (BYVAL offset%)"
      PRINT #1, "DECLARE FUNCTION VSPeek32& (BYVAL offset%)"
   END IF
   IF chosen%(9) THEN
      PRINT #1, "DECLARE FUNCTION VSAllocateXMS% (BYVAL NumKB%)"
      PRINT #1, "DECLARE FUNCTION VSDeallocateXMS% (BYVAL Handle%)"
      PRINT #1, "DECLARE FUNCTION VSDetectXMS%"
      PRINT #1, "DECLARE FUNCTION VSFreeXMS%"
      PRINT #1, "DECLARE FUNCTION VSMoveXMS%(BYVAL DestAddress&, BYVAL DestHdl%, BYVAL SrcAddress&, BYVAL SrcHdl%, BYVAL NumBytes&)"
      PRINT #1, "DECLARE FUNCTION VSResizeXMS% (BYVAL Handle%, BYVAL NumKB%)"
      PRINT #1, "DECLARE FUNCTION VSTotalXMS%"
   END IF
   IF chosen%(11) THEN
      PRINT #1, "DECLARE FUNCTION VSCosine% (BYVAL angle%)"
      PRINT #1, "DECLARE FUNCTION VSSine% (BYVAL angle%)"
      PRINT #1, "DECLARE FUNCTION VSVisible% (BYVAL x1%, BYVAL y1%, BYVAL x2%, BYVAL y2%, BYVAL x3%, BYVAL y3%)"
   END IF
   IF chosen%(10) THEN
      PRINT #1, "DECLARE FUNCTION VSFileMatchInit% (BYVAL DTAseg%, BYVAL DTAoff%, BYVAL filenameseg%, BYVAL filenameoff%)"
      PRINT #1, "DECLARE FUNCTION VSFileMatch%"
      PRINT #1, "DECLARE FUNCTION VSLoad% (BYVAL filenameseg%, BYVAL filenameoff%, BYVAL writeseg%, BYVAL writeoff%, BYVAL nbytes&)"
      PRINT #1, "DECLARE FUNCTION VSLoadPut% (BYVAL filenameseg%, BYVAL filenameoff%, BYVAL x%, BYVAL y%, BYVAL bufferseg%, BYVAL bufferoff%)"
   END IF
 
'***Variables***
   IF chosen%(10) THEN
      PRINT #1, "TYPE dta"
      PRINT #1, "   Res AS STRING * 21"
      PRINT #1, "   Attr AS STRING * 1"
      PRINT #1, "   Filetime AS INTEGER"
      PRINT #1, "   Filedata AS INTEGER"
      PRINT #1, "   Filesize AS LONG"
      PRINT #1, "   Filename AS STRING * 13"
      PRINT #1, "   Res2 AS STRING * 85"
      PRINT #1, "END TYPE"
      PRINT #1, "DIM MatchedName AS dta"
   END IF
END SUB

SUB makelib
   SHELL "del " + outfile$ + ".lib"
   temp$ = "lib " + outfile$
   IF chosen%(0) = 1 THEN temp$ = temp$ + "+dashstd"
   IF chosen%(1) = 1 THEN temp$ = temp$ + "+dtexture"
   IF chosen%(2) = 1 THEN temp$ = temp$ + "+dperiph"
   IF chosen%(3) = 1 THEN temp$ = temp$ + "+dline"
   IF chosen%(4) = 1 THEN temp$ = temp$ + "+dmisc"
   IF chosen%(5) = 1 THEN temp$ = temp$ + "+dscreen"
   IF chosen%(6) = 1 THEN temp$ = temp$ + "+dsprite"
   IF chosen%(7) = 1 THEN temp$ = temp$ + "+dpixel"
   IF chosen%(8) = 1 THEN temp$ = temp$ + "+dmemory"
   IF chosen%(9) = 1 THEN temp$ = temp$ + "+dxms"
   IF chosen%(10) = 1 THEN temp$ = temp$ + "+dfile"
   IF chosen%(11) = 1 THEN temp$ = temp$ + "+dmath"
   COLOR 9, 0
   temp$ = temp$ + libtemp$ + ","
   PRINT temp$
   COLOR 7, 0
   SHELL temp$
END SUB

SUB makeqlb
   temp$ = "link /qu"
   IF chosen%(0) = 1 THEN temp$ = temp$ + " dashstd"
   IF chosen%(1) = 1 THEN temp$ = temp$ + " dtexture"
   IF chosen%(2) = 1 THEN temp$ = temp$ + " dperiph"
   IF chosen%(3) = 1 THEN temp$ = temp$ + " dline"
   IF chosen%(4) = 1 THEN temp$ = temp$ + " dmisc"
   IF chosen%(5) = 1 THEN temp$ = temp$ + " dscreen"
   IF chosen%(6) = 1 THEN temp$ = temp$ + " dsprite"
   IF chosen%(7) = 1 THEN temp$ = temp$ + " dpixel"
   IF chosen%(8) = 1 THEN temp$ = temp$ + " dmemory"
   IF chosen%(9) = 1 THEN temp$ = temp$ + " dxms"
   IF chosen%(10) = 1 THEN temp$ = temp$ + " dfile"
   IF chosen%(11) = 1 THEN temp$ = temp$ + " dmath"
   IF chosen%(12) = 1 THEN temp$ = temp$ + " qb.lib"
   IF chosen%(13) = 1 THEN
      DO
         LOCATE 19, 1: FOR a% = 1 TO 320: PRINT " "; : NEXT
         LOCATE 19, 1
         INPUT "What other library would you like to link to it (no extension)"; a$
         PRINT
         temp$ = temp$ + " " + a$ + ".lib"
         libtemp$ = libtemp$ + "+" + a$ + ".lib"
         INPUT "Would you like to link another library (Y/N)"; a$
         IF UCASE$(a$) <> "Y" THEN EXIT DO
      LOOP
   END IF
   CLS
   INPUT "What will the output file be called (default=Dash)"; outfile$
   IF outfile$ = "" THEN outfile$ = "dash"
   temp$ = temp$ + "," + outfile$ + ",,bqlb45"
   COLOR 9, 0
   PRINT temp$
   COLOR 7, 0
   SHELL temp$
END SUB

SUB quitsub
   COLOR 7, 0
   CLS
   PRINT "No changes to the library have been made."
   PRINT
   END
END SUB

SUB setinfo
   choices(0) = "Standard"
   choices(1) = "Texture-mapping"
   choices(2) = "Peripherals"
   choices(3) = "Lines"
   choices(4) = "Miscellaneous"
   choices(5) = "Screen control"
   choices(6) = "Sprites"
   choices(7) = "Pixels"
   choices(8) = "Memory addressing"
   choices(9) = "Extended Memory"
   choices(10) = "File accessing"
   choices(11) = "Math"
   choices(12) = "QB.LIB"
   choices(13) = "(Another library)"
   choices(14) = "Done"

info(0) = "This includes subs for palette manipulation and saving and the displaying of transparent, gradient text and shadowed text."
info(1) = "This includes subs for transparent or translucent texturing or transparent" + CHR$(13) + "filling of quadrilaterals and triangles."
info(2) = "This includes subs to control and read information on the mouse and reading  information on a joystick or gamepad."
info(3) = "This includes subs for drawing horizontal, vertical, and diagonal lines and" + CHR$(13) + "for filling in boxes."
info(4) = "This includes subs for changing between screens 13h and 3h, drawing a menu" + CHR$(13) + "border, fading white/black, delaying the program, clearing the keyboard" + CHR$(13) + "buffer, etc."
info(5) = "This includes subs for scrolling the screen vertically or horizontally, for" + CHR$(13) + "filling the screen with a color, and for copy between screens."
info(6) = "This includes subs for drawing solid, transparent, translucent, scaled, and  rotated sprites."
info(7) = "This includes subs for placing pixels and getting a pixel's color and for    drawing a starfield layer."
info(8) = "This includes subs for 16- and 32-bit POKEing and PEEKing and blitting" + CHR$(13) + "any amount of memory <64Kb between locations."
info(9) = "This includes subs for accessing XMS, allocating/deallocating XMS, and       transfering data to/from XMS."
info(10) = "This includes subs for loading data from files or drawing sprites directly   from files."
info(11) = "This includes 3D math functions and trig functions."
info(12) = "This is QB's extended library that allows one to call interrupts or assembly language subs."
info(13) = "This allows you to link one or more other libraries to your custom version of" + CHR$(13) + "VirtuaSoft's Dash 13h library."
info(14) = "This saves your changes to Dash and quits."
END SUB

SUB showchosen
   FOR a% = 0 TO 13
      LOCATE a% + 4, 1
      IF chosen%(a%) = 1 THEN PRINT "*"
   NEXT
END SUB

