home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 248 / 248.d81 / t.dotbasic < prev    next >
Text File  |  2022-08-26  |  9KB  |  383 lines

  1. u
  2.             DotBASIC Plus
  3.              The Tutorial
  4.            by Dave Moorman
  5.  
  6.  
  7.     DotBASIC Plus (DB+) is a new and
  8. exciting way to put pizzazz in your
  9. programs. This tutorial series will
  10. walk through a number of program
  11. ideas, explaining the various
  12. DBCommands along the way.
  13.  
  14.     You do not need to be a programmer
  15. -- however some familiarity with BASIC
  16. 2.0 (the built-in language on the
  17. C-64) will help. We will start from
  18. scratch. Yep -- "Hello, World" will be
  19. our first project. From there, we will
  20. explore doing custom screens, event
  21. regions, mouse controls, and a host of
  22. other features.
  23.  
  24.     With DB+, you do not have to know
  25. any Machine Language. You don't even
  26. need to know much about bloading and
  27. using ML modules. Most everything you
  28. will need is built into the language.
  29.  
  30.     You will need a copy of the
  31. DotBASIC Plus disk and at least one
  32. disk drive. The system works best if
  33. you have two or more drives. The DB+
  34. disk should be put in your secondary
  35. drive, and your formatted Work Disk in
  36. the primary drive. I use drive 8 for
  37. my Work, drive 9 for my Utilties, and
  38. drive 10 for the DB+ disk. Your
  39. situation may vary. I also work in
  40. VICE, the Versatile Commodore
  41. Emulator, on a Pentium 400 Windows 98
  42. machine. Even on the shiny new
  43. equipment, I am woefully behind the
  44. cutting edge!
  45.  
  46.     You will want to copy DB+ to a new
  47. disk. Single 1541 users will need to
  48. delete the text files (t.*) to have
  49. room for your work. Just be sure to
  50. copy your program to another disk when
  51. the project is completed.
  52.  
  53.  
  54.  SEMI-OBLIGATORY
  55.  HELLO WORLD PROGRAM
  56.  
  57.     So you are ready to go? Format
  58. your work disk, make sure all disks
  59. are in the proper drives. We will use
  60. the "variables" db for your DB+ disk
  61. drive and dw for the Work disk drive.
  62. Ready? Here we go!
  63.  
  64.     LOAD"B.DOTBASIC",db
  65.  
  66.     and
  67.  
  68.     RUN
  69.  
  70.     You will see a menu of all working
  71. drives labeled "Dot Disk." Choose the
  72. drive your DB+ disk is in. The next
  73. menu is "Work Dsk." Choose the drive
  74. your Work disk is in. You will be
  75. asked to confirm both choices. If you
  76. need to change, press <N>, then press
  77. <Y> to try again.
  78.  
  79.     You are now prompted to input the
  80. program name. We will call this
  81. program "hello". Type in:
  82.  
  83.                 hello
  84.  
  85.  and press <RETURN>.
  86.  
  87.     After some very quick flashes,
  88. the screen gets a blue background,
  89. blue border, and white text
  90. characters. If you look at the
  91. directory,
  92.  
  93.  LOAD"$",dw
  94.  and
  95.  LIST
  96.  
  97.  you will see
  98.  
  99.  B.HELLO
  100.  MOUSE2.1 7K 1000
  101.  HELLO.DML
  102.  HELLO.DBS
  103.  
  104.     B.HELLO is the boot program, the
  105. one you will load and run to start
  106. your program. MOUSE2.1 7K 1000
  107. provides many of the commands you
  108. will use. HELLO.DML is the ML program
  109. that interprets commands from DB+ and
  110. makes them work.
  111.  
  112.     And HELLO.DBS is your DB+
  113. program. This is the place where you
  114. will be working.
  115.  
  116.     If you loaded the directory and
  117. listed it, now LOAD"HELLO.DBS",dw .
  118. Either way, RUN it. Now LIST the
  119. program:
  120.  
  121.  5 d=peek(186): dd=56*256: mm=16*256
  122.  10 rem begin list
  123.  20 rem.endlist
  124.  30 sysdd
  125.  40 .tx,1: print"<clr>";:
  126.     .bg,6:.br,14
  127.  59998 .of
  128.  59999 end
  129.  60000 gosub60008: n$=n$+".dbs"
  130.  60001 d=peek(186): sys14339
  131.  60002 open1,d,15,"s0:"+n$: close1
  132.  60003 saven$,d:end
  133.  60008 n$="hello"
  134.  60009 return
  135.  
  136. Line 5 sets up important variables.
  137. Lines 10 through 20 are used to add
  138. commands to your DB+ program. Line 30
  139. starts DB+.
  140.  
  141. Line 40 uses three DB+ commands.
  142.  
  143.  .TX,color
  144.     sets the Text color. Add 128 to
  145.     the color value to reverse the
  146.     text.
  147.  
  148.  .BG sets the Background color.
  149.  
  150.  .BR sets the Border color.
  151.  
  152.     On line 59998 we have another
  153. DotCommand:
  154.  
  155.  .OF
  156.  
  157. which turns off DB+ and returns your
  158. computer to it's normal default
  159. state. The SYS14339 in line 60001
  160. does the same thing.
  161.  
  162.     You will note that lines 60000 on
  163. contain our LOADSTAR "scratch and
  164. save" routine. With DB+, all you ever
  165. need to do to save your program is
  166.  
  167.  GOTO60000
  168.  
  169. And press <RETURN>.
  170.  
  171.     Impressed? Confused? Don't worry.
  172. We will now write "Hello"!
  173.  
  174.  100 PRINT"Hello, World"
  175.  102 .DO
  176.  104 .MA
  177.  106 .UN L2% or PEEK(198)
  178.  108 PRINT"<clr>";
  179.  110 POKE 198,0
  180.  
  181.  (You will notice that throughout this
  182. tutorial, I will use upper case
  183. characters for commands, and lower/
  184. upper case for text in strings.
  185. "<clr>" is <Shift-Home>.)
  186.  
  187.     Actually, the printing of "Hello
  188. World" is just plain BASIC 2.0. The
  189. DB+ improvement comes with lines 102
  190. - 106.
  191.  
  192.  .DO begins a Do-Loop. If you have
  193. worked with any language other than
  194. BASIC 2.0, you know what a Do-Loop is
  195. all about. We will explain in a
  196. moment.
  197.  
  198.  .MA is "Mouse Ask," which puts all
  199. the current conditions of the mouse in
  200. various variables. One of those
  201. variables is L2%, which is 0 until the
  202. left mouse button is clicked. (This
  203. goes for the joystick fire button as
  204. well.)
  205.  
  206.  .UN is short for UNtil, and the
  207. program will loop back to the .DO
  208. until either l2% or PEEK(198) are not
  209. 0. So when you click the left mouse
  210. button, fire button, or press any key,
  211. the program falls through the UNtil.
  212. Otherwise, this code just waits for
  213. something to happen.
  214.  
  215.     The Do-Loop is perfect for many
  216. mouse-driven activities and we will
  217. use it a lot. We can put everything on
  218. just one line:
  219.  
  220.  102 .do:.ma:.un l2% or
  221.         peek(198):poke198,0
  222.  
  223.     So GOTO60000 then RUN your
  224. program! Always GOTO60000 before
  225. RUNning your program! That way, if DB+
  226. is still active in the background, it
  227. will be stopped.
  228.  
  229.     You can do all sorts of things
  230. with this. For example, a FOR-NEXT
  231. loop will add some color and fun:
  232.  
  233. 100 for x=0to15:.tx,x:print"Hello,
  234. World":next
  235.  
  236.     Change line 102 to
  237.  102 .do:.ma
  238.  
  239. then add:
  240.  
  241.  103 .bg,cx%and15
  242.  104 .br,cy%and15
  243.  
  244.     Now your mouse/joystick will
  245. control the color of the background
  246. and border. CX% gives the text cell
  247. x-coordinate (after .MA happens), and
  248. CY% is the y-coordinate. You will find
  249. this feature extremely valuable!
  250.  
  251.     Check out the DB+ Docs for all the
  252. values returned by .MA. Think of the
  253. POWER!
  254.  
  255.           ------------------
  256.  
  257.  INFINITE COMMANDS
  258.  
  259.     I have lost track of how many
  260. commands are available in DB+; the
  261. list just keeps growing. However,
  262. except for the ones you used above,
  263. you will have to "include" the
  264. commands in the program.
  265.  
  266.     With your disks still in the
  267. drives, reset your computer, then load
  268. and run B.DOTBASIC. Choose the drives
  269. you are using (as before). This time,
  270. for the program name, input:
  271.  
  272.     hello2
  273.  
  274.     Now for the fun. To include
  275. commands, add this line to your
  276. program:
  277.  
  278.  11 rem.text,.box,.keymw
  279.  
  280.     Save the program (good old GOTO
  281. 60000), then load and run B.DEV from
  282. your DB+ disk. If DEV stops, it means
  283. you included a non-existant command,
  284. forgot the REM, or put a space before
  285. the dots.
  286.  
  287.     Let's look at the three commands.
  288.  
  289.  .TEXT,X,Y,W,STRING
  290.  
  291.     This command prints the string at
  292. X,Y -- and word wraps it to fit in W
  293. width. It doesn't get much easier than
  294. that!
  295.  
  296.  .BOX,X,Y,W,H,SC,CO
  297.  
  298.     This draws a box on the screen
  299. with the upper left corner at X,Y, a
  300. width of W, and a Height of H. SC
  301. stands for Screen Code -- usually 32
  302. for a blank screen or 160 for reversed
  303. spaces. CO is COlor, of course. If you
  304. use 255 for SC, the area is painted
  305. with CO. Add 16 to CO to draw a frame
  306. around the box.
  307.  
  308.  .KEYMW
  309.  
  310.     Key/Mouse Wait replaces the
  311. Do-Loop we mentioned above. The
  312. program stops and waits for either a
  313. mouse click or a key press. The mouse
  314. variables hold the mouse's current
  315. information. I% will contain the ASCII
  316. number of the key pressed (0 if none).
  317.  
  318.     We are going to draw a box on the
  319. screen and fill it with text. First
  320. the box:
  321.  
  322.  100 .box,5,5,30,07,32,1+16
  323.  
  324.     This box has its upper left corner
  325. at column 5, row 5, is 30 columns wide
  326. and 7 rows high (or deep). The screen
  327. code is 32 -- a space, with a color of
  328. 1 -- white. The +16 puts a frame
  329. around the box.
  330.  
  331.     Now we need some text to put in
  332. the box.
  333.  
  334.  110 t$="This is a wonderful test of
  335.     this remarkable system. "
  336.  111 t$=t$+"Nothing can possibly go
  337.     wrong with this test."
  338.  
  339.     T$ now holds this long text. Lets
  340. set the text color to yellow, and the
  341. border and background to black.
  342.  
  343.  112 .tx,7:.br,0:.bg,0
  344.  
  345.     We are now ready to print the text
  346. with .TEXT. Note that the X,Y
  347. locations are one more than the box's
  348. X,Y, and the width is two less than
  349. that of the box.
  350.  
  351.  120 .text,6,6,28,t$
  352.  
  353.     And watch how tidy this is:
  354.  
  355.  130 .k