Author Topic: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library  (Read 142906 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: SDL for the TI-Nspire
« Reply #15 on: February 10, 2012, 03:18:04 am »
This is good to hear Hoffa :)

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: SDL for the TI-Nspire
« Reply #16 on: February 10, 2012, 07:36:17 am »
Great job hoffa I can't wait to see what comes of this. I'll also have to move my one simple SDL program over to the nspire. How much code change is needed to go from a program written in C++ for a computer to working with the calc?
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: SDL for the TI-Nspire
« Reply #17 on: February 10, 2012, 07:52:48 am »
Well, Ndless is focusing on C, but you can get a C++ compiler to work: http://blog.tangrs.id.au/?p=712 .
If the program only uses SDL libraries and hoffa finished this one, it should compile fine without any changes. (I think)

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: SDL for the TI-Nspire
« Reply #18 on: February 10, 2012, 08:16:12 am »
thanks jimbauwens I forgot that ndless was mainly for C :P
And I actually will still need to know if this will work on a regular nspire. I dont have a CX :(
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline Jim Bauwens

  • Lua! Nspire! Linux!
  • Editor
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1881
  • Rating: +206/-7
  • Linux!
    • View Profile
    • nothing...
Re: SDL for the TI-Nspire
« Reply #19 on: February 10, 2012, 09:10:51 am »
It should work on any Nspire, if hoffa does it correctly (and I don't doubt that) :)

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: SDL for the TI-Nspire
« Reply #20 on: February 11, 2012, 08:04:18 am »
I think I've finally--after many smashed walls, headaches and a bucket of aspirin--narrowed down one major issue.

Have this piece of code for instance:
Code: [Select]
#include <os.h>

typedef struct type1_t {
    const char *s;
} type1_t;

typedef struct type2_t {
    const char *s1;
    const char *s2;
} type2_t;

int main(void) {
    type1_t test1 = {"foobar"};
    type2_t test2 = {"foo", "bar"};
    printf("test1.s: %s\n", test1.s); /* Prints "foobar" */
    printf("test2.s1: %s\n", test2.s1); /* Should print "foo"; doesn't */
    printf("test2.s2: %s\n", test2.s2); /* Should print "bar"; doesn't */
    return 0;
}

As you can read, the output is:
test1.s: foobar
test2.s1:
test2.s2:

Which is completely wrong. Here's what the output obviously should be: http://codepad.org/DQcGIFy3

I think this might be one of those ARM struct alignment issues, or possibly some other bug. Either way, it has kept me from advancing with the port.
Any input on this one, ExtendeD? (or others, if you know what might be causing the problem)
« Last Edit: February 11, 2012, 08:14:14 am by hoffa »

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: SDL for the TI-Nspire
« Reply #21 on: February 11, 2012, 09:47:03 am »
Well on my side it outputs:

Code: [Select]
test1.s: foobar
test2.s1: foo
test2.s2: bar

Which version of GCC are you using? On which OS?
Can you also post the content of the .s file generated with nspire-gcc -S <your.c>?
« Last Edit: February 11, 2012, 09:52:06 am by ExtendeD »
Ndless.me with the finest TI-Nspire programs

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: SDL for the TI-Nspire
« Reply #22 on: February 11, 2012, 10:01:20 am »
This is very weird, not the first time only I have the issues.

Here's the assembly code: http://pastebin.com/2Giv2ScW

I also attached a TNS that doesn't print the values.

EDIT:
Windows 7 x64 and Yagarto that uses the following versions:
binutils: 2.21
gcc:      4.6.2
newlib:   1.19.0
gdb:      7.3.1
« Last Edit: February 11, 2012, 10:03:52 am by hoffa »

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: SDL for the TI-Nspire
« Reply #23 on: February 11, 2012, 10:38:07 am »
My .s is identical. Strangely using nspire-as on the .s file reproduces the error on my side.
I see:
.LC2:
   .word   .LC0
   .word   .LC1
Which is not good, GCC doesn't make it relocatable by Ndless.

I'm afraid you will have to use something like this:

Code: [Select]
int main(void) {
    type1_t test1 = {"foobar"};
    type2_t test2 = {"foo", "bar"};
    nl_relocdata((unsigned*)&test2.s1, 1);
    nl_relocdata((unsigned*)&test2.s2, 1);
    printf("test1.s: %s\n", test1.s); /* Prints "foobar" */
    printf("test2.s1: %s\n", test2.s1); /* Should print "foo"; doesn't */
    printf("test2.s2: %s\n", test2.s2); /* Should print "bar"; doesn't */
    return 0;
}

See http://hackspire.unsads.com/wiki/index.php/Ndless_features_and_limitations#Global_variables_and_initialization .

How much is this a problem in your case?
If it is too annoying I will then  have to integrate tangrs's ELF loader with its drawbacks.
Ndless.me with the finest TI-Nspire programs

Offline hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: SDL for the TI-Nspire
« Reply #24 on: February 11, 2012, 10:57:24 am »
I see. But how come then that you were able to see the strings?

It does work now, but I'm afraid it will make the porting process a rather "hacky" and dirty one, with #if directives everywhere (breaking the clean code and flexibility) as SDL does rely quite a lot on structs. The code is not that simple in SDL as in the example, so the result might be spaghetti code. For now I'll try to see how it goes with nl_relocdata, if the code becomes an ugly mess I'll tell you. Thanks anyway for pointing out that fix, it'll be useful.

What are the drawbacks of using the ELF loader?

Offline ExtendeD

  • CoT Emeritus
  • LV8 Addict (Next: 1000)
  • *
  • Posts: 825
  • Rating: +167/-2
    • View Profile
Re: SDL for the TI-Nspire
« Reply #25 on: February 11, 2012, 11:01:18 am »
According to tangrs the program size seems rather random, sometimes very big.
And this would require maintaining a much more complex program loader than the current one.
Ndless.me with the finest TI-Nspire programs

Offline alberthrocks

  • Moderator
  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 876
  • Rating: +103/-10
    • View Profile
Re: SDL for the TI-Nspire
« Reply #26 on: February 11, 2012, 11:03:58 am »
BLFT is also another possible option, if that may help with making SDL port work.
Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/


Proud member of ClrHome!

Miss my old signature? Here it is!
Spoiler For Signature:
Alternate "New" IRC post notification bot (Newy) down? Go here to reset it! http://withg.org/albert/cpuhero/

Withgusto Networks Founder and Administrator
Main Server Status: http://withg.org/status/
Backup Server Status: Not available
Backup 2/MC Server Status: http://mc.withg.org/status/

Activity remains limited due to busyness from school et al. Sorry! :( Feel free to PM, email, or if you know me well enough, FB me if you have a question/concern. :)

Don't expect me to be online 24/7 until summer. Contact me via FB if you feel it's urgent.


Proud member of ClrHome!

Spoiler For "My Projects! :D":
Projects:

Computer/Web/IRC Projects:
C______c: 0% done (Doing planning and trying to not forget it :P)
A_____m: 40% done (Need to develop a sophisticated process queue, and a pretty web GUI)
AtomBot v3.0: 0% done (Planning stage, may do a litmus test of developer wants in the future)
IdeaFrenzy: 0% done (Planning and trying to not forget it :P)
wxWabbitemu: 40% done (NEED MOAR FEATURES :P)

Calculator Projects:
M__ C_____ (an A____ _____ clone): 0% done (Need to figure out physics and Axe)
C2I: 0% done (planning, checking the demand for it, and dreaming :P)

Offline Lionel Debroux

  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2135
  • Rating: +290/-45
    • View Profile
    • TI-Chess Team
Re: SDL for the TI-Nspire
« Reply #27 on: February 11, 2012, 11:04:07 am »
ELF is a very complicated format, so an ELF loader is a complicated piece of software :(

bFLT ( http://www.uclinux.org/bFLT/ , http://retired.beyondlogic.org/uClinux/bflt.htm ) is much simpler a format, which was suggested a number of times since the introduction of Ndless 1.0 nearly two years ago.
I once opened the source code of Linux kernel's bFLT loader ( https://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=fs/binfmt_flat.c;hb=HEAD ). It needs some porting to work outside the Linux kernel environment :)

EDIT: heh, I see alberthro beat me by mere seconds to mentioning bFLT :D
EDIT2: added a note.
EDIT3: added link to Linux's bFLT loader.
« Last Edit: February 11, 2012, 11:17:19 am 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 hoffa

  • Project Author
  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 304
  • Rating: +131/-13
    • View Profile
Re: SDL for the TI-Nspire
« Reply #28 on: February 11, 2012, 11:08:35 am »
I will rely on nl_relocdata as long as possible then; the advantages of keeping the ELF loader away outweigh the advantages of integrating it. But we'll see how it turns out after a few lines of code.

Offline lkj

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 485
  • Rating: +58/-1
    • View Profile
Re: SDL for the TI-Nspire
« Reply #29 on: February 11, 2012, 11:26:31 am »
EDIT:
Windows 7 x64 and Yagarto that uses the following versions:
binutils: 2.21
gcc:      4.6.2
newlib:   1.19.0
gdb:      7.3.1

For me the program works, also windows7 x64, but yagarto with gcc 4.6.0 and gdb 7.2.