home *** CD-ROM | disk | FTP | other *** search
- 1 rem ********************************* * *
- 2 rem * b+ demo program by j. mattson * * - 05/20/89 - *
- 3 rem * this program has been created * * to help you absorb the many *
- 4 rem * new commands. study the rems * * & programming techniques and *
- 5 rem * you will be well on your way * * mastering b+! *
- 6 rem * * *********************************
- 7 rem
- 8 rem * load b+ and set things up *
- 10 ifa=.thena=1:load"b+",8,1
- 15 rem *protect hi-res area from basic*
- 20 poke52,88:poke56,88:clr:printchr$(142);
- 25 rem * sprite pointer for later use *
- 30 fori=.to63:poke22528+i,.:next:fori=.to5:readj:poke22528+i*3,j:next
- 40 data 240,224,176,24,12,4
- 42 rem * quick ml routine allows safe * * return to loadstar - 'quit' *
- 45 rem * resets computer, so should * * not be used with 'chained' *
- 48 rem * programs (like loadstar) *
- 50 fori=22592to22633:readj:pokei,j:next:data120,160,0,162,0,185,94,88,153,4,3
- 60 data200,192,6,144,245,185,94,88,157,20,3,200,232,224,6,144,244,88,96
- 70 data124,165,26,167,228,167,49,234,102,254,1,254
- 75 rem * set up x & y equivalents for * * joy command directions, then *
- 78 rem * jump to main program to skip * * various subroutines *
- 80 fori=.to8:readx(i),y(i):next:goto140
- 90 data 0,0,0,-1,1,-1,1,0,1,1,0,1,-1,1,-1,0,-1,-1
- 95 rem * frequently used subroutines * * first, wait for space bar *
- 100 poke198,.: rem clear keyboard
- 110 geta$:ifa$<>" "then110
- 120 return
- 125 rem * normalize screen values *
- 130 (NULL)0:(NULL)1024:(NULL)4096:(NULL)0:(NULL)0,15:(NULL)1,11:(NULL)7,13:(NULL):return
- 135 rem * activate b+ and get rolling *
- 140 sys49152
- 145 rem * pause to show title screen * * then set up first window - *
- 150 (NULL)1:(NULL)2,6,27,7,0,1:(NULL)7,13:a$="this opening screen tells"
- 155 rem * note that string variables * * can be added together when *
- 158 rem * the desired string is too * * long for a basic line *
- 160 a$=a$+"you that b+ is installed.of course, you'll want to"
- 170 a$=a$+"clear it afterwards with the cls[153] command."
- 172 rem * color codes may be embedded * * to change the color of text *
- 175 rem * - be careful to format the * * string to fit the window - *
- 178 rem * counting color characters! * * now open the window... *
- 180 (NULL)a$
- 185 rem * pause and repeat procedure * * for the next window *
- 190 (NULL)2:a$="^ this is an example ofthe window commands, bythe way."
- 200 (NULL)13,12,25,5,0,1:(NULL)a$
- 205 rem * now a 'press space' message * * with a 'dot' border... *
- 210 (NULL)2:(NULL)7,10:(NULL)11,16,18,3,81,2:(NULL)" > press space <":i=.
- 215 rem * ...and jazz it up with the * * paint command *
- 220 geta$:ifa$<>" "theni=(i+1)and15:(NULL)81,i:goto220
- 225 rem * close up the windows slowly * * to make effect obvious *
- 230 fori=1to3:(NULL):forj=1to200:nextj,i:(NULL)7,13:(NULL)16,11,8,3,0,1
- 240 (NULL)"wheee!":fori=1to400:next:(NULL):(NULL)1
- 245 rem *clear screen & explain stuff *
- 250 (NULL):print" during this demo you can move to the"
- 260 print" next screen by pressing [158]space.[153]":(NULL)1
- 270 print" the flashing border on the last screen"
- 280 print" was created with the paint[153] command, by the way.":(NULL)1
- 290 print" note the way the screen was restored behind the windows.":(NULL)1
- 300 print" similarly, whole screens can be store[153]d and recall[153]ed.":gosub100
- 305 rem * save screen in buffer zero * * and then clear it *
- 310 (NULL)0:(NULL):print" let's demonstrate...":gosub100
- 315 rem * restore screen... *
- 320 (NULL)0:gosub100
- 325 rem * ...and open message window *
- 330 (NULL)7,10:(NULL)4,6,32,3,0,1:(NULL)"now for something different..."
- 340 gosub100:(NULL):(NULL)7,13
- 345 rem * the sprite commands *
- 350 (NULL):print" first, we'll activate a sprite and"
- 360 print" position it with sprite[153] and movspr[153], respectively."
- 370 (NULL)0,170,136:(NULL)0,1,1,0,0,0,0:(NULL)2
- 375 rem * link joystick 2 to sprite 0 * * with a speed of 3 *
- 380 (NULL)2,0,3:print" try moving the port two joystick...":(NULL)2
- 390 print" the joystick and the sprite are now"
- 400 print" link[153]ed - and will continue to be, even while this demo is going!"
- 410 gosub100:(NULL):print" let's make use of this with some new"
- 420 print" commands. we'll make a hi-res screen"
- 430 print" with bank[153], cset[153], mode[153] & screen[153], erase"
- 440 print" it with wipe[153] and then draw on it with"
- 450 print" plot[153] and joy[153]. press [158]fire[153] to draw a dot or erase a drawn dot."
- 460 print" you'll probably want to study the demo program to see how this ";
- 470 print"was done. note that the routine will work much faster"
- 472 print" with the many [158]rem[153] statements removed.":gosub100
- 475 rem * switch bank to 16384-32767 * * and video matrix to 23552, *
- 478 rem * with hi-res screen at 24576 *
- 480 (NULL)1:(NULL)23552:(NULL)24576
- 485 rem * switch on hi-res and clean * * up both it & video matrix *
- 490 (NULL)3:(NULL):(NULL)
- 495 rem * change sprite to the pointer* * we set up earlier; shut off *
- 498 rem * link & use joy instead *
- 500 poke24568,96:(NULL)0
- 505 rem * set up initial coordinates *
- 510 x=170:y=80:(NULL)0,x,y
- 515 rem * main drawing loop, using x * * and y array set up earlier. *
- 518 rem * first, check keyboard for * * space (= quit drawing) *
- 520 geta$:ifa$=" "then590
- 525 rem * get joy value in j% - if 0 * * then nothing has happened *
- 530 (NULL)2,j%:ifj%=0then520
- 532 rem * j%>0, so mask it with 127 * * to find direction without *
- 535 rem * fire button; use x/y array * * to add new move & make sure *
- 538 rem * it is still on the screen *
- 540 j=j%and127:x1=x+x(j):y1=y+y(j):ifx1<24orx1>342thenx1=x
- 550 ify1<0ory1>249theny1=y
- 555 rem * values are ok, so update x * * & y coordinates *
- 560 x=x1:y=y1:(NULL)0,x,y
- 562 rem * fire button pressed? if so, * * reset the point. note that *
- 564 rem * sprite & hi-res coordinates * * are not the same, so an *
- 566 rem * adjustment must be made! * * also, remember to put colon *
- 568 rem * between 'then' and a new b+ * * command. *
- 570 ifj%>8then:(NULL)2,x-24,y-50
- 575 rem * and restart loop... *
- 580 goto520
- 585 rem * space was pressed, so exit * * loop & normalize screen *
- 590 gosub130:(NULL)0,0:print" what an artist!":(NULL)1
- 600 print" now watch the next screen carefully...":gosub100
- 605 rem * set up top of split screen: * * clear it before activating *
- 608 rem * raster & copy lower case * * character set to it *
- 610 (NULL)0,15,11,2,3,4,0,0,2,0,2:(NULL):(NULL)2:(NULL)32768:(NULL):(NULL)0:(NULL)1024
- 620 (NULL)1,34816
- 625 rem * display split screen & show * * characters in both halves *
- 630 (NULL)12:i=.
- 640 poke32808+i,i:poke1544+i,i:i=i+1:geta$:ifa$<>" "andi<256then640
- 645 rem * turn off & normalize screen *
- 650 (NULL)2:(NULL):gosub130
- 660 print" you saw that correctly: [158]two[153] different character sets on the ";
- 670 print"[158]same[153] screen - with [158]two[153] screen and border colors!":(NULL)3
- 680 print" well, not quite the same screen. the"
- 690 print" raster[153] commands allow you to easily"
- 700 print" use [158]split screens[153], with information taken from two sources."
- 710 (NULL)3:print" remember your hi-res work of art?":gosub100
- 715 rem * set up new raster with high * * resolution top - note order *
- 720 (NULL)0,15,11,2,3,4,2,0,1,7,8:(NULL):(NULL)1,13,"neat, huh?[153]"
- 730 (NULL)12:gosub100:(NULL):gosub130
- 740 print" leaving the realm of graphics for a"
- 750 print" moment, here's a less dramatic but equally useful command..."
- 755 rem * wait for space then show * * disk directory *
- 760 gosub100:(NULL)7,3:(NULL)
- 765 rem * more message windows... *
- 770 (NULL)2,6,36,5,0,1:a$="note the fact that this program isstill running"
- 780 a$=a$+" quite nicely after issuing a directory[153] command!":(NULL)7,13
- 790 (NULL)a$:gosub100:(NULL):a$="now let's clean up in an unusualway with "
- 800 a$=a$+"the lclear command...":(NULL)3,11,34,4,0,1:(NULL)a$:gosub100
- 810 (NULL):(NULL)7,13:(NULL)0
- 815 rem * use lclear to erase lines * * in a specific order *
- 820 fori=.to12:(NULL)12-i,12+i:forj=1to25:nextj,i
- 830 (NULL):print" let's bring it back for more special"
- 840 print" effects, using dice[153] and fcol[153]...":gosub100
- 845 rem * recall screen, then fill it * * with random colors *
- 850 (NULL)0
- 860 (NULL)16,d%:(NULL)d%-1:geta$:ifa$<>" "then860
- 870 (NULL):print" there are even more new commands at"
- 880 print" your disposal which can't be visibly demonstrated here."
- 890 print" the best way to learn about them is to"
- 900 print" try them out yourself.":gosub100:(NULL):(NULL)0,0:(NULL)1,0:(NULL)7,1
- 905 a$=" b+"
- 910 fori=.to7:(NULL)16,i,8,5,0,i+1:(NULL)a$:(NULL)16,20-i,8,5,0,i+1:(NULL)a$
- 920 next:a$=" b+: advanced basic ":(NULL)9,10,22,5,0,15
- 930 a$=a$+" [153]by j. mattson":(NULL)a$:gosub100:(NULL)
- 940 (NULL)8,11,24,3,0,1:(NULL)"q)uit or w)atch again?"
- 950 geta$:ifa$<>"q"anda$<>"w"then950
- 960 fori=.to16:(NULL):forj=1to5:nextj,i:ifa$="w"then140
- 970 rem * deactivate b+ & clean up * * normally the 'quit' command *
- 980 rem * would do all of this, by * * resetting the computer *
- 1000 sys22592
- 1010 poke53280,14:poke53281,6:printchr$(142)"[154][147]";:poke52,160:poke56,160:clr
- 1012 rem
- 1015 rem **return to loadstar**********
- 1018 rem
- 1020 open15,8,15,"r0:b+ menu=b+ menu":input#15,er:close15
- 1030 ifer=63then1070
- 1040 print"[147]":end
- 1050 geta$:ifa$<>chr$(13)then1050
- 1060 goto1020
- 1070 print"[147]returning to b+ menu... ":print"load"chr$(34);
- 1080 print"b+ menu"chr$(34)",8":print"run[145][145][145][145][145][145][145][145]":poke631,13
- 1090 poke632,13:poke633,13:poke198,3:new
-