* WalrusIRC

You need to have 5 posts and not be part of restricted usergroups in order to use the WalrusIRC embedded shoutbox. However, you can also access our IRC channel called #CodeWalrus via EFnet.

Author Topic: nSquirrel : Squirrel programming language on Ti-Nspire  (Read 8652 times)

0 Members and 1 Guest are viewing this topic.

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
nSquirrel : Squirrel programming language on Ti-Nspire
« on: March 30, 2016, 08:31:51 am »
nSquirrel
Squirrel on Ti-Nspire

Last release version (v1.0.1) : https://github.com/Eiyeron/squirrel/releases/tag/nsquirrel_1.0.1 (includes documentation, which the binary linked to this post doesn't)
Project repository : https://github.com/Eiyeron/squirrel/
nSquirrel (interpreter + n2SDLib) branch : https://github.com/Eiyeron/squirrel/tree/nSquirrel


"Squirrel is a high level imperative, object-oriented programming language, designed to be a light-weight scripting language that fits in the size, memory bandwidth, and real-time requirements of applications like video games."

(Translation : it's a lightweight script language destined to be embedded in programs like Lua does.)

(click to show/hide)

nSquirrel is a fork of this language destined for Ti-Nspires. The core language will be easily embeddable into Ndless projects as the project offers libraries and API to mess with it. Thus, it's included with bindings to n2DLib to allow playing with the screen and the keyboard.

Instructions :
- Download the archive containing the program (sq.tns) and if wanted, the example scripts.
- Install your sq.tns on your calc's nspire folder
- Now you can launch the interpreter for an interactive session ( quit() to exit it) or launch a .nut script (only after running the exectuable once). NOte that thanks to nspireio, you have to press twice Enter to validate your input.
- The interpreter registering itself to open .nut files, to execute such scripts, you will just have to click on them.

Notes
- For further versions, I'll probably provide two versions of the binaries, ones to compile nSquirrel's interpreter (which uses Nspire-IO) and one to be included in projects.
« Last Edit: April 08, 2016, 02:57:19 pm by Duke "Tape" Eiyeron »


  • Calculators owned: A lot.

Offline Streetwalrus

  • Professional slacker
  • Super User
  • Original 5
  • Join Date: Nov 2014
  • Location: Israel
  • Posts: 2903
  • Post Rating Ratio: +20/-0
  • ƎW∀⅁ ƎH⊥
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #1 on: March 30, 2016, 08:38:21 am »
Awesome, now you should be able to make bindings for Nspire specific things besides Nspire-IO (which isn't hard to integrate by the way).
  • Calculators owned: TI-80, HP 40G, TI-84 Plus rev G (yay 128k RAM), TI-83 Plus Silver Edition (broken LCD), TI-82 Stats.fr (black), TI-Nspire CX rev C (yay Nlaunchy), TI-83+ SE ViewScreen



Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18599
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #2 on: March 30, 2016, 03:10:36 pm »
Awesome Eiyeron. If this gets completed and allow everyone to launch the binary directly without much hassle, then this will be a great addition to other Nspire languages. Now we have BASIC, Lua, ASM, C, Python, Javascript and Squirrel. :)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Ivoah

  • Super User
  • Join Date: Dec 2014
  • Location:
  • Posts: 523
  • Post Rating Ratio: +6/-0
    • @NoahRosamilia
    • Ivoah
    • @UCmgDyh_AeaHALohvR7PKXIw
    • /u/Ivoah
    • Ivoah
    • 114/11421
    • Codinghobbit
  • Gender: Male
  • WalriiPoints: 100
Re: Porting Squirrel programming language
« Reply #3 on: March 30, 2016, 03:12:27 pm »
Awesome Eiyeron. If this gets completed and allow everyone to launch the binary directly without much hassle, then this will be a great addition to other Nspire languages. Now we have BASIC, Lua, ASM, C, Python, Javascript and Squirrel. :)
Don't forget C++
  • Calculators owned: TI-86 (now broken), TI SR-56, TI-Nspire CX CAS, TI-84+ SE, TI-84+ SE, TI-85, TI-73 Explorer VS, ViewScreen, TI-84+ CSE, TI-83+ SE

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18599
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #4 on: March 30, 2016, 03:15:40 pm »
Ah yeah, true. I always forget which of the C-compatible calculators (68K, Nspire, 83+, 84+CSE, 84+CE, PRIZM, 9860G, etc) supports C++, C# or not >.<.
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #5 on: March 30, 2016, 04:02:53 pm »
I had to cheat my way but it uses now nspireio to show and require input data. The biggest slowing thing is probably nspireio itself for now. The linked build should be working (at least on emulator. I need to find an USB cable).
I need to find a way to avoid the lib using it also. I mostly hacked the binary, but the runtime library uses printf at one place and would probably need another function instead.
« Last Edit: April 04, 2016, 12:49:49 pm by Duke "Tape" Eiyeron »
  • Calculators owned: A lot.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18599
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #6 on: March 30, 2016, 04:07:10 pm »
That's good to hear. I assume that sprites and such graphics cannot be displayed yet? Also, will this be compatible with the newer TI-Nspire CX CR4 hardware (the one with 240x320 screens flipped sideways instead of an actual 320x240 LCD)?
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #7 on: March 30, 2016, 04:12:21 pm »
IIRC nspireio has been updated to support the newer hardware. Though I don't really know how it works from Ndless' side and I probably suppose that a version check is done at every pixel acces (where one-time funptr selection would probably make up for the loss.)

