home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / games / m18v22.zip / M18.BAS next >
BASIC Source File  |  1988-02-01  |  6KB  |  189 lines

  1. '****************************************************
  2. 'This program is designed to be used with the MEAN-18
  3. 'golf game by Accolade. It will allow you to have as
  4. 'many golf courses as you wish available to play rather
  5. 'than the limit of three imposed by MEAN-18.
  6. '
  7. 'A special thanks to Fred Strobl for his programming
  8. 'help with the read.filename routine he wrote for me.
  9. '
  10. 'written in March, 1987 by Ken Hopkins (WA9WCP)
  11. 'who only wishes he could play golf for real as well as
  12. 'he can with Mean18.
  13. '
  14. '========  Modifications since the origonal release  ========
  15. '
  16. ' 12/30/87 - I added a CLS to the first line of "readdir" to
  17. '            ensure that the files were always displayed in
  18. '            the proper place on the screen and thus would
  19. '            always be read correctly.
  20. '            I also rewrote the "choose" function so that it
  21. '            would work properly with more than 9 courses.
  22. '            Released as M18V20.ARC
  23. '
  24. ' 12/31/87 - Added the capability to utilize up to 42 courses.
  25. '            Changed the format of the menu display to allow
  26. '            three columns of names.
  27. '            Fixed a bug that wouldn't let you select the same
  28. '            course twice in a row.
  29. '
  30. ' 01/02/88 - Fixed a bug that didn't allow the full 42 courses
  31. '            to be used...only 41!  Added some error checking
  32. '            code.  This is version 2.1
  33. '
  34. ' 01/29/88 - Once again I have increased the capacity of the
  35. '            program.  It is reaching the point where I am out
  36. '            of screen space!  I have renumbered this version
  37. '            to 2.2.  I used a couple of routines from the
  38. '            Advanced Basic 4.0 library.  You need to have this
  39. '            to be able to compile the program now.
  40. '
  41. '                                     Dick Stout
  42. '                                     Computing Technology BBS
  43. '                                     (619) 375-2306
  44. '
  45. KEY OFF
  46. DEFINT A-Z
  47. Max = 100                  '**Changed max files to 100
  48. DIM File$(Max)
  49. '
  50. CLS
  51. GOSUB CheckGolfFile   'Make sure the GOLF.* file is present
  52. GOSUB Getfiles
  53. GOSUB Menu            'Display which courses are available?
  54. GOSUB Choose          'Choose which course do you want to play?
  55. SHELL "GOLF"          'Call the Golf game
  56.  
  57. END
  58. '
  59.  
  60. Menu:
  61. Fmt1$ = "\\### - \      \"
  62. CLS
  63. PRINT TAB(15); "M18.EXE; version 2.2, compiled with QBasic 4.0"
  64. PRINT
  65. PRINT TAB(5); "                   Menu of available MEAN-18 Golf Courses"
  66. PRINT TAB(5); "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  67. 'PRINT
  68. FOR a = 1 TO Max STEP 5
  69.   SELECT CASE a
  70.   CASE IS < Max - 3
  71.     PRINT USING Fmt1$; ""; a; File$(a); ""; a + 1; File$(a + 1);
  72.     PRINT USING Fmt1$; ""; a + 2; File$(a + 2); ""; a + 3; File$(a + 3);
  73.     PRINT USING Fmt1$; ""; a + 4; File$(a + 4)
  74.   CASE IS < Max - 2
  75.     PRINT USING Fmt1$; ""; a; File$(a); ""; a + 1; File$(a + 1);
  76.     PRINT USING Fmt1$; ""; a + 2; File$(a + 2); ""; a + 3; File$(a + 3)
  77.   CASE IS < Max - 1
  78.     PRINT USING Fmt1$; ""; a; File$(a); ""; a + 1; File$(a + 1);
  79.     PRINT USING Fmt1$; ""; a + 2; File$(a + 2)
  80.   CASE IS < Max
  81.     PRINT USING Fmt1$; ""; a; File$(a); ""; a + 1; File$(a + 1)
  82.   CASE ELSE
  83.     PRINT USING Fmt1$; ""; a; File$(a)
  84.   END SELECT
  85. NEXT
  86. PRINT
  87. RETURN
  88. '
  89. Choose:
  90. ch$ = ""
  91. Iline = CSRLIN
  92. WHILE (ch$ = "")
  93.    LOCATE Iline, 1
  94.    INPUT "      Enter the number of the course you wish to play => ", ch$                         'ADDED 12/30/87 by Dick Stout
  95. WEND
  96. i = VAL(ch$)
  97. IF i > 0 AND i <= Max THEN
  98.    NAME File$(i) AS LEFT$(File$(i), 8) + ".M18"
  99. ELSE
  100.    GOSUB Menu
  101.    GOTO Choose
  102. END IF
  103. RETURN
  104.  
  105. Getfiles:
  106. Filename$ = "*.M1?" + CHR$(0)
  107. fil$ = SPACE$(12)
  108. CALL findfirstf(Filename$, attr%, ercd%)
  109. IF ercd% THEN
  110.     PRINT "No MEAN-18 courses were found, this program must be run in"
  111.     PRINT "the directory that contains the .M10 or M18 courses."
  112.     END
  113. ELSE
  114.     CALL getnamef(fil$, flen%)
  115.     File$(1) = LEFT$(fil$, 12)
  116. END IF
  117. IF ercd% = -1 THEN PRINT "ERROR!"
  118.  
  119. i = 2
  120. DO WHILE ercd% = 0
  121. CALL findnextf(ercd%)
  122. IF ercd% THEN
  123.     PRINT
  124. ELSE
  125.     CALL getnamef(fil$, flen%)
  126.     File$(i) = LEFT$(fil$, 12)
  127.     i = i + 1
  128. END IF
  129. IF ercd% = -1 THEN
  130.     PRINT "ERROR!"
  131.     EXIT DO
  132. END IF
  133. LOOP
  134. Max = i - 1
  135.  
  136. FOR j = 1 TO Max
  137.     k = INSTR(File$(j), ".")
  138.     first$ = LEFT$(File$(j), k - 1)
  139.     fext$ = MID$(File$(j), k + 1, 3)
  140.     File$(j) = first$ + SPACE$(8 - LEN(first$)) + "." + fext$
  141.     IF MID$(File$(j), 10, 3) = "M18" THEN            'rename left over *.M18
  142.         NAME File$(j) AS LEFT$(File$(j), 8) + ".M10"  'files from last game
  143.         File$(j) = LEFT$(File$(j), 8) + ".M10"
  144.     END IF
  145. NEXT
  146. ' ============================== BubbleSort ==================================
  147. '    The BubbleSort algorithm cycles through SortArray, comparing adjacent
  148. '    elements and swapping pairs that are out of order.  It continues to
  149. '    do this until no pairs are swapped.
  150. ' ============================================================================
  151. '
  152. BubbleSort:
  153.    Limit = Max
  154.    DO
  155.       Switch = FALSE
  156.       FOR Row = 1 TO (Limit - 1)
  157.  
  158.          ' Two adjacent elements are out of order, so swap their values
  159.          ' and redraw those two bars:
  160.          IF File$(Row) > File$(Row + 1) THEN
  161.             SWAP File$(Row), File$(Row + 1)
  162.             Switch = Row
  163.          END IF
  164.       NEXT Row
  165.  
  166.       ' Sort on next pass only to where the last switch was made:
  167.       Limit = Switch
  168.    LOOP WHILE Switch
  169.  
  170. RETURN
  171.  
  172. RETURN
  173.  
  174. CheckGolfFile:
  175. Filename$ = "GOLF.*" + CHR$(0)
  176. fil$ = SPACE$(12)
  177. CALL findfirstf(Filename$, attr%, ercd%)
  178. IF ercd% THEN
  179.     PRINT
  180.     PRINT "No GOLF.EXE file was found, this program must be run in"
  181.     PRINT "the directory that contains GOLF.EXE and the courses."
  182.     PRINT
  183.     END
  184. ELSE
  185. END IF
  186. RETURN
  187.  
  188.  
  189.