Omnimaga

Omnimaga => Our Projects => Ndless => Topic started by: totorigolo on January 04, 2012, 04:00:48 pm

Title: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 04, 2012, 04:00:48 pm
Hello everybody,

I'm coming from TI-Planet to inform you about the progression of nRGBlib, which is a Ndless colorful (but compatible with classic Nspire) library.
You can see the corresponding news :
And you can see the original topic on TI-Planet here (http://tiplanet.org/forum/viewtopic.php?f=20&t=8597) (FR). Note that this topic, on Omnimaga, may be outdated because I'm French so...
------------------------------------------------------------------------------------------

Roadmap :

nRGBlib 0.1 : First stable version - available on request

nRGBlib 0.2 : Former stable version - public
nRGBlib 0.3 : Last stable version - public

------------------------------------------------------------------------------------------

Features:

nRGBlib is composed of several packages to perfectly suit your needs.

------------------------------------------------------------------------------------------

Medias :

GeometriCX v0.1
(http://img.removedfromgame.com/imgs/GeometriCX.JPG)

nRGBlib v0.1 with CXSnake and GeometriCX


nRGBlib v0.2dev with HelloRGB, CXSnake and GeometriCX (Thanks to Goplat for his emulator)


nRGBlib v0.3 indev : RPG + map editor

4bpp drawing has been accelered a lot since v0.3, but the video was taken before the optimization.

------------------------------------------------------------------------------------------

Downloads:
Here is my Bitbucket (Mercurial) repository. Go in "Downloads" section :
https://bitbucket.org/totorigolo/nrgblib/overview (https://bitbucket.org/totorigolo/nrgblib/overview)
------------------------------------------------------------------------------------------
If you have any question or suggestion about this library, please feel free  :)

totorigolo
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Jim Bauwens on January 04, 2012, 04:03:02 pm
Very nice totorigolo :)
I've been looking into my copy, and it looks very straitforward to use. I haven't done anything with it yet, but I definitly will :D
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 04, 2012, 04:06:08 pm
The 0.1 version is in only one file, and I didn't pay attention about organization. In the future version, the code will be more structured  ;)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Adriweb on January 04, 2012, 04:07:36 pm
This lib is awesome :)

You should post a screenshot/video ;)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on January 04, 2012, 04:25:11 pm
This looks useful!
I can't wait for ndless 3 to come out :)

 
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 04, 2012, 04:27:03 pm
Adriweb: Done ! I used the same images than jimbauwens.

epic7: Thanks you !
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Nick on January 04, 2012, 04:50:53 pm
when watching that video, it looks like you're gonna be burried below a bunch of colored circles, since they seem to come closer xp

but it's really great, this will be a big help in game development.. congratz
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: DJ Omnimaga on January 04, 2012, 06:25:31 pm
Looks very nice, any demo will be available soon? :)

Keep us updated when you can :)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 05, 2012, 01:53:46 pm
What do you mean when you say "demo" ? Ndless 3 isn't yet public. Currently, there are CXSnake and GeometriCX. (Perhaps CXSnake screen shots ?  ;D)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: DJ Omnimaga on January 05, 2012, 02:27:41 pm
Oh I meant so we can test it, but yeah you're right about Ndless x.x. Maybe more animated screenshots?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 05, 2012, 04:11:20 pm
New video on the presentation topic, about compatibility between Nspire CX / Nspire Touchpad/Clickpad.


I did this compatibility with the following formula : color = ((R + G + B) / 3) / 16; and then I use the Ndless 2.1 setPixel(); function.
I have also edited my Color structure to be able to do this :

Code: [Select]
    //...
    Color appleCol; // Red for CX and Black for Classic
        appleCol.R = 255; // |
        appleCol.G = 0;   // |-> Red
        appleCol.B = 0;   // |
        appleCol.BW = 0; // Black

    drawSthColor(x, y, appleCol);
    //...
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: apcalc on January 11, 2012, 03:25:30 pm
Nice video and great work! ;)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 16, 2012, 04:26:42 pm
Here it is ! The new nRGBlib v0.2 :). It will be available soon to Download...  ;)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Jim Bauwens on January 17, 2012, 03:11:48 am
Very nice !
I'll soon take a look at it :D
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: DJ Omnimaga on January 17, 2012, 03:42:39 am
Pretty good so far :)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: apcalc on January 17, 2012, 06:35:19 pm
I like the progress on this, great work! :)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on January 19, 2012, 04:48:27 pm
Ndless 3 is out !
Here is the link to download nRGBlib :) :
https://bitbucket.org/totorigolo/nrgblib/downloads (https://bitbucket.org/totorigolo/nrgblib/downloads)

