'USELESS SOCK the "graphical" library by Lost socK software
'version 0.21
'http://www.lostsocksoftware.com/
'dave@nodtveidt.net

'$DYNAMIC
'$INCLUDE: 'USELESS.BI'
DEFINT A-Z

'DEMO CODE!!!

USsetMode 6
CLS
PRINT "Welcome to the USELESS SOCK demo for version " + USversion$(1)
PRINT
PRINT "Checking for ANSI.SYS driver:"
getansi = UScheckAnsi
IF getansi = 1 THEN
  PRINT "ANSI.SYS installed."
ELSE
  PRINT "ANSI.SYS not installed."
END IF
PRINT
PRINT "Checking video hardware:"
vidhardware$ = USdetectVideoHardware
PRINT "Your video hardware ID is: "; vidhardware$
PRINT
PRINT "For best results, please run this demo fullscreen."
PRINT
PRINT "Press any key to demonstrate empty box and special filled box routines."
DO: LOOP WHILE INKEY$ = ""
CLS
DO
xx1 = INT(RND(1) * USinternalScreenX) - 10
xx2 = INT(RND(1) * USinternalScreenX + 10)
yy1 = INT(RND(1) * USinternalScreenY) - 10
yy2 = INT(RND(1) * USinternalScreenY + 15)
USdrawBox xx1, yy1, xx2, yy2, 219, INT(RND(1) * 16), SCREENSEG, SCREENOFF
LOOP WHILE INKEY$ = ""
DO
xx1 = INT(RND(1) * USinternalScreenX) - 10
xx2 = INT(RND(1) * USinternalScreenX + 10)
yy1 = INT(RND(1) * USinternalScreenY) - 10
yy2 = INT(RND(1) * USinternalScreenY + 15)
USdrawBoxF xx1, yy1, xx2, yy2, 219, 178, 2, 1, SCREENSEG, SCREENOFF
LOOP WHILE INKEY$ = ""
CLS
COLOR 7
PRINT "USELESS SOCK is capable of perfect straight lines using the Bresenham's"
PRINT "theory. It can also do elipses. Press any key to observe."
DO: LOOP WHILE INKEY$ = ""
CLS
DO
xx1 = INT(RND(1) * USinternalScreenX) - 10
xx2 = INT(RND(1) * USinternalScreenX + 10)
yy1 = INT(RND(1) * USinternalScreenY) - 10
yy2 = INT(RND(1) * USinternalScreenY + 15)
USdrawLine xx1, yy1, xx2, yy2, 219, INT(RND(1) * 16), SCREENSEG, SCREENOFF
LOOP WHILE INKEY$ = ""
CLS
CLS
DO
xx1 = INT(RND(1) * USinternalScreenX) - 10
xx2 = INT(RND(1) * USinternalScreenX + 10)
yy1 = INT(RND(1) * USinternalScreenY) - 10
yy2 = INT(RND(1) * USinternalScreenY + 15)
USdrawEllipse xx1, yy1, xx2, yy2, 219, INT(RND(1) * 16), SCREENSEG, SCREENOFF
LOOP WHILE INKEY$ = ""
CLS
COLOR 7
PRINT "What good is a graphical library with no sprite routines? USELESS SOCK has"
PRINT "them of course. We have placed a SLEEP 1 between each update to show you that"
PRINT "this is actually possible in text mode. Then we will show you how we cram as"
PRINT "many sprites onto the screen as possible. Press any key."
DO: LOOP WHILE INKEY$ = ""
DIM sprite(81) AS INTEGER
USdrawBoxF 1, 1, 8, 8, 219, 178, 15, 10, SCREENSEG, SCREENOFF
USgetSprite 1, 1, 8, 8, VARSEG(sprite(0)), VARPTR(sprite(0)), SCREENSEG, SCREENOFF
DO
  CLS
  aa = INT(RND(1) * USinternalScreenX)
  bb = INT(RND(1) * USinternalScreenY)
  USputSprite aa, bb, VARSEG(sprite(0)), VARPTR(sprite(0)), SCREENSEG, SCREENOFF
  SLEEP 1
