#150776 - mog123 - Tue Feb 12, 2008 7:00 pm
Hi, I'm using tonclibs and I'm trying to display a sprite (got the bg to display) can you possibly tell me what I'm doing wrong?
Code: |
#include "tonc.h"
#include "bg.h"
#include "ball.h"
OBJ_ATTR obj_buffer[128];
int main()
{
u32 loop;
u32 tid= 0, pb= 0; //tile id , palbank
OBJ_ATTR *ball= &obj_buffer[0];
REG_DISPCNT = DCNT_MODE4 | DCNT_BG2 | DCNT_OBJ | DCNT_OBJ_1D;
for(loop =0; loop <256; loop++)
{
pal_bg_mem[loop] = bgPalette[loop];
}
for (loop = 0; loop < (120*160); loop++)
{
vid_mem_front[loop] = bgData[loop] ;
}
for(loop = 0; loop < 256; loop++)
{
pal_obj_mem[loop] = ballPalette[loop];
}
obj_set_attr(ball,
ATTR0_SQUARE, // Square, regular sprite
ATTR1_SIZE_8,
ATTR2_PALBANK(pb) | tid); // 8x8p,
while(1)
{
vid_vsync();
oam_copy(oam_mem, obj_buffer, 1);
}
return 0;
}
|
I get an error like this:
In function oam_copy : undefined reference to memcpy32
also:
collect2: ld returned 1 exit status.
That's bout it
Please help
#150780 - DiscoStew - Tue Feb 12, 2008 8:27 pm
Your error is pointing into the oam_copy function, which we see you using, but not showing. The reason why memcpy32 is unreferenced is because you did not include the header to which you can include it, which is <stdio.h>. In the file where you have your oam-copy function, be sure to add that header.
_________________
DS - It's all about DiscoStew
#150782 - Dwedit - Tue Feb 12, 2008 8:52 pm
That's a linker error. Make sure you're including the necessary libraries.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."
#150783 - mog123 - Tue Feb 12, 2008 8:52 pm
o yeah, I forgot i needed the normal libs too:)
edit: included stdio.h and still nothing
Last edited by mog123 on Tue Feb 12, 2008 9:03 pm; edited 1 time in total
#150784 - Cearn - Tue Feb 12, 2008 8:53 pm
memcpy32 is part of tonclib, not the standard C library. You're probably not linking libtonc.a to the project. Check your makefile to see if -ltonc is present anywhere and if the linker directory is set up properly.
#150787 - DiscoStew - Tue Feb 12, 2008 9:05 pm
Cearn wrote: |
memcpy32 is part of tonclib, not the standard C library. You're probably not linking libtonc.a to the project. Check your makefile to see if -ltonc is present anywhere and if the linker directory is set up properly. |
Ah, ok. It's been a while since I last involved myself with your stuff Cearn. so I honestly didn't know about your library.
_________________
DS - It's all about DiscoStew
#150788 - mog123 - Tue Feb 12, 2008 9:06 pm
I'm using a batchfile.
#150790 - gauauu - Tue Feb 12, 2008 9:39 pm
Cearn wrote: |
Check your makefile to see if -ltonc is present anywhere and if the linker directory is set up properly. |
mog123 wrote: |
I'm using a batchfile. |
%s/make/batch/g
Check your batchfile to see if -ltonc is present anywhere and if the linker directory is set up properly.
.....
In the compile step where you link all the .o files together, you generally also specify what libraries it should link to. Look for other -l parameters, and add -ltonc with them.
Also make sure you have libtonc.a and it is in a directory that is included in your linker's path. This is generally specified by -L on that same step. So your linker step will probably look something vaguely like:
Code: |
arm-eabi-gcc.exe (etc etc) -Lc:/gba/libs/locationOfTonc file1.o file2.o (etc) -lgba -ltonc myGame.gba |
#151008 - mog123 - Sun Feb 17, 2008 12:54 am
Still nothing, I linked it and nothing still get that undefined memcpy32
also i get (got this earlier too)
implicit incompatible memcpy
Is there a way to relate to sprite numbers as an array in tonclib?
something like sprite[0] sprite[1] etc?
BTW: I can't use memcpy in any demo, nothing that i try - some help would be needed too.
#151013 - Cearn - Sun Feb 17, 2008 2:24 am
mog123 wrote: |
Still nothing, I linked it and nothing still get that undefined memcpy32 |
There should be a file called libtonc.a somewhere (probably tonclib/lib/libtonc.a) This is the directory you need to use with -L.
mog123 wrote: |
also i get (got this earlier too)
implicit incompatible memcpy |
The declaration of memcpy is in stdlib.h. Try to #include it and see what happens. If not, give the exact error message and the source line causing it.
mog123 wrote: |
Is there a way to relate to sprite numbers as an array in tonclib? something like sprite[0] sprite[1] etc? |
If you mean "can I access OAM as an array", use oam_mem[0], oam_mem[1], etc.
mog123 wrote: |
BTW: I can't use memcpy in any demo, nothing that i try - some help would be needed too. |
Define "can't use". Does building the project fail, or does it give the wrong results?
It would also help if you gave us your batchfile. Batchfiles have the habit of growing unmaintainable very fast (which is part of the reason their use is not recommended for this stuff), and it's possible you didn't add the required parts in quite the right way. I'd strongly suggest learning the basics of makefiles; they're not as hard as they look and you will benefit from it in the long run.