Skip to content

Commit

Permalink
fix macro name
Browse files Browse the repository at this point in the history
  • Loading branch information
HailSanta authored and HailSanta committed Feb 28, 2024
1 parent 4be7a2d commit 9c888cd
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 28 deletions.
6 changes: 3 additions & 3 deletions include/script_api/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion src/evt/evt.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/evt/f8f60_len_1560.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 4 additions & 4 deletions src/world/area_hos/hos_05/hos_05_3_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/world/area_jan/jan_13/jan_13_2_puzzle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/world/area_kgr/kgr_01/kgr_01_2_wiggle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/world/area_mim/mim_01/mim_01_4_hint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/world/area_mim/mim_03/mim_03_4_hint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
6 changes: 3 additions & 3 deletions src/world/area_mim/mim_06/mim_06_4_hint.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
8 changes: 4 additions & 4 deletions src/world/area_trd/trd_07/trd_07_3_magic_doors.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion src/world/common/complete/Quizmo.inc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 9c888cd

Please sign in to comment.