From e079e7a3ad408263a730ae75df4c3ec2c5ccabb9 Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 19:08:23 +0100 Subject: [PATCH 01/11] Add trigonometric functions to sdlstdinc --- units/sdlstdinc.inc | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index e8f718cf..5ea3084d 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -138,6 +138,62 @@ function SDL_realloc(mem: Pointer; size: csize_t): Pointer; cdecl; procedure SDL_free(mem: Pointer); cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_free' {$ENDIF} {$ENDIF}; + +(*** --- Math functions --- ***) + + +(** + * Calculate the cosine of x, where x is given in radians. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_cos(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_cos' {$ENDIF} {$ENDIF}; + +(** + * Calculate the cosine of x, where x is given in radians. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_cosf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_cosf' {$ENDIF} {$ENDIF}; + +(** + * Calculate the sine of x, where x is given in radians. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_sin(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_sin' {$ENDIF} {$ENDIF}; + +(** + * Calculate the sine of x, where x is given in radians. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_sinf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_sinf' {$ENDIF} {$ENDIF}; + +(** + * Calculate the tangent of x, where x is given in radians. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_tan(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_tan' {$ENDIF} {$ENDIF}; + +(** + * Calculate the tangent of x, where x is given in radians. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_tanf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_tanf' {$ENDIF} {$ENDIF}; + + +(*** --- iconv functions --- ***) + + (** * This function converts a string between encodings in one pass, returning a * string that must be freed with SDL_free(), or NIL on error. From e4d330d9c8ca59bbfa6c23bc36f8dc97cc2be6c2 Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 19:15:36 +0100 Subject: [PATCH 02/11] Add arc-trig functions to sdlstdinc --- units/sdlstdinc.inc | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index 5ea3084d..34a21fe0 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -142,6 +142,78 @@ procedure SDL_free(mem: Pointer); cdecl; (*** --- Math functions --- ***) +(** + * Calculate the arc cosine of x; + * that is, the value (in radians) whose cosine equals x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_acos(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_acos' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc cosine of x; + * that is, the value (in radians) whose cosine equals x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_acosf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_acosf' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc sine of x; + * that is, the value (in radians) whose sine equals x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_asin(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_asin' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc sine of x; + * that is, the value (in radians) whose sine equals x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_asinf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_asinf' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc tangent of x; + * that is, the value (in radians) whose tangent equals x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_atan(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_atan' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc tangent of x; + * that is, the value (in radians) whose tangent equals x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_atanf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_atanf' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc tangent of y/x, using the signs of the two arguments + * to determine the quadrant of the result. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_atan2(y, x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_atan2' {$ENDIF} {$ENDIF}; + +(** + * Calculate the arc tangent of y/x, using the signs of the two arguments + * to determine the quadrant of the result. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_atan2f(y, x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_atan2f' {$ENDIF} {$ENDIF}; + (** * Calculate the cosine of x, where x is given in radians. * From 6691a76c753a66e2bf34387bd17595db790501f4 Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 19:33:55 +0100 Subject: [PATCH 03/11] Add SDL_ceil and SDL_floor --- units/sdlstdinc.inc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index 34a21fe0..25dd7956 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -214,6 +214,22 @@ function SDL_atan2(y, x: cdouble): cdouble; cdecl; function SDL_atan2f(y, x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_atan2f' {$ENDIF} {$ENDIF}; +(** + * Calculate the smallest integral value that is not less than x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_ceil(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ceil' {$ENDIF} {$ENDIF}; + +(** + * Calculate the smallest integral value that is not less than x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_ceilf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ceilf' {$ENDIF} {$ENDIF}; + (** * Calculate the cosine of x, where x is given in radians. * @@ -230,6 +246,22 @@ function SDL_cos(x: cdouble): cdouble; cdecl; function SDL_cosf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_cosf' {$ENDIF} {$ENDIF}; +(** + * Calculate the largest integral value that is not greater than x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_floor(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_floor' {$ENDIF} {$ENDIF}; + +(** + * Calculate the largest integral value that is not greater than x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_floorf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_floorf' {$ENDIF} {$ENDIF}; + (** * Calculate the sine of x, where x is given in radians. * From b65907ff9a3b117c3dc9472a77b474bde87c5cad Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 19:42:16 +0100 Subject: [PATCH 04/11] Add SDL_copysign and SDL_fabs --- units/sdlstdinc.inc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index 25dd7956..c13839a9 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -230,6 +230,24 @@ function SDL_ceil(x: cdouble): cdouble; cdecl; function SDL_ceilf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_ceilf' {$ENDIF} {$ENDIF}; +(** + * Return a number whose absolute value matches that of x, + * but the sign matches that of y. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_copysign(x, y: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_copysign' {$ENDIF} {$ENDIF}; + +(** + * Return a number whose absolute value matches that of x, + * but the sign matches that of y. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_copysignf(x, y: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_copysignf' {$ENDIF} {$ENDIF}; + (** * Calculate the cosine of x, where x is given in radians. * @@ -246,6 +264,22 @@ function SDL_cos(x: cdouble): cdouble; cdecl; function SDL_cosf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_cosf' {$ENDIF} {$ENDIF}; +(** + * Calculate the absolute value of x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_fabs(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_fabs' {$ENDIF} {$ENDIF}; + +(** + * Calculate the absolute value of x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_fabsf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_fabsf' {$ENDIF} {$ENDIF}; + (** * Calculate the largest integral value that is not greater than x. * From 61eba7d9a1803444f1cc5d2e4b658dec1cb46f55 Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 19:51:06 +0100 Subject: [PATCH 05/11] Add SDL_round and SDL_trunc --- units/sdlstdinc.inc | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index c13839a9..b9dc980c 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -296,6 +296,38 @@ function SDL_floor(x: cdouble): cdouble; cdecl; function SDL_floorf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_floorf' {$ENDIF} {$ENDIF}; +(** + * Round to nearest integer, away from zero. + * + * \since This function is available since SDL 2.0.16. + *) +function SDL_lround(x: cdouble): clong; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_lround' {$ENDIF} {$ENDIF}; + +(** + * Round to nearest integer, away from zero. + * + * \since This function is available since SDL 2.0.16. + *) +function SDL_lroundf(x: cfloat): clong; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_lroundf' {$ENDIF} {$ENDIF}; + +(** + * Round to nearest integral value, away from zero. + * + * \since This function is available since SDL 2.0.16. + *) +function SDL_round(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_round' {$ENDIF} {$ENDIF}; + +(** + * Round to nearest integral value, away from zero. + * + * \since This function is available since SDL 2.0.16. + *) +function SDL_roundf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_roundf' {$ENDIF} {$ENDIF}; + (** * Calculate the sine of x, where x is given in radians. * @@ -328,6 +360,22 @@ function SDL_tan(x: cdouble): cdouble; cdecl; function SDL_tanf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_tanf' {$ENDIF} {$ENDIF}; +(** + * Round to nearest integral value, towards zero. + * + * \since This function is available since SDL 2.0.14. + *) +function SDL_trunc(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_trunc' {$ENDIF} {$ENDIF}; + +(** + * Round to nearest integral value, towards zero. + * + * \since This function is available since SDL 2.0.14. + *) +function SDL_truncf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_truncf' {$ENDIF} {$ENDIF}; + (*** --- iconv functions --- ***) From 00e7f77b12430b783eb2e68ebf5878c94e8da1ff Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 20:48:53 +0100 Subject: [PATCH 06/11] Add SDL_pow and SDL_sqrt --- units/sdlstdinc.inc | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index b9dc980c..b9275ead 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -312,6 +312,22 @@ function SDL_lround(x: cdouble): clong; cdecl; function SDL_lroundf(x: cfloat): clong; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_lroundf' {$ENDIF} {$ENDIF}; +(** + * Calculate the value of x raised to the power of y. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_pow(x, y: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_pow' {$ENDIF} {$ENDIF}; + +(** + * Calculate the value of x raised to the power of y. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_powf(x, y: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_powf' {$ENDIF} {$ENDIF}; + (** * Round to nearest integral value, away from zero. * @@ -344,6 +360,22 @@ function SDL_sin(x: cdouble): cdouble; cdecl; function SDL_sinf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_sinf' {$ENDIF} {$ENDIF}; +(** + * Calculate the non-negative square root of x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_sqrt(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_sqrt' {$ENDIF} {$ENDIF}; + +(** + * Calculate the non-negative square root of x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_sqrtf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_sqrtf' {$ENDIF} {$ENDIF}; + (** * Calculate the tangent of x, where x is given in radians. * From 724704c8a85cfe686f0970705f910c1eb501b1ea Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 21:24:19 +0100 Subject: [PATCH 07/11] Add SDL_exp, SDL_nlog and SDL_log10 --- units/sdlstdinc.inc | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index b9275ead..176cbac1 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -264,6 +264,24 @@ function SDL_cos(x: cdouble): cdouble; cdecl; function SDL_cosf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_cosf' {$ENDIF} {$ENDIF}; +(** + * Calculate the value of e (the base of natural logarithms) + * raised to the power of x. + * + * \since This function is available since SDL 2.0.9. + *) +function SDL_exp(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_exp' {$ENDIF} {$ENDIF}; + +(** + * Calculate the value of e (the base of natural logarithms) + * raised to the power of x. + * + * \since This function is available since SDL 2.0.9. + *) +function SDL_expf(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_expf' {$ENDIF} {$ENDIF}; + (** * Calculate the absolute value of x. * @@ -296,6 +314,40 @@ function SDL_floor(x: cdouble): cdouble; cdecl; function SDL_floorf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_floorf' {$ENDIF} {$ENDIF}; +(** + * Calculate the natural logarithm of x. + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_nlog(x: cdouble): cdouble; cdecl; + external SDL_LibName + name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_log' {$ELSE} 'SDL_log' {$ENDIF}; + +(** + * Calculate the natural logarithm of x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_nlogf(x: cfloat): cfloat; cdecl; + external SDL_LibName + name {$IF DEFINED(DELPHI) AND DEFINED(MACOS)} '_SDL_logf' {$ELSE} 'SDL_logf' {$ENDIF}; + +(** + * Calculate the base 10 logarithm of x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_log10(x: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_log10' {$ENDIF} {$ENDIF}; + +(** + * Calculate the base 10 logarithm of x. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_log10f(x: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_log10f' {$ENDIF} {$ENDIF}; + (** * Round to nearest integer, away from zero. * From 4a59633c63f21bb3e925911863547de088d25b3a Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 21:32:44 +0100 Subject: [PATCH 08/11] Add SDL_scalbn --- units/sdlstdinc.inc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index 176cbac1..64699842 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -396,6 +396,24 @@ function SDL_round(x: cdouble): cdouble; cdecl; function SDL_roundf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_roundf' {$ENDIF} {$ENDIF}; +(** + * Calculate x multiplied by the floating-point radix to the power of n. + * On most systems, the radix is 2, making this equivalent to x*(2**n). + * + * \since This function is available since SDL 2.0.4. + *) +function SDL_scalbn(x: cdouble; n: cint): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_scalbn' {$ENDIF} {$ENDIF}; + +(** + * Calculate x multiplied by the floating-point radix to the power of n. + * On most systems, the radix is 2, making this equivalent to x*(2**n). + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_scalbnf(x: cfloat; n: cint): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_scalbnf' {$ENDIF} {$ENDIF}; + (** * Calculate the sine of x, where x is given in radians. * From 786ae36ac2cf18d3c4d09f08decd4dd0cb85b990 Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 21:35:34 +0100 Subject: [PATCH 09/11] Calculate SDL_fmod --- units/sdlstdinc.inc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index 64699842..8dd70cdd 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -314,6 +314,22 @@ function SDL_floor(x: cdouble): cdouble; cdecl; function SDL_floorf(x: cfloat): cfloat; cdecl; external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_floorf' {$ENDIF} {$ENDIF}; +(** + * Calculate the floating-point remainder of dividing x by y. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_fmod(x, y: cdouble): cdouble; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_fmod' {$ENDIF} {$ENDIF}; + +(** + * Calculate the floating-point remainder of dividing x by y. + * + * \since This function is available since SDL 2.0.8. + *) +function SDL_fmodf(x, y: cfloat): cfloat; cdecl; + external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_fmodf' {$ENDIF} {$ENDIF}; + (** * Calculate the natural logarithm of x. * From 86ece3fc13e72a71d73915ea0c3671df9e6df4f2 Mon Sep 17 00:00:00 2001 From: suve Date: Tue, 14 Mar 2023 21:37:01 +0100 Subject: [PATCH 10/11] Use SDL_fabsf inside SDL_FRectEqualsEpsilon --- units/sdl2.pas | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/units/sdl2.pas b/units/sdl2.pas index 563701e0..a879cb8d 100644 --- a/units/sdl2.pas +++ b/units/sdl2.pas @@ -291,7 +291,6 @@ function SDL_FRectEmpty(const r: PSDL_FRect): Boolean; Result := (r = NIL) or (r^.w <= cfloat(0.0)) or (r^.h <= cfloat(0.0)) end; -{ FIXME: This the Pascal System.Abs() function, instead of the C SDL_fabsf() function. } function SDL_FRectEqualsEpsilon(const a, b: PSDL_FRect; const epsilon: cfloat): Boolean; begin Result := @@ -301,13 +300,13 @@ function SDL_FRectEqualsEpsilon(const a, b: PSDL_FRect; const epsilon: cfloat): (a = b) or ( - (Abs(a^.x - b^.x) <= epsilon) + (SDL_fabsf(a^.x - b^.x) <= epsilon) and - (Abs(a^.y - b^.y) <= epsilon) + (SDL_fabsf(a^.y - b^.y) <= epsilon) and - (Abs(a^.w - b^.w) <= epsilon) + (SDL_fabsf(a^.w - b^.w) <= epsilon) and - (Abs(a^.h - b^.h) <= epsilon) + (SDL_fabsf(a^.h - b^.h) <= epsilon) ) ) end; From a0c4392142e2bbe3ac70ab4d516489fb5ec6eee7 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 28 May 2023 11:31:35 +0200 Subject: [PATCH 11/11] Add comment for SDL_nlog and SDL_nlogf --- units/sdlstdinc.inc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/units/sdlstdinc.inc b/units/sdlstdinc.inc index 8dd70cdd..86320069 100644 --- a/units/sdlstdinc.inc +++ b/units/sdlstdinc.inc @@ -334,6 +334,10 @@ function SDL_fmodf(x, y: cfloat): cfloat; cdecl; * Calculate the natural logarithm of x. * * \since This function is available since SDL 2.0.4. + + SDL2-for-Pascal: ATTENTION: The original C name of this function is SDL_log, + but since Pascal names are case-insensitive, it is in conflict with SDL_Log (logging function). + Hence we decided to rename it. *) function SDL_nlog(x: cdouble): cdouble; cdecl; external SDL_LibName @@ -343,6 +347,10 @@ function SDL_nlog(x: cdouble): cdouble; cdecl; * Calculate the natural logarithm of x. * * \since This function is available since SDL 2.0.8. + + SDL2-for-Pascal: ATTENTION: The original C name of this function is SDL_logf, + but to be consistent with the renamed SDL_log function (see comment of SDL_nlog + for details), we decided to rename it. *) function SDL_nlogf(x: cfloat): cfloat; cdecl; external SDL_LibName