LOOP WHILE INKEY$ = ""
DO
  aa = INT(RND(1) * USinternalScreenX)
  bb = INT(RND(1) * USinternalScreenY)
  USputSprite aa, bb, VARSEG(sprite(0)), VARPTR(sprite(0)), SCREENSEG, SCREENOFF
LOOP WHILE INKEY$ = ""
IF LEFT$(vidhardware$, 1) = "V" THEN
  CLS
  COLOR 7
  PRINT "Since you have VGA hardware, we're going to show you the difference between the"
  PRINT "default 720x400 pixel mode and the special 640x400 pixel mode. We'll now fill"
  PRINT "the screen with a CHR$(177)."
  PRINT
  PRINT "Press any key."
  DO: LOOP WHILE INKEY$ = ""
  CLS
  USdrawBoxF 1, 1, 80, 50, 177, 177, 14, 14, SCREENSEG, SCREENOFF
  LOCATE 1, 1
  COLOR 7
  PRINT "Take note of the one-pixel line between each char cell, making something of a"
  PRINT "vertical prison-bar effect. Now, we will enable the special 640x400 mode and"
  PRINT "again fill the screen with CHR$(177) to show the difference."
  PRINT
  PRINT "Press any key."
  DO: LOOP WHILE INKEY$ = ""
  CLS
  USset640x400
  USdrawBoxF 1, 1, 80, 50, 177, 177, 14, 14, SCREENSEG, SCREENOFF
  LOCATE 1, 1
  COLOR 7
  PRINT "Nice, huh? The ugly vertical line has been eliminated!"
  PRINT
  PRINT "Press any key."
  DO: LOOP WHILE INKEY$ = ""
END IF
CLS
COLOR 7
PRINT "Finally, Useless Sock has a BMP routine. You can choose what char to display"
PRINT "'pixels' with, and since the routine is so fast, you can easily alternate"
PRINT "chars to create a really crazy effect!"
PRINT
PRINT "First we'll show you what it's like to load a BMP using 219, then with an"
PRINT "alternating 176,177,178,219 sequence, and then a real eyesore!!"
PRINT
PRINT "Press any key to begin."
DO: LOOP WHILE INKEY$ = ""
result = USloadBMP%("test.bmp", 219, SCREENSEG, SCREENOFF)
DO: LOOP WHILE INKEY$ = ""
DO
  result = USloadBMP%("test.bmp", 176, SCREENSEG, SCREENOFF)
  result = USloadBMP%("test.bmp", 177, SCREENSEG, SCREENOFF)
  result = USloadBMP%("test.bmp", 178, SCREENSEG, SCREENOFF)
  result = USloadBMP%("test.bmp", 219, SCREENSEG, SCREENOFF)
  result = USloadBMP%("test.bmp", 178, SCREENSEG, SCREENOFF)
  result = USloadBMP%("test.bmp", 177, SCREENSEG, SCREENOFF)
  a$ = INKEY$
LOOP WHILE a$ = ""
DO
  result = USloadBMP%("test.bmp", 220, SCREENSEG, SCREENOFF)
  result = USloadBMP%("test.bmp", 223, SCREENSEG, SCREENOFF)
  a$ = INKEY$
LOOP WHILE a$ = ""
CLS
PALETTE
COLOR 7
PRINT "This has been a USELESS SOCK demonstration."
PRINT "Should you ever feel the need to use something as primitive as this, feel"
PRINT "free. This library and all of its source are PUBLIC DOMAIN."
PRINT
PRINT "By Lost socK software"
PRINT "1999, 2003, 2004"
PRINT
PRINT "erm...the end or sumthin'..."
DO: LOOP WHILE INKEY$ = ""
END

