Loading ...
Sorry, an error occurred while loading the content.

Archive of sample programs?

Expand Messages
  • carroll_bible
    Hi, everyone, I discovered BASIC on the TRS 80 when the BASIC Editor was how the machine booted. On DOS boxes I followed it through GW BASIC, but was involved
    Message 1 of 6 , Jul 4, 2010
    • 0 Attachment
      Hi, everyone,
      I discovered BASIC on the TRS 80 when the BASIC Editor was how the machine booted. On DOS boxes I followed it through GW BASIC, but was involved with other things about the time Visual BASIC came along and lost touch with one of the most enjoyable things I've ever done on the computer. Now I have a Mac Book and was delighted to discover Chipmunk BASIC!

      I dug up my old programs to try in CB, but soon discovered very little would port directly. I've looked through many of the links found on the CB home page and found a sample program to roll dice which showed me the format for generating random numbers in CB. Now I need other simple, sample programs that illustrate things such as the LOCATE equivalent, or how to place things in the Graphics Window.

      I did find the resources from the Middle School, etc. and will dig through them if necessary. I joined this forum in hopes that the Database link there on the left of the screen might be chocked full to the cheeks with such programs, but haven't found such.

      Does anyone know of such a resource that shows simple examples of usage of principle commands in CB?
    • griffin239
      ... This would be useful resource. The Files section would most likely be the place for such a thing as the Database on yahoo groups is, well, basically a
      Message 2 of 6 , Jul 5, 2010
      • 0 Attachment
        --- In chipmunkbasicforum@yahoogroups.com, "carroll_bible" <carroll_bible@...> wrote:
        > Does anyone know of such a resource that shows simple examples of usage of principle commands in CB?

        This would be useful resource. The "Files" section would most likely be the place for such a thing as the Database on yahoo groups is, well, basically a very crappy spreadsheet thats tedious to use.

        If you are on some kind of UNIX system bas 2.1 supports the LOCATE command and a couple of other neat old school BASIC stuff.
        http://www.moria.de/~michael/bas/

        In CB on the mac its gotoxy x,y for moving the cursor inside the editor window.

        For the graphics window (mac or windows) its like so:
        5 x=10: y=10: s$="Hello"
        10 graphics moveto x,y
        15 graphics text s$

        These TRS-80 emulators might help you with your ancient programs (how'd you retrieve those anyway, for sure they were on 5 inch floppies!)
        http://www.vavasour.ca/jeff/trs80.html

        Maybe easiest to post the group a problem so users can point to a solution.
        I don't use CB much until I get an email from the group and say "Aha! A problem to solve!"

        Here's a simple program that only uses the editor window (as I often use Mac OS Terminal window with ancient Mattel Aquarius font for reliving the 80's). The program is adapted from a Timex/Sinclair book of games. It draws and stores a 'road' in an array.

        5 rd$=" ": REM empty road area
        10 dim road$(256)
        11 roaddepth =0
        20 for e = 1 to 256 : road$(e) = chr$(32) : next e

        100 for i = 1 to 8
        110 ri=2*rnd(1)-1
        105 curves=8*rnd(1)+1
        120 for rdrp=1 to curves
        200 n = n + ri
        220 if n < 4 then n=8+(ri*-1)
        300 for lr=1 to n: lrd$=lrd$+chr$(255): next lr
        350 tr$=lrd$+rd$+rd$
        400 for rr=1 to 36-len(tr$): rrd$=rrd$+chr$(255) : next rr
        450 roaddepth = roaddepth+1
        500 Road$(roaddepth) = tr$ + rrd$
        700 lrd$="":rrd$=""
        800 next rdrp
        950 ri=2*rnd(1)-1
        1000 next i

        1200 for i = 1 to roaddepth: print Road$(i);" ";i: next i

        REM Mr Bill
      • Bryan McDonald
        Here is some basic code from some programs I wrote for a four part basic tutorial I posted on YouTube (in HD): http://www.youtube.com/watch?v=MXRHt3R_9so
        Message 3 of 6 , Jul 5, 2010
        • 0 Attachment
          Here is some basic code from some programs I wrote for a four part
          basic tutorial I posted on YouTube (in HD):
          http://www.youtube.com/watch?v=MXRHt3R_9so
          http://www.youtube.com/watch?v=mwDxnMBsUGQ
          http://www.youtube.com/watch?v=h8L3oJzTPQE
          http://www.youtube.com/watch?v=XU_EG5sBxG4

          random colors.bas
          10 graphics window 600,600
          20 pset rnd(800),rnd(800)
          30 graphics color rnd(100),rnd(100),rnd(100)
          40 goto 20

          pascal triangle.bas
          10 dim a(30) : dim b(30) : row = 1 : a(1) = 1
          20 while row < 20
          30 for i = 1 to row
          40 b(i) = a(i)+a(i-1) : print b(i);" ";
          50 next
          60 for i = 1 to row
          70 a(i) = b(i)
          80 next
          90 row = row+1 : print
          100 wend

          color bounce.bas
          10 graphics 0
          20 graphics window 600,600
          30 dx1 = 3 : dy1 = 4 : dx2 = 5 : dy2 = 6 : dx3 = 7 : dy3 = 8
          40 for j = 1 to 400
          50 x1 = x1+dx1 : x2 = x2+dx2 : x3 = x3+dx3
          60 y1 = y1+dy1 : y2 = y2+dy2 : y3 = y3+dy3
          70 if x1 > 600 or x1 < 0 then dx1 = -dx1
          80 if x2 > 600 or x2 < 0 then dx2 = -dx2
          90 if x3 > 600 or x3 < 0 then dx3 = -dx3
          100 if y1 > 600 or y1 < 0 then dy1 = -dy1
          110 if y2 > 600 or y2 < 0 then dy2 = -dy2
          120 if y3 > 600 or y3 < 0 then dy3 = -dy3
          122 graphics color rnd(100),rnd(100),rnd(100)
          130 graphics lineto x1,y1 : graphics lineto x2,y2 : graphics lineto
          x3,y3 : graphics lineto x1,y1
          140 for i = 1 to 1000000 : next
          150 next
          160 cls : goto 40

          bounce2.bas
          10 graphics 0
          20 graphics window 600,600
          30 dx1 = 3 : dy1 = 4 : dx2 = 5 : dy2 = 6 : dx3 = 7 : dy3 = 8
          40 for j = 1 to 400
          50 x1 = x1+dx1 : x2 = x2+dx2 : x3 = x3+dx3
          60 y1 = y1+dy1 : y2 = y2+dy2 : y3 = y3+dy3
          70 if x1 > 600 or x1 < 0 then dx1 = -dx1
          80 if x2 > 600 or x2 < 0 then dx2 = -dx2
          90 if x3 > 600 or x3 < 0 then dx3 = -dx3
          100 if y1 > 600 or y1 < 0 then dy1 = -dy1
          110 if y2 > 600 or y2 < 0 then dy2 = -dy2
          120 if y3 > 600 or y3 < 0 then dy3 = -dy3
          130 graphics lineto x1,y1 : graphics lineto x2,y2 : graphics lineto
          x3,y3 : graphics lineto x1,y1
          140 for i = 1 to 1000000 : next
          150 next
          160 cls : goto 40

          bouncing pixel with friction.bas
          10 graphics 0
          20 graphics window 604,604
          30 a = 0.1
          40 dx1 = 3
          50 dy1 = dy1+a
          60 x1 = x1+dx1
          70 y1 = y1+dy1
          80 if x1 > 600 or x1 < 0 then dx1 = -dx1
          90 if y1 > 600 then dy1 = -dy1 : y1 = 600 : a = a+1.000000E-04
          92 if y1 < 0 then dy1 = -dy1 : y1 = 0
          100 graphics pset x1,y1
          110 for i = 1 to 10000 : next
          120 goto 50

          bouncing pixel slow.bas
          10 graphics 0
          20 graphics window 600,600
          30 a = 0.1
          40 dx1 = 3
          50 dy1 = dy1+a
          60 x1 = x1+dx1
          70 y1 = y1+dy1
          80 if x1 > 600 or x1 < 0 then dx1 = -dx1
          90 if y1 > 600 then dy1 = -dy1 : y1 = 600
          92 if y1 < 0 then dy1 = -dy1 : y1 = 0
          100 graphics pset x1,y1
          110 for i = 1 to 1000000 : next
          120 goto 50

          Here are some really cool basic tricks I collected from the forum:
          Hi, Richard.

          I tried the following and it worked:

          filename$="/Users/jeff/Desktop/Allofme.MP3"
          gosub Play(filename$)
          end

          sub Play(filename$,dothis$)
          sys("afplay " + filename$)
          end sub


          The following simplified version also worked:

          sys("afplay /Users/jeff/Desktop/Allofme.MP3")
          end


          I found that I could not interrupt play in Chipmunk BASIC. To stop
          play before
          the end of file I used Activity Monitor to quit the process "afplay".

          ....Jeff


          Re: Sprite Images

          You can now do sprites directly from jpg files.
          put the jpg in the same folder as your saved program, and use this code:

          sprite 0,1,"mypic.jpg",50,350,128

          which is:

          sprite 0,(sprite number),"(jpg name.jpg)",(x pos),(y pos),(id you give
          to this
          particular picture)


          Each picture you use needs a different ID.

          I don't know it you still need help, but I just noticed your posts.

          10 OPEN "COM1:9600,n,8,1,CS,DS,RS" AS#1 ;opens and configures serial
          file
          20 PRINT#1, "CPA11111110" ;configures PA0 as output
          30 REM FORCES
          40 PRINT#1, "RESPA0" ;resets PA0
          50 REM FORCES
          50 PRINT#1, "RA0" ;sends RA0 command
          60 INPUT#1, AN0 ;receives data into variable AN0
          70 IF AN0>50% then PRINT#1, "SETPA0"' ;sends SETPA0 command if
          80 GOTO 50 AN0>50% and returns to line 50
          90 PRINT#1, "RESPA0" : GOTO 50 ;resets PA0 and returns to 50

          some time back Ron
          Nicholoson got me into business with versions 3.6.0 or higher running
          under Mac OSX. His procedure was to first run a little loop to find
          what devices are connected to the USB bus:

          for n=1 to 6:print macfunction("serialpath",n):next

          In my case, I have available two Keyspan USB/RS232 adapters, a single-
          port device Model USA-19HS, and a 2-port device Model USA-28X B.
          Both I believe to be used fairly widely, and Keyspan supplies just a
          single set of driver code to work with either unit. With just the
          single-port adapter connected to my Mac Mini, running the above code
          yields:

          /dev/cu.modem
          /dev/cu.KeySerial1
          /dev/cu.USA19H3B13P1.1

          Then if I run the following two-line program, using info gleaned from
          the above, I get 123456 sent out from the TXD line of the RS232
          connector.

          10 open "COM1:/dev/cu.KeySerial1:9600,N,8,1" for output as #1
          20 print #1,"123456;

          I'm not sure why there are the two identifiers for the single Keyspan
          adapter but either will work when plugged into line 10.

          Similarly, if I plug in just the 2-port adapter, and run the for/next
          loop I get:

          /dev/cu.modem
          /dev/cu.KeySerial1
          /dev/cu.USA28X3b13P1.1
          /dev/cu.USA28X3b13P2.2

          Using info from the last line above I get output from Port 2 of the
          adapter, and using either of the middle two identifiers will output
          from Port 1.

          ===========

          What does macfunction("serialpath",n) return for n = 1 thru 4?
          Or ls -l the /dev directory to see what new device appeared after
          plugging in your serial device.
          One of those strings is probably what to use between the two ":" in
          the Chipmunk Basic open COM1 command.

          160 config$ = "COM1:/dev/tty.usbmodem1511:2400,N,8,1"
          > 200 open config$ for input as #2
          > 220 open config$ for output as #1
          > 240 k = 0
          > 260 while k <> 3 : rem control-C to exit
          > 280 a$ = input$(1,2)
          > 320 print a$;
          > 340 k$ = inkey$ : k = asc(k$)
          > 360 if (k > 3) then fputbyte k,#1
          > 380 wend
          > 420 close #2 : close #1
          > 440 print : print "done"
          > 460 end

          ============

          Try using the terminal console app ( ls -ltr /dev ) to find out what
          devices are
          added to your /dev directory after you plug in your USB adapter.

          - Ron

          --- In chipmunkbasicforum@yahoogroups.com, "Bart Hibbs"
          <bart_hibbs@y...>
          wrote:
          > I have a USB to serial adaptor. How do I get Chipmunk Basic to use
          it?
          > I found this in some of the documentation:
          >
          > open "COM1:/dev/cu.modem:1200,N,8,1" for output as #1
          > open "COM1:/dev/cu.modem:1200,N,8,1" for input as #2

          ==============

          It also turns out that
          the code fragment in the mannula works:

          20 sp1$ = macfunction("serialpath",1) : print sp1$
          30 if sp1$ = "" then stop
          40 sp2$ = macfunction("serialpath",2) : print sp2$
          50 config$ = "COM1:"+sp2$+":9600,N,8,1"
          60 print config$ : print
          70 open config$ for input as #2
          80 open config$ for output as #1

          sp2$ gets the port name for the keyspan adaptor.

          ===============
          1 graphics WINDOW 600, 600
          10 pset rnd(800),rnd(800)
          30 graphics color rnd(100),rnd(100),rnd(100)
          40 goto 10

          graphics 0
          graphics cls

          ===============


          Thanks,
          Bryan McDonald
          Senior Product Design Manager
          Apple Inc.



          On Jul 4, 2010, at 6:26 PM, carroll_bible wrote:

          > Hi, everyone,
          > I discovered BASIC on the TRS 80 when the BASIC Editor was how the
          > machine booted. On DOS boxes I followed it through GW BASIC, but was
          > involved with other things about the time Visual BASIC came along
          > and lost touch with one of the most enjoyable things I've ever done
          > on the computer. Now I have a Mac Book and was delighted to discover
          > Chipmunk BASIC!
          >
          > I dug up my old programs to try in CB, but soon discovered very
          > little would port directly. I've looked through many of the links
          > found on the CB home page and found a sample program to roll dice
          > which showed me the format for generating random numbers in CB. Now
          > I need other simple, sample programs that illustrate things such as
          > the LOCATE equivalent, or how to place things in the Graphics Window.
          >
          > I did find the resources from the Middle School, etc. and will dig
          > through them if necessary. I joined this forum in hopes that the
          > Database link there on the left of the screen might be chocked full
          > to the cheeks with such programs, but haven't found such.
          >
          > Does anyone know of such a resource that shows simple examples of
          > usage of principle commands in CB?
          >
          >
          >



          [Non-text portions of this message have been removed]
        • carroll_bible
          Byran, Thanks for all the good material. Here is the Bingo my eye immediately picked out: sprite 0,1, mypic.jpg ,50,350,128 I was wondering how to create a
          Message 4 of 6 , Jul 6, 2010
          • 0 Attachment
            Byran,
            Thanks for all the good material.

            Here is the "Bingo" my eye immediately picked out:

            sprite 0,1,"mypic.jpg",50,350,128

            I was wondering how to create a sprite (something I've never used before) and then get it into my CB program. It will the first thing I play with. Let's see...since I use Corel Draw, I'll draw something, convert to a bitmap and then save as a jpg. Move it to the right directory bring into a random foot race with the Spider (Sprite 1) that seems to be built into CB. I'll call my sprite #2.
            Carroll
          • carroll_bible
            Hey, bill, I appreciate your input. The legacy programs I have were mostly created in DOS on GW Basic (or whatever version I last used in the 80 s). So they
            Message 5 of 6 , Jul 6, 2010
            • 0 Attachment
              Hey, bill,
              I appreciate your input. The legacy programs I have were mostly created in DOS on GW Basic (or whatever version I last used in the 80's). So they were on 3" floppies. I scrambled to get everything onto the hard drive before diskette drives completely disappeared. These days, of course, the little flash memory chips (is that what they are called?) make life easy. Thank God the Mac accepted all of my DOS (Windows for DOS) files with no fuss!
              You realize, of course, that had the Founding Fathers written the Constitution on a computer, by this time we would have no way to access it. Well, OK, they would have made an exception for the Constitution, but 99% of what is created today will be lost to future historians, in say 100 years.
              your comment about using the Editor Window intrigued me. Is there a simple explanation of the difference between the Graphics Window and the Editor?
              Carroll
            • griffin239
              ... Not sure if its the same on Windows but I ll assume it is. The editor or Console is basically where you stick your code, some basic text output can be
              Message 6 of 6 , Jul 7, 2010
              • 0 Attachment
                --- In chipmunkbasicforum@yahoogroups.com, "carroll_bible" <carroll_bible@...> wrote:
                > your comment about using the Editor Window intrigued me. Is there a simple explanation of the difference between the Graphics Window and the Editor?
                > Carroll
                >

                Not sure if its the same on Windows but I'll assume it is.
                The editor or "Console" is basically where you stick your code, some basic text output can be viewed from your running program in the editor window, like when using inkey$, input, and print commands.
                The output or "Graphics" window handles things like the circle command, colors and sprites.

                Hrmmm looking through the docs, even in the windows download it has circle under Mac only commands. Looks like everything didn't make it to the Windows port, just tried it under emulation and graphics circle and rect didn't produce a result.

                Mr Bill
              Your message has been successfully submitted and would be delivered to recipients shortly.