This link will be always up to date, because it's mine.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: ExtendeD on January 19, 2012, 04:49:55 pm
Thanks totorigolo :) Also make sure to put it in your first post.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: willrandship on January 19, 2012, 11:36:49 pm
So, does "character drawing" mean sprite support or text?

Sprite support would be really nice. At arbitrary sizes, ideally.

Also, have you considered image importing?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Spyro543 on January 20, 2012, 08:51:42 am
Is there a pixel test command? That would be highly useful.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: tangrs on February 07, 2012, 05:10:04 am
Looks very interesting!

I might use it sometime when I have the time XD
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on February 22, 2012, 05:23:30 pm
/me downloads
/me is clueless about ndless makefile stuff

In your example makefile,
What does "the directory for the tns file" mean
Also, where it says "one .o file for each .c file" am I supposed to replace that with something?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: lkj on February 22, 2012, 05:54:06 pm
the "directory for the tns file" means the name and directory were the compiled .tns will be. For example this line could be
Code: [Select]
DISTDIR = Example.tns
In the OBJS line you have to write the names of the .c files you want to compile, but with .o instead of .c at the end of each name.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on February 23, 2012, 07:20:24 pm
Where am I supposed to put all that makefile code?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Jonius7 on February 23, 2012, 10:36:23 pm
This is great. Hopefully this'll allow to extend the capabilities of the nspire significantly.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on February 23, 2012, 11:01:16 pm
the "directory for the tns file" means the name and directory were the compiled .tns will be. For example this line could be
Code: [Select]
DISTDIR = Example.tns
In the OBJS line you have to write the names of the .c files you want to compile, but with .o instead of .c at the end of each name.
So I could put
DISTDIR = C:/ndless/test1/testprogram.tns
?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on February 24, 2012, 08:07:59 pm
Is there any guide or something to tell how to use the functions?''

And should this makefile work?
I get an error that i think is in the OBJS line.
Code: [Select]
GCC = nspire-gcc
LD = nspire-ld
GCCFLAGS = -Os -nostdlib -I"c:/nRGBlib/sdk/include/"
LDFLAGS = -L "c:/nRGBlib/sdk/lib/"
OBJCOPY := "$(shell (which arm-elf-objcopy arm-none-eabi-objcopy arm-linux-gnueabi-objcopy | head -1) 2>/dev/null)"
ifeq (${OBJCOPY},"")
OBJCOPY := arm-none-eabi-objcopy
endif
OBJS = main.o bar.o -> hello.o
DISTDIR = .
vpath %.tns $(DISTDIR)

all: hello.tns

%.o: %.c
$(GCC) $(GCCFLAGS) -c $<

%.o: %.S
$(GCC) $(GCCFLAGS) -c $<

hello.tns: $(OBJS)
$(LD) $(LDFLAGS) $^ -o $(@:.tns=.elf) -lRGB
@mkdir -p $(DISTDIR)
$(OBJCOPY) -O binary $(@:.tns=.elf) $(DISTDIR)/$@

clean:
rm -f *.o *.elf
rm -f $(DISTDIR)/hello.tns
EDIT: I changed it to just OBJS = hello.o and it made the tns
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on February 26, 2012, 11:18:17 pm
In nRGBlib, how do you make sprites? Or has that not been implemented yet?

Also, as ive posted multiple times :P, rand() doesnt work because RGBlib has a rand function that conflicts with yagarto's one, so how do I get it to work? The snake game uses rand() and it works fine.... I can't really spot any differences between snake's code and mine that could have made snake's work, other than that it included nMATHS, but that didn't change anything for me when I included it

Edit: Ouch, triple post D:
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Jim Bauwens on February 27, 2012, 02:14:46 am
Just take a look at the example nRGBLib program's source, it's quite clear.
It also shows how to draw sprites IIRC.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on March 03, 2012, 09:27:53 am
Above all, please excuse me epic7, Spyro543 and willrandship for not responding, I didn't receive any mail and this topic has more succes than the french one...

So, does "character drawing" mean sprite support or text?

Sprite support would be really nice. At arbitrary sizes, ideally.

Also, have you considered image importing?

"character drawing" means text. I was wondering about sprite support and images, but i had actually not work on nRGBlib since Ndless 3 out.

Is there a pixel test command? That would be highly useful.

I added one, but i had problems, so i deleted it for the public release. It will be added soon  :)

In nRGBlib, how do you make sprites? Or has that not been implemented yet?

