DECLARE SUB openclose ()
DECLARE SUB horl (v%, c%)
' IF YOUR MACHEIN DOES NOT SUPPORT SCREEN 12
' THEN CHANGE IT TO A DIFFERENT SCREEN TRY 13 OR 2
'
' << RIL >> = RIGHT MOST BOUNDARY
' << BOT >> = THE BOTTOM OF THE SCREEN
'
' YOU WILL NEED TO CHANGE THiS TO COMPINSATE FOR
' A SCREEN OTHER THAN 12
' WHEN CODING OR MAKING ALTERATIONS TO THIS PROGRAM USE THE
' QBASIC.EXE /H OPTION8 FOR MAXIMUM VEIWING AREA
'
' Scott can be reached electronically at the following
'
' E - Mail << swg3681@ircc.net >>
' ICQ# << 29443657 >>
' IREAN Network user id << Mrnatural >>
'
'  or by snail mail
'    *****
'   Scott W Gates                                 /-----\
'  702 S/W Barker Street                  _______/ _   _ \_____
'  Sebastian Fl                           |       / | | \     |\
'  32958                                  |       _______     | \
'                                         |       __  __      | |
'                                         |   __  \|  |/ __   | |
'                                         |  /  \________/ \  | |
'                                         |  |\/ \_______\/|  | |
'                                         |  ||            |  | |
'  ________________________________       |  ||            |  | |
' |\ ______________________________\      |  ||            |  | |
' | |                               |     |  ||            |  | |
' | | TTT  A  L   K K III N  N  GGG |     |  ||            |  | |
' | |  T  A A L   KK   I  NN N G    |     |   \           /   | |
' | |  T  AAA L   K K  I  N NN G G  |     |____\         /____| |
'  \|  T  A A L   K K III N  N G  G |      \____\        \_____\|
'   ----------LLL--------------GGG--
'
'
'
'
'                ___    _____
'               / __\  |\____\      ___        _____    ______
'     __       | / _|  | |    \    /\__\      /  ___\  |\ ____\
'   _/  \_     |/ /    | | |\  |  / /   \    / / ___|  | | ____|
'  |      |    || |    | | |_| | |\/  _  \  | / /      | | |
'  | /--\ |    \| \    | | |_/ | | | |_\  | || |       | | |
'  | |  | |      \ \   | |     | | | |__| | || |       | | |__
'  | |  | |      |\ \  | |  __/  | |  __  | || |       | | |__\
'  |_\  /_|      || |  | | |     | | | || | \| |       | | ___|
'               _ | |  | | |     | | | || |   \ \__    | | |__
'              | _/ /  | | |     | | | || |    \ \_\   | | |__\
'               \|_/    \|_|      \|_| \|_|     \___|   \|_____|
'
'                       PPP  A  RR   A  N  N OOO III DDD  SSSS
'                       P P A A R R A A NN N O O  I  D  D S
'                       PPP AAA RR  AAA N NN O O  I  D  D SSS
'  ############         P   A A R R A A N  N O O  I  D  D    S
'  #          #         P   A A R R A A N  N OOO III DDD  SSS
'  #  A       #
'  # Scott    #
'  #  Gates   #         <<< be the Recognizer >>  
'  #          #
'  # Thing... #
'  #          #
'  ############
'
'
'
'
DEFINT A-Z
DECLARE SUB vline (v, horv, c)
DECLARE SUB HORIZON (horv)
DECLARE SUB DOCUMENTREADER ()
DECLARE SUB GAMEPAUSED ()
DECLARE SUB TANKVEIW (SCORE)
DECLARE SUB GRAB (H, v, eh, EV, DISK, NRP)
DECLARE SUB RECOGEXPLO (eh, EV)
DECLARE SUB callibratejoy (HCNT, VCNT, THCNT, TVCNT)
DECLARE SUB DRAWRECOGNIZER (eh, EV, eh1$, ev1$, op, enemy1$, EROT, EROT1$)
DECLARE SUB CURRSTAT (LIFE!, SCORE!, DISK!)
DECLARE SUB DRAWFLYN (FLH!, FLV!, FL1!, FL2!)
DECLARE SUB DRAWTRON (TRH!, TRV!, TR1!, TR2!)
DECLARE SUB TANKEXPLO (LH, LV, RIL, BOT, EHH, EVV)
DECLARE SUB intro (RIL, BOT)
DECLARE SUB PLAYWAV (wavefile$)
DECLARE SUB ValidWavHeader (FILE$, LenHeader%, dataLen&, nChannels%, nSamplesPerSec&, nAvgBytesPerSec&, ok%)
DECLARE SUB WriteToDSP (v%)
DECLARE SUB PlayBack (buffer$, size%, freq&, BytesPerSec&, chans%, num%)
DECLARE SUB delay (tdelay!)
DECLARE SUB SPEAK (phr$)
DECLARE FUNCTION GetBlasterAddr% ()
DECLARE FUNCTION SBreset% ()

COMMON SHARED BlasterAddr%, dma%, repeats%
     CLEAR 10000

 cent = (640 / 2) - 70
 vl = cent
 vln1 = cent + (640 / 3) - 50
 vln2 = cent - (640 / 3 - 50)
 vln3 = cent + (640 / 5) - 50
 vln4 = cent - (640 / 5 - 50)
 vln5 = vln3 + 160 ' right most grid line
 eh = cent: EV = 200
 op = 1
 RIL = 640: BOT = 400
 H = 1
SCORE = 40
'CALL intro(RIL, BOT)
ES = 5
horv = 50
INPUT "DO YOU WANT TO USE JOYSTICKS ?  <Y,N>"; YN$
YN$ = UCASE$(YN$)
IF YN$ = "Y" THEN joystkdis = 0: joy$ = " joystick enabled" ELSE joystkdis = 1: joy$ = "keyboard only"

  IF joystkdis = 0 THEN
    CX = STICK(0): CY = STICK(1): CXX = STICK(2): CYY = STICK(3)
     ELSE
     CX = 50
    CY = 50
  END IF
SCREEN 9: REM SET TO LARGE SCREEN LIMITED COLOR

10 CALL TANKVEIW(SCORE)

 IF joystkdis = 0 THEN
  X = STICK(0): Y = STICK(1): XX = STICK(2): YY = STICK(3)
  B = STRIG(0): b1 = STRIG(1): b2 = STRIG(2): B3 = STRIG(3)
 END IF

 LOCATE 2, 20: PRINT joy$


ke$ = INKEY$: REM get keyboard info
ke$ = UCASE$(ke$)
 IF joystkdis = 1 THEN
  X = CX
  Y = CY
 END IF
