Author Topic: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files  (Read 52048 times)

0 Members and 1 Guest are viewing this topic.

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #60 on: September 25, 2011, 02:11:52 pm »
Too bad...
I still have only 9 days of free trial, and I mainly code on my clickpad :(
I'll have to ask someone to copy my code.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #61 on: September 25, 2011, 02:31:36 pm »
!summon Goplat :
Can you debugger be interfaced with a scripting language ?
I mean bashing actions like this one :

-> k 10032aa0 +x
-> c
-> Ctrl+S
-> w C:\dump.xml r1 400
-> c
-> w C:\dump.xml r1 400
-> c
-> w C:\dump.xml r1 400
...
n time ...
-----> Dump of a document.

EDIT : well, I guess that integrated plugins would be really great, isn't it ? :D
« Last Edit: September 25, 2011, 02:49:00 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Goplat

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 289
  • Rating: +82/-0
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #62 on: September 25, 2011, 03:54:20 pm »
Levak: You could create a file containing all the debugger commands to enter:
Code: [Select]
k 10032AA0 +x
c
w dump1.xml r1 r2
c
w dump2.xml r1 r2
c
w dump3.xml r1 r2
c
w dump4.xml r1 r2
c
w dump5.xml r1 r2
c
w dump6.xml r1 r2
(...for as long as you expect the xml to be...)
then run: nspire_emu ... /D < commands.txt
« Last Edit: September 25, 2011, 03:54:42 pm by Goplat »
Numquam te deseram; numquam te deficiam; numquam circa curram et te desolabo
Numquam te plorare faciam; numquam valedicam; numquam mendacium dicam et te vulnerabo

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #63 on: September 25, 2011, 04:17:46 pm »
Two bugs related to replacing & and < in lua source with character entities:

* escape_special_xml_chars stops processing when it reaches the offset equal to the size of the original input ("p < in_buf + header_size + in_size"), not taking into account that the size is changing during the loop, so characters near the end of the program may not get escaped
* xml_compress copies the footer without taking into account the change in size ("memcpy(in_buf + header_size + in_size, lua_footer, sizeof(lua_footer));"), resulting in a truncated program and garbage at the end of the xml

Thanks Goplat! This would explain the problems Levak had with Make3D.
« Last Edit: September 25, 2011, 04:18:37 pm by ExtendeD »
Ndless.me with the finest TI-Nspire programs

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #64 on: September 26, 2011, 10:58:32 am »
Levak: You could create a file containing all the debugger commands to enter:
then run: nspire_emu ... /D < commands.txt

Thanks !

Here is my working dumper thanks to your help :
Code: [Select]
function dump {
local winePath="$HOME/.wine/dosdevices/c:"
local rom=$(zenity --file-selection --title="Sélectionnez un fichier *.rom" --filename="$RELPAT/");
if [ "$rom" ]; then
if [ "${rom##*.}" = "rom" ]; then
local size=$(zenity --entry --title="Taille du classeur à dumper (octets)" --entry-text="0");
let num=$size/170
echo "k 10032AA0 +x" > "$RELPAT/commands.txt"
echo "c" >> "$RELPAT/commands.txt"
local i=0
while [ $i -le $num ]; do
# Complete tempory file names with zeros so that it's listed correclty
let local dif=${#num}-${#i}
local spaces=$(printf "%"$dif"s")
local zeros=${spaces// /0}
# Fill command list
echo "w C:\dump$zeros$i.xml r1 r2" >> "$RELPAT/commands.txt"
echo "c" >> "$RELPAT/commands.txt"
let i=$i+1
done

# Launch emulator with debug command list
"$RELPAT"/nspire_emu.exe /F="$rom" /B=boot2.img.raw /D < "$RELPAT/commands.txt"

# Concatenate final XML file using tempory files
echo -n "" > "$RELPAT/dump.xml"
for f in "$winePath/dump*"; do
cat $f >> "$RELPAT/dump.xml"
done
rm "$winePath/dump*"
rm "$RELPAT/commands.txt"
else
zenity --error --title="Erreur" --text="Veuillez sélectionner un fichier *.rom et pas autre chose ! \n Opération annulée"
fi
fi
}
> bash 4 linux
> requires zenity
> requires wine
> only works with OS 3.0.1 AND NONCAS roms.

EDIT : it can easily be added to my bash launcher
47 +                "dump" "Dumper un classeur (Ctrl+S -- dump.xml)" \
177 + (the code above)
271 +          elif [ "$select_noncas" = "dump" ]; then
            dump
« Last Edit: September 26, 2011, 01:59:16 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #65 on: September 26, 2011, 11:56:52 am »
Nice Levak :)
For those who wonder: Levak's script can be used to dump TNS documents of arbitrary size as XML documents, before adapting them and converting them back with Luna v0.2.
Ndless.me with the finest TI-Nspire programs

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #66 on: September 26, 2011, 12:59:29 pm »
Code: [Select]
echo $(perl -0777 -pe 's/(.*&lt;r2dtotree&gt;|&lt;\/r2dtotree&gt;.*)//gsm' dump.xml | sed "s/&lt;node name=&quot;1para&quot;&gt;/\x0D/g;s/&lt;\/*node[^g]*&gt;//g;s/&lt;\/*leaf[^g]*&gt;//g;s/&lt;cursor[^g]*&gt;//g;s/&amp;quot;/\"/g;s/&amp;apos;/'/g;s/&amp;lt;/</g;s/&amp;gt;/>/g" | sed 's/&amp;/\&/g' ) > dump.lua



is the code to get the source code form the xml file of a lua program coded using oclua (TI-Notepad) :D
« Last Edit: September 26, 2011, 01:38:23 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Adriweb

  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1708
  • Rating: +229/-17
    • View Profile
    • TI-Planet.org
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #67 on: September 26, 2011, 01:23:17 pm »
nice !

Making a third-party SDK for reading/writing .tns is getting closer I think :P

Might not be done at all, but it could have a great potential, I'm sure....
My calculator programs
TI-Planet.org co-admin.
TI-Nspire Lua programming : Tutorials  |  API Documentation

Offline Chockosta

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 447
  • Rating: +169/-6
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #68 on: September 26, 2011, 01:56:15 pm »
Amazing ! I'm going to use this a lot !
Thank you very much.

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #69 on: September 27, 2011, 05:42:54 am »
Luna v0.2a is now available with several bug fixes. Sorry for this unable v0.2.
http://ndlessly.wordpress.com/2011/09/27/luna-bug-fixes/
Ndless.me with the finest TI-Nspire programs

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #70 on: September 27, 2011, 09:57:15 am »
Luna v0.2a is now available with several bug fixes. Sorry for this unable v0.2.
http://ndlessly.wordpress.com/2011/09/27/luna-bug-fixes/

Do you plan to include a Linux and a Mac build the next time (or does this one already feature it)? For people who can't build one themselves, it'd be neat.

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #71 on: September 27, 2011, 12:28:39 pm »
Luna v0.2a is now available with several bug fixes. Sorry for this unable v0.2.
http://ndlessly.wordpress.com/2011/09/27/luna-bug-fixes/

Do you plan to include a Linux and a Mac build the next time (or does this one already feature it)? For people who can't build one themselves, it'd be neat.

You should specify which Linux distro and which Mac version... cuze Windows is AFAIK the only one where it is "hard" to compile and where a compiled *.exe is the same for everyone.
Don't you think ?
« Last Edit: September 27, 2011, 12:29:20 pm by Levak »
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Cuervo

  • LV2 Member (Next: 40)
  • **
  • Posts: 33
  • Rating: +2/-1
    • View Profile
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #72 on: September 27, 2011, 01:12:50 pm »
Here's the Mac OS X Version (x86 and x86_64) of Luna 0.2a (EDIT: b). I don't want to compile a PowerPC-version.

EDIT: All download links here:
0.1 (x86, x86_64): http://www.fanofblitzbasic.de/download.php?dlid=LunaMacOSX
0.2 (x86, x86_64, ppc): http://www.fanofblitzbasic.de/download.php?dlid=LunaMacOSX02
0.2a (x86, x86_64): http://www.fanofblitzbasic.de/download.php?dlid=LunaMacOSX02a
0.2b (x86, x86_64): http://www.fanofblitzbasic.de/download.php?dlid=LunaMacOSX02b

@ExtendeD:
Please try if my Makefile also works on Windows, if it does, please use it instead of your Makefile. It's the only thing that needs to be changed to compile Luna on Mac OS X.

@Levak:
Nope, the x86-Version should work on any Mac with an Intel processor (built since 2005/2006, should run on Mac OS X >= 10.4), I only provide a x86_64 version for those who really want to use 64-Bit (which should have no effect on Luna^^)


Cuervo
« Last Edit: November 11, 2011, 02:19:53 pm by Cuervo »

Offline Levak

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +208/-39
    • View Profile
    • My website
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #73 on: September 27, 2011, 01:19:10 pm »
@Levak:
Nope, the x86-Version should work on any Mac with an Intel processor (built since 2005/2006, should run on Mac OS X >= 10.4), I only provide a x86_64 version for those who really want to use 64-Bit (which should have no effect on Luna^^)

Mac has changed ? :o
Ok, troll off :D
I do not get mad at people, I just want them to learn the way I learnt.
My website - TI-Planet - iNspired-Lua

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: "Luna" is here and converts your .lua files into 3.0.2-compatible .tns files
« Reply #74 on: September 27, 2011, 01:33:13 pm »
On Linux, only static builds might solve the heterogeneity, but it's not very good to use static builds.
Member of the TI-Chess Team.
Co-maintainer of GCC4TI (GCC4TI online documentation), TILP and TIEmu.
Co-admin of TI-Planet.