Author Topic: XF320 lib on the way  (Read 11685 times)

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
XF320 lib on the way
« on: November 18, 2009, 08:12:33 am »
To help devs on OS native, i'm going to implement a multimedia lib for Dingoo OS Native.
This lib is a port of xflib (http://www.xflib.net) and will help you to make game for OS native.

What will you have in it :
- Multiple Backgrounds handling (16 backgrounds^^ with tiles / bitmap in 16 bits mode), with gif /jpeg and perhaps png support if i solve pb with std functions
- Text handling
- Sprites (with rotation)
- wav sound support (4 channels with 16 bits signed, 22050 khz)

I think the lib will be available at the end of this week (so you will have enough time to use it for dingoo digital contest ^^)

If you need some nice feature in it, just tell me, i will try to implement it.
« Last Edit: November 18, 2009, 12:23:18 pm by alekmaul »

Spiller

  • *
  • Posts: 106
Re: XF320 lib on the way
« Reply #1 on: November 18, 2009, 08:55:17 am »
...if i solve pb with std functions...

What problem do you need to solve? I might be able to help.

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #2 on: November 18, 2009, 09:12:49 am »
Well, i have problem to add our stdlib / string / stdio wrapper.
When i want to compile my main program, it said that stderr is unknow, _errno also, and some others things like strtod too.
I think i need to add something to my library makefile, but when i add include like #include "../lib/stdlib", the compiler send an error with conflicting type regarding FILE and some others i don't remember (i'm at work ^^).

Spiller

  • *
  • Posts: 106
Re: XF320 lib on the way
« Reply #3 on: November 18, 2009, 09:26:19 am »
OK, so missing stdlib stuff. I think I might have some stderr/errno stuff in already. I will have a look (I'm at work as well  ;)).

The strtod function would not be so easy to implement, but it can be done. What's the "../lib/stdlib"? If you're trying to include stuff from the toolchain: it's meant for Linux and is going to conflict with the flatmush stdlib.
« Last Edit: November 18, 2009, 09:28:52 am by Spiller »

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #4 on: November 18, 2009, 09:35:09 am »
OK, so missing stdlib stuff. I think I might have some stderr/errno stuff in already. I will have a look (I'm at work as well  ;)).

The strtod function would not be so easy to implement, but it can be done. What's the "../lib/stdlib"? If you're trying to include stuff from the toolchain: it's meant for Linux and is going to conflict with the flatmush stdlib.

I put your #define for stderr and others, but it seems that it has no effect ... :(
I have a source code of strtod also, but i think the compiler try to search first in linux gcc toolchain before flatmush lib (the famous ../lib/stdlib directory).
It's a strange pb, will try to fix it this evening

Spiller

  • *
  • Posts: 106
Re: XF320 lib on the way
« Reply #5 on: November 18, 2009, 12:00:05 pm »
Ah, now I know what "../lib/stdlib" is. I don't have it in that place because I use a central storage for it (dingkit) instead of duplicating it to every project. ;)

If you're using C++ stuff, the compiler will first look in the toolchain stuff. I haven't seen that happen with normal C code though.

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #6 on: November 18, 2009, 12:20:48 pm »
I'm using only C source code, and yes, i'm stupid to duplicate each time flatmush lib (certainly my old age ^^ and a too much big hard drive with lots of space ^^) but as i will ship source code with the lib, the best way is to give people all the package to avoid pb when trying to develop some games.

Harteex

  • * Administrator
  • Posts: 709
    • Harteex Productions
Re: XF320 lib on the way
« Reply #7 on: November 18, 2009, 02:47:43 pm »
I also duplicate flatmush lib all the time :p
Maybe it would be a good way to redistribute more things pre-compiled.. like ogg, stdlib and modplay etc.

Anyway, I hope this lib will help to attract more devs :)

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #8 on: November 18, 2009, 03:05:44 pm »
Anyway, I hope this lib will help to attract more devs :)
It's of course my goal !

Spiller

  • *
  • Posts: 106
Re: XF320 lib on the way
« Reply #9 on: November 18, 2009, 04:21:03 pm »
I also duplicate flatmush lib all the time :p
Maybe it would be a good way to redistribute more things pre-compiled.. like ogg, stdlib and modplay etc.

I'm still planning on releasing 'dingkit' which is based largely on code from flatmush, Ingenic, and us three. Currently dingkit has:

  • Stdlib (still some string functions missing)
  • Libsupc++ (partial C++ support)
  • Flatmush libs (display, graphics, control, etc)
  • Ingenic stuff (overclocking, etc)
  • A crc32 implementation (from zlib)
  • Init, entry, launch and sound examples
  • Makefile, dlmake.ini and link.xn examples

I want to add better C++ support before releasing this, because otherwise I would be getting too much questions on it. It's alpha quality right now and it should be at least beta. I hope my StelGOO project is going to leave me with a dingkit in releasable state.

I do need someone to test if dingkit could be used with the Cygwin toolchain as well. Currently it's only tested on the Linux toolchain. Technically it shouldn't be a problem because the toolchains are comparable. I also switched back from using elf2app.py to dlmake.exe.


alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #10 on: November 18, 2009, 07:23:05 pm »
OK, i add -lc to my examples and now, i only have a few pb .
Still remain :
Quote
mipsel-linux-ld ctype.o errno.o malloc.o qsort.o stdio.o stdlib.o string.o time.
o entry_point.o main.o   ../../../xf320lib/libxf320.a ../../../lib/entry.a -lc -
lm -lgcc -Bstatic -T link.xn -o downenv.elf -Map downenv.map -Ttext 0x80a00000 -
L../../../lib -Ld:/cygwindingoo/mipseltools/lib -zmuldefs
/mipseltools/bin/../mipsel-linux/lib/libm.a(k_standard.o): In function `__kernel
_standard':
k_standard.c:(.text+0x2048): undefined reference to `stderr'
k_standard.c:(.text+0x204c): undefined reference to `stderr'
k_standard.c:(.text+0x2054): undefined reference to `fputs'
k_standard.c:(.text+0x2054): relocation truncated to fit: R_MIPS_26 against `fpu
ts'


k_standard.c:(.text+0x277c): undefined reference to `fputs'
k_standard.c:(.text+0x15b4): undefined reference to `stderr'
k_standard.c:(.text+0x278c): undefined reference to `stderr'
k_standard.c:(.text+0x2794): undefined reference to `fputs'
k_standard.c:(.text+0x27bc): undefined reference to `__assert_fail'

Without -lc, i have also :
Quote
mipsel-linux-ld ctype.o errno.o malloc.o qsort.o stdio.o stdlib.o string.o time.o entry_point.o main.o   ../../../xf320lib/libxf320.a ../../../lib/entry.a -lm -lgcc -Bstatic -T link.xn -o downenv.elf -Map downenv.map -Ttext 0x80a00000 -L../../../lib -Ld:/cygwindingoo/mipseltools/lib -zmuldefs
../../../xf320lib/libxf320.a(xf320_png.o): In function `read_png':
xf320_png.c:(.text+0xc0): undefined reference to `_setjmp'
xf320_png.c:(.text+0xc0): relocation truncated to fit: R_MIPS_26 against `_setjmp'

pngrutil.c:(.text+0x45b4): undefined reference to `__strtod_internal'
pngrutil.c:(.text+0x45b4): relocation truncated to fit: R_MIPS_26 against `__strtod_internal'
pngrutil.c:(.text+0x4694): undefined reference to `__strtod_internal'
pngrutil.c:(.text+0x4694): relocation truncated to fit: R_MIPS_26 against `__strtod_internal'

k_standard.c:(.text+0xd8): relocation truncated to fit: R_MIPS_26 against `__errno_location'
k_standard.c:(.text+0x16c): undefined reference to `__errno_location'
k_standard.c:(.text+0x16c): relocation truncated to fit: R_MIPS_26 against `__errno_location'
k_standard.c:(.text+0x268): undefined reference to `__errno_location'
k_standard.c:(.text+0x2d0): undefined reference to `__errno_location'
/mipseltools/bin/../mipsel-linux/lib/libm.a(k_standard.o):k_standard.c:(.text+0x338): more undefined references to `__errno_location' follow
/mipseltools/bin/../mipsel-linux/lib/libm.a(k_standard.o): In function `__kernel_standard':

As i said before, i only have pb after adding libpng and libz. I remove libpng I/O support.

Spiller, what do you mean with cygwin toolchain and linux toolchain ? i don't understand the difference. For me, we need to use mipseltools inside cywin for compilation, don't we ?
« Last Edit: November 18, 2009, 08:00:36 pm by alekmaul »

dukemagus

  • Guest
Re: XF320 lib on the way
« Reply #11 on: November 18, 2009, 07:59:33 pm »
we from the community are grateful for your hard work... may the gods pay you for your brilliant job

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #12 on: November 18, 2009, 08:00:55 pm »
*POST my edit here to reflet last change *

[EDIT] If i put in flatmush stdlib, in file stdio.c the following code :
Quote
/* Standard streams.  */
FILE *stdin;
FILE *stdout;
FILE *stderr;

And, of course, still using -lc, all problem disappears  but ...
App file grows from 130 Kbytes  to 1030 Kbytes  o_O ??? really strange, pnglib + zlib take so much Kbytes in an app file ?...
Of course, app file works fine on dingoo so png file is loaded without any pb

Spiller

  • *
  • Posts: 106
Re: XF320 lib on the way
« Reply #13 on: November 19, 2009, 07:59:47 am »
Ingenic supplies two toolchains for ucos development: one for Windows (Cygwin based) and one for Linux development. I'm on Linux so I'm using the Linux toolchain. You're on Windows so you're using the Cygwin one. The toolchains are quite similar but not necessarily the same. The toolchains can be found on the Ingenic FTP server in this spot:

ftp://ftp.ingenic.cn/3sw/02rtos/00toolchain/

Both toolchains have in common that they're actually compiling mipsel-linux libraries and binaries. The native firmware OS is not mipsel-linux. The binaries are compatible because the processor matches, but the supplied libraries are not.

When you add in '-lc' what happens is that you're dragging in libc as compiled for mipsel-linux. I am surprised that the binary actually works because most functions in that libc will try to use features specific to Linux. I would actually disrecommend adding '-lc' and make sure that your own libc (flatmush one) is compatible enough to be able to support libpng and libz. I did some more work on dingkit yesterday and have implemented almost all string functions now. This evening I will continue on the IO bit. I need to implement this all to get close to 100% C++ support.

« Last Edit: November 19, 2009, 08:03:25 am by Spiller »

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #14 on: November 19, 2009, 08:14:32 am »
Yes, i know about libc but now, i better understand what you mean about toolchain.
The only big question is why the app file is so big with -lc (so libc) ...
I think i will release the first version of XF320lib without png support (gif and jpeg are enough for the first release).
I also implement some string functions like strrchr and strtod but libpng/libz uses lots of others things and i don't want  actually to take time for that.

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #15 on: November 19, 2009, 06:37:48 pm »
Ok, fix the png problem, it seems to work now without libc (and app file is now only 250Kbytes)  ;D !
So, png support seems to be ok. I will now continue to convert all the xflib examples before release to see if there is others problems. ...

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #16 on: November 24, 2009, 07:39:44 am »
OK, new wip . png support is not so good and seems to hang sometime (don't know why atually :( ).
jpeg support does not hang dingoo but is buggy on screen  (don't know why atually :( ).
I also have pbs with sprite rotation/zoom which hang the Dingoo actually ...  >:( not so easy to port xflib in fact...

Harteex

  • * Administrator
  • Posts: 709
    • Harteex Productions
Re: XF320 lib on the way
« Reply #17 on: November 24, 2009, 01:13:50 pm »
It could also be a problem with stdlib. Most parts are written by flatmush, others are from different places around the net, for example wikipedia and uclibc.

I also have some problems with both modplay and tremor (ogg library), in some very cases they cause a crash.

For example I tried multiple implementations of qsort before I found the one from uclibc, which seems to work fine, but I don't know for sure. Does XFlib use qsort?

alekmaul (OP)

  • *
  • Posts: 330
    • Portabledev
Re: XF320 lib on the way
« Reply #18 on: November 24, 2009, 02:05:39 pm »
Nope, i don't see anything regarding qsort and i implemented lot's of things in stdlib directory.
I think the best thing will be to release actual version to allow someone else to help me to release this lib.
I'm at work actually, i will do that this evening.

jxv

  • *
  • Posts: 38
Re: XF320 lib on the way
« Reply #19 on: November 24, 2009, 03:57:13 pm »
I started working on a data structure that is similar to the sequential container classes in the STL, but it only will have four simple functions, remove, insert, size, get/operator[]. It uses binary trees to store data. You can use it if you like once I am done.

 

Post a new topic
Post a new topic