Page 1 of 4

A test program?

Posted: Tue Jun 19, 2018 4:10 am
by floobydust
I've recently ported the EhBasic code (2.22p3) over to my C02 Pocket SBC board and have it working, albeit I need to integrate it into the monitor code, get the Xmodem load/save working, etc. However, I was wondering if anyone has some sample BASIC program that can be used to test EhBasic itself. I've never been much of a BASIC programmer but am looking for something that I can use as a loop test for the system.

Re: A test program?

Posted: Tue Jun 19, 2018 5:43 am
by barrym95838
What kind of output device is available? If it's a text terminal, how about:

Code: Select all

5 DEF FNA(Z)=30*EXP(-Z*Z/100)
100 PRINT
110 FOR X=-30 TO 30 STEP 1.5
120 L=0
130 Y1=5*INT(SQR(900-X*X)/5)
140 FOR Y=Y1 TO -Y1 STEP -5
150 Z=INT(25+FNA(SQR(X*X+Y*Y))-.7*Y)
160 IF Z<=L THEN 190
170 L=Z
180 PRINT TAB(Z)"*";
190 NEXT Y
200 PRINT
210 NEXT X
300 END
(credit: 101 BASIC Computer Games, D.E.C., 1975)

Mike B.

Re: A test program?

Posted: Tue Jun 19, 2018 7:12 am
by BigEd
That's nice! I pasted it over serial into a Beeb and it ran unchanged - hidden line removal on the cheap!

Re: A test program?

Posted: Tue Jun 19, 2018 6:31 pm
by floobydust
barrym95838 wrote:
What kind of output device is available? If it's a text terminal, how about:

Code: Select all

5 DEF FNA(Z)=30*EXP(-Z*Z/100)
100 PRINT
110 FOR X=-30 TO 30 STEP 1.5
120 L=0
130 Y1=5*INT(SQR(900-X*X)/5)
140 FOR Y=Y1 TO -Y1 STEP -5
150 Z=INT(25+FNA(SQR(X*X+Y*Y))-.7*Y)
160 IF Z<=L THEN 190
170 L=Z
180 PRINT TAB(Z)"*";
190 NEXT Y
200 PRINT
210 NEXT X
300 END
(credit: 101 BASIC Computer Games, D.E.C., 1975)

Mike B.
Thanks Mike,

I just did a copy/paste directly into the serial port terminal window and it entered the entire program in a few seconds 8)
I've been using a native terminal app for OSX called Serial which I prefer over ExtraPutty (which is windoze only). I also added a few extra lines to print a loop count. It seems to work okay.... guess letting it run for an extended period of time will tell. The output is all asterisk characters oddly placed on the screen but each loop of the main program has the same result, so I guess it's correct.

I have had a few errant crashes when either entering a line into EhBasic or trying to RUN the program. It's intermittent so I've not attempted to track it down just yet. I still need to finish the Xmodem upload code for the Monitor, then integrate that into EhBasic's load/save functions, plus integrate launching EhBasic into the Monitor CTRL-? commands.

So far, doing a warm start doesn't work, as you can have a program there which will LIST but won't RUN... so some work to do yet.

Re: A test program?

Posted: Tue Jun 19, 2018 6:33 pm
by BigEd
You could try TAB(Z/2) if your screen isn't very wide. On a 40 col mode it didn't look very impressive but on an 80 col mode I could see the point!

Re: A test program?

Posted: Tue Jun 19, 2018 6:41 pm
by floobydust
BigEd wrote:
You could try TAB(Z/2) if your screen isn't very wide. On a 40 col mode it didn't look very impressive but on an 80 col mode I could see the point!
Hi Ed,

Actually, I am using an 80 column wide screen... just not sure what the output should be (meaning I could have an issue with EhBasic). Here's what the output looks like:

Code: Select all

                         *
                     *                 *                *
                  *                *                 *                *                               *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
           *  *                 *                *                 *                *                               *                              *                               *
           *  *                 *                 *                *                 *                              *                              *                               *
           *  *                 *                 *                 *                *                              *                              *                               *
       *   *  *                 *                  *                *                 *                             *                              *                               *                              *
       *   *  *                  *                 *                  *                             *                              *                             *                               *                              *
       *   *   *                 *                   *                 *                              *                            *                              *                              *                              *
       *   *   *                  *                    *                  *                             *                             *                              *                              *
       *   *   *                   *                     *                                *                             *                              *                              *
       *   *   *                    *                      *                                  *                            *                              *
       *   *    *                     *                       *                                   *
       *   *    *                      *                         *                                   *
       *   *     *                       *                          *                                    *
       *   *     *                        *                                         *                                                   *
       *   *     *                        *                                           *                                                   *
    *  *   *     *                         *                                          *                                                    *
       *   *     *                        *                                           *                                                   *
       *   *     *                        *                                         *                                                   *
       *   *     *                       *                          *                                    *
       *   *    *                      *                         *                                   *
       *   *    *                     *                       *                                   *
       *   *   *                    *                      *                                  *                            *                              *
       *   *   *                   *                     *                                *                             *                              *                              *
       *   *   *                  *                    *                  *                             *                             *                              *                              *
       *   *   *                 *                   *                 *                              *                            *                              *                              *                              *
       *   *  *                  *                 *                  *                             *                              *                             *                               *                              *
       *   *  *                 *                  *                *                 *                             *                              *                               *                              *
           *  *                 *                 *                 *                *                              *                              *                               *
           *  *                 *                 *                *                 *                              *                              *                               *
           *  *                 *                *                 *                *                               *                              *                               *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
                  *                *                 *                *                               *
                     *                 *                *
                         *