EDIT : tested on calc and it works.
« Last Edit: March 30, 2016, 08:46:04 pm by Duke "Tape" Eiyeron »
  • Calculators owned: A lot.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18599
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #8 on: March 31, 2016, 05:24:48 am »
There is a compatibility layer in Ndless 4.2, but if something updates the entire LCD every frame rather than just parts of it, then it will run 50 times slower, while stuff that does partial screen redraw will run 3 times slower. However, there is a way to achieve almost the same speed on newer hardware than older one. Basically, don't rely entirely on the Ndless 4.2 CR4 compatibility layer. :P
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline gameblabla

  • Super User
  • Join Date: May 2015
  • Location:
  • Posts: 720
  • Post Rating Ratio: +14/-6
  • TI-nspire porter
Re: Porting Squirrel programming language
« Reply #9 on: March 31, 2016, 10:44:26 am »
That's an interesting project and all but i still think that the Shakespeare Programming Language is better.
I'm guessing though that you are not planning on supporting nSDL or any graphics library with Squirrel ?
  • Calculators owned: TI Nspire CX, TI-89

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #10 on: March 31, 2016, 11:41:56 am »
That'd mean integrating with the source, as there isn't any dynamic libraries on ndless. THat's something more or less envisaged. Gotta take some time for it.

Note : Saved yesterday my calc from the weirdest brick : anything editing the flash (editing, creating, deleting files) would be automatically rollbacked. Had to reinstall the OS. >.>

Small latenight update : integrating n2Dlib. Every drawing functions are done, I need to figure what to do to store and manage sprites (blobs or sprites?...), but the rest seems to work
« Last Edit: March 31, 2016, 11:16:44 pm by Duke "Tape" Eiyeron »
  • Calculators owned: A lot.

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #11 on: April 01, 2016, 12:41:08 pm »
Pushed a new version containing n2DLib and bindings to every drawing function with n2d as prefix (minus drawPolygon), which means :

Code: [Select]
initBuffering
deinitBuffering
updateScreen
clearBuffer
clearBufferB
clearBufferW
getPixel
setPixelUnsafe
setPixel
setPixelRGB
drawHLine
fillRect
drawSprite
drawSpritePart
drawSpriteScaled
drawSpriteRotated
drawLine
fillRect
fillCircle
fillEllipse
drawString
drawDecimal
drawChar

Note that every function that asks for Rect asks for the four variables instead of said rect.
Code: [Select]
extern void drawSpriteScaled(const unsigned short*, const Rect*, int, unsigned short);

=> n2d.drawSpriteScaled(sprite, 0, 0, i, i, 0, 0)

For now, to draw a sprite, you need to convert your picture into a n2D sprite, and convert it with this function :
Code: [Select]
function array_to_blob(array)
{
   local b = blob(array[0]*array[1])
   foreach(v in array)
      b.writen(v, 'w')
   return b
}

Sample program:
(click to show/hide)
« Last Edit: April 02, 2016, 01:56:30 pm by Duke "Tape" Eiyeron »
  • Calculators owned: A lot.

