A test program?
- floobydust
- Posts: 1394
- Joined: 05 Mar 2013
A test program?
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
https://github.com/floobydust
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: A test program?
What kind of output device is available? If it's a text terminal, how about:
(credit: 101 BASIC Computer Games, D.E.C., 1975)
Mike B.
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
Mike B.
Re: A test program?
That's nice! I pasted it over serial into a Beeb and it ran unchanged - hidden line removal on the cheap!
- floobydust
- Posts: 1394
- Joined: 05 Mar 2013
Re: A test program?
barrym95838 wrote:
What kind of output device is available? If it's a text terminal, how about:
(credit: 101 BASIC Computer Games, D.E.C., 1975)
Mike B.
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
Mike B.
I just did a copy/paste directly into the serial port terminal window and it entered the entire program in a few seconds
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
https://github.com/floobydust
Re: A test program?
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!
- floobydust
- Posts: 1394
- Joined: 05 Mar 2013
Re: A test program?
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!
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
*
* * *
* * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * *
* * *
*Regards, KM
https://github.com/floobydust
https://github.com/floobydust
Re: A test program?
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.
- floobydust
- Posts: 1394
- Joined: 05 Mar 2013
Re: A test program?
Okay, I changed like 180 to:
PRINT TAB(Z/4)"*";
and it printed this:
Looking at the manual for EhBasic, using the SPC function might be a better option... same output using SPC(Z/4)"*";
PRINT TAB(Z/4)"*";
and it printed this:
Code: Select all
*
***
*****
*******
*******
*******
*********
*********
*********
***********
***** ******
**** *******
*** ** *****
*** * *****
*** * * ***
** * * * *
** * * * *
** * * * *
** * * * *
** * * * *
**** * * *
** * * * *
** * * * *
** * * * *
** * * * *
** * * * *
*** * * ***
*** * *****
*** ** *****
**** *******
***** ******
***********
*********
*********
*********
*******
*******
*******
*****
***
*Code: Select all
*
* * *
* * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * *
* * * * * * * * *
* * * * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * * * *
* * * * * * *
* * * * * * *
* * * * * * *
* * * * *
* * *
*Regards, KM
https://github.com/floobydust
https://github.com/floobydust
Re: A test program?
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.
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: A test program?
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.
Mike B.
Re: A test program?
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)
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)
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: A test program?
AppleSoft:
Hmm ... it looks like TAB() treats the leftmost column as column 1, and POS() treats it as column 0.
Mike B.
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?
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)
edit: in BBC Basic, you'd use POS instead of POS(0)
- barrym95838
- Posts: 2056
- Joined: 30 Jun 2013
- Location: Sacramento, CA, USA
Re: A test program?
That or SPC(Z-POS(0)-1) with a risk of crashing if the argument winds up negative.
Mike B.
Mike B.
Re: A test program?
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.
It should print endless Madelbrot sets.
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 10Bill