diff options
Diffstat (limited to 'SDK/Developer/CoreSystem/Sources')
| -rw-r--r-- | SDK/Developer/CoreSystem/Sources/App.c | 31 | ||||
| -rw-r--r-- | SDK/Developer/CoreSystem/Sources/File.c | 43 | ||||
| -rw-r--r-- | SDK/Developer/CoreSystem/Sources/Heap.c | 55 | ||||
| -rw-r--r-- | SDK/Developer/CoreSystem/Sources/Math.c | 14 |
4 files changed, 143 insertions, 0 deletions
diff --git a/SDK/Developer/CoreSystem/Sources/App.c b/SDK/Developer/CoreSystem/Sources/App.c new file mode 100644 index 00000000..7778c064 --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/App.c @@ -0,0 +1,31 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> + +/// @brief Main Application object, retrieved from the RtGetAppPointer symbol. +ApplicationInterfaceRef kSharedApplication = NullPtr; + +/// @brief Gets the app arguments count. +/// @param void no arguments. +/// @return The number of arguments given to the application. +CA_EXTERN_C SizeType RtGetAppArgumentsCount(VoidType) +{ + CA_MUST_PASS(kSharedApplication); + + return kSharedApplication->Invoke(kSharedApplication, kCallGetArgsCount); +} + +/// @brief Gets the app arguments pointer. +/// @param void no arguments. +/// @return +CA_EXTERN_C CharacterTypeUTF8** RtGetAppArgumentsPtr(VoidType) +{ + CA_MUST_PASS(kSharedApplication); + + return (CharacterTypeUTF8**)kSharedApplication->Invoke(kSharedApplication, + kCallGetArgsPtr); +} diff --git a/SDK/Developer/CoreSystem/Sources/File.c b/SDK/Developer/CoreSystem/Sources/File.c new file mode 100644 index 00000000..40cbd515 --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/File.c @@ -0,0 +1,43 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> +#include <Headers/File.h> + +enum FileOp +{ + kFlushFile, + kReadFork, + kWriteFork, + kOpenFork, + kCloseFork, +}; + +/// @brief Opens a new file. +/// @param path where to find it. +/// @param rest the restrict (rw, rwe, r+, w+, r, w) +/// @return FSRef the file. +CA_EXTERN_C FSRef FsOpenFile(const CharacterTypeUTF8* path, + const CharacterTypeUTF8* rest) +{ + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(path && FsIsValidPath(path) == Yes); + CA_MUST_PASS(rest); + + return kSharedApplication->Invoke(kSharedApplication, kCallOpenFile, path, + rest); +} + +/// @brief Closes the file and flushes it to the said file. +/// @param refFs the filesystem reference. +/// @return +CA_EXTERN_C VoidType FsCloseFile(FSRef refFs) +{ + CA_MUST_PASS(kSharedApplication); + + kSharedApplication->Invoke(kSharedApplication, refFs, kFlushFile); + kSharedApplication->Invoke(kSharedApplication, kCallCloseFile, refFs); +} diff --git a/SDK/Developer/CoreSystem/Sources/Heap.c b/SDK/Developer/CoreSystem/Sources/Heap.c new file mode 100644 index 00000000..6c5e381e --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/Heap.c @@ -0,0 +1,55 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Defines.h> +#include <Headers/Heap.h> + +/// @brief Allocate from the user's heap. +/// @param sz size of object. +/// @param flags flags. +/// @return +CA_EXTERN_C PtrVoidType RtTlsAllocate(QWordType sz, DWordType flags) +{ + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(sz); + CA_MUST_PASS(flags); + + return (PtrVoidType)kSharedApplication->Invoke(kSharedApplication, + kCallAllocPtr, sz, flags); +} + +/// @brief Free pointer from the user's heap. +/// @param ptr the pointer to free. +CA_EXTERN_C VoidType RtTlsFree(PtrVoidType ptr) +{ + CA_MUST_PASS(kSharedApplication); + CA_MUST_PASS(ptr); + + CA_UNREFERENCED_PARAMETER( + kSharedApplication->Invoke(kSharedApplication, kCallFreePtr, ptr)); +} + +/// @brief Get pointer size. +/// @param ptr the pointer to find. +/// @return the size. +CA_EXTERN_C QWordType RtTlsGetSize(PtrVoidType ptr) +{ + CA_MUST_PASS(kSharedApplication); + + CA_MUST_PASS(ptr); + return kSharedApplication->Invoke(kSharedApplication, kCallSizePtr, ptr); +} + +/// @brief Check if the pointer exists. +/// @param ptr the pointer to check. +/// @return if it exists +CA_EXTERN_C BooleanType RtTlsPtrExists(PtrVoidType ptr) +{ + CA_MUST_PASS(kSharedApplication); + + CA_MUST_PASS(ptr); + return kSharedApplication->Invoke(kSharedApplication, kCallCheckPtr, ptr); +} diff --git a/SDK/Developer/CoreSystem/Sources/Math.c b/SDK/Developer/CoreSystem/Sources/Math.c new file mode 100644 index 00000000..6797166a --- /dev/null +++ b/SDK/Developer/CoreSystem/Sources/Math.c @@ -0,0 +1,14 @@ +/* ------------------------------------------- + + Copyright Mahrouss Logic + +------------------------------------------- */ + +#include <Headers/Math.h> + +/// @brief Number generator helper. +/// @return Random generated number. +CA_EXTERN_C SizeType MathRand(VoidType) +{ + return kSharedApplication->Invoke(kSharedApplication, kCallRandomNumberGenerator); +}
\ No newline at end of file |
