ATan() possible?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

ATan() possible?

Post by AnonymousTipster »

I have come to a snag in my current project which requires an ATan function. I don't think that this can be solved by a simple array of numbers like sin and cos. There 'seems' to be sceFpuSin and sceFpuCos, but I can't see a sceFpuATan function. I couldn't see a function like this in the PSPSDK, and was wondering if somebody can think of a solution to this.

Thanks.
nol33t
Posts: 1
Joined: Sun Jul 10, 2005 7:22 am

Post by nol33t »

use the math lib ( #include<math.h> and -lm at the link )

see also http://forums.ps2dev.org/viewtopic.php?p=19341#19341

Code: Select all

Mathematical Library Functions                           atan&#40;3M&#41;

NAME
     atan - arc tangent function

SYNOPSIS
     cc &#91; flag ... &#93; file ... -lm &#91; library ... &#93;
     #include <math.h>

     double atan&#40;double x&#41;;

DESCRIPTION
     The atan&#40;&#41; function computes the principal value of the  arc
     tangent of x.
Treat
Posts: 16
Joined: Sun Sep 26, 2004 10:17 pm

Post by Treat »

AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Well, the compiler is finding s_atan.c (newlib/libm/math/s_atan.c), but it gives me lots of undefined referrences to '__adddf3' and '__muldf3'. I have #include <Math.h> and have put -lm for my linker. I think it is also finding the s_atan.o, which has been precompiled. It must be something simple, but i'm not sure what i'm doing wrong.
ector
Posts: 195
Joined: Thu May 12, 2005 10:22 pm

Post by ector »

Avoid double precision math on the PSP as it is likely to be dog slow because of the lack of double precision floating point hardware. It has a fast single precision FPU though, not to speak of the VFPU which still has not been publically documented..
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Missing -lgcc, obviously.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

I've put the -lgcc in, and that stops the errors, but the compiler complains : psp-ld: cannot find -lgcc.
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Something's wrong with your toolchain then. Look if the libgcc.a file is in the toolchain directory. If yes, the toolchain is misplaced, and you need a -L on the command line to specify the path to libgcc.a. If no, your toolchain is fucked up and there's nothing I can do about it.
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Well, you could just tell him to link with psp-gcc and not psp-ld, since that's what we've told everyone else who has the same problem.
pixel
Posts: 791
Joined: Fri Jan 30, 2004 11:43 pm

Post by pixel »

Aaaahhh, indeed, I didn't see he was using psp-ld and not psp-gcc...
pixel: A mischievous magical spirit associated with screen displays. The computer industry has frequently borrowed from mythology. Witness the sprites in computer graphics, the demons in artificial intelligence and the trolls in the marketing department.
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Well, the main part of my .sh file looks like this:

Code: Select all

psp-gcc -g -c hellopsp.c
psp-gcc -g -c AnTi2D.c
psp-gcc -g -c -xassembler -O -o startup.o startup.S
psp-gcc -O0 startup.o hellopsp.o AnTi2D.o  -lgcc -lm -M -Ttext 8900000 -q -o  out > hellopsp.map
Whearas it looked like:

Code: Select all

psp-gcc -g -c hellopsp.c
psp-gcc -g -c AnTi2D.c
psp-gcc -g -c -xassembler -O -o startup.o startup.S
psp-ld -O0 startup.o hellopsp.o AnTi2D.o  -lgcc -lm -M -Ttext 8900000 -q -o  out > hellopsp.map
When there was the -lgcc not found error.
With the new script, I am getting 'linker input file not used because linking not done'.
I haven't used cygwin and gcc before, so any help will be appreciated, and thanks for being understanding.
mrbrown
Site Admin
Posts: 1537
Joined: Sat Jan 17, 2004 11:24 am

Post by mrbrown »

Switch to PSPSDK and all of these problems will go away.

http://wiki.ps2dev.org/psp:programming_faq
AnonymousTipster
Posts: 197
Joined: Fri Jul 01, 2005 2:50 am

Post by AnonymousTipster »

Ok, thanks, I'll get onto porting it after my first release.
Post Reply