Also, as ive posted multiple times :P, rand() doesnt work because RGBlib has a rand function that conflicts with yagarto's one, so how do I get it to work? The snake game uses rand() and it works fine.... I can't really spot any differences between snake's code and mine that could have made snake's work, other than that it included nMATHS, but that didn't change anything for me when I included it

Edit: Ouch, triple post D:

Did you manage to use rand() and to compile ? I will answer faster this time ;)

Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: lkj on March 03, 2012, 10:03:04 am
the "directory for the tns file" means the name and directory were the compiled .tns will be. For example this line could be
Code: [Select]
DISTDIR = Example.tns
In the OBJS line you have to write the names of the .c files you want to compile, but with .o instead of .c at the end of each name.
So I could put
DISTDIR = C:/ndless/test1/testprogram.tns
?

I'm sorry that I was wrong and didn't answer :(
It would have to be
DISTDIR = C:/ndless/test1/
but I guess you've figured it out yourself.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on March 05, 2012, 03:49:45 pm
Nope. Never got rand() to compile.

Also, I guess I'll just make my sprites out of shapes for now. :P
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on March 06, 2012, 08:14:52 am
Do you include <nMATHS.h> ? Otherwise show me your code.

In the current configuration of nRGBlib, it's not very useful to have sprites, because you can create as many shapes as you want, it's very light (for example, a box = int16_t x; + int16_t y; + int16_t w; + int16_t h;). This is why I have not yet implemented sprites so far.

Tell me if my English is bad  ;)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on March 09, 2012, 08:36:49 pm
nMATHS.h doesnt help, heres the code
http://pastebin.com/QfaM34Fc

Also, how do you display integers?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on March 10, 2012, 01:09:02 pm
I have no problem with your code.

I've replaced like this:
Code: [Select]
        //seed=randnum(seed); //my goal is to give yvel a random value -128 to 128
        seed = randMinMax(-128, 128);
and it works pretty fine.

Can you send me your Makefile ?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on March 10, 2012, 02:51:46 pm
I'd just need to do
yvel=randMinMax(-128, 128)
do do what i need

Makefile
Code: [Select]
GCC = nspire-gcc
LD = nspire-ld
GCCFLAGS = -Os -nostdlib -I"c:/nRGBlib/sdk/include/"
LDFLAGS = -L "c:/nRGBlib/sdk/lib/"
OBJCOPY := "$(shell (which arm-elf-objcopy arm-none-eabi-objcopy arm-linux-gnueabi-objcopy | head -1) 2>/dev/null)"
ifeq (${OBJCOPY},"")
OBJCOPY := arm-none-eabi-objcopy
endif
OBJS = pong.o
DISTDIR = .
vpath %.tns $(DISTDIR)

all: Pong.tns

%.o: %.c
$(GCC) $(GCCFLAGS) -c $<

%.o: %.S
$(GCC) $(GCCFLAGS) -c $<

Pong.tns: $(OBJS)
$(LD) $(LDFLAGS) $^ -o $(@:.tns=.elf) -lRGB
@mkdir -p $(DISTDIR)
$(OBJCOPY) -O binary $(@:.tns=.elf) $(DISTDIR)/$@

clean:
rm -f *.o *.elf
rm -f $(DISTDIR)/Pong.tns
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on March 10, 2012, 06:55:02 pm
Your Makefile seems to be good.

