6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Apr 27, 2024 6:45 am

All times are UTC




Post new topic Reply to topic  [ 53 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
 Post subject: A test program?
PostPosted: Tue Jun 19, 2018 4:10 am 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
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.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 5:43 am 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1926
Location: Sacramento, CA, USA
What kind of output device is available? If it's a text terminal, how about:
Code:
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 7:12 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
That's nice! I pasted it over serial into a Beeb and it ran unchanged - hidden line removal on the cheap!


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 6:31 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
barrym95838 wrote:
What kind of output device is available? If it's a text terminal, how about:
Code:
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.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 6:33 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
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!


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 6:41 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
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:
                         *
                     *                 *                *
                  *                *                 *                *                               *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
           *  *                 *                *                 *                *                               *                              *                               *
           *  *                 *                 *                *                 *                              *                              *                               *
           *  *                 *                 *                 *                *                              *                              *                               *
       *   *  *                 *                  *                *                 *                             *                              *                               *                              *
       *   *  *                  *                 *                  *                             *                              *                             *                               *                              *
       *   *   *                 *                   *                 *                              *                            *                              *                              *                              *
       *   *   *                  *                    *                  *                             *                             *                              *                              *
       *   *   *                   *                     *                                *                             *                              *                              *
       *   *   *                    *                      *                                  *                            *                              *
       *   *    *                     *                       *                                   *
       *   *    *                      *                         *                                   *
       *   *     *                       *                          *                                    *
       *   *     *                        *                                         *                                                   *
       *   *     *                        *                                           *                                                   *
    *  *   *     *                         *                                          *                                                    *
       *   *     *                        *                                           *                                                   *
       *   *     *                        *                                         *                                                   *
       *   *     *                       *                          *                                    *
       *   *    *                      *                         *                                   *
       *   *    *                     *                       *                                   *
       *   *   *                    *                      *                                  *                            *                              *
       *   *   *                   *                     *                                *                             *                              *                              *
       *   *   *                  *                    *                  *                             *                             *                              *                              *
       *   *   *                 *                   *                 *                              *                            *                              *                              *                              *
       *   *  *                  *                 *                  *                             *                              *                             *                               *                              *
       *   *  *                 *                  *                *                 *                             *                              *                               *                              *
           *  *                 *                 *                 *                *                              *                              *                               *
           *  *                 *                 *                *                 *                              *                              *                               *
           *  *                 *                *                 *                *                               *                              *                               *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
              *                 *                *                 *                *                               *                              *
                  *                *                 *                *                               *
                     *                 *                *
                         *


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

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 6:44 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 6:53 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
Okay, I changed like 180 to:
PRINT TAB(Z/4)"*";
and it printed this:

Code:
      *
     ***
    *****
   *******
   *******
   *******
  *********
  *********
  *********
 ***********
 ***** ******
 **** *******
 *** ** *****
 *** * *****
 *** * * ***
 ** * * * *
 ** * *  * *
 ** * *   * *
 ** *  *  *  *
 ** *  *   * *
 ****  *   * *
 ** *  *   * *
 ** *  *  *  *
 ** * *   * *
 ** * *  * *
 ** * * * *
 *** * * ***
 *** * *****
 *** ** *****
 **** *******
 ***** ******
 ***********
  *********
  *********
  *********
   *******
   *******
   *******
    *****
     ***
      *


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

Code:
      *
     *      *       *
    *     *      *       *        *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
 *  *   *    *     *      *       *        *        *         *          *
 *  *   *    *     *       *       *        *        *         *          *
 *  *   *    *      *       *        *        *         *         *          *
 *  *   *     *      *        *        *         *         *          *
 *  *   *     *       *        *         *         *          *
 *  *   *     *       *         *         *          *
 *  *    *      *        *          *
 *  *    *      *         *           *
 *  *    *      *          *            *
 *  *    *       *          *             *
 *  *    *       *           *             *
 * *  *    *       *           *             *
 *  *    *       *           *             *
 *  *    *       *          *             *
 *  *    *      *          *            *
 *  *    *      *         *           *
 *  *    *      *        *          *
 *  *   *     *       *         *         *          *
 *  *   *     *       *        *         *         *          *
 *  *   *     *      *        *        *         *         *          *
 *  *   *    *      *       *        *        *         *         *          *
 *  *   *    *     *       *       *        *        *         *          *
 *  *   *    *     *      *       *        *        *         *          *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
  *   *    *     *      *       *        *        *         *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
   *    *     *      *       *        *        *
    *     *      *       *        *
     *      *       *
      *

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 7:28 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 7:57 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1926
Location: Sacramento, CA, USA
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.


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 8:03 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
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)
Attachment:
TAB BBC Basic.png
TAB BBC Basic.png [ 13.18 KiB | Viewed 13032 times ]


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 8:26 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1926
Location: Sacramento, CA, USA
AppleSoft:

Attachment:
a2tab.JPG
a2tab.JPG [ 28.06 KiB | Viewed 13026 times ]


Hmm ... it looks like TAB() treats the leftmost column as column 1, and POS() treats it as column 0.

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 8:42 pm 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10793
Location: England
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)


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Tue Jun 19, 2018 8:47 pm 
Offline
User avatar

Joined: Sun Jun 30, 2013 10:26 pm
Posts: 1926
Location: Sacramento, CA, USA
That or SPC(Z-POS(0)-1) with a risk of crashing if the argument winds up negative.

Mike B.


Top
 Profile  
Reply with quote  
 Post subject: Re: A test program?
PostPosted: Wed Jun 20, 2018 4:48 am 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1000
Location: Canada
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:
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.

_________________
Bill


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 53 posts ]  Go to page 1, 2, 3, 4  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: