[News] BBC BASIC Beta Testing - 2009/03/06 r720

Porting Richard Russell's BBC BASIC (Z80) to the TI-83+ and TI-84+ series calculators.

Moderator: benryves

Post Reply
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Re: [News] BBC BASIC Beta Testing - 2009/01/28 r654

Post by cjgone »

Sad, I can't even open the .zip file since it says something about a corruption. =.-
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/28 r654

Post by benryves »

Try downloading it again? I just downloaded it (to verify something hadn't gone wrong when uploading) and both the built-in Windows unzipping tool and 7-zip handle it fine.
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/29 r660

Post by benryves »

A few bug-fixes in the r660 release:
  • Circles are stretched correctly when the X axis and Y axis use different scale factors (eg in MODE 0, the default).
  • Large circles are drawn (they weren't being drawn at all previously!)
  • SWAP will let you swap indirected variables (including fixed strings and byte variables) and will not let you pass literals.
  • The cursor flashes during WAIT operations.
The circle drawing code has been sped up significantly by skipping two expensive multiplications and a 32-bit square root calculation when the supplied point on its circumference has the same x or y component as the centre of the circle (ie, in normal use).

EXIT FOR now lets you pass an optional loop variable to break out of nested FOR loops:

Code: Select all

FOR I%=1 TO 3
  FOR J%=4 TO 5
    IF bool% THEN EXIT FOR I%
  NEXT J%
NEXT I%
This shares the same caveats as EXIT FOR on the Windows version.
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Re: [News] BBC BASIC Beta Testing - 2009/01/28 r654

Post by cjgone »

K, got it to work and i'm excited to test this thing out. ;o

My .zip skills aren't to good, heh.
ahudson
New Member
Posts: 15
Joined: Sun 09 Nov, 2008 8:16 pm

Re: [News] BBC BASIC Beta Testing - 2009/01/29 r660

Post by ahudson »

I have installed the latest beta on my TI-84 Plus SE and I noticed that the "Input" command had some problems. As you see in the code below (an excact replica of what I did with this simple calculator program) the Input command appears to only recognize the first value entered and does not evaluate the selection.

BBC BASIC (Z80) v3.00
(C) R.T.Russel 1987

10 PRINT "**************
********** CALCULAT
OR ****************
*********"
20 INPUT "",A
30 PRINT A
40 GOTO 20
SAVE "CALC"
RUN "CALC"
************************
* CALCULATOR *
************************
? 35+6
35
?

Escape at line 20
>

I am led to believe that this is a bug because, as illustrated below, the PRINT command will evaluate the selection.

BBC BASIC (Z80) v3.00
(C) R.T.Russel 1987

PRINT 35+8
43

Can you possibly look into this and corect the issue?

Thanks!
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/29 r660

Post by benryves »

I'll point you to the INPUT documentation for why this happens, but if you're simply after the correct way to read an expression (like '35+6') and convert it into a numeric value then you should read input into a string variable then use EVAL to evaluate it, like this:

Code: Select all

INPUT A$ : A=EVAL(A$)
If you wish to get rid of the "? " prompt, use the following instead:

Code: Select all

INPUT;A$ : A=EVAL(A$)
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/29 r660

Post by benryves »

I've started tweaking some of the graphics code, and have corrected ellipses (so they have the same shape when drawn filled as drawn outlined - filled ellipses were a little ugly before).

I'm holding off a release until I can figure out the rules for filled rectangles - on BBC BASIC for Windows if you ask for a rectangle one pixel width/height it is drawn as a single pixel; on the TI-83+ version it draws it two pixels wide/high. Rectangles are expressed as two diagonally opposite corners and the TI-83+ version fills between both inclusively (as with lines) whereas the Windows version appears to stop one pixel short. I'll experiment a bit with different versions of BBC BASIC to see which is correct, but this should be an easy correction.

In the meantime, have an ugly program that produces pretty results:
Image Image Image

Code: Select all

   10 REM Mandelbrot set fractal.
   20 REM Based on a program by Ken Silverman.
   30 MODE3
   40 mnX=-1.8:mxX=.7
   50 mnY=-1:mxY=1
   60 dX=mxX-mnX:dY=mxY-mnY
   70 FOR res%=0TO5
   80   R%=128DIV2^res%:S%=0:T%=0
   90   FORY%=0TO255STEPR%:FORX%=0TO383STEPR%
  100     IFres%AND((T%ORS%)AND1)=0 S%=S%+1:NEXT
  110     x=X%/384*dX+mnX:y=Y%/256*dY+mnY:ox=x:oy=y
  120     FORC%=0TO14:xx=x*x:yy=y*y:IFxx+yy>3 EXIT FOR
  130       y=x*y*2+oy:x=xx-yy+ox:NEXT
  140       GCOLC%:RECTANGLE FILL X%,Y%,R%-1
  150   S%=S%+1:NEXT:T%=T%+1:NEXT
  160 NEXT res%
  170 REPEAT:UNTILINKEY0<>-1
Increase the 3 in line 120's IFxx+yy>3 to increase the quality (and time it takes to render). Change mnX, mxX, mnY and mxY at the top of the program to change the window settings (ie, which bit of the fractal is being rendered).

Edit: The newly-uploaded version features the corrected ellipse code, some bug fixes to the EXIT and WHILE statements and support for indentation of extended keywords in the PC editor.
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by tr1p1ea »

Oh wow ben! The dithering on that mandelbrot is fantastic! It generates super fast for a calc too!. BBC BASIC teh future!
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by cjgone »

It works on my calc but I don't get the syntax to much.

Code: Select all

10 INPUT "How old r u?",A
20 IF A > 50 THEN
30	PRINT "u r old"
40 END
What's wrong with this code? It prints the text regardless of what A is equal to.

Wait is BBC basic interpretted or compiled? and are structures implemented?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by benryves »

Code: Select all

10 INPUT "How old r u?",A
20 IF A > 50 THEN
30	PRINT "u r old"
40 END
What's wrong with this code? It prints the text regardless of what A is equal to.
IF statements must fit on one line. A limitation of the interpreter's handling of statement blocks is that they must be executed at least once, as it can't skip over the block (unless you use a GOTO). So,

Code: Select all

10 INPUT "How old r u",A
20 IF A>50 THEN PRINT "u r old"
will work. I know it's not ideal, and later versions of the language support IF/THEN/ENDIF blocks (a special case if THEN is the last thing on a line) but there are ways around the limitation. One way is to use the WHILE loop instead (which I've added and supports skipping over a block), like this:

Code: Select all

10 INPUT "How old r u",A
20 WHILE A > 50
30   PRINT "u r old"
40 EXIT WHILE:ENDWHILE
Wait is BBC basic interpretted or compiled? and are structures implemented?
The BASIC code is entirely interpreted. This version of BBC BASIC does not support structures, though you may be able to replicate their functionality with multidimensional arrays. If you want to go lower level, you can use the indirection operators to create your own data structures.

If you use the integrated assembler, that outputs fully assembled code (there is not a Z80 "interpreter"), which is useful for speed.
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by cjgone »

Okay, thanks.

Wait, since it's interpretted, and I think interpretation is slower then compiling, is their a way to turn it into a binary file for faster execution?

How fast is BBC basic compared to let's say assembler?
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by benryves »

BASIC programs are stored in a tokenised binary form which is easy to parse (see here and here); that's about as close as a binary format as you'll get.

BBC BASIC programs run at least an order of magnitude slower than native assembly, but on the other hand it's much quicker to develop a BASIC program than it is to develop an assembly program. BBC BASIC offers an alternative to assembly when you can accept a speed hit (though you can of course mix the two for the best of both worlds).
cjgone
Regular Member
Posts: 83
Joined: Tue 18 Apr, 2006 5:33 am
Location: Washington->UC Berkeley '15

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by cjgone »

How would I go about drawing a 8x8 picture? And how do I make a pointer? or even an array of pointers? Anyway to define an 8bit variable to make calculations faster?
User avatar
tr1p1ea
Maxcoderz Staff
Posts: 4141
Joined: Thu 16 Dec, 2004 10:06 pm
Location: I cant seem to get out of this cryogenic chamber!
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by tr1p1ea »

I believe there are already special cases in place to take advantage of integer math if thats all you require.
"My world is Black & White. But if I blink fast enough, I see it in Grayscale."
Image
Image
User avatar
benryves
Maxcoderz Staff
Posts: 3087
Joined: Thu 16 Dec, 2004 10:06 pm
Location: Croydon, England
Contact:

Re: [News] BBC BASIC Beta Testing - 2009/01/30 r668

Post by benryves »

cjgone wrote:How would I go about drawing a 8x8 picture?
This is where it starts to get a bit messy I'm afraid; the best solution currently is to use MODE 4 (for large 8x8 characters) and VDU 23 to redefine the characters. If you wish to draw a sprite at any position on the screen, you could then use VDU 5 to switch to drawing text at the graphics cursor position. It's all a bit slow, though (I acknowledge this!) Take a look at TILEMAP.8xp for an example of tilemapping using redefined characters.
And how do I make a pointer? or even an array of pointers?
Any numeric variable can be used as a pointer when using the indirection operators. You can allocate memory using DIM.
Anyway to define an 8bit variable to make calculations faster?
If anything it will make calculations slower as they're all done in 32-bit anyway, but yes - using DIM and indirection:

Code: Select all

10 DIM byte 0
20 FOR ?byte=0 TO 255
30   PRINT ?byte
40 NEXT
In terms of speed, the static variables (A%-Z% and @%) are faster than ones allocated on the heap as they are at constant places in memory. It is also faster if you use variables with different first letters as variables are stored in a linked list based on their first letter; if every variable started with the letter 'x' there would be only one (long) linked list in use and that would have to be searched every time a variable was used.
tr1p1ea wrote:I believe there are already special cases in place to take advantage of integer math if thats all you require.
As tr1p1ea astutely pointed out, "BBC BASIC (Z80) stores integer values in real variables in a special way which allows the faster integer arithmetic routines to be used if appropriate. The presence of an integer value in a real variable is indicated by the stored exponent being zero. Thus, if the stored exponent is zero, the real variable is being used to hold an integer and the 4 byte mantissa holds the number in normal integer format".
Post Reply