Author Topic: ScriptBasic - Raspberry Pi  (Read 255347 times)

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
ScriptBasic - Raspberry Pi
« on: March 30, 2019, 02:25:38 PM »
I'm pleased  to announce a release of ScriptBasic for the Raspberry Pi. You can do a traditional install with a .deb file or as an AppImage

This version of the binaries do NOT work on the Raspberry Pi Zero.
(Requires ARM v7 or greater)

DEB Install:

Code: Bash
  1. sudo apt install ./scriptbasic-2.1-linux-armhf.deb

DEB Uninstall:

Code: Bash
  1. sudo apt remove scriptbasic-2.1-linux-armhf

To run a script use scriba <script nane> when using the DEB Install.

To use the AppImage version ScriptBasic, unzip the file in the /usr/local/bin (or a directory in the system path) and use sb <script_name> to run your scripts. To remove ScriptBasic, remove the sb file.

I have added scriptbasic-rpi-zero.deb as an attachment. This version will run on ALL versions of the Raspberry Pi where the scriptbasic-2.1-linux-armhf.deb and AppImage versiosn will only run on the ARM v7 versions of the boards. The same instructions apply just change the name of the .deb file.


ScriptBasic User and Developer Guides

Most of the ScriptBasic development activity is happening on the All BASIC Forum.

Language Features
  • Tradional BASIC syntax
  • Variant style variables (no definition or declaration  needed)
  • Indexed, associative arrays (or combo of both) no practical limits
  • Muilt-threaded - asynchronous / synchronous execution
  • Unlimited seamless expansion via the extension API
  • Embeddable API
  • Footprint less than 800 KB
  • Runs on everything with a single source tree (written in ANSI C)
  • Application proxy web server that runs ScriptBasic code
  • Cascading pre-processor support
  • Debugger with single step execution, break points and more

Extension Modules
  • libcurl + SSL
  • MySQL
  • SQLite
  • ODBC
  • json
  • XML
  • regex
  • CGI
  • zlib
  • SBT - thread support
  • IUP - cross platform portable GUI
  • SDL_gfx graphics primatives with alpha channel support
  • BBC BASIC graphic library
  • more ..

Free - Open Source - MIT License

Raspberry Pi Downloads Attached
« Last Edit: April 13, 2019, 03:38:51 PM by support »

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic - Raspberry Pi
« Reply #1 on: March 31, 2019, 10:14:08 PM »
I was able to get the BBC BASIC graphics extension module working on the Raspberry Pi.

Code: Script BASIC
  1. ' UFO
  2.  
  3. IMPORT bbc.bas
  4.  
  5. BBC::OPEN "ScriptBasic BBC UFO - Raspberry PI"
  6. t1 = BBC::TIME()
  7. BBC::MODE 31
  8. BBC::ORIGIN 800, 600
  9. xs = 2
  10. ys = 2
  11. BBC::GCOL 0, 14
  12. BBC::OFF
  13. a = 700
  14. b = A * A
  15. c = 600
  16. FOR x = 0 TO a STEP xs
  17.   s = x * x
  18.   p = SQR(b - s)
  19.   FOR i = -p TO p STEP 6 * ys
  20.     r = SQR(s + i * i) / a
  21.     q = (r - 1) * SIN(24 * r)
  22.     y = INT(i / 3 + q * c)
  23.     IF i = -p THEN
  24.       m = y
  25.       n = y
  26.     END IF
  27.     IF y > m THEN m = y
  28.     IF y < n THEN n = y
  29.     IF m = y OR n = y THEN
  30.       BBC::PLOT 69, NOT(x), y
  31.       BBC::PLOT 69, x, y
  32.     END IF
  33.   NEXT
  34. NEXT
  35. t2 = BBC::TIME()
  36. t3 = (t2 - t1) / 1000
  37. BBC::OFF
  38. BBC::VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds."
  39. WHILE BBC::KEYNAME(1) <> "-escape"
  40. WEND
  41. BBC::CLOSE
  42.  


Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic - Raspberry Pi
« Reply #2 on: March 31, 2019, 10:15:30 PM »
Here is the Fren example.