IF ke$ = "K" THEN X = CX + 50
IF ke$ = "J" THEN X = 20
IF ke$ = "M" THEN Y = CY + 50
IF ke$ = "I" THEN Y = 20


  IF X > (CX + 5) THEN EROT = EROT - 1: IF EROT < 1 THEN EROT = 360
  IF X < (CX - 5) THEN EROT = EROT + 1: IF EROT > 360 THEN EROT = 1
 
 
  IF X > (CX + 5) THEN eh = eh + ES
  IF X < (CX - 5) THEN eh = eh - ES

  IF Y > (CY + 5) THEN EV = EV + ES
  IF Y < (CY - 5) THEN EV = EV - ES

 IF joystkdis = 0 THEN
  IF B = -1 THEN ke$ = "C" ELSE ke$ = "O"
 END IF
  op = op1
  IF ke$ = "C" THEN
  op1 = 0
  CALL openclose
  END IF
  IF ke$ = "O" THEN op1 = 1
  
  
  IF X < (CX + 5) AND X > (CX - 5) THEN IF EROT > 1 AND EROT < 180 THEN EROT = EROT - 1
  IF X < (CX + 5) AND X > (CX - 5) THEN IF EROT > 180 THEN EROT = EROT + 1: IF EROT > 360 THEN EROT = 0

  IF EV > 250 THEN horv = horv - 1: IF horv < 20 THEN horv = 20
  IF EV < 200 THEN horv = horv + 1: IF horv > 340 THEN horv = 340
  IF EV > 350 THEN EV = 350
  IF EV < 30 THEN EV = 30
  IF eh > 500 THEN eh = 500
  IF eh < 20 THEN eh = 20

CALL DRAWRECOGNIZER(eh, EV, eh1$, ev1$, op, enemy1$, EROT, EROT1$)
CALL HORIZON(horv)
   gc = gc + 1: IF gc > 20 THEN gc = 1
  gv = gv + INC
    INC = INC + 1
     gh = horv + gv
      IF gh >= 400 THEN gv = 0: INC = 1
     CALL horl(gh, gc)
    CALL horl(gh1, 0)
  gh1 = gh


  IF eh > (cent + 20) THEN
    vl = vl - 5: IF vl < 5 THEN vl = 506
    vln1 = vln1 - 5: IF vln1 < 5 THEN vln1 = 506
    vln2 = vln2 - 5: IF vln2 < 5 THEN vln2 = 506
    vln3 = vln3 - 5: IF vln3 < 5 THEN vln3 = 506
    vln4 = vln4 - 5: IF vln4 < 5 THEN vln4 = 506
    vln5 = vln5 - 5: IF vln5 < 5 THEN vln5 = 506
                                      
                                       
                                       
                                        
  END IF
  IF eh < (cent - 20) THEN
    vl = vl + 5: IF vl > 506 THEN vl = 5
    vln1 = vln1 + 5: IF vln1 > 506 THEN vln1 = 5
    vln2 = vln2 + 5: IF vln2 > 506 THEN vln2 = 5
    vln3 = vln3 + 5: IF vln3 > 506 THEN vln3 = 5
    vln4 = vln4 + 5: IF vln4 > 506 THEN vln4 = 5
    vln5 = vln5 + 5: IF vln5 > 506 THEN vln5 = 5
   
    

 
  END IF
   ' Draw the grid lines
   CALL vline(vl, horv, gc)
   CALL vline(vln1, horv, gc)
   CALL vline(vln2, horv, gc)
   CALL vline(vln3, horv, gc)
   CALL vline(vln4, horv, gc)
   CALL vline(vln5, horv, gc)

    'Erase the last position of the grid lines...
   IF vl <> (vl1) OR horv1 <> (horv) THEN
    CALL vline(vl1, horv1, 0)
    CALL vline(vln11, horv1, 0)
    CALL vline(vln21, horv1, 0)
   CALL vline(vln31, horv1, 0)
   CALL vline(vln41, horv1, 0)
   CALL vline(vln51, horv1, 0)
   END IF

   vl1 = vl
   vln11 = vln1
   vln21 = vln2
   vln31 = vln3
   vln41 = vln4
   vln51 = vln5
   REM ste vl1 to vl's last numeric value
   horv1 = horv

1000 GOTO 10

SUB callibratejoy (HCNT, VCNT, THCNT, TVCNT)
PRINT "center joystick and press <enter>"
 PRINT "ready your joystick"
 LJH = 50: LJV = 100

 DO
  HCNT = STICK(0): VCNT = STICK(1)
  THCNT = STICK(2): TVCNT = STICK(3)
 LOCATE 10, 10: PRINT "horozontal "; HCNT; " Verticle "; VCNT
 LOCATE 11, 10: PRINT "HOROZONTAL "; THCNT; " VERTICLE "; TVCNT


 ke$ = INKEY$
 LOOP UNTIL ke$ = CHR$(13)


END SUB

DEFSNG A-Z
SUB CURRSTAT (LIFE, SCORE, DISK)

  CALL SPEAK("LIVES-(; LIFE; ")
    PRINT "SCORE-("; SCORE; ")"
    PRINT "DISK(S) IN POSSESSION-("; DISK; ")"
    PRINT "HIT <ENTER> BE READY FOR ACTION"
    DO
    ke$ = INKEY$

    LOOP UNTIL ke$ = CHR$(13)
    
END SUB

DEFINT A-Z
'------------------------------------------------------------------------------
SUB delay (tdelay!)
time1! = TIMER
DO
LOOP WHILE (TIMER - time1! < tdelay!) OR (time1! > TIMER)
END SUB

SUB DOCUMENTREADER
     DIM pa$(800)
   
  CALL SPEAK("DAM YOU USER")

     
   
  CALL SPEAK("YOU HAVE FOUND A BACK DOOR TO DILANGERS TEXT READER")
     DO
     FILES
   
      
       PRINT "pick your directory if this ons will suffice then hit enter"
       INPUT "dir "; dr$
      
       IF dr$ <> "" THEN CHDIR dr$
       
       LOOP UNTIL dr$ = ""
     SPEAK ("what shall i read")
    INPUT "I WILL READ ANY OF THESE FILES TO YOU,END OF LINE"; DOCUMENT$
     IF DOCUMENT$ = "" THEN CALL SPEAK("WHAT YOU DON'T WANT TO READ ANYTHING")

     WHILE DOCUMENT$ <> ""
      CLOSE #1
        LINECOUNT = 1
        PRINT "OPENING-"; dr$ + DOCUMENT$
        OPEN LD$ + DOCUMENT$ FOR INPUT AS #1
     DO
        LINE INPUT #1, pa$(LINECOUNT)
        PRINT pa$(LINECOUNT)
         LINECOUNT = LINECOUNT + 1
    LOOP UNTIL (EOF(1))
    CLOSE #1
    DOCUMENT$ = ""
    WEND
    xl = LINECOUNT
      FOR X = 1 TO (xl)
      PRINT pa$(X)
      CALL SPEAK(pa$(X))
      NEXT X




END SUB

DEFSNG A-Z
SUB DRAWFLYN (FLH, FLV, FL1, FL2)
FLYN$ = "E5F5G5NH5G10R5E2D10G2R10H2U10F2R5H10"

FLH$ = "R" + STR$(FLH): FLV$ = "D" + STR$(FLV)

       FL1$ = "R" + STR$(FL1): FL2$ = "D" + STR$(FL2)

DRAW "BM0,0C6B" + FLH$ + "B" + FLV$ + FLYN$
       IF FL1 <> (FLH) OR FL2 <> (FLV) THEN DRAW "BM0,0C0B" + FL1$ + "B" + FL2$ + FLYN$
       FL1 = FLH: FL2 = FLV







END SUB

