User | Post |
Ramsus
Posts: 149/162 |
Generally speaking, you probably won't use the things that don't work. If in doubt, write a program to test it out or don't use it.
Some things that won't work: pipes, sockets, files, stream-based I/O, threads, processes Some things that should work: string and memory functions, math Some things that might not work, or might work slowly: Floating point math functions
You might consider writing your own memory copying/blitting functions that use GBA-specific code (DMA and what not), as well as your own memory allocator (maybe something stack-based? Also check out the alloca function. Nonstandard but very common.). |
HyperLamer
Posts: 5907/8210 |
Alright, but how do I know what will work and what won't? Trying to compile printf() doesn't raise any errors. |
Ramsus
Posts: 146/162 |
Yeah, I think the guy who maintains it went on a trip or something.
Anyway, certain things like printf won't work without a lot of additional code porting more newlib features, but with crtls, malloc and sprintf should work just fine. Now you just need to write a few letter drawing routines and you can write your own version of printf (also look up varargs if you aren't familiar with them).
There's a GBA library called SGADE here: http://www.suddenpresence.com/sgade/
You can make use of it with the newlib C library (now that you know the important parts work), but it doesn't require one.
|
HyperLamer
Posts: 5896/8210 |
Well, AgbMain doesn't seem to be throwing any red flags, but there's still nothing happening. I figured this was supposed to be a full GBA library and all, but all I see is Unix stuff. And of course no documentation, because some... I can't think of a bad enough word... deleted all the Wiki pages and just filled them with links to God-knows-what. |
Ramsus
Posts: 145/162 |
If lnkscript is already there, then it was probably set up for you. If gcc wants you to use AgbMain, then that's the case and you can forget about setting it up yourself.
Otherwise, you'd want to remove these:
F:\DOS\gbadev\arm-agb-elf\lib\crt0.o F:\DOS\gbadev\arm-agb-elf\lib\interwork\crt0.o F:\DOS\gbadev\arm-agb-elf\lib\thumb\crt0.o F:\DOS\gbadev\arm-agb-elf\lib\thumb\interwork\crt0.o
And put the crt0.o file that you assembled from crtls and the lnkscript file that comes with it in the same folder as the sources you want to compile. Then use gcc -T lnkscript -o whatever.elf main.o graphics.o input.o etc.o and objcopy -O binary whatever.elf whatever.gba
|
HyperLamer
Posts: 5892/8210 |
Wait... I've got a bunch of these. Which do I delete/rename, and where do I put the new ones?
F:\DOS\gbadev\arm-agb-elf\lib\crt0.o F:\DOS\gbadev\arm-agb-elf\lib\interwork\crt0.o F:\DOS\gbadev\arm-agb-elf\lib\thumb\crt0.o F:\DOS\gbadev\arm-agb-elf\lib\thumb\interwork\crt0.o
F:\DOS\gbadev\crtls\crt0.S F:\DOS\gbadev\link_script\CRT0.S
F:\DOS\gbadev\crtls\lnkscript F:\DOS\gbadev\link_script\lnkscript |
Ramsus
Posts: 144/162 |
Not quite. Delete the crt0.o files (or move them into a backup folder), then assemble crt0.s (as -o crt0.o crt0.s). Then in your projects, put crt0.o and lnkscript in the same folder and run gcc -T lnkscript to link stuff. You'll also need to use AgbMain instead of main. |
HyperLamer
Posts: 5855/8210 |
Alright, so how do I use these link scripts? Just replace the existing files in \crtls, and include stdlib like usual? |
Ramsus
Posts: 143/162 |
Originally posted by HyperHacker So there's nothing GBA-specific here? Not even printf()?
Nope. You've only installed an assembler/linker, a compiler, and a standard C library, all designed to be portable.
These things should just work out of the box: optimized memory copying/clearing functions (written in assembly), most string and math functions, qsort, etc.
You'll have to mess with the linker script and crt0.o object image to get things like malloc/free working and to supply some functions for newlib stubs (like _write_r, so you can use newlib's printf, but then you need the newlib documentation for details). You might also consider rolling your own custom allocator instead of using malloc/free.
One really nice thing about everyone using GCC and newlib is that there are already custom linker scripts and crt0.s files out there you can just download, assemble, and use -- assuming your setup doesn't have one already. That'll make it so a lot of things work properly on a GBA.
You can also write your own versions of whatever functions you might need and link without any standard libraries (-nostdlib to give it a try, use start instead of main as the entry point). If you do this, your code should only have includes for your own headers and use functions in your sources, but it'll be a lot smaller.
EDIT: Here's a list of the headers you should have available:
_ansi.h _syslist.h alloca.h ar.h argz.h assert.h ctype.h dirent.h envz.h errno.h fastmath.h fcntl.h grp.h iconv.h ieeefp.h langinfo.h libgen.h limits.h locale.h machine/_types.h machine/ansi.h machine/endian.h machine/fastmath.h machine/ieeefp.h machine/malloc.h machine/param.h machine/setjmp-dj.h machine/setjmp.h machine/stdlib.h machine/termios.h machine/time.h machine/types.h malloc.h math.h newlib.h paths.h process.h pthread.h pwd.h reent.h regdef.h search.h setjmp.h signal.h stdio.h stdlib.h string.h sys/_types.h sys/cdefs.h sys/config.h sys/dirent.h sys/errno.h sys/fcntl.h sys/features.h sys/file.h sys/iconvnls.h sys/lock.h sys/param.h sys/queue.h sys/reent.h sys/resource.h sys/sched.h sys/signal.h sys/stat.h sys/stdio.h sys/string.h sys/syslimits.h sys/time.h sys/timeb.h sys/times.h sys/types.h sys/unistd.h sys/utime.h sys/wait.h termios.h time.h unctrl.h unistd.h utime.h utmp.h wchar.h wctype.h
|
Kyoufu Kawa
Posts: 1842/2481 |
Any standard library functions I've seen on GBA weren't in any library. I actually have a printf.c file in Catnip. |
HyperLamer
Posts: 5829/8210 |
So there's nothing GBA-specific here? Not even printf()? |
Ramsus
Posts: 140/162 |
Originally posted by HyperHacker Well I can just as well download a library or write my own... just wanted to know what stuff is available in this one, and why there's all this Unix stuff.
Those are just standard C library and POSIX functions that came with newlib. You don't really need them for gameboy development, and most of them shouldn't do anything on the GBA. |
HyperLamer
Posts: 5776/8210 |
Well I can just as well download a library or write my own... just wanted to know what stuff is available in this one, and why there's all this Unix stuff. |
Sokarhacd
Posts: 1494/1757 |
if you want easy functions, that have to do with the GBA, get one of the mentioned, HAM, or DevKitArm, they have headers for stuff, and HAM is better for that, since most functions are already there, like displaying an image, writing text, all that. someone also made a 3rd party library with titlescreen functions, and some other interesting ones, so thats probably worth checking out more(http://ngine.de) its like a 40-50MB download. |
HyperLamer
Posts: 5762/8210 |
I mean library functions, like printf(). (That appears to exist... no errors compiling it anyway.) What all of those are there? And yes, the GBA has a BIOS to do things like math and such (DS should too...?). I don't know a whole lot about it but I do know the basics of how it works.
[edit] I looked through the header files, and I just don't get it. It's all Unix stuff. Filesystems, signals, threads... none of this has anything to do with GBA. |
Ramsus
Posts: 139/162 |
There are no functions right now (the GBA doesn't have any system software that I know of). You set a pointer to the address that the screen's video memory resides in and a pointer to the address of the register that controls the screen drawing mode, copy a value for the desired mode into the second pointer's location, then copy data to the screen's memory in the format used by the mode you set it to.
In other words, this is where you look up basic GBA development documentation. I'll find and list some this weekend.
|
HyperLamer
Posts: 5759/8210 |
Maybe you could be a little more specific? I don't even really know what sort of functions are available for the GBA with this. Where would I look for that, the include files? |
interdpth
Posts: 488/527 |
Set up the screens dma some data |
HyperLamer
Posts: 5757/8210 |
...OK, now I feel stupid. I forgot binutils. It works now, but the program doesn't. (Just a printf, with stdio.h included.) The Nintendo logo is zeroed out - does that matter in VBA? - and all the palettes/graphics are empty... so how do I include the logo and graphics? (I read in one of the docs that I would have to supply my own logo, no problem, but there's still the question of how I put it in the ROM. )
Also the forward slash didn't work either. It still chokes at spaces. I even tried putting a backslash before the space to escape it (IIRC, you can do that in Linux) but it didn't work. |
Ramsus
Posts: 138/162 |
Originally posted by HyperHacker That is the exact error. gcc: installation problem, cannot exec `as': No such file or directory That's if I set up the path right, otherwise it can't even find gcc.
You never went into detail on how you were running the program, what the layout of the installed files were, and how you installed/set up the files and the environment, which is what I was more interested in than the vague error message you keep posting. You kind of explained what you were trying to do, but it was too unclear to pick out a specific problem.
Anyway, if as.exe is in the same directory (bin) as gcc.exe and ld.exe, and that directory is in the path, then all I can suggest is to delete everything and use some other build/version like the one HAM includes.
|
This is a long thread. Click here to view it. |