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

  1. u
  2.         DOTBASIC DOCUMENTATION
  3.                 Part 2
  4.  
  5.               Program by
  6.       Dave Moorman and Lee Novak
  7.           Text by Lee Novak
  8.  
  9.  
  10.     Here is the Mr. Mouse portion of
  11. the documentation for DotBASIC. I have
  12. edited the following to refer to
  13. DotBASIC commands. Otherwise, Lee sees
  14. all and tells all.
  15.  
  16.  DMM
  17.  
  18.  
  19.     I am pleased to finally present
  20. the reworking of one of LOADSTAR's
  21. most popular toolboxes. I'd like to
  22. thank Jeff Jones for his help in this
  23. project. Without it, DotBASIC would
  24. have been quite different. He stopped
  25. me from making a couple of BIG
  26. mistakes, and even some of his ideas
  27. are among this mess of code.
  28.  
  29. [NOTE:] I do not know of anyone who
  30. did more to make BASIC programming
  31. easy and elegant than Jeff Jones. He
  32. introduced the earliest Toolbox back
  33. on LOADSTAR 91, and proceeded to
  34. improve it until Lee got into the act
  35. with Mr.Mouse. DMM
  36.  
  37.  
  38.     Programs written with DotBASIC
  39. (DB) automatically support both a
  40. mouse in port 1 and a joystick in port
  41. 2. The FIRE button on the joystick is
  42. the same as the left mouse button. For
  43. joystick users, any key can be defined
  44. to replace the missing right mouse
  45. button. The middle button (on CMD's
  46. SmartMouse) will double the mouse's
  47. speed.
  48.  
  49.     Lee has included many internal
  50. variables and controls that can be
  51. accessed with POKE MV+offset. The
  52. variable MV is automatically assigned
  53. when DotBASIC is initiated.
  54.  
  55.  
  56.     Let's go over the features
  57. included in DotBASIC. First off, the
  58. keyboard can mimic the mouse buttons.
  59.  
  60.    Related Variables:     (& defaults)
  61.  
  62.   MV+14  Right Keycode        (F7 = 3)
  63.  
  64.     MV+14 holds the keyboard
  65. equivalent to the right mouse button.
  66. The spacebar serves as the left button
  67. -- people expect this. The right
  68. button is defined as F7, but you could
  69. change it if you've assigned a
  70. function to the right mouse button and
  71. would like to use F7 (and F8) as
  72. hotkeys instead.
  73.  
  74.     Note that MV+14 is not an ASCII
  75. code. "Keycodes" are generated by the
  76. SCNKEY routine during the interrupt.
  77. They can be determined with this
  78. one-line program:
  79.  
  80.    10 print peek(203):goto 10
  81.  
  82.     When you RUN it, hold down the key
  83. you want to designate as a button and
  84. note the number showing. Be aware that
  85. keycodes are not affected by the
  86. special (SHIFT) keys, and these
  87. special keys don't have keycodes - so
  88. they can't be used as mouse buttons.
  89.  
  90.   MV+18  Keyboard Enable (default 129)
  91.  
  92.          +128 = Return can click
  93.          +64  = Space can click
  94.          +32  = Commodore can click.
  95.          +1   = CRSR keys move arrow
  96.  
  97.     Even the CRSR keys can control the
  98. arrow pointer around the screen. This
  99. makes it especially easy to add
  100. "keyboard support" to your programs
  101. without having to think about it. By
  102. default, the RETURN key serves as the
  103. left mouse button.
  104.  
  105.      With a POKE, you could enable
  106. the COMMODORE key to also serve as
  107. the left mouse button. This would be
  108. useful for any "click and drag"
  109. situations within your program, only
  110. because the Commodore key can be read
  111. independently of the CRSR keys. It is
  112. awkward to use, but it works. RETURN
  113. or SPACE can be used to "click" the
  114. rest of the time. It's more natural.
  115.  
  116.  
  117.     You can change the appearance of
  118. the mouse arrow with
  119.  
  120.   MV+17  Twin Flag    (default is 128)
  121.  
  122.     A Twin Flag setting of 128 (or
  123. higher) will cause sprite 1 to be
  124. enabled as a black shadow arrow. After
  125. that, it is the interrupt's job to
  126. ensure the shadow arrow follows the
  127. other sprite. The Twin Flag may be set
  128. to these values:
  129.  
  130.      0 = Single sprite only
  131.    128 = Dual sprite, shadow @ x+2,y+1
  132.    192 = Dual sprite, perfect sync
  133.  
  134.     Although 192 would cause the
  135. shadow sprite to be directly under the
  136. pointer sprite, and thus unseen, there
  137. ARE other uses for this feature. The
  138. sprites don't have to share the same
  139. shape, you know.
  140.  
  141.  
  142.   ASK BASIC: .MA
  143.   --------------
  144.  
  145.     This crucial command is the only
  146. way to get feedback from DotBASIC
  147. outside the Main Event Driver Loop
  148. (line 100 on the template program).
  149. Feedback is deposited in integer
  150. variables. Here's the wealth of
  151. information you will get:
  152.  
  153.    Mouse position information
  154.  
  155.    PX%  Pixel-X location (0-319)
  156.    PY%  Pixel-Y location (0-199)
  157.    CX%  Cell-X location  (0-39)
  158.    CY%  Cell-Y location  (0-24)
  159.  
  160.    Mouse button information
  161.  
  162.    L1%  Left button    (0=up, 1=down)
  163.    R1%  Right button   (0=up, 1=down)
  164.    L2%  New left push  (0=no, 1=yes)
  165.    R2%  New right push (0=no, 1=yes)
  166.  
  167.      While L1% and R1% merely return
  168. the state of the buttons, L2% and R2%
  169. tell you if the press is NEW. This is
  170. useful for clicking on things. Here is
  171. a sure-fire way to sense a new click:
  172.  
  173.  100 .MA
  174.  101 IF(L1% AND L2%)=0 THEN 100
  175.  102 <<CLICK HAPPENED>>
  176.  
  177. [NOTE:] Use the .DO loop:
  178.  
  179.     .DO:.MA:.UN L2%
  180.  
  181.  This works splendidly. DMM
  182.  
  183.  
  184.     There are also other times when
  185. you want to do something when the
  186. button is pressed, but not continually
  187. as the user holds the button down and
  188. scoots across the screen.
  189.  
  190.     Internally, new button presses are
  191. nulled when the button is lifted or
  192. the .MA routine is called.
  193.  
  194.  
  195.    Text screen information
  196.  
  197.    SC%  Screen Code under mouse
  198.    CC%  Color Code under mouse
  199.    PP%  Pointer Position of mouse
  200.  
  201.     The color data is stripped of its
  202. upper (garbage) nybble. The pointer
  203. position is the RAM location of the
  204. screen cell right under the mouse.
  205. Since PP% is an integer, values above
  206. 32767 will be negative.
  207.  
  208. [NOTE:] This won't be a problem is you
  209. use the default screen at $0400
  210. (1024). But should you get brave, use
  211. .IU,PP% to put the full, positive
  212. value in FP!  DMM
  213.  
  214.  
  215.    Region information
  216.  
  217.    RG%  Region # mouse is over (0-64)
  218.    CR%  Region # being clicked (0-64)
  219.  
  220.     A "region" is an area of the
  221. screen that you can define by its
  222. x1,x2,y1,y2 limits. (The Event Regions
  223. you define with VDOT are these very
  224. regions!) RG% will be zero unless the
  225. mouse pointer is currently on top of
  226. an ACTIVE region. CR% will be zero
  227. unless the user is currently
  228. left-clicking on a particular region.
  229. In the case of overlapping regions,
  230. the higher number is returned.
  231.  
  232.     The "freshness" of all mouse
  233. feedback depends on how often you are
  234. able to call the ASK routine, and how
  235. quickly your program can respond to
  236. the data.
  237.  
  238.  
  239.   PRINT AT: .P@,x,y,string
  240.   ------------------------
  241.  
  242.     This prints a string as you'd
  243. expect - with one exception. To aid in
  244. readying lists and menus, any F7's
  245. embedded in the string (inside quote
  246. mode) will result in a tab back to the
  247. X coordinate and a cursor down.
  248.  
  249.  
  250.   DEFINE REGION:
  251.   .RD,region #,x1,x2,y1,y2
  252.   ------------------------
  253.  
  254.     Any area of the screen can be
  255. defined as a "region". You specify the
  256. region number (1-64) and its cellular
  257. limits. By using regions, you can
  258. easily tell if the mouse is over an
  259. icon, box, or whatever. You can
  260. re-define a region on the fly and
  261. indefinitely.
  262.  
  263. [NOTE:] Remember, Event Regions are
  264. regions, too. Define Regions only in
  265. Event Handling routines or when the
  266. Event Driver has been disabled. Also,
  267. it is a good idea use a different
  268. Region Data Zone for your own regions.
  269. One place that is handy (unless you
  270. are using sprites) is page 35.
  271.  
  272.  POKE MV+1,34
  273.  
  274.  When the code returns to the Main
  275. Event Driver Loop, the Event
  276. Region Data is restored automatically.
  277. (DMM)
  278.  
  279.  
  280.    Related variables:     (& defaults)
  281.  
  282.   MV+0  Region Data Zone: LB     (0)
  283.   MV+1  Region Data Zone: HB     (4)
  284.   MV+2  Number of Active Regions (0)
  285.  
  286.     Defined regions are not "seen" by
  287. the mouse unless you mark them as
  288. ACTIVE, by placing a value into MV+2.
  289. For example, if this number is 7, then
  290. regions 1-7 are active. Each time you
  291. define a region, that region number is
  292. automatically placed into MV+2 for
  293. your convenience. You may change this
  294. number at will.
  295.  
  296.     Region data can be placed almost
  297. anywhere in memory, the exception
  298. being under the ROMS or I/O. As
  299. mentioned in the NOTE above, if you
  300. are defining and using run-time
  301. regions, you should first set the
  302. Region Data Zone with POKEs to MV+1
  303. and MV+0 before defining regions. It's
  304. your job to ensure this area is safe
  305. from BASIC and your other data.
  306.  
  307. [NOTE:] As I was doing the final edit
  308. on this text, I tried an experiment. I
  309. POKEd MV+2 with a 0 in line 99 -- just
  310. before the Main Event Driver Loop. The
  311. Event Driver was very uneventful!
  312. Nothing happened. No roll-over, no
  313. clicks. Dead!
  314.  
  315.  So, If you want to disable certain
  316. Event Regions, organize them so the
  317. ones you want to disable are higher
  318. numbered than the ones you want
  319. active. Then reduce the value in MV+2.
  320. But remember, you [cannot] add Event
  321. Regions on the fly. You will get a
  322. Syntax Error. DMM
  323.  
  324.  
  325.   CAGE MOUSE: .MC,x1,x2,y1,y2
  326.   ---------------------------
  327.  
  328.     This command confines the mouse
  329. pointer's movement within an area. It
  330. is almost not even needed, since menus
  331. automatically alter the cage and the
  332. .QR command ensures you start out
  333. with a full-screen cage.
  334.  
  335.     Check out QUICKSMITH (on LS #164)
  336. to see a use I have found for CAGE.
  337. When you are using the slider bar, the
  338. mouse is caged within the range of
  339. movement the bar allows. On more
  340. expensive computers, the mouse can
  341. "slip" off the slider bar and cause
  342. confusion.
  343.  
  344.  
  345.   POSITION MOUSE: MP,x,y
  346.   ----------------------
  347.  
  348.     Use this command to place the
  349. mouse at any cellular X,Y location. If
  350. you attempt to place the mouse outside
  351. of its "cage", it will be snapped back
  352. inside instantly.
  353.  
  354.  
  355.   PAUSE: .@Z,jiffies
  356.   ------------------
  357.  
  358.     This routine waits for the
  359. specified number of mouse interrupts
  360. to pass before returning control to
  361. you. The wait is (usually) measured in
  362. sixtieths of a second, and the value
  363. cannot exceed 255.
  364.  
  365.  
  366.   PRINT CENTER: .PC,y,string
  367.   --------------------------
  368.  
  369.     This routine prints your string
  370. (up to 40 characters) centered on any
  371. line y (0-24). Don't use F7's in these
  372. strings as you probably won't get the
  373. effect you were looking for.
  374.  
  375.  
  376.   BLOCK: .BX,x1,x2,y1,y2,sc,color
  377.   -------------------------------
  378.  
  379.     The BLOCK command is able to
  380. perform a variety of tasks, based on
  381. the parameters you feed it. The last
  382. two parameters specify what to do
  383. within the boundaries:
  384.  
  385.   BLOCK: To fill an area with a
  386.     character, just specify its screen
  387.     code (0-254) and the color you
  388.     want it to be (0-15).
  389.  
  390.   PAINT: Using 255 for a screen code
  391.     causes the routine to only color
  392.     the area, leaving screen RAM
  393.     intact.
  394.  
  395.   SHADE: Using 255 for a color code
  396.     causes all of the colors in the
  397.     area to be assigned a darker shade
  398.     than each currently has. Screen
  399.     RAM is not affected.
  400.  
  401.   REVERSE, UN-REVERSE, and FLIP: Add
  402.     128 to the color code to invoke
  403.     reverse, 64 for un-reverse, and
  404.     192 for flip. Color RAM will not
  405.     be affected unless you add an
  406.     additional 16 to the values above.
  407.  
  408.   FRAME: Adding 32 to the color code
  409.     will draw a frame (like BOX below)
  410.     that ignores the center area
  411.     automatically.
  412.  
  413.   BOX: Adding 16 to the color code
  414.     results in a box made up of nine
  415.     specific characters. The defaults
  416.     work well with either case font.
  417.     They can be changed for use with
  418.     custom fonts that have their
  419.     box-making characters elsewhere.
  420.  
  421.     BOX refuses to use screen code 0
  422.     in what it draws. This is so you
  423.     can set MV+41 (the screen code
  424.     used to draw the interior of
  425.     boxes) to zero. The effect is that
  426.     BOX now behaves like FRAME,
  427.     leaving the center alone.
  428.  
  429.  
  430.   AFFECT REGION: .RA,region #,sc,color
  431.   ------------------------------------
  432.  
  433.     This command is just like BLOCK.
  434. But instead of specifying x1,x2,y1,y2
  435. parameters, you indicate which region
  436. you want to affect.
  437.  
  438.     AFFECT is most often used in
  439. causing visible changes to a region
  440. when it is clicked on. It can also
  441. help in setting up screens. Event
  442. Regions can be affected at will!
  443.  
  444.  
  445.   SCREEN STASH:   .SS,page
  446.   SCREEN RESTORE: .SR,page
  447.   ------------------------
  448.  
  449.     SCREEN STASH will store the text
  450. screen and color map anywhere in
  451. memory, even under ROM and I/O. 8
  452. consecutive pages (2048 bytes or 2K)
  453. are needed to save both areas. The
  454. border and background colors are also
  455. saved.
  456.  
  457.     SCREEN RESTORE displays a stashed
  458. screen from anywhere in memory. The
  459. border and background colors are also
  460. restored.
  461.  
  462. [TECHNICAL NOTE:] The stash/restore
  463. routines copy 1002 bytes each of the
  464. screen and color map. STASH will put
  465. the border and background colors into
  466. locations $d800+1000 and $d800+1001
  467. before doing the memory transfer.
  468. After RESTOREing, the colors are
  469. brought back from those locations. The
  470. two bytes after the end of the screen
  471. are stashed and restored also, but
  472. they have no significance.
  473.  
  474.  
  475.     We are just getting started. More
  476. fun to come in Part 2!
  477.  
  478.  
  479.  
  480.