Login
Username:

Password:

Remember me



Lost Password?

Register now!

Sections

Who's Online
94 user(s) are online (84 user(s) are browsing Forums)

Members: 2
Guests: 92

davec555, nbache, more...

Support us!

Headlines

 
  Register To Post  

(1) 2 »
[Solved]SDK-Gurus: ScummVM_OS4 needs your help
Home away from home
Home away from home


See User information
Hi there devs and all that have more insight into the SDK
and programming/coding on OS4 than me (no big deal, i have
near to nothing)

I?m asking for help on a specific problem, the OS4 build
of ScummVM has some flaws on certain games which only shows
up on our platform.
One specific bug is the infamous "moonwalking bug" which
lets the characters walk backwards in "The Curse of Monkey
Island" and "The Dig".

One of the ScummVM devs hit the jackpot by pointing to a
specific function I didn?t even know exists.
atan2()

Take a look at the sourceforge bug tracker item to get an idea about
what was going on.

The problem: Juha (Mr_Capehill - the current official
maintainer) won?t be around for quite some time and the
Scumm devs already closed this item due to the fact that
it's not ScummVM related.

Can someone please test if the function is broken or simply
not used in the right way and offer ideas to fix for OS4?

It IS working now, at least on my build, but the "patch"
provided by cyx won't go into the SVN because it would break
the builds on other platforms (or so i understand it)

Thanks very much for your help

PS: If this is the wrong forum, please move (the thread)

edit: Problem solved


Edited by Raziel on 2007/1/7 17:04:46
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@Raziel

First information you need to post if you have problems with funtions from external libraries (not part of your own package)... what 'C'-Runtime Library you are using. Are you using newlib or clib2? and what version?

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Home away from home
Home away from home


See User information
@hnl_dk

Newlib build

version, uhm...3.11?

Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Quite a regular
Quite a regular


See User information
@hnl_dk and raziel

