Omnimaga

Calculator Community => Discontinued => Major Community Projects => nSDL => Topic started by: hoffa on January 23, 2012, 06:18:44 am

Title: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on January 23, 2012, 06:18:44 am
SDL (http://www.libsdl.org/) for the TI-Nspire

nSDL is a port of the widely used, cross-platform and open source SDL graphics library for the Ndless-fueled TI-Nspire.

nSDL 1.1.1 is here! Click here (http://ourl.ca/14975/336602) for the new updates.

To download the latest nSDL build and access the wiki, check out the nSDL website (http://hoffa.github.com/nSDL/).

nSDL also has its own little wiki, which you can access by clicking here (https://github.com/Hoffa/nSDL/wiki).

nSDL features:

(http://i.imgur.com/JKGzx.png) (http://i.imgur.com/1XoSd.png)
(http://i.imgur.com/ltvwD3U.png) (http://i.imgur.com/YlB2gym.png)
(http://i.imgur.com/jNLLz.png) (http://i.imgur.com/V6KWP.png)
(http://i.imgur.com/ONKjZ.png) (http://i.imgur.com/wO9NE9z.gif)

Links:
Title: Re: SDL for the TI-Nspire
Post by: Adriweb on January 23, 2012, 06:42:14 am
Awesome [huge] project !

Good Luck and Have fun :)

(Aslo, Are you going to put it on GitHub or so as you're programming it ?)
Title: Re: SDL for the TI-Nspire
Post by: Juju on January 23, 2012, 06:44:38 am
That would be pretty awesome and useful, good luck :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on January 23, 2012, 06:48:24 am
Aslo, Are you going to put it on GitHub or so as you're programming it ?
Yeah probably, but I'll set it up once I have something more concrete done.
https://github.com/Hoffa/TI-Nspire-SDL (https://github.com/Hoffa/TI-Nspire-SDL)
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on January 23, 2012, 07:37:26 am
Nice :)

But as said before, Albert and totorigolo are also busy with an SDL port.
Maybe you should contact them, and eventually work together?
Title: Re: SDL for the TI-Nspire
Post by: hoffa on January 23, 2012, 07:54:08 am
Nice :)

But as said before, Albert and totorigolo are also busy with an SDL port.
Maybe you should contact them, and eventually work together?
But I thought you said (or whoever it was) that they were "looking" at it, from which I concluded they weren't actually writing any code.
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on January 23, 2012, 09:06:46 am
Well, they both were seriously planning on making it, and there is a chance they already coded stuff.
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on January 23, 2012, 04:01:14 pm
I think totorigolo was busy with nRGBlib and hasn't started much work on it.

Good luck hoffa with your project. Don't hesitate to ask if you need Ndless to provide anything currently not available.
Title: Re: SDL for the TI-Nspire
Post by: alberthrocks on January 23, 2012, 06:14:03 pm
Indeed I am! :) In fact, ExtendeD approached me via email and mentioned that he'd like to combine efforts to make a port of SDL. (Or as I like to term it, nSDL!)
(ExtendeD, I'm attempting to finish an email to you regarding future plans...)

Here's my plan - it has changed a little bit, but it should convey the point anyway:
(http://dl.dropbox.com/u/1016340/PublicPictures/ndless3FutureAPI.png)

The change I've mentioned? Having nDraw or not. Basically, nDraw would handle the important thing - the layers. In SDL, having a fullscreen window is equivalent to writing directly to the screen buffer. If you wanted to use the hardware mouse in the CX, it must be drawn as a window/layer.

HOWEVER... I could implement it SDL so that full screen means a window/layer. It all depends...
We should really combine efforts, since creating 3 incarnations of nSDL is going to be painful and pointless... :P
Title: Re: SDL for the TI-Nspire
Post by: hoffa on January 23, 2012, 06:30:04 pm
Seems good, except I'm not sure if prematurely combining nonexistent libraries into one big group is a good idea. It would somehow feel like the beginning of a massive bloated library (no as in Java obviously, it's all relative) where everybody's dealing with about everything and no one's doing anything meticulously well. A library like SDL would be the foundation structure of other programs, and the said library should be like a razor sharp knife. It should be robust, clean, flexible while at the same time faster than the speed of light. I don't mind combining efforts, but I prefer to avoid it being included in some set with other libraries.
Title: Re: SDL for the TI-Nspire
Post by: DJ Omnimaga on January 23, 2012, 06:45:26 pm
This seems interesting. I don't understand much what this is though, so I can't give much feedback, although if that makes calc games dev easier, this is great :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 01, 2012, 06:56:37 am
Got SDL to run on the calculator. Now that it does, I can start doing the more serious things.

(http://i.imgur.com/s6N3q.png)
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on February 01, 2012, 07:50:04 am
Good :)
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on February 01, 2012, 08:12:58 am
Indeed, very nice :)
Title: Re: SDL for the TI-Nspire
Post by: njaddison on February 09, 2012, 08:22:14 am
I found out that SDL can be used to run flash programs. So, we can play flash games on the nspire! They will have to be decompiled first, though.

Edit:
What the f***!
Somebody just randomly downrated my post! If there isn't any possible way flash can be ported to the nspire, then I am officially dumb!! Which in that case, I am smart, but I have no common sense.

Seriously, can't you have some imagination, people? I am learning more and more about my nspire every day, and the way I learn things is by asking questions, some are dumb questions, and by being corrected when I suggest something that can't be done! So please cut me some slack! I haven't been this angry since my friend put a pressure plate in front of my door in minecraft, letting mobs come into my house!!!!

I am a nice person, and I would never downrate someone's post, no matter how dumb it is. If anything, I would press the like button, and then tell them their mistake without being mean to them. But you guys are not me! So please put yourself in my shoes, and see how I feel (but plug your nose: my shoes stink).
Title: Re: SDL for the TI-Nspire
Post by: DJ Omnimaga on February 10, 2012, 03:18:04 am
This is good to hear Hoffa :)
Title: Re: SDL for the TI-Nspire
Post by: ruler501 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?
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens 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)
Title: Re: SDL for the TI-Nspire
Post by: ruler501 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 :(
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens 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) :)
Title: Re: SDL for the TI-Nspire
Post by: hoffa 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 (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)
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD 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>?
Title: Re: SDL for the TI-Nspire
Post by: hoffa 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 (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
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD 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.
Title: Re: SDL for the TI-Nspire
Post by: hoffa 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?
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD 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.
Title: Re: SDL for the TI-Nspire
Post by: alberthrocks on February 11, 2012, 11:03:58 am
BLFT is also another possible option, if that may help with making SDL port work.
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux 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.
Title: Re: SDL for the TI-Nspire
Post by: hoffa 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.
Title: Re: SDL for the TI-Nspire
Post by: lkj 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.
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on February 11, 2012, 11:34:21 am
You should switch to GCC 4.6.2, lkj: all "x.y.0" releases of GCC contain quite a few significant bugs :)
(though the last major disaster "x.y.0" release was GCC 4.0.0, i.e. years ago)
Title: Re: SDL for the TI-Nspire
Post by: lkj on February 11, 2012, 12:26:51 pm
I never saw any bug, but I switched as you suggested.
I thought updating would be as complicated as setting up the ndless-SDK, but it was very easy :)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 11, 2012, 01:20:19 pm
Could somebody quickly check my code, it doesn't seem to print the value of f. Either I'm using nl_relocdata wrong, or then I'm too tired and am missing something silly.

http://pastebin.com/N2iiUhd1 (http://pastebin.com/N2iiUhd1)

That's more or less how SDL behaves at one point, and it's reallocating the function pointer that causes issues. The strings print out fine, calling the function doesn't work though.

EDIT: I've tried everything I can think of. Am I really missing something here or is there no way to use nl_relocdata on a pointer to a function? (I doubt it, even in the wiki it is mentioned)
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on February 12, 2012, 06:25:10 am
Things are getting complicated in your case, nl_relocdata was introduced to handle simpel cases, sorry about that.

I unfortunately cannot test them on this computer, but here are a few corrections:

- nl_relocdata((unsigned int *)bootstrap, sizeof(bootstrap) / sizeof(bootstrap[0]));: I'm not sure relocating NULL is a good idea. Use nl_relocdata((unsigned int *)bootstrap, 1); instead.
- nl_relocdata((unsigned int *)bootstrap[0]->fp, sizeof(void *));: Use nl_relocdata((unsigned int *)bootstrap[0]->fp, 1);

But anyway I'm not sure this will fix your error, I'll look further into this as soon as possible.
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 12, 2012, 06:56:42 am
Thanks, but it unfortunately did not fix it. What exactly does size refer to--what size does it refer to (in bytes I presume)? I'll experiment around a bit, but if there is no solution yet I will kindly wait for any future developments.

EDIT:
What do you mean relocating NULL? bootstrap is not NULL, nor is the quotient equal to zero.
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on February 12, 2012, 07:17:16 am
But bootstrap contains a NULL value, I'm not sure I'm skipping NULL values.

nl_relocdata relocates an array of pointers (it should work as well on entire structures containing only pointers). The second parameter corresponds to the number of pointers to relocate.
Title: Re: SDL for the TI-Nspire
Post by: alberthrocks on February 12, 2012, 12:02:17 pm
Hmm... how hard will it be to write a BLFT loader? It seems that this project (and possibly many others) might need one.
It has code relocation and is much smaller than the ELF loader.

(If it isn't too hard, I might attempt to write one :P Seems that one would need to know ARM ASM to do it... which I don't know)
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on February 12, 2012, 01:06:14 pm
Lionel Debroux has just started a port of the Linux implementation, he will post more about it.
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on February 12, 2012, 01:38:30 pm
I have indeed started looking at what pieces need to be changed for porting Linux's bFLT loader (fs/binfmt_flat.c + include/linux/flat.h + arch/arm/include/asm/flat.h) to non-Linux OS running on the Nspire. And a quick examination (<1h) shows dozens of places that need to be adjusted; it's not necessarily very hard to do so, for the most part, it's just that someone needs to spend time doing it, and I don't have time to undertake such a task alone - for a start, not this evening.

ExtendeD has suggested looking at QEMU's loader (linux-user/flatload.c), which looks slightly more portable than Linux's loader. It remains quite tied to Linux/QEMU internals, and may or may not be a better starting point than Linux's loader: unlike Linux's loader, QEMU's loader's support for compressed binaries and for libraries is explicitly disabled - and we clearly want both, probably with a higher priority on libraries. Support for compressed bFLT binaries wouldn't cost much space in the loader, since we can (well, "ought to be able to") rely on the zlib functions embedded in the OS.

Quote
Seems that one would need to know ARM ASM to do it
I doubt that it's necessary: AFAICT, the bFLT loaders in Linux and QEMU are plain C :)


EDIT: here's the current state of the stuff. As you can see, I haven't changed the code yet, and won't do tonight. The tarball is made of five files:
* binfmt_flat_mod.c is Linux's bFLT loader, annotated with a bunch of TODOs on parts that we need to remove or port;
* binflt_flat.diff is the diff against the pristine file;
* the two headers are include/linux/flat.h and arch/arm/include/asm/flat.h;
* flatload.c is QEMU's bFLT loader.
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on February 14, 2012, 03:40:59 pm
Could somebody quickly check my code, it doesn't seem to print the value of f. Either I'm using nl_relocdata wrong, or then I'm too tired and am missing something silly.

http://pastebin.com/N2iiUhd1 (http://pastebin.com/N2iiUhd1)

That's more or less how SDL behaves at one point, and it's reallocating the function pointer that causes issues. The strings print out fine, calling the function doesn't work though.

EDIT: I've tried everything I can think of. Am I really missing something here or is there no way to use nl_relocdata on a pointer to a function? (I doubt it, even in the wiki it is mentioned)

Here it is fixed: http://pastebin.com/ELBkWJMt
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 15, 2012, 10:50:55 am
Oh wow, thanks. I'm quite surprised as I tried the same code as you except without the &-operator; I thought prefixing a function name with the ampersand was optional, both should return the address of the said function AFAIK.

EDIT:
This is great news as I'm now able to initialize the barebone video driver:

(http://i.imgur.com/muODp.png)
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on February 15, 2012, 12:32:16 pm
Good :)

Here the address of the field that contains the function pointer is expected, so the & is required.
Title: Re: SDL for the TI-Nspire
Post by: ExtendeD on February 15, 2012, 12:48:09 pm
Good :)

Here the address of the field that contains the function pointer is expected, so the & is required.
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on February 15, 2012, 04:38:25 pm
Nice to see the progress!
Title: Re: SDL for the TI-Nspire
Post by: DJ Omnimaga on February 15, 2012, 11:48:27 pm
Good to hear hoffa. Hopefully this gets finished eventually. :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 16, 2012, 01:05:57 pm
I'm now able to fill the screen (which by itself isn't too amazing, but it does prove that the underlying stuff works) and update it (and update any part of the screen for that matter, although with a solid-colored surface it's hard to tell if it works as it should). This is where I'll leave it for a week, going to the French alps tomorrow; gotta pack my skiing gear.

(http://i.imgur.com/1Qr1h.png)
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on February 16, 2012, 01:18:27 pm
Good :)

Make sure to make a backup before leaving ;)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 28, 2012, 11:38:09 am
Alrighty back from the mountains, I can resume the work. It seems that the current code works well when it comes to drawing rectangles and updating specific parts of the screen, which is great. This might mean drawing sprites (and more generally, BMP images) will work without having to do too much work.

(http://i.imgur.com/7TIZI.png)
Title: Re: SDL for the TI-Nspire
Post by: alberthrocks on February 28, 2012, 04:00:39 pm
...you don't know how much I'm loving you for this! :D Keep up the great work! :D

Just a few questions:
1) Are you using any loaders or none at all? (If none, that's pretty amazing O_O)
2) What portions of the SDL API are you planning to implement? (Sound is possible if you output to certain ports - not conventional sound, unfortunately - you'd have to connect speakers to some dock pins :P) I suggest implementing SDL_DisplayFormat() so I can port one of my SDL apps rather easily. ;) (That one is actually pretty simple - it copies the format of the surface specified in the argument, and creates a new one from it.)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on February 28, 2012, 04:28:31 pm
1) None currently, but it's sometimes a bit of a mystery to know whether or not a certain issue is caused by global variables (e.g. I'm currently unable to blit BMPs although reading and loading seems to be working; it takes quite a bit of time to go through the code always having in mind the problem might not be caused by the code itself).

2) Video, events, timers and input (i.e. "joystick") are the main things I'm planning to implement. I haven't looked at audio, but it's not impossible that it'll also be included. EDIT: SDL_image and SDL_gfx shouldn't be too difficult to port.

SDL_DisplayFormat is a practically platform-independent function, so it should already work.
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on February 29, 2012, 06:50:25 am
Nice progress!
Title: Re: SDL for the TI-Nspire
Post by: calc84maniac on February 29, 2012, 08:23:16 am
Once we get a firm grasp on the USB hardware (apparently BrandonW is getting really close) it might be a good idea to try supporting USB audio.
Title: Re: SDL for the TI-Nspire
Post by: Adriweb on February 29, 2012, 09:30:23 am
Once we get a firm grasp on the USB hardware (apparently BrandonW is getting really close) it might be a good idea to try supporting USB audio.
Great !
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on February 29, 2012, 12:49:09 pm
That's indeed great news :)
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on February 29, 2012, 01:17:52 pm
Good progress, as usual ;)


I have barely touched the bFLT loader code since I posted in reply #38 of this topic, in that the changes since reply #38 are trivial:
Code: [Select]
--- old/binfmt_flat_mod.c       2012-02-12 20:25:14.000000000 +0100
+++ binfmt_flat.c       2012-02-14 18:54:14.624405087 +0100
@@ -15,40 +15,12 @@
  *     JAN/99 -- coded full program relocation ([email protected])
  */
 
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/sched.h>
-#include <linux/mm.h>
-#include <linux/mman.h>
-#include <linux/errno.h>
-#include <linux/signal.h>
-#include <linux/string.h>
-#include <linux/fs.h>
-#include <linux/file.h>
-#include <linux/stat.h>
-#include <linux/fcntl.h>
-#include <linux/ptrace.h>
-#include <linux/user.h>
-#include <linux/slab.h>
-#include <linux/binfmts.h>
-#include <linux/personality.h>
-#include <linux/init.h>
-#include <linux/flat.h> // This and arch/arm/include/asm/flat.h contain interesting stuff.
-#include <linux/syscalls.h>
-
-#include <asm/byteorder.h>
-#include <asm/system.h>
-#include <asm/uaccess.h>
-#include <asm/unaligned.h>
-#include <asm/cacheflush.h>
-#include <asm/page.h>
-
 /****************************************************************************/
 
 // Until the code has production status...
 #define DEBUG 1
 
-// We'll probably want both compressed files, and bFLT libraries
+// We want both compressed files, and bFLT libraries
 #define CONFIG_BINFMT_ZFLAT
 #define CONFIG_BINFMT_SHARED_FLAT
 
@@ -96,27 +68,6 @@
 static int load_flat_binary(struct linux_binprm *, struct pt_regs * regs);
 static int flat_core_dump(struct coredump_params *cprm);
 
-// TODO REMOVE Linux-specific
-static struct linux_binfmt flat_format = {
-       .module         = THIS_MODULE,
-       .load_binary    = load_flat_binary,
-       .core_dump      = flat_core_dump,
-       .min_coredump   = PAGE_SIZE
-};
-
-/****************************************************************************/
-/*
- * Routine writes a core dump image in the current directory.
- * Currently only a stub-function.
- */
-// TODO REMOVE Linux-specific
-static int flat_core_dump(struct coredump_params *cprm)
-{
-       printk("Process %s:%d received signr %d and should have core dumped\n",
-                       current->comm, current->pid, (int) cprm->signr);
-       return(1);
-}
-
 /****************************************************************************/
 /*
  * create_flat_tables() parses the env- and arg-strings in new user
@@ -550,10 +501,8 @@
                 */
                DBG_FLT("BINFMT_FLAT: ROM mapping of file (we hope)\n");
 
-               down_write(&current->mm->mmap_sem); // TODO REMOVE
                textpos = do_mmap(bprm->file, 0, text_len, PROT_READ|PROT_EXEC,
                                  MAP_PRIVATE|MAP_EXECUTABLE, 0); // TODO PORT we'll probably read everything to RAM
