mirror of
https://github.com/zeldaret/mm.git
synced 2026-08-09 02:45:25 -04:00
Organize libc and libm files (#1499)
* memmove * strcpy * strcmp * memset * fmodf * fix some missing includes * Remove libc header dependencies on libultra * fix * review
This commit is contained in:
@@ -1,11 +0,0 @@
|
||||
#include "global.h"
|
||||
|
||||
void* __osMemset(void* ptr, s32 val, size_t size) {
|
||||
u8* dst = ptr;
|
||||
register s32 rem;
|
||||
|
||||
for (rem = size--; rem != 0; rem = size--) {
|
||||
*dst++ = val;
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "global.h"
|
||||
#include "libc/string.h"
|
||||
|
||||
void* __osMemcpy(void* dst, void* src, size_t size) {
|
||||
u8* _dst = dst;
|
||||
u8* _src = src;
|
||||
register s32 rem;
|
||||
void* memmove(void* dst, const void* src, size_t size) {
|
||||
unsigned char* _dst = dst;
|
||||
const unsigned char* _src = src;
|
||||
register size_t rem;
|
||||
|
||||
if (_dst == _src) {
|
||||
return dst;
|
||||
@@ -0,0 +1,12 @@
|
||||
#include "libc/string.h"
|
||||
|
||||
void* memset(void* ptr, int val, size_t size) {
|
||||
unsigned char* dst = ptr;
|
||||
register size_t rem;
|
||||
|
||||
for (rem = size--; rem != 0; rem = size--) {
|
||||
*dst++ = val;
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "global.h"
|
||||
#include "libc/string.h"
|
||||
|
||||
s32 __osStrcmp(const char* str1, const char* str2) {
|
||||
char c1;
|
||||
char c2;
|
||||
int strcmp(const char* str1, const char* str2) {
|
||||
unsigned char c1;
|
||||
unsigned char c2;
|
||||
|
||||
do {
|
||||
c1 = *str1++;
|
||||
c2 = *str2++;
|
||||
|
||||
if (c1 != c2) {
|
||||
return c1 - c2;
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "libc/string.h"
|
||||
|
||||
char* __osStrcpy(char* dst, const char* src) {
|
||||
char* strcpy(char* dst, const char* src) {
|
||||
char* _dst = dst;
|
||||
|
||||
while (*src != '\0') {
|
||||
@@ -1,10 +1,10 @@
|
||||
#include "libc64/os_malloc.h"
|
||||
|
||||
#include "alignment.h"
|
||||
#include "functions.h" // for __osMemcpy
|
||||
#include "libc/stdbool.h"
|
||||
#include "libc/stdint.h"
|
||||
#include "macros.h" // for ARRAY_COUNT
|
||||
#include "libc/string.h"
|
||||
#include "macros.h"
|
||||
|
||||
#define FILL_ALLOCBLOCK (1 << 0)
|
||||
#define FILL_FREEBLOCK (1 << 1)
|
||||
@@ -374,7 +374,7 @@ void* __osRealloc(Arena* arena, void* ptr, size_t newSize) {
|
||||
next2 = (void*)((uintptr_t)next + diff);
|
||||
node->next = next2;
|
||||
node->size = newSize;
|
||||
__osMemcpy(next2, next, sizeof(ArenaNode));
|
||||
memmove(next2, next, sizeof(ArenaNode));
|
||||
} else {
|
||||
// Create a new pointer and manually copy the data from the old pointer to the new one
|
||||
newPtr = __osMalloc(arena, newSize);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "global.h"
|
||||
#include "libc/math.h"
|
||||
|
||||
f32 fmodf(f32 dividend, f32 divisor) {
|
||||
s32 quotient;
|
||||
float fmodf(float dividend, float divisor) {
|
||||
int quotient;
|
||||
|
||||
if (divisor == 0.0f) {
|
||||
return 0.0f;
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "global.h"
|
||||
#include "libc/string.h"
|
||||
|
||||
static CutsceneCamera* sCurCsCamera;
|
||||
|
||||
@@ -44,8 +45,8 @@ s32 CutsceneCamera_Init(Camera* camera, CutsceneCamera* csCamera) {
|
||||
|
||||
sCurCsCamera = csCamera;
|
||||
|
||||
__osMemset(&csCamera->eyeInterp, 0, sizeof(CutsceneCameraInterp));
|
||||
__osMemset(&csCamera->atInterp, 0, sizeof(CutsceneCameraInterp));
|
||||
memset(&csCamera->eyeInterp, 0, sizeof(CutsceneCameraInterp));
|
||||
memset(&csCamera->atInterp, 0, sizeof(CutsceneCameraInterp));
|
||||
|
||||
csCamera->eyeInterp.type = csCamera->atInterp.type = CS_CAM_INTERP_OFF;
|
||||
|
||||
|
||||
+1
-1
@@ -6955,7 +6955,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, PlayState
|
||||
s16 curUID;
|
||||
s16 j;
|
||||
|
||||
__osMemset(camera, 0, sizeof(Camera));
|
||||
memset(camera, 0, sizeof(Camera));
|
||||
|
||||
camera->play = sCamPlayState = play;
|
||||
curUID = sCameraNextUID;
|
||||
|
||||
+2
-1
@@ -65,6 +65,7 @@ Gfx* sSkyboxStarsDList;
|
||||
#include "objects/gameplay_keep/gameplay_keep.h"
|
||||
#include "objects/gameplay_field_keep/gameplay_field_keep.h"
|
||||
#include "overlays/kaleido_scope/ovl_kaleido_scope/z_kaleido_scope.h"
|
||||
#include "libc/string.h"
|
||||
|
||||
// Data
|
||||
f32 sSandstormLerpScale = 0.0f;
|
||||
@@ -1298,7 +1299,7 @@ void Environment_UpdateLights(PlayState* play, EnvironmentContext* envCtx, Light
|
||||
AdjLightSettings spA4[4];
|
||||
|
||||
var_fs3 = 0.0f;
|
||||
__osMemset(spA4, 0, sizeof(AdjLightSettings) * ARRAY_COUNT(spA4));
|
||||
memset(spA4, 0, sizeof(AdjLightSettings) * ARRAY_COUNT(spA4));
|
||||
lightSettingsList = play->envCtx.lightSettingsList;
|
||||
|
||||
if ((envCtx->lightSettingOverride != LIGHT_SETTING_OVERRIDE_NONE) &&
|
||||
|
||||
+2
-1
@@ -1,5 +1,6 @@
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "global.h"
|
||||
#include "libc/string.h"
|
||||
#include "z64quake.h"
|
||||
#include "z64view.h"
|
||||
|
||||
@@ -174,7 +175,7 @@ QuakeRequest* Quake_RequestImpl(Camera* camera, u32 type) {
|
||||
s16 index = Quake_GetFreeIndex();
|
||||
QuakeRequest* req = &sQuakeRequests[index];
|
||||
|
||||
__osMemset(req, 0, sizeof(QuakeRequest));
|
||||
memset(req, 0, sizeof(QuakeRequest));
|
||||
|
||||
req->camera = camera;
|
||||
req->camId = camera->camId;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
*
|
||||
* For general information about CRC, see the crc.c file (that's a lot of c's!).
|
||||
*/
|
||||
|
||||
#include "ultra64.h"
|
||||
#include "libc/stddef.h"
|
||||
|
||||
#define VOICE_CRC_LENGTH 8
|
||||
|
||||
Reference in New Issue
Block a user