DEFINT A-Z
SUB DRAWRECOGNIZER (eh, EV, eh1$, ev1$, op, enemy1$, EROT, EROT1$)
    ENO$ = "s10BU17R5F5R10D30L10E5U10H5L20G5D10F5L10U30R10E5R5BD17s4"
    ENC$ = "s10BU17R5F5R10D10L10G5D10F5L20E5U10H5L10U10R10E5R5BD17s4"
    RECFACE$ = "BU30BL5L5D5R5NU5BR10U5R5D5L5BL5BD30"


    IF op = 1 THEN ENEMY$ = ENO$' regognizer is not ready to pounce
    IF op = 0 THEN ENEMY$ = ENC$' your in for it!!!

            ENEMY$ = ENEMY$ + RECFACE$ + ENEMY$
   n = EROT * 10 MOD 720
   Z = INT(n / 2)
      EROT$ = "TA" + STR$(Z)
   
    eh$ = "R" + STR$(eh): EV$ = "D" + STR$(EV)
    DRAW "BM 0,0C4B" + eh$ + "B" + EV$ + EROT$ + ENEMY$
    DRAW "BM 0,0TA0"
    IF eh1$ <> (eh$) OR ev1$ <> (EV$) OR EROT1$ <> (EROT$) OR enemy1$ <> (ENEMY$) THEN DRAW "BM 0,0C0B" + eh1$ + "B" + ev1$ + EROT1$ + enemy1$
    eh1$ = eh$: ev1$ = EV$
    enemy1$ = ENEMY$
    eh1$ = eh$: ev1$ = EV$
   
    EROT1$ = EROT$
    DRAW "BM0,0TA0"
END SUB

DEFSNG A-Z
SUB DRAWTRON (TRH, TRV, TR1, TR2)


TRON$ = "E5F5G5NH5G10R5E2D10G2R10H2U10F2R5H10"

TRH$ = "R" + STR$(TRH): TRV$ = "D" + STR$(TRV)

       TR1$ = "R" + STR$(TR1): TR2$ = "D" + STR$(TR2)

DRAW "BM0,0C3B" + TRH$ + "B" + TRV$ + TRON$
       IF TR1 <> (TRH) OR TR2 <> (TRV) THEN DRAW "BM0,0C0B" + TR1$ + "B" + TR2$ + TRON$
       TR1 = TRH: TR2 = TRV


END SUB

DEFINT A-Z
SUB GAMEPAUSED
PRINT ""
PRINT " GGG   AA  M   M EEEE PPPP   AA  U  U  SSS  EEEE DDDD       "
PRINT "G   G A  A MM MM E    P   P A  A U  U S     E    D   D      "
PRINT "G     A  A M M M E    P   P A  A U  U S     E    D   D      "
PRINT "G GG  AAAA M   M EEE  PPPP  AAAA U  U  SSS  EEE  D   D      "
PRINT "G   G A  A M   M E    P     A  A U  U     S E    D   D      "
PRINT " GGG  A  A M   M EEEE P     A  A  UUU  SSS  EEEE DDDD       "
PRINT
PRINT "                   <S> TO RESUME:)"

 DO


 ke$ = INKEY$
 ke$ = LCASE$(ke$)

 
 IF ke$ = CHR$(27) THEN CALL DOCUMENTREADER: PRINT "<s> to resume game play"
 LOOP UNTIL ke$ = "s"
 CLS
 CALL SPEAK("READY YOURSELF USER")



END SUB

'------------------------------------------------------------------------------
FUNCTION GetBlasterAddr%
'Get Blaster Address and DMA channel from Environment Variable
tmp% = 0  'No Environment Variable Set...default
blast$ = UCASE$(ENVIRON$("BLASTER"))
IF LEN(blast$) THEN
   tmp% = INSTR(blast$, "A")
   tmp1$ = MID$(blast$, tmp% + 1, 3)
   tmp% = VAL("&H" + tmp1$)
   IF tmp% = 203 THEN tmp% = -1    'If there is no value assigned
   IF tmp% > 0 THEN
      tmp2% = INSTR(blast$, "D")
      dma% = VAL(MID$(blast$, tmp2% + 1))        'dma% is a global variable
      IF dma% < 0 OR dma% > 7 THEN tmp% = -2
   END IF
END IF
GetBlasterAddr% = tmp%
END FUNCTION

SUB GRAB (H, v, eh, EV, DISK, NRP)
 CLAW$ = "TA 0L 10D 10L 10U 10U 10R 10 N U 300 R 10 N U 300 R 10D 10D 10L 10U 10D 10D 10E 10L 10U 10L 10D 10D 10H 10TA0"


ARMH = H
ARMV = 0
ARMH$ = "R" + STR$(H)

FOR ARMV = 0 TO (v) STEP 5
SOUND 100 + ARMV, .05
ARMV$ = "D" + STR$(ARMV)

DRAW "BM0,0BC4" + ARMH$ + "B" + ARMV$ + CLAW$
DRAW "BM0,0BC0" + ARMH1$ + "B" + ARMV1$ + CLAW$
ARMH1$ = ARMH$: ARMV1$ = ARMV$
NEXT ARMV
IF ARMV > (EV - 40) AND ARMH > (eh - 40) AND ARMH < (eh + 40) THEN bv = 1 ELSE CALL SPEAK("MISS"): CLS


eh = H
WHILE bv = 1
FOR ARMV = (v) TO 0 STEP -5
SOUND 100 + (ARMV * 2), .5
ARMV$ = "D" + STR$(ARMV)
DRAW "BM0,0BC4" + ARMH$ + "B" + ARMV$ + CLAW$
DRAW "BM0,0BC0" + ARMH1$ + "B" + ARMV1$ + CLAW$
ARMH1$ = ARMH$: ARMV1$ = ARMV$
EV = ARMV
CALL DRAWRECOGNIZER(eh, EV, eh1$, ev1$, op, enemy1$, EROT, EROT1$)


NEXT ARMV
bv = 0
DISK = DISK + 5
NRP = 1
CLS

WEND



END SUB

SUB GRID (gh, gv)

LINE (5, gh)-(200, gh), 1


END SUB

SUB HORIZON (horv)


LINE (5, horv - 4)-(505, horv - 4), 0
LINE (5, horv - 3)-(505, horv - 3), 7
LINE (5, horv - 2)-(505, horv - 2), 4
LINE (5, horv - 1)-(505, horv - 1), 2
LINE (5, horv)-(505, horv), 1
LINE (5, horv + 1)-(505, horv + 1), 2
LINE (5, horv + 2)-(505, horv + 2), 4
LINE (5, horv + 3)-(505, horv + 3), 7
LINE (5, horv + 4)-(505, horv + 4), 0



END SUB

SUB horl (v, c)
gh = v
LINE (5, gh)-(505, gh), c

END SUB

SUB intro (RIL, BOT)
   teh = 5
 CLS
  SCREEN 2
  LOCATE 7, teh: PRINT "THIS VERSION UTILIZES WAV. TO TALK"
   LOCATE 8, teh: PRINT "PRESS <s> to start"
  LOCATE 9, teh: PRINT "WELCOME TO TRON 1998 BY SCOTT W GATES..."
   LOCATE 10, teh: PRINT "Questions E-mail me at swg3681@ircc.net"
 LOCATE 6, 5: PRINT "SPACE PARANOIDS"
       
CALL DRAWRECOGNIZER(450, 48, eh1$, ev1$, 1, enemy1$, EROT, EROT1$)


HH = -160

DRAW "BM 10,10 S10C4R15D5L5D5L5U5L5U5BR20D10R5U5F5R5H5R5U5L15BR20D10R15U10L15BR20D10R5U5F5R5U10L5D5H5L5S4"
LINE (0, 100)-(RIL, 100), 1
FOR H = 0 TO RIL STEP 7
LINE (H, 100)-(HH, BOT), 1

