home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 236 / 236.d81 / t.dbdocs4 < prev    next >
Encoding:
Text File  |  2004-01-01  |  13.4 KB  |  515 lines

  1. u
  2.         DOTBASIC DOCUMENTATION
  3.                 Part 5
  4.  
  5.    And now the exciting conclusion!
  6.  
  7.  
  8.   GET DIRECTORY:
  9.   .B$,"$:*",dv,loc,# filenames
  10.   ----------------------------
  11.  
  12.     This will read the disk directory
  13. from device DV. The directory can be
  14. placed anywhere, even under I/O.
  15. MM2.1 converts the directory to an
  16. EDSTAR file as it's brought in. This
  17. allows SCROLLING MENU to use the
  18. information as a file requestor.
  19.  
  20.     Normally you would use "$:*" to
  21. get all the disk's filenames. You can
  22. replace "$:*" with any search pattern
  23. you want, up to 16 characters long.
  24. For example, using "$:b.*,t.*" on a
  25. LOADSTAR disk would bring in the
  26. names of all the boot and text files.
  27. (This works on VICE only if True Drive
  28. is enabled.)
  29.  
  30.     E$ will return the error message.
  31. T$ will contain the disk's name
  32. within quotes, and B$ will contain
  33. the "blocks free" message. Use
  34. VAL(B$) to extract the number of
  35. blocks free on the disk. N% returns
  36. the number of filenames loaded.
  37.  
  38.     If there was an error during the
  39. directory getting, T$ and B$ will
  40. return strings full of spaces, and E$
  41. will tell about the error. The one
  42. thing your program should do before
  43. disk access is check if the drive is
  44. actually online, like this:
  45.  
  46.    1000 close2:open2,dv,2:close2
  47.    1010 if st=-128 then...
  48.    1020 ...continue
  49.  
  50.     Line 1010 would go and deal with
  51. a "device not present" situation. If
  52. all is well, line 1020 executes and
  53. disk access occurs.
  54.  
  55.     GET DIRECTORY has been greatly
  56. improved with the addition of one
  57. more parameter: how many filenames
  58. you have room to hold. This number
  59. should be calculated as:
  60.  
  61.    # files = INT((bufferspace-1)/32)
  62.  
  63.     For example, if your buffer was
  64. from 49152 to 53248, you could fit
  65. INT((4096-1)/32) = 127 names there.
  66. This formula takes into account the
  67. zero cap and the three bytes per line
  68. that the racking process needs.
  69.  
  70.     If the buffer space is filled up
  71. before all the filenames are loaded,
  72. B$ will return "more files on disk".
  73. If you don't care about buffer space,
  74. use 0 for the number of filenames.
  75.  
  76.  
  77.  SCROLLING MENU:
  78.  .ML,<area>,bx,ic,u,h,lc,t$,b$
  79.  -----------------------------
  80.  
  81.     The <area> represents the x1,x2,
  82. y1,y2 parameters so common to
  83. DotBASIC. (In your code, replace
  84. <area> with the x1,x2,y1,y2
  85. parameters.)
  86.  
  87.     The x1,x2,y1,y2 parameters set the
  88. area the menu will occupy on the
  89. screen, which must be at least 7
  90. characters tall and 11 wide. BX -
  91. Color for the box around the Scrolling
  92. Menu. IC - Color for the "icons" --
  93. UP, DOWN, HOME, QUIT. U is the color
  94. of the unhighlighted items of the
  95. menu. H is the highlight bar color. If
  96. you don't want the text to reverse or
  97. un-reverse as the bar moves, add 128
  98. to H.
  99.  
  100.     Left-click on UP or DOWN icons to
  101. scroll the text. Right-click on them
  102. and the list jumps a page at a time.
  103. The user can use the CRSR keys to
  104. scroll or page through the text as
  105. well.
  106.  
  107.     Clicking on HOME icon will bring
  108. the list to the top. Pressing the
  109. HOME key will bring the highlight bar
  110. to the top of the page, and the next
  111. press brings the list to the top.
  112.  
  113.     Click on an item or press RETURN
  114. to select it. The entire item is
  115. returned in W$. F$ will return a null
  116. unless this is a file requestor --
  117. when it will contain the filename. SL%
  118. returns the selection number.
  119.  
  120.     Clicking on QUIT icon, pressing
  121. Q, or pressing the Global Escape key
  122. will return zero in SL% and nulls in
  123. W$ and F$.
  124.  
  125.     LC is the location of the EDSTAR
  126. file, which can be anywhere in
  127. memory. The file will be "racked up"
  128. before use, which can take up to a
  129. second (gasp!) on 1 MHz machines.
  130. When LC=0, the text file will not be
  131. racked up again -- like when you have
  132. sorted the data. This is better served
  133. for the multi-select menu, if you
  134. wanted to re-enter the menu without
  135. zeroing the "selected" flags. (Read
  136. on!)
  137.  
  138.     T$ is printed at the menu's top,
  139. in reverse, between HOME and UP. B$
  140. is printed at the bottom, between
  141. QUIT and DOWN. You needn't use the
  142. actual variables T$ and B$, but if
  143. this is going to be a file requestor,
  144. it's perfect. The user gets to see
  145. the disk name and blocks free without
  146. any extra effort from you.!
  147.  
  148.     Set X2 to 255 and the proper
  149. width for a file requestor will be
  150. assigned, but that's it. DotBASIC
  151. knows what filename info looks like
  152. and will set F$ properly when it finds
  153. a filename - regardless of width.
  154.  
  155.     NOTE: Using the SCROLLING MENU
  156. with LC not equal to zero changes what
  157. the INDEX routine is cued up to read.
  158. That is, if LC>0 then the data is
  159. Racked.
  160.  
  161.      An alternate use of LC=0 is, for
  162. example, in a puzzle game. You could
  163. BLOAD WITH ZERO the instructions,
  164. RACK it up right away, and then just
  165. use 0 for LC in the scrolling menu.
  166. The HELP text would pop up quickly,
  167. every time the user needed it.
  168.  
  169.  
  170. BUILD YOUR OWN SCROLLING MENUS
  171. -------------------------------
  172.  
  173.      X1+128 is a powerful new
  174. feature. If you do not like the
  175. generic look of the scrolling menu,
  176. you can now do something about it!
  177.  
  178.      Several things DON'T happen when
  179. x1+128 is used. The bx,ic,t$, and b$
  180. parameters are IGNORED. The scrolling
  181. menu box is NOT drawn. The previouse
  182. CAGE remains the same. The x1,x2,y1,
  183. y2 parameters now represent the area
  184. for the ACTUAL scrolling text alone.
  185.  
  186.      "Manual Icons" is just that.
  187. MR.MOUSE is trusting YOU to create,
  188. label, and enable (as regions) the
  189. icons for your scrolling menu. They
  190. can be any size and at any location.
  191.  
  192.      Since you may not always label
  193. the EXIT icon as "Quit", MV+16 exists
  194. so you can assign an appropriate key
  195. to the exit function. The CRSR keys
  196. still scroll and page, and HOME still
  197. goes home. ESCAPE cancels, just like
  198. EXIT (in the regular scrolling menu).
  199.  
  200.     For SCROLLING MENU to work, you
  201. must have a RACKED EDSTAR file in
  202. memory, and it must end with a zero
  203. byte. If STAR LINKER is used to place
  204. prepared lists into memory, you will
  205. need to append a zero to each text
  206. file with an ML monitor. (Or use
  207. Mr.Edstar -- which includes the 0 at
  208. the end of the file.)
  209.  
  210.  
  211.   MORE ABOUT INDEXING
  212.   -------------------
  213.  
  214.     When a file is RACKed up by
  215. yourself or a scrolling menu,
  216. MV+24/25 reveal the location of the
  217. text's newly generated pointers. The
  218. number of items in the current
  219. INDEXable file is at MV+26/27. These
  220. two variables, which used to be kept
  221. internally, are now at the disposal
  222. of the advanced programmer.
  223.  
  224.     By preserving and later restoring
  225. MV+24-27, it is possible to have two
  226. or more INDEXable files in memory at
  227. once, without having to RACK them
  228. (taking almost a second) just so you
  229. can switch between them.
  230.  
  231.     RACKing also would wipe out all
  232. the "selected" flags stored as bit 7
  233. of each item's LENGTH value. You may
  234. want to preseve MV+24-27 before
  235. calling another scrolling menu so you
  236. do not lose these flags. POKE the
  237. saved values back into MV+24-27 when
  238. it's time to INDEX SELECTED ITEMs.
  239.  
  240. [NOTE:] Remember, with DotBASIC, you
  241. can Get and Put two-byte values in
  242. memory with single commands. If you
  243. want to preserve the above locations
  244. in I1 and I2, then
  245.  
  246.    .G2,MV+24,I1:.G2,MV+26,I2
  247.  
  248. To replace the values
  249.  
  250.    .P2,MV+24,I1:.P2,MV+26,I2
  251.  
  252. Simple, eh? DMM
  253.  
  254.  
  255.     Yes sir. We have multi-selectable
  256. scrolling menus now! But first, let's
  257. examine the regular SCROLLING MENU:
  258.  
  259.  
  260.   MULTI-SELECT SCROLL MENU
  261.   .MV,area,b,i,u,h,s,w,l,t$,b$
  262.   ----------------------------
  263.  
  264.   area - use x1,x2,y1,y2 in your code
  265.   b    - box color
  266.   i    - icon collor
  267.   u    - unhighlighted color
  268.   h    - highlighted color
  269.   s    - selected color
  270.   w    - selected With bar
  271.   l    - location of file
  272.   t$   - top string
  273.   b$   - bottom string
  274.  
  275.     It's always easy to spot the
  276. selected items, even when they are
  277. under the highlight bar. Which of the
  278. u,h,s,w items are REVERSED is set
  279. from bits 3-0 to MV+15. By default,
  280. the highlight bar and all selected
  281. items are reversed. Each reverse bit
  282. can be temporarily disobeyed by
  283. adding 128 to the u,h,s,w parameters.
  284.  
  285.     Selecting items is as easy as
  286. hitting RETURN or clicking on them.
  287. The item is toggled and the mouse and
  288. highlight bar are moved down to the
  289. next item, scrolling when necessary -
  290. even when selecting with the mouse!
  291.  
  292.     The additional keys A, N, and T
  293. function within multi-select menus to
  294. select ALL, NONE, and to TOGGLE ALL
  295. items (respectively). The mouse user
  296. cannot access these special features
  297. unless YOU enable manual icons!
  298.  
  299.     Exiting a multi-select menu is the
  300. confusing part. If you press the EXIT
  301. key (MV+16), SL% will return the
  302. number of items selected. If ESCAPE is
  303. pressed, the menu is cancelled and
  304. zero is returned in SL%. The selected
  305. items still exist, and still can be
  306. indexed, but you are just told that
  307. there weren't any selected items.
  308.  
  309.     Once you have a selected item or
  310. items, use:
  311.  
  312.   INDEX SELECTED ITEM: .SI,number
  313.   -------------------------------
  314.  
  315.     This puts the ITEM(Number) into
  316. W$ and (if a Directory) F$. A quick
  317. look at Selected Items could be
  318. accomplished with
  319.  
  320.             FOR X=1 TO SL%
  321.             SYS .SI,X
  322.             PRINT W$
  323.             NEXT
  324.  
  325.  
  326.   PRINT SELECTED ITEM
  327.   .SP,x,y,number
  328.   -------------------
  329.  
  330.     Does a PRINT AT of the item text,
  331. without affecting W$.
  332.  
  333.  
  334.   PRINT SELECTED NAME: .SN,x,y,number
  335.   -----------------------------------
  336.  
  337.    Does that same as
  338.  
  339.               P@,x,y,F$
  340.  
  341. (without affecting F$!
  342.  
  343.     If you are using manual icons, the
  344. mouse usually can move anywhere on the
  345. screen. Nothing happens if the user
  346. clicks outside the menu. Even clicking
  347. on an active region has no effect IF
  348. the region number isn't one that I've
  349. assigned a function to.
  350.  
  351.      Here are the REGION NUMBERS and
  352. the functions they would have for a
  353. regular scrolling menu:
  354.  
  355.      1. home
  356.      2. scroll up
  357.      3. scroll down
  358.      4. exit
  359.      5. page up
  360.      6. page down
  361.  
  362.      Regions 5 and 6 aren't
  363. necessary, so don't feel obligated to
  364. use them. Nothing bad will happen if
  365. you don't have 6 active regions.
  366. Right-clicking on regions 2 and 3
  367. also PAGE, too.
  368.  
  369.      MULTI-SELECT SCROLL MENUs will
  370. obey up to four extra regions, if you
  371. take the time to define them.
  372.  
  373.      7. select all
  374.      8. select none
  375.      9. toggle all
  376.     10. cancel
  377.  
  378.     Pressing EXIT or clicking on
  379. region 4 will return the number of
  380. selected items in SL%. Region 10
  381. behaves just like ESCAPE, returning a
  382. grand total of zero selected items.
  383.  
  384.     Remember: When regions overlap,
  385. the higher number has priority. So, if
  386. you don't want regions 5 and 6 in your
  387. multi-select menu, just be sure to
  388. define regions 7 and 8 so they
  389. perfectly overlap the previous two on
  390. the screen!
  391.  
  392.     However, joystick users with a
  393. repeating fire button may appreciate
  394. regions 5 and 6. No matter what you
  395. decide, be sure to include regions
  396. 1-4: the same ones that are present
  397. using the generic "standard" icons.
  398.  
  399.  
  400.   SCROLL NUMBER ENABLE
  401.   .S#,current,total,selected
  402.   --------------------------
  403.  
  404.     You can add that finishing touch
  405. to a scrolling menu with SCROLL
  406. NUMBER. Like the LOADSTAR Presenter's
  407. Text Reader, you can make a message
  408. like "Line 172 of 308" that is updated
  409. each time the infomation changes.
  410. Multi-select menus also show the total
  411. number of SELECTED items.
  412.  
  413.     The parameters are locations in
  414. memory where the numbers will be POKEd
  415. by this routine. So, to put the
  416. Current line number at the top of the
  417. default screen, the Total just below
  418. it, and ignore Selected, use:
  419.  
  420.   SYS ML+228,1024,1064,0
  421.  
  422.     One reason this is a separate
  423. command is because it is RISKY. The
  424. numbers are POKEd to the location you
  425. specify, whether it be the screen or
  426. somewhere it can wreak havoc! So, be
  427. careful when entering these values.
  428.  
  429.     It takes some time to figure out
  430. the screen location to place each
  431. 4-digit number at, but it is worth the
  432. effort. Assign 0 to the numbers that
  433. you choose not to enable.
  434.  
  435. [NOTE:] Use the PP% variable in a
  436. short program line to let the mouse
  437. find the location!
  438.  
  439.          .DO:.MA:.UN L2%:?PP%
  440.  
  441.  
  442.   VARIOUS OTHER STUFF
  443.   -------------------
  444.  
  445.     Four variables help to give the
  446. joystick and CRSR keys several degrees
  447. of motion. The minimum and maximum
  448. speeds are measured in "pixels per
  449. interrupt". The acceleration and
  450. deceleration values are more relative.
  451. But don't bother yourself with these
  452. settings: the defaults work quite well
  453. for most applications.
  454.  
  455.     Sprite Update, the variable at
  456. MV+5, could be set to zero to prevent
  457. the interrupt routine from moving any
  458. sprites at all. It still would keep
  459. track of the "phantom" pointer. I
  460. doubt that this command is of any use.
  461.  
  462. NOTE: Actually, it DOES have a use.
  463. When you really, really need all 8
  464. sprites during a program and can live
  465. without the mouse -- or can code to
  466. use a character as a mouse, you will
  467. be glad Lee included this varialbe!
  468.  
  469.  
  470.     On boot, DotBASIC uses the EASY
  471. SPRITE function to produce a simple
  472. arrow pointer. The upper-leftmost
  473. pixel of that sprite is what is called
  474. the "pointing pixel". As far as
  475. DotBASIC is concerned, that IS the
  476. pointer! All feedback data returned by
  477. the ASK routine is true for that one
  478. pixel only.
  479.  
  480.     What if you want to design a
  481. mouse-driven shooting game whose
  482. pointer looks like a targeting box?
  483.  
  484.    Related variables:     (& defaults)
  485.  
  486.   MV+3  Pointing Pixel-X       (0)
  487.   MV+4  Pointing Pixel-Y       (0)
  488.  
  489.     Use these variables to define the
  490. pointing pixel within your sprite,
  491. where x=0-23 and y=0-20. Expanded
  492. sprites mean you should double the
  493. proper value(s) here, too.
  494.  
  495.  LN
  496.  
  497.  NOTE: These docs have been edited
  498. with the assumption that you will be
  499. doing purely DotBASIC programming.
  500. Mr.Mouse is fully available in
  501. DotBASIC, with a beginning address of
  502. 9216. ML coders can also use many of
  503. these commands to great advantage. For
  504. Mr.Mouse address offsets, see issue
  505. 177.
  506.  
  507.  Even as I edit this massive
  508. documentation, I realize that DotBASIC
  509. -- at least the Mr. Mouse portion --
  510. is incredibly powerful. I am still
  511. learning. And you can to!
  512.  
  513.  DMM
  514.  
  515.  
  516.