summaryrefslogtreecommitdiff
path: root/src/code
diff options
context:
space:
mode:
authorEllipticEllipsis <elliptic.ellipsis@gmail.com>2022-05-01 23:06:35 +0100
committerGitHub <noreply@github.com>2022-05-02 00:06:35 +0200
commite84f5ab3878b30bdddd2ee5a0dbddc10e00d219d (patch)
tree67e1ac6584b3612b2b5e4066388ef2bc811efc1f /src/code
parent7334ffa373d7aeef31977c2fe39af711d7069809 (diff)
Memstuff (#1164)
* Un-fake a couple of matches in memory manip functions * Document fmodf * Un-fake a couple of matches in memory manip functions * Document fmodf * Rename functions and files * Document memmove, memsets, memcpys * Format * Sort out some missing sizeofs * Name fmodf * Rename local variables * size_t * Use COBRA_SHADOW_TEX_SIZE * Review * Tweak the Doxyfile to remove @brief requirement * Roman's review * Fix a bug comment * Change fmodf
Diffstat (limited to 'src/code')
-rw-r--r--src/code/__osMalloc.c26
-rw-r--r--src/code/__osMemmove.c33
-rw-r--r--src/code/__osMemset.c21
-rw-r--r--src/code/audio_heap.c2
-rw-r--r--src/code/code_80069420.c44
-rw-r--r--src/code/code_80106860.c12
-rw-r--r--src/code/code_801068B0.c24
-rw-r--r--src/code/fmodf.c21
-rw-r--r--src/code/z_camera.c2
-rw-r--r--src/code/z_demo.c46
-rw-r--r--src/code/z_lib.c21
-rw-r--r--src/code/z_message_PAL.c8
-rw-r--r--src/code/z_quake.c2
-rw-r--r--src/code/z_sram.c167
-rw-r--r--src/code/z_view.c2
15 files changed, 250 insertions, 181 deletions
diff --git a/src/code/__osMalloc.c b/src/code/__osMalloc.c
index ddf3024fa..30e99cecb 100644
--- a/src/code/__osMalloc.c
+++ b/src/code/__osMalloc.c
@@ -122,7 +122,7 @@ void __osMallocAddBlock(Arena* arena, void* start, s32 size) {
size2 = (size - diff) & ~0xF;
if (size2 > (s32)sizeof(ArenaNode)) {
- func_80106860(firstNode, BLOCK_UNINIT_MAGIC, size2); // memset
+ __osMemset(firstNode, BLOCK_UNINIT_MAGIC, size2);
firstNode->next = NULL;
firstNode->prev = NULL;
firstNode->size = size2 - sizeof(ArenaNode);
@@ -151,7 +151,7 @@ void ArenaImpl_RemoveAllBlocks(Arena* arena) {
iter = arena->head;
while (iter != NULL) {
next = ArenaImpl_GetNextBlock(iter);
- func_80106860(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode)); // memset
+ __osMemset(iter, BLOCK_UNINIT_MAGIC, iter->size + sizeof(ArenaNode));
iter = next;
}
@@ -228,7 +228,7 @@ void* __osMalloc_NoLockDebug(Arena* arena, u32 size, const char* file, s32 line)
ArenaImpl_SetDebugInfo(iter, file, line, arena);
alloc = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
- func_80106860(alloc, BLOCK_ALLOC_MAGIC, size);
+ __osMemset(alloc, BLOCK_ALLOC_MAGIC, size);
}
break;
@@ -288,7 +288,7 @@ void* __osMallocRDebug(Arena* arena, u32 size, const char* file, s32 line) {
ArenaImpl_SetDebugInfo(iter, file, line, arena);
allocR = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
- func_80106860(allocR, BLOCK_ALLOC_MAGIC, size);
+ __osMemset(allocR, BLOCK_ALLOC_MAGIC, size);
}
break;
@@ -339,7 +339,7 @@ void* __osMalloc_NoLock(Arena* arena, u32 size) {
ArenaImpl_SetDebugInfo(iter, NULL, 0, arena);
alloc = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
- func_80106860(alloc, BLOCK_ALLOC_MAGIC, size);
+ __osMemset(alloc, BLOCK_ALLOC_MAGIC, size);
}
break;
}
@@ -398,7 +398,7 @@ void* __osMallocR(Arena* arena, u32 size) {
ArenaImpl_SetDebugInfo(iter, NULL, 0, arena);
alloc = (void*)((u32)iter + sizeof(ArenaNode));
if (arena->flag & FILL_ALLOCBLOCK) {
- func_80106860(alloc, BLOCK_ALLOC_MAGIC, size);
+ __osMemset(alloc, BLOCK_ALLOC_MAGIC, size);
}
break;
}
@@ -442,7 +442,7 @@ void __osFree_NoLock(Arena* arena, void* ptr) {
ArenaImpl_SetDebugInfo(node, NULL, 0, arena);
if (arena->flag & FILL_FREEBLOCK) {
- func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
+ __osMemset((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
}
newNext = next;
@@ -454,7 +454,7 @@ void __osFree_NoLock(Arena* arena, void* ptr) {
node->size += next->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
- func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
+ __osMemset(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
node->next = newNext;
next = newNext;
@@ -467,7 +467,7 @@ void __osFree_NoLock(Arena* arena, void* ptr) {
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
- func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
+ __osMemset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
}
}
@@ -512,7 +512,7 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) {
ArenaImpl_SetDebugInfo(node, file, line, arena);
if (arena->flag & FILL_FREEBLOCK) {
- func_80106860((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
+ __osMemset((u32)node + sizeof(ArenaNode), BLOCK_FREE_MAGIC, node->size);
}
newNext = node->next;
@@ -524,7 +524,7 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) {
node->size += next->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
- func_80106860(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
+ __osMemset(next, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
node->next = newNext;
next = newNext;
@@ -537,7 +537,7 @@ void __osFree_NoLockDebug(Arena* arena, void* ptr, const char* file, s32 line) {
prev->next = next;
prev->size += node->size + sizeof(ArenaNode);
if (arena->flag & FILL_FREEBLOCK) {
- func_80106860(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
+ __osMemset(node, BLOCK_FREE_MAGIC, sizeof(ArenaNode));
}
}
}
@@ -590,7 +590,7 @@ void* __osRealloc(Arena* arena, void* ptr, u32 newSize) {
}
node->next = newNext;
node->size = newSize;
- func_801068B0(newNext, next, sizeof(ArenaNode)); // memcpy
+ __osMemmove(newNext, next, sizeof(ArenaNode));
} else {
// "Allocate a new memory block and move the contents"
osSyncPrintf("新たにメモリブロックを確保して内容を移動します\n");
diff --git a/src/code/__osMemmove.c b/src/code/__osMemmove.c
new file mode 100644
index 000000000..892fee5ee
--- /dev/null
+++ b/src/code/__osMemmove.c
@@ -0,0 +1,33 @@
+#include "global.h"
+
+/**
+ * memmove: copies `len` bytes from memory starting at `src` to memory starting at `dest`.
+ *
+ * Unlike memcpy(), the regions of memory may overlap.
+ *
+ * @param dest address of start of buffer to write to
+ * @param src address of start of buffer to read from
+ * @param len number of bytes to copy.
+ *
+ * @return dest
+ */
+void* __osMemmove(void* dest, const void* src, size_t len) {
+ u8* d = dest;
+ const u8* s = src;
+
+ if (d == s) {
+ return dest;
+ }
+ if (d < s) {
+ while (len--) {
+ *d++ = *s++;
+ }
+ } else {
+ d += len - 1;
+ s += len - 1;
+ while (len--) {
+ *d-- = *s--;
+ }
+ }
+ return dest;
+}
diff --git a/src/code/__osMemset.c b/src/code/__osMemset.c
new file mode 100644
index 000000000..703d3a8c1
--- /dev/null
+++ b/src/code/__osMemset.c
@@ -0,0 +1,21 @@
+#include "global.h"
+
+/**
+ * memset: sets `len` bytes to `val` starting at address `dest`.
+ *
+ * @see There are two other memsets in this codebase, Lib_MemSet(), MemSet()
+ *
+ * @param dest address to start at
+ * @param val value to write (s32, but interpreted as u8)
+ * @param len number of bytes to write
+ *
+ * @return dest
+ */
+void* __osMemset(void* dest, s32 val, size_t len) {
+ u8* ptr = dest;
+
+ while (len--) {
+ *ptr++ = val;
+ }
+ return dest;
+}
diff --git a/src/code/audio_heap.c b/src/code/audio_heap.c
index 4ba1cff41..3dc51979c 100644
--- a/src/code/audio_heap.c
+++ b/src/code/audio_heap.c
@@ -1021,7 +1021,7 @@ void* AudioHeap_AllocPermanent(s32 tableType, s32 id, u32 size) {
gAudioContext.permanentCache[index].size = size;
//! @bug UB: missing return. "ret" is in v0 at this point, but doing an
- // explicit return uses an additional register.
+ //! explicit return uses an additional register.
#ifdef AVOID_UB
return ret;
#endif
diff --git a/src/code/code_80069420.c b/src/code/code_80069420.c
index 3d656cfb0..6dd0a94f4 100644
--- a/src/code/code_80069420.c
+++ b/src/code/code_80069420.c
@@ -1,23 +1,47 @@
#include "global.h"
-void* MemCopy(void* dest, void* src, s32 size) {
- u8* destu = (u8*)dest;
- u8* srcu = (u8*)src;
+/**
+ * memcpy: copies `len` bytes from memory starting at `src` to memory starting at `dest`. Expects the memory
+ * specified by `src` and `dest` to not overlap.
+ *
+ * @see libultra also has a memcpy().
+ *
+ * @param dest address of start of buffer writing to
+ * @param src address of start of buffer to read from
+ * @param len number of bytes to copy. (`s32` rather than the standard `size_t`)
+ *
+ * @return dest
+ */
+void* MemCpy(void* dest, const void* src, s32 len) {
+ u8* d = dest;
+ const u8* s = src;
- while (size > 0) {
- *destu++ = *srcu++;
- size--;
+ while (len > 0) {
+ *d++ = *s++;
+ len--;
}
return dest;
}
-void* MemSet(void* dest, s32 val, s32 size) {
- u8* destu = (u8*)dest;
- s32 s = size;
+/**
+ * memset: sets `len` bytes to `val` starting at address `dest`.
+ *
+ * @see There are two other memsets in this codebase, Lib_MemSet(), __osMemset().
+ * This one is unused.
+ *
+ * @param dest address to start at
+ * @param val value to write (`s32`, but interpreted as `u8`)
+ * @param len number of bytes to write. (`s32` rather than the standard `size_t`)
+ *
+ * @return dest
+ */
+void* MemSet(void* dest, s32 val, s32 len) {
+ u8* d = dest;
+ s32 s = len;
while (s > 0) {
- *destu++ = val;
+ *d++ = val;
s--;
}
diff --git a/src/code/code_80106860.c b/src/code/code_80106860.c
deleted file mode 100644
index 4c1b8480b..000000000
--- a/src/code/code_80106860.c
+++ /dev/null
@@ -1,12 +0,0 @@
-#include "global.h"
-
-// memset used in __osMalloc, z_quake, z_view, and z_camera
-void* func_80106860(void* ptr, s32 val, size_t size) {
- u8* sp4 = ptr;
- register s32 a3;
-
- for (a3 = size--; a3 != 0; a3 = size--) {
- *sp4++ = val;
- }
- return ptr;
-}
diff --git a/src/code/code_801068B0.c b/src/code/code_801068B0.c
deleted file mode 100644
index d673cc5e0..000000000
--- a/src/code/code_801068B0.c
+++ /dev/null
@@ -1,24 +0,0 @@
-#include "global.h"
-
-// memmove used in __osMalloc.c
-void* func_801068B0(void* dst, void* src, size_t size) {
- u8* spC = dst;
- u8* sp8 = src;
- register s32 a3;
-
- if (spC == sp8) {
- return dst;
- }
- if (spC < sp8) {
- for (a3 = size--; a3 != 0; a3 = size--) {
- *spC++ = *sp8++;
- }
- } else {
- spC += size - 1;
- sp8 += size - 1;
- for (a3 = size--; a3 != 0; a3 = size--) {
- *spC-- = *sp8--;
- }
- }
- return dst;
-}
diff --git a/src/code/fmodf.c b/src/code/fmodf.c
index 6cc69dd87..e1e386223 100644
--- a/src/code/fmodf.c
+++ b/src/code/fmodf.c
@@ -1,12 +1,27 @@
#include "global.h"
+/**
+ * Computes one `x` modulo `y` for floats.
+ *
+ * Acts like the standard C fmodf except does not handle Infinity. See https://en.cppreference.com/w/c/numeric/math/fmod
+ * for the details. It summarizes this function as follows:
+ * "The floating-point remainder of the division operation x/y calculated by this function is exactly the value x - n*y,
+ * where n is x/y with its fractional part truncated.
+ *
+ * The returned value has the same sign as x and is less or equal to y in magnitude."
+ *
+ * @param x dividend
+ * @param y modulus
+ *
+ * @return f32 0.0f if y is 0.0f, or x modulo y otherwise
+ */
f32 fmodf(f32 x, f32 y) {
- s32 quot;
+ s32 n;
if (y == 0.0f) {
return 0.0f;
}
- quot = x / y;
+ n = x / y;
- return x - (quot * y);
+ return x - (n * y);
}
diff --git a/src/code/z_camera.c b/src/code/z_camera.c
index 74af46b0f..cc2c65b54 100644
--- a/src/code/z_camera.c
+++ b/src/code/z_camera.c
@@ -6793,7 +6793,7 @@ void Camera_Init(Camera* camera, View* view, CollisionContext* colCtx, GlobalCon
s16 curUID;
s16 j;
- func_80106860(camera, 0, sizeof(*camera));
+ __osMemset(camera, 0, sizeof(Camera));
if (sInitRegs) {
for (i = 0; i < sOREGInitCnt; i++) {
OREG(i) = sOREGInit[i];
diff --git a/src/code/z_demo.c b/src/code/z_demo.c
index 3b6e42327..9e58d7b69 100644
--- a/src/code/z_demo.c
+++ b/src/code/z_demo.c
@@ -1571,9 +1571,9 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
s32 cutsceneEndFrame;
s16 j;
- MemCopy(&totalEntries, cutscenePtr, 4);
+ MemCpy(&totalEntries, cutscenePtr, 4);
cutscenePtr += 4;
- MemCopy(&cutsceneEndFrame, cutscenePtr, 4);
+ MemCpy(&cutsceneEndFrame, cutscenePtr, 4);
cutscenePtr += 4;
if ((cutsceneEndFrame < csCtx->frames) && (csCtx->state != CS_STATE_UNSKIPPABLE_EXEC)) {
@@ -1587,7 +1587,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
for (i = 0; i < totalEntries; i++) {
- MemCopy(&cmdType, cutscenePtr, 4);
+ MemCpy(&cmdType, cutscenePtr, 4);
cutscenePtr += 4;
if (cmdType == -1) {
@@ -1596,7 +1596,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
switch (cmdType) {
case CS_CMD_MISC:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
func_80064824(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1604,7 +1604,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_SET_LIGHTING:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
Cutscene_Command_SetLighting(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1612,7 +1612,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_PLAYBGM:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
Cutscene_Command_PlayBGM(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1620,7 +1620,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_STOPBGM:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
Cutscene_Command_StopBGM(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1628,7 +1628,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_FADEBGM:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
Cutscene_Command_FadeBGM(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1636,7 +1636,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_09:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
Cutscene_Command_09(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1644,7 +1644,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_SETTIME:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
func_80065134(globalCtx, csCtx, (void*)cutscenePtr);
@@ -1652,7 +1652,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_SET_PLAYER_ACTION:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1680,7 +1680,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 138:
case 139:
case 144:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1708,7 +1708,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 125:
case 131:
case 141:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1732,7 +1732,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 121:
case 126:
case 132:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1755,7 +1755,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 108:
case 127:
case 133:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1774,7 +1774,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 83:
case 128:
case 135:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1791,7 +1791,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 90:
case 129:
case 136:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1809,7 +1809,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 115:
case 130:
case 137:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1826,7 +1826,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
case 114:
case 134:
case 142:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1837,7 +1837,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_SET_ACTOR_ACTION_9:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1848,7 +1848,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
}
break;
case CS_CMD_SET_ACTOR_ACTION_10:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1882,7 +1882,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
cutscenePtr += 8;
break;
case CS_CMD_TEXTBOX:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cmd = (CsCmdBase*)cutscenePtr;
@@ -1898,7 +1898,7 @@ void Cutscene_ProcessCommands(GlobalContext* globalCtx, CutsceneContext* csCtx,
cutscenePtr += 8;
break;
default:
- MemCopy(&cmdEntries, cutscenePtr, 4);
+ MemCpy(&cmdEntries, cutscenePtr, 4);
cutscenePtr += 4;
for (j = 0; j < cmdEntries; j++) {
cutscenePtr += 0x30;
diff --git a/src/code/z_lib.c b/src/code/z_lib.c
index 90df45b91..524d58a0a 100644
--- a/src/code/z_lib.c
+++ b/src/code/z_lib.c
@@ -1,10 +1,25 @@
#include "global.h"
-void Lib_MemSet(u8* dest, size_t size, u8 val) {
- u32 i;
+/**
+ * memset: sets `len` bytes to `val` starting at address `dest`.
+ *
+ * Unlike normal memset,
+ * - `dest` is a `u8*` already,
+ * - does not return `dest`,
+ * - the arguments are in a different order,
+ * - `val` is a `u8` instead of the standard `s32`.
+ *
+ * @see There are two other memsets in this codebase, __osMemset(), MemSet()
+ *
+ * @param dest address to start at
+ * @param len number of bytes to write
+ * @param val value to write
+ */
+void Lib_MemSet(u8* dest, size_t len, u8 val) {
+ size_t i;
// clang-format off
- for (i = 0; i < size; i++) { *dest++ = val; }
+ for (i = 0; i < len; i++) { *dest++ = val; }
// clang-format on
}
diff --git a/src/code/z_message_PAL.c b/src/code/z_message_PAL.c
index c5b316f46..eb5320926 100644
--- a/src/code/z_message_PAL.c
+++ b/src/code/z_message_PAL.c
@@ -2619,8 +2619,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) {
osSyncPrintf("録音終了!!!!!!!!!録音終了\n");
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("\n====================================================================\n");
- MemCopy(gSaveContext.scarecrowCustomSong, gScarecrowCustomSongPtr,
- sizeof(gSaveContext.scarecrowCustomSong));
+ MemCpy(gSaveContext.scarecrowCustomSong, gScarecrowCustomSongPtr,
+ sizeof(gSaveContext.scarecrowCustomSong));
for (i = 0; i < ARRAY_COUNT(gSaveContext.scarecrowCustomSong); i++) {
osSyncPrintf("%d, ", gSaveContext.scarecrowCustomSong[i]);
}
@@ -2682,8 +2682,8 @@ void Message_DrawMain(GlobalContext* globalCtx, Gfx** p) {
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("\n====================================================================\n");
- MemCopy(gSaveContext.scarecrowSpawnSong, gScarecrowSpawnSongPtr,
- sizeof(gSaveContext.scarecrowSpawnSong));
+ MemCpy(gSaveContext.scarecrowSpawnSong, gScarecrowSpawnSongPtr,
+ sizeof(gSaveContext.scarecrowSpawnSong));
for (i = 0; i < ARRAY_COUNT(gSaveContext.scarecrowSpawnSong); i++) {
osSyncPrintf("%d, ", gSaveContext.scarecrowSpawnSong[i]);
}
diff --git a/src/code/z_quake.c b/src/code/z_quake.c
index cd1fac1d1..257d6627b 100644
--- a/src/code/z_quake.c
+++ b/src/code/z_quake.c
@@ -152,7 +152,7 @@ QuakeRequest* Quake_AddImpl(Camera* cam, u32 callbackIdx) {
s16 idx = Quake_GetFreeIndex();
QuakeRequest* req = &sQuakeRequest[idx];
- func_80106860(req, 0, sizeof(QuakeRequest)); // memset
+ __osMemset(req, 0, sizeof(QuakeRequest));
req->cam = cam;
req->camPtrIdx = cam->thisIdx;
req->callbackIdx = callbackIdx;
diff --git a/src/code/z_sram.c b/src/code/z_sram.c
index 923f7d5b1..1277b06ea 100644
--- a/src/code/z_sram.c
+++ b/src/code/z_sram.c
@@ -322,7 +322,7 @@ void Sram_OpenSave(SramContext* sramCtx) {
i = gSramSlotOffsets[gSaveContext.fileNum];
osSyncPrintf("ぽいんと=%x(%d)\n", i, gSaveContext.fileNum); // "Point="
- MemCopy(&gSaveContext, sramCtx->readBuff + i, sizeof(Save));
+ MemCpy(&gSaveContext, sramCtx->readBuff + i, sizeof(Save));
osSyncPrintf(VT_FGCOL(YELLOW));
osSyncPrintf("SCENE_DATA_ID = %d SceneNo = %d\n", gSaveContext.savedSceneNum,
@@ -397,7 +397,7 @@ void Sram_OpenSave(SramContext* sramCtx) {
osSyncPrintf(VT_FGCOL(BLUE));
osSyncPrintf("\n====================================================================\n");
- MemCopy(gScarecrowCustomSongPtr, gSaveContext.scarecrowCustomSong, sizeof(gSaveContext.scarecrowCustomSong));
+ MemCpy(gScarecrowCustomSongPtr, gSaveContext.scarecrowCustomSong, sizeof(gSaveContext.scarecrowCustomSong));
ptr = (u8*)gScarecrowCustomSongPtr;
for (i = 0; i < ARRAY_COUNT(gSaveContext.scarecrowCustomSong); i++, ptr++) {
@@ -412,7 +412,7 @@ void Sram_OpenSave(SramContext* sramCtx) {
osSyncPrintf(VT_FGCOL(GREEN));
osSyncPrintf("\n====================================================================\n");
- MemCopy(gScarecrowSpawnSongPtr, gSaveContext.scarecrowSpawnSong, sizeof(gSaveContext.scarecrowSpawnSong));
+ MemCpy(gScarecrowSpawnSongPtr, gSaveContext.scarecrowSpawnSong, sizeof(gSaveContext.scarecrowSpawnSong));
ptr = gScarecrowSpawnSongPtr;
for (i = 0; i < ARRAY_COUNT(gSaveContext.scarecrowSpawnSong); i++, ptr++) {
@@ -537,7 +537,7 @@ void Sram_VerifyAndLoadAllSaves(FileChooseContext* fileChooseCtx, SramContext* s
for (slotNum = 0; slotNum < 3; slotNum++) {
offset = gSramSlotOffsets[slotNum];
osSyncPrintf("ぽいんと=%x(%d) SAVE_MAX=%d\n", offset, gSaveContext.fileNum, sizeof(Save));
- MemCopy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
+ MemCpy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
oldChecksum = gSaveContext.checksum;
gSaveContext.checksum = 0;
@@ -555,7 +555,7 @@ void Sram_VerifyAndLoadAllSaves(FileChooseContext* fileChooseCtx, SramContext* s
// checksum didnt match, try backup save
osSyncPrintf("ERROR!!! = %x(%d)\n", gSramSlotOffsets[slotNum], slotNum);
offset = gSramSlotOffsets[slotNum + 3];
- MemCopy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
+ MemCpy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
oldChecksum = gSaveContext.checksum;
gSaveContext.checksum = 0;
@@ -635,48 +635,45 @@ void Sram_VerifyAndLoadAllSaves(FileChooseContext* fileChooseCtx, SramContext* s
osSyncPrintf("SAVECT=%x, NAME=%x, LIFE=%x, ITEM=%x, 64DD=%x, HEART=%x\n", DEATHS, NAME, HEALTH_CAP, QUEST, N64DD,
DEFENSE);
- MemCopy(&fileChooseCtx->deaths[0], sramCtx->readBuff + SLOT_OFFSET(0) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
- MemCopy(&fileChooseCtx->deaths[1], sramCtx->readBuff + SLOT_OFFSET(1) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
- MemCopy(&fileChooseCtx->deaths[2], sramCtx->readBuff + SLOT_OFFSET(2) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
-
- MemCopy(&fileChooseCtx->fileNames[0], sramCtx->readBuff + SLOT_OFFSET(0) + NAME,
- sizeof(fileChooseCtx->fileNames[0]));
- MemCopy(&fileChooseCtx->fileNames[1], sramCtx->readBuff + SLOT_OFFSET(1) + NAME,
- sizeof(fileChooseCtx->fileNames[0]));
- MemCopy(&fileChooseCtx->fileNames[2], sramCtx->readBuff + SLOT_OFFSET(2) + NAME,
- sizeof(fileChooseCtx->fileNames[0]));
-
- MemCopy(&fileChooseCtx->healthCapacities[0], sramCtx->readBuff + SLOT_OFFSET(0) + HEALTH_CAP,
- sizeof(fileChooseCtx->healthCapacities[0]));
- MemCopy(&fileChooseCtx->healthCapacities[1], sramCtx->readBuff + SLOT_OFFSET(1) + HEALTH_CAP,
- sizeof(fileChooseCtx->healthCapacities[0]));
- MemCopy(&fileChooseCtx->healthCapacities[2], sramCtx->readBuff + SLOT_OFFSET(2) + HEALTH_CAP,
- sizeof(fileChooseCtx->healthCapacities[0]));
-
- MemCopy(&fileChooseCtx->questItems[0], sramCtx->readBuff + SLOT_OFFSET(0) + QUEST,
- sizeof(fileChooseCtx->questItems[0]));
- MemCopy(&fileChooseCtx->questItems[1], sramCtx->readBuff + SLOT_OFFSET(1) + QUEST,
- sizeof(fileChooseCtx->questItems[0]));
- MemCopy(&fileChooseCtx->questItems[2], sramCtx->readBuff + SLOT_OFFSET(2) + QUEST,
- sizeof(fileChooseCtx->questItems[0]));
-
- MemCopy(&fileChooseCtx->n64ddFlags[0], sramCtx->readBuff + SLOT_OFFSET(0) + N64DD,
- sizeof(fileChooseCtx->n64ddFlags[0]));
- MemCopy(&fileChooseCtx->n64ddFlags[1], sramCtx->readBuff + SLOT_OFFSET(1) + N64DD,
- sizeof(fileChooseCtx->n64ddFlags[0]));
- MemCopy(&fileChooseCtx->n64ddFlags[2], sramCtx->readBuff + SLOT_OFFSET(2) + N64DD,
- sizeof(fileChooseCtx->n64ddFlags[0]));
-
- MemCopy(&fileChooseCtx->defense[0], sramCtx->readBuff + SLOT_OFFSET(0) + DEFENSE,
- sizeof(fileChooseCtx->defense[0]));
- MemCopy(&fileChooseCtx->defense[1], sramCtx->readBuff + SLOT_OFFSET(1) + DEFENSE,
- sizeof(fileChooseCtx->defense[0]));
- MemCopy(&fileChooseCtx->defense[2], sramCtx->readBuff + SLOT_OFFSET(2) + DEFENSE,
- sizeof(fileChooseCtx->defense[0]));
-
- MemCopy(&fileChooseCtx->health[0], sramCtx->readBuff + SLOT_OFFSET(0) + HEALTH, sizeof(fileChooseCtx->health[0]));
- MemCopy(&fileChooseCtx->health[1], sramCtx->readBuff + SLOT_OFFSET(1) + HEALTH, sizeof(fileChooseCtx->health[0]));
- MemCopy(&fileChooseCtx->health[2], sramCtx->readBuff + SLOT_OFFSET(2) + HEALTH, sizeof(fileChooseCtx->health[0]));
+ MemCpy(&fileChooseCtx->deaths[0], sramCtx->readBuff + SLOT_OFFSET(0) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
+ MemCpy(&fileChooseCtx->deaths[1], sramCtx->readBuff + SLOT_OFFSET(1) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
+ MemCpy(&fileChooseCtx->deaths[2], sramCtx->readBuff + SLOT_OFFSET(2) + DEATHS, sizeof(fileChooseCtx->deaths[0]));
+
+ MemCpy(&fileChooseCtx->fileNames[0], sramCtx->readBuff + SLOT_OFFSET(0) + NAME,
+ sizeof(fileChooseCtx->fileNames[0]));
+ MemCpy(&fileChooseCtx->fileNames[1], sramCtx->readBuff + SLOT_OFFSET(1) + NAME,
+ sizeof(fileChooseCtx->fileNames[0]));
+ MemCpy(&fileChooseCtx->fileNames[2], sramCtx->readBuff + SLOT_OFFSET(2) + NAME,
+ sizeof(fileChooseCtx->fileNames[0]));
+
+ MemCpy(&fileChooseCtx->healthCapacities[0], sramCtx->readBuff + SLOT_OFFSET(0) + HEALTH_CAP,
+ sizeof(fileChooseCtx->healthCapacities[0]));
+ MemCpy(&fileChooseCtx->healthCapacities[1], sramCtx->readBuff + SLOT_OFFSET(1) + HEALTH_CAP,
+ sizeof(fileChooseCtx->healthCapacities[0]));
+ MemCpy(&fileChooseCtx->healthCapacities[2], sramCtx->readBuff + SLOT_OFFSET(2) + HEALTH_CAP,
+ sizeof(fileChooseCtx->healthCapacities[0]));
+
+ MemCpy(&fileChooseCtx->questItems[0], sramCtx->readBuff + SLOT_OFFSET(0) + QUEST,
+ sizeof(fileChooseCtx->questItems[0]));
+ MemCpy(&fileChooseCtx->questItems[1], sramCtx->readBuff + SLOT_OFFSET(1) + QUEST,
+ sizeof(fileChooseCtx->questItems[0]));
+ MemCpy(&fileChooseCtx->questItems[2], sramCtx->readBuff + SLOT_OFFSET(2) + QUEST,
+ sizeof(fileChooseCtx->questItems[0]));
+
+ MemCpy(&fileChooseCtx->n64ddFlags[0], sramCtx->readBuff + SLOT_OFFSET(0) + N64DD,
+ sizeof(fileChooseCtx->n64ddFlags[0]));
+ MemCpy(&fileChooseCtx->n64ddFlags[1], sramCtx->readBuff + SLOT_OFFSET(1) + N64DD,
+ sizeof(fileChooseCtx->n64ddFlags[0]));
+ MemCpy(&fileChooseCtx->n64ddFlags[2], sramCtx->readBuff + SLOT_OFFSET(2) + N64DD,
+ sizeof(fileChooseCtx->n64ddFlags[0]));
+
+ MemCpy(&fileChooseCtx->defense[0], sramCtx->readBuff + SLOT_OFFSET(0) + DEFENSE, sizeof(fileChooseCtx->defense[0]));
+ MemCpy(&fileChooseCtx->defense[1], sramCtx->readBuff + SLOT_OFFSET(1) + DEFENSE, sizeof(fileChooseCtx->defense[0]));
+ MemCpy(&fileChooseCtx->defense[2], sramCtx->readBuff + SLOT_OFFSET(2) + DEFENSE, sizeof(fileChooseCtx->defense[0]));
+
+ MemCpy(&fileChooseCtx->health[0], sramCtx->readBuff + SLOT_OFFSET(0) + HEALTH, sizeof(fileChooseCtx->health[0]));
+ MemCpy(&fileChooseCtx->health[1], sramCtx->readBuff + SLOT_OFFSET(1) + HEALTH, sizeof(fileChooseCtx->health[0]));
+ MemCpy(&fileChooseCtx->health[2], sramCtx->readBuff + SLOT_OFFSET(2) + HEALTH, sizeof(fileChooseCtx->health[0]));
osSyncPrintf("f_64dd=%d, %d, %d\n", fileChooseCtx->n64ddFlags[0], fileChooseCtx->n64ddFlags[1],
fileChooseCtx->n64ddFlags[2]);
@@ -741,11 +738,11 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
offset = gSramSlotOffsets[gSaveContext.fileNum];
osSyncPrintf("I=%x no=%d\n", offset, gSaveContext.fileNum);
- MemCopy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
+ MemCpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
offset = gSramSlotOffsets[gSaveContext.fileNum + 3];
osSyncPrintf("I=%x no=%d\n", offset, gSaveContext.fileNum + 3);
- MemCopy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
+ MemCpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE);
@@ -755,20 +752,20 @@ void Sram_InitSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
j = gSramSlotOffsets[gSaveContext.fileNum];
- MemCopy(&fileChooseCtx->deaths[gSaveContext.fileNum], sramCtx->readBuff + j + DEATHS,
- sizeof(fileChooseCtx->deaths[0]));
- MemCopy(&fileChooseCtx->fileNames[gSaveContext.fileNum], sramCtx->readBuff + j + NAME,
- sizeof(fileChooseCtx->fileNames[0]));
- MemCopy(&fileChooseCtx->healthCapacities[gSaveContext.fileNum], sramCtx->readBuff + j + HEALTH_CAP,
- sizeof(fileChooseCtx->healthCapacities[0]));
- MemCopy(&fileChooseCtx->questItems[gSaveContext.fileNum], sramCtx->readBuff + j + QUEST,
- sizeof(fileChooseCtx->questItems[0]));
- MemCopy(&fileChooseCtx->n64ddFlags[gSaveContext.fileNum], sramCtx->readBuff + j + N64DD,
- sizeof(fileChooseCtx->n64ddFlags[0]));
- MemCopy(&fileChooseCtx->defense[gSaveContext.fileNum], sramCtx->readBuff + j + DEFENSE,
- sizeof(fileChooseCtx->defense[0]));
- MemCopy(&fileChooseCtx->health[gSaveContext.fileNum], sramCtx->readBuff + j + HEALTH,
- sizeof(fileChooseCtx->health[0]));
+ MemCpy(&fileChooseCtx->deaths[gSaveContext.fileNum], sramCtx->readBuff + j + DEATHS,
+ sizeof(fileChooseCtx->deaths[0]));
+ MemCpy(&fileChooseCtx->fileNames[gSaveContext.fileNum], sramCtx->readBuff + j + NAME,
+ sizeof(fileChooseCtx->fileNames[0]));
+ MemCpy(&fileChooseCtx->healthCapacities[gSaveContext.fileNum], sramCtx->readBuff + j + HEALTH_CAP,
+ sizeof(fileChooseCtx->healthCapacities[0]));
+ MemCpy(&fileChooseCtx->questItems[gSaveContext.fileNum], sramCtx->readBuff + j + QUEST,
+ sizeof(fileChooseCtx->questItems[0]));
+ MemCpy(&fileChooseCtx->n64ddFlags[gSaveContext.fileNum], sramCtx->readBuff + j + N64DD,
+ sizeof(fileChooseCtx->n64ddFlags[0]));
+ MemCpy(&fileChooseCtx->defense[gSaveContext.fileNum], sramCtx->readBuff + j + DEFENSE,
+ sizeof(fileChooseCtx->defense[0]));
+ MemCpy(&fileChooseCtx->health[gSaveContext.fileNum], sramCtx->readBuff + j + HEALTH,
+ sizeof(fileChooseCtx->health[0]));
osSyncPrintf("f_64dd[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->n64ddFlags[gSaveContext.fileNum]);
osSyncPrintf("heart_status[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->defense[gSaveContext.fileNum]);
@@ -781,14 +778,14 @@ void Sram_EraseSave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
Sram_InitNewSave();
offset = gSramSlotOffsets[fileChooseCtx->selectedFileIndex];
- MemCopy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
+ MemCpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + offset, &gSaveContext, SLOT_SIZE, OS_WRITE);
- MemCopy(&fileChooseCtx->n64ddFlags[fileChooseCtx->selectedFileIndex], sramCtx->readBuff + offset + N64DD,
- sizeof(fileChooseCtx->n64ddFlags[0]));
+ MemCpy(&fileChooseCtx->n64ddFlags[fileChooseCtx->selectedFileIndex], sramCtx->readBuff + offset + N64DD,
+ sizeof(fileChooseCtx->n64ddFlags[0]));
offset = gSramSlotOffsets[fileChooseCtx->selectedFileIndex + 3];
- MemCopy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
+ MemCpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000) + offset, &gSaveContext, SLOT_SIZE, OS_WRITE);
osSyncPrintf("CLEAR終了\n");
@@ -802,32 +799,32 @@ void Sram_CopySave(FileChooseContext* fileChooseCtx, SramContext* sramCtx) {
gSramSlotOffsets[fileChooseCtx->copyDestFileIndex]);
offset = gSramSlotOffsets[fileChooseCtx->selectedFileIndex];
- MemCopy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
+ MemCpy(&gSaveContext, sramCtx->readBuff + offset, sizeof(Save));
offset = gSramSlotOffsets[fileChooseCtx->copyDestFileIndex];
- MemCopy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
+ MemCpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
offset = gSramSlotOffsets[fileChooseCtx->copyDestFileIndex + 3];
- MemCopy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
+ MemCpy(sramCtx->readBuff + offset, &gSaveContext, sizeof(Save));
SsSram_ReadWrite(OS_K1_TO_PHYSICAL(0xA8000000), sramCtx->readBuff, SRAM_SIZE, OS_WRITE);
offset = gSramSlotOffsets[fileChooseCtx->copyDestFileIndex];
- MemCopy(&fileChooseCtx->deaths[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + DEATHS,
- sizeof(fileChooseCtx->deaths[0]));
- MemCopy(&fileChooseCtx->fileNames[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + NAME,
- sizeof(fileChooseCtx->fileNames[0]));
- MemCopy(&fileChooseCtx->healthCapacities[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + HEALTH_CAP,
- sizeof(fileChooseCtx->healthCapacities[0]));
- MemCopy(&fileChooseCtx->questItems[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + QUEST,
- sizeof(fileChooseCtx->questItems[0]));
- MemCopy(&fileChooseCtx->n64ddFlags[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + N64DD,
- sizeof(fileChooseCtx->n64ddFlags[0]));
- MemCopy(&fileChooseCtx->defense[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + DEFENSE,
- sizeof(fileChooseCtx->defense[0]));
- MemCopy(&fileChooseCtx->health[fileChooseCtx->copyDestFileIndex], (sramCtx->readBuff + offset) + HEALTH,
- sizeof(fileChooseCtx->health[0]));
+ MemCpy(&fileChooseCtx->deaths[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + DEATHS,
+ sizeof(fileChooseCtx->deaths[0]));
+ MemCpy(&fileChooseCtx->fileNames[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + NAME,
+ sizeof(fileChooseCtx->fileNames[0]));
+ MemCpy(&fileChooseCtx->healthCapacities[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + HEALTH_CAP,
+ sizeof(fileChooseCtx->healthCapacities[0]));
+ MemCpy(&fileChooseCtx->questItems[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + QUEST,
+ sizeof(fileChooseCtx->questItems[0]));
+ MemCpy(&fileChooseCtx->n64ddFlags[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + N64DD,
+ sizeof(fileChooseCtx->n64ddFlags[0]));
+ MemCpy(&fileChooseCtx->defense[fileChooseCtx->copyDestFileIndex], sramCtx->readBuff + offset + DEFENSE,
+ sizeof(fileChooseCtx->defense[0]));
+ MemCpy(&fileChooseCtx->health[fileChooseCtx->copyDestFileIndex], (sramCtx->readBuff + offset) + HEALTH,
+ sizeof(fileChooseCtx->health[0]));
osSyncPrintf("f_64dd[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->n64ddFlags[gSaveContext.fileNum]);
osSyncPrintf("heart_status[%d]=%d\n", gSaveContext.fileNum, fileChooseCtx->defense[gSaveContext.fileNum]);
@@ -851,7 +848,7 @@ void Sram_InitSram(GameState* gameState, SramContext* sramCtx) {
if (sZeldaMagic[i + SRAM_HEADER_MAGIC] != sramCtx->readBuff[i + SRAM_HEADER_MAGIC]) {
osSyncPrintf("SRAM破壊!!!!!!\n"); // "SRAM destruction! ! ! ! ! !"
gSaveContext.language = sramCtx->readBuff[SRAM_HEADER_LANGUAGE];
- MemCopy(sramCtx->readBuff, sZeldaMagic, sizeof(sZeldaMagic));
+ MemCpy(sramCtx->readBuff, sZeldaMagic, sizeof(sZeldaMagic));
sramCtx->readBuff[SRAM_HEADER_LANGUAGE] = gSaveContext.language;
Sram_WriteSramHeader(sramCtx);
}
diff --git a/src/code/z_view.c b/src/code/z_view.c
index 9ed5fad57..0a847ef49 100644
--- a/src/code/z_view.c
+++ b/src/code/z_view.c
@@ -24,7 +24,7 @@ View* View_New(GraphicsContext* gfxCtx) {
View* view = SystemArena_MallocDebug(sizeof(View), "../z_view.c", 285);
if (view != NULL) {
- func_80106860(view, 0, sizeof(View)); // memset
+ __osMemset(view, 0, sizeof(View));
View_Init(view, gfxCtx);
}