Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - hoffa

Pages: 1 ... 12 13 [14] 15 16 ... 21
196
nSDL / Re: SDL for the TI-Nspire
« 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

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)

197
nSDL / Re: SDL for the TI-Nspire
« 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.

198
nSDL / Re: SDL for the TI-Nspire
« 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?

199
nSDL / Re: SDL for the TI-Nspire
« on: February 11, 2012, 10:01:20 am »
This is very weird, not the first time only I have the issues.

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

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

EDIT:
Windows 7 x64 and Yagarto that uses the following versions:
binutils: 2.21
gcc:      4.6.2
newlib:   1.19.0
gdb:      7.3.1

200
nSDL / Re: SDL for the TI-Nspire
« on: February 11, 2012, 08:04:18 am »
I think I've finally--after many smashed walls, headaches and a bucket of aspirin--narrowed down one major issue.

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

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

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

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

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

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

I think this might be one of those ARM struct alignment issues, or possibly some other bug. Either way, it has kept me from advancing with the port.
Any input on this one, ExtendeD? (or others, if you know what might be causing the problem)

201
nSDL / Re: SDL for the TI-Nspire
« 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.


202
TI-Nspire / Re: NGL — TI-Nspire Graphics Library
« on: January 30, 2012, 06:07:08 pm »
Sure.

Edit: disregard that, got it to work.

203
TI-Nspire / Re: NGL — TI-Nspire Graphics Library
« on: January 30, 2012, 03:58:06 pm »
Are you sure that the file not being sent isn't just a bug in nspire_emu? Try to connect and send again.
I'm quite sure it isn't a bug. It's difficult to explain why, but nspire_emu's behavior feels consistent and more or less logical.

edit: Isn't that the issue you wrote about and fixed here?
That was just a quick hack (that doesn't seem to always work) for nspire_emu disconnecting the USB link every once in a while. It's not it.

204
TI-Nspire / Re: NGL — TI-Nspire Graphics Library
« on: January 30, 2012, 03:46:44 pm »
hoffa, will you still continue to try the SDL port?
Yes, I will continue with the SDL port.

Quote
either the resulting binary cannot be sent to the calculator

What do you mean exactly?
Using nspire_emu, if I try to send the file nothing happens. No errors no nothing. Now that you mentioned the memcpy issue (didn't anyone was aware of it), I think it might very well be because of that.

or then that GCC doesn't compile the code (with some undefined reference's to memcpy).

See http://www.unsads.com/projects/nsptools/ticket/27 .
I'll quickly fix it if it's a blocking problem for you.
I'd appreciate it a lot if you could fix it, it would allow me to advance with the SDL port and with this library. I'm pretty sure it's what's causing the file not being sent.

205
TI-Nspire / Re: NGL — TI-Nspire Graphics Library
« on: January 30, 2012, 01:04:15 pm »
Great :)

Is it complementary to http://ourl.ca/14731/275989 ?
If I had to define it that way, I'd say alternative.

Also, I think I more or less know why there are issues with big chunks of data and the fact that sometimes my code doesn't run even though I changed practically nothing. I'm pretty sure it has to do with the way GCC optimizes for ARM. For instance the way it optimizes structs/enums/unions might cause alignment issues and whatnot (I noticed it won't run when I specify the blit destination with a struct ngl_rect).
http://www.aleph1.co.uk/chapter-10-arm-structured-alignment-faq
Seems like it's a rather common issue, at least according to the number of results on "arm struct alignment" on Google.

206
TI-Nspire / Re: NGL — TI-Nspire Graphics Library
« on: January 30, 2012, 09:20:35 am »
A suggestion:

ngl_create_surface(ngl_uint w, ngl_uint h)

Should probably be

ngl_create_surface(ngl_uint x, ngl_uint y, ngl_uint w, ngl_uint h)
ngl_create_surface only allocates memory for the surface. The surface can then be blitted to another surface (which can then be copied to the framebuffer using ngl_flip) using ngl_blit_surface, which asks for the position (the ngl_rect dst_rect parameter).

Edit:
Added support for 16-level grayscale format.

207
Calculator C / Re: program to convert bmp into Nspire c-arrays?
« on: January 30, 2012, 07:56:50 am »
I'm using a self-made tool, except it converts to normal RGB data (i.e. you'll have to parse the data in the program itself). http://hoffa.franceserv.fr/image2bytes/