-               up_write(&current->mm->mmap_sem); // TODO REMOVE
                if (!textpos || IS_ERR_VALUE(textpos)) {
                        if (!textpos)
                                textpos = (unsigned long) -ENOMEM;
@@ -564,10 +513,8 @@
 
                len = data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
                len = PAGE_ALIGN(len);
-               down_write(&current->mm->mmap_sem); // TODO REMOVE
                realdatastart = do_mmap(0, 0, len,
                        PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE, 0); // TODO PORT we'll probably copy everything to RAM
-               up_write(&current->mm->mmap_sem); // TODO REMOVE
 
                if (realdatastart == 0 || IS_ERR_VALUE(realdatastart)) {
                        if (!realdatastart)
@@ -611,10 +558,8 @@
 
                len = text_len + data_len + extra + MAX_SHARED_LIBS * sizeof(unsigned long);
                len = PAGE_ALIGN(len);
-               down_write(&current->mm->mmap_sem); // TODO REMOVE
                textpos = do_mmap(0, 0, len,
                        PROT_READ | PROT_EXEC | PROT_WRITE, MAP_PRIVATE, 0); // TODO PORT we'll probably read everything to RAM
-               up_write(&current->mm->mmap_sem); // TODO REMOVE
 
                if (!textpos || IS_ERR_VALUE(textpos)) {
                        if (!textpos)
@@ -962,16 +907,3 @@
 
        return 0;
 }
-
-/****************************************************************************/
-// TODO REMOVE Linux-specific
-static int __init init_flat_binfmt(void)
-{
-       return register_binfmt(&flat_format);
-}
-
-/****************************************************************************/
-
-core_initcall(init_flat_binfmt);
-
-/****************************************************************************/

As I wrote above:
Quote
and I don't have time to undertake such a task alone - for a start, not this evening.
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 01, 2012, 02:15:12 pm
I wrote an early version of the joystick input driver (i.e. the TI-Nspire's keypad works as a SDL "joystick"). I behaves a bit weird with SDL_PollEvent (endless events once the first one is fired), but with SDL_WaitEvent it seems to be behaving as it should. It has two axes obviously (left/right and up/down) and 24 buttons (only the most used ones are currently included). No hats, but the touchpad could be used as a joystick trackball though. Anyway if you want to try it out yourself grab the tinspire_test/tinspire_test.tns on github, you should be able to paint the screen using the arrow keys and exit using esc. Check the tinspire_test.c (https://github.com/Hoffa/TI-Nspire-SDL/blob/master/tinspire_test/tinspire_test.c) file if you want to see what the code looks like (it's a big SDL hell though, I just quickly add code to test it).

(http://i.imgur.com/d5i93.png)

BTW, should the joystick fire events as long as an arrow key is pressed or should it just fire the very first one? The former seems more logical to me when it's about joysticks.
Title: Re: SDL for the TI-Nspire
Post by: Jim Bauwens on March 01, 2012, 02:46:32 pm
Again, nice work :)
Title: Re: SDL for the TI-Nspire
Post by: njaddison on March 01, 2012, 11:23:33 pm
The ti-nspire test file reboots my nspire when I open it!
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 02, 2012, 01:17:11 am
You're trying it on the classical TI-Nspire I suppose (and hope)? I forgot to mention it but I'm only working on the CX right now (the classical one is another story because of its annoying 4-bit pixels, which requires some special care), and as such it should only work on that calculator (which, funnily enough, I do not own; relying fully on the emulator).

EDIT: I'd appreciate it if somebody could check if the TNS (https://github.com/Hoffa/TI-Nspire-SDL/blob/master/tinspire_test/tinspire_test.tns) works as it should on their physical CX. :)
Title: Re: SDL for the TI-Nspire
Post by: atiatinini on March 02, 2012, 01:53:50 pm
It works, but the loading cursor (the one that looks like a clock) keeps flashing on the screen when pressing the touchpad and sometimes the program freezes for some seconds.
But very nice work!  :)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 02, 2012, 04:29:33 pm
Thanks for the information! I think the freezes and clock icon appearing might be caused by some issues with the input code that sends a gazillion events (and needs fixing), or then by the main loop that runs too fast (or, in the worst case, too slow). Seems like I'll have to slowly start writing the non-CX graphics code so I can myself try it on my Touchpad so as to see how it runs.

Anyway, I added "classical" SDL events (those SDLK_* things for instance) which took quite a bit of time for the keymaps and whatnot, but again it behaves a bit weird with SDL_PollEvent.

EDIT: SDL doesn't seem to handle 4-bit color at all, which is a bit trickier. I think I'll have to pretend it's an 8 BPP display and just before copying to the framebuffer pack it in 4 bits or something.
Title: Re: SDL for the TI-Nspire
Post by: atiatinini on March 02, 2012, 06:44:18 pm
Hmmm, tried the new tinspire_test.tns and it reboots my CX..
Is it supposed to?

EDIT: Nevermind, just saw it tries to load a bmp image in /Examples. It's working better now, but the pink cursor no more moves continuously when holding a key.
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 02, 2012, 07:00:14 pm
It shouldn't, no. Weird, works very well on the emulator.
It's still some early code though, I haven't thoroughly tested it (and more generally, the tinspire_test.tns on github doesn't necessarily have to work; I just push the changes when I feel like it). I think I'll write the video driver for non-CX first so that I have a better idea of the behavior on both machines.
Thanks again anyway, I'll look into it more tomorrow.

EDIT: It does try to load a BMP, but I don't think it should stop it from running, as it just returns NULL and moves on. It's normal that it doesn't work when holding the key, that's how events work in SDL. SDL_EnableKeyRepeat() should enable that behavior though, but I'm not entirely sure if it works currently as I haven't fully implemented the timers system (in fact there's only SDL_Delay()).
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 03, 2012, 06:38:36 pm
Seems like getting it working on the classical TI-Nspire has been more difficult than I thought. I can feel I'm pretty to close to getting it run, but those palettes, 4-bit pixels and whatnot have been a pain in the ass. This is the sort of thing I've been looking at for the last few hours:
(http://i.imgur.com/yOKrl.png)
Figuring out the cause of the issue is also always a major buttpain. Even more annoying is to go to sleep and leave it in its current state.

Anyway, on a side note, that whole Ndless-being-blocked-in-3.2 thing gave me quite a blow to the head. I have to admit I'm pretty fucking frustrated; I expected it but didn't think it'd come this quickly. Right now I feel like the work I'm doing is completely useless, and realistically speaking it is. It may take a month (or more) to have a first more or less stable version of SDL, from then on it takes time for people to learn the library/port programs. At that time 3.2 will be out, it'll be the shiny new thing and 3.1 will be outdated. Even I won't feel like staying on an "old" platform developing for a tiny minority. Even if I'd like to, I can't, as I'm getting my ass conscripted for about a year in the Finnish Army (yes I'm Finnish and we have conscription), and after that I'm moving to the UK for my university studies. There I will hardly ever use my TI-Nspire and will most probably develop on other platforms. I will try to finish this thing even for the sake of it (and to be able to add "ported SDL to a calculator" on my CV). Just realized it'll possibly be my last project on a calculator, but we'll see how it eventually turns out.
Title: Re: SDL for the TI-Nspire
Post by: alberthrocks on March 03, 2012, 06:45:57 pm
Anyway, on a side note, that whole Ndless-being-blocked-in-3.2 thing gave me quite a blow to the head. I have to admit I'm pretty fucking frustrated; I expected it but didn't think it'd come this quickly. Right now I feel like the work I'm doing is completely useless, and realistically speaking it is. It may take a month (or more) to have a first more or less stable version of SDL, from then on it takes time for people to learn the library/port programs. At that time 3.2 will be out, it'll be the shiny new thing and 3.1 will be outdated. Even I won't feel like staying on an "old" platform developing for a tiny minority. Even if I'd like to, I can't, as I'm getting my ass conscripted for about a year in the Finnish Army (yes I'm Finnish and we have conscription), and after that I'm moving to the UK for my university studies. There I will hardly ever use my TI-Nspire and will most probably develop on other platforms. I will try to finish this thing even for the sake of it (and to be able to add "ported SDL to a calculator" on my CV). Just realized it'll possibly be my last project on a calculator, but we'll see how it eventually turns out.
:(

Well, it's great that you *are* finishing this up, so that we'll have something to work upon in the future. Heck, I think you might revive the Ndless community with this! ;) Once ports of many famous games are made, this will get more popular and TI will be pressured more to stop being silly... **

I can't believe I'm saying this, but the one platform that seems stable (for now) is the PRIZM. Unfortunately, as we all become, you will be busy soon and this will be your last project. :/

Anyway, good luck for the future! :D

** I'm an optimist. :P
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 04, 2012, 01:21:38 pm
Oh boy finally I have some code that initializes and runs stably on both calculators. I eventually noticed there was an extremely annoying memory leak that caused completely unpredictable and inconsistent behavior only with non-CX code (in non-graphical parts). Just before I hung myself I magically managed to fix the issue by fixing another issue. It's so goddamn reliving to see this showing up in the console no matter how many times you run the program:
(http://i.imgur.com/p022o.png)

Feels good man.

It also now prevents you from launching any code not compiled for the current calculator:
(http://i.imgur.com/ZDWlt.png)
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on March 04, 2012, 01:54:24 pm
Great ;)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 04, 2012, 02:28:27 pm
And last update today: I wrote a first version of the non-CX video code. It works poorly with anything odd (as opposed to even; doesn't handle single nibbles when copying data), but I have some results:

(http://i.imgur.com/UrpQS.png)

(Oh, and I got to try it on my own TI-Nspire, which is nice; seems to be working well with that primitive example)
Title: Re: SDL for the TI-Nspire
Post by: Nick on March 04, 2012, 02:59:24 pm
it might be simple, but it shows us you reached something.. i wouldn't say it's just "some results", it's nice to see it working.. that means it can be developped further, and that's the purpose i think, so be happy :)
Title: Re: SDL for the TI-Nspire
Post by: Adriweb on March 04, 2012, 03:03:34 pm
Awesome work hoffa :D
Title: Re: SDL for the TI-Nspire
Post by: ruler501 on March 04, 2012, 03:23:44 pm
Great job cant wait to see all the great games that will be made using this
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 04, 2012, 05:29:28 pm
Actually this'll be the last update for today. On the previous screen you can see that gradient, but it only shows 7 colors and it doesn't seem to be consistent. That's because SDL's palette color mapper is crap (or not suited for 4-bit displays), so I decided to get completely rid of the palette and replace the color mapper code by a one-liner. It should be faster, much better, and should simplify and speed things up generally as all the bytes in the screen buffer are already within the 0-15 range. I'm not entirely sure that it won't cause any issues later (not sure how SDL deals with blitting surfaces with different formats etc.), but currently it seems to be working well, and here's the result (compare with the previous one, it's the same code for the gradient) (oh, also notice odd coordinates work well):

(http://i.imgur.com/cgVrX.png)

Here are the basic things I still need to do before we have a first beta version of SDL for the TI-Nspire:
- Get the BMP blitting to work
- Fix the events (it currently sends loads of them and at inappropriate moments; also some stuff with the joystick I need to fix)
- Implement the timers system fully
(- Add own function to blit images from array data)

Those are the most important things and the first things that come to my mind.

BTW, on my calculator performance-wise it seems quite fast, it's rather snappy and responsive although it's updating the whole screen every time and a lot more than it should (event system that needs working on). It's a very simple program but it's good to see it runs fast.
Title: Re: SDL for the TI-Nspire
Post by: atiatinini on March 04, 2012, 06:10:14 pm
Nice, keep up the good work!  ;)

Also, will it be possible to port VisualBoyAdvance? It's SDL-based.  :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 04, 2012, 06:13:18 pm
Nice, keep up the good work!  ;)

Also, will it be possible to port VisualBoyAdvance? It's SDL-based.  :D
Depends what exactly are the libraries used by VBA, but sure, with some trimming it shouldn't be too big of an issue.
EDIT: Reo, are you sure about it? I honestly don't have an idea, but VBA might be optimized quite a bit as it's already a robust and mature program.
Title: Re: SDL for the TI-Nspire
Post by: Reo on March 04, 2012, 06:13:31 pm
Nice, keep up the good work!  ;)

Also, will it be possible to port VisualBoyAdvance? It's SDL-based.  :D

It wouldn't run at any kind of playable speed. The closest anybody would get toward a playable experience is a port of gpsp.
Title: Re: SDL for the TI-Nspire
Post by: calc84maniac on March 04, 2012, 07:22:11 pm
Yeah, and gpsp uses SDL so this would be a good first step to porting it :)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 05, 2012, 05:48:17 pm
Alrighty now SDL_GetTicks() should work on the non-CX models (thanks calc84maniac), and once I get the same done for CX's, it'll be as far as I'll go as far as timers are concerned (that makes a lot of as'). Implementing SDL_AddTimer() and whatnot requires some sort of threads or pseudo-threads, plus they're rarely used. Also the event system does actually work as it should, it was just me who used SDL_PollEvent() wrong.

So basically the things that still need to be written/fixed are the timer things for CX (should be pretty straightforward once I have the courage to read the CX timer documentation), BMP blitting and some issues with non-CX surfaces. If everything goes well those two last things are the real problems I still need to tackle. BMP blitting might not work because of some other thing that does not work as it should (something I have not yet noticed), and the issues on non-CX models seem to be caused by surfaces created with SDL_CreateRGBSurface() (in fact it fails if I try to blit a surface created with that function). Also ExtendeD might soon update Ncubate which should be great; GDB would speed up the debugging process quite a bit. :)
Title: Re: SDL for the TI-Nspire
Post by: njaddison on March 05, 2012, 06:11:28 pm
Hoffa, how did you get the boot 1 for the cx? I don't have a cx, but I've been wanting to use one with nspire_emu. I just have a regular nspire, but it would be nice to have an nspire cx on the nspire_emu.

BTW, does is gpsp a gameboy advance emulator for the sony psp? Because if it is, how would someone port it to the nspire? There is no way to convert the psp EBOOT.PBP file to a .tns file. And besides, even if it did, it probably wouldn't work because gpsp is an unsigned app for the psp, and can only run on custom firmware.
Title: Re: SDL for the TI-Nspire
Post by: calc84maniac on March 05, 2012, 06:20:05 pm
There's a version of GPSP for the GP2X, which is the most likely thing to port from.

Also Hoffa, how are you handling the fact that the timer is 16-bit? I think the SDL_GetTicks() is supposed to return a 32-bit value.
Title: Re: SDL for the TI-Nspire
Post by: Mighty Moose on March 05, 2012, 06:30:20 pm
On a similar note, there's one for the iPod video (which uses an arm(7?) processor) called iGPSP, but the GP2X version may be more portable  (Plus, iirc, iGPSP has a number of issues and it's not updated very often :().

Just thought I'd throw that out there.
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 05, 2012, 06:34:21 pm
Hoffa, how did you get the boot 1 for the cx? I don't have a cx, but I've been wanting to use one with nspire_emu. I just have a regular nspire, but it would be nice to have an nspire cx on the nspire_emu.
I got it off someone else. Drop me a PM and I'll send it to you tomorrow.

Also Hoffa, how are you handling the fact that the timer is 16-bit? I think the SDL_GetTicks() is supposed to return a 32-bit value.
Well currently I just convert the timer value to milliseconds and return it. I should indeed return the number of milliseconds since SDL was initialized, and simulating a 32-bit timer is rather painstaking with a 16-bit timer unless I somehow periodically check for overlaps and add that to the overall value. I might do it sometime later, but currently it would unnecessarily complexify the code, it would be too much hassle for something that isn't that big of an issue. Currently the timer precision is only at 10 Hz (i.e. 0.1s precision), but that gives ~1.8 hours without a timer reset. I doubt anyone uses the same program on a calculator that long anyway, so I guess I'll increase the timer to 20 Hz (or more) tomorrow.
Title: Re: SDL for the TI-Nspire
Post by: calc84maniac on March 05, 2012, 06:36:59 pm
Maybe have it run at 1024Hz and whenever SDL_GetTicks() is called, have it add the current counter value to a saved 32-bit ticks value and then reset the counter. This would only act strange if the program goes 64 seconds without ever calling SDL_GetTicks(), and that's not very likely.
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 05, 2012, 06:41:06 pm
Hmm, yeah, it's usually used to measure intervals so it might be a good idea to do that. I'll maybe lower it a bit just to be safe (as in 512 Hz? It would give a precision of ~0.002s and double the better-get-the-tick-value-or-else time).
Title: Re: SDL for the TI-Nspire
Post by: DJ Omnimaga on March 05, 2012, 06:50:51 pm
I'M liking the progress on this so far Hoffa. Glad development is continuing even if TI constantly blocks Ndless since 2010.
Title: Re: SDL for the TI-Nspire
Post by: Jonius7 on March 06, 2012, 07:49:04 am
Hoffa, how did you get the boot 1 for the cx? I don't have a cx, but I've been wanting to use one with nspire_emu. I just have a regular nspire, but it would be nice to have an nspire cx on the nspire_emu.
I got it off someone else. Drop me a PM and I'll send it to you tomorrow.

Thought it was kinda illegal to distribute roms.
But anyway, it can be done with a real CX using polydumper available on tiplanet.org
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 06, 2012, 10:32:32 am
I dealt with the 16-bit/32-bit timer issue on the non-CX models by using the RTC on the calculator and add a multiple of 2^16 to the tick count variable if necessary. That way it works like a 32-bit timer, and SDL_GetTicks() works as it really should. Plus, it's set to 1024 Hz as calc84maniac suggested, which gives quite a lot of accuracy (accuracy as in ticks/s; I'm using the approximation that 1 kHz ~= 1.024 kHz though, so there's a tiny percentage of error on very long runs).

Thought it was kinda illegal to distribute roms.
But anyway, it can be done with a real CX using polydumper available on tiplanet.org
It is, and many things in life are. But in all honesty, for such trivial matters I don't really care. Although I don't want to break the forum rules, hence I'm dealing with that in private.
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 10, 2012, 03:07:29 pm
After a long time, I finally have some results on the CX when it comes to blitting BMP images. The debugging has been very laborious without proper tools, but it seems to work now. I still need to go through the code as it currently uses a slow blitter, and there's some optimized version available, but I'm skipping the part that chooses the blitter as it's what's causing problems.
Enjoy: (and notice the silly debugging messages)

(http://i.imgur.com/nUd6r.png)

When I get the checking to work, I need to look at the non-CX model which has similar issues with blitting.
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on March 10, 2012, 03:36:52 pm
Hey, great :)

I created a news yesterday evening at http://tiplanet.org/forum/viewtopic.php?f=43&t=8888 :)
Title: Re: SDL for the TI-Nspire
Post by: Juju on March 10, 2012, 05:13:09 pm
Well, that's pretty awesome :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 11, 2012, 09:01:02 am
Some more great news, not sure if this even requires an explanation:

(http://i.imgur.com/FzjDQ.png)
Title: Re: SDL for the TI-Nspire
Post by: Adriweb on March 11, 2012, 09:08:42 am
non-CX working too ?

Awesome :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 11, 2012, 09:15:02 am
Indeed, yeah. Damn sweet.

(http://i.imgur.com/ZbP9G.png)

Here's the todo list from the README, so you can see what's still left to do:
Code: [Select]
Todo:
- Add SDL_GetTicks() for CX
- Map more keys to SDLKs
- Add support for diagonal arrow keys in events & joystick
- Should the joystick continuously fire events if an arrow key is held down?
- Put all the compiled objects in one folder, along with libSDL.a?
- Add some own function to load images stored in arrays (?)
- Add mouse support
A few of those are trivial to do, but as you can see there's not much left before a beta, if everything goes well and if I don't find any other issues.
Title: Re: SDL for the TI-Nspire
Post by: Lionel Debroux on March 11, 2012, 10:33:12 am
IOW, you made the same thing for Clickpad/Touchpad ? :)
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 11, 2012, 11:19:19 am
Yes, or more generally, I fixed most of the blitting issues. Here's a short video so you can more or less see how blitting a big image runs speed-wise:



EDIT: I actually forgot to pass the surface through SDL_DisplayFormat() to convert to the screen's pixel format. With SDL_DisplayFormat() it's a lot snappier.

EDIT2: Here's another video that gives a better impression of the blitting speed (and seems like there are some issues with timers I need to fix):

Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 12, 2012, 04:07:56 pm
While I'm dealing with the timer stuff, I decided to implement fonts. There are 4 fonts included by default, but it's easily extensible. See for yourself:

(http://i.imgur.com/BG1zZ.png)

Drawing fonts is as easy as calling the SDL_NSP_DrawString() function (any TI-Nspire-specific functions I add will be prefixed with SDL_NSP_*).
Title: Re: SDL for the TI-Nspire
Post by: njaddison on March 12, 2012, 06:41:21 pm
While I'm dealing with the timer stuff, I decided to implement fonts. There are 4 fonts included by default, but it's easily extensible. See for yourself:

(http://i.imgur.com/BG1zZ.png)

Drawing fonts is as easy as calling the SDL_NSP_DrawString() function (any TI-Nspire-specific functions I add will be prefixed with SDL_NSP_*).

Is nSDL far enough to start porting SDL programs to the nspire? Or do you need to do more work? (I know nothing about SDL, so I have no clue what you have to do to finish it) Also, could I put custom fonts off of my computer on my nspire using nSDL without having to make the font over again?

Yes, or more generally, I fixed most of the blitting issues. Here's a short video so you can more or less see how blitting a big image runs speed-wise:



EDIT: I actually forgot to pass the surface through SDL_DisplayFormat() to convert to the screen's pixel format. With SDL_DisplayFormat() it's a lot snappier.

EDIT2: Here's another video that gives a better impression of the blitting speed (and seems like there are some issues with timers I need to fix):



Also, the video isn't showing, maybe it's because youtube is blocked at my school? I had no problem viewing youtube videos off of omnimaga before...
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 12, 2012, 06:52:57 pm
Is nSDL far enough to start porting SDL programs to the nspire? Or do you need to do more work? (I know nothing about SDL, so I have no clue what you have to do to finish it) Also, could I put custom fonts off of my computer on my nspire using nSDL without having to make the font over again?
I wouldn't say it is yet. Depends what programs of course, but a few crucial things are missing, and it needs some testing (but that's when it comes to porting more sophisticated programs in the current state; writing your own shouldn't be that big of an issue though). Also many programs use floating point math, and it doesn't seem like Ndless in its current states supports any of that. I'd say if everything goes nicely there might be an early beta at the end of the week.

Also, the video isn't showing, maybe it's because youtube is blocked at my school? I had no problem viewing youtube videos off of omnimaga before...
Yeah it's just you, the video works.
Title: Re: SDL for the TI-Nspire
Post by: calc84maniac on March 12, 2012, 07:30:42 pm
I'm pretty sure the GCC we use supports floating point. Of course, it can be slow since the floating point math has to be emulated with integer instructions.
Title: Re: SDL for the TI-Nspire
Post by: Chockosta on March 13, 2012, 10:59:01 am
Floating point operations work.
But floating point numbers can't be displayed with printf("%f") or sprintf("%f").
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 15, 2012, 03:14:14 pm
Alrighty guys, I'm happy to announce the first beta version of SDL for the TI-Nspire will come out very soon. :)

But before I can do that, I need someone to check one thing on their physical CX. It's everything but complicated; download the attachment, send it to your calculator and enjoy the nice fonts and just observe how the timer increases. It should output the number of milliseconds since SDL initialization, so it should increase at a rate of 1000 a second. Press any key to update that value. If it increases way too fast, just tell me. That's all I need you to do, it should take just a few seconds. Thank you a lot for whoever helps me; the faster I get the info the faster I can release SDL. :)

I've made quite a few changes since last update. I changed to a much faster, more flexible and cleaner font system, updated the timer stuff, fixed some issues and whatnot.
Title: Re: SDL for the TI-Nspire
Post by: atiatinini on March 15, 2012, 03:35:02 pm
It's working very well, and the timer is very accurate! :D
Title: Re: SDL for the TI-Nspire
Post by: hoffa on March 15, 2012, 03:42:53 pm
It's working very well, and the timer is very accurate! :D
Good to hear, seems like the problem's only on the non-CX models then (the value increases at the speed of light). Once I finish studying I'll go and beat the crap out of that timer bug, do some housekeeping and release the beta (very probably tomorrow, unless I once again end up going to bed at around 1 AM). Thanks again.

EDIT: I'll probably make some how-to thread for those new to SDL with instructions, links to tutorials and such things once something's ready.

EDIT2: Just released TI-Nspire SDL 0.1.0. :)
Title: Re: nSDL (0.1.1 beta)
Post by: hoffa on March 16, 2012, 11:37:39 am
Just finished rewriting the thread, it's still missing a lot of things (how-to, screenshots, etc.) but it's a nice start.

Also removed yesterday's 0.1.0, as it was missing the headers and still had the old clumsy SDL_NSP_* functions. So I quickly rolled out 0.1.1, that'll be the starting point. I haven't written any instructions yet, but those who know their way around SDL and static libraries can already start playing around with it. :) I also renamed the project to nSDL; I wasn't to fond of the n-prefix, but TI-Nspire SDL just seemed too massive, so nSDL it is then.
Title: Re: nSDL (0.1.0 beta)
Post by: Jim Bauwens on March 16, 2012, 11:38:49 am
Very nice!

Need to see to test this when I installed Ndless (again) on my CX :)
Title: Re: nSDL (0.1.1 beta)
Post by: alberthrocks on March 16, 2012, 11:57:39 am
Once again, great job! You've worked really hard :D
Title: Re: nSDL (0.1.1 beta)
Post by: lkj on March 16, 2012, 02:05:12 pm
Great job! I'll have to learn how to use SDL :)
Title: Re: nSDL (0.1.1 beta)
Post by: hoffa on March 17, 2012, 03:58:28 pm
I did some benchmarking, and the performance seems rather good.

Blitting 1000 times a 100x100 BMP image takes about 2.6 seconds. See for yourself:

Title: Re: nSDL (0.1.1 beta)
Post by: Lionel Debroux on March 17, 2012, 04:06:30 pm
That's ~400 100x100 BMP images per second.
What are the figures for 32x32 and 16x16 bitmaps (if possible, drawn with various modes: replace, masked, transparent), i.e. game sprites ? :)
Title: Re: nSDL (0.1.1 beta)
Post by: hoffa on March 17, 2012, 04:25:01 pm
Image: (http://webgel.net/bb/files/image.bmp) (16x16)
1000 blits in 114 ms: 8772 blits/second

Image: (http://webgel.net/bb/files/1/image.bmp) (32x32)
1000 blits in 334 ms: 2994 blits/second

EDIT:

Trying out alpha, just posting this here as it gives a nice-looking CRT effect (well, more or less): (don't mind the results, it's on an emulator)
(http://webgel.net/bb/files/alpha.png)
Alpha doesn't work on palettized surfaces though (i.e. Touchpad/Clickpad models), although I could hack it a bit and add support for them.

EDIT2:

Here's the code I used for the benchmark test: http://pastebin.com/vvdpJq57 (http://pastebin.com/vvdpJq57)
Title: Re: nSDL (0.1.1 beta)
Post by: Lionel Debroux on March 18, 2012, 07:59:00 am
Thanks :)

So... as there are 20*15 16x16 sprites on the Nspire's 320x240 screen, 8-9K blits per second for 16x16 sprites translates to 26-30 FPS for redrawing the entire screen using only 16x16 clipped sprites. That's better than the performance achievable on TI-68k calcs (shown by e.g. ExtGraph demo12), which is good news, but it's still insufficient for completely getting rid of a tilemap engine for platform games. But unlike what we did on TI-68k calculators (reimplementing tilemap engines), we'll surely be able to take advantage of a number of existing tilemap engine implementations :)
Title: Re: nSDL (0.1.1 beta)
Post by: hoffa on March 18, 2012, 09:20:00 am
Seems pretty good for a start. Performance hasn't really been my main thing yet though, as I have been dealing with more important stuff. In later versions I'll optimize whatever possible to squeeze all the juice out of the TI-Nspire. (memcpy I'm looking at you)

On a side note, I'm working on getting SDL_image to run, i.e. support for a lot of different image formats.
Title: Re: nSDL (0.1.1 beta)
Post by: Lionel Debroux on March 18, 2012, 09:32:45 am
Quote
Seems pretty good for a start. Performance hasn't really been my main thing yet though, as I have been dealing with more important stuff. In later versions I'll optimize whatever possible to squeeze all the juice out of the TI-Nspire.
Sure :)

Quote
On a side note, I'm working on getting SDL_image to run, i.e. support for a lot of different image formats.
Nice :)

Title: Re: nSDL (0.1.1 beta)
Post by: DJ Omnimaga on March 18, 2012, 02:25:00 pm
Darn that is awesome, you even got alpha transparency! Great job on this :)
Title: Re: nSDL (0.1.2 beta)
Post by: hoffa on March 20, 2012, 03:20:52 pm
0.1.2's out, it contains mostly just minor changes. One useful addition though is printf-like formatting for SDL_nDrawString (along with NSP_COL and NSP_ROW to easily align text).
For example, to draw "Hello 0xFFFF, 42, world!" in row 1 (starts from 0) column 5, you could do something like (just replace the values by variables of course, otherwise it's useless):

SDL_nDrawString(screen, font, NSP_COL(5), NSP_ROW(1), "Hello 0x%X, %d, %s!", 65535, 42, "world");

It also supports tabs and newline characters, and text wrapping.

I've looked at the mouse stuff, and I might be able to implement that for the next release. I'll also write a full how-to guide to (I reckon it's not very homely when I just dump the headers and static libs in a zip file) and a few example codes in the thread soon.

EDIT:

Could somebody check how fast sprites are blitted on the CX? Download the zip and copy both TNS files to the Examples folder on your TI-Nspire, then run sdl_test.tns. I'm not sure how well memcpy is optimized, but with some magic it might (it's a vague guess though) be faster on the CX than on the non-CX. Thanks a lot.
Title: Re: nSDL (0.1.2 beta)
Post by: Nick on March 20, 2012, 04:26:15 pm
it varies between about 112 and 116 ms per 1000 blits (i tried it about 10 times) with an average of 113.44

edit: it's a CX CAS btw
edit2: changed 100 to 1000 (typo)
Title: Re: nSDL (0.1.2 beta)
Post by: hoffa on March 20, 2012, 04:40:39 pm
1000 blits in 113 ms means 8850 blits/s for a 32x32 BMP image, while on the non-CX it was 2994 blits/s. If your figures and my calculations are correct, that's nearly three times faster than on the non-CX. Damn. :o

Is that correct or am I just missing something and failing at basic math? (EDIT: indeed I messed up, it was 16x16 not 32x32)

EDIT:

Could you (or anyone else for that matter) replace the image.bmp.tns, by the one attached (it's the 16x16 one)? Thanks a lot, you're doing a great favor.
Title: Re: nSDL (0.1.2 beta)
Post by: atiatinini on March 20, 2012, 04:54:20 pm
Both images are exactly the same (16x16).

EDIT: I've tried with another 32x32 image and it says '1000 blits in 282 ms'.
Title: Re: nSDL (0.1.2 beta)
Post by: hoffa on March 20, 2012, 05:11:49 pm
Oh wow what a mistake, so it was the 16x16 after all. No wonder the results seemed too great to be true.

Well seems like there's not much difference with the 16x16 (although maybe 1000 blits is too little), but in a 1000-blit run it seems to be about 50 ms faster on the CX with the 32x32 image. Thanks for the information.

Once I get the more important stuff working (mouse for instance), I'll look into performance.

EDIT:

Good news. I hadn't compiled with any GCC optimization yet and had forgot about it. Now I compiled SDL with -O3 (i.e. highest optimization level), and the size went from 383K to 241K. But most importantly, with the exact same 32x32 image on a 1000-blit run, it took 325 ms without optimization, and 155 ms with optimization. That's over twice as fast. :)


I checked and rechecked, and it is indeed true. I tried with a 10000-blit run this time, one program compiled with no optimization and the other one with O3. Here are the results that fit the previous finding:

(10000-blit run, 32x32 BMP image)
Unoptimized: 3261 ms or 3067 blits/s (+0%)
O3 optimized: 1555 ms or 6431 blits/s (+110%)
Title: Re: nSDL (0.1.2 beta)
Post by: atiatinini on March 20, 2012, 07:25:50 pm
Great news, can't wait for that how-to! :D
Title: Re: nSDL (0.1.2 beta)
Post by: Adriweb on March 20, 2012, 08:37:54 pm
Really nice :o
Title: Re: nSDL (0.1.2 beta)
Post by: apcalc on March 20, 2012, 10:06:17 pm
Great progress!  :D
Title: Re: nSDL (0.1.2 beta)
Post by: Lionel Debroux on March 21, 2012, 02:35:38 am
Good ;)
Title: Re: nSDL (0.1.2 beta)
Post by: Jim Bauwens on March 21, 2012, 04:55:54 am
Indeed, very nice :)
Title: Re: nSDL (0.1.2 beta)
Post by: ExtendeD on March 21, 2012, 08:47:04 am
Great job hoffa!
Does the current version would allow to port easily SDL-based programs of other platforms?
And do you think some of these libs would work? http://www.libsdl.org/libraries.php?category=12&os=8
Title: Re: nSDL (0.1.2 beta)
Post by: hoffa on March 21, 2012, 10:08:21 am
I've tried porting some very small SDL programs and it works well. Haven't tried porting anything bigger yet though.

As far as the libs are concerned, most of the libs there seem portable. SDL_image for instance certainly is, and it's on my todo list.
Title: Re: nSDL (0.1.3 beta)
Post by: hoffa on March 24, 2012, 12:48:37 pm
Finished writing the how-to guide. Enjoy. :)

Also rolled out 0.1.3, only change being the -O3 switch in the Makefile which gave a huge performance boost.
Title: Re: nSDL (0.1.3 beta)
Post by: Nick on March 24, 2012, 12:55:55 pm
what do you mean with performance? faster? or less usage of the processor for the same executions?

how much better does it perform now?
Title: Re: nSDL (0.1.3 beta)
Post by: hoffa on March 24, 2012, 01:07:01 pm
Faster as in it draws faster. As I mentioned a few posts earlier, it improved drawing speeds by about 110% (i.e. over twice as fast).

EDIT: here (http://ourl.ca/14975;msg=238515)
Title: Re: nSDL (0.1.3 beta)
Post by: ExtendeD on March 24, 2012, 01:35:04 pm
What doesn't make any sense is the size improvement induced by -O3 compared to -Os.
Title: Re: nSDL (0.1.3 beta)
Post by: hoffa on March 24, 2012, 01:37:29 pm
It wasn't even -Os, I at first used no optimization (i.e. -O0) for stability purposes and then forgot about it.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 25, 2012, 09:56:16 am
Booyakasha!

0.1.4's up. It should actually be 0.1.3b or 0.1.3.0.0.0.1 as it contains very little code changes, but hey, who wants to stay in 0.1.* forever? I'll probably jump to 0.2.0 once I get the mouse to work, just for shits'n'giggles.

Anyway, basically this version goes hand in hand with the new how-to guide. First of all I hid that whole NSP_COLOR_LCD thing from the user as it complicates the build process and whatnot. Then I added a very easily adaptable Makefile.sample file to the final archive which simplifies the build a lot (only a make cx/tc is needed to build now, no more cryptic commands). Also I added a primitive README file to the said archive; it doesn't really help anything at all (who reads README's anyway?) but it makes it look more serious. Then I did some general housekeeping to the code and removed some mouse-related test stuff clogging up the event loop. Oh and as I mentioned a few sentences earlier, I updated the how-to guide.

There won't be any updates for at least a few days as this version has been clinically proven through rigorous scientific experiments to be a "stable beta".

Have fun.

EDIT: Added images of the available fonts.
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on March 25, 2012, 10:29:57 am
Just wondering, is it possible to use c++?
Great work! :)
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 25, 2012, 10:38:12 am
Quote from: libsdl.org
SDL is written in C, but works with C++ natively

So yes, but then again we need to get C++ to work (tangrs was working on it IIRC). So once there's C++, there's SDL C++.
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on March 27, 2012, 02:38:49 pm
I've been trying to port some SDL Demos (here (http://www.libsdl.org/projects/)), but most of them use math functions that won't work with SDL. For example:
Spoiler For Spoiler:
#include <os.h>
#include <math.h>

int main(void) {
    printf("calculating sqrt... ");
    int n = sqrt(123);
    printf("done!");
    return 0;
}
This code runs ok, but if I add SDL_Init like this:
Spoiler For Spoiler:
#include <os.h>
#include <SDL/SDL.h>
#include <math.h>