HH = HH + 15
NEXT H
s = 5
v = 100
DO
v = v + s
s = s + 1
LINE (0, v)-(RIL, v), 1
LOOP UNTIL v > BOT

 SPEAK ("welcome to space paranoids")

DO
  
  ke$ = INKEY$
  ke$ = LCASE$(ke$)
  IF ke$ = "s" OR BU = 1 OR STRIG(0) = -1 OR STRIG(4) = -1 OR STRIG(2) = -1 OR STRIG(6) = -1 THEN ELOP = 1
LOOP UNTIL ELOP = 1


END SUB

SUB openclose
FOR s = 0 TO 2000 STEP 200
SOUND 100 + s, .05
NEXT s
FOR s = 2000 TO 0 STEP -200
SOUND 100 + s, .05
NEXT s

END SUB

'------------------------------------------------------------------------------
SUB PlayBack (buffer$, size%, freq&, BytesPerSec&, chans%, num%)
size% = size% - 1
segment& = VARSEG(buffer$)
offset& = SADD(buffer$)
IF segment& < 0 THEN segment& = segment& + 65536
IF offset& < 0 THEN offset& = offset& + 65536
baseaddr& = segment& * 16 + offset&
look1% = VARPTR(baseaddr&)
look2% = VARPTR(size%)
SELECT CASE dma%
   CASE 0
      dmapage% = &H87   '135 decimal
      dmaaddr% = 0
      dmalen% = 1
   CASE 1
      dmapage% = &H83   '131 decimal
      dmaaddr% = 2
      dmalen% = 3
   CASE 2
      dmapage% = &H81
      dmaaddr% = 4
      dmalen% = 5
   CASE 3
      dmapage% = &H82
      dmaaddr% = 6
      dmalen% = 7
   CASE 4
      dmapage% = &H8F
      dmaaddr% = &HC0
      dmalen% = &HC2
   CASE 5
      dmapage% = &H8B
      dmaaddr% = &HC4
      dmalen% = &HC6
   CASE 6
      dmapage% = &H89
      dmaaddr% = &HC8
      dmalen% = &HCA
   CASE 7
      dmapage% = &H8A
      dmaaddr% = &HCC
      dmalen% = &HCE
END SELECT
SELECT CASE dma%
   CASE 0 TO 3
      dmamask% = &HA
      dmamode% = &HB
      dmaclear% = &HC
      dmastatus% = &H8
   CASE 4 TO 7
      dmamask% = &HD4
      dmamode% = &HD6
      dmaclear% = &HD8
      dmastatus% = &HD0
END SELECT
SELECT CASE dma%
   CASE 0, 4
      dmaterminal% = 1   'bit 0 of status register (&H08 or &HD0)
   CASE 1, 5
      dmaterminal% = 2   'bit 1
   CASE 2, 6
      dmaterminal% = 4   'bit 2
   CASE 3, 7
      dmaterminal% = 8   'bit 3
END SELECT

OUT dmamask%, dma% + 4   'mask the dma channel
OUT dmaclear%, &H0       '(clear the internal DMA flip/flop)
OUT dmamode%, 72 + dma%  '  72=010010XX where XX=dmachannel%
OUT dmaaddr%, PEEK(look1%)      'bits 0-7 of  the 20bit address
OUT dmaaddr%, PEEK(look1% + 1)  'bits 8-15 of the 20bit address
OUT dmapage%, PEEK(look1% + 2)  'bits 16-19 of the 20 bit address
OUT dmalen%, PEEK(look2%)       'bits 0-7 of size%
OUT dmalen%, PEEK(look2% + 1)   'bits 8-15  of size%
OUT dmamask%, dma%              'enable channel

IF num% = 1 THEN  'only need to Write out time constant once
   timeconst% = 256 - 1000000 / (freq& * chans%)
   CALL WriteToDSP(&H40)
   CALL WriteToDSP(timeconst%)
   'Reset Mixer    DSPmixeraddress = Blasteraddr% + &H4
   OUT BlasterAddr% + &H4, &H0
   OUT BlasterAddr% + &H4 + 1, 0
   'Set Volume to Maximum...255
   OUT BlasterAddr% + &H4, &H22
   OUT BlasterAddr% + &H4 + 1, 255
   IF chans% = 2 THEN
      'Set mixer to Stereo Output
      OUT BlasterAddr% + &H4, &HE
      OUT BlasterAddr% + &H4 + 1, 34      '34=2^5+2^1
   END IF
END IF
IF BytesPerSec& > 22000 THEN
   CALL WriteToDSP(&H48)   'Set Block Size
ELSE
   CALL WriteToDSP(&H14)   'DMA Mode 8-bit DAC
END IF
CALL WriteToDSP(PEEK(look2%))      'Lo byte of address
CALL WriteToDSP(PEEK(look2% + 1))  'High byte of address
IF BytesPerSec& > 22000 THEN CALL WriteToDSP(&H91)  'High Speed DMA mode 8-bit
dummy% = INP(dmastatus%)    'Read status byte once to make sure DMA is going.
WAIT dmastatus%, dmaterminal%   'Loop until terminal count bit set in DMA status register
'DMA Transfer is Now Complete
'Acknowledge the DSP interrupt by reading the DATA AVAILABLE port once
dummy% = INP(BlasterAddr% + &HE)    'DSP Available address
END SUB

DEFSNG A-Z
SUB PLAYWAV (wavefile$)


repeats% = 1
BlasterAddr% = GetBlasterAddr%
SELECT CASE BlasterAddr%
   CASE -2
      PRINT "Bad DMA Channel specified!"
      END
   CASE -1
      PRINT "No Port Base Address Given!"
      END
   CASE 0
      PRINT "No BLASTER Environment Variable Set!"
      END
   CASE ELSE
      'Assume a valid Address Exists
'      PRINT "Blaster Address = "; HEX$(BlasterAddr%)
END SELECT
IF NOT SBreset% THEN
   PRINT "SoundBlaster Card Would Not Reset!"
   END
END IF

sp% = INSTR(Spec$, " ")
IF sp% THEN
   wavefile$ = LEFT$(Spec$, sp% - 1)
   repeats% = VAL(RIGHT$(Spec$, LEN(Spec$) - sp%))
   IF repeats% = 0 THEN repeats% = 1
ELSE
   IF LEN(Spec$) THEN
      wavefile$ = Spec$
      repeats% = 1
   END IF
END IF

IF LEN(wavefile$) = 0 THEN
END IF
'wavefile$ = "C:\QBASIC\THEME.WAV"
CALL ValidWavHeader(wavefile$, LenHeader%, WavLen&, Channels%, Sampling&, bytes&, ok%)

IF NOT ok% THEN
   PRINT "Bad Wave File Format"
   END
END IF

MaxBuffer% = 7053

CALL WriteToDSP(&HD1)  'Speaker ON
FOR repeat% = 1 TO repeats%    'This can loop to play the file ii% times]
filenum% = FREEFILE
   OPEN wavefile$ FOR BINARY AS filenum%
      num% = 0
      SEEK filenum%, LenHeader% + 1
      Remaining& = WavLen&
      DO
         num% = num% + 1
         IF Remaining& > MaxBuffer% THEN
            BufferLen% = MaxBuffer%
         ELSE
            BufferLen% = Remaining&
         END IF
         Remaining& = Remaining& - BufferLen%
         buffer$ = SPACE$(BufferLen%)
         GET filenum%, , buffer$
         CALL PlayBack(buffer$, BufferLen%, Sampling&, bytes&, Channels%, num%)
      LOOP WHILE Remaining& > 0
      OUT &H20, &H20   'Reset Normal Interrupt Service
   CLOSE filenum%
