more math opcodes

svn-id: r15474
This commit is contained in:
Gregory Montoir 2004-10-08 17:56:08 +00:00
parent 757f2fdcef
commit eb97857c95
2 changed files with 43 additions and 9 deletions

View File

@ -868,10 +868,13 @@ protected:
/* HE version 90 script opcodes */
void o90_dup();
void o90_getLT();
void o90_getGT();
void o90_min();
void o90_max();
void o90_sin();
void o90_cos();
void o90_sqrt();
void o90_atan2();
void o90_getSegmentAngle();
void o90_startLocalScript();
void o90_wizImageOps();
void o90_unknown25();

View File

@ -80,14 +80,14 @@ void ScummEngine_v90he::setupOpcodes() {
OPCODE(o72_isAnyOf),
/* 1C */
OPCODE(o90_wizImageOps),
OPCODE(o90_getLT),
OPCODE(o90_getGT),
OPCODE(o90_min),
OPCODE(o90_max),
OPCODE(o90_sin),
/* 20 */
OPCODE(o90_cos),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o6_invalid),
OPCODE(o90_sqrt),
OPCODE(o90_atan2),
OPCODE(o90_getSegmentAngle),
/* 24 */
OPCODE(o6_invalid),
OPCODE(o90_unknown25),
@ -388,7 +388,7 @@ void ScummEngine_v90he::o90_dup() {
}
}
void ScummEngine_v90he::o90_getLT() {
void ScummEngine_v90he::o90_min() {
int a = pop();
int b = pop();
@ -399,7 +399,7 @@ void ScummEngine_v90he::o90_getLT() {
}
}
void ScummEngine_v90he::o90_getGT() {
void ScummEngine_v90he::o90_max() {
int a = pop();
int b = pop();
@ -420,6 +420,37 @@ void ScummEngine_v90he::o90_cos() {
push((int)(cos(a) * 100000));
}
void ScummEngine_v90he::o90_sqrt() {
int i = pop();
if (i < 2) {
push(i);
} else {
push((int)sqrt(i + 1));
}
}
void ScummEngine_v90he::o90_atan2() {
int y = pop();
int x = pop();
int a = (int)(atan2(y, x) * 180. / PI);
if (a < 0) {
a += 360;
}
push(a);
}
void ScummEngine_v90he::o90_getSegmentAngle() {
int y1 = pop();
int x1 = pop();
int dy = y1 - pop();
int dx = x1 - pop();
int a = (int)(atan2(dy, dx) * 180. / PI);
if (a < 0) {
a += 360;
}
push(a);
}
void ScummEngine_v90he::o90_startLocalScript() {
int args[16];
int script, entryp;