Quote
I'd just need to do
yvel=randMinMax(-128, 128)
do do what i need
I'm not sure to have understood, but if I have well understood, you're right :
Code: [Select]
while (players  == 0)
    {
        //seed++;
        rand();
        if (isKeyPressed(KEY_NSPIRE_CTRL))

        /* ... */

        //seed=randnum(seed); //my goal is to give yvel a random value -128 to 128
        //yvel=seed%257-128;
        yvel=randMinMax(-128, 128);
And I've checked yvel values and they are goods.

Sorry if I'm repeating me, but what is your problem exactly? What is the output of gcc if your code not compile?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on March 10, 2012, 10:45:29 pm
Hm, I'll try it again and I'll show you the error if it fails.

Also, is there a way better than what I currently use to draw things?
My current way is something like:

Loop
{
Draw object
Pause
Do code stuffs
Draw white over object
Update object's coordinates
}

The objects flash a lot with this tho
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on March 12, 2012, 02:29:19 pm
Your way seems good, but I can't help you much better, because I am just a French 15 years old boy who had learned thanks to the SdZ and alone to program :P So, nRGBlib's code is surely not optimized at all, and all suggestions / patch / help (/ ...) is obviously the welcome  ;) (→ https://bitbucket.org/totorigolo/nrgblib/issues?status=new&status=open)

The objects flash a lot with this tho

Indeed, I noticed that the ball is flashing a lot. Maybe, you can use drawBox instead of drawDisc to clear the previous ball, because it should be faster...
To draw circles or discs, I currently use Bresenham's algorithm (http://fr.wikipedia.org/wiki/Algorithme_de_trac%C3%A9_d%27arc_de_cercle_de_Bresenham (or in English http://en.wikipedia.org/wiki/Midpoint_circle_algorithm), thanks Excale for the link :)), and you can see my implementation here (https://bitbucket.org/totorigolo/nrgblib/src/d999e40ef8af/src/nRGBlib/drawDisc.c). Maybe an (more) optimized version exists.

Anyway, thanks you for your feedback :D
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on April 01, 2012, 06:06:24 am
I am currently adding many new things to nRGBlib, whose images. The system is currently functional, but I have not optimized for the moment only the CX (16bpp), because I absolutely wants to keep compatibility between 16bpp / 4bpp without recompilation, and I'm having some problems with void* pointers ...

So if someone wants to help me in optimizing 4bpp in order to accelerate the next nRGBlib's release.  :)

I also plan to open PNG and JPG (because right now the format is one that I created) by integrating the source code of mViewer (for BMP and PNG) and of Nspire and Movie Player (of tangrs) (for JPG), which are released under GPL v2 and v3.
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on April 01, 2012, 03:24:42 pm
Here is an example of nRGBlib's current features.

The map editor is coded in C + + with SFML. It was created thanks to this tutorial (http://www.games-creators.org/wiki/R%C3%A9aliser_un_RPG_en_C_avec_SDL_et_FMOD).


The sample run slower on 4bpp, because of non-optimization.


----

PS: For epic7, I haven't change your code, but I've just added the double-buffering :
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: Adriweb on April 01, 2012, 03:47:41 pm
very nice !! :o
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on April 01, 2012, 03:56:24 pm
Thanks you :D

If you want to play, or create your map, you will have to wait  :P
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on April 17, 2012, 06:09:33 pm
nRGBlib v0.3 has just been released.
The main post (http://ourl.ca/14731) has been updated.
A new has been published on TI-Planet : http://tiplanet.org/forum/viewtopic.php?p=123024 (http://tiplanet.org/forum/viewtopic.php?p=123024).
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: DJ Omnimaga on April 17, 2012, 06:14:59 pm
Awesome, nice to see you still working on this :)
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on April 17, 2012, 08:14:59 pm
Yay!

What was that double-buffering thing?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on April 19, 2012, 12:05:15 pm
Yay!

What was that double-buffering thing?

If you are talking about "PS: For epic7, I haven't change your code, but I've just added the double-buffering :", I was seemingly wrong because I use only one buffer... I actually don't know how to name it, but it's a buffer ;)

If you are talking about the code, here it is : http://pastebin.com/UPmJT0nB. There are not several changes.

---------------------------------------------------

You can download the v0.3 samples here (https://bitbucket.org/totorigolo/nrgblib/downloads/samples-v0.3.zip) !
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on April 19, 2012, 02:18:43 pm
Cool! :D

I didn't know that I could add buffers like that.
Now that it looks like the flashing is no longer an issue, I can start making a better game! :D
/me downloads 0.3
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: epic7 on April 22, 2012, 10:49:48 am
How do I draw images/sub-images?

Also, could sub-images possibly be used as sprites?
Title: Re: [nRGBlib] W.I.P - Colorful librairy for Ndless 3.1
Post by: totorigolo on April 22, 2012, 11:33:07 am
* How do I draw images/sub-images?

Take a look at the RPG sample.

Code: [Select]
   // Create the sub-image
    ImageSubrect tile;
    setImage(&tile, &img);

    tile.w = CELL_SIZE;
    tile.h = CELL_SIZE;
    tile.x = 0;
    tile.y = 0;
    tile.offset_x = CELL_SIZE * 3;
    tile.offset_y = CELL_SIZE * 2;

    drawImagesubrect(&tile, buffer);

edit 1:
* Also, could sub-images possibly be used as sprites?
I don't know what is exactly a sprite, but you can use it to draw tiles from a tileset, or to draw an animated sprite.
A sub-image is just like a frame on an image, where you can change its height, width and position.

I hope you understand me...

edit 2:
Sub-Images are like SDL_Rect in these tuto : http://vally8.free.fr/coinprog/sdl/tut5/sprite.php - http://www.aaroncox.net/tutorials/2dtutorials/sdl_sprite.pdf. But SDL_SetColorKey() doesn't exists yet.

(http://tiplanet.org/forum/download/file.php?id=205&mode=view)