NEXT repeat%
CALL WriteToDSP(&HD3)  'Speaker OFF

END SUB

DEFINT A-Z
SUB RECOGEXPLO (eh, EV)
BLOCK$ = "TA 0L 2L 2L 2U 2U 2U 2U 2U 2R 2R 2R 2D 2L 2U 2D 2L 2L 2R 2U 2D 2D 2L 2R 2R 2U 2D 2R 2U 2D 2D 2L 2U 2D 2L 2U 2D 2L 2R 2D 2R 2U 2D 2R 2U 2D 2D 2L 2U 2L 2D 2L 2U 2R 2TA0"




 LH$ = "R" + STR$(eh)
 LV$ = "D" + STR$(EV)
 WHILE DLY < 600
  RIG$ = "R" + STR$(DLY)
  DOWN$ = "D" + STR$(DLY)
  LEF$ = "L" + STR$(DLY)
  UP$ = "U" + STR$(DLY)

  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + RIG$ + BLOCK$
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + DOWN$ + BLOCK$
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + LEF$ + BLOCK$
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + UP$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + RIG1$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + DOWN1$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + LEF1$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + UP1$ + BLOCK$

  RIG1$ = RIG$
  LEF1$ = LEF$
  DOWN1$ = DOWN$
  UP1$ = UP$




 DLY = DLY + 30
 WEND

END SUB

'------------------------------------------------------------------------------
FUNCTION SBreset%
'DSPreset% = address% + &H6
'DSPread% = address% + &HA
'DSPwrite% = address% + &HC
'DSPavail% = address% + &HE
'DSPmixer% = address% + &H4
OUT BlasterAddr% + &H6, 1   'Reset address
delay .1
OUT BlasterAddr% + &H6, 0
time1! = TIMER: noreset% = 0
DO
   'Read Data Available port until bit 7 is set
   'This should take about 100 micro seconds...give it 1 full second
   IF TIMER - time1! > 1! THEN noreset% = -1
LOOP UNTIL ((INP(BlasterAddr% + &HE) AND 128) = 128) OR noreset%
IF NOT noreset% THEN
   IF INP(BlasterAddr% + &HA) = &HAA THEN
      SBreset% = -1
   ELSE
      SBreset% = 0
   END IF
ELSE
   SBreset% = 0
END IF
END FUNCTION

' version 1.0
' up dates to this program are frequently made
' don't hesatae to get your latest version
' contact me at << swg3681@ircc.net>>
' i will be pleased to send you the latest version
' please specify your version in case it may be the current one
' if you make an improvement to this code and want it to be known
' don't hesatate to submit it to me at the above e-mail
'   @@@@@@@@
' speech macro written by Scott W Gates
' all the below string expressings apply just to examining the text at character & ASCII Level
' such as Chr(32) 'Spacebar'
' Reader is the reader status 1 if on 0 if off 'when speech is taking place
' lsize is the character size of the phrase len(phr$)
' Lc is used to count through the phrase to pick out the word$ (words)
'   using a Chr$(32) 'space' as a seperator
' Letr$ is used to assmeble word$
' Phr$ = the complete phrase typed in
' wc = the cuurent character being examined
' rword$ is the word being read without Chr$(32)
' moc moves the wc character marker :0 = inactive(idle) >0 will sum moc with wc
' word$ is the word with safety chr$(32) put in for nltr$ and pltr$ to work
' ltr$ return the current character being read
' Ltva is the number value of ltr$ hence Ltva = val(ltr$)
' nltr$ returns the next letter following the current wc position
' Nlltr$ returns the next to last letter (call) would give l
' Nltv returns the number value of the next character
' pltr$ returns the previous letter befor the current wc position
' Pltv returns the number value of the previous character
' wc is the marker indicating the current character being read
' lsize is the size of the phrase including chr$(32) or spaces
' rword$ is just the word being read no chr$(32) 'spaces
' rsword is len(rword$)
' ntv 'checks if current letter mid(word$,wc,1) is next to a vowel 'a,e,i,o,u'
' lv means long vowel 1 if true 0 if false
' cfv mean check for vowel 1 if true 0 if false :note this may not be directly of use to you
' wpb is the begging of the word len wize in phr$
' wpl is the words length wpl = len(word$) 'note its value is put in
' ch$ returns the character to be added when assembling  word$
' Pronum$ returns the condition of proper number pronunceation from
' Dormant if off
' Active if on
' vowels returns the number of vowels in word
'
SUB SPEAK (phr$)

 IF phr$ = "" THEN phr$ = "speech error"

 rword$ = ""
 phr$ = phr$ + " "
 phr$ = LCASE$(phr$)
 reader = 0: wpb = 1: wpl = 1
'Get phrase size and check all letters
   lsize = LEN(phr$)

   FOR lc = 1 TO lsize
   letr$ = MID$(phr$, lc, 1)
   IF letr$ = CHR$(32) OR lc = (lsize) THEN word$ = MID$(phr$, wpb, wpl): reader = 1
    rword$ = ""
    FOR chc = 1 TO LEN(word$): ch$ = MID$(word$, chc, 1): IF ch$ <> CHR$(32) THEN rword$ = rword$ + ch$
    NEXT chc
    
      wpl = wpl + 1 ' needed to prevent contiuous loop
' show Reader status in
'   IF reader = 0 THEN PRINT "Idle"

'   IF reader = 1 THEN PRINT "Reading"
WHILE reader = 1
    IF wpl > 2 THEN lltr$ = MID$(rword$, wpl - 2, 1)
   IF wpl > 2 THEN nlltr$ = MID$(rword$, wpl - 2, 1):

   word$ = word$ + " ": word$ = " " + word$
   ' Show the word being read in cell "e:6"

   FOR wc = 2 TO wpl + 1 ' Read entire word compinsating for character placement
   IF wpl > 2 THEN pltr$ = MID$(word$, wc - 1, 1)
   ltr$ = MID$(word$, wc, 1): nltr$ = MID$(word$, wc + 1, 1)
   ltva = VAL(ltr$)
' sgl stands for single letter
' the below 'if then' statement test to see if the word is a single letter
' sgl returns a 1 if true 0 if false
   pltv = VAL(pltr$): nltv = VAL(nltr$) ' get the number values of the character if present
   IF pltr$ = CHR$(32) AND nltr$ = CHR$(32) THEN sgl = 1 ELSE sgl = 0
   IF wpl - wc >= 3 THEN L3tr$ = MID$(word$, wc + 2, 1)
' show l3tr$ in cell ("b:3")