int main(void) {
    printf("calculating sqrt... ");
    int n = sqrt(123);
    printf("done!");

    SDL_Init(SDL_INIT_VIDEO);

    SDL_Quit();

    return 0;
}
It stops with this warning:
(http://i43.tinypic.com/e8stmo.png)

I asked hoffa about this but he also doesn't know what's causing the warning. Any help?
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 27, 2012, 03:34:05 pm
Indeed it's a rather strange problem. I tried removing all code from SDL_Init() and just returning 0, but it still gives the mentioned error, whether it is called before or after the sqrt() function. However, what I noticed was that it works with no issues when using functions that do not return floating point types, such as ceil(). I'm not sure why it works without the SDL_Init() and doesn't if it is there (in one case the whole SDL lib is linked, in the other not; might have something to do with that), but it might be a Newlib issue, as the Hackspire wiki suggests:
Quote
Compatibility of Ndless with Newlib has not been tested. You may get definition conflicts and crashes due to Newlib running without the required relocation that Ndless doesn't provide. You should always build your programs with the nspire-ld flag -nostdlib, except if you need the single precision floating-point helper functions internally called by GCC when required (__aeabi_fadd, ...).
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on March 27, 2012, 04:20:23 pm
Won't all of these relocation issues be fixed if we use an elf/bFLT/QEMU loader? :)
Title: Re: nSDL (0.1.4 beta)
Post by: ExtendeD on March 27, 2012, 04:55:03 pm
Maybe.

 atiatinini, hoffa, which version of YAGARTO/Newlib are you respectively using?
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 27, 2012, 05:03:22 pm
binutils: 2.21
gcc:      4.6.2
newlib:   1.19.0
gdb:      7.3.1

BTW, atiatini, meanwhile you could use the fast inverse square root function (used in Quake for example):

float inv_sqrt(float x) {
   union {
      float x;
      int i;
   } u = {x};
   u.i = 0x5f3759df - (u.i >> 1);
   return u.x * (1.5f - (0.5f * x * u.x * u.x));
}


It's quite "hackish", but just do 1/inv_sqrt() and you have an accurate and a very fast approximation of the square root.
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on March 27, 2012, 05:14:44 pm
Thanks, I'll use those "alternative methods" then. :)
Title: Re: nSDL (0.1.4 beta)
Post by: ExtendeD on March 27, 2012, 05:27:54 pm
I'd prefer that both of you contribute to find out the root cause of the issue.
atiatinini, if you are trying to port SDL programs, you'll probably encounter other conflicts more difficult to identify and work around.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 27, 2012, 05:35:09 pm
I'd prefer that both of you contribute to find out the root cause of the issue.
I'll have a more thorough look at it tomorrow (or whenever I have the time). I checked newlib's sqrt() implementation (http://sourceware.org/cgi-bin/cvsweb.cgi/~checkout~/src/newlib/libm/math/e_sqrt.c?rev=1.1.1.1&content-type=text/plain&cvsroot=src) (I'm pretty sure that's the one used), and there doesn't seem to be any global variable stuff that could cause issues.
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on March 27, 2012, 05:52:03 pm
I'd prefer that both of you contribute to find out the root cause of the issue.
atiatinini, if you are trying to port SDL programs, you'll probably encounter other conflicts more difficult to identify and work around.
Yes, there are a few things that doesn't seem to work with Ndless, like srand(int) and rand();
Title: Re: nSDL (0.1.4 beta)
Post by: ExtendeD on March 28, 2012, 04:08:03 am
The source code of Newlib's sqrt is this one:

http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libm/math/w_sqrt.c?annotate=1.1.1.1&cvsroot=src

_LIB_VERSION refers to the global variable __fdlib_version, I'm not sure why but it seems to require relocation, which cannot be provided by Ndless.
It actually doesn't work well without nSDL, it's just that the random access to memory falls to a valid address (but still not __fdlib_version).
I'm afraid we cannot trust any Newlib function without a full-featured relocator.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 28, 2012, 09:26:01 am
The source code of Newlib's sqrt is this one:

http://sourceware.org/cgi-bin/cvsweb.cgi/src/newlib/libm/math/w_sqrt.c?annotate=1.1.1.1&cvsroot=src

_LIB_VERSION refers to the global variable __fdlib_version, I'm not sure why but it seems to require relocation, which cannot be provided by Ndless.
It actually doesn't work well without nSDL, it's just that the random access to memory falls to a valid address (but still not __fdlib_version).
I'm afraid we cannot trust any Newlib function without a full-featured relocator.
Can't Newlib "just" be recompiled with some nl_relocdata hacking meanwhile?
Title: Re: nSDL (0.1.4 beta)
Post by: ExtendeD on March 28, 2012, 09:30:34 am
I suppose this would require some effort. And for example I don't understand why _LIB_VERSION would require nl_relocdata, so identifying what needs to be patched isn't clear to me.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 28, 2012, 10:38:11 am
I'll try and port (wait, no, I will port) fdlibm (actually I think that's what newlib partly uses); it would be a nice add-on with the next nSDL release.

EDIT:

I compiled the fdlibm sqrt routine codes with _IEEE_LIBM and __LITTLE_ENDIAN defined, and it works nicely:

(http://i.imgur.com/miGOw.png)

The "inside *" messages are there to prove that it is indeed using the new functions and those of the math lib magically included by GCC.
Maybe the same trick could be blindly used on newlib's libm code (which should be pretty much the same).

PS: It seems that GCC includes libm even without -lm, how do I force it not to use any libraries? Using -nostdlib with ld-nspire just makes it vomit all kinds of __aeabi_* errors.

EDIT2: I did a few changes and compiled fdlibm; it should implement all functions in <math.h> and it also contains the macros (were added from newlib's <math.h> manually). If it works well it could be a more or less lightweight replacement to newlib's libm.a. Library's attached.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on March 29, 2012, 04:48:29 pm
I managed to get the mouse to work, at least to some degree. Some very weird bug shuts down the program at seemingly random moments, as you can see:



EDIT: After numerous tests it seems that it crashes (or whatever happens) if the mouse goes to the y-coordinate 9. I see no logical explanation for this bug.
Title: Re: nSDL (0.1.4 beta)
Post by: ExtendeD on March 31, 2012, 04:15:52 am
I've looked closer if anything could be done for the relocation issue. Global variables containing data which need to be relocated are stored in the 'data.rel' section of the ELF file, but this doesn't mean we can blindly relocate anything in this section, since there may also be fields not to be relocated. The relocation info cannot be emitted to the binary file and the current Ndless relocator cannot do much about it.

I'd like to see if tangrs's relocator ( http://ourl.ca/15714 ) would fix all these issues.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 03, 2012, 08:00:18 am
Just to give you a quick heads up, the next version--0.2.0--and rather major step, will have numerous changes. Among those will be mouse support, 8 BPP support for CX (thanks to atiatini for the idea; makes it possible to port 8 BPP programs for the CX), many font-related changes (if you're the observing type you can notice one thing on the screenshot below) and a lot of under-the-hood modifications (performance, stability, etc.). Also a few surprises. Quick screenshot to show 16 BPP and palettized 8 BPP on CX (actually it's just an excuse to give the thread some color):

(http://i.imgur.com/1RGtr.png)
Title: Re: nSDL (0.1.4 beta)
Post by: Lionel Debroux on April 03, 2012, 08:19:52 am
Looks good, as usual :)

Quote
8 BPP support for CX (thanks to atiatini for the idea; makes it possible to port 8 BPP programs for the CX),
FWIW, while their screen sucks beyond usability, the Clickpad & Touchpad models do support 8 bpp, as shown by nDOOM :)

Quote
many font-related changes (if you're the observing type you can notice one thing on the screenshot below)
Transparency ?
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 03, 2012, 08:37:38 am
Quote
8 BPP support for CX (thanks to atiatini for the idea; makes it possible to port 8 BPP programs for the CX),
FWIW, while their screen sucks beyond usability, the Clickpad & Touchpad models do support 8 bpp, as shown by nDOOM :)
In this case it's software 8 BPP for CX (i.e. if 8 BPP used, the 8->16 conversion is done at the very end), the same way as it's software 8 BPP for Touchpad/Clickpad (8->4 conversion done at the end). I indeed read that it was possible to change the bit depth on the grayscale display, but I suppose the screen'll still only have 16 shades of gray, and the advantages of switching to hardware 8 BPP are limited (not sure how it would behave in weird situations or sudden crashes).

Quote
many font-related changes (if you're the observing type you can notice one thing on the screenshot below)
Transparency ?
Nope, that should already work with SDL_SetAlpha(). It's non-monospaced fonts (e.g. see "quick"). I acknowledge the font isn't the best to show that, but it wasn't the point either.
Title: Re: nSDL (0.1.4 beta)
Post by: Lionel Debroux on April 03, 2012, 08:58:00 am
Quote
but I suppose the screen'll still only have 16 shades of gray,
AFAICT (from watching DummyOS changing colors smoothly enough), the grayscale screen can do 256 shades of gray... or at least, it can do more than 16 shades :)

Quote
and the advantages of switching to hardware 8 BPP are limited (not sure how it would behave in weird situations or sudden crashes).
(emphasis mine)
Indeed, this can be used as an argument against hardware 8 bpp...
The normal 320 x 240 x 4 bpp screen area is stored in SRAM, but the 320 x 240 x 8 bpp area cannot be stored there, it needs to be stored in SDRAM. Upon exit, one has to make sure that the memory is freed and the screen base address pointer is restored, otherwise funny stuff will occur.
And reading from display memory stored in SDRAM might have some unwanted effects (-> critor ?).

The case for hardware 8 bpp mode, on Clickpad & Touchpad, would be to reduce the risk that Clickpad & Touchpad users are left in the cold for SDL-based programs.

Quote
It's non-monospaced fonts
Oh yeah, that's good :)
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 03, 2012, 09:18:06 am
AFAICT (from watching DummyOS changing colors smoothly enough), the grayscale screen can do 256 shades of gray... or at least, it can do more than 16 shades :)
If that's true, I might be more inclined to try 8 bpp out.

The normal 320 x 240 x 4 bpp screen area is stored in SRAM, but the 320 x 240 x 8 bpp area cannot be stored there, it needs to be stored in SDRAM. Upon exit, one has to make sure that the memory is freed and the screen base address pointer is restored, otherwise funny stuff will occur.
And reading from display memory stored in SDRAM might have some unwanted effects (-> critor ?).
If I have some documentation and facts I can rely on, it should be very possible to implement. SDRAM should never be read anyway, in nSDL's case all reads go through the buffer. I could just write some experimental code through a bunch of #if's like I've been doing until now and add a static library to the list (libSDL-TC8.a or something) for those who want to try it out. It might very well be that the advantages of having a 8 bpp display outweight the disadvantages of the rare occasion when the calculator explodes because of access violations.

The case for hardware 8 bpp mode, on Clickpad & Touchpad, would be to reduce the risk that Clickpad & Touchpad users are left in the cold for SDL-based programs.
How so left in the cold?
Title: Re: nSDL (0.1.4 beta)
Post by: Lionel Debroux on April 03, 2012, 09:25:55 am
Quote
SDRAM should never be read anyway, in nSDL's case all reads go through the buffer.
Yup, but nSDL itself has to read from the buffer stored in SDRAM, and there might be some quirks in doing so. I vaguely remember something about that, but I'll stop talking about that matter until someone more knowledgeable than I am (e.g. critor, on that aspect) has a more definitive input :)

Quote
How so left in the cold?
8 bpp is much more usable than 4 bpp for graphics. IMO, chances are that more people will care about Clickpad & Touchpad compatibility if they support 8 bpp, than if they support only 4 bpp :)
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 03, 2012, 11:59:25 pm
Just to give you a quick heads up, the next version--0.2.0--and rather major step, will have numerous changes. Among those will be mouse support, 8 BPP support for CX (thanks to atiatini for the idea; makes it possible to port 8 BPP programs for the CX), many font-related changes (if you're the observing type you can notice one thing on the screenshot below) and a lot of under-the-hood modifications (performance, stability, etc.). Also a few surprises. Quick screenshot to show 16 BPP and palettized 8 BPP on CX (actually it's just an excuse to give the thread some color):

(http://i.imgur.com/1RGtr.png)
Wow nice. 8 bit support would be great for game sprites especially, to save space. ALso for large images on the small screen, if you use dithering, the quality drop won't be as noticeable. :)

Also the mouse seems nice. How is the touchpad sensitivity? I know the cursor of the one in the OS stutters a lot when I move the finger around, but maybe it was the OS fault.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 05, 2012, 05:18:05 am
Okay I tried switching to 8 bpp using nDoom as my main source of information. I then decided to draw--what I thought it would be--a gradient, just copying bytes from lower to higher, and this is what I got (actual calc and on the emulator):

(http://i.imgur.com/a3UFK.png) (http://i.imgur.com/gQkuY.png)

Only the first 16 pixels show a gradient (the usual 16 "colors"), after that it's just a clusterfuck of seemingly random shades of gray. I thought it would be darker to lighter from 0 to 255.

In other news, atiatini ported some plasma demo effect, here's the result:



And on CX using the 8 bpp mode:

(http://i44.tinypic.com/2cwjrk9.png) (http://i40.tinypic.com/dcrfrb.png)

Also the mouse seems nice. How is the touchpad sensitivity? I know the cursor of the one in the OS stutters a lot when I move the finger around, but maybe it was the OS fault.

Seemed pretty fine to me when I tried, no stuttering as far as I could notice. :)
Title: Re: nSDL (0.1.4 beta)
Post by: calc84maniac on April 05, 2012, 08:28:11 am
You'd have to fill the palette RAM with 256 grayscale color values, each from 15 (black) to 0 (white).
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 05, 2012, 08:49:36 am
Wow that looks great. :D When this is available for download, I need to try the color version to see how this looks like on my CX (assuming a demo of the above is made available?). :D
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on April 05, 2012, 09:03:07 am
Wow that looks great. :D When this is available for download, I need to try the color version to see how this looks like on my CX (assuming a demo of the above is made available?). :D
Of course!  :D

CX:
http://www.mediafire.com/?7omfqojuxjjrpp2
Touchpad/Clickpad:
http://www.mediafire.com/?ax8dyd9xqgjb2z5

And here's the source (just ignore my dirty random generator at the end):
http://pastebin.com/gqjXDTBw

Also, please note that the actual code that generates the plasma effect was not made by me, this is just a port of a demo available here (http://www.libsdl.org/projects/plasma/).
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 05, 2012, 09:15:03 am
Oh cool to hear there's one. :D Also welcome to the forums if I didn't welcome you already (I don't remember since I was less active at one point and there were many posts per day I missed) :D

Now students can hallucinate without the use of drugs. <_<
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 05, 2012, 09:56:11 am
You'd have to fill the palette RAM with 256 grayscale color values
Oh of course, I was thinking about that.

each from 15 (black) to 0 (white)
So there after all is only 16 colors available? My main reason to even try to switch to 8 bpp is for some extra shades of gray, the speed increase is negligible.
Title: Re: nSDL (0.1.4 beta)
Post by: calc84maniac on April 05, 2012, 02:27:20 pm
Yeah, only 16 shades (well, really 15 since both colors 14 and 15 are solid black). But even the CX screen only supports 32 shades of gray :P

However, I think a 256-entry palette mode could still be useful, as nDoom used that even in its original grayscale form.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 05, 2012, 02:50:12 pm
However, I think a 256-entry palette mode could still be useful, as nDoom used that even in its original grayscale form.
In what way could it be useful? In its current form SDL uses a 256-color software palette; the result is exactly the same whether using software or hardware palette.
Title: Re: nSDL (0.1.4 beta)
Post by: calc84maniac on April 05, 2012, 05:39:08 pm
A hardware palette will always be faster than a software palette (on the CX you won't have to waste the memory of expanding into a 16-bit buffer either)
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 05, 2012, 05:40:02 pm
How many colors total does the CX support? Was it 65536 like the PRIZM?

Also, the above, at least for now, justifies buying a CX over the PRIZM. Now with a CX, you can feel the effects of hallucination without having to buy drugs, so you save money!
Title: Re: nSDL (0.1.4 beta)
Post by: calc84maniac on April 05, 2012, 05:52:26 pm
Yes, the CX supports 65536 colors. In theory, the Prizm can support 4 times as many colors (18-bit) but I haven't confirmed it yet, plus it would waste a lot of memory.
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 05, 2012, 06:00:43 pm
Thanks for the info, and I see. I think 256 for games on such small screen would be just fine enough anyway.

Also I just got a BSOD on my CX! O.O (well... not really, but the loading screen reminded me of one)
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 07, 2012, 02:09:09 pm
I've now added hardware 8 bpp on both TC (i.e. Touchpad/Clickpad) and CX models. In fact I restructured the code and there are now 5 different bpp modes: CX SW16 HW16, CX SW8 HW16, CX SW8 HW8, TC SW8 HW8, TC SW8 HW4 (where SWx HWy is software x bpp, hardware y bpp display).

I'm considering implementing double buffering and wondering if it's worth the trouble (in TC models it's unnecessary, no tearing thanks to the slow and shitty LCD). Also I need to fix some mouse issues and do some further fine-tuning before 0.2.0.
Title: Re: nSDL (0.1.4 beta)
Post by: Lionel Debroux on April 07, 2012, 03:26:27 pm
Good, as usual :)
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 13, 2012, 02:47:16 pm
Could somebody with a CX do me a favor?

Could you grab the the attached file, send it to your calculator and just see if everything works. Move your finger around the touchpad to move the mouse, if you press it you should see "SDL_MOUSEBUTTONDOWN" showing up. It uses hardware 8 bpp and the touchpad, so I'd like to know if everything works nicely. Thanks for whoever helps me. :)

(0.2.0 is advancing nicely, there'll be a lot changes and a bigger "launch" than usually)
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on April 13, 2012, 07:12:08 pm
It works, but lags a lot. Sometimes the program completely freezes for a few seconds.
But is amazing, thanks!  :)
Title: Re: nSDL (0.1.4 beta)
Post by: Nick on April 13, 2012, 08:37:48 pm
I tried it on a CX CAS (don't know if there's anything different than a normal CX) and i have the same result. I shows up, shows the coordinates, shows the mousebuttondown and coordinates, but lags sometimes for a short while

edit: My calc did a reboot when i pressed [esc] ö i don't think that' normal.. i treid it 3 times, and everytime it did a reboot..
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 13, 2012, 10:36:08 pm
Thanks a lot you both.

Not sure about the rebooting issue, but I fear it has something to do with the mouse, I had the same problem at first but thought I had fixed it (on Touchpad it works). When it comes to mouse lag, it's very weird behavior, but I remember having something like it on my Touchpad at first, fixed it by moving the touchpad scanning function a bit. Could you try the attached program for me? It reads raw values from the touchpad, I'd like if to know if the "Velocity" still lags and updates rarely or if it's fast:
Spoiler For Spoiler:
(http://i.imgur.com/fNPzH.png)
I can only bribe you with a thank you in the readme.

This is how the mouse works on my Touchpad:
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on April 14, 2012, 12:39:34 am
The values change when I use the touchpad but the mouse doesn't appear.  :(
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 14, 2012, 12:53:44 am
The values change when I use the touchpad but the mouse doesn't appear.  :(
That's normal, I disabled the mouse so that I can only read raw values (no SDL involved except for the font drawing). So it seems it does update it normally. I think the problem might be similar to the one had some time ago. Thanks a lot, I'll look into it. :)
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 15, 2012, 11:08:53 pm
I'll give it a try when I have some time, but I have a bug to report for the Plasma program: After a few times running it, when you press enter to run the file, nothing happens at all, even if you ran another Ndless program before. Once your calc rebooted, it seems to work again.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 18, 2012, 05:01:37 pm
Just to keep you guys updated, the mouse now works on CX models when using SDL_WaitEvent() (thanks atiatini for the testing), but it still "lags" (actually input lag) when using SDL_PollEvent(), so that among other things remains to be fixed.

Also meanwhile I've been working on an extremely simple image format for those who might prefer to include images in the executable (useful for small sprites and such), along with a converter:

(http://i.imgur.com/UBOuQ.png)

Oh and I'll probably be a bit less active as I plunged into some more serious indie game development.
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on April 18, 2012, 06:15:29 pm
Nice, hopefully we will soon see awesome games (and emulators :)) being made with nSDL!  :D

And yes, there is a bug in the plasma demo, I'll probably release an updated version soon. ;)

EDIT: Here it is:

CX:
http://www.mediafire.com/?huad2sed9i378t3
Touchpad/Clickpad:
http://www.mediafire.com/?p36ze746p0ot847
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 20, 2012, 07:03:26 pm
Some more updates...

I've added support for own extremely simple image format, and I added a SDL_nDrawStringInRect() function which draws a string within the boundaries of an SDL_Rect, as you could imagine. Here's a little screenshot showing off the NSP_FONT_AUTOSIZE feature (non-monospaced fonts), SDL_nDrawStringInRect() (the purple rectangle is only to show how it fits itself inside it, it's not part of the function), and an image included in the executable (everything is of course well integrated into SDL, the SDL_nLoadImage() function returns an SDL_Surface for example):

(http://i.imgur.com/SmtBX.png)

Here's also a more recent screenshot of the image converter that'll be included with nSDL 0.2.0:

(http://i.imgur.com/ISIzC.png)
Title: Re: nSDL (0.1.4 beta)
Post by: atiatinini on April 20, 2012, 07:38:58 pm
Amazing!  :)
Just wondering, how's the performance of this compared to BMP blitting?
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 20, 2012, 07:48:20 pm
Amazing!  :)
Just wondering, how's the performance of this compared to BMP blitting?
Should be exactly the same as the result is the same (SDL_Surface).
Title: Re: nSDL (0.1.4 beta)
Post by: DJ Omnimaga on April 20, 2012, 11:27:07 pm
Awesome update Hoffa. :)

Off-topic: Those tiles are nice. Are they from a game in particular or did you make them yourself?
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on April 21, 2012, 09:18:00 am
Now by default all text is somewhat formatted before drawn on the screen, i.e. unnecessary spaces are removed. It can be removed for whatever reason using the NSP_FONT_NOFORMAT flag. Screenshot (the string used is the one in quotes of course):

(http://i.imgur.com/ajsZj.png)

I'll probably add word wrapping at some point too, not sure how cleanly it'll fit in the code. Speaking of cleanness, I've removed tab support, all font width/height getter functions I had at one point, and the textwrapping feature when using SDL_nDrawString(). That is because those features are very rarely useful, have inconsistent behavior and are a bitch to maintain and integrate. They would only be useful in console-type applications, and in that case nspireio should do the job. Removing them allows much cleaner and more robust code.

EDIT: After some further thought, I'll possibly add the string width/height getter functions again. It was especially the tab character that made me hesitate, but now that it's gone I guess I can clean those functions up. They might be useful for drawing centered text and whatnot.

Off-topic: Those tiles are nice. Are they from a game in particular or did you make them yourself?
Some free ones I found somewhere I can't remember.
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on May 02, 2012, 03:58:23 pm
0.2.0 coming very soon... :ninja:
Title: Re: nSDL (0.1.4 beta)
Post by: hoffa on May 04, 2012, 01:00:44 pm
Here's a screenshot of a little program I'm writing for a TI-Nspire SDL tutorial I'm working on:

(http://i.imgur.com/bN8Fv.png)

I actually released 0.2.0 but didn't make it public, as I found some small issues (found them while working on the aforementioned program) that needed to be fixed, so the next public version will be 0.2.1, which should be out tomorrow if everything goes well.
Title: Re: nSDL (0.1.4 beta)
Post by: hellninjas on May 04, 2012, 02:43:36 pm
This looks REALLY cool..
+1!
Title: Re: nSDL (0.1.4 beta)
Post by: Lionel Debroux on May 04, 2012, 02:49:53 pm
Yup, as usual, this is good work :)

Relayed at TI-Planet, http://tiplanet.org/forum/viewtopic.php?t=8907&p=123755#p123755 ;)
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: hoffa on May 05, 2012, 01:06:42 pm
0.2.1 is out! ;D
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: Yeong on May 05, 2012, 01:26:19 pm
is SDL easier to program than nspire c/asm?
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: hoffa on May 05, 2012, 01:35:38 pm
is SDL easier to program than nspire c/asm?
Well it still is in C. But yes, it is much easier than doing everything from scratch. Also SDL's quite mature and there's a lot of resources and information available on the Internet about it, that's always good.
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: atiatinini on May 05, 2012, 03:28:08 pm
Any progress in C++ support?  :)
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: hoffa on May 05, 2012, 03:51:15 pm
Any progress in C++ support?  :)
No idea, I'm not the one dealing with that. I don't think anyone is working to get C++ on the TI-Nspire.
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: DJ Omnimaga on May 05, 2012, 08:29:26 pm
Didn't certain C++ commands work on the Nspire though? I remember there was a post somewhere claiming some did... ???

Also nice update on this :)
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: Adriweb on May 06, 2012, 04:15:57 am
Tangrs was/is working on a C++ compiler, but I don't know the status of that right now....
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: hoffa on May 07, 2012, 03:20:49 pm
Some updates...
I will probably release unexpectedly soon the following version, 0.3.0. I'm writing a lot of the video code for full compatibility on all calculators without the need to recompile (and not the slightest impact on performance). That means one program for all calculators. (it's quite a major change, hence the jump to 0.3.0 right away)
There's also a bug with uneven width images when using the array-based images that needs to be fixed.
I'll probably add a mode for easier porting that shows a message box when an error occurs, avoids mystical reboots and such.

Here's the Zelda example running on both machines in 8 bpp, same binary for both (and as you can see in the version, no more nSDL 0.2.0-8/16-cx wizardry):
(http://webgel.net/bf/5/sdl.png)
That also means there'll be no NSP_BPP, so the user will have to specify the bit depth (if 16 bpp is used, it'll be forced to 8 bpp on classic models).

EDIT: here's the on-calc debug helper in action:
(http://webgel.net/bf/debug.png)
It shows all messages printed with NSP_DPRINT() and SDL_SetError().
Title: Re: nSDL 0.2.1—A fast, robust, cross-platform graphics library for the TI-Nspire
Post by: hoffa on May 11, 2012, 12:18:34 pm
0.3.0, with a few changes:


Here's the Zelda example running in 100x100:
(http://i.imgur.com/8LaoJ.png)

This version should be quite useful for porting SDL programs.

Download here (http://hoffa.github.com/nSDL/).
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Hayleia on May 11, 2012, 01:56:06 pm
This looks great :D
I hope a lot of people will code games for Nspires with this :)

Btw, if it is now v0.3.0, you might want to change the title of the first post Nevermind :P
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Adriweb on May 11, 2012, 03:20:06 pm
Very nice :D

Also, since it's a "universal binary", what the size difference with the version before ? Probably not much ? (which means it's easier anyway for the programmer/user)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: willrandship on May 11, 2012, 04:15:30 pm
hmm....

BASIC commands that use this....mmmmm :)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 12, 2012, 08:00:45 am
Very nice :D

Also, since it's a "universal binary", what the size difference with the version before ? Probably not much ? (which means it's easier anyway for the programmer/user)
There's practically no difference.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 13, 2012, 07:41:14 am
I've been doing some porting lately to see how it works.

First of all I ported a small CHIP-8/SCHIP emulator:
(http://webgel.net/bf/chip8.png)

(http://webgel.net/bf/chip82.png)
(Joust up in this mothafaqa)

But because of the way the CHIP-8 system works, it flickers (no buffers) and requires fine configuring (how many opcodes before drawing etc.), can't bother to play around with it to get everything to run smoothly.

Then I tried a space shooter I found on the web, and seems to work well except there's no fscanf on the TI-Nspire, and as such I cannot load the mission files, which means I only see this: (I can move around and shoot and everything)
(http://webgel.net/bf/6/test.png)
(That's a screenshot from the two player mode)

Haven't had any major issues or troubles porting the programs currently.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: compu on May 13, 2012, 08:10:30 am
Nice!

GCC has __builtin_fscanf() as far as I know.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: critor on May 13, 2012, 08:23:22 am
Please correct me if I'm wrong:

We can easily port only:
- games whose source code is available
- games which relies on the SDL library
- games which doesn't use assembly (between an MS-DOS and a Linux version of the same game, we should choose to work on the Linux version)
- games written in C (no C++)


Meaning that until we've got a C++ toolchain for Ndless, most of the greatest SDL games/emulators can't be ported?...
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 13, 2012, 08:43:51 am
We can easily port only:
- games whose source code is available
- games which relies on the SDL library
- games which doesn't use assembly (between an MS-DOS and a Linux version of the same game, we should choose to work on the Linux version)
- games written in C (no C++)
Also resolution should be taken into account, as nSDL handles resolution <= 320x240. Oh and global variables can be a source of frustration on bigger programs as there's no stable loader currently. Thankfully GP32/GP2X and some other machines have many games, use SDL, have a 320x240 resolution and many (most?) of the games are written in C. Oh and of course all the DOS clones/ports in SDL (C-Dogs, OpenTyrian and whatnot) and generic flexible SDL games.

EDIT:

I hardcoded (using a simple script) the map data in the program and compiled it. Magic happened:
(http://webgel.net/bf/8/lol.png)
I've attached the game here in my post. I'd appreciate it if someone with a CX could try it (just dump the whole folder in the Examples folder on the TI-Nspire) and tell me how it runs. Even better would be to upload a video about it. If you have a Touchpad/Clickpad you can try it too, but the games' colors are quite dark; I couldn't see much (that made me think of a function that inverts the palette...hmm).

The controls are CTRL, tab, arrow keys (player 1) and 8/2/4/6, enter (player 2). Yes there's 2 player mode also.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Adriweb on May 13, 2012, 01:46:27 pm
Awesome ! :D

I just tried it on my CX-CAS and took a video of my lame playing-while-recording skills :P

:


(Anyway, this was filmed under bad (camera, lightning etc) conditions, so if anyone wants to do a better recording, please do so :D)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: alberthrocks on May 13, 2012, 02:23:35 pm
Please correct me if I'm wrong:

We can easily port only:
- games whose source code is available
- games which relies on the SDL library
- games which doesn't use assembly (between an MS-DOS and a Linux version of the same game, we should choose to work on the Linux version)
- games written in C (no C++)

Meaning that until we've got a C++ toolchain for Ndless, most of the greatest SDL games/emulators can't be ported?...
To address some points:

- Yup, but that goes without saying. There is no way we can do any binary translation; otherwise, iOS apps could then be ported to Android. (OK, bad example, but you know what I mean)
- Yeah, pretty much. But SDL will still let people create new games too :)
- Somewhat - assembly can be ported too. SDL emulators in particular can use this. More or less, C -> ASM for any emulator work because C would be (somewhat) slow.
- There's a bFLT loader that is supposedly done, which supports C++ programming. (See here (https://github.com/tangrs/ndless-bflt-loader/tree/c++-support).) I do not know of its status, and whether or not it has merged with the official ndless tree, or if it's stable or not. (I think the author, tangrs, is busy with his finals, so... ExtendeD and tangrs can clarify its status.)

There's one little thing that I'd like to see implemented before it gets off: replacing library IDs with Java-style names. (For instance, "com.alberthrocks.myawesomelibrary") There's a max of 256 libraries that can be had, which in the future may not be enough. (I've indicated that idea here (http://ourl.ca/15736/294998).) Unfortunately I don't have enough experience to try this, so... :P
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Lionel Debroux on May 13, 2012, 02:29:17 pm
Quote
I do not know of its status, and whether or not it has merged with the official ndless tree
It has not yet.

Quote
There's one little thing that I'd like to see implemented before it gets off: replacing library IDs with Java-style names.
If it cannot be done with standard bFLT (and I'm not aware it can be done), it's unlikely to be something we want to do: hacked up formats require non-standard toolchains, which are a maintenance burden in the long term ;)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: alberthrocks on May 13, 2012, 03:10:04 pm
Quote
I do not know of its status, and whether or not it has merged with the official ndless tree
It has not yet.
Ahh... if only I had time to work on this :/ (I have college-like finals, aka CollegeBoard AP tests this week.)

If it cannot be done with standard bFLT (and I'm not aware it can be done), it's unlikely to be something we want to do: hacked up formats require non-standard toolchains, which are a maintenance burden in the long term ;)
True :) Well... I guess we could reserve a few numbers for ndless' core and particular important libraries, and then use some kind of ID manager for the rest. I just hope implementing all of this won't get too messy...
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: DJ Omnimaga on May 14, 2012, 07:04:54 pm
That is great. I love the progress on this. Hopefully converting SDL games won't be too hard in the future. :)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 15, 2012, 01:11:47 pm
As the porting went rather well, I'm now working on an improved public version (named Dodgin' Diamond 2X) of the aforementioned game, Dodgin' Diamond 2. As usual, a screenshot, of the game's menu:

(http://webgel.net/bf/dd2x.png)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Adriweb on May 15, 2012, 01:27:25 pm
Can you share the file ? :P

edit : whenever it's done :D
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Hayleia on May 16, 2012, 11:58:57 am
I hardcoded (using a simple script) the map data in the program and compiled it. Magic happened:
Spoiler For Spoiler:
(http://webgel.net/bf/8/lol.png)
I've attached the game here in my post. I'd appreciate it if someone with a CX could try it (just dump the whole folder in the Examples folder on the TI-Nspire) and tell me how it runs. Even better would be to upload a video about it. If you have a Touchpad/Clickpad you can try it too, but the games' colors are quite dark; I couldn't see much (that made me think of a function that inverts the palette...hmm).

The controls are CTRL, tab, arrow keys (player 1) and 8/2/4/6, enter (player 2). Yes there's 2 player mode also.
I tried it on my CX, then with one of my friend, we couldn't stop playing in two player mode :P
However, would it be possible to remap the keys for the first player (or maybe the two players) ? Because the Touchpad sucks a lot.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 16, 2012, 02:15:59 pm
I hardcoded (using a simple script) the map data in the program and compiled it. Magic happened:
Spoiler For Spoiler:
(http://webgel.net/bf/8/lol.png)
I've attached the game here in my post. I'd appreciate it if someone with a CX could try it (just dump the whole folder in the Examples folder on the TI-Nspire) and tell me how it runs. Even better would be to upload a video about it. If you have a Touchpad/Clickpad you can try it too, but the games' colors are quite dark; I couldn't see much (that made me think of a function that inverts the palette...hmm).

The controls are CTRL, tab, arrow keys (player 1) and 8/2/4/6, enter (player 2). Yes there's 2 player mode also.
I tried it on my CX, then with one of my friend, we couldn't stop playing in two player mode :P
However, would it be possible to remap the keys for the first player (or maybe the two players) ? Because the Touchpad sucks a lot.

What keys would you suggest? I admit my touchpad is crap too (feels very unresponsive and soft).

EDIT: I'll make it touchpad and/or numpad in single player, and only touchpad in co-op.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Hayleia on May 16, 2012, 02:28:57 pm
EDIT: I'll make it touchpad and/or numpad in single player, and only touchpad in co-op.
Good idea :)

What keys would you suggest? I admit my touchpad is crap too (feels very unresponsive and soft).
Else, you could also use the numpad for player one and some of the bottom keys for the second player, like I for up, W for down, ',' for left, R for right and Space to shoot ?

Or something even better would be to make several key_config external files (like the ones we must put in Examples) that the game would load, and according to which one we have, the key configuration is not the same. But that may be a bit annoying to do for you :-\
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 16, 2012, 02:47:38 pm
What keys would you suggest? I admit my touchpad is crap too (feels very unresponsive and soft).
Else, you could also use the numpad for player one and some of the bottom keys for the second player, like I for up, W for down, ',' for left, R for right and Space to shoot ?

Or something even better would be to make several key_config external files (like the ones we must put in Examples) that the game would load, and according to which one we have, the key configuration is not the same. But that may be a bit annoying to do for you :-\
I'm not sure if playing with the tiny buttons is more comfortable than with the touchpad. I think I'll keep it touchpad/numpad in the first version at least, and later I'll look into external config files if I have the time. Meanwhile, here's a screenshot of the improved version I'm working on:

(http://webgel.net/bf/1/dd2x.png)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Hayleia on May 16, 2012, 03:31:26 pm
I'm not sure if playing with the tiny buttons is more comfortable than with the touchpad. I think I'll keep it touchpad/numpad in the first version at least, and later I'll look into external config files if I have the time.
Yeah, I thought it would be hard too but in fact, once you placed your fingers on the keys, you don't move them a lot in this type of game. Moreover, the touchpad doesn't allow to push on two directionnal keys at a time (this is why my friend beat me the third time :P) and doesn't allow you to keep two fingers on the "buttons" :(

Also,
(http://webgel.net/bf/1/dd2x.png)
/me wants O.O
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 16, 2012, 03:42:45 pm
I'm not sure if playing with the tiny buttons is more comfortable than with the touchpad. I think I'll keep it touchpad/numpad in the first version at least, and later I'll look into external config files if I have the time.
Yeah, I thought it would be hard too but in fact, once you placed your fingers on the keys, you don't move them a lot in this type of game. Moreover, the touchpad doesn't allow to push on two directionnal keys at a time (this is why my friend beat me the third time :P) and doesn't allow you to keep two fingers on the "buttons" :(
Maybe you're right. Being unable to move diagonally is a good argument actually, so I guess I'll do it numpad for player 1 and keyboard for player 2. It'll leave the Clickpad users out for (playable) two player mode, but once I release nSDL 0.3.1 there'll be diagonal touchpad key support too, which will probably make me update this and switch back.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Hayleia on May 16, 2012, 03:49:58 pm
Thanks for taking my arguments in consideration :)

...but once I release nSDL 0.3.1 there'll be diagonal touchpad key support too, which will probably make me update this and switch back.
Or make those config files :P
But don't worry, there is no hurry ;)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: cyanophycean314 on May 16, 2012, 09:25:39 pm
(http://webgel.net/bf/1/dd2x.png)

This is looking better than ever! I wants.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Alex on May 17, 2012, 10:34:54 am
Wahou! Cool! I wants.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 18, 2012, 06:40:45 pm
The game has now been released: http://ourl.ca/16186 (http://ourl.ca/16186)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: TheNlightenedOne on May 18, 2012, 11:11:16 pm
It looks awesome, but... nSDL programs are huge!
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 19, 2012, 05:34:14 am
Yeah, the overwhelming majority of the space is taken by the 792x445 bitmap sprite sheet. As I mentioned in the post, it could have been considerably smaller if I had the time to rearrange the sprite sheet (it would require to change all of the hardcoded values in the code), as there's a lot of empty space in it. I will probably at some point rearrange it, which should reduce the size by at least twice.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: DJ Omnimaga on May 22, 2012, 08:33:38 pm
Wow great stuff again. I really hope when nSDL comes out that it will help bringing an influx of new Ndless games to the community.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: piexil on May 23, 2012, 02:41:20 pm
I wonder if a port of Dosbox would be possible using this.
IIRC It uses SDL

But, I think the lowest thing it's been compiled for is ARMv6/ARM11, and IIRC the nspire is ARM9/v5.
I wonder how the speed of emulating a 286/386 Real would run, then again someone did make an x86 emulator for the DS.
Sorry for going a little off-topic :$
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Lionel Debroux on May 25, 2012, 12:08:56 pm
Quote
I really hope when nSDL comes out that it will help bringing an influx of new Ndless games to the community.
I hope so too, but the hard fact is that TI will release OS 3.2 before nSDL usage by programmers has a chance to really take off...

Quote
I wonder if a port of Dosbox would be possible using this.
Possible, maybe... but I'm not so sure that it would be usable for anything but the 8086 and the slower 80286 versions, as the poor little ARM CPU in the Nspire is not very powerful. Each core of the newest ARM CPUs does an order of magnitude better than the Nspire's CPU.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Jim Bauwens on May 25, 2012, 12:12:17 pm
DOSbox is mainly C++ IIRC. We first need to wait for better C++ support in order to port it.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: critor on May 28, 2012, 06:54:09 pm
Atiatinini, could you please release the source code of your plasma demo?

I think such a simple example would help many people figuring out what has to be changed when porting a PC SDL game.


Thanks.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: hoffa on May 31, 2012, 01:09:39 pm
Just passing by to say there'll probably only be one quick update (or none at all) at some point before I stop maintaining nSDL and generally end all involvement in calculator-related stuff. I have my exams right now and should be studying; no time to play around. Two days after graduation I hop on plane to Finland for my year-long conscription in the Finnish marines (hopefully eventually getting into army reserve officer school). Once that's done I'm moving to the UK for my university studies and will have other things on my mind.

@critor: http://ourl.ca/14975;msg=241303 (http://ourl.ca/14975;msg=241303)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: ExtendeD on May 31, 2012, 01:29:26 pm
That is sad for the TI-Nspire community... Hopefully someone will take the maintenance of nSDL after you and bring it even further.

Anyway thank you again for all you efforts and good luck with your personal projects :)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: DJ Omnimaga on May 31, 2012, 01:31:44 pm
Sorry to hear. I hope you still pass by from time to time to say hello. Good luck!

Hopefully someone takes over nSDL in the near future.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Jim Bauwens on May 31, 2012, 01:36:57 pm
Aww, that's not too nice.
But good luck whatever you have planned with your life :)
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: ruler501 on May 31, 2012, 10:20:51 pm
Good luck hoffa. sad to see you go. You've done great on making this and it should help launch some new interest in the nspire.
Title: Re: nSDL 0.3.0—A fast & robust TI-Nspire graphics library
Post by: Lionel Debroux on June 01, 2012, 01:37:16 am
Indeed, sad to see one of the most productive members leave the community. Good luck :)
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 07, 2012, 07:49:05 am
My last update for nSDL is here, 0.3.1. Changes are:

- Updated Image to NTI converter for faster speed and better handling of larger pictures
- Renamed SDL_n* functions to nSDL_*
- Renamed NSP_* macros to NSDL_*
- Renamed SDL_* environment variables to NSDL_*
- Removed NSP_HSPACING_DEFAULT, NSP_VSPACING_DEFAULT, NSP_NAME, NSP_NAME_FULL, NSP_RMASK16, NSP_GMASK16, NSP_BMASK16, SDL_nCreatePalette(), SDL_nDrawChar()
- Key mapping changed
- Diagonal arrow keys are correctly handled
- Performance improvements
- Binaries should be slightly smaller

The wiki (https://github.com/Hoffa/nSDL/wiki) has been changed accordingly.

As usual, download here (http://hoffa.github.com/nSDL/).
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 11, 2012, 01:02:36 am
Now that SDL for the TI-Nspire works rather well and has been under development for some time, I will probably (despite my finals) try and port a very fast software implementation of OpenGL (based on TinyGL). That could mean some serious 3D stuff soon. There'll also be a very last update for nSDL that basically does some final cleaning up to leave a nice little package before I go.
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: Eiyeron on June 11, 2012, 05:09:50 am
WOn't you work on SDl's addons? That would be quite useful!
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 11, 2012, 11:18:34 am
WOn't you work on SDl's addons? That would be quite useful!
Yessir!

(http://i.imgur.com/0dsha.png)

SDL_gfx up in this!

EDIT:
WELL, WELL, WELL, what do we have here?

(http://i.imgur.com/cJ6Z8.png)
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: Lionel Debroux on June 11, 2012, 12:45:25 pm
Interesting ;)
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: ruler501 on June 11, 2012, 02:32:44 pm
Is there any way of easily finding where you made changes to the SDL source? I would like to look a little to see what it takes to port it to a new platform
Title: Re: nSDL 0.3.1—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 11, 2012, 03:01:16 pm
I've now updated nSDL to 0.3.2. I've done some major housekeeping, the code should be a lot cleaner and everything should be nicely organized (the current video code for instance (here (https://github.com/Hoffa/nSDL/blob/master/src/video/tinspire/SDL_tinspirevideo.c)) is nearly twice as small as 0.2.0's 400-liner (here (https://github.com/Hoffa/nSDL/blob/997397c18b966133b20efda07bc2ab8bab56e3fc/src/video/tinspire/SDL_tinspirevideo.c))). I've purged all crap from everywhere, no more mouse support because it wasn't perfect when using SDL_PollEvent() and I couldn't bother to debug it (and I think Lua's better for that kind of stuff), no more diagonal arrow key support I added in the previous version. Removing those two simplified the event fetching code to a simple little loop, which means it's faster and I'm much more content with it. It's such a rewarding feeling to clean shit up.

Anyway I also added SDL_gfx and updated fdlibm no one's heard about (it's a working, fast, Sun's full implementation of math.h functions; newlib's math functions don't work): https://github.com/Hoffa/nSDL/wiki/Additional-libraries (https://github.com/Hoffa/nSDL/wiki/Additional-libraries)
I haven't really tested SDL_gfx THAT MUCH, but it should run alright. SDL_gfx allows you to rotate and stretch images, draw anti-aliased lines, circles, triangles and all of your deepest fantasies. If I remember correctly it should do some heavy surface conversions on the fly so it might be pretty damn slow on a calculator, but I haven't tested so what do I know.

So here are the changes:
- Removed mouse, diagonal arrow key support
- Using SDL_GetVideoInfo() should now always give accurate information
- Faster event loop
- A LOT of cleaning up
- Apart from nSDL itself, added SDL_gfx and updated fdlibm

I think I'm finally ready to leave my baby for quite a long time.

Is there any way of easily finding where you made changes to the SDL source? I would like to look a little to see what it takes to port it to a new platform
Sure. Check out the source code here: https://github.com/Hoffa/nSDL (https://github.com/Hoffa/nSDL)
If you don't see "Initial commit." next to the file, it means I've changed something. Click on the message the view the changes of that commit. You can browse different commits here also: https://github.com/Hoffa/nSDL/commits/master (https://github.com/Hoffa/nSDL/commits/master)
Most of the interesting stuff is in the src/ folder obviously.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Jim Bauwens on June 11, 2012, 03:23:34 pm
Nice hoffa :)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Eiyeron on June 12, 2012, 05:37:00 am
(http://www.instructables.com/files/deriv/FV2/SFKD/FZNHOUDY/FV2SFKDFZNHOUDY.MEDIUM.jpg)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: ruler501 on June 12, 2012, 10:42:07 pm
Where is SCREEN_WIDTH defined? I cannot seem to find its definition anywhere but you use it in nspirevideo and sdl uses it in joystick.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 13, 2012, 12:51:36 am
In libndls.h, included by os.h.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: ruler501 on June 13, 2012, 01:01:51 am
Ok thanks was driving me crazy not being able to find it.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: critor on June 23, 2012, 08:39:49 am
Wow that looks great. :D When this is available for download, I need to try the color version to see how this looks like on my CX (assuming a demo of the above is made available?). :D
Of course!  :D

CX:
http://www.mediafire.com/?7omfqojuxjjrpp2
Touchpad/Clickpad:
http://www.mediafire.com/?ax8dyd9xqgjb2z5

And here's the source (just ignore my dirty random generator at the end):
http://pastebin.com/gqjXDTBw

Also, please note that the actual code that generates the plasma effect was not made by me, this is just a port of a demo available here (http://www.libsdl.org/projects/plasma/).

Trying to recompile the plasma demo, I get an undefined reference to the sinus function.
How did you do?

Thanks.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 23, 2012, 09:12:43 am
Newlib's math library doesn't work, so you have to use another library. In fact you need to use fdlibm compiled for the TI-Nspire, which you can find here (https://github.com/Hoffa/nSDL/wiki/Additional-libraries). (I suggest including fdlibm.h rather than math.h, but both should work since they should be pretty much identical)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Adriweb on June 23, 2012, 02:49:15 pm
He finally got it working with   -lm  :)

Here's the game he ported : http://tiplanet.org/forum/viewtopic.php?p=126303#p126303
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: cyanophycean314 on June 23, 2012, 05:56:45 pm
That video looks awesome! :)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Juju on June 23, 2012, 10:41:50 pm
fdlibm eh? Gotta try on the Prizm. Unless someone manages to make it work with newlib.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: hoffa on June 24, 2012, 06:26:44 am
fdlibm eh? Gotta try on the Prizm. Unless someone manages to make it work with newlib.
Yeah you should be able to compile it easily using the code from here (https://github.com/Hoffa/nSDL/tree/master/tinspire/libs/fdlibm-1.5-r2). I'm not sure if there are any issues with globals on the Prizm, but that code should compile perfectly on any platform, just edit the Makefile a bit (and rename the resulting libm.a to libfdm.a to avoid doubts and name collisions). Oh and in fdlibm.h, remove the #ifdef _TINSPIRE/#endif at the top.

He finally got it working with   -lm  :)

Here's the game he ported : http://tiplanet.org/forum/viewtopic.php?p=126303#p126303
Damn that's awesome!

EDIT:
I edited the voxel demo a bit (nearly tripled range, made mountains much bigger and imposing, made it run full screen, added Mars-like colors and some other adjustments):
(http://i.imgur.com/KfJ6q.png)

I've attached the download (yes, I know it's massive, it's because I couldn't bother to reduce the gigantic trig lookup table). Code's here (http://pastebin.com/KhNEcvxu). Check it out, tell me how it runs (on the Touchpad it seems to be pretty smooth, but it's hard to tell with the shitty LCD).

Controls are arrow keys to move, 5 toggle noclip, and +/- to increase/decrease altitude when in noclip.

EDIT2: Added a porting tips (https://github.com/Hoffa/nSDL/wiki/Porting-tips) page in the wiki.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Yeong on June 27, 2012, 10:16:18 am
so I heard that there's a gba emulator using SDL or something (at least I think that's what calc84maniac said before). Will it be possible to port it to nspire?
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: calc84maniac on June 27, 2012, 10:20:27 am
so I heard that there's a gba emulator using SDL or something (at least I think that's what calc84maniac said before). Will it be possible to port it to nspire?
I'm already porting it (and I removed all SDL references as well, since it's mainly used for the framebuffer)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Yeong on June 27, 2012, 10:20:56 am
O.o I can't wait!
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: critor on June 27, 2012, 10:58:09 am
so I heard that there's a gba emulator using SDL or something (at least I think that's what calc84maniac said before). Will it be possible to port it to nspire?
I'm already porting it (and I removed all SDL references as well, since it's mainly used for the framebuffer)

If I'm thinking of the same emulator, it's written in C++.

Do many things have to be changed/rewritten ?
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: calc84maniac on June 27, 2012, 11:02:20 am
You're not thinking of the same emulator. This is the GP2X/Wiz version of gpSP.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Yeong on June 27, 2012, 11:58:47 am
so ETA of release? ;D
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: xacto on July 03, 2012, 03:37:10 am
So how long have you been working on porting it to nspire?
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: hoffa on July 06, 2012, 12:43:43 pm
Done! The diploma's in my pocket, got the grades I needed for UK university in 2013. My plane for the army is leaving tomorrow.

Farewell! ;D

(I'll be keeping my thumbs up for an eventual influx of some new Nspire programmers in September. :P)

EDIT:

Hair's cut, papers are in order, I'm ready to swim in ice cold water 60 kg on my back and fire a few rounds meanwhile:

Spoiler For Spoiler:
(http://i.imgur.com/UfWxg.png)

Damn, I look like a goddamn jock already.

This is Hoffa 101, can you read?
...
Hoffa 101, ending transmission. Over.
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Lionel Debroux on July 06, 2012, 12:48:54 pm
Farewell, and thanks ;)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: critor on July 06, 2012, 12:52:46 pm
See you again and thanks for everything you've done up to now :)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: cyanophycean314 on July 06, 2012, 09:13:20 pm
Great work and have fun!  :)
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: Torio on July 16, 2012, 12:44:26 pm
Hello,
Is it possible to increase the size of letters drawn by nSDL_DrawStr() ?

Thank you,
Torio
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: DJ Omnimaga on July 17, 2012, 03:16:56 am
Farewell Hoffa. Hopefully in the future you can return or show up a few times around here :). Good luck!
Title: Re: nSDL 0.3.2—A fast & robust TI-Nspire graphics library
Post by: ruler501 on July 31, 2012, 10:34:08 pm
Hello,
Is it possible to increase the size of letters drawn by nSDL_DrawStr() ?

Thank you,
Torio
I do not think so if I remember from when I looked through the code its a hardcoded value
Title: Re: nSDL 1.0—A very fast & robust TI-Nspire graphics library
Post by: hoffa on September 01, 2012, 05:38:55 pm
Hooyah!

Updated to 1.0. Not much to say except that it's 1.0 and it contains bug fixes and such. Also it doesn't print all that debug crap anymore. Oh and some minor stuff not worth mentioning. Through many rigorous scientific trials it has been proven nSDL in its current state isn't a fragile piece of buggy code (and I'm rather content with it), and deserves its 1.0. Let's just hope there'll be an influx of new Nspire programmers.

I still need to update the how-to page on the wiki to adapt to the newest Ndless changes, I'll do it when I can.

PS: Salutations from the 3rd platoon Coastal Jaeger Company of the Finnish Marines:
Spoiler For Spoiler:
(http://i.imgur.com/EK29N.jpg)

Be afraid. Be very afraid.
I'm posing on my knees near the ghetto booty, if anyone cares. Despite the faces, can't wait to get out of here.
Title: Re: nSDL 1.0—A very fast & robust TI-Nspire graphics library
Post by: Eiyeron on September 01, 2012, 05:51:50 pm
Congrats!
Title: Re: nSDL 1.0—A very fast & robust TI-Nspire graphics library
Post by: Lionel Debroux on September 02, 2012, 02:16:19 am
Good :)

Quote
Let's just hope there'll be an influx of new Nspire programmers.
Sadly, unlikely: the next OS version will certainly set the anti-downgrade protection high enough to prevent going back to OS 3.1.0.392.
Title: Re: nSDL 1.0—A very fast & robust TI-Nspire graphics library
Post by: DJ Omnimaga on September 02, 2012, 02:24:30 am
Glad to still see you around :D
Title: Re: nSDL 1.0.1—A very fast & robust graphics library
Post by: Eiyeron on September 17, 2012, 02:24:10 pm
By the way, is the mouse supported or nope?

I want to port some demos! :p

EDIT: aw right, removed because stability issues...
Title: Re: nSDL 1.0.1—A very fast & robust graphics library
Post by: alberthrocks on September 17, 2012, 03:05:51 pm
Is there any way SDL_GetTicks() can get implemented? It currently aborts due to SDL Threads not being implemented.
Title: Re: nSDL 1.0.1—A very fast & robust graphics library
Post by: hoffa on September 17, 2012, 03:54:15 pm
SDL_GetTicks()? It should be working according to my knowledge. It doesn't even require any threads or anything. Are you sure you don't mean timers? What version of nSDL are you using? Could you post the code that doesn't work?

@Eiyeron: yeah, too unstable/buggy for my taste. Got it to work smoothly when SDL_WaitEvent() was used; it was a staggering mess with SDL_PollEvent(), never really figured out what the issue was because of a lack of time (got my ass conscripted, as the profile picture suggests). I wanted my last real release to be as clean and stable as possible, see. You can still grab an older version of nSDL though if you want (here (https://github.com/Hoffa/nSDL/tags)), but check the changelog for the latest version that had experimental mouse support.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on November 29, 2012, 11:50:56 am
Tiny update that handles arrow keys better (diagonal arrow keys supported) and maps the Nspire's touchpad click button to SDLK_KB_ENTER. Those were supposed to be included in an update with functional mouse support, but as it's been taking so long and can't test my code on an actual TI-Nspire (and probably won't for long), I decided to push those changes to master so they're outta the way.

(Download's on the website, as usual)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: SpiroH on November 29, 2012, 12:14:49 pm
Thank you soldier. Have a nice pleasant fight. ;)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Hayleia on November 29, 2012, 12:31:51 pm
(offtopic, is it normal to have post ratings disabled on this topic ?)

Anyway, this is great to see an update on this project, even a "tiny" one. It shows that even if you don't have a lot of time, you did not discontinue it completely :)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: DJ Omnimaga on December 07, 2012, 05:25:18 pm
Yeah, they created a sub-forum for the project but forgot to enable post ratings in it (it's disabled by default). You could PM an admin about it.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 03, 2013, 04:24:14 am
Bump,

I've several questions :

Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: ExtendeD on January 03, 2013, 07:26:17 am
Isn't your strflc() similar to strrchr(...) - argv[0]?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 03, 2013, 08:26:13 am
Oh yeah, I didn't think of it that way ...
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 03, 2013, 03:09:28 pm
  • In my program, I'm loading a bitmap with SDL_LoadBMP(path), but it seems that relative path doesn't work. If I have image.bmp.tns in the same directory as my program, just typing SDL_LoadBMP("image.bmp.tns"); doesn't work. Is there a way to fix that ?
Yeah that must be because of the way ndless (or syscalls, whatever) handle opening files (at some point in the code it's just calling fopen). Rather than implementing the relative path thing in nSDL, I think it would be better to do it in the fopen code itself for consistency across all programs. Despite that, I've never had to use "/documents/Examples/derp.bmp.tns" as the path, "Examples/derp.bmp.tns" has always worked IIRC.

  • Second question, I have sprites that have transparent parts, but it seems that transparency isn't supported due to the NTI format and get replaced by white 0xffff. Is there a way to use transparent sprites or are they forbidden ?
The format itself doesn't support transparency (neither does BMP), but SDL does support color keys for surfaces, and that's what you should be using. In the image, draw (in Paint or whatever) the parts that you want transparent with a certain color (#ff00ff is quite common) and after you've loaded it and have its SDL_Surface, do SDL_SetColorKey(surface, SDL_SRCCOLORKEY, SDL_MapRGB(screen->format, 0xff, 0x00, 0xff)). More info here (http://www.libsdl.org/docs/html/sdlsetcolorkey.html).
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 04, 2013, 04:24:57 pm
Thanks for that :)

Do you think you'll port SDL_Image to Nspire someday ? It would be really, really useful to load various image formats :)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 06, 2013, 04:24:48 pm
Fuck me. For last few hours I've been trying to port SDL_image, and it has been one of the most frustrating experiences ever. I fucking hate debugging, someone please shoot me in the head, blow my brains out and burn my body with fire. ExtendeD I really would like you to fix the relocation issues, it's unbelievably horrible (but I suppose you know more than well enough the feeling I'm feeling right now, so no hurry). I even managed to film the whole process (actually now, the video begins after about 2 hours of debugging). Watch it. Feel my pain. We need to raise awareness!



I will never ever work as a code monkey in some gigantic corporation, I'd kill myself  before that. Debugging some mysterious black magic is not my thing. I don't mind coding but FUCK this is crazy my brain is completely fucked and I need to hit some boxing bag to release the tension inside me. My brain has been literally violated with the force of a thousand supermassive black holes. Goddamn global static arrays of structures with constant fucking strings and pointers to functions. The issues I'm having go against all the laws of physics and the behavior fluctuates faster than a Thai whore's mouth in Pattaya. It doesn't even have anything to do with the would-be complexity of the code. Even porting SDL and fixing its own flock of relocation issues wasn't this annoying. It should be a war crime to make me go through this kind of shit. If C was a person it would have been considered rape. Please ban me from the Internet for such vulgar terminology, tell me I'm a bad boy for saying no-no words and traumatizing the 7-year-old boys here. Give me a ticket, tell me I need to watch my language. Hack my IP, call the cyber cops, neg me to oblivion, tell your mom, I don't give a fuck. I feel like punching kittens right now.

Alright, calm down hoffa, everything's alright.

ALSO, I HATE THIS SHITTY LOW RESOLUTION ON MY LAPTOP.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 06, 2013, 04:40:49 pm
Oh waw O.O

Too bad I can't watch the video : "This video isn't watchable in your country" D:

I haven't done many programs, but I think I can understand what you're feeling :P Debugging is also the thing I hate the most in coding. It's so annoying and so frustrating when it doesn't work :banghead:
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 06, 2013, 04:47:53 pm
Yeah, worst thing there's no logic at all behind the issues I'm having. And I've done some serious debugging before, but this just takes it all to a whole new level.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: excale on January 06, 2013, 04:49:56 pm
How is debugging property of EMI?
(maybe you were listening to some music during the debug session and youtube spotted them?)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 06, 2013, 04:55:48 pm
@Hoffa what bugs are you encountering in fact ? Today I tried to port only the gif loading, and I didn't get any error other than "This file type is not supported" always. I just compiled SDL_image.h, IMG.c and IMG_gif.c (and removed all dependencies like constants and strings relatives to other formats). I just gave up after a few hours ;D but maybe I can help you debugging.

@Excale in fact it's "Cette vidéo n'est pas disponible dans votre pays" but I don't know how to say it properly in English :P
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 06, 2013, 05:03:06 pm
(new page, can't raise awareness like this)
Everybody! Look at this! This violates all international humanitarian laws: http://ourl.ca/14975/333020 (http://ourl.ca/14975/333020)

How is debugging property of EMI?
(maybe you were listening to some music during the debug session and youtube spotted them?)
Probably because I used "Don't Worry, Be Happy" as the background music.

@Hoffa what bugs are you encountering in fact ? Today I tried to port only the gif loading, and I didn't get any error other than "This file type is not supported" always. I just compiled SDL_image.h, IMG.c and IMG_gif.c (and removed all dependencies like constants and strings relatives to other formats). I just gave up after a few hours ;D but maybe I can help you debugging.
Yeah you have to define LOAD_GIF for it to even compile anything (otherwise it just compiles virtually empty functions, that's why you got the error). I have no idea what the issue nor do I want to think about it. It's some mix of relocation issues with ndless and pure magic. The behavior was irregular and completely illogical to even the most experienced human mind. Shit breaks down when it feels like it, next build doesn't, works with while but not for, reads one string but not the other, doesthefuckdoiknowwhat, etc.
It's worse than writing Brainfuck or Java, or trying to solve a Rubik's cube.

EDIT: Offtopic, but I got out of the Finnish Army this Friday. No more conscription. No more shaved head or asshole sergeants using you as a puppet. No more waking up at 6 AM, no more spending two weeks in the forest. No more 30-hour-long 70-km marches with 60 kg "camping" equipment on your back. No more APILAS, no more RK62, no more M72, no more TM 65 77, no more NSV. Feels great to back in normal life!

Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Adriweb on January 06, 2013, 06:38:38 pm
This worked for me : http://www.proxfree.com/youtube-proxy.php

Anyway, love your video x)

GL/HF :D
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Levak on January 06, 2013, 06:38:40 pm
(new page, can't raise awareness like this)
Everybody! Look at this! This violates all international humanitarian laws: http://ourl.ca/14975/333020 (http://ourl.ca/14975/333020)

How is debugging property of EMI?
(maybe you were listening to some music during the debug session and youtube spotted them?)
Probably because I used "Don't Worry, Be Happy" as the background music.
Maybe because you raged like hell on paint with some words some people might be shocked ? :o
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: DJ Omnimaga on January 06, 2013, 11:48:59 pm
At least it wasn't copyrighted by Sony Music Entertainment. If that was the case, your video would look suspicious, since a SME copyright block/warning is a very huge sign of rickroll. ;D

Anyway yeah debugging is annoying, and in my case I found it annoying with just TI-BASIC. I can't imagine how bad it must be with lower level languages. >.<
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 07, 2013, 04:35:23 pm
Done!

I finally managed to port SDL_image. The relocation issues were so frustrating I today decided to hardcode the cancerous part. Here's nSDL drawing the OpenBSD fish loaded from a GIF file:

(http://i.imgur.com/iiUNq.png)

Using the freshly ported SDL_image (which can be downloaded, as usual, here (https://github.com/Hoffa/nSDL/wiki/Additional-libraries)), you can now load images of the following formats: GIF, LBM, PCX, PNM, TGA and XCF.

You should now be able to use much less memory to store those pictures as opposed to using BMP (or the in-code NTI format). GIF images are usually at least 4 times smaller than their BMP counterpart.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: fb39ca4 on January 07, 2013, 06:31:04 pm
Is nDraw part of nSDL or is it a separate project?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 07, 2013, 06:33:35 pm
There's no such thing as nDraw. Blitting (or "drawing" as I referred it to) is all part of standard SDL.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: DJ Omnimaga on January 07, 2013, 07:50:07 pm
Great news! Hopefully this makes Matrefeytontias' F-Zero clone much smaller :P (currently, just one race track is 1 MB large)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: fb39ca4 on January 07, 2013, 07:57:24 pm
There's no such thing as nDraw. Blitting (or "drawing" as I referred it to) is all part of standard SDL.
So the picture on the first page no longer applies then.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 07, 2013, 08:22:11 pm
Nope. Oh wow, that was nearly a year ago. ;D
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 08, 2013, 12:58:29 am
Yay, awesome :D thanks a lot for it, I'll make a great use of it (especially with F-Zero yeah ;D )
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: ExtendeD on January 08, 2013, 03:55:00 am
ExtendeD I really would like you to fix the relocation issues, it's unbelievably horrible (but I suppose you know more than well enough the feeling I'm feeling right now, so no hurry).

Sorry about that. I really need tangrs to debug the issue with the bFLT loader and nSDL.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 08, 2013, 01:20:07 pm
Here's nSDL drawing the OpenBSD fish loaded from a GIF file:

How did you make it to have the right colours from a gif file ? I'm loading a gif image from /documents/Examples/map.gif and it doesn't have the right colours at all ... Have I to save it as a gif with 16-bits colours ? If so, how can you do it with Gimp ?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 08, 2013, 01:47:26 pm
Here's nSDL drawing the OpenBSD fish loaded from a GIF file:

How did you make it to have the right colours from a gif file ? I'm loading a gif image from /documents/Examples/map.gif and it doesn't have the right colours at all ... Have I to save it as a gif with 16-bits colours ? If so, how can you do it with Gimp ?
Dunno, I just saved the file as a GIF on Paint. Can you post the file here?
EDIT: Try if passing the surface through SDL_DisplayFormat() and see if it helps. BTW, for a speed boost you should always pass your files' surfaces through that function, it avoids SDL having to convert to the display format on the fly.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 09, 2013, 01:04:57 am
Ew, Out of Memory D: it's true that uncompressed, my gif file is 42 MB ... I'll just go with tilemapping.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 09, 2013, 06:32:06 am
Did you fix the color issue or not? Could you attach the file that caused problems here?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 10, 2013, 07:23:02 am
I'll be releasing a last version of nSDL before a very long pause. 6 months ago I said I wouldn't be able to update while in the army, but I could as I did have some free time. This time I really won't be able to work on nSDL at all, as I'm going backpacking in Australia for half a year, and I won't be taking my computer with me. So I want to release an Anniversary Edition of nSDL (as the 23rd it'll be 1 year since the creation of this thread) with some new features and such, and I also want to squash the last bugs so I can travel happily.

If you have ANY kind of ideas for improvements, suggestions, issues, whatever, please do say. Don't think too much about it, I'll do the filtering. :) Things that will be in the next release are among other things optimized pixel access functions and a solution to the relative path issue.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 10, 2013, 01:03:39 pm
I attached the image that caused problems.

Also I think that some kind of shaders would be cool, like colour modifying or others.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: fb39ca4 on January 10, 2013, 01:07:15 pm
Yeah, that would be a perfect candidate for tilemapping. As for shaders, wouldn't you just write those yourself in C?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 10, 2013, 01:11:11 pm
Of course I could, as for every SDL command ._. but since it can be optimized to work together with SDL, why do not ask hoffa ?

Also,
Yeah, that would be a perfect candidate for tilemapping.
^ I don't understand that :/ (sorry, French inside)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: fb39ca4 on January 10, 2013, 01:17:59 pm
Of course I could, as for every SDL command ._. but since it can be optimized to work together with SDL, why do not ask hoffa ?

Also,
Yeah, that would be a perfect candidate for tilemapping.
^ I don't understand that :/ (sorry, French inside)
The picture would be good for tilemapping because there are a lot of repeated patterns in there.

I don't think shaders have ever been a part of pure SDL.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 10, 2013, 01:19:27 pm
Of course I could, as for every SDL command ._. but since it can be optimized to work together with SDL, why do not ask hoffa ?

Also,
Yeah, that would be a perfect candidate for tilemapping.
^ I don't understand that :/ (sorry, French inside)
The picture would be good for tilemapping because there are a lot of repeated patterns in there.

Oh okay :)

And shaders aren't part of the original SDL, but why not make ones for nSDL ? We're not restricted to functionalities already existing in the original lib (see nSDL_LoadImage and others).
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 10, 2013, 01:40:28 pm
I have no issues, I get this while blitting the image: (don't mind the fish)

(http://i.imgur.com/ZjBaG.png)

You do understand the surface IMG_Load returns is 8bpp as the GIF is 8bpp?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 10, 2013, 01:41:01 pm
Yeah, but what's the code you're using ? You told me to use SDL_DisplayFormat, I did so.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 10, 2013, 02:00:24 pm
SDL_DisplayFormat converts the surface to the device's native format, i.e. on a CX it'll be converted to a 16-bit surface, on others it'll be 8 bpp. I think the issue is you're passing 16-bit color to the setpixel function that draws on a 8-bit surface or something. It's difficult to guess without the code.

As for the shaders, although it might be a good idea, it isn't really part of the low-level SDL philosophy, it's too high level without much use. I want to keep nSDL fast and efficient, as a razor sharp robust base for other things, or something.

EDIT: Maybe you should initialize SDL as 8 bpp? nSDL handles 8 bpp on CX, and as you're only dealing with 8 bpp stuff it would maybe be easier to concentrate only on one bit depth?
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: ruler501 on January 10, 2013, 06:11:01 pm
Maybe base a version of SDL2
/me hides
In all seriousness though it might be nice to have some form of shaders, but I'm not sure if they would go well with SDL. It would probably be better to have a seperate library for them.
One thing I think could be nice for some people would be to have more example programs illustrating nSDL specific programs and problems that might arise.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 10, 2013, 07:15:43 pm
I actually looked at SDL2, and I've been waiting for a long time for a stable version to come out (even for one PC project I'm working on that uses SDL2). Even when does come out, SDL2 has very little to add to a machine such as the TI-Nspire, expect maybe for the included drawing (lines and whatnot) functions.

As far as example programs are concerned, that's a very good point, and there'll be included sample(s) in the next release.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: ruler501 on January 10, 2013, 08:05:53 pm
I actually looked at SDL2, and I've been waiting for a long time for a stable version to come out (even for one PC project I'm working on that uses SDL2). Even when does come out, SDL2 has very little to add to a machine such as the TI-Nspire, expect maybe for the included drawing (lines and whatnot) functions.

As far as example programs are concerned, that's a very good point, and there'll be included sample(s) in the next release.
yeah I see how SDL2 is more for higher power devices. I don't think there's much added that you can't easily implement as a side part.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 11, 2013, 02:48:05 am
EDIT: Maybe you should initialize SDL as 8 bpp? nSDL handles 8 bpp on CX, and as you're only dealing with 8 bpp stuff it would maybe be easier to concentrate only on one bit depth?

Yeah, I can try that, but I don't know how to :/
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 11, 2013, 03:41:03 am
Just initialize SDL with a 8bpp bit depth, i.e. in the SDL_SetVideoMode instead of is_cx?16:8, just use 8.

But quite sure the color issue is just because of  some wrong SDL_PixelFormat passed to SDL_MapRGB (first parameter) or something. Your pixel access function should handle different bit depths automatically, and the only way to have strange results is by passing a wrong color.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 11, 2013, 09:38:11 am
It's kinda strange in fact. If I try to just blit my gif image (exactly the one I attached above) to the screen it's ok :

(http://img.removedfromgame.com/imgs/fzeroPlain.PNG)

But if I access it with my getPixel function I get that with 16 bpp :

(http://img.removedfromgame.com/imgs/fzeroBug16.PNG)

And that with 8 bpp :

(http://img.removedfromgame.com/imgs/fzeroBug8.PNG)

That's kinda strange ???
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 11, 2013, 10:13:19 am
Attach the whole code here, doesn't matter if it's ugly as hell. It's difficult to fix without any code. I'm pretty sure it's either your setpixel function that doesn't work, or that the color value that you're passing to the function isn't of the same bit depth as the surface on which you're drawing.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 12, 2013, 01:04:09 pm
I attached all that is needed to compile and test the program. But please, you who are watching this topic, don't use any of the code I posted, it's all full of unoptimized stuffs.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 12, 2013, 01:56:15 pm
I quickly looked at the code.

color is taken from bitmap, which is an 8 bpp surface (the GIF, that is).
You then set color on a 16 bpp surface (the screen variable on a CX)
That must be the problem; you're drawing a 8 bpp color on a 16 bpp surface.
I suggest you to either initialize SDL with 8 bpp, or pass bitmap through SDL_DisplayFormat().
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Lionel Debroux on January 12, 2013, 02:31:42 pm
8 bpp helps compatibility with Clickpad/Touchpad, although the screen is so bad that the game would hardly be playable anyway on those models, and I'm not convinced that we need much more than 256 colors for a F-Zero game on a platform without hardware acceleration... so I'd suggest using 8 bpp mode as well.
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 12, 2013, 03:08:20 pm
I already attached a pic of the program with SDL initialized in 8bpp mode, it didn't work anymore (green display). Moreover, the use of SDL_DisplayMode(bitmap) takes out all the available memory and throws "SDL : out of memory".
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 12, 2013, 06:22:35 pm
Alrighty a few things here.

1. When compiling your program, use -Wall -Wextra to spot things that could cause issues. For instance, you're freeing tempBitmap and sky but they've never been initialized.

2. Don't do stuff like this: screen->format = SDL_PIXELFORMAT_RGB332;. SDL should take care of the pixel format automatically.

3. Here's why the color was messed up: when you're using 8 bpp depth, each pixel is stored in a single byte. That byte isn't enough to store the RGB value directly, and so a palette is used to map each value to a certain color. I don't know why SDL_image would do it, but seems like the palette isn't the same on bitmap and screen (maybe you used GIMP to save it? Dunno). That's why you need to make them same, by copying bitmap's palette to screen's palette using SDL_SetColors(). Just do SDL_SetColors(screen, bitmap->format->palette->colors, 0, bitmap->format->palette->ncolors) just after loading the GIF (look up the function on google so you understand what you're writing). That way both palettes match, and here's the result:

(http://i.imgur.com/iQzzL.png)

It sucks at first but that's the way 8-bit displays work.

EDIT: When I saved that GIF again on Paint, it grew to 2.1 MB, but with that one colors were correct without changing the palette at all. What program did you use to save the GIF and how'd you get it down to 800 kB? It might be the program that has a palette completely different from everyone else.

4. SDL_SetColorKey(shipSurface, SDL_SRCCOLORKEY, SDL_MapRGB(screen->format, 0xff, 0, 0xff)); should be SDL_SetColorKey(shipSurface, SDL_SRCCOLORKEY, SDL_MapRGB(shipSurface->format, 0xff, 0, 0xff));, as you're mapping that RGB(255,0,255) using shipSurface's bpp (which might very well be different from that of screen).
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: Matrefeytontias on January 13, 2013, 01:14:33 pm
I always use Gimp for image editing (I find it soooooo useful).

Also, thanks a lot, it works ! :)
Title: Re: nSDL 1.0.2—A very fast & robust graphics library
Post by: hoffa on January 17, 2013, 02:54:19 pm
(http://i.imgur.com/YpU32.png)

nSDL 1.1.0 Anniversary Edition is here!

The 23rd of this month it will be one year since the creation of this thread and the beginning of nSDL! :hyper:

Right away, here's the changelog:
As usual, the download is available on the nSDL website (http://hoffa.github.com/nSDL/). For more information about the new function prototypes and whatnot, check the wiki (https://github.com/Hoffa/nSDL/wiki).

As mentioned earlier, this will most probably be the last update before a very long pause! :ninja:

Spoiler For Spoiler:
I'm going backpacking to Australia in early February for half a year. :)
Title: Re: nSDL 1.1.0 Anniversary Edition—The Ultimate TI-Nspire Graphics Library!
Post by: SpiroH on January 17, 2013, 04:59:38 pm
Happy nSpirish-SDL Birthday! Good shot. ;)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library!
Post by: hoffa on January 29, 2013, 03:39:14 pm
Oh wow, well I'm glad I found out about this before leaving. There was one big issue with 1.1.0; I'll quote:

BTW, about the SDL_GetTicks() issue you mentioned earlier, it was my fault. I had completely forgotten to uncomment a line in nSDL that enabled bus access for the timer, and consequently it worked on the emulator but not one the actual hardware (i.e., it returned always 0). It was extremely dumb and careless from me, but I've updated it now, SDL_GetTicks() should work now (I've tested it on both physical calculators, everything runs smoothly).

Let's just pretend that 1.1.0 never existed. :ninja:

Anyway, updated, download available on the website, you know the drill.

EDIT:

Oh, by the way, I also wrote an online image-to-NTI converter. It does exactly the same thing as the program included in nSDL, except it's faster for massive images and does no formatting whatsoever (which means a smaller source file): http://hoffa.franceserv.fr/nti/ (http://hoffa.franceserv.fr/nti/)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library!
Post by: fb39ca4 on January 31, 2013, 10:49:53 pm
What program is this picture?
http://i.imgur.com/ONKjZ.png
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library!
Post by: alberthrocks on January 31, 2013, 10:51:27 pm
Oh wow, well I'm glad I found out about this before leaving. There was one big issue with 1.1.0; I'll quote:

BTW, about the SDL_GetTicks() issue you mentioned earlier, it was my fault. I had completely forgotten to uncomment a line in nSDL that enabled bus access for the timer, and consequently it worked on the emulator but not one the actual hardware (i.e., it returned always 0). It was extremely dumb and careless from me, but I've updated it now, SDL_GetTicks() should work now (I've tested it on both physical calculators, everything runs smoothly).

Let's just pretend that 1.1.0 never existed. :ninja:
Woo, glad to here that issue is fixed! I guess I can start a (not so) secret porting project again! ;)
Title: Re: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library!
Post by: TheNlightenedOne on January 31, 2013, 10:51:47 pm
It's the hoffa-modified version of newvox, originally ported to nSDL by critor.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library!
Post by: hoffa on February 01, 2013, 05:42:52 am
What program is this picture?
http://i.imgur.com/ONKjZ.png
As said above.

Here's the post: http://ourl.ca/14975/308110;topicseen#new (http://ourl.ca/14975/308110;topicseen#new)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 07, 2013, 02:31:59 pm
Alrighty guys got some free time on my hands right now, will probably release an update within the month. Just wondering if you have any suggestions or things you'd like to see being added in the next release. Don't be shy, hit me with your best shots; I'll take care of the filtering. I have already done some minor changes, and mouse support is in the works (I'm trying to figure out the most sane and elegant way to implement it in a single thread).
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on August 07, 2013, 05:40:50 pm
Yeah :D nice to see you're back working on it !

I don't have any suggestions for now, excepting maybe commands to draw vertical, horizontal and general lines, and filled polygons. Because this is a real pain to do x.x
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Eiyeron on August 07, 2013, 06:30:41 pm
Oh, hello Hoffa! NIce to see you back! I made my return just in time, so!
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on August 07, 2013, 06:44:33 pm
Glad to hear Hoffa. :) Good luck!
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Legimet on August 08, 2013, 02:29:10 am
Yes, mouse support! :D
(I need it for my next project)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Legimet on August 18, 2013, 07:22:51 am
Since SDL 2.0 is now out, what benefits would it offer to the Nspire once you port it?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Adriweb on August 18, 2013, 07:26:38 am
Grabbed this from : http://wiki.libsdl.org/moin.fcg/MigrationGuide


Quote
Overview of new features

These are the most important new features in SDL 2.0:

Full 3D hardware acceleration
Support for OpenGL 3.0+ in various profiles (core, compatibility, debug, robust, etc)
Support for OpenGL ES
Support for multiple windows
Support for multiple displays
Support for multiple audio devices
Android and iOS support
Simple 2D rendering API that can use Direct3D, OpenGL, OpenGL ES, or software rendering behind the scenes
Force Feedback available on Windows, Mac OS X and Linux
XInput and XAudio2 support for Windows
Atomic operations
Power management (exposes battery life remaining, etc)
Shaped windows
32-bit audio (int and float)
Simplified Game Controller API (the Joystick API is still here, too!)
Touch support (multitouch, gestures, etc)
Better fullscreen support
Better keyboard support (scancodes vs keycodes, etc).
Message boxes
Clipboard support
Basic Drag'n'Drop support
Proper unicode input and IME support
A really powerful assert macro
zlib license instead of LGPL.
Lots of old annoyances from 1.2 are gone
Many other things!
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: SpiroH on August 18, 2013, 07:40:26 am
Since SDL 2.0 is now out, what benefits would it offer to the Nspire once you port it?
Yeah, but beware that the porting effort of most of the current SDL apps wouldn't be that straightforward without a lot of source recoding. So, not all that glitters is always gold. I mean, SDL 2.0 is NOT backwards-compatible with SDL 1.2. :P
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: willrandship on August 18, 2013, 10:22:26 am
Here's a filtered list of the features that really matter on the nspire. I did remove some stuff that's technically useable, but unlikely to be used, like multiple audio device support. (Easy enough, but I don't know how much audio the USB can handle when you have 4 USB audio dongles :P) Look at this list as motivations for why to switch.


The window-based changes don't matter since even if you use X, there's only 320x240 pixels to work with anyway.

Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 22, 2013, 12:46:44 pm
While SDL2 is a much more modern GPU-based API, it wouldn't benefit the TI-Nspire that much. There are some new useful functions and the whole library is cleaner but apart from that at the moment it's too much work (or not that much work at all, depends, haven't looked at it) and not many open source projects have been made using it, so the return on investment is so-so. I still need to update the current nSDL (I'm waiting for that tiny drop of motivation to form so I can finish it) before I can even think of the next version.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: ElementCoder on August 22, 2013, 12:50:37 pm
I hope that drop will form soon, nSDL is an awesome project :) Maybe silly question: could someone give an example when you want code to be unable to be interruped?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 22, 2013, 07:22:45 pm
Would it be possible to somehow control the TI-Nspire's native cursor through Ndless? I don't know if it's because of some new changes in Ndless or not, but now I can see the animated clock desperetaly trying to draw itself on the screen, and it moves as I move my finger on the touchpad. That means there is some master thread running and taking care of the mouse, it would be much better if I could get access to that. I guess functions to read the coordinates and force the cursor to draw itself would be extremely welcome.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Levak on August 22, 2013, 07:40:12 pm
Are you enabling interrutps through TCT_Local_Control_Interrupts() and why ?
If not, consider it as a bug, and you may call ExtendeD.

If you're enabling interrupts for a custom IRQ handler, you may use a specific mask (I don't rememeber what bit filed it was).
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: ExtendeD on August 23, 2013, 04:09:28 pm
hoffa, do you have a sample program showing this?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: willrandship on August 26, 2013, 03:38:52 pm
ElementCoder, let's say you're trying to do software bit-banged asynchronous serial. The timings on that are very precise, so an interrupt would screw it up bad enough to get at least one bad byte, probably two.

Also, maybe you don't want to be able to pause during a transition, or similar. If pausing was interrupt-based you would either need to check if it was a transition, or disable the interrupt.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 27, 2013, 06:34:48 am
hoffa, do you have a sample program showing this?
Yeah, attached. Sorry for the late reply, have been insanely busy.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Levak on August 27, 2013, 06:49:49 am
hoffa, do you have a sample program showing this?
Yeah, attached. Sorry for the late reply, have been insanely busy.
May you attach the source as well ? (or a link since it looks like it's Mode7)
Thanks.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 27, 2013, 07:29:15 am
It's pretty much this code: http://ourl.ca/18123/337001 (http://ourl.ca/18123/337001)

It uses an unreleased version of nSDL however (with shitty mouse support).

In other news, that TI downgrade block thing is really a turnoff. If I can finish one last version of nSDL that's good, but I think I'll retire from the TI-Nspire community after that (going to university, got a lot of things to look forward to, plus I've been getting into iOS development). I've been here long enough to see that not many people are that involved with the TI-Nspire (even I just look at projects' screenshots, think to myself "cool" and then switch tabs) and I could invest the time in some better stuff. I've been wanting to quit for some time already, but I hate leaving projects in the cold.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: critor on August 27, 2013, 08:54:35 am
By being demotivated and retiring from the TI-Nspire development community, don't you think that you're doing exactly what TI wanted?

And TI probably don't think they're losing anything like that, as they have many teachers to create TI-Nspire content.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Adriweb on August 27, 2013, 11:45:44 am
well, for them, the least native developers/hackers, the better, so indeed, as stated multiple times, it's just the lack of motivation / amount of people that makes TI "win" the native fight for a given OS version.
If somebody skilled is motivated enough to find exploits, I'm sure he'll find it.
That's what  Extended and the other ndless contributors have done over time ! But the lack of time was/is more the reason for not having an ndless 3.2 yet I guess
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 27, 2013, 12:46:06 pm
By being demotivated and retiring from the TI-Nspire development community, don't you think that you're doing exactly what TI wanted?

And TI probably doesn't think they're losing anything like that, as they have many teachers to create TI-Nspire content.
Maybe, but I have to be honest, I don't feel like I'm "fighting" for anything, nor do I really feel like I want to. I just like the TI-Nspire system somewhat and it's fun hacking it (well it was at least in high school), but now to me it's just more like a responsibility to "finish" what I started. Calculators are pretty much irrelevant to my life post-high school anyway and my interest is slowly fading away. TI's a dick, oh well. It's not something I bother to invest my time in once the whole show reaches a certain point, and it isn't something so close to my heart that I feel like using more energy to punch back.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: ExtendeD on August 27, 2013, 04:55:02 pm
Sad decision :( nSDL didn't (or hasn't had yet) the success it deserves...
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Eiyeron on August 28, 2013, 06:41:41 am
Oh... See what you"re doing, TI!

Anyway, thanks to have ported nSDL, hoffa, it was a good idea.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Lionel Debroux on August 28, 2013, 08:10:37 am
Quote
See what you"re doing, TI!
That's one of their goals...
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: SpiroH on August 28, 2013, 09:40:48 am
Thank you hoffa for the beautiful nSDL. I can perfectly understand your move, although I do not wholeheartedly believe it that much. Sooner rather than later you'll come back to Omnimaga. You're a popular guy around here. Also, i think TI-Nspire we'll very soon be a past toy, because its architecture and price is being overcome by way better alternatives. TI will probably have to change their PR with students/developers if they want to survive. I guess they're getting too old and greedy without realizing it. ;)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on August 28, 2013, 01:33:11 pm
Yeah it sucks that you are planning to stop working on this and retiring from TI-Nspire dev, although I can understand why. You are not alone who stopped developing for the same reasons. I personally was kinda interested in Nspire development when ASM/C arrived, hoping that someone released nAxe or something and perhaps trying Lua, but with everything that TI did, I finally decided against it. It is hard to stay motivated to code for a platform, fully knowing that in one year, almost nobody will be able to use our programs anymore.

By the way have you ever considered developing for the Casio PRIZM, HP Prime or TI-84 Plus C Silver Edition instead? I know calcs becomes pretty much irrelevant after hi school, but look at KermMartian, BrandonW and Ranman, who still actively made calculator programs over a decade after finishing hi school. Ranman was 40 years old, yet, during his free time (limited due to having kids and work), he still worked on TI-89 clones of Commodore 64 games. I myself released new calc games 10 years after finishing hi school, although much less than before. IIRC, someone was working on pSDL for the PRIZM, but I don't know what happened to it. The HP Prime is not hacked yet, but its BASIC language is even faster than Nspire Lua (by far) and people are already working to hack the calc. As for the 84+CSE, it's much slower, but if you like old school platforms and pushing them to their limits that could be a nice alternative, plus it's incredibly popular (just see how many downloads per week a simple Frogger or Snake clone can get). All those three calcs are open to ASM development (especially the 84+CSE, which has an Asm() command), although the HP Prime isn't released yet.

PRIZM (FX cg20):
-Max 94.3 MHz SH4
-2 MB RAM (61 KB for BASIC coders)
-16 MB Flash
-384x216 color LCD supporting both 65536 and 8 color modes

TI-84 Plus C Silver Edition:
-15 MHz Z80
-128 KB RAM (21 KB for user)
-3.5 MB Flash
-Color LCD supporting both 320x240 and 160x240 resolution, along with 65536 and 8 color modes
-Built-in horizontal scrolling support

HP Prime:
-Max 400 MHz ARM processor (supposedly clocked at 266 MHz by default)
-32 MB RAM (16 used by the OS)
-256 MB Flash
-320x240 LCD supporting 65536 colors
-BASIC language supports sprites of any size, sprite scaling, decuple buffering (10 buffers, although I don't see much need for anything higher than double or triple buffering), rectangles and transparent text (7 different sizes) that is anti-aliased.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: ExtendeD on August 28, 2013, 03:19:09 pm
hoffa, just to let you know, although this probably won't make you change your mind: I have been circumventing protections, patching, hacking, reversing, extending the TI-89, 92+, Voyage 200, TI-Nspire Clickpad and CX since 1997. Things were a bit more easy on the TI-68k but the page always was often rather white at the beginning and TI has never been cooperative.

I have had hundred reasons for quitting during these 16 years... but I'm still here, not as productive as I would like to be, not doing things always right, releasing things much less used that I'd like, or missing expectations. But the Ndless download stats and the kind words I sometimes receive from people around the world remind me I have at least been able to contribute to change things a little bit in a good way. And to take pleasure anyway.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on August 28, 2013, 03:39:10 pm
Yeah I remember that with the 68K models, TI kept changing the hardware, causing most old programs to break. At one point in 2000 or so, most people thought that on HW2 grayscale would never be possible. Then came HW3 a few years later, which broke all ASM programs.

On the 84+, we had to deal with compatibility issues with TI-Graph Link-generated groups, then came the 2007 hardware change causing games using extra RAM to break. MP OSes also caused major problems and several of my older games don't work properly on them.

Casio calcs had their shares of issues as well, especially the FX 9860G hardware changes last year or so.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 28, 2013, 04:18:13 pm
hoffa, just to let you know, although this probably won't make you change your mind: I have been circumventing protections, patching, hacking, reversing, extending the TI-89, 92+, Voyage 200, TI-Nspire Clickpad and CX since 1997. Things were a bit more easy on the TI-68k but the page always was often rather white at the beginning and TI has never been cooperative.

I have had hundred reasons for quitting during these 16 years... but I'm still here, not as productive as I would like to be, not doing things always right, releasing things much less used that I'd like, or missing expectations. But the Ndless download stats and the kind words I sometimes receive from people around the world remind me I have at least been able to contribute to change things a little bit in a good way. And to take pleasure anyway.
I understand, and you have all of my most genuine respect and gratitude for all the things you've done. As SpiroH said, I might get that small sparkle of motivation some time in the future for old time's sake, but for the time being I got my mind on other things and I'm too busy doing other stuff (if anyone cares, working, making as much money as I can before university, doing my iOS app, also I've been studying Korean for 3 months now and hoping to do my graduate studies in Seoul).
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on August 28, 2013, 04:19:28 pm
I thought you already moved to university since the army stuff? ???
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 28, 2013, 04:42:35 pm
I thought you already moved to university since the army stuff? ???
Nah, I was travelling in Australia for 6 months.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: TIfanx1999 on August 29, 2013, 08:44:58 am
I know this is a bit off topic, but is there any reason in particular you are considering Korea? Also, life> than calculators. :)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 29, 2013, 09:54:46 am
I know this is a bit off topic, but is there any reason in particular you are considering Korea? Also, life> than calculators. :)
Well I've traveled relatively much and I got some kind of thirst for cultural shock. I was already interested in Korea during high school (not because of K-pop thank God) because of quite a few things (history, culture, very varied and some absolutely gorgeous landscapes, cheap booze, weird food and customs, issues with batshit insane North, weather, etc.) and was planning to go there after Australia, but 6 months wasn't enough. Down under I met a lot of Koreans while doing fruit picking, and I lived for 2 months in Melbourne with 7 Koreans (one of them even became my girlfriend until I left). I had a very positive experience with them and it just boosted my will to go there even more (plus the food they made was really good, I'm a big fan of spicy food and meat; kimchi is godlike). I've always had a desire to do somewhat "extreme" things and to do stuff the massive majority wouldn't do, Korea is still relatively uncharted territory for foreigners (compared to Japan for example). I'm also going to study Computer Science (and will take Korean courses in university), and Korea is a booming economy where IT plays a huge role and opportunities are many. I decided that if I want to do something maybe a bit crazy during my life, I better start early and I better start right away; it's a big investment. I'm going in April to Korea for a few weeks and already had offers from pretty much all of my friends to give me a bed and show me around; it's a good start. :)

What a wall.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: ElementCoder on August 29, 2013, 10:02:58 am
I wish I could do that kind of traveling, how was Australia? I hope the spark returns someday, but for now it seems your future is great and I wish you the best of luck with your study and other things :)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on August 29, 2013, 10:51:47 am
I wish I could do that kind of traveling, how was Australia? I hope the spark returns someday, but for now it seems your future is great and I wish you the best of luck with your study and other things :)
Why couldn't you do that kind of traveling? What's stopping you? If it's really what you'd like to do, then work towards it, get the money, make the plans, most issues and obstacles can be dealt with, and usually the biggest obstacle is yourself. Don't just wait and regret it as time passes. The most difficult part is actually making a concrete step from the planning stage; you'll probably start questioning yourself, wondering if it's a good idea after all, stretching any tiny risk into a massive problem and overthinking everything, but that's entirely normal, that's how it feels to get out of the comfort zone. Even I felt a mix of excitement and fear when I went there as I literally went with a backpack, some cash and no plans whatsoever and I was afraid I'd be alone the whole trip. But it turned out to be one of the best decisions I could make. Met some many people and made long-term friends, experienced so many things (travelling around in a campervan, hitchhiking, sleeping on Bondi beach, learning to play harmonica, freezing my ass off in a single-layer $14 tent while it poured 8 hours, having a massive huntsman spider next to me while I was taking a dump, smoking some synthetic "spices" and being in low-earth orbit in the middle of Sydney during the night, picking apples for 6 hours and getting $30, stopping at some beautiful isolated place with a pond and a whole bunch of kangaroos, etc.).

Sorry for the offtopics, I'm outie now. :P
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Legimet on August 29, 2013, 12:06:55 pm
Good luck in university, and I hope you continue developing nSDL! :)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on August 29, 2013, 04:38:13 pm
The main issue for me when it comes to traveling is money and work schedule. Since I often work on weekends and rarely have two days off in a row, traveling very far is next to impossible unless it's during one of my vacation weeks. Then come the money issue: If I decide to travel somewhere that costs $2000 total, then it will take me one year to save. Also I always was concerned that traveling alone was not a good idea (although I could just avoid going out at night), but traveling with a friend or family member would be even harder, due to conflicting work/school schedules and possible money issues on his side.

In Eiyeron's case, though, I think there is also the issue about him not even being 18+ yet, meaning that parents might not want him to travel far nor pay for the trip.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: SpiroH on August 29, 2013, 06:28:59 pm
Now that this is going all the way off-topic, i might just say that you can always start off with short distances travels (to a neighbouring country, for instance) to get a feel, and later decide what you should do next. As already said by DJ, it's not a very good idea to go very far to start with and specially to travel alone when you are very young < 18 years. But do learn to take risks when you're young, it will certainly be very useful, funny and sometimes troublesome as well. :)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on December 01, 2013, 05:17:14 am
Epic necro bump, that unfortunately is a bug report,

I found out that nSDL_GetPixel(SDL_Surface*, int, int) is incompatible with surfaces loaded with SDL_LoadBMP(char*) :/ it works with images loaded by IMG_Load(char*) though.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Levak on December 01, 2013, 07:04:28 am
I found out that nSDL_GetPixel(SDL_Surface*, int, int) is incompatible with surfaces loaded with SDL_LoadBMP(char*) :/ it works with images loaded by IMG_Load(char*) though.

Hmmmm, that's interesting, because I knew about a same bug in the OCaml SDL binding where grayscale images (bmp here) were incompatible with set/get pixel.

Is your bmp a grayscale image by any chance ?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on December 01, 2013, 07:07:57 am
No, it's a classical 24-bits bitmap.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on December 01, 2013, 09:06:04 am
No, it's a classical 24-bits bitmap.

From the nSDL wiki:
Quote
Returns the pixel's color at (x, y). Assumes the surface has been locked. Does no clipping. Supports 8-, 16- and 32-bit surfaces.

I intentionally did not want to support 24-bit surfaces as they require a few extra operations, and I wanted to keep the pixel manipulation functions as fast as possible.

I just looked at the pixel manipulation code in nSDL, and apparently it should call SDL_Unsupported(), which I think IIRC calls SDL_SetError(). Did you try doing SDL_GetError() after the pixel thing?

Also you shouldn't be handling 24-bit images in speed critical code, as neither of the machines use that as their native display bit depth. You'll lose a lot of performance if you start blitting 24-bit stuff on 16-bit surfaces etc. as the conversion is done on the fly. Convert the surface as you load them.

TL;DR it's not supposed to work
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on December 01, 2013, 09:21:41 am
Okay then it would better to throw an error when loading 24-bits bitmaps, because it took me several hours to understand where that "nSDL : Unknown error" came from x.x
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on January 06, 2014, 09:31:50 am
Bump,

Why can't I use nSDL_DrawString(SDL_Surface*, nSDL_Font*, int, int, char*, ...) on a non-CX calc, when the exact same code works on CX calcs ?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on January 11, 2014, 07:34:23 am
That's weird; has apparently been working fine for others and me.

Does the function return 0? What's the exact code you're using? Not just a problem with colors that are converted into 4-bit format and happen to have same value?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: AnToX98 on January 11, 2014, 08:18:07 am
@hoffa ! <3

I tested your "coyote demo" uploaded on TI-planet, did you made a topic for it ?
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on January 11, 2014, 08:23:14 pm
@hoffa ! <3

I tested your "coyote demo" uploaded on TI-planet, did you made a topic for it ?
Damn that's some really old stuff (the tile map game engine thing, renamed it to Owl later). I think I had a thread here before yeah, but nobody seemed to care and I couldn't bear the responsibility of maintenance (or something) so I just deleted everything (I think I have a backup somewhere though).
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on February 02, 2014, 12:24:33 am
That demo was in Ndless, right? That was cool, but IIRC by then the GBC emulator had come out and people didn't seem to take on large RPGs or something.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: SpiroH on February 19, 2014, 09:28:03 am
@hoffa ! <3

I tested your "coyote demo" uploaded on TI-planet, did you made a topic for it ?
Damn that's some really old stuff (the tile map game engine thing, renamed it to Owl later). I think I had a thread here before yeah, but nobody seemed to care and I couldn't bear the responsibility of maintenance (or something) so I just deleted everything (I think I have a backup somewhere though).
Hoffa are you (still) in Australia? How's life over there? Lotsa chicks? ;)
Me too, i would like see that live-dead thread resurrected.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: hoffa on May 09, 2014, 10:14:17 pm

Check this out:
http://www.omnimaga.org/ti-nspire-projects/nsdl-2/msg383149/#msg383149 (http://www.omnimaga.org/ti-nspire-projects/nsdl-2/msg383149/#msg383149)


Spoiler For Spoiler:
Oh wow this is a bit late, but better late that never eh.

That demo was in Ndless, right? That was cool, but IIRC by then the GBC emulator had come out and people didn't seem to take on large RPGs or something.
It was pure Lua. o/

@hoffa ! <3

I tested your "coyote demo" uploaded on TI-planet, did you made a topic for it ?
Damn that's some really old stuff (the tile map game engine thing, renamed it to Owl later). I think I had a thread here before yeah, but nobody seemed to care and I couldn't bear the responsibility of maintenance (or something) so I just deleted everything (I think I have a backup somewhere though).
Hoffa are you (still) in Australia? How's life over there? Lotsa chicks? ;)
Me too, i would like see that live-dead thread resurrected.
Time flies and I'm now in the UK doing a BSc in Computer Science. It's soon been a year, but yeah Australia was pretty cool, met and traveled with a whole bunch of interesting people (and girls), camped like a hobo everywhere, did all sorts of work and it pretty much changed the direction of my life with the whole Koreans and Korea episode (long story short found myself in Korean flat in Melbourne, had an awesome experience, made good friends and met my Korean ex, started learning the language #YOLO, made lots of Korean friends at university in the UK, visited Korea in Easter and going back in summer for 3 months to Yonsei University to study and a month to work. Have been studying the language for 6 months now and will do my graduate studies there, if not more)
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: DJ Omnimaga on May 09, 2014, 10:52:43 pm
Nice to see you around still :D
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on May 10, 2014, 03:48:07 am
Oh hey ! It's been a while :D Nice to see you're still working on calc stuff ;D

I can't think of anything to add to nSDL for now. It always had what I wanted it to have.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: SpiroH on May 11, 2014, 09:55:40 am
Check this out:
http://www.omnimaga.org/ti-nspire-projects/nsdl-2/msg383149/#msg383149 (http://www.omnimaga.org/ti-nspire-projects/nsdl-2/msg383149/#msg383149)
Spoiler For Spoiler:
Oh wow this is a bit late, but better late that never eh.

That demo was in Ndless, right? That was cool, but IIRC by then the GBC emulator had come out and people didn't seem to take on large RPGs or something.
It was pure Lua. o/

@hoffa ! <3

I tested your "coyote demo" uploaded on TI-planet, did you made a topic for it ?
Damn that's some really old stuff (the tile map game engine thing, renamed it to Owl later). I think I had a thread here before yeah, but nobody seemed to care and I couldn't bear the responsibility of maintenance (or something) so I just deleted everything (I think I have a backup somewhere though).
Hoffa are you (still) in Australia? How's life over there? Lotsa chicks? ;)
Me too, i would like see that live-dead thread resurrected.
Time flies and I'm now in the UK doing a BSc in Computer Science. It's soon been a year, but yeah Australia was pretty cool, met and traveled with a whole bunch of interesting people (and girls), camped like a hobo everywhere, did all sorts of work and it pretty much changed the direction of my life with the whole Koreans and Korea episode (long story short found myself in Korean flat in Melbourne, had an awesome experience, made good friends and met my Korean ex, started learning the language #YOLO, made lots of Korean friends at university in the UK, visited Korea in Easter and going back in summer for 3 months to Yonsei University to study and a month to work. Have been studying the language for 6 months now and will do my graduate studies there, if not more)
I like the spoiler a lot ;) ! Welcome back and please do post some of your adventures in Your Highness' kingdom.


Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: Matrefeytontias on May 15, 2014, 08:17:48 am
I don't know if I'm doing it wrong or what, but nSDL forces the BPP to 8 on TI-Nspire non-CX calcs, even after I set the LCD to 16-bits mode. Is it that you're checking the BPP validity with is_cx or has_colors in SDL_SetVideoMode ? If so, you should consider reading bit 1 to 3 of 0xC000001C to check if the screen is correctly set to accept the provided BPP value.
Title: Re: nSDL 1.1.1 Anniversary Edition—The Ultimate TI-Nspire Graphics Library
Post by: pimathbrainiac on May 30, 2014, 09:09:10 am
Okay, so I have a pretty large sprite sheet (converted to NTI, of course). When I use the following code to get the sprites:
Code: [Select]
void draw_tile(SDL_Surface *tileset, long tile_num, int x, int y)
{
    SDL_Rect src_rect, screen_pos;
    src_rect.x = tile_num * 10 + 8;
    src_rect.y = tile_num / 30 * 10 + 119;
    src_rect.w = TILE_WIDTH;
    src_rect.h = TILE_HEIGHT;
    screen_pos.x = x * TILE_WIDTH;
    screen_pos.y = y * TILE_HEIGHT;
    SDL_BlitSurface(tileset, &src_rect, screen, &screen_pos);
}

Any sprite with an x or y value greater than 127 is not displayed. I looked at the official SDL_Rect struct definition, and those values should end up being 16 bit values, not 8 bit values. Is this a problem with the code or a problem with the library? I am using a monochrome Nspire CAS.