I think I have a hint what it's trying to do.... but, not quite correct... hmmmmm...

Re: A test program?

Posted: Tue Jun 19, 2018 6:44 pm
by BigEd
It should look like some overlapping peaks... try TAB(Z/4) or TAB(Z/10) and you'll get the idea, then perhaps you can figure out what's happening. PRINT "X";TAB(4);"X" should print 4 spaces between the Xs, I think.

Re: A test program?

Posted: Tue Jun 19, 2018 6:53 pm
by floobydust
Okay, I changed like 180 to:
PRINT TAB(Z/4)"*";
and it printed this:

Code: Select all

      *
     ***
    *****
   *******
   *******
   *******
  *********
  *********
  *********
 ***********
 ***** ******
 **** *******
 *** ** *****
 *** * *****
 *** * * ***
 ** * * * *
 ** * *  * *
 ** * *   * *
 ** *  *  *  *
 ** *  *   * *
 ****  *   * *
 ** *  *   * *
 ** *  *  *  *
 ** * *   * *
 ** * *  * *
 ** * * * *
 *** * * ***
 *** * *****
 *** ** *****
 **** *******
 ***** ******
 ***********
  *********
  *********
  *********
   *******
   *******
   *******
    *****
     ***
      *
Looking at the manual for EhBasic, using the SPC function might be a better option... same output using SPC(Z/4)"*";

Code: Select all

      *
     *      *       *
    *     *      *       *        *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
 *  *   *    *     *      *       *        *        *         *          *
 *  *   *    *     *       *       *        *        *         *          *
 *  *   *    *      *       *        *        *         *         *          *
 *  *   *     *      *        *        *         *         *          *
 *  *   *     *       *        *         *         *          *
 *  *   *     *       *         *         *          *
 *  *    *      *        *          *
 *  *    *      *         *           *
 *  *    *      *          *            *
 *  *    *       *          *             *
 *  *    *       *           *             *
 * *  *    *       *           *             *
 *  *    *       *           *             *
 *  *    *       *          *             *
 *  *    *      *          *            *
 *  *    *      *         *           *
 *  *    *      *        *          *
 *  *   *     *       *         *         *          *
 *  *   *     *       *        *         *         *          *
 *  *   *     *      *        *        *         *         *          *
 *  *   *    *      *       *        *        *         *         *          *
 *  *   *    *     *       *       *        *        *         *          *
 *  *   *    *     *      *       *        *        *         *          *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
    *     *      *       *        *
     *      *       *
      *

Re: A test program?

Posted: Tue Jun 19, 2018 7:28 pm
by BigEd
Ah, I wonder if your Basic is not tabbing to a specific column but tabbing by some number of spaces... so everything got stretched out.

Re: A test program?

Posted: Tue Jun 19, 2018 7:57 pm
by barrym95838
Yeah, SPC(Z) isn't the correct choice for this case. The TAB(Z) I know is supposed to keep track of the current output column position P and try to space to the requested column Z, but only if it's to the right of the current one. It'll output (Z-P) spaces, but no "negative" spaces.

Mike B.

Re: A test program?

Posted: Tue Jun 19, 2018 8:03 pm
by BigEd
Here's a snapshot of the Beeb's output for
PRINT "X"TAB(4)"X"TAB(8)"X"
- you'll see the Xs are evenly spaced (and there are only three spaces printed between each pair)
TAB BBC Basic.png

Re: A test program?

Posted: Tue Jun 19, 2018 8:26 pm
by barrym95838
AppleSoft:
a2tab.JPG
Hmm ... it looks like TAB() treats the leftmost column as column 1, and POS() treats it as column 0.

Mike B.

Re: A test program?

Posted: Tue Jun 19, 2018 8:42 pm
by BigEd
So SPC(Z-POS(0)) instead of TAB(Z) should do the trick?

edit: in BBC Basic, you'd use POS instead of POS(0)

Re: A test program?

Posted: Tue Jun 19, 2018 8:47 pm
by barrym95838
That or SPC(Z-POS(0)-1) with a risk of crashing if the argument winds up negative.

Mike B.

Re: A test program?

Posted: Wed Jun 20, 2018 4:48 am
by BillO
How about this?

It's been with me so long I don't know who to credit, but the only thing I did was port it to EhBASIC.

Code: Select all

10 MX=20
20 LET C$=" .,'~!^:;[/<&?oxOX#  "
30 FOR Y=-19 TO 19
40 FOR X=-49 TO 30
50 CR=X/30
70 CI=Y/15
80 ZR = CR
90 ZI = CI
95 CO = 1
100 ZM = ZR*ZR
105 ZN = ZI*ZI
107 ZL = ZM+ZN
110 IF ZL>4 THEN GOTO 170
120 ZJ=ZM-ZN+CR
130 ZI=ZR*ZI*2+CI
140 ZR=ZJ
150 CO=CO+1
160 IF CO<MX THEN GOTO 100
170 PRINT MID$(C$,1+COUNT,1);
180 NEXT X
185 PRINT ""
190 NEXT Y
200 GOTO 10
It should print endless Madelbrot sets.