Offline Duke "Tape" Eiyeron

  • Urist McEiyolobster
  • Super User
  • Join Date: Nov 2014
  • Location: (V)(-_(//));(V)
  • Posts: 1636
  • Post Rating Ratio: +11/-2
  • Fanciest Walrus of the oceans.
    • @@Eiyeron
    • Eiyeron
    • /u/Eiyeron
    • Eiyeron
    • Rétro-Actif : Rétro/Prog/Blog
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #12 on: April 02, 2016, 01:57:59 pm »
Update time : Added N2DLib's fixed functions, fixed a few (useless) warnings and some functions. I included in the zip a script I did from scratch to show pretty things on the screen

Small edit : I found how to make libs from the script side:

Let's say you have a file a.nut, right? HEre's its content :
Code: [Select]
local function func()
{
return 42
}

# Explicit root table setting. I'm setting a global variable called a which contains the function func at the index f.
::a <- {"f" : f}

So I can do from another script (or from the interpreter)
Code: [Select]
dofile("test.nut") // Loads file
print(a.f()) // a is now in the root table (::), so you can call its function f.
// And it'll print '42'

So yeah, I'm happily saying that Squirrel already allows user-scripted libraries :D So now, the biggest issue is organizing your libraries : Ndless doesn't allow relative paths IIRC (I need correction on this point but it was an issue on WRPG), like "subfolder/script.tns" but only absolutes path ("/documents/<path to your script>/subfolder/script.tns") which isn't really cool if you ever move your scripts not in the right place... I'll see what I can do to emulate this behaviour.
« Last Edit: April 02, 2016, 03:01:53 pm by Duke "Tape" Eiyeron »
  • Calculators owned: A lot.

Offline xlibman

  • Omni founder & CW co-founder
  • CodeWalrus Staff
  • Super User
  • Original 5
  • CodeWalrus Supporter
  • *
  • Join Date: Nov 2014
  • Location: Quebec, Canada
  • Posts: 18599
  • Post Rating Ratio: +95/-4
    • dj_omnimaga
    • DJOmnimaga.music
    • @DJOmnimaga
    • dj_omnimaga
    • @DJOmnimaga
    • /u/DJ_Omnimaga
    • DJOmnimaga
    • 112/11286
    • @djomnimaga
    • @DJOmnimaga
    • DJ Omnimaga music store
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #13 on: April 02, 2016, 06:27:46 pm »
Nice progress Eiyeron. :)
  • Calculators owned: TI-57, 73, TI-80 (broken), TI-81, TI-82, TI-83, TI-83+ (broken), TI-83+ (broken), TI-83+SE (broken), TI-84+, TI-84+CSE, TI-84+CE, TI-85, TI-86, TI-89T, TI-92, TI-Nspire, TI-Nspire CX (semi-broken), HP 39gII, HP Prime, Casio fx-7000G, fx-7400G+, fx-7700GE, fx-9750G+, fx-9750GII, fx-9860G, cfx-9850G, FX-1.0+, fx-CG10, fx-CP400
  • Consoles, mobile devices and vintage computers owned: Samsung i5510, Nexus 5, Atari 2600, Lynx, SMS, Game Gear, Genesis, Dreamcast, NES, SNES, N64, GCN, Wii, Wii U, GBA, DS, 3DS, PS2, PS3, PS4, PSP, PSVita, XBox 360, XBOne

Bandcamp|Reverbnation|Facebook|Youtube|Twitter
Retired Omnimaga admin (2001-11) and editor (2012-14)

Offline Jkolade936

  • All Around Coolio
  • Super User
  • Join Date: Jan 2016
  • Location: Horseheads, NY
  • Posts: 1515
  • Post Rating Ratio: +9/-1
  • I'm an unknown loner. I try to change that.
    • Jkolade936
    • My Sprites and Walrii Collection
  • Gender: Male
Re: Porting Squirrel programming language
« Reply #14 on: April 03, 2016, 12:20:55 am »
That creature in the picture doesn't exactly look like a squirrel...?
  • Calculators owned: None of them. :'(
Does this qualify as a signature? 
The answer is "Sure."


 


You can also use the following HTML or bulletin board code to share it on your page or forum signature!


Also do not forget to check our affiliates below.
Planet Casio TI-Planet Calc.news BroniesQC BosaikNet Velocity Games