' below section of this macro accesses the speech fragments
' it is concerned with assembling speech for numbers
' and commonly used words under united states English
   LV = 0
  'check to see if word has long vowels "a,e,i,o,u"
   IF ltr$ = "a" OR ltr$ = "e" OR ltr$ = "i" OR ltr$ = "o" OR ltr$ = "u" OR ltr$ = "y" THEN cfv = 1: vowels = vowels + 1
    IF cfv = 1 THEN IF nltr$ = "a" OR nltr$ = "e" OR nltr$ = "i" OR nltr$ = "o" OR nltr$ = "u" THEN LV = 1: ntv = 1: moc = 1
     IF cfv = 1 THEN IF lltr$ = "a" OR lltr$ = "e" OR lltr$ = "i" OR lltr$ = "o" OR lltr$ = "u" OR lltr$ = "y" THEN LV = 1
      IF cfv = 1 AND wc < wpl - 3 THEN IF ltr$ <> "o" AND nlltr$ = "a" OR nlltr$ = "e" OR nlltr$ = "i" OR nlltr$ = "o" OR nlltr$ = "u" THEN LV = 1
       'return check for vowel to zero hence cfv=0
        'cfv =1 if true 0 if false


   cfv = 0
   IF rsword = 1 THEN ltr$ = rword$

   '         [[[[[[[[   ]]]]]]]]
   ' [[[[[[[[  standard letters ]]]]]]]
   '         [[[[[[[[   ]]]]]]]]

' PRINT ltr$ 'for testing purposes only
IF ltr$ = "y" AND nltr$ = CHR$(32) THEN say$ = "e": ltr$ = ""
'scope of "a"

   IF ltr$ = "a" AND sgl = 1 THEN say$ = "a": ltr$ = ""
  
    ' a cont aeiou section
' Scope of "b"
   IF ltr$ = "b" AND sgl = 1 THEN say$ = "b"
      IF ltr$ = "b" AND sgl = 0 THEN say$ = "bb"
'scope of "c"
IF ltr$ = "c" AND rword$ = "nice" THEN say$ = "ss": ltr$ = ""
 IF ltr$ = "c" AND rword$ = "space" THEN say$ = "ss": ltr$ = ""
  IF ltr$ = "c" AND rword$ = "come" THEN say$ = "kk": ltr$ = ""
   IF ltr$ = "c" AND sgl = 1 THEN say$ = "c": ltr$ = ""
    IF ltr$ = "c" AND nltr$ = "h" THEN say$ = "ch": ltr$ = "": moc = 1' ch as in church
     IF ltr$ = "c" AND nltr$ = "k" THEN moc = 1: say$ = "kk": ltr$ = ""
      IF ltr$ = "c" AND rword$ = "cell" THEN say$ = "ss": ltr$ = ""
       IF ltr$ = "c" AND ntv = 1 THEN say$ = "ss": ltr$ = ""
        IF ltr$ = "c" AND sgl = 0 AND ntv = 0 THEN say$ = "Cc": ltr$ = ""
         IF ltr$ = "c" AND ntv = 1 THEN say$ = "kk": ltr$ = ""
          IF ltr$ = "c" AND sgl = 0 AND L3tr$ <> "t" THEN say$ = "ss": ltr$ = ""
           IF ltr$ = "c" AND nltr$ = "c" THEN moc = 1: say$ = "kk"
' scope of "d"
   IF ltr$ = "d" AND sgl = 1 THEN say$ = "d"
     IF ltr$ = "d" AND sgl = 0 THEN say$ = "dd"
' scope of "e"
   IF ltr$ = "e" AND sgl = 1 THEN say$ = "e": ltr$ = ""
     ' e phonix at aeiou section
' scope of "f"
   IF ltr$ = "f" AND sgl = 1 THEN say$ = "f"
      IF ltr$ = "f" AND sgl = 0 THEN say$ = "ff"
' scope of "g"
  'PRINT ltr$
  IF ltr$ = "g" AND pltr$ = "e" THEN say$ = "gg": ltr$ = ""
   IF ltr$ = "g" AND nltr$ = "r" THEN say$ = "gg": ltr$ = ""
    IF ltr$ = "g" AND pltr$ <> CHR$(32) AND nltr$ <> CHR$(32) THEN say$ = "JJ": ltr$ = ""
     IF ltr$ = "g" AND sgl = 1 THEN say$ = "g"
      IF ltr$ = "g" AND sgl = 0 THEN say$ = "gg"
' scope of "h"
   IF ltr$ = "h" AND sgl = 1 THEN say$ = "h"
      IF ltr$ = "h" AND sgl = 0 THEN say$ = "hh" 'h as in horse
' scope of "i"
   IF ltr$ = "i" AND sgl = 1 THEN say$ = "i": ltr$ = ""
' scope of "j"
   IF ltr$ = "j" AND sgl = 1 THEN say$ = "j"
      IF ltr$ = "j" AND sgl = 0 THEN say$ = "jj"
' scope of "k"
   IF ltr$ = "k" AND sgl = 1 THEN say$ = "k"
      IF ltr$ = "k" AND sgl = 0 THEN say$ = "kk"
' scope of "l"
   IF ltr$ = "l" AND sgl = 1 THEN say$ = "l"
      IF ltr$ = "l" AND sgl = 0 THEN say$ = "ll": REM  If nltr$ = "l" Then moc = 2
' scope of "m"
   IF ltr$ = "m" AND sgl = 1 THEN say$ = "m"
      IF ltr$ = "m" AND agl = 0 THEN say$ = "mm" ' m as in mouse
' scope of "n"
   IF ltr$ = "n" AND sgl = 1 THEN say$ = "n"
      IF ltr$ = "n" AND sgl = 0 THEN say$ = "nn"
' scope of "o"
   IF ltr$ = "o" AND sgl = 1 THEN say$ = "o"
      ' o's phonixe cont at aeiou section
' scope of "p"
   IF ltr$ = "p" AND sgl = 1 THEN say$ = "p"
      IF ltr$ = "p" AND sgl = 0 THEN say$ = "pp"
' scope of "q"
   IF ltr$ = "q" AND sgl = 1 THEN say$ = "q"
      IF ltr$ = "q" AND sgl = 0 THEN say$ = "k"
' scope of "r"
   IF ltr$ = "r" AND sgl = 1 THEN say$ = "r"
      IF ltr$ = "r" AND sgl = 0 THEN say$ = "rr"
' scope of "s"

   IF ltr$ = "s" AND sgl = 1 THEN say$ = "s"
     IF ltr$ = "s" AND nltr$ = "h" THEN say$ = "sh": moc = 1: ltr$ = "" ' sh as in shack
      IF ltr$ = "s" AND sgl = 0 THEN say$ = "ss"

' scope of "t"
   IF ltr$ = "t" AND sgl = 1 THEN say$ = "t"
    ' "th" as in the
     IF ltr$ = "t" AND nltr$ = "h" THEN moc = 1: say$ = "th": ltr$ = ""' rem th
      IF ltr$ = "t" AND sgl = 0 THEN say$ = "tt"
       IF ltr$ = "t" AND nltr$ = "t" THEN moc = 1: ltr$ = ""
   
' scope of "u"
   IF ltr$ = "u" AND sgl = 1 THEN say$ = "u": ltr$ = ""
' scope of "v"
   IF ltr$ = "v" AND sgl = 1 THEN say$ = "v"
      IF ltr$ = "v" AND sgl = 0 THEN say$ = "vv"
' scope of "w"
   IF ltr$ = "w" AND sgl = 1 THEN say$ = "w"
      IF ltr$ = "w" AND sgl = 0 THEN say$ = "ww"
' scope of "x"
   IF ltr$ = "x" THEN say$ = "x"
