diff --git a/include/script_api/macros.h b/include/script_api/macros.h index 0e318be3c..91f570da5 100644 --- a/include/script_api/macros.h +++ b/include/script_api/macros.h @@ -43,14 +43,14 @@ #define EVT_LIMIT -270000000 // TODO better name // This fixes an issue with fixed point numbers not being correct. Potentially a truncation vs round difference. -#define Float_ROUND(x) ((x) >=0 ? (f64)((x) + 0.9) : (f64)(x)) -#define Float(DOUBLE) ((Bytecode)Float_ROUND(((DOUBLE) * 1024.0f)) - EVT_FIXED_OFFSET) +#define FLOAT_ROUND(x) ((x) >=0 ? (f64)((x) + 0.9) : (f64)(x)) +#define Float(DOUBLE) ((Bytecode)FLOAT_ROUND(((DOUBLE) * 1024.0f)) - EVT_FIXED_OFFSET) /// Progammatically converts Float --> f32 #define EVT_FIXED_TO_FLOAT(x) ({f32 var = (x) + EVT_FIXED_OFFSET; var /= 1024.0f; var;}) /// Progammatically converts f32 --> Float -#define Float_TO_FIXED(x) (((x) * 1024.0f) + -EVT_FIXED_OFFSET) +#define FLOAT_TO_FIXED(x) (((x) * 1024.0f) + -EVT_FIXED_OFFSET) /// Address/pointer constant. #define Ref(sym) ((Bytecode) &(sym)) diff --git a/src/evt/evt.c b/src/evt/evt.c index db7271997..b3a2ede30 100644 --- a/src/evt/evt.c +++ b/src/evt/evt.c @@ -23,7 +23,7 @@ f32 evt_fixed_var_to_float(Bytecode scriptVar) { } Bytecode evt_float_to_fixed_var(f32 value) { - // not equivalent to hte Float_TO_FIXED() macro due to the s32 cast + // not equivalent to hte FLOAT_TO_FIXED() macro due to the s32 cast // occuring *before* the add here and *after* the add in the macro return (s32)(value * 1024.0f) + -EVT_FIXED_OFFSET; } diff --git a/src/evt/f8f60_len_1560.c b/src/evt/f8f60_len_1560.c index 058bfa788..de55a61ed 100644 --- a/src/evt/f8f60_len_1560.c +++ b/src/evt/f8f60_len_1560.c @@ -433,9 +433,9 @@ API_CALLABLE(GetNextPathPos) { } get_path_position(alpha, &pos, path->numVectors, path->lengths, path->staticVectorList, path->vectors); - script->varTable[1] = (pos.x * 1024.0f) + -2.3e8f; - script->varTable[2] = (pos.y * 1024.0f) + -2.3e8f; - script->varTable[3] = (pos.z * 1024.0f) + -2.3e8f; + script->varTable[1] = FLOAT_TO_FIXED(pos.x); + script->varTable[2] = FLOAT_TO_FIXED(pos.y); + script->varTable[3] = FLOAT_TO_FIXED(pos.z); if (path->timeElapsed < path->timeLeft) { path->timeElapsed = path->timeElapsed + 1; diff --git a/src/world/area_hos/hos_05/hos_05_3_misc.c b/src/world/area_hos/hos_05/hos_05_3_misc.c index cd4e42cc4..56233a331 100644 --- a/src/world/area_hos/hos_05/hos_05_3_misc.c +++ b/src/world/area_hos/hos_05/hos_05_3_misc.c @@ -35,10 +35,10 @@ API_CALLABLE(N(func_80240690_A2A8D0)) { angle = (script->varTable[1] * 180.0f) / PI; magnitude = (rand_int(10) / vt2) + 3.0f; - script->varTable[10] = Float_TO_FIXED(magnitude * cos_rad(angle)); - script->varTable[11] = Float_TO_FIXED(rand_int(15) + 5); - script->varTable[12] = Float_TO_FIXED(magnitude * sin_rad(angle)); - script->varTable[13] = Float_TO_FIXED((f32)(rand_int(10) + 10) * -0.05); + script->varTable[10] = FLOAT_TO_FIXED(magnitude * cos_rad(angle)); + script->varTable[11] = FLOAT_TO_FIXED(rand_int(15) + 5); + script->varTable[12] = FLOAT_TO_FIXED(magnitude * sin_rad(angle)); + script->varTable[13] = FLOAT_TO_FIXED((f32)(rand_int(10) + 10) * -0.05); return ApiStatus_DONE2; } diff --git a/src/world/area_jan/jan_13/jan_13_2_puzzle.c b/src/world/area_jan/jan_13/jan_13_2_puzzle.c index 509633b19..a89296132 100644 --- a/src/world/area_jan/jan_13/jan_13_2_puzzle.c +++ b/src/world/area_jan/jan_13/jan_13_2_puzzle.c @@ -28,8 +28,8 @@ void N(setup_gfx_geyser)(void) { } API_CALLABLE(N(GetRatioFromPercent)) { - script->varTable[2] = Float_TO_FIXED(script->varTable[1] / 100.0f); - script->varTable[3] = Float_TO_FIXED(script->varTable[1] / 100.0f); + script->varTable[2] = FLOAT_TO_FIXED(script->varTable[1] / 100.0f); + script->varTable[3] = FLOAT_TO_FIXED(script->varTable[1] / 100.0f); return ApiStatus_DONE2; } diff --git a/src/world/area_kgr/kgr_01/kgr_01_2_wiggle.c b/src/world/area_kgr/kgr_01/kgr_01_2_wiggle.c index 89869df99..08c0bb617 100644 --- a/src/world/area_kgr/kgr_01/kgr_01_2_wiggle.c +++ b/src/world/area_kgr/kgr_01/kgr_01_2_wiggle.c @@ -85,7 +85,7 @@ API_CALLABLE(N(GetEffectiveTongueOffset)) { percent = 100.0f; } amplitude = (amplitude * percent) / 100.0f; - script->varTable[0] = Float_TO_FIXED(amplitude); + script->varTable[0] = FLOAT_TO_FIXED(amplitude); return ApiStatus_DONE2; } diff --git a/src/world/area_mim/mim_01/mim_01_4_hint.c b/src/world/area_mim/mim_01/mim_01_4_hint.c index bc35edd95..526eef71a 100644 --- a/src/world/area_mim/mim_01/mim_01_4_hint.c +++ b/src/world/area_mim/mim_01/mim_01_4_hint.c @@ -12,9 +12,9 @@ API_CALLABLE(N(GetFlowerNormal)) { N(GetFirstTriangleNormal)(mdl->modelNode->displayData->displayList, &x, &y, &z); - evt_set_variable(script, *args++, Float_TO_FIXED(x)); - evt_set_variable(script, *args++, Float_TO_FIXED(y)); - evt_set_variable(script, *args++, Float_TO_FIXED(z)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(x)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(y)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(z)); return ApiStatus_DONE2; } diff --git a/src/world/area_mim/mim_03/mim_03_4_hint.c b/src/world/area_mim/mim_03/mim_03_4_hint.c index e1108c02c..ed5b04c14 100644 --- a/src/world/area_mim/mim_03/mim_03_4_hint.c +++ b/src/world/area_mim/mim_03/mim_03_4_hint.c @@ -12,9 +12,9 @@ API_CALLABLE(N(GetFlowerNormal)) { N(GetFirstTriangleNormal)(mdl->modelNode->displayData->displayList, &x, &y, &z); - evt_set_variable(script, *args++, Float_TO_FIXED(x)); - evt_set_variable(script, *args++, Float_TO_FIXED(y)); - evt_set_variable(script, *args++, Float_TO_FIXED(z)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(x)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(y)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(z)); return ApiStatus_DONE2; } diff --git a/src/world/area_mim/mim_06/mim_06_4_hint.c b/src/world/area_mim/mim_06/mim_06_4_hint.c index 4f38d8dd6..f23453ad8 100644 --- a/src/world/area_mim/mim_06/mim_06_4_hint.c +++ b/src/world/area_mim/mim_06/mim_06_4_hint.c @@ -12,9 +12,9 @@ API_CALLABLE(N(GetFlowerNormal)) { N(GetFirstTriangleNormal)(mdl->modelNode->displayData->displayList, &x, &y, &z); - evt_set_variable(script, *args++, Float_TO_FIXED(x)); - evt_set_variable(script, *args++, Float_TO_FIXED(y)); - evt_set_variable(script, *args++, Float_TO_FIXED(z)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(x)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(y)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(z)); return ApiStatus_DONE2; } diff --git a/src/world/area_trd/trd_07/trd_07_3_magic_doors.c b/src/world/area_trd/trd_07/trd_07_3_magic_doors.c index 8b9add7f7..108e24974 100644 --- a/src/world/area_trd/trd_07/trd_07_3_magic_doors.c +++ b/src/world/area_trd/trd_07/trd_07_3_magic_doors.c @@ -7,10 +7,10 @@ API_CALLABLE(N(GetPointsWithCamRelativeOffset)) { f32 posZ = evt_get_float_variable(script, *args++); f32 angle = evt_get_float_variable(script, *args++); - script->varTable[0] = Float_TO_FIXED(posX + (sin_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 270.0f)) * 1000.0f)); - script->varTable[1] = Float_TO_FIXED(posZ - (cos_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 270.0f)) * 1000.0f)); - script->varTable[2] = Float_TO_FIXED(posX + (sin_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 90.0f)) * 1000.0f)); - script->varTable[3] = Float_TO_FIXED(posZ - (cos_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 90.0f)) * 1000.0f)); + script->varTable[0] = FLOAT_TO_FIXED(posX + (sin_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 270.0f)) * 1000.0f)); + script->varTable[1] = FLOAT_TO_FIXED(posZ - (cos_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 270.0f)) * 1000.0f)); + script->varTable[2] = FLOAT_TO_FIXED(posX + (sin_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 90.0f)) * 1000.0f)); + script->varTable[3] = FLOAT_TO_FIXED(posZ - (cos_deg(clamp_angle(gCameras[CAM_DEFAULT].curYaw + angle + 90.0f)) * 1000.0f)); return ApiStatus_DONE2; } diff --git a/src/world/common/complete/Quizmo.inc.c b/src/world/common/complete/Quizmo.inc.c index 7c54d0cff..3a6c15b28 100644 --- a/src/world/common/complete/Quizmo.inc.c +++ b/src/world/common/complete/Quizmo.inc.c @@ -450,7 +450,7 @@ API_CALLABLE(N(Quizmo_GetCamVfov)) { Bytecode* args = script->ptrReadPos; s32 cameraID = evt_get_variable(script, *args++); - evt_set_variable(script, *args++, Float_TO_FIXED(gCameras[cameraID].vfov)); + evt_set_variable(script, *args++, FLOAT_TO_FIXED(gCameras[cameraID].vfov)); return ApiStatus_DONE2; }