home *** CD-ROM | disk | FTP | other *** search
/ PC Plus SuperCD 1 / SuperCD_1.iso / pcplus / wilf / piecrust.bas < prev    next >
BASIC Source File  |  1996-10-14  |  20KB  |  914 lines

  1. DEFINT A-Z
  2. DECLARE SUB ziDragging ()
  3. ' Return if mouse active and still dragging, or else exhausted
  4.  
  5. DECLARE SUB ziDrawBank (FromButton, ToButton)
  6. ' Draw a bank of buttons (using Bank array)
  7.  
  8. DECLARE SUB ziExhaust ()
  9. ' Return when no keystrokes and no mouse buttons
  10.  
  11. DECLARE SUB ziLoadFont (Font$)
  12. ' Load a specified font
  13.  
  14. DECLARE SUB ziLocateMCursor (XCoord, YCoord)
  15. ' Locate mouse cursor to a named point
  16.  
  17. DECLARE SUB ziMouseOnButton (FromButton, ToButton)
  18. ' Sets FoundButton
  19.  
  20. DECLARE SUB ziPublish (PrintString$, Size, Italic)
  21. ' Print a string
  22. '   Size   = magnitude (per 8 pixels)
  23. '   Italic = +1 to make italic
  24. '          = +2 to make overprint (no background)
  25.  
  26. DECLARE SUB ziRadio (Button, FromButton, ToButton)
  27. ' Set one button in a Bank, resetting the rest
  28.  
  29. DECLARE SUB ziReadField (Min, Max, Permitted$)
  30. ' Read a field at the current TCursor location
  31. '   Permitted$ contains:
  32. '     * - any characters
  33. '     . - allow one full-stop (as decimal)
  34. '     A - auto-enter (when filled)
  35. '     C - capitalise letters
  36. '     E - ESC allowed to finish (skip) field
  37. '     J - justify (especially for numeric)
  38. '     N - numerics
  39. '     P - password-type display
  40. '     S - space
  41. '     X - alphabetic
  42. '     Y - Y or N (upper or lower)
  43.  
  44. DECLARE SUB ziSetMCursorVis (Status)
  45. ' Set visibility of mouse cursor
  46. '   Status = 0 for OFF
  47. '            1 for ON
  48. '            2 for ENQUIRE (set MCursorVis)
  49. '           10 for TEMPORARILY OFF
  50. '           11 for RESTORED (set MCursorVis)
  51.  
  52. DECLARE SUB ziWander (Timeout!)
  53. ' Timeout  = in seconds (0 = none)
  54. ' Response =   0 = (0:00) timed out
  55. '              n = (0:n)  displacement into Allowed$
  56.  
  57. ' key           &h01xx  &h02xx  &h04xx  &h08xx  &h10xx  &h20xx  &h40xx
  58. '                plain   CTRL    shift   Mouse    Fn   CTRL-Fn  shift-Fn
  59.  
  60. ' Enter      0    *       *       -      double    -      -       -
  61. ' (left)     1    *       *       -      left     F1     ^F1     +F1
  62. ' (right)    2    *       *       -      right    F2     ^F2     +F2
  63. ' (up)       3    *       -       -      both     F3     ^F3     +F3
  64. ' (down)     4    *       -       -    leftdrag   F4     ^F4     +F4
  65.  
  66. ' Backspace  5    *       *       -    rightdrag  F5     ^F5     +F5
  67. ' Home       6    *       *       -    bothdrag   F6     ^F6     +F6
  68. ' End        7    *       *       -       -       F7     ^F7     +F7
  69.  
  70. ' PgUP       8    *       *       -       -       F8     ^F8     +F8
  71. ' PgDN       9    *       *       -       -       F9     ^F9     +F9
  72.  
  73. ' Tab       10    *       -       *       -       F10    ^F10    +F10
  74. ' Escape    11    *       -       -       -       F11    ^F11    +F11
  75. '           12    -       -       -       -       F12    ^F12    +F12
  76.  
  77. ' Allowed$  = other allowed strokes
  78. ' (Note:  DClick is a flag permitting Double-clicks of mouse - slower!)
  79.  
  80. DEFINT A-Z
  81. DECLARE SUB zsAlignGCursor ()
  82. ' Align graphic cursor to same as text cursor
  83. '  - sets Row, Col, GXloc, GYloc
  84.  
  85. DECLARE SUB zsAlignTCursor ()
  86. ' Align text cursor to same as graphic cursor
  87. '  - sets Row, Col, GXloc, GYloc
  88.  
  89. DECLARE SUB zsLocateGCursor (XCoord, YCoord)
  90. ' Locate graphic cursor to a named point
  91.  
  92. DECLARE SUB zsPastel (XCoord, YCoord, Wide, Deep, colour1, colour2)
  93. ' Colour the defined oblong with a pastel mix of two colours
  94. '  Deep = 0 or 1 - square
  95. '       = n      - Y-pixel depth
  96.  
  97. DECLARE SUB zsSetScrnMode (Mode, HiRows, HiCols)
  98. ' Mode = 9 or 12
  99. ' HiRows = 1 to make high number of rows
  100. ' HiCols = 1 to make high number of cols (80)
  101. ' Set SCREEN parameters and blank the screen
  102. '  - sets ScrnMode, Xmax, Ymax, Rows, Cols, XYRatio!
  103. '  - uses FG and optionally BG (colours)
  104.  
  105. DECLARE SUB zsSubstitute (XCoord, YCoord, Wide, Deep, colour1, colour2)
  106. ' Substitute one colour with another within the defined oblong
  107. '  Deep = 0 or 1 - square
  108. '       = n      - Y-pixel depth
  109.  
  110. DECLARE SUB zzBasicInt (IntType)
  111. ' Execute interrupt (params in REGS.AX etc)
  112.  
  113. DECLARE SUB zzInPath (Field$)
  114. ' Return full path to a file (in same string)
  115.  
  116. '================================================
  117. '/  UK copyright (c) 1995 by Future Publishing
  118. '/
  119. '/
  120. '/
  121. '/
  122. '================================================
  123. TYPE REGISTERS
  124.   AX AS INTEGER
  125.   BX AS INTEGER
  126.   CX AS INTEGER
  127.   DX AS INTEGER
  128.   DS AS INTEGER
  129.   SI AS INTEGER
  130.   ES AS INTEGER
  131.   DI AS INTEGER
  132.   FL AS INTEGER
  133. END TYPE
  134.  
  135. TYPE Buttons
  136.   Xloc AS INTEGER
  137.   Yloc AS INTEGER
  138.   Wide AS INTEGER
  139.   Deep AS INTEGER
  140. '  0 = checkbutton
  141. '  1 = square sculptured
  142. '  n = Y-pixels deep
  143.   State AS INTEGER
  144. '  0 = off
  145. '  1 = on
  146.   Active AS INTEGER
  147. '  0 = inactive
  148. '  1 = active
  149. END TYPE
  150.  
  151. CONST Pi! = 3.14159
  152. CONST Ex! = 2.71828
  153. CONST DegToRad! = .0174533
  154. CONST RadToDeg! = 57.2958
  155.  
  156. CONST ziNoShift = &H1
  157. CONST ziCTRL = &H2
  158. CONST ziShift = &H4
  159. CONST ziMouse = &H8
  160. CONST ziFn = &H10
  161. CONST ziCTRLFn = &H20
  162. CONST ziShiftFn = &H40
  163.  
  164. CONST ziL = 1
  165. CONST ziR = 2
  166. CONST ziUp = 3
  167. CONST ziDn = 4
  168. CONST ziBS = 5
  169. CONST ziHome = 6
  170. CONST ziEnd = 7
  171. CONST ziPgUp = 8
  172. CONST ziPgDn = 9
  173. CONST ziTab = 10
  174. CONST ziEsc = 11
  175.  
  176. CONST ziDbl = 0
  177. CONST ziBoth = 3
  178. CONST ziLDrag = 4
  179. CONST ziRDrag = 5
  180. CONST ziBothDrag = 6
  181.  
  182. DIM SHARED REGS AS REGISTERS
  183. DIM SHARED Bank(20) AS Buttons
  184. DIM SHARED Bad, Module$
  185. DIM SHARED Mouse, MCursorVis, MXloc, MYloc
  186. DIM SHARED DClick
  187. DIM SHARED ScrnMode, BG, FG, TCursor
  188. DIM SHARED Xmax, Ymax, GXloc, GYloc, XYratio!
  189. DIM SHARED Rows, Cols, Row, Col
  190. DIM SHARED Allowed$, Field$
  191. DIM SHARED FoundButton
  192. DIM SHARED Font(255, 7)
  193. DIM SHARED Response, HResponse, LResponse
  194.  
  195. '++++++++++++++++++++++++
  196. RANDOMIZE TIMER
  197. ON ERROR GOTO RESUMENEXT
  198. RESUMENEXT:
  199.   IF ERR = 255 THEN
  200.     CLS
  201.     BEEP
  202.     PRINT "Cannot find module "; Module$
  203.     SLEEP
  204.     SYSTEM
  205.   END IF
  206.   IF ERR THEN
  207.     Bad = ERR
  208.     RESUME NEXT
  209.   END IF
  210. '++++++++++++++++++++++++
  211. ' Test for presence of a mouse
  212. Mouse = 0
  213. REGS.AX = 0
  214. CALL zzBasicInt(&H33)
  215. IF REGS.AX THEN
  216.   Mouse = 1
  217.   CALL ziSetMCursorVis(0)
  218. END IF
  219. '++++++++++++++++++++++++
  220. ' Load the ASCII font
  221. CALL ziLoadFont("Ascii8x8")
  222. '/==================================/'
  223. '/  End of Standard Piecrust code   /'
  224. '/==================================/'
  225.  
  226. '++++++++++++++++++++++++
  227. SUB ziDragging
  228.  
  229.   IF Mouse AND MCursorVis THEN
  230.     SELECT CASE Response
  231.     CASE 2052 TO 2054
  232.       REGS.AX = 3
  233.       CALL zzBasicInt(&H33)
  234.       IF REGS.BX = Response - 2051 THEN
  235.         EXIT SUB
  236.       END IF
  237.     END SELECT
  238.   END IF
  239.   CALL ziExhaust
  240.  
  241. END SUB
  242.  
  243. '++++++++++++++++++++++++
  244. SUB ziDrawBank (FromButton, ToButton)
  245.  
  246.   CALL ziSetMCursorVis(10)
  247.  
  248.   FOR i = FromButton TO ToButton
  249.  
  250.     IF Bank(i).Active THEN
  251.  
  252.       IF Bank(i).State THEN
  253.         colour1 = 8
  254.       ELSE
  255.         colour1 = 15
  256.       END IF
  257.       colour2 = colour1 XOR 7
  258.  
  259.       XCoord = Bank(i).Xloc
  260.       YCoord = Bank(i).Yloc
  261.       XWidth = Bank(i).Wide
  262.       YDepth = Bank(i).Deep
  263.       X2Coord = XCoord + XWidth
  264.  
  265.       IF YDepth THEN
  266.         IF YDepth = 1 THEN
  267.           Y2Coord = YCoord + XWidth / XYratio!
  268.         ELSE
  269.           Y2Coord = YCoord + YDepth
  270.         END IF
  271.         LINE (XCoord, YCoord)-(X2Coord - 1, YCoord), colour1
  272.         LINE (XCoord, YCoord)-(XCoord, Y2Coord - 1), colour1
  273.         LINE (XCoord + 1, Y2Coord)-(X2Coord, Y2Coord), colour2
  274.         LINE (X2Coord, YCoord)-(X2Coord, Y2Coord), colour2
  275.       ELSE
  276.         a = XWidth \ 2
  277.         b = a / XYratio!
  278.         c = XCoord + a
  279.         d = YCoord + b
  280.  
  281.         LINE (XCoord, YCoord)-(c + a, d + b), 7, BF
  282.  
  283.         CIRCLE (c, d), a, 8
  284.         CIRCLE (c, d), a - 1, 8
  285.         PAINT (c, d), 7, 7
  286.         IF Bank(i).State THEN
  287.           CIRCLE (c, d), XWidth \ 3, 8
  288.           PAINT (c, d), 8, 8
  289.         END IF
  290.       END IF
  291.     END IF
  292.  
  293.   NEXT
  294.  
  295.   CALL ziSetMCursorVis(11)
  296.  
  297. END SUB
  298.  
  299. '++++++++++++++++++++++++
  300. SUB ziExhaust
  301.  
  302.   DO
  303.     x$ = INKEY$
  304.   LOOP WHILE LEN(x$)
  305.  
  306.   IF Mouse AND MCursorVis THEN
  307.     DO
  308.       REGS.AX = 3
  309.       CALL zzBasicInt(&H33)
  310.     LOOP WHILE (REGS.BX AND 3)
  311.   END IF
  312.   Response = 0
  313. END SUB
  314.  
  315. '++++++++++++++++++++++++
  316. SUB ziLoadFont (Font$)
  317.  
  318.   DEF SEG = VARSEG(Font(0, 0))
  319.  
  320.   Module$ = Font$ + ".OVL"
  321.   CALL zzInPath(Module$)
  322.   IF Module$ = "" THEN
  323.     Module$ = Font$ + ".OVL"
  324.     ERROR 255
  325.   ELSE
  326.     BLOAD Module$, VARPTR(Font(0, 0))
  327.   END IF
  328.  
  329.   DEF SEG
  330.  
  331. END SUB
  332.  
  333. '++++++++++++++++++++++++
  334. SUB ziLocateMCursor (XCoord, YCoord)
  335.  
  336.   IF Mouse THEN
  337.     MXloc = XCoord
  338.     MYloc = YCoord
  339.     REGS.AX = 4
  340.     REGS.CX = XCoord
  341.     REGS.DX = YCoord
  342.     CALL zzBasicInt(&H33)
  343.     CALL ziSetMCursorVis(1)
  344.   END IF
  345.  
  346. END SUB
  347.  
  348. '++++++++++++++++++++++++
  349. SUB ziMouseOnButton (FromButton, ToButton)
  350.  
  351.   FoundButton = 0
  352.   FOR i = FromButton TO ToButton
  353.     IF Bank(i).Active THEN
  354.       IF Bank(i).Deep < 2 THEN
  355.         j = Bank(i).Wide / XYratio!
  356.       ELSE
  357.         j = Bank(i).Deep
  358.       END IF
  359.       IF MXloc > Bank(i).Xloc THEN
  360.         IF MXloc < Bank(i).Xloc + Bank(i).Wide THEN
  361.           IF MYloc > Bank(i).Yloc THEN
  362.             IF MYloc < Bank(i).Yloc + j THEN
  363.               FoundButton = i
  364.               EXIT SUB
  365.             END IF
  366.           END IF
  367.         END IF
  368.       END IF
  369.     ELSE
  370.       EXIT SUB
  371.     END IF
  372.   NEXT
  373.  
  374. END SUB
  375.  
  376. '++++++++++++++++++++++++
  377. SUB ziPublish (PrintString$, Size, Italic)
  378.  
  379.   CALL ziSetMCursorVis(10)
  380.  
  381.   xx = POINT(0)
  382.   yy = POINT(1)
  383.   IF Size THEN
  384.     Scale = Size
  385.   ELSE
  386.     Scale = 1
  387.   END IF
  388.  
  389.   LenString = LEN(PrintString$)
  390.  
  391.   ExpScale = 8 * Scale
  392.   limxx = xx + ExpScale * LenString - 1
  393.   limyy = yy + ExpScale - 1
  394.  
  395.   IF Italic AND 1 THEN
  396.     limxx = limxx + 4 * Scale
  397.   END IF
  398.  
  399.  
  400.   IF Italic AND 2 THEN
  401.   ELSE
  402.     LINE (xx, yy)-(limxx, limyy), BG, BF
  403.   END IF
  404.  
  405.  
  406.   FOR a = 0 TO LenString - 1
  407.     x = ASC(MID$(PrintString$, a + 1, 1))
  408.     b = xx + ExpScale * a
  409.     FOR y = 0 TO 7
  410.       c = Font(x, y)
  411.       d = y * Scale
  412.       e = yy + d
  413.       IF Italic AND 1 THEN
  414.         f = b + 4 * Scale - (d + Scale - 1) \ 2 - 1
  415.       ELSE
  416.         f = b
  417.       END IF
  418.       g = 128
  419.       DO
  420.         IF c AND g THEN
  421.           FOR h = 0 TO Scale - 1
  422.             FOR i = 0 TO Scale - 1
  423.               PSET (f + h, e + i), FG
  424.             NEXT
  425.           NEXT
  426.         END IF
  427.         f = f + Scale
  428.         g = g \ 2
  429.       LOOP UNTIL g = 0
  430.     NEXT
  431.   NEXT
  432.   CALL zsLocateGCursor(limxx + 1, yy)
  433.  
  434.   CALL ziSetMCursorVis(11)
  435.  
  436. END SUB
  437.  
  438. '++++++++++++++++++++++++
  439. SUB ziRadio (Button, FromButton, ToButton)
  440.  
  441.   IF Button >= FromButton THEN
  442.     IF Button <= ToButton THEN
  443.       FOR a = FromButton TO ToButton
  444.         Bank(a).State = 0
  445.       NEXT
  446.     END IF
  447.   END IF
  448.  
  449.   Bank(Button).State = 1
  450.   CALL ziDrawBank(FromButton, ToButton)
  451.  
  452. END SUB
  453.  
  454. '++++++++++++++++++++++++
  455. SUB ziReadField (Min, Max, Permitted$)
  456.  
  457.   CALL ziSetMCursorVis(10)
  458.  
  459.   atRow = CSRLIN
  460.   atCol = POS(x)
  461.   Field$ = ""
  462.   PRINT CHR$(219); SPACE$(Max);
  463.   Rules$ = UCASE$(Permitted$)
  464.  
  465.   Brake = 1
  466.   WHILE Brake
  467.     x$ = ""
  468.     WHILE LEN(x$) = 0
  469.       x$ = INKEY$
  470.     WEND
  471.     IF INSTR(Rules$, "C") THEN x$ = UCASE$(x$)
  472.     oldLen = LEN(Field$)
  473.     Good = 0
  474.     IF INSTR(Rules$, ".") THEN
  475.       IF x$ = "." THEN
  476.         IF INSTR(Field$, ".") = 0 THEN
  477.           Good = 1
  478.         END IF
  479.       END IF
  480.     END IF
  481.     IF INSTR(Rules$, "N") THEN
  482.       IF INSTR("0123456789", x$) THEN
  483.         Good = 1
  484.       END IF
  485.     END IF
  486.     IF INSTR(Rules$, "S") THEN
  487.       IF x$ = " " THEN
  488.         Good = 1
  489.       END IF
  490.     END IF
  491.     IF INSTR(Rules$, "X") THEN
  492.       IF INSTR("ABCDEFGHIJKLMNOPQRSTUVWXYZ", UCASE$(x$)) THEN
  493.         Good = 1
  494.       END IF
  495.     END IF
  496.     IF INSTR(Rules$, "Y") THEN
  497.       IF INSTR("YyNy", x$) THEN
  498.         Good = 1
  499.       END IF
  500.     END IF
  501.     IF Good THEN
  502.       Field$ = Field$ + x$
  503.       IF INSTR(Field$, ".") THEN
  504.         NewMax = Max + 1
  505.       ELSE
  506.         NewMax = Max
  507.       END IF
  508.       Field$ = MID$(Field$, 1, NewMax)
  509.     END IF
  510.  
  511.     ' handle Bkspace
  512.     IF ASC(x$) = 8 AND LEN(Field$) THEN
  513.       Field$ = MID$(Field$, 1, LEN(Field$) - 1)
  514.     END IF
  515.  
  516.     Signif$ = Field$ + "X"
  517.     WHILE INSTR(" 0", MID$(Signif$, 1, 1))
  518.       Signif$ = MID$(Signif$, 2)
  519.     WEND
  520.     IF INSTR(Signif$, ".") THEN
  521.       SignifLen = LEN(Signif$) - 2
  522.     ELSE
  523.       SignifLen = LEN(Signif$) - 1
  524.     END IF
  525.  
  526.     ' handle Enter
  527.     IF ASC(x$) = 13 AND SignifLen >= Min THEN
  528.       oldLen = LEN(Field$) + 1
  529.       Brake = 0
  530.     END IF
  531.  
  532.     ' handle Esc
  533.     IF ASC(x$) = 27 THEN
  534.       LOCATE atRow, atCol
  535.       PRINT CHR$(219); SPACE$(Max);
  536.       Field$ = ""
  537.       IF INSTR(Rules$, "E") THEN
  538.         RETURN
  539.       END IF
  540.     END IF
  541.  
  542.     ' reprint if change, or beep if no change
  543.     IF oldLen = LEN(Field$) THEN
  544.       BEEP
  545.     ELSE
  546.       LOCATE atRow, atCol
  547.       IF INSTR(Rules$, "P") THEN
  548.         PRINT STRING$(LEN(Field$), 254); CHR$(219); " ";
  549.       ELSE
  550.         PRINT Field$; CHR$(219); " ";
  551.       END IF
  552.     END IF
  553.  
  554.     ' check for auto-Enter
  555.     IF INSTR(Rules$, "A") THEN
  556.       IF SignifLen = Max THEN
  557.         Brake = 0
  558.       END IF
  559.     END IF
  560.   WEND
  561.  
  562.   ' justify if required
  563.   IF INSTR(Rules$, "J") THEN
  564.     WHILE MID$(Field$, 1, 1) = "0"
  565.       Field$ = MID$(Field$, 2)
  566.     WEND
  567.     Field$ = RIGHT$(SPACE$(NewMax) + Field$, NewMax)
  568.   END IF
  569.  
  570.   ' reprint, deleting the cursor
  571.   LOCATE atRow, atCol
  572.   IF INSTR(Rules$, "P") THEN
  573.     PRINT STRING$(LEN(Field$), 254); " ";
  574.   ELSE
  575.     PRINT Field$; " ";
  576.   END IF
  577.  
  578.   CALL ziSetMCursorVis(11)
  579.  
  580. END SUB
  581.  
  582. '++++++++++++++++++++++++
  583. SUB ziSetMCursorVis (Status) STATIC
  584.  
  585.   IF Mouse THEN
  586.     SELECT CASE Status
  587.     CASE 0
  588.       IF MCursorVis THEN
  589.        REGS.AX = 2
  590.        CALL zzBasicInt(&H33)
  591.       END IF
  592.     CASE 1
  593.       REGS.AX = 1
  594.       CALL zzBasicInt(&H33)
  595.     CASE 10
  596.       REGS.AX = &H2A
  597.       CALL zzBasicInt(&H33)
  598.       IF REGS.AX = 0 THEN
  599.         TempFlag = 1
  600.         REGS.AX = 2
  601.         CALL zzBasicInt(&H33)
  602.       ELSE
  603.         TempFlag = 0
  604.       END IF
  605.     CASE 11
  606.       IF TempFlag THEN
  607.         REGS.AX = 1
  608.         CALL zzBasicInt(&H33)
  609.       END IF
  610.     END SELECT
  611.     REGS.AX = &H2A
  612.     CALL zzBasicInt(&H33)
  613.     IF REGS.AX = 0 THEN
  614.       MCursorVis = 1
  615.     ELSE
  616.       MCursorVis = 0
  617.     END IF
  618.   END IF
  619. END SUB
  620.  
  621. '++++++++++++++++++++++++
  622. SUB ziWander (Timeout!)
  623.  
  624.   IF Timeout! = 0 THEN
  625.     WatchFor! = TIMER + 3600
  626.   ELSE
  627.     WatchFor! = TIMER + Timeout!
  628.   END IF
  629.  
  630.   Response = 0
  631.  
  632.   DO
  633.     x$ = INKEY$
  634.     IF LEN(x$) THEN
  635.       SELECT CASE LEN(x$)
  636.       CASE 1
  637.         a = INSTR(Allowed$, x$)
  638.         IF a THEN
  639.           Response = a
  640.           EXIT DO
  641.         END IF
  642.         SELECT CASE ASC(x$)
  643.         CASE 8: Response = 261
  644.         CASE 9: Response = 266
  645.         CASE 10: Response = 512
  646.         CASE 13: Response = 256
  647.         CASE 27: Response = 267
  648.         CASE 127: Response = 517
  649.         END SELECT
  650.         IF Response THEN
  651.           EXIT DO
  652.         END IF
  653.       CASE 2
  654.         Rightmost = ASC(RIGHT$(x$, 1))
  655.         SELECT CASE Rightmost
  656.         CASE 15: Response = 1019
  657.         CASE 59 TO 68
  658.           Response = 4038
  659.         CASE 72: Response = 187
  660.         CASE 71 TO 73
  661.           Response = 191
  662.         CASE 75: Response = 182
  663.         CASE 77: Response = 181
  664.         CASE 80: Response = 180
  665.         CASE 79 TO 81
  666.           Response = 184
  667.         CASE 84 TO 93
  668.           Response = 16301
  669.         CASE 94 TO 103
  670.           Response = 8099
  671.         CASE 115 TO 116
  672.           Response = 398
  673.         CASE 117: Response = 402
  674.         CASE 118: Response = 403
  675.         CASE 119: Response = 399
  676.         CASE 127: Response = 390
  677.         CASE 132: Response = 388
  678.         CASE 133 TO 134
  679.           Response = 3974
  680.         CASE 135 TO 136
  681.           Response = 16260
  682.         CASE 137 TO 138
  683.           Response = 8066
  684.         END SELECT
  685.         IF Response THEN
  686.           Response = Response + Rightmost
  687.           EXIT DO
  688.         END IF
  689.       END SELECT
  690.     END IF
  691.  
  692.     IF Mouse AND MCursorVis THEN
  693.       REGS.AX = 3
  694.       CALL zzBasicInt(&H33)
  695.       SELECT CASE REGS.BX
  696.       CASE 1 TO 3
  697.         Response = 2048 + REGS.BX
  698.         nowtime! = TIMER
  699.         DO
  700.           REGS.AX = 3
  701.           CALL zzBasicInt(&H33)
  702.           IF REGS.BX = 0 THEN EXIT DO
  703.         LOOP UNTIL TIMER - nowtime! > .3
  704.         IF REGS.BX = Response - 2048 THEN
  705.           Response = Response + 3
  706.         ELSE
  707.           IF REGS.BX = 0 AND Response = 2049 AND DClick THEN
  708.             nowtime! = TIMER
  709.             DO
  710.               REGS.AX = 3
  711.               CALL zzBasicInt(&H33)
  712.               IF REGS.BX = 1 THEN EXIT DO
  713.             LOOP UNTIL TIMER - nowtime! > .3
  714.             IF REGS.BX = 1 THEN
  715.               Response = 2048
  716.               CALL ziExhaust
  717.             END IF
  718.           END IF
  719.           IF REGS.BX = 3 THEN
  720.             Response = 2051
  721.           END IF
  722.         END IF
  723.       END SELECT
  724.       IF Response THEN
  725.         MXloc = REGS.CX
  726.         MYloc = REGS.DX
  727.         EXIT DO
  728.       END IF
  729.     END IF
  730.  
  731.   LOOP UNTIL WatchFor! < TIMER
  732.   HResponse = Response \ 256
  733.   LResponse = Response MOD 256
  734.  
  735. END SUB
  736.  
  737. '++++++++++++++++++++++++
  738. SUB zsAlignGCursor
  739.  
  740.   Row = CSRLIN
  741.   Col = POS(0)
  742.   GXloc = (Col - 1) * ((Xmax + 1) \ Cols)
  743.   GYloc = (Row - 1) * (((Ymax \ Rows) * Rows + 1) \ Rows)
  744.   CALL zsLocateGCursor(GXloc, GYloc)
  745.  
  746. END SUB
  747.  
  748. '++++++++++++++++++++++++
  749. SUB zsAlignTCursor
  750.  
  751.   GXloc = POINT(0)
  752.   GYloc = POINT(1)
  753.   a = (Xmax + 1) / Cols
  754.   b = (Ymax + 1) / Rows
  755.   Col = (GXloc + a - 1) \ a + 1
  756.   Row = (GYloc + b - 1) \ b + 1
  757.   LOCATE Row, Col
  758.   CALL zsAlignGCursor
  759.  
  760. END SUB
  761.  
  762. '++++++++++++++++++++++++
  763. SUB zsLocateGCursor (XCoord, YCoord)
  764.  
  765.   GXloc = XCoord
  766.   GYloc = YCoord
  767.   PSET (GXloc, GYloc), POINT(GXloc, GYloc)
  768.  
  769. END SUB
  770.  
  771. '++++++++++++++++++++++++
  772. SUB zsPastel (XCoord, YCoord, Wide, Deep, colour1, colour2)
  773.  
  774.   CALL ziSetMCursorVis(10)
  775.  
  776.   IF Deep < 2 THEN
  777.     a = Wide / XYratio!
  778.   ELSE
  779.     a = Deep
  780.   END IF
  781.  
  782.   LINE (XCoord, YCoord)-(XCoord + Wide - 1, YCoord + a - 1), colour1, BF
  783.   FOR b = XCoord TO XCoord + Wide - 1 STEP 2
  784.     LINE (b, YCoord)-(b, YCoord + a - 1), colour2, , &H5555
  785.   NEXT
  786.   FOR b = XCoord + 1 TO XCoord + Wide - 1 STEP 2
  787.     LINE (b, YCoord)-(b, YCoord + a - 1), colour2, , &HAAAA
  788.   NEXT
  789.  
  790.   CALL ziSetMCursorVis(11)
  791.  
  792. END SUB
  793.  
  794. '++++++++++++++++++++++++
  795. SUB zsSetScrnMode (Mode, HiRows, HiCols)
  796.  
  797.   CALL ziSetMCursorVis(10)
  798.  
  799.   ScrnMode = Mode
  800.   IF Mode = 9 THEN
  801.     SCREEN 9
  802.     IF HiRows THEN
  803.       Rows = 43
  804.     ELSE
  805.       Rows = 25
  806.     END IF
  807.     Xmax = 639
  808.     Ymax = 349
  809.   END IF
  810.   IF Mode = 12 THEN
  811.     SCREEN 12
  812.     IF HiRows THEN
  813.       Rows = 60
  814.     ELSE
  815.       Rows = 30
  816.     END IF
  817.     Xmax = 639
  818.     Ymax = 479
  819.   END IF
  820.  
  821.   IF HiCols THEN
  822.     Cols = 80
  823.   ELSE
  824.     Cols = 40
  825.   END IF
  826.   WIDTH Cols, Rows
  827.   CLS
  828.   IF Mode = 9 THEN
  829.     COLOR FG, BG
  830.   ELSE
  831.     COLOR FG
  832.   END IF
  833.   LINE (0, 0)-(Xmax, Ymax), BG, BF
  834.   LOCATE 1, 1, 0
  835.   PSET (0, 0), BG
  836.   XYratio! = .75 * (Xmax + 1) / (Ymax + 1)
  837.  
  838.   CALL ziSetMCursorVis(11)
  839.  
  840. END SUB
  841.  
  842. '++++++++++++++++++++++++
  843. SUB zsSubstitute (XCoord, YCoord, Wide, Deep, colour1, colour2)
  844.  
  845.   CALL ziSetMCursorVis(10)
  846.  
  847.   IF Deep < 2 THEN
  848.     a = Wide / XYratio!
  849.   ELSE
  850.     a = Deep
  851.   END IF
  852.   FOR b = XCoord TO XCoord + Wide - 1
  853.     FOR c = YCoord TO YCoord + a - 1
  854.       IF POINT(b, c) = colour1 THEN
  855.         PSET (b, c), colour2
  856.       END IF
  857.     NEXT
  858.   NEXT
  859.  
  860.   CALL ziSetMCursorVis(11)
  861.  
  862. END SUB
  863.  
  864. '++++++++++++++++++++++++
  865. SUB zzBasicInt (IntType) STATIC
  866.  
  867.   DIM ASM(54)
  868.   DEF SEG = VARSEG(ASM(0))
  869.  
  870.   IF ASM(1) = 0 THEN
  871.     Module$ = "BASICINT.OVL"
  872.     CALL zzInPath(Module$)
  873.     IF Module$ = "" THEN
  874.       Module$ = "BASICINT.OVL"
  875.       ERROR 255
  876.     ELSE
  877.       BLOAD Module$, VARPTR(ASM(0))
  878.     END IF
  879.   END IF
  880.  
  881.   CALL ABSOLUTE(REGS, IntType, VARPTR(ASM(0)))
  882.  
  883.   DEF SEG
  884.  
  885. END SUB
  886.  
  887. '++++++++++++++++++++++++
  888. SUB zzInPath (Field$)
  889.  
  890.   x$ = ".;" + ENVIRON$("PATH")
  891.   IF RIGHT$(x$, 1) <> ";" THEN x$ = x$ + ";"
  892.   i = 1
  893.   DO
  894.     j = INSTR(i, x$, ";")
  895.     IF j THEN
  896.       y$ = UCASE$(MID$(x$, i, j - i))
  897.       i = j + 1
  898.       IF RIGHT$(y$, 1) <> "\" THEN y$ = y$ + "\"
  899.       f$ = y$ + Field$
  900.       Bad = 0
  901.       OPEN "I", 1, f$
  902.       IF Bad = 0 THEN
  903.         CLOSE 1
  904.         EXIT DO
  905.       END IF
  906.       f$ = ""
  907.     END IF
  908.   LOOP WHILE j
  909.   Bad = 0
  910.   Field$ = f$
  911.  
  912. END SUB
  913.  
  914.