208
TI-Nspire / NGL — TI-Nspire Graphics Library
« on: January 30, 2012, 07:40:05 am »
NGL is a very lightweight graphics library that I've written that provides buffered access to the TI-Nspire's framebuffer. It provides only a few functions and is not supposed to be a full-fledged graphics library with every drawing routine available, it only includes the basic bricks required (i.e. drawing pixels, filling rectangles and drawing sprites). If it even means anything, I'd say I'm sticking to the SDL philosophy.

It is compatible with CX and non-CX calculators, although binaries are not interchangeable between the two, for flexibility- and speed-related reasons. You can find the "documentation" on the project's github, although the code should be self-documenting and not too difficult to grasp.

Github: https://github.com/Hoffa/NGL

I have one last issue to tackle/understand before I can provide a nice package of the library (and there are still a few bugs to hunt down and improvements to be made). How am I supposed to declare sprite data? ngl_load_image takes as input raw image data and then parses it, but the problem with defining the raw data array is that either the resulting binary cannot be sent to the calculator, or then that GCC doesn't compile the code (with some undefined reference's to memcpy). If I put the array in another translation unit (i.e. in some header or other file) the former happens. If I declare the array in main's scope, I get the memcpy issues. I see little logic in this, maybe the TI-Nspire doesn't like big chunks of statically allocated data (but GCC itself is a very good compressor). Once I manage to deal with that, drawing sprites would be no issue. Any help regarding that?

EDIT: on hold; working on the SDL port.

209
Calculator C / Re: Linking static libraries on the TI-Nspire
« on: January 26, 2012, 05:13:12 pm »
Here is an update of the Ndless SDK for you that should fix this (r526):
- Add _TINSPIRE
- Add missing syscalls stub for newlib
Wonderful, that fixed it, thanks a lot! Now I'll be able to get to the real thing.

Edit:
The TNS is not accepted by nspire_emu (i.e., nothing shows up), but I'll look into that tomorrow.

Edit 2:

Compiling:
Code: [Select]
#include <os.h>

int main(void) {
puts("Hello!");
return 0;
}

Using: nspire-gcc test.c -nostdlib

Gives:
Code: [Select]
$ nspire-gcc -nostdlib sdl.c
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/bin/ld.exe: warning: cannot find entry symbol _start; defaulting to 00008000
C:\Users\Hoffa\AppData\Local\Temp\ccKOUO0B.o: In function `exit':
sdl.c:(.text+0x250): undefined reference to `__crt0_savedsp'
sdl.c:(.text+0x254): undefined reference to `__crt0exit'
collect2: ld returned 1 exit status

Edit 3:
Seems to compile and run today, never mind. When it comes to SDL, still haven't managed to call a function. I'm looking into that now.

210
Calculator C / Re: Linking static libraries on the TI-Nspire
« on: January 26, 2012, 01:11:27 pm »
Output:
Code: [Select]
$ nspire-ld sdl.o libSDL.a
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2\libgcc.a(unwind-arm.o): In function `get_eit_entry':
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/unwind-arm.c:614: undefined reference to `__exidx_start'
C:\msys\1.0\home\yagarto\gcc-build\arm-none-eabi\libgcc/../../../gcc-4.6.2/libgcc/../gcc/config/arm/unwind-arm.c:614: undefined reference to `__exidx_end'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-abort.o): In function `abort':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\stdlib/../../../../../newlib-1.19.0/newlib/libc/stdlib/abort.c:63: undefined reference to `_exit'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-signalr.o): In function `_kill_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.19.0/newlib/libc/reent/signalr.c:61: undefined reference to `_kill'
c:/program files (x86)/yagarto/bin/../lib/gcc/arm-none-eabi/4.6.2/../../../../arm-none-eabi/lib\libc.a(lib_a-signalr.o): In function `_getpid_r':
C:\msys\1.0\home\yagarto\newlib-build\arm-none-eabi\newlib\libc\reent/../../../../../newlib-1.19.0/newlib/libc/reent/signalr.c:96: undefined reference to `_getpid'
collect2: ld returned 1 exit status

Seems like some ARM specific errors. Doesn't seem to recognize the entry point.

Pages: 1 ... 12 13 [14] 15 16 ... 21