Update JoeyLib Utility Functions
parent
4910c32459
commit
a1e0af83b9
1 changed files with 50 additions and 2 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
#### jlUtilByteSwap
|
||||||
|
```c
|
||||||
|
juint16 jlUtilByteSwap(juint16 twoBytes);
|
||||||
|
```
|
||||||
|
Swaps the two bytes stored in `twoBytes` and returns them.
|
||||||
|
|
||||||
#### jlUtilDie
|
#### jlUtilDie
|
||||||
```c
|
```c
|
||||||
void jlUtilDie(const char *why);
|
void jlUtilDie(const char *why);
|
||||||
|
@ -16,18 +22,54 @@ bool jlUtilIsOdd(int x);
|
||||||
```
|
```
|
||||||
Fast even/odd macro. If `x` is odd, it returns `true`. If `x` is even, it returns `false`.
|
Fast even/odd macro. If `x` is odd, it returns `true`. If `x` is even, it returns `false`.
|
||||||
|
|
||||||
|
#### jlUtilMakePathname
|
||||||
|
```c
|
||||||
|
char *jlUtilMakePathname(char *filename, char *extension);
|
||||||
|
```
|
||||||
|
Returns a temporary character array that consists of the game data directory name, target specific path specifier, the provided `filename`, and the `extension` concatenated into one string. DO NOT free the returned string! If you need to preserve the value returned, `strdup` it to another string.
|
||||||
|
|
||||||
#### jlUtilMustExit
|
#### jlUtilMustExit
|
||||||
```c
|
```c
|
||||||
bool jlUtilMustExit(void);
|
bool jlUtilMustExit(void);
|
||||||
```
|
```
|
||||||
You MUST call `jlUtilMustExit` in any game loop that prevents your application from exiting. If `jlUtilMustExit` returns `true` your application MUST exit safely. This is used on platforms where operating system events may need to terminate your application.
|
You MUST call `jlUtilMustExit` in any game loop that prevents your application from exiting. If `jlUtilMustExit` returns `true` your application MUST exit safely. This is used on platforms where operating system events may need to terminate your application.
|
||||||
|
|
||||||
|
#### jlUtilNibbleSwap
|
||||||
|
```c
|
||||||
|
void jlUtilNibbleSwap(byte *mem, jint16 count, byte old, byte new);
|
||||||
|
```
|
||||||
|
Swaps all occurrences of the nibble `old` in the block of memory `mem` to `new` for `count` bytes. Useful for swapping colors on display surfaces.
|
||||||
|
|
||||||
|
#### jlUtilRandom
|
||||||
|
```c
|
||||||
|
juint16 jlUtilRandom(void);
|
||||||
|
```
|
||||||
|
Returns a random unsigned 16 bit value that is consistent across target platforms.
|
||||||
|
|
||||||
|
#### jlUtilRandomSeedGet
|
||||||
|
```c
|
||||||
|
juint32 jlUtilRandomSeedGet(void);
|
||||||
|
```
|
||||||
|
Returns the internal "seed" of the random number generator in its current state. Useful for saving the state of the random number generator.
|
||||||
|
|
||||||
|
#### jlUtilRandomSeedSet
|
||||||
|
```c
|
||||||
|
void jlUtilRandomSeedSet(juint32 seed);
|
||||||
|
```
|
||||||
|
Specifies the internal "seed" to use for the next random number.
|
||||||
|
|
||||||
#### jlUtilShutdown
|
#### jlUtilShutdown
|
||||||
```c
|
```c
|
||||||
void jlUtilShutdown(void);
|
void jlUtilShutdown(void);
|
||||||
```
|
```
|
||||||
Cleanly shuts down JoeyLib. You should free any resources you have allocated before shutting down. If `JOEY_DEBUG` is defined, various memory statistics will be recorded in a file named `JLSTATS`. This function does not return.
|
Cleanly shuts down JoeyLib. You should free any resources you have allocated before shutting down. If `JOEY_DEBUG` is defined, various memory statistics will be recorded in a file named `JLSTATS`. This function does not return.
|
||||||
|
|
||||||
|
#### jlUtilSleep
|
||||||
|
```c
|
||||||
|
void jlUtilSleep(juint16 tenths);
|
||||||
|
```
|
||||||
|
Pauses program execution for `tenths` one-tenth seconds.
|
||||||
|
|
||||||
#### jlUtilStackPop
|
#### jlUtilStackPop
|
||||||
```c
|
```c
|
||||||
void *jlUtilStackPop(jlStackT stack);
|
void *jlUtilStackPop(jlStackT stack);
|
||||||
|
@ -48,6 +90,12 @@ Starts up JoeyLib and initializes the library. `appName` is the name of your ap
|
||||||
|
|
||||||
#### jlUtilTimer
|
#### jlUtilTimer
|
||||||
```c
|
```c
|
||||||
unsigned int jlUtilTimer(void);
|
juint16 jlUtilTimer(void);
|
||||||
```
|
```
|
||||||
Provides a "wall clock" timer that is consistent across platforms. The value returned increments (roughly) every 1/10th of a second. When it reaches `MAX_INT`, it will roll over to zero.
|
Provides a "wall clock" timer that is consistent across platforms. The value returned increments (roughly) every 1/10th of a second. When it reaches `JUINT16_MAX`, it will roll over to zero.
|
||||||
|
|
||||||
|
#### jlUtilTimeSpan
|
||||||
|
```c
|
||||||
|
juint16 jlUtilTimeSpan(juint16 past, juint16 current);
|
||||||
|
```
|
||||||
|
Returns the difference, in tenths of a second, between `past` and `current` (which are assumed to be values returned by `jlUtilTimer`). Handles zero rollover.
|
||||||
|
|
Loading…
Add table
Reference in a new issue