' scope of "y"
IF ltr$ = "y" AND rword$ = "by" THEN say$ = "i": ltr$ = ""
 IF ltr$ = "y" AND nltr$ = "" THEN say$ = "e": ltr$ = ""
  IF ltr$ = "y" AND nltr$ = "e" THEN say$ = "yy": ltr$ = ""
   IF ltr$ = "y" AND rword$ = "you" THEN say$ = "U": ltr$ = "": wc = lsize: word$ = ""
    IF ltr$ = "y" AND nltr$ = "o" THEN say$ = "yy": ltr$ = ""
     IF ltr$ = "y" AND pltr$ = "n" THEN say$ = "E": ltr$ = ""
      IF ltr$ = "y" AND rword$ = "byte" THEN say$ = "i": ltr$ = ""
       IF ltr$ = "y" AND sgl = 0 AND LV = 0 THEN say$ = "yy": ltr$ = ""
        IF ltr$ = "y" AND sgl = 1 THEN say$ = "y": ltr$ = ""
         IF ltr$ = "y" AND pltr$ <> CHR$(32) THEN say$ = "e": ltr$ = ""

' scope of "z"
   IF ltr$ = "z" AND sgl = 1 THEN say$ = "z"
      IF ltr$ = "z" AND sgl = 0 THEN say$ = "zz"
' end of standard letters

' special phonix section 'a,e,i,o,u'
' vowel "a"
  IF ltr$ = "a" AND rword$ = "gates" THEN say$ = "a": ltr$ = ""
   IF ltr$ = "a" AND rword$ = "have" THEN say$ = "AA": ltr$ = ""
    IF ltr$ = "a" AND rword$ = "start" THEN say$ = "R": ltr$ = ""
     IF ltr$ = "a" AND rword$ = "are" THEN say$ = "r": ltr$ = "": word$ = "" 'force "R" for "are"
      IF ltr$ = "a" AND rword$ = "happy" THEN say$ = "aa": ltr$ = ""
       IF ltr$ = "a" AND LV = 1 AND nltr$ <> "r" THEN say$ = "a": ltr$ = ""
        IF ltr$ = "a" AND nltr$ = "r" AND LV = 1 THEN say$ = "r": ltr$ = "": moc = 1
         IF ltr$ = "a" AND LV = 0 THEN say$ = "aa": ltr$ = ""
          IF ltr$ = "a" AND lltr$ = "e" THEN say$ = "a": ltr$ = ""
           IF ltr$ = "a" AND sgl = 0 AND lltr$ <> "e" THEN say$ = "a": ltr$ = ""
            IF ltr$ = "a" AND LV = 0 THEN say$ = "aa": ltr$ = ""



' vowel "e
   
      IF ltr$ = "e" AND nltr$ = CHR$(32) AND LV = 1 THEN say$ = "": ltr$ = ""

 IF ltr$ = "e" AND nltr$ = CHR$(32) THEN say$ = "e": ltr$ = ""
   
    

  IF ltr$ = "e" AND nltr$ = "r" THEN say$ = "": ltr$ = ""
   IF ltr$ = "e" AND lltr$ = "y" THEN say$ = "EE": ltr$ = ""
    IF ltr$ = "e" AND ntv = 0 AND nltr$ <> CHR$(32) THEN say$ = "ee": ltr$ = ""
     IF ltr$ = "e" AND nltr$ = "n" THEN say$ = "ii": ltr$ = ""
      IF ltr$ = "e" AND rword$ = "welcome" AND pltr$ = "w" THEN say$ = "ee": ltr$ = ""
       IF ltr$ = "e" AND rword$ = "byte" THEN say$ = "": ltr$ = ""
        IF ltr$ = "e" AND rword$ = "here" AND pltr$ <> "r" THEN say$ = "e"
         IF ltr$ = "e" AND rword$ = "come" THEN say$ = "": ltr$ = ""
          IF ltr$ = "e" AND rword$ = "there" THEN say$ = "eee": ltr$ = ""
           IF ltr$ = "e" AND rword$ = "the" THEN say$ = "e": ltr$ = "":    ' force long e for "the"
            IF ltr$ = "e" AND nltr$ = "r" THEN say$ = "e": ltr$ = ""
             IF ltr$ = "e" AND wc < wpl AND pltr$ <> "p" AND lltr$ <> "o" AND LV = 1 THEN say$ = "e":  ltr$ = ""
              IF ltr$ = "e" AND LV = 1 AND ntv = 1 AND wc < wpl AND pltr$ <> "P" AND lltr$ <> "o" THEN say$ = "e": ltr$ = ""
               IF ltr$ = "e" AND LV = 1 AND sgl = 0 AND pltr$ <> "p" AND wc < wpl THEN say$ = "ee": ltr$ = ""
                IF ltr$ = "e" AND LV = 0 THEN say$ = "e": ltr$ = ""
                 IF ltr$ = "e" AND LV = 1 THEN say$ = "e": ltr$ = ""
          
                      'when all else fails long "e"




  ' vowel "i"
  IF ltr$ = "i" AND rword$ = "hi" THEN say$ = "i": ltr$ = "" ' force long i as in "hi"
   IF ltr$ = "i" AND ntv = 0 AND LV = 0 THEN say$ = "ii": ltr$ = ""
      IF ltr$ = "i" AND LV = 1 THEN say$ = "i": ltr$ = ""

' vowel "o"

IF ltr$ = "o" AND nltr$ = "u" AND lltr$ <> "d" THEN say$ = "oo": moc = 1: ltr$ = ""
 IF ltr$ = "o" AND nltr$ = "u" THEN say$ = "aa": ltr$ = ""
  ' "OU" AS IN FOUND OR SOUND = FORCES AA.WAV
   IF ltr$ = "o" AND pltr$ = "c" AND LV = 0 THEN say$ = "aaa": ltr$ = ""
    IF ltr$ = "o" AND nltr$ = "m" THEN say$ = "uu": ltr$ = ""
     IF ltr$ = "o" AND rword$ = "come" THEN say$ = "o"
      IF ltr$ = "o" AND rword$ = "tron" THEN say$ = "aaa": ltr$ = ""
       IF ltr$ = "o" AND nltr$ = "w" THEN say$ = "aaa": ltr$ = ""
        IF ltr$ = "o" AND plltr$ = "z" THEN say$ = "o": ltr$ = ""
         IF ltr$ = "o" AND nltr$ = "o" THEN say$ = "oo": ltr$ = ""
          IF ltr$ = "o" AND pltr$ = "t" THEN say$ = "oo": ltr$ = ""
           IF ltr$ = "o" AND nltr$ = CHR$(32) AND LV = 1 THEN say$ = "o": ltr$ = ""
            ' o as in 'on'
             IF ltr$ = "o" AND pltr$ = CHR$(32) THEN say$ = "aaa": ltr$ = ""
              IF ltr$ = "o" AND LV = 1 AND nltr$ <> "o" AND ntv = 1 THEN say$ = "o": ltr$ = ""
               IF ltr$ = "o" THEN say$ = "o"
' vowel "u"
 IF ltr$ = "u" AND rword$ = "stupid" THEN say$ = "oo": ltr$ = ""
  IF ltr$ = "u" AND rword$ = "user" THEN say$ = "u": ltr$ = ""
   IF ltr$ = "u" AND LV = 0 THEN say$ = "uu"
     IF ltr$ = "u" AND LV = 1 THEN say$ = "oo": 'leave open for next test of "u"
    
    
    
    
    
    
'   end of vowel section
    
     IF moc > 0 THEN wc = wc + moc: moc = 0
     IF wc > wpl THEN word$ = ""
   LV = 0