Code: Script BASIC
  1. ' Fern
  2.  
  3. IMPORT bbc.bas
  4.  
  5. BBC::OPEN "ScriptBasic BBC fern - Raspbery Pi"
  6. t1 = BBC::TIME()
  7. BBC::MODE 31
  8. BBC::ORIGIN 200, 100
  9. BBC::OFF
  10. BBC::GCOL 0, 10
  11. x = 0
  12. y = 0
  13. FOR i = 1 TO 80000
  14.   r = BBC::RND(1)
  15.   IF r <= 0.1 THEN
  16.     a = 0
  17.     b = 0
  18.     c = 0
  19.     d = 0.16
  20.     e = 0
  21.     f = 0
  22.   END IF
  23.   IF r > 0.1 AND r <= 0.86 THEN
  24.     a = .85
  25.     b = .04
  26.     c = -.04
  27.     d = .85
  28.     e = 0
  29.     f = 1.6
  30.   END IF
  31.   IF r > 0.86 AND r <= 0.93 THEN
  32.     a = .2
  33.     b = -.26
  34.     c = .23
  35.     d = .22
  36.     e = 0
  37.     f = 1.6
  38.   END IF
  39.   IF r > 0.93 THEN
  40.     a = -.15
  41.     b = .28
  42.     c = .26
  43.     d = .24
  44.     e = 0
  45.     f = .44
  46.   END IF
  47.   newx = a * x + b * y + e
  48.   newy = c * x + d * y + f
  49.   x = newx
  50.   y = newy
  51.   BBC::MOVE 600 + 96 * x, 32 + 96 * y
  52.   BBC::DRAW 600 + 96 * x, 32 + 96 * y
  53. NEXT i
  54. t2 = BBC::TIME()
  55. t3 = (t2-t1)/1000
  56. BBC::VDUSTR "Time: " & FORMAT("%.4f",t3) & " seconds"
  57. BBC::WAITKEY
  58. BBC::CLOSE
  59.  

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic - Raspberry Pi
« Reply #3 on: March 31, 2019, 10:16:30 PM »
Finally the graph example. Hopefully other BBC BASIC fans will contribute examples as well.

Code: Script BASIC
  1. ' Graph Demo
  2.  
  3. IMPORT bbc.bas
  4.  
  5. CONST SDLK_ESCAPE = 27
  6.  
  7. BBC::OPEN "ScriptBasic BBC graphdemo - Raspberry Pi"
  8. t1 = BBC::TIME()
  9. BBC::MODE 31
  10. BBC::ORIGIN 800, 600
  11. xlow = -10
  12. xhigh = 10
  13. ylow = -10
  14. yhigh = 10
  15. depth = 10
  16. xscale = 30
  17. yscale = 12
  18. c = -4000
  19.  
  20. FOR x = xlow TO xhigh
  21.   BBC::MOVE xscale * (x + ylow), yscale * (ylow - x) + c / (x * x + ylow * ylow + depth)
  22.   FOR y = ylow TO yhigh
  23.     BBC::DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth)
  24.   NEXT
  25. NEXT
  26. FOR y = ylow TO yhigh
  27.   BBC::MOVE xscale * (xlow + y), yscale * (y - xlow) + c / (xlow * xlow + y * y + depth)
  28.   FOR x = xlow TO xhigh
  29.     BBC::DRAW xscale * (x + y), yscale * (y - x) + c / (x * x + y * y + depth)
  30.   NEXT
  31. NEXT
  32. t2 = BBC::TIME()
  33. t3 = (t2 - t1) / 1000
  34. BBC::OFF
  35. BBC::VDUSTR "Time: " & FORMAT("%.4f", t3) & " seconds."
  36. WHILE BBC::GETKEY(1) <> SDLK_ESCAPE
  37. WEND
  38. BBC::CLOSE
  39.  

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic - Raspberry Pi
« Reply #4 on: March 31, 2019, 10:17:41 PM »
For those not into the retro BBC BASIC graphics primitives, I ported the SDL_gfx extension module to the Raspberry Pi.

