Author Topic: Third-party ports of Lua to TI calculators...  (Read 9062 times)

0 Members and 1 Guest are viewing this topic.

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Third-party ports of Lua to TI calculators...
« on: June 28, 2011, 08:29:45 am »
* for the Nspire platform, let's not forget davyg's effort, http://ourl.ca/10458 , because it would let us some independence wrt. what TI feels like giving us. Remember, the new 84+(SE) boot code is further proof that they're trying more actively than ever to lock things down.


* for the TI-68k platform: recently, on yAronet, an experimental port of an older version of Lua (5.0.2) to the TI-68k was mentioned.
It's a "kernel"-based program (lua.89z), using three "kernel"-based libraries to overcome the 64 KB size limit: "liblua" (core), "lualib" (some library functions), and "lamslib" (AMS-specific library, which currently contains Lua wrappers for getkey, ngetchx, clrscr, DrawPix, ScrRectFill and DrawStr).

After shuffling files around (lualib/* -> src/lib/, core/* -> src/), the diff against upstream Lua 5.0.2 comes up rather small: http://www.mirari.fr/1xkz . It's likely that it could be ported forward to newer versions of Lua without too much hassle :)
Several io.* functions and a couple math functions haven't been implemented, there's no support for stdin / stdout / stderr on AMS / TIGCCLIB / GCC4TILIB, and the source ought to be modified for using the strtod built in AMS (I integrated strtod into GCC4TI last week-end, "it never got done" in TIGCC since 2003 or even 2002) but it's nevertheless bound to be usable for a number of classes of programs - especially if someone spends a bit of time expanding lamslib :)

And there's another way to overcome the size limit: making the Lua interpreter and library a FlashApp. For that purpose, we don't even have to withstand TI's horrible toolchain from end to end: GTC is known to be compiled largely with TIGCC / GCC4TI, and linked with TIFS.


* for the TI-Z80 platform: well, compiling the Lua interpreter yields a binary large enough it wouldn't be great fun to deal with paginated memory...
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Third-party ports of Lua to TI calculators...
« Reply #1 on: June 28, 2011, 11:52:59 am »
Hmm, that 68k port looks pretty interesting! It would be also great if it landed on punix, as that might give the os a boost :)

Thanks for the info Lionel!

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Third-party ports of Lua to TI calculators...
« Reply #2 on: June 28, 2011, 12:32:31 pm »
Since PedroM and Punix are both more POSIX-y than AMS + TIGCCLIB/GCC4TILIB are, porting Lua there is indeed slightly easier than porting Lua on AMS :)
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Third-party ports of Lua to TI calculators...
« Reply #3 on: July 08, 2011, 01:30:38 pm »
Status update:
* I have cleaned up the source of the aforementioned Lua89, so as to make it easier to forward port the patch to new versions;
* I have fiddled with the compiler and linker flags, for a size gain on the binaries of ~20 KB out of 100 KB. Most of the flags I added were not available when Lua89 was made.
* forward-porting from 5.0.2 to the last bugfix release of the 5.0.x series, 5.0.3, is easy enough: less than 20 changed offsets, three conflicts. However, forward-porting to the next major version, 5.1, is another matter: only a minority of files do not conflict...
[EDIT: there are slightly fewer conflicts after adjusting the diff to match the shuffling of files between the 5.0 series and the 5.1 series. But still...]

Diff against Lua 5.0.3: http://www.mirari.fr/hJuT . Not tested beyond checking that the provided Hello World example (hello.89t) doesn't crash ;)
« Last Edit: July 08, 2011, 03:37:46 pm by Lionel Debroux »
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Third-party ports of Lua to TI calculators...
« Reply #4 on: July 09, 2011, 08:30:51 am »
Sound cool Lionel, keep us posted on your progress! :)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Third-party ports of Lua to TI calculators...
« Reply #5 on: July 09, 2011, 11:52:42 am »
Sure :)

Bad news: when making several tests, I've just noticed that Lua89, in its pristine form (5.0.2) as well as its current form (5.0.3), doesn't support files suitable for the text editor: Lua 5.0.x like only input files whose line endings are LF... and sure enough, the text editor built in AMS supports only CR line endings...
Good news: the Lua 5.1.x on my Linux supports all of CR, LF and CRLF line endings, so upgrading to a newer Lua version ought to solve this problem and make Lua89 more useful / less useless. I've started the work of porting to 5.1.4, but...
Bad news: porting forward to 5.1.4 would take a number of additional hours, and merely fixing the conflicts is unlikely to yield a source code in a compilable state, let alone in a working state - it needs lots of testing afterwards.

The official test suites for 5.0 and 5.1 can be found easily, but 1) the port to the TI-68k platform needs to be expanded and 2)  these test programs will have to be screened for unimplemented functions / variables.
In Lua89, besides core Lua (in which at least the command-line arguments are missing), most functions of the following libraries are available: coroutine.*, table.*, io.* (no standard input/output, no locales), os.* (no clock, no time, no date), string.*, math.*, debug.*.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: Third-party ports of Lua to TI calculators...
« Reply #6 on: July 09, 2011, 03:55:05 pm »
Thanks for all your work Lionel!
Its quite interesting, and might be a good learning tool for other people in the future :)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Third-party ports of Lua to TI calculators...
« Reply #7 on: July 22, 2011, 03:55:34 pm »
Status update: porting Lua89 to 5.1.4 isn't much fun (I have done the easy part, the hard part remains...), and grepping through the sources showed that it was easy to make the Lua 5.0.x interpreter cope with CR line endings instead of LF line endings.
So that's what I did for now. The slowness of Lua on the TI-68k platform can't be fixed, but at least, this change fixes the largest usability annoyance of the original version of Lua89: it's now possible to use the built-in text editor for on-calc Lua programming.

I have refreshed the patch at http://www.mirari.fr/hJuT , against Lua 5.0.3. It contains several pre-converted example files.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline DrDnar

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 546
  • Rating: +97/-1
    • View Profile
Re: Third-party ports of Lua to TI calculators...
« Reply #8 on: July 22, 2011, 06:04:51 pm »
Remember, the new 84+(SE) boot code is further proof that they're trying more actively than ever to lock things down.
I honestly think that TI doesn't understand the purpose of the RSA signature. I think they think of the signature as being akin to a real signature, and that factoring the keys means we can forge their real, legally binding signature. They upgraded to 2048-bit RSA because they don't want us forging their signature, not because they don't want us making 3rd-party OSes or patching the OS.

Either that, or they actually don't understand that we had the ability to unlock flash years before we factored their keys, or the importance thereof.
"No tools will make a man a skilled workman, or master of defense, nor be of any use to him who has not learned how to handle them, and has never bestowed any attention upon them. . . . Yes, [] the tools which would teach men their own use would be beyond price."—Plato's The Republic, circa 380 BC

SirCmpwn

  • Guest
Re: Third-party ports of Lua to TI calculators...
« Reply #9 on: July 22, 2011, 06:13:18 pm »
I would love a 3rd party Ndless-enabled version of Lua so that I have even less reason to upgrade.

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Third-party ports of Lua to TI calculators...
« Reply #10 on: July 23, 2011, 02:24:12 am »
Yup, but it would be quite a bit of work to make a third-party version of Lua compatible with TI's: it requires reimplementing their additions to the API, the event-driven model, etc.
And the API will change (mostly expand) in the future, as outlined by the documentation mentioning 3.1 OS and some Lua stuff not accessible in 3.0.*.

The roadblocks in the task of porting mainline Lua to the Nspire are more in the library of functions than in the toolchain: the Ndless SDK is using mainline GCC.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Third-party ports of Lua to TI calculators...
« Reply #11 on: July 24, 2011, 09:30:46 am »
Yeah for Z80 Calculators, it wouldn't be so good, but for the 68K it looks amazing!

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: Third-party ports of Lua to TI calculators...
« Reply #12 on: July 24, 2011, 10:03:11 am »
I wonder why RAGE2000's original port didn't become more popular in 2003-2004... that was 2-3 years before the TI-68k community mostly died.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: Third-party ports of Lua to TI calculators...
« Reply #13 on: July 25, 2011, 05:06:46 pm »
I personally haven't heard of it until now, I'm not sure RAGE2000 advertise it much.
Ndless.me with the finest TI-Nspire programs