' end of special vowel "a,e,i,o,u" section
' Numbers this should be self explanatory...

IF ltr$ = "0" THEN SPEAK ("zero")
IF ltr$ = "9" THEN SPEAK ("nine")
IF ltr$ = "8" THEN SPEAK ("ate")
IF ltr$ = "7" THEN SPEAK ("seven")
IF ltr$ = "6" THEN SPEAK ("six")
IF ltr$ = "5" THEN SPEAK ("five")
IF ltr$ = "4" THEN SPEAK ("for")
IF ltr$ = "3" THEN SPEAK ("three")
IF ltr$ = "2" THEN SPEAK ("to")
IF ltr$ = "1" THEN SPEAK ("wun")
' end of numbers
  IF wc >= wpl THEN reader = 0: ltr$ = "": rword$ = ""
  IF wpl = 1 THEN word$ = "": rword$ = "": ltr$ = ""

  ltr$ = ""
 IF say$ <> "" THEN PLAYWAV "c:\windows\sound\qbspeech\" + say$ + ".wav"
'  PRINT say$
  say$ = ""
NEXT wc

 nlltr$ = "": wpl = 1: wpb = lc: ntv = 0: vowels = 0: LV = 0: L3tr$ = ""
 WEND
  NEXT lc






 END SUB

SUB TANKEXPLO (LH, LV, RIL, BOT, EHH, EVV)
BLOCK$ = "TA 0L 2L 2L 2U 2U 2U 2U 2U 2R 2R 2R 2D 2L 2U 2D 2L 2L 2R 2U 2D 2D 2L 2R 2R 2U 2D 2R 2U 2D 2D 2L 2U 2D 2L 2U 2D 2L 2R 2D 2R 2U 2D 2R 2U 2D 2D 2L 2U 2L 2D 2L 2U 2R 2TA0"




 FOR s = 1 TO 40
 CIRCLE (LH, LV), s, 7
 CIRCLE (LH, LV), S1, 0: S1 = s
 SOUND 3000, .05
 SOUND 200, .5
 NEXT s
 LH$ = "R" + STR$(LH)
 LV$ = "D" + STR$(LV)
 WHILE DLY < 600
  RIG$ = "R" + STR$(DLY)
  DOWN$ = "D" + STR$(DLY)
  LEF$ = "L" + STR$(DLY)
  UP$ = "U" + STR$(DLY)
 
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + RIG$ + BLOCK$
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + DOWN$ + BLOCK$
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + LEF$ + BLOCK$
  DRAW "BM0,0C7B" + LH$ + "b" + LV$ + "B" + UP$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + RIG1$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + DOWN1$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + LEF1$ + BLOCK$
  DRAW "BM0,0C0B" + LH$ + "b" + LV$ + "B" + UP1$ + BLOCK$
 
  RIG1$ = RIG$
  LEF1$ = LEF$
  DOWN1$ = DOWN$
  UP1$ = UP$




 DLY = DLY + 30
 WEND
END SUB

SUB TANKVEIW (SCORE)
 FACE$ = "TA 0 BR 2 BR 2 BU 2 BU 2U 2U 2R 2R 2D 2D 2L 2L 2 BD 2 BD 2 BL 2 BL 2 BL 2 BL 2 BU 2 BU 2 BL 2L 2L 2U 2U 2R 2R 2D 2D 2 BR 2 BR 2 BD 2 BD 2G 2R 2 BD 2 BL 2 BL 2 BL 2F 2R 2R 2R 2R 2R 2R 2E 2L 2L 2L 2L 2L 2L 2L 2L 2TA0"
 
  
  
   LINE (0, 0)-(510, 430), 1, B
   LINE (1, 1)-(509, 429), 7, B
   LINE (2, 2)-(508, 428), 9, B
   LINE (3, 3)-(507, 427), 4, B
   LINE (4, 4)-(506, 426), 8, B

 
   CIRCLE (570, 60), 60, 1
   CIRCLE (570, 60), 59, 7
   CIRCLE (570, 60), 58, 9
   CIRCLE (570, 60), 57, 4
   CIRCLE (570, 60), 56, 8
  
   DRAW "BM570,60S15" + FACE$
   LOCATE 10, 65
  
   PRINT "SCORE "
   LOCATE 11, 65
   PRINT SCORE
   DRAW "BM0,0S4"

END SUB

'------------------------------------------------------------------------------
SUB ValidWavHeader (FILE$, LenHeader%, dataLen&, nChannels%, nSamplesPerSec&, nAvgBytesPerSec&, ok%)
rID$ = SPACE$(4)
wID$ = SPACE$(4)
fID$ = SPACE$(4)
dat$ = SPACE$(4)
dummy$ = SPACE$(1)

filenum% = FREEFILE
OPEN FILE$ FOR BINARY AS filenum%
  GET filenum%, , rID$
  GET filenum%, , rLen&
  GET filenum%, , wID$
  GET filenum%, , fID$
  GET filenum%, , fLen&
  GET filenum%, , wFormatTag%       '2 bytes
  GET filenum%, , nChannels%        '2 bytes
  GET filenum%, , nSamplesPerSec&   '4 bytes
  GET filenum%, , nAvgBytesPerSec&  '4 bytes
  GET filenum%, , nBlockAlign%      '2 bytes
  GET filenum%, , FormatSpecific%   '2 bytes
  'Read bytes until have read fLen& total bytes.
  'I have no idea what these next bytes are used for (if they even exist).
  FOR i% = 1 TO fLen& - 16          '16 bytes is what we have read in so far
     GET filenum%, , dummy$         'read in 1 byte at a time
  NEXT i%
  GET filenum%, , dat$
  IF UCASE$(dat$) = "FACT" THEN
     'funny format...
     GET filenum%, , dummy&
     GET filenum%, , dummy&
     GET filenum%, , dat$
  END IF
  GET filenum%, , dataLen&
  LenHeader% = LOC(1)
CLOSE filenum%
'  PRINT rID$;
'  PRINT rLen&;
'  PRINT wID$;
'  PRINT fID$;
'  PRINT fLen&;
'  PRINT wFormatTag%;       '2 bytes
'  PRINT nChannels%;        '2 bytes
'  PRINT nSamplesPerSec&;   '4 bytes
'  PRINT nAvgBytesPerSec&;  '4 bytes
'  PRINT nBlockAlign%;      '2 bytes
'  PRINT FormatSpecific%;   '2 bytes
'  PRINT dat$;
'  PRINT dataLen&;
'  PRINT LenHeader%
IF UCASE$(rID$) = "RIFF" THEN
   IF UCASE$(wID$) = "WAVE" THEN
      IF UCASE$(dat$) = "DATA" THEN
         IF UCASE$(fID$) = "FMT " THEN
           IF FormatSpecific% = 8 THEN ok% = -1
         END IF
      END IF
   END IF
END IF
END SUB

SUB vline (v, horv, c)
cent = (640 / 2) - 50
tv = v
bv = v
IF bv > (cent) OR tv > (cent) THEN bv = bv + (bv - cent)
IF bv < (cent) OR tv < (cent) THEN bv = bv - (cent - bv)
LINE (tv, horv)-(bv, 400), c

END SUB

'------------------------------------------------------------------------------
SUB WriteToDSP (v%)
DO
LOOP UNTIL (INP(BlasterAddr% + &HC) AND 128) = 0
OUT BlasterAddr% + &HC, v%
END SUB

