libode port for wii - Open Dynamics Engine for wii
May 07, 2011 05:12PM
Hello wiidevs,

I did not founded the libode ported to wii, then I am trying by myself.

I'm trying to port the libode(http://www.ode.org/) for physics collision detection in 3D to wii using devkitpro.

after some work I has able to compile all ode/src/joints, and many objects in ode/src...
but the my first big compile problem is the fire ode/src/timer.c:

/bin/bash ../../libtool --tag=CXX   --mode=compile /opt/devkitpro/devkitPPC/bin/powerpc-eabi-g++ -DHAVE_CONFIG_H -I.  -I../../include   -I../../OPCODE -I../../OPCODE/Ice -DdTRIMESH_ENABLED -DdTRIMESH_OPCODE -DdSINGLE  -g -O2 -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c -o timer.lo timer.cpp
libtool: compile:  /opt/devkitpro/devkitPPC/bin/powerpc-eabi-g++ -DHAVE_CONFIG_H -I. -I../../include -I../../OPCODE -I../../OPCODE/Ice -DdTRIMESH_ENABLED -DdTRIMESH_OPCODE -DdSINGLE -g -O2 -MT timer.lo -MD -MP -MF .deps/timer.Tpo -c timer.cpp -o timer.o
timer.cpp: In function 'void dStopwatchStart(dStopwatch*)':
timer.cpp:134:43: error: unknown register name '%edx' in 'asm'
timer.cpp:134:43: error: unknown register name '%ecx' in 'asm'
timer.cpp:134:43: error: unknown register name '%eax' in 'asm'
timer.cpp:115:45: error: unknown register name '%edx' in 'asm'
timer.cpp:115:45: error: unknown register name '%eax' in 'asm'
timer.cpp: In function 'void dStopwatchStop(dStopwatch*)':
timer.cpp:134:43: error: unknown register name '%edx' in 'asm'
timer.cpp:134:43: error: unknown register name '%ecx' in 'asm'
timer.cpp:134:43: error: unknown register name '%eax' in 'asm'
timer.cpp:115:45: error: unknown register name '%edx' in 'asm'
timer.cpp:115:45: error: unknown register name '%eax' in 'asm'
timer.cpp: In function 'void dTimerStart(const char*)':
timer.cpp:134:43: error: unknown register name '%edx' in 'asm'
timer.cpp:134:43: error: unknown register name '%ecx' in 'asm'
timer.cpp:134:43: error: unknown register name '%eax' in 'asm'
timer.cpp:115:45: error: unknown register name '%edx' in 'asm'
timer.cpp:115:45: error: unknown register name '%eax' in 'asm'
timer.cpp: In function 'void dTimerNow(const char*)':
timer.cpp:115:45: error: unknown register name '%edx' in 'asm'
timer.cpp:115:45: error: unknown register name '%eax' in 'asm'
timer.cpp: In function 'void dTimerEnd()':
timer.cpp:134:43: error: unknown register name '%edx' in 'asm'
timer.cpp:134:43: error: unknown register name '%ecx' in 'asm'
timer.cpp:134:43: error: unknown register name '%eax' in 'asm'
timer.cpp:115:45: error: unknown register name '%edx' in 'asm'
timer.cpp:115:45: error: unknown register name '%eax' in 'asm'
make[2]: *** [timer.lo] Error 1
make[2]: Leaving directory `/home/ton/src/wii/ode/ode-0.11.1/ode/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/ton/src/wii/ode/ode-0.11.1/ode/src'
make: *** [all] Error 2

yep... there's a asm code that is the problem:

static inline void getClockCount (unsigned long cc[2])
{
#ifndef X86_64_SYSTEM   
  asm volatile (
        "rdtsc\n"
        "movl %%eax,(%%esi)\n"
        "movl %%edx,4(%%esi)\n"
        : : "S" (cc) : "%eax","%edx","cc","memory");
#else
  asm volatile (
        "rdtsc\n"
        "movl %%eax,(%%rsi)\n"
        "movl %%edx,4(%%rsi)\n"
        : : "S" (cc) : "%eax","%edx","cc","memory");
#endif
}

static inline void serialize()
{
#ifndef X86_64_SYSTEM
  asm volatile (
        "mov $0,%%eax\n"
        "push %%ebx\n"
        "cpuid\n"
        "pop %%ebx\n"
        : : : "%eax","%ecx","%edx","cc","memory");
#else
  asm volatile (
        "mov $0,%%rax\n"
        "push %%rbx\n"
        "cpuid\n"
        "pop %%rbx\n"
        : : : "%rax","%rcx","%rdx","cc","memory");
#endif
}

I think that with the correct register names all will compile ok... but I don't know the ppc architecture...

Can someone help me to fix it and port this great lib to wii ?

Att
Ton
Re: libode port for wii - Open Dynamics Engine for wii
May 07, 2011 10:01PM
This code is taken from [wiibrew.org]... it's a nice way to get a hiress 64bit timer.
No idea about the (load/save???) serialize suff.

u64 timer_gettime()
{
	u32 tb_upper;
	u32 tb_upper1;
	u32 tb_lower;
	u64 time;
	
	do
    {
      __asm__ __volatile__ ("mftbu %0" : "=r"(tb_upper));
      __asm__ __volatile__ ("mftb %0" : "=r"(tb_lower));
      __asm__ __volatile__ ("mftbu %0" : "=r"(tb_upper1));
    }
	while (tb_upper != tb_upper1);
	
	time = (((u64)tb_upper) << 32) | tb_lower;
	return time;
}
// calling example
//u64 microsecs = ticks_to_microsecs(gettime());   // ticks macro is part of devkitPPC .. more like this one can be found


Have you tried compiling with temporary stubs in these types of places?
Re: libode port for wii - Open Dynamics Engine for wii
May 08, 2011 10:49AM
Not sure if you need to implement the cpuid stuff.

The cpuid x86 asm instruction returns the processor info. based on the value set in EAX. In this case EAX=0 will return Get vendor, more detail can be found here. [en.wikipedia.org].
Re: libode port for wii - Open Dynamics Engine for wii
May 11, 2011 03:38AM
In this code cpuid is only being used to serialize execution (hence the function name and why the function returns void). Issuing a "sc" instruction when running under libogc will do the same thing.
Sorry, only registered users may post in this forum.

Click here to login