It could be easily verified by compiling the atan2 test program (I would test 7 calls, pairs of args such as:(1,1) (0,1) (-1,1) (-1,0) (-1,-1) (0, -1) and (1, -1).

Compile it vs clib2 and via newlib and check results. I dunnoh how to do it and if it is possble, but if it is: compile vs system math libs as well, but that could be same as newlib (I'm too rusty after such a long time without A1).

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@Raziel

Quote:

Raziel wrote:
@hnl_dk

Newlib build

ok
Quote:
version, uhm...3.11?

the stub library from SDK 51.22 together with newlib from the newly rereased update?

What is the code using atan2() that does fail?

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Home away from home
Home away from home


See User information
@Jack

Quote:

It could be easily verified by compiling the atan2 test program (I would test 7 calls, pairs of args such as:(1,1) (0,1) (-1,1) (-1,0) (-1,-1) (0, -1) and (1, -1).

Compile it vs clib2 and via newlib and check results. I dunnoh how to do it and if it is possble, but if it is: compile vs system math libs as well, but that could be same as newlib (I'm too rusty after such a long time without A1).

Morning Jack...

I may be able to compile this test program, if i find it...
everything else...eh, WHAT?

Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@Jack

I want him to past how atan2() is used, as it does not need to be atan2() that is the problem, it could also be other functions that needs to be tested.

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Home away from home
Home away from home


See User information
@hnl_dk

The code line i changed to make it work:

//_targetFacing = getAngleFromPos(deltaXFactor, deltaYFactor, (_vm->_game.id == GID_DIG || _vm->_game.id == GID_CMI));//__amigaos4__
_targetFacing = getAngleFromPos(deltaXFactor, deltaYFactor, false);//__amigaos4__

The atan2() code segment that is called and fails:

int getAngleFromPos(int x, int y, bool useATAN) {
if (useATAN) {
double temp = atan2((double)x, (double)-y);
return normalizeAngle((int)(temp * 180 / PI));
} else {
if (ABS(y) * 2 < ABS(x)) {
if (x > 0)
return 90;
return 270;
} else {
if (y > 0)
return 180;
return 0;
}
}
}

Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just can't stay away
Just can't stay away


See User information
@Jack

Quote:

Jack wrote:
@hnl_dk and raziel

It could be easily verified by compiling the atan2 test program (I would test 7 calls, pairs of args such as:(1,1) (0,1) (-1,1) (-1,0) (-1,-1) (0, -1) and (1, -1).

Compile it vs clib2 and via newlib and check results.

And what are the correct results?

atan2() is broken in at least 2 of 3 AmigaOS C libraries
6.RAM Disk:> type test.c
#include <math.h>
#include <stdio.h>

int main(void)
{
printf("atan2( 0, 0) = %f\n", atan2( 0, 0));
printf("atan2( 0, 1) = %f\n", atan2( 0, 1));
printf("atan2( 1, 0) = %f\n", atan2( 1, 0));
printf("atan2( 1, 1) = %f\n", atan2( 1, 1));
printf("atan2( 0,-1) = %f\n", atan2( 0,-1));
printf("atan2(-1, 0) = %f\n", atan2(-1, 0));
printf("atan2(-1,-1) = %f\n", atan2(-1,-1));
return 0;
}
6.RAM Disk:> gcc -Os -Wall test.c -o test
6.RAM Disk:> test
atan2( 0, 0) = NaN
atan2( 0, 1) = 3.141593
atan2( 1, 0) = -1.570796
atan2( 1, 1) = 0.785398
atan2( 0,-1) = 3.141593
atan2(-1, 0) = -1.570796
atan2(-1,-1) = -2.356194
6.RAM Disk:> gcc -Os -Wall test.c -o test -mcrt=clib2 -lm
6.RAM Disk:> test
atan2( 0, 0) = 0.000000
atan2( 0, 1) = 0.000000
atan2( 1, 0) = 1.570796
atan2( 1, 1) = 0.785398
atan2( 0,-1) = 3.141593
atan2(-1, 0) = -1.570796
atan2(-1,-1) = -2.356194
6.RAM Disk:> m68k-amigaos-gcc -Os -Wall test.c -o test -noixemul -lm
6.RAM Disk:> test
atan2( 0, 0) = NaN
atan2( 0, 1) = 0.000000
atan2( 1, 0) = 1.570796
atan2( 1, 1) = 0.785398
atan2( 0,-1) = 3.141593
atan2(-1, 0) = -1.570796
atan2(-1,-1) = -2.356194

Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Quite a regular
Quite a regular


See User information
@Raziel

U can disable atan2 via the argument and see if it helps.
(useATAN = 0)

@hnl_dk

I just proposed a simple test for atan2 alone:

printf("45deg = %lf\n", atan2(1,1) * 180.0/M_PI);
printf("90deg = %lf\n", atan2(1,0) * 180.0/M_PI);
printf("135deg = %lf\n", atan2(1,-1) * 180.0/M_PI);
printf("180deg = %lf\n", atan2(0,-1) * 180.0/M_PI);
printf("-135deg = %lf\n", atan2(-1,-1) * 180.0/M_PI);
printf("-90deg = %lf\n", atan2(-1,0) * 180.0/M_PI);
printf("-45deg = %lf\n", atan2(-1,1) * 180.0/M_PI);

Jack

edit : hnl_dk's post below reminded me that iot should be between -180 and 180 degrees, corrected last 3 lines, thanks.


Edited by Jack on 2007/1/7 11:05:16
Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@joerg

atan2( 0, 0) = 0.000000
atan2( 0, 1) = 0.000000
atan2( 1, 0) = 1.570796
atan2( 1, 1) = 0.785398
atan2( 0,-1) = 3.141593
atan2(-1, 0) = -1.570796
atan2(-1,-1) = -2.356194

that are the correct results (according to glibc)

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Quite a regular
Quite a regular


See User information
@Raziel

Morning 2u2

@Joerg

Quote:

And what are the correct results?


Com'n, little trigonometry won't harm anyone. If you're going to implement 3d api for AOS4 --- it's essential

Quote:

atan2() is broken in at least 2 of 3 AmigaOS C libraries


Even longlived gnuplot has a bugh in tanh() (there's a gap between 355-745deg)

Jack

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Home away from home
Home away from home


See User information
@hnl_dk

Homer voice: "MMMMmmmh, Tech Talk"


Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Quite a regular
Quite a regular


See User information
@nhl_dk


I'm totally drunk

Sorry
Had'nt my coffee yet

Jack

edit: deleted the b***t I wrote

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@Jack

Quote:
ATAN2(3) Linux Programmer's Manual


use something better ... look at return value

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@Jack

Quote:

Jack wrote:
@nhl_dk


I'm totally drunk

Sorry
Had'nt my coffee yet

Jack

edit: deleted the b***t I wrote

was almost about to reply again... that you need some new glasses (as the result was the same, as the one from clib2)

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Quite a regular
Quite a regular


See User information
@hnl_dk

My appologies, you're right. Blanked the post,
The 0,0 one shoudn't be nan? Gone to check...it is 0.0

Jack
edit: checked

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just popping in
Just popping in


See User information
@Jack

Quote:

Jack wrote:
@hnl_dk

My appologies, you're right. Blanked the post,
The 0,0 one shoudn't be nan? Gone to check

Jack

according to the man page
Quote:
If either x or y is NaN, a NaN shall be returned.


...

Quote:
If both arguments are 0, a domain error shall not occur.


...

so clib2 and glibc are right

Best regards,
hnl_dk - Henning Nielsen Lund [Denmark]
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Quite a regular
Quite a regular


See User information
@hnl_dk

Quote:
so clib2 and glibc are right


What does the default comilation uses? Newlib? Does newlib loads the libs: stuff?

Resized Image
"the expression, 'atonal music,' is most unfortunate--it is on a par with calling flying 'the art of not falling,' or swimming 'the art of not drowning.'. A. Schoenberg
Go to top
Re: SDK-Gurus: ScummVM_OS4 needs your help
Just can't stay away
Just can't stay away


See User information
@hnl_dk

Quote:

hnl_dk wrote:
@joerg

atan2( 0, 0) = 0.000000
atan2( 0, 1) = 0.000000
atan2( 1, 0) = 1.570796
atan2( 1, 1) = 0.785398
atan2( 0,-1) = 3.141593
atan2(-1, 0) = -1.570796
atan2(-1,-1) = -2.356194

that are the correct results (according to glibc)

I've fixed it in newlib.library 52.7, but atan2(0,0) still returns NaN, just like in libnix, which is correct IMHO and the 0 from glibc and clib2 are wrong!?

Go to top

  Register To Post
(1) 2 »

 




Currently Active Users Viewing This Thread: 1 ( 0 members and 1 Anonymous Users )




Powered by XOOPS 2.0 © 2001-2024 The XOOPS Project