diff options
author | Paweł Kołodziejski | 2009-02-20 16:22:09 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2009-02-20 16:22:09 +0000 |
commit | f4719cf79c32ba8797ef6803100acd65bf925572 (patch) | |
tree | adedeabfab6fab0dfc9fb416a82ec002f3cc1628 /engines/sci/engine | |
parent | 823d924064a11cb2f58df76451e2d038dc41220f (diff) | |
download | scummvm-rg350-f4719cf79c32ba8797ef6803100acd65bf925572.tar.gz scummvm-rg350-f4719cf79c32ba8797ef6803100acd65bf925572.tar.bz2 scummvm-rg350-f4719cf79c32ba8797ef6803100acd65bf925572.zip |
formating
svn-id: r38600
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kmath.cpp | 77 |
1 files changed, 28 insertions, 49 deletions
diff --git a/engines/sci/engine/kmath.cpp b/engines/sci/engine/kmath.cpp index d010d0ae60..d038f85c68 100644 --- a/engines/sci/engine/kmath.cpp +++ b/engines/sci/engine/kmath.cpp @@ -25,31 +25,22 @@ #include "sci/include/engine.h" - -reg_t -kRandom(state_t *s, int funct_nr, int argc, reg_t *argv) { - return make_reg(0, - SKPV(0) + (int)((SKPV(1) + 1.0 - SKPV(0)) * (rand() / (RAND_MAX + 1.0)))); +reg_t kRandom(state_t *s, int funct_nr, int argc, reg_t *argv) { + return make_reg(0, SKPV(0) + (int)((SKPV(1) + 1.0 - SKPV(0)) * (rand() / (RAND_MAX + 1.0)))); } - -reg_t -kAbs(state_t *s, int funct_nr, int argc, reg_t *argv) { - /* This is a hack, but so is the code in Hoyle1 that needs it. */ +reg_t kAbs(state_t *s, int funct_nr, int argc, reg_t *argv) { + // This is a hack, but so is the code in Hoyle1 that needs it. if (argv[0].segment) - return make_reg(0, 0x3e8); /* Yes people, this is an object */ + return make_reg(0, 0x3e8); // Yes people, this is an object return make_reg(0, abs(SKPV(0))); } - -reg_t -kSqrt(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kSqrt(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, (gint16) sqrt((float) abs(SKPV(0)))); } - -int -get_angle(int xrel, int yrel) { +int get_angle(int xrel, int yrel) { if ((xrel == 0) && (yrel == 0)) return 0; else { @@ -57,9 +48,9 @@ get_angle(int xrel, int yrel) { if (val < 0) val += 360; - /* Take care of OB1 differences between SSCI and - FSCI. SCI games sometimes check for equality with - "round" angles */ + // Take care of OB1 differences between SSCI and + // FSCI. SCI games sometimes check for equality with + // "round" angles if (val % 45 == 44) val++; else if (val % 45 == 1) @@ -69,74 +60,65 @@ get_angle(int xrel, int yrel) { } } -reg_t -kGetAngle(state_t *s, int funct_nr, int argc, reg_t *argv) { - /* Based on behavior observed with a test program created with - ** SCI Studio. - */ +reg_t kGetAngle(state_t *s, int funct_nr, int argc, reg_t *argv) { + // Based on behavior observed with a test program created with + // SCI Studio. int x1 = SKPV(0); int y1 = SKPV(1); int x2 = SKPV(2); int y2 = SKPV(3); int xrel = x2 - x1; - int yrel = y1 - y2; /* y-axis is mirrored. */ + int yrel = y1 - y2; // y-axis is mirrored. int angle; - /* Move (xrel, yrel) to first quadrant. */ + // Move (xrel, yrel) to first quadrant. if (y1 < y2) yrel = -yrel; if (x2 < x1) xrel = -xrel; - /* Compute angle in grads. */ + // Compute angle in grads. if (yrel == 0 && xrel == 0) angle = 0; else angle = 100 * xrel / (xrel + yrel); - /* Fix up angle for actual quadrant of (xrel, yrel). */ + // Fix up angle for actual quadrant of (xrel, yrel). if (y1 < y2) angle = 200 - angle; if (x2 < x1) angle = 400 - angle; - /* Convert from grads to degrees by merging grad 0 with grad 1, - ** grad 10 with grad 11, grad 20 with grad 21, etc. This leads to - ** "degrees" that equal either one or two grads. - */ + // Convert from grads to degrees by merging grad 0 with grad 1, + // grad 10 with grad 11, grad 20 with grad 21, etc. This leads to + // "degrees" that equal either one or two grads. angle -= (angle + 9) / 10; return make_reg(0, angle); } - -reg_t -kGetDistance(state_t *s, int funct_nr, int argc, reg_t *argv) { - int xrel = (int)(((float) SKPV(1) - SKPV_OR_ALT(3, 0)) / cos(SKPV_OR_ALT(5, 0) * PI / 180.0)); /* This works because cos(0)==1 */ +reg_t kGetDistance(state_t *s, int funct_nr, int argc, reg_t *argv) { + int xrel = (int)(((float) SKPV(1) - SKPV_OR_ALT(3, 0)) / cos(SKPV_OR_ALT(5, 0) * PI / 180.0)); // This works because cos(0)==1 int yrel = SKPV(0) - SKPV_OR_ALT(2, 0); return make_reg(0, (gint16)sqrt((float) xrel*xrel + yrel*yrel)); } -reg_t -kTimesSin(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kTimesSin(state_t *s, int funct_nr, int argc, reg_t *argv) { int angle = SKPV(0); int factor = SKPV(1); return make_reg(0, (int)(factor * 1.0 * sin(angle * PI / 180.0))); } - -reg_t -kTimesCos(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kTimesCos(state_t *s, int funct_nr, int argc, reg_t *argv) { int angle = SKPV(0); int factor = SKPV(1); return make_reg(0, (int)(factor * 1.0 * cos(angle * PI / 180.0))); } -reg_t -kCosDiv(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kCosDiv(state_t *s, int funct_nr, int argc, reg_t *argv) { int angle = SKPV(0); int value = SKPV(1); double cosval = cos(angle * PI / 180.0); @@ -148,8 +130,7 @@ kCosDiv(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, (gint16)(value / cosval)); } -reg_t -kSinDiv(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kSinDiv(state_t *s, int funct_nr, int argc, reg_t *argv) { int angle = SKPV(0); int value = SKPV(1); double sinval = sin(angle * PI / 180.0); @@ -161,8 +142,7 @@ kSinDiv(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, (gint16)(value / sinval)); } -reg_t -kTimesTan(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kTimesTan(state_t *s, int funct_nr, int argc, reg_t *argv) { int param = SKPV(0); int scale = SKPV_OR_ALT(1, 1); @@ -174,8 +154,7 @@ kTimesTan(state_t *s, int funct_nr, int argc, reg_t *argv) { return make_reg(0, (gint16) - (tan(param * PI / 180.0) * scale)); } -reg_t -kTimesCot(state_t *s, int funct_nr, int argc, reg_t *argv) { +reg_t kTimesCot(state_t *s, int funct_nr, int argc, reg_t *argv) { int param = SKPV(0); int scale = SKPV_OR_ALT(1, 1); |