home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 66 / 066.d81 / b+demo (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  9KB  |  176 lines

  1. 1 rem *********************************       *                               *
  2. 2 rem * b+ demo program by j. mattson *       *         - 05/20/89 -          *
  3. 3 rem * this program has been created *       * to help you absorb the many   *
  4. 4 rem * new commands. study the rems  *       * & programming techniques and  *
  5. 5 rem * you will be well on your way  *       * mastering b+!                 *
  6. 6 rem *                               *       *********************************
  7. 7 rem
  8. 8 rem *   load b+ and set things up   *
  9. 10 ifa=.thena=1:load"b+",8,1
  10. 15 rem *protect hi-res area from basic*
  11. 20 poke52,88:poke56,88:clr:printchr$(142);
  12. 25 rem * sprite pointer for later use *
  13. 30 fori=.to63:poke22528+i,.:next:fori=.to5:readj:poke22528+i*3,j:next
  14. 40 data 240,224,176,24,12,4
  15. 42 rem * quick ml routine allows safe *        * return to loadstar - 'quit'  *
  16. 45 rem * resets computer, so should   *        * not be used with 'chained'   *
  17. 48 rem * programs (like loadstar)     *
  18. 50 fori=22592to22633:readj:pokei,j:next:data120,160,0,162,0,185,94,88,153,4,3
  19. 60 data200,192,6,144,245,185,94,88,157,20,3,200,232,224,6,144,244,88,96
  20. 70 data124,165,26,167,228,167,49,234,102,254,1,254
  21. 75 rem * set up x & y equivalents for *        * joy command directions, then *
  22. 78 rem * jump to main program to skip *        * various subroutines          *
  23. 80 fori=.to8:readx(i),y(i):next:goto140
  24. 90 data 0,0,0,-1,1,-1,1,0,1,1,0,1,-1,1,-1,0,-1,-1
  25. 95 rem * frequently used subroutines  *        * first, wait for space bar    *
  26. 100 poke198,.: rem clear keyboard
  27. 110 geta$:ifa$<>" "then110
  28. 120 return
  29. 125 rem *   normalize screen values   *
  30. 130 (NULL)0:(NULL)1024:(NULL)4096:(NULL)0:(NULL)0,15:(NULL)1,11:(NULL)7,13:(NULL):return
  31. 135 rem * activate b+ and get rolling *
  32. 140 sys49152
  33. 145 rem * pause to show title screen  *         * then set up first window -  *
  34. 150 (NULL)1:(NULL)2,6,27,7,0,1:(NULL)7,13:a$="this opening screen tells"
  35. 155 rem * note that string variables  *         * can be added together when  *
  36. 158 rem * the desired string is too   *         * long for a basic line       *
  37. 160 a$=a$+"you that b+ is installed.of course, you'll want to"
  38. 170 a$=a$+"clear it afterwards with the cls[153] command."
  39. 172 rem * color codes may be embedded *         * to change the color of text *
  40. 175 rem * - be careful to format the  *         * string to fit the window -  *
  41. 178 rem * counting color characters!  *         * now open the window...      *
  42. 180 (NULL)a$
  43. 185 rem * pause and repeat procedure  *         * for the next window         *
  44. 190 (NULL)2:a$="^ this is an example ofthe window commands, bythe way."
  45. 200 (NULL)13,12,25,5,0,1:(NULL)a$
  46. 205 rem * now a 'press space' message *         * with a 'dot' border...      *
  47. 210 (NULL)2:(NULL)7,10:(NULL)11,16,18,3,81,2:(NULL)" > press space <":i=.
  48. 215 rem * ...and jazz it up with the  *         * paint command               *
  49. 220 geta$:ifa$<>" "theni=(i+1)and15:(NULL)81,i:goto220
  50. 225 rem * close up the windows slowly *         * to make effect obvious      *
  51. 230 fori=1to3:(NULL):forj=1to200:nextj,i:(NULL)7,13:(NULL)16,11,8,3,0,1
  52. 240 (NULL)"wheee!":fori=1to400:next:(NULL):(NULL)1
  53. 245 rem *clear screen & explain stuff *
  54. 250 (NULL):print" during this demo you can move to the"
  55. 260 print" next screen by pressing [158]space.[153]":(NULL)1
  56. 270 print" the flashing border on the last screen"
  57. 280 print" was created with the paint[153] command, by  the way.":(NULL)1
  58. 290 print" note the way the screen was restored    behind the windows.":(NULL)1
  59. 300 print" similarly, whole screens can be store[153]d  and recall[153]ed.":gosub100
  60. 305 rem * save screen in buffer zero  *         * and then clear it           *
  61. 310 (NULL)0:(NULL):print" let's demonstrate...":gosub100
  62. 315 rem * restore screen...           *
  63. 320 (NULL)0:gosub100
  64. 325 rem * ...and open message window  *
  65. 330 (NULL)7,10:(NULL)4,6,32,3,0,1:(NULL)"now for something different..."
  66. 340 gosub100:(NULL):(NULL)7,13
  67. 345 rem * the sprite commands         *
  68. 350 (NULL):print" first, we'll activate a sprite and"
  69. 360 print" position it with sprite[153] and movspr[153],     respectively."
  70. 370 (NULL)0,170,136:(NULL)0,1,1,0,0,0,0:(NULL)2
  71. 375 rem * link joystick 2 to sprite 0 *         * with a speed of 3           *
  72. 380 (NULL)2,0,3:print" try moving the port two joystick...":(NULL)2
  73. 390 print" the joystick and the sprite are now"
  74. 400 print" link[153]ed - and will continue to be, even  while this demo is going!"
  75. 410 gosub100:(NULL):print" let's make use of this with some new"
  76. 420 print" commands. we'll make a hi-res screen"
  77. 430 print" with bank[153], cset[153], mode[153] & screen[153], erase"
  78. 440 print" it with wipe[153] and then draw on it with"
  79. 450 print" plot[153] and joy[153]. press [158]fire[153] to draw a dot  or erase a drawn dot."
  80. 460 print" you'll probably want to study the demo  program to see how this ";
  81. 470 print"was done. note  that the routine will work much faster"
  82. 472 print" with the many [158]rem[153] statements removed.":gosub100
  83. 475 rem * switch bank to 16384-32767  *         * and video matrix to 23552,  *
  84. 478 rem * with hi-res screen at 24576 *
  85. 480 (NULL)1:(NULL)23552:(NULL)24576
  86. 485 rem * switch on hi-res and clean  *         * up both it & video matrix   *
  87. 490 (NULL)3:(NULL):(NULL)
  88. 495 rem * change sprite to the pointer*         * we set up earlier; shut off *
  89. 498 rem * link & use joy instead      *
  90. 500 poke24568,96:(NULL)0
  91. 505 rem * set up initial coordinates  *
  92. 510 x=170:y=80:(NULL)0,x,y
  93. 515 rem * main drawing loop, using x  *         * and y array set up earlier. *
  94. 518 rem * first, check keyboard for   *         * space (= quit drawing)      *
  95. 520 geta$:ifa$=" "then590
  96. 525 rem * get joy value in j% - if 0  *         * then nothing has happened   *
  97. 530 (NULL)2,j%:ifj%=0then520
  98. 532 rem * j%>0, so mask it with 127   *         * to find direction without   *
  99. 535 rem * fire button; use x/y array  *         * to add new move & make sure *
  100. 538 rem * it is still on the screen   *
  101. 540 j=j%and127:x1=x+x(j):y1=y+y(j):ifx1<24orx1>342thenx1=x
  102. 550 ify1<0ory1>249theny1=y
  103. 555 rem * values are ok, so update x  *         * & y coordinates             *
  104. 560 x=x1:y=y1:(NULL)0,x,y
  105. 562 rem * fire button pressed? if so, *         * reset the point. note that  *
  106. 564 rem * sprite & hi-res coordinates *         * are not the same, so an     *
  107. 566 rem * adjustment must be made!    *         * also, remember to put colon *
  108. 568 rem * between 'then' and a new b+ *         * command.                    *
  109. 570 ifj%>8then:(NULL)2,x-24,y-50
  110. 575 rem * and restart loop...         *
  111. 580 goto520
  112. 585 rem * space was pressed, so exit  *         * loop & normalize screen     *
  113. 590 gosub130:(NULL)0,0:print" what an artist!":(NULL)1
  114. 600 print" now watch the next screen carefully...":gosub100
  115. 605 rem * set up top of split screen: *         * clear it before activating  *
  116. 608 rem * raster & copy lower case    *         * character set to it         *
  117. 610 (NULL)0,15,11,2,3,4,0,0,2,0,2:(NULL):(NULL)2:(NULL)32768:(NULL):(NULL)0:(NULL)1024
  118. 620 (NULL)1,34816
  119. 625 rem * display split screen & show *         * characters in both halves   *
  120. 630 (NULL)12:i=.
  121. 640 poke32808+i,i:poke1544+i,i:i=i+1:geta$:ifa$<>" "andi<256then640
  122. 645 rem * turn off & normalize screen *
  123. 650 (NULL)2:(NULL):gosub130
  124. 660 print" you saw that correctly: [158]two[153] different   character sets on the ";
  125. 670 print"[158]same[153] screen -     with [158]two[153] screen and border colors!":(NULL)3
  126. 680 print" well, not quite the same screen. the"
  127. 690 print" raster[153] commands allow you to easily"
  128. 700 print" use [158]split screens[153], with information     taken from two sources."
  129. 710 (NULL)3:print" remember your hi-res work of art?":gosub100
  130. 715 rem * set up new raster with high *         * resolution top - note order *
  131. 720 (NULL)0,15,11,2,3,4,2,0,1,7,8:(NULL):(NULL)1,13,"neat, huh?[153]"
  132. 730 (NULL)12:gosub100:(NULL):gosub130
  133. 740 print" leaving the realm of graphics for a"
  134. 750 print" moment, here's a less dramatic but      equally useful command..."
  135. 755 rem * wait for space then show    *         * disk directory              *
  136. 760 gosub100:(NULL)7,3:(NULL)
  137. 765 rem * more message windows...     *
  138. 770 (NULL)2,6,36,5,0,1:a$="note the fact that thi