Code: Script BASIC
  1. ' ScriptBasic GFX - Alpha Circles
  2.  
  3. IMPORT gfx.bas
  4.  
  5. scrn = gfx::Window(640, 480, "ScriptBasic GFX - Alpha Circles - Raspberry Pi")
  6. ' Random Value Arrays
  7. RANDOMIZE(gfx::Time())
  8. FOR i = 0 TO 512
  9.   rx[i] = RND() % 640
  10.   ry[i] = 60 + RND() % 480 - 80
  11.   rz[i] = RND() % 64
  12.   rr[i] = RND() AND  255
  13.   rg[i] = RND() AND  255
  14.   rb[i] = RND() AND  255
  15.   af = rx[i] / 640
  16.   ra[i] = INT(255 * af)
  17. NEXT
  18.  
  19. ts = gfx::Time()
  20. FOR i = 0 TO 512
  21.   gfx::filledCircleRGBA scrn, rx[i], ry[i], rz[i], rr[i], rg[i], rb[i], ra[i]
  22. NEXT
  23. te = gfx::Time()
  24. gfx::stringColor scrn, 20, 15, "Time: " & FORMAT("%.4f",(te-ts)/1000) & " Seconds." & CHR(0), 0xffffffff
  25. gfx::Update
  26. WHILE gfx::KeyName(1) <> "+escape"
  27. WEND
  28. gfx::Close
  29.  

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic - Raspberry Pi
« Reply #5 on: March 31, 2019, 10:19:03 PM »
This shows some of the SDL_gfx graphic primitives.

Code: Script BASIC
  1. ' SDL_gfx Demo
  2.  
  3. IMPORT gfx.bas
  4.  
  5. screen = gfx::Window(700, 600, "ScriptBasic GFX Demo - Raspberry Pi")
  6. gfx::pixelRGBA(screen, 10, 15, 255, 255, 255, 255)
  7. gfx::lineRGBA(screen, 20, 10, 70, 90, 255, 0, 0, 255)
  8. gfx::trigonRGBA(screen, 500, 50, 550, 200, 600, 150, 0, 255, 255, 255)
  9. gfx::filledTrigonRGBA(screen, 200, 200, 300, 50, 400, 200, 0, 0, 255, 255)
  10. gfx::rectangleRGBA(screen, 10, 300, 100, 380, 0, 255, 0, 255)
  11. gfx::boxRGBA(screen, 210, 76, 325, 300, 255, 0, 0, 150)
  12. gfx::ellipseRGBA(screen, 600, 400, 50, 90, 255, 255, 0, 200)
  13. gfx::filledEllipseRGBA(screen, 600, 400, 25, 150, 0, 255, 0, 255)
  14. x[0] = 350
  15. x[1] = 275
  16. x[2] = 300
  17. x[3] = 325
  18. x[4] = 350
  19. x[5] = 400
  20. y[0] = 325
  21. y[1] = 325
  22. y[2] = 390
  23. y[3] = 390
  24. y[4] = 375
  25. gfx::polygonRGBA(screen, x, y, 6, 255, 255, 255, 155)
  26. s[0] = 400
  27. s[1] = 450
  28. s[2] = 450
  29. s[3] = 425
  30. s[4] = 300
  31. t[0] = 400
  32. t[1] = 410
  33. t[2] = 450
  34. t[3] = 425
  35. t[4] = 500
  36. gfx::filledPolygonRGBA(screen, s, t, 5, 255, 0, 255, 155)
  37. gfx::Update
  38. WHILE gfx::KeyName(1) <> "+escape"
  39. WEND
  40. gfx::Close
  41.  

Support

  • Administrator
  • *****
  • Posts: 22
    • View Profile
Re: ScriptBasic - Raspberry Pi
« Reply #6 on: March 31, 2019, 10:20:21 PM »
Attached are the extension modules and dependencies need for the bbc and gfx extension modules. These extensions only work with the DEB install at this time.

One must install the SDL 1.2 and SDL_gfx 1.2 runtime libraries.

sudo apt-get install libsdl1.2debian-1.2.15+dfsg1-4+rpt2
sudo apt-get install libsdl-gfx1.2-5-2.0.25-5

BBC
1. unzip the bbc.zip file in a temp directory
2. sudo cp bbc.so /usr/local/lib/scriba/
3. sudo cp bbc.bas /usr/local/include/scriba/
4. sudo cp libbbc.so /usr/lib/


SDL_gfx
1. unzip the gfx.zip file in a temp directory
2. sudo cp gfx.so /usr/local/lib/scriba/
3. sudo cp gfx.bas /usr/local/include/scriba/

Use the ScriptBasic example code posted in this thread to test your installation.
« Last Edit: March 31, 2019, 10:28:43 PM by support »