summaryrefslogtreecommitdiff
path: root/arm9/lib/src
diff options
context:
space:
mode:
authorred031000 <rubenru09@aol.com>2020-05-26 01:54:32 +0100
committerGitHub <noreply@github.com>2020-05-26 01:54:32 +0100
commit227da51c377f621f542ffdb52ef56bfb807f29ab (patch)
tree31ec68ffd57f0d43df60f6885636cc12de782306 /arm9/lib/src
parent895b0ad8b9c09a0b6b1de59de76ed4a258076f87 (diff)
parent0985659425ab1a9035d85512e330cdc247b24e6b (diff)
Merge pull request #109 from red031000/master
OS_protectionUnit.c + warning fixes
Diffstat (limited to 'arm9/lib/src')
-rw-r--r--arm9/lib/src/FS_archive.c52
-rw-r--r--arm9/lib/src/FS_command.c4
-rw-r--r--arm9/lib/src/FS_command_default.c38
-rw-r--r--arm9/lib/src/FS_file.c16
-rw-r--r--arm9/lib/src/FS_overlay.c26
-rw-r--r--arm9/lib/src/FS_rom.c18
-rw-r--r--arm9/lib/src/FX_atan.c53
-rw-r--r--arm9/lib/src/FX_cp.c24
-rw-r--r--arm9/lib/src/FX_mtx22.c8
-rw-r--r--arm9/lib/src/FX_mtx33.c42
-rw-r--r--arm9/lib/src/FX_mtx43.c48
-rw-r--r--arm9/lib/src/FX_mtx44.c32
-rw-r--r--arm9/lib/src/FX_vec.c54
-rw-r--r--arm9/lib/src/GX.c20
-rw-r--r--arm9/lib/src/GX_bgcnt.c16
-rw-r--r--arm9/lib/src/GX_g2.c38
-rw-r--r--arm9/lib/src/GX_g3_util.c90
-rw-r--r--arm9/lib/src/GX_g3b.c2
-rw-r--r--arm9/lib/src/GX_g3imm.c2
-rw-r--r--arm9/lib/src/GX_g3x.c38
-rw-r--r--arm9/lib/src/GX_load2d.c8
-rw-r--r--arm9/lib/src/GX_load3d.c16
-rw-r--r--arm9/lib/src/GX_vramcnt.c28
-rw-r--r--arm9/lib/src/MATH_crc.c14
-rw-r--r--arm9/lib/src/OS_alloc.c8
-rw-r--r--arm9/lib/src/OS_arena.c30
-rw-r--r--arm9/lib/src/OS_emulator.c6
-rw-r--r--arm9/lib/src/OS_init.c18
-rw-r--r--arm9/lib/src/OS_interrupt.c2
-rw-r--r--arm9/lib/src/OS_protectionUnit.c22
-rw-r--r--arm9/lib/src/OS_reset.c8
-rw-r--r--arm9/lib/src/OS_system.c14
-rw-r--r--arm9/lib/src/OS_tcm.c2
-rw-r--r--arm9/lib/src/OS_terminate_proc.c4
-rw-r--r--arm9/lib/src/custom_allocator.c4
35 files changed, 409 insertions, 396 deletions
diff --git a/arm9/lib/src/FS_archive.c b/arm9/lib/src/FS_archive.c
index 6c0f01f1..01f794f8 100644
--- a/arm9/lib/src/FS_archive.c
+++ b/arm9/lib/src/FS_archive.c
@@ -1,5 +1,4 @@
#include "FS_archive.h"
-#include "FS_file.h"
#include "FS_command.h"
#include "FSi_util.h"
#include "MI_memory.h"
@@ -45,6 +44,7 @@ ARM_FUNC FSResult FSi_WriteMemCallback(struct FSArchive * p_arc, const void * sr
ARM_FUNC FSResult FSi_ReadMemoryCore(FSArchive * p_arc, void * dest, u32 pos, u32 size)
{
+#pragma unused(p_arc)
MI_CpuCopy8((const void *)pos, dest, size);
return FS_RESULT_SUCCESS;
}
@@ -77,21 +77,21 @@ ARM_FUNC FSFile * FSi_NextCommand(FSArchive * p_arc)
const BOOL is_start = !FSi_IsArchiveRunning(p_arc);
if (is_start)
p_arc->flag |= FS_ARCHIVE_FLAG_RUNNING;
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
if (is_start)
{
if ((p_arc->proc_flag & FS_ARCHIVE_PROC_ACTIVATE) != 0)
- (*p_arc->proc) (p_file, FS_COMMAND_ACTIVATE);
+ (void)((*p_arc->proc) (p_file, FS_COMMAND_ACTIVATE));
}
bak_psr = OS_DisableInterrupts();
p_file->stat |= FS_FILE_STATUS_OPERATING;
if (FS_IsFileSyncMode(p_file))
{
OS_WakeupThread(p_file->queue);
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return NULL;
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return p_file;
}
}
@@ -103,7 +103,7 @@ ARM_FUNC FSFile * FSi_NextCommand(FSArchive * p_arc)
FSFile tmp;
FS_InitFile(&tmp);
tmp.arc = p_arc;
- (*p_arc->proc)(&tmp, FS_COMMAND_IDLE);
+ (void)((*p_arc->proc)(&tmp, FS_COMMAND_IDLE));
}
}
if (FSi_IsArchiveSuspending(p_arc))
@@ -112,7 +112,7 @@ ARM_FUNC FSFile * FSi_NextCommand(FSArchive * p_arc)
p_arc->flag |= FS_ARCHIVE_FLAG_SUSPEND;
OS_WakeupThread(&p_arc->stat_q);
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return NULL;
}
@@ -126,11 +126,11 @@ ARM_FUNC void FSi_ExecuteAsyncCommand(FSFile * p_file)
if (FS_IsFileSyncMode(p_file))
{
OS_WakeupThread(p_file->queue);
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
break;
}
p_file->stat |= FS_FILE_STATUS_ASYNC;
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
if (FSi_TranslateCommand(p_file, p_file->command) == FS_RESULT_PROC_ASYNC)
break;
p_file = FSi_NextCommand(p_arc);
@@ -160,7 +160,7 @@ ARM_FUNC BOOL FSi_SendCommand(FSFile * p_file, FSCommandType command)
if (FSi_IsArchiveUnloading(p_arc))
{
FSi_ReleaseCommand(p_file, FS_RESULT_CANCELLED);
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return FALSE;
}
if ((bit & FS_ARCHIVE_PROC_SYNC) != 0)
@@ -169,22 +169,22 @@ ARM_FUNC BOOL FSi_SendCommand(FSFile * p_file, FSCommandType command)
if (!FS_IsArchiveSuspended(p_arc) && !FSi_IsArchiveRunning(p_arc))
{
p_arc->flag |= FS_ARCHIVE_FLAG_RUNNING;
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
if ((p_arc->proc_flag & FS_ARCHIVE_PROC_ACTIVATE))
- (*p_arc->proc)(p_file, FS_COMMAND_ACTIVATE);
+ (void)((*p_arc->proc)(p_file, FS_COMMAND_ACTIVATE));
bak_psr = OS_DisableInterrupts();
p_file->stat |= FS_FILE_STATUS_OPERATING;
if (!FS_IsFileSyncMode(p_file))
{
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
FSi_ExecuteAsyncCommand(p_file);
return TRUE;
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
}
else if (!FS_IsFileSyncMode(p_file))
{
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return TRUE;
}
else
@@ -193,7 +193,7 @@ ARM_FUNC BOOL FSi_SendCommand(FSFile * p_file, FSCommandType command)
{
OS_SleepThread(p_file->queue);
} while (!(p_file->stat & FS_FILE_STATUS_OPERATING));
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
}
}
return FSi_ExecuteSyncCommand(p_file);
@@ -213,7 +213,7 @@ ARM_FUNC FSArchive * const FS_FindArchive(const char * name, int name_len)
FSArchive * p_arc = arc_list;
while (p_arc && (p_arc->name.pack != pack))
p_arc = p_arc->next;
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return p_arc;
}
@@ -243,7 +243,7 @@ ARM_FUNC BOOL FS_RegisterArchiveName(FSArchive * p_arc, const char * name, int n
p_arc->flag |= FS_ARCHIVE_FLAG_REGISTER;
ret = TRUE;
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return ret;
}
@@ -266,7 +266,7 @@ ARM_FUNC void FS_ReleaseArchiveName(FSArchive * p_arc)
current_dir_pos.index = 0;
current_dir_pos.own_id = 0;
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
}
}
@@ -305,7 +305,7 @@ ARM_FUNC BOOL FS_UnloadArchive(FSArchive * p_arc)
}
p_arc->list.next = NULL;
if (bak_state)
- FS_ResumeArchive(p_arc);
+ (void)FS_ResumeArchive(p_arc);
}
p_arc->base = 0;
p_arc->fat = 0;
@@ -315,7 +315,7 @@ ARM_FUNC BOOL FS_UnloadArchive(FSArchive * p_arc)
p_arc->fat_bak = p_arc->fnt_bak = 0;
p_arc->flag &= ~(FS_ARCHIVE_FLAG_CANCELING | FS_ARCHIVE_FLAG_LOADED | FS_ARCHIVE_FLAG_UNLOADING);
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return TRUE;
}
@@ -333,7 +333,7 @@ ARM_FUNC u32 FS_LoadArchiveTables(FSArchive *p_arc, void *p_mem, u32 max_size)
{
MI_CpuFill8(p_cache, 0x00, p_arc->fat_size);
}
- FS_CloseFile(&tmp);
+ (void)FS_CloseFile(&tmp);
}
p_arc->fat = (u32)p_cache;
p_cache += p_arc->fat_size;
@@ -343,7 +343,7 @@ ARM_FUNC u32 FS_LoadArchiveTables(FSArchive *p_arc, void *p_mem, u32 max_size)
{
MI_CpuFill8(p_cache, 0x00, p_arc->fnt_size);
}
- FS_CloseFile(&tmp);
+ (void)FS_CloseFile(&tmp);
}
p_arc->fnt = (u32)p_cache;
p_arc->load_mem = p_mem;
@@ -369,7 +369,7 @@ ARM_FUNC void * FS_UnloadArchiveTables(FSArchive * p_arc)
p_arc->table_func = p_arc->read_func;
}
if (bak_stat)
- FS_ResumeArchive(p_arc);
+ (void)FS_ResumeArchive(p_arc);
}
return ret;
}
@@ -392,7 +392,7 @@ ARM_FUNC BOOL FS_SuspendArchive(FSArchive * p_arc)
p_arc->flag |= FS_ARCHIVE_FLAG_SUSPEND;
}
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
return bak_stat;
}
@@ -406,7 +406,7 @@ ARM_FUNC BOOL FS_ResumeArchive(FSArchive * p_arc)
p_arc->flag &= ~FS_ARCHIVE_FLAG_SUSPEND;
p_target = FSi_NextCommand(p_arc);
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
if (p_target)
FSi_ExecuteAsyncCommand(p_target);
return bak_stat;
diff --git a/arm9/lib/src/FS_command.c b/arm9/lib/src/FS_command.c
index 818a65ea..7e0d41c9 100644
--- a/arm9/lib/src/FS_command.c
+++ b/arm9/lib/src/FS_command.c
@@ -10,7 +10,7 @@ ARM_FUNC void FSi_ReleaseCommand(FSFile * p_file, FSResult ret)
p_file->stat &= ~(FS_FILE_STATUS_CANCEL | FS_FILE_STATUS_BUSY | FS_FILE_STATUS_SYNC | FS_FILE_STATUS_ASYNC | FS_FILE_STATUS_OPERATING);
p_file->error = ret;
OS_WakeupThread(p_file->queue);
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
}
ARM_FUNC FSResult FSi_TranslateCommand(FSFile *p_file, FSCommandType command)
@@ -58,7 +58,7 @@ ARM_FUNC FSResult FSi_TranslateCommand(FSFile *p_file, FSCommandType command)
while (FSi_IsArchiveSync(p_arc))
OS_SleepThread(&p_arc->sync_q);
ret = p_file->error;
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
}
}
else if (!FS_IsFileSyncMode(p_file))
diff --git a/arm9/lib/src/FS_command_default.c b/arm9/lib/src/FS_command_default.c
index 002e1d53..582bf1b2 100644
--- a/arm9/lib/src/FS_command_default.c
+++ b/arm9/lib/src/FS_command_default.c
@@ -1,27 +1,10 @@
#include "nitro.h"
#include "FS_file.h"
#include "FS_command.h"
-#include "FS_archive.h"
#include "MI_byteAccess.h"
#include "MI_memory.h"
#include "FSi_util.h"
-
-typedef struct
-{
- FSArchive *arc;
- u32 pos;
-}
-FSiSyncReadParam;
-
-ARM_FUNC FSResult FSi_ReadFileCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_WriteFileCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_SeekDirCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_ReadDirCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_FindPathCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_GetPathCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_OpenFileFastCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_OpenFileDirectCommand(FSFile * p_file);
-ARM_FUNC FSResult FSi_CloseFileCommand(FSFile * p_file);
+#include "FS_command_default.h"
FSResult (*const fsi_default_command[])(FSFile *) = {
[FS_COMMAND_READFILE] = FSi_ReadFileCommand,
@@ -41,8 +24,8 @@ ARM_FUNC u32 FSi_StrNICmp(const char * str1, const char * str2, u32 len)
int i;
for (i = 0; i < len; i++)
{
- u32 c = MI_ReadByte(str1 + i) - 'A';
- u32 d = MI_ReadByte(str2 + i) - 'A';
+ u32 c = (u32)(MI_ReadByte(str1 + i) - 'A');
+ u32 d = (u32)(MI_ReadByte(str2 + i) - 'A');
if (c <= 'Z' - 'A')
c += 'a' - 'A';
if (d <= 'Z' - 'A')
@@ -69,7 +52,7 @@ ARM_FUNC FSResult FSi_ReadTable(FSiSyncReadParam * p, void * dst, u32 len)
OSIntrMode bak_psr = OS_DisableInterrupts();
while (FSi_IsArchiveSync(p_arc))
OS_SleepThread(&p_arc->sync_q);
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
ret = p_arc->list.next->error;
}
break;
@@ -216,7 +199,7 @@ ARM_FUNC FSResult FSi_FindPathCommand(FSFile *p_dir)
else if ((name_len == 2) & (MI_ReadByte(path + 1) == '.'))
{
if (p_dir->prop.dir.pos.own_id != 0)
- FSi_SeekDirDirect(p_dir, p_dir->prop.dir.parent);
+ (void)FSi_SeekDirDirect(p_dir, p_dir->prop.dir.parent);
path += 2;
continue;
}
@@ -300,7 +283,7 @@ ARM_FUNC FSResult FSi_GetPathCommand(FSFile *p_file)
dir_id = INVALID_ID;
do
{
- FSi_SeekDirDirect(&tmp, pos);
+ (void)FSi_SeekDirDirect(&tmp, pos);
if (!pos)
num_dir = tmp.prop.dir.parent;
tmp.arg.readdir.p_entry = &entry;
@@ -337,10 +320,10 @@ ARM_FUNC FSResult FSi_GetPathCommand(FSFile *p_file)
id = dir_id;
if (id != 0)
{
- FSi_SeekDirDirect(&tmp, id);
+ (void)FSi_SeekDirDirect(&tmp, id);
do
{
- FSi_SeekDirDirect(&tmp, tmp.prop.dir.parent);
+ (void)FSi_SeekDirDirect(&tmp, tmp.prop.dir.parent);
tmp.arg.readdir.p_entry = &entry;
tmp.arg.readdir.skip_string = TRUE;
while (FSi_TranslateCommand(&tmp, FS_COMMAND_READDIR) == FS_RESULT_SUCCESS)
@@ -378,7 +361,7 @@ ARM_FUNC FSResult FSi_GetPathCommand(FSFile *p_file)
MI_CpuCopy8(":/", dst + pos, 2);
pos += 2;
id = dir_id;
- FSi_SeekDirDirect(&tmp, id);
+ (void)FSi_SeekDirDirect(&tmp, id);
if (file_id != INVALID_ID)
{
tmp.arg.readdir.p_entry = &entry;
@@ -401,7 +384,7 @@ ARM_FUNC FSResult FSi_GetPathCommand(FSFile *p_file)
{
do
{
- FSi_SeekDirDirect(&tmp, tmp.prop.dir.parent);
+ (void)FSi_SeekDirDirect(&tmp, tmp.prop.dir.parent);
tmp.arg.readdir.p_entry = &entry;
tmp.arg.readdir.skip_string = FALSE;
MI_WriteByte(dst + total - 1, '/');
@@ -464,5 +447,6 @@ ARM_FUNC FSResult FSi_OpenFileDirectCommand(FSFile * p_file)
ARM_FUNC FSResult FSi_CloseFileCommand(FSFile * p_file)
{
+#pragma unused (p_file)
return FS_RESULT_SUCCESS;
}
diff --git a/arm9/lib/src/FS_file.c b/arm9/lib/src/FS_file.c
index 8bca5c8e..c1a6c54d 100644
--- a/arm9/lib/src/FS_file.c
+++ b/arm9/lib/src/FS_file.c
@@ -90,23 +90,23 @@ static BOOL FSi_FindPath(FSFile * p_dir, const char * path, FSFileID * p_file_id
ARM_FUNC int FSi_ReadFileCore(FSFile * p_file, void * dst, s32 len, BOOL async)
{
- const s32 pos = p_file->prop.file.pos;
- const s32 rest = p_file->prop.file.bottom - pos;
- const u32 org = len;
+ const s32 pos = (s32)p_file->prop.file.pos;
+ const s32 rest = (s32)(p_file->prop.file.bottom - pos);
+ const u32 org = (u32)len;
if (len > rest)
len = rest;
if (len < 0)
len = 0;
p_file->arg.readfile.dst = dst;
p_file->arg.readfile.len_org = org;
- p_file->arg.readfile.len = len;
+ p_file->arg.readfile.len = (u32)len;
if (!async)
p_file->stat |= FS_FILE_STATUS_SYNC;
- FSi_SendCommand(p_file, FS_COMMAND_READFILE);
+ (void)FSi_SendCommand(p_file, FS_COMMAND_READFILE);
if (!async)
{
if (FS_WaitAsync(p_file))
- len = p_file->prop.file.pos - pos;
+ len = (s32)(p_file->prop.file.pos - pos);
else
len = -1;
}
@@ -206,7 +206,7 @@ ARM_FUNC int FS_ReadFile(FSFile * p_file, void * dst, s32 len)
return FSi_ReadFileCore(p_file, dst, len, FALSE);
}
-ARM_FUNC BOOL FS_SeekFile(FSFile * p_file, int offset, FSSeekFileMode origin)
+ARM_FUNC BOOL FS_SeekFile(FSFile * p_file, s32 offset, FSSeekFileMode origin)
{
switch (origin)
{
@@ -226,7 +226,7 @@ ARM_FUNC BOOL FS_SeekFile(FSFile * p_file, int offset, FSSeekFileMode origin)
offset = (s32)p_file->prop.file.top;
if (offset > (s32)p_file->prop.file.bottom)
offset = (s32)p_file->prop.file.bottom;
- p_file->prop.file.pos = offset;
+ p_file->prop.file.pos = (u32)offset;
return TRUE;
}
diff --git a/arm9/lib/src/FS_overlay.c b/arm9/lib/src/FS_overlay.c
index 79a3b43e..de64d97d 100644
--- a/arm9/lib/src/FS_overlay.c
+++ b/arm9/lib/src/FS_overlay.c
@@ -67,16 +67,16 @@ ARM_FUNC BOOL FSi_LoadOverlayInfoCore(FSOverlayInfo * p_ovi, MIProcessor target,
return FALSE;
if (FS_ReadFile(file, p_ovi, sizeof(FSOverlayInfoHeader)) != sizeof(FSOverlayInfoHeader))
{
- FS_CloseFile(file);
+ (void)FS_CloseFile(file);
return FALSE;
}
- FS_CloseFile(file);
+ (void)FS_CloseFile(file);
p_ovi->target = target;
if (!FS_OpenFileFast(file, FS_GetOverlayFileID(p_ovi)))
return FALSE;
p_ovi->file_pos.offset = FS_GetFileImageTop(file);
p_ovi->file_pos.length = FS_GetLength(file);
- FS_CloseFile(file);
+ (void)FS_CloseFile(file);
return TRUE;
}
@@ -96,7 +96,7 @@ ARM_FUNC BOOL FS_LoadOverlayInfo(FSOverlayInfo * p_ovi, MIProcessor target, FSOv
return FALSE;
p_ovi->file_pos.offset = FS_GetFileImageTop(file);
p_ovi->file_pos.length = FS_GetLength(file);
- FS_CloseFile(file);
+ (void)FS_CloseFile(file);
return TRUE;
}
else
@@ -114,11 +114,11 @@ ARM_FUNC BOOL FS_LoadOverlayImageAsync(FSOverlayInfo * p_ovi, FSFile * p_file)
return FALSE;
else
{
- s32 size = FSi_GetOverlayBinarySize(p_ovi);
+ s32 size = (s32)FSi_GetOverlayBinarySize(p_ovi);
FS_ClearOverlayImage(p_ovi);
if (FS_ReadFileAsync(p_file, FS_GetOverlayAddress(p_ovi), size) != size)
{
- FS_CloseFile(p_file);
+ (void)FS_CloseFile(p_file);
return FALSE;
}
return TRUE;
@@ -133,14 +133,14 @@ ARM_FUNC BOOL FS_LoadOverlayImage(FSOverlayInfo * p_ovi)
return FALSE;
else
{
- s32 size = FSi_GetOverlayBinarySize(p_ovi);
+ s32 size = (s32)FSi_GetOverlayBinarySize(p_ovi);
FS_ClearOverlayImage(p_ovi);
if (FS_ReadFile(file, FS_GetOverlayAddress(p_ovi), size) != size)
{
- FS_CloseFile(file);
+ (void)FS_CloseFile(file);
return FALSE;
}
- FS_CloseFile(file);
+ (void)FS_CloseFile(file);
return TRUE;
}
}
@@ -168,9 +168,9 @@ static const u8 fsi_def_digest_key[64] = {
};
static const void *fsi_digest_key_ptr = fsi_def_digest_key;
-static int fsi_digest_key_len = sizeof(fsi_def_digest_key);
+static u32 fsi_digest_key_len = sizeof(fsi_def_digest_key);
-ARM_FUNC BOOL FSi_CompareDigest(const u8 *spec_digest, void *src, int len)
+ARM_FUNC BOOL FSi_CompareDigest(const u8 *spec_digest, void *src, u32 len)
{
int i;
u8 digest[FS_OVERLAY_DIGEST_SIZE];
@@ -203,7 +203,7 @@ ARM_FUNC void FS_StartOverlay(FSOverlayInfo * p_ovi)
if (p_ovi->header.id < odt_max)
{
const u8 * spec_digest = SDK_OVERLAY_DIGEST + FS_OVERLAY_DIGEST_SIZE * p_ovi->header.id;
- ret = FSi_CompareDigest(spec_digest, p_ovi->header.ram_address, (int)rare_size);
+ ret = FSi_CompareDigest(spec_digest, p_ovi->header.ram_address, rare_size);
}
}
if (!ret)
@@ -276,7 +276,7 @@ ARM_FUNC void FS_EndOverlay(FSOverlayInfo *p_ovi)
}
p = next;
}
- OS_RestoreInterrupts(bak_psr);
+ (void)OS_RestoreInterrupts(bak_psr);
}
if (!head)
diff --git a/arm9/lib/src/FS_rom.c b/arm9/lib/src/FS_rom.c
index 4160e3b1..09098dfe 100644
--- a/arm9/lib/src/FS_rom.c
+++ b/arm9/lib/src/FS_rom.c
@@ -26,18 +26,20 @@ ARM_FUNC FSResult FSi_ReadRomCallback(FSArchive * p_arc, void * dst, u32 src, u3
ARM_FUNC FSResult FSi_WriteDummyCallback(FSArchive * p_arc, const void *src, u32 dst, u32 len)
{
+#pragma unused(p_arc, src, dst, len)
return FS_RESULT_FAILURE;
}
ARM_FUNC FSResult FSi_RomArchiveProc(FSFile * p_arc, FSCommandType cmd)
{
+#pragma unused(p_arc)
switch (cmd)
{
case FS_COMMAND_ACTIVATE:
- CARD_LockRom(fsi_card_lock_id);
+ CARD_LockRom((u16)fsi_card_lock_id);
return FS_RESULT_SUCCESS;
case FS_COMMAND_IDLE:
- CARD_UnlockRom(fsi_card_lock_id);
+ CARD_UnlockRom((u16)fsi_card_lock_id);
return FS_RESULT_SUCCESS;
case FS_COMMAND_WRITEFILE:
return FS_RESULT_UNSUPPORTED;
@@ -48,11 +50,13 @@ ARM_FUNC FSResult FSi_RomArchiveProc(FSFile * p_arc, FSCommandType cmd)
ARM_FUNC FSResult FSi_ReadDummyCallback(FSArchive *p_arc, void *dst, u32 src, u32 len)
{
+#pragma unused (p_arc, dst, src, len)
return FS_RESULT_FAILURE;
}
ARM_FUNC FSResult FSi_EmptyArchiveProc(FSFile *p_file, FSCommandType cmd)
{
+#pragma unused(p_file, cmd)
return FS_RESULT_UNSUPPORTED;
}
@@ -68,7 +72,7 @@ ARM_FUNC void FSi_InitRom(u32 default_dma_no)
CARD_Init();
FS_InitArchive(&fsi_arc_rom);
- FS_RegisterArchiveName(&fsi_arc_rom, "rom", 3);
+ (void)FS_RegisterArchiveName(&fsi_arc_rom, "rom", 3);
if (MB_IsMultiBootChild())
{
@@ -77,7 +81,7 @@ ARM_FUNC void FSi_InitRom(u32 default_dma_no)
fsi_ovt7.offset = (u32)~0;
fsi_ovt7.length = 0;
FS_SetArchiveProc(&fsi_arc_rom, FSi_EmptyArchiveProc, (u32)FS_ARCHIVE_PROC_ALL);
- FS_LoadArchive(&fsi_arc_rom, 0x00000000, 0, 0, 0, 0, FSi_ReadDummyCallback, FSi_WriteDummyCallback);
+ (void)FS_LoadArchive(&fsi_arc_rom, 0x00000000, 0, 0, 0, 0, FSi_ReadDummyCallback, FSi_WriteDummyCallback);
}
else
{
@@ -95,7 +99,7 @@ ARM_FUNC void FSi_InitRom(u32 default_dma_no)
}
else
{
- FS_LoadArchive(&fsi_arc_rom, 0x00000000,
+ (void)FS_LoadArchive(&fsi_arc_rom, 0x00000000,
fat->offset, fat->length,
fnt->offset, fnt->length,
FSi_ReadRomCallback, FSi_WriteDummyCallback);
@@ -110,8 +114,8 @@ ARM_FUNC u32 FS_SetDefaultDMA(u32 dma_no)
BOOL bak_stat = FS_SuspendArchive(&fsi_arc_rom);
fsi_default_dma_no = dma_no;
if (bak_stat)
- FS_ResumeArchive(&fsi_arc_rom);
- OS_RestoreInterrupts(bak_psr);
+ (void)FS_ResumeArchive(&fsi_arc_rom);
+ (void)OS_RestoreInterrupts(bak_psr);
return bak_dma_no;
}
diff --git a/arm9/lib/src/FX_atan.c b/arm9/lib/src/FX_atan.c
index 9a936fa0..fa2d0dbe 100644
--- a/arm9/lib/src/FX_atan.c
+++ b/arm9/lib/src/FX_atan.c
@@ -141,11 +141,11 @@ ARM_FUNC u16 FX_Atan(fx32 x){
{
x = FX_Inv(x);
fx16 y = FX_AtanTable_[x >> 5];
- return 0x4000 - y;
+ return (u16)(0x4000 - y);
}
else if (x < 0x1000)
{
- return FX_AtanTable_[x >> 5];
+ return (u16)FX_AtanTable_[x >> 5];
}
else
{
@@ -158,21 +158,20 @@ ARM_FUNC u16 FX_Atan(fx32 x){
{
x = FX_Inv(-x);
fx16 y = FX_AtanTable_[x >> 5];
- return y - 0x4000;
+ return (u16)(y - 0x4000);
}
else if (x > -0x1000)
{
- return -FX_AtanTable_[-x >> 5];
+ return (u16)(-FX_AtanTable_[-x >> 5]);
}
else
{
- return -0x2000;
+ return (u16)(-0x2000);
}
}
}
ARM_FUNC u16 FX_Atan2(fx32 x, fx32 y){
- fx32 result;
u32 positive, bias, denominator, numerator;
if (x > 0)
{
@@ -180,15 +179,15 @@ ARM_FUNC u16 FX_Atan2(fx32 x, fx32 y){
{
if (y > x)
{
- numerator = x;
- denominator = y;
+ numerator = (u32)x;
+ denominator = (u32)y;
bias = 0;
positive = TRUE;
}
else if (y < x)
{
- numerator = y;
- denominator = x;
+ numerator = (u32)y;
+ denominator = (u32)x;
bias = 0x4000;
positive = FALSE;
}
@@ -202,15 +201,15 @@ ARM_FUNC u16 FX_Atan2(fx32 x, fx32 y){
y = -y;
if (y < x)
{
- numerator = y;
- denominator = x;
+ numerator = (u32)y;
+ denominator = (u32)x;
bias = 0x4000;
positive = TRUE;
}
else if (y > x)
{
- numerator = x;
- denominator = y;
+ numerator = (u32)x;
+ denominator = (u32)y;
bias = 0x8000;
positive = FALSE;
}
@@ -232,16 +231,16 @@ ARM_FUNC u16 FX_Atan2(fx32 x, fx32 y){
y = -y;
if (y > x)
{
- numerator = x;
- denominator = y;
- bias = -0x8000;
+ numerator = (u32)x;
+ denominator = (u32)y;
+ bias = (u32)(-0x8000);
positive = TRUE;
}
else if (y < x)
{
- numerator = y;
- denominator = x;
- bias = -0x4000;
+ numerator = (u32)y;
+ denominator = (u32)x;
+ bias = (u32)(-0x4000);
positive = FALSE;
}
else
@@ -253,15 +252,15 @@ ARM_FUNC u16 FX_Atan2(fx32 x, fx32 y){
{
if (y < x)
{
- numerator = y;
- denominator = x;
- bias = -0x4000;
+ numerator = (u32)y;
+ denominator = (u32)x;
+ bias = (u32)(-0x4000);
positive = TRUE;
}
else if (y > x)
{
- numerator = x;
- denominator = y;
+ numerator = (u32)x;
+ denominator = (u32)y;
bias = 0x0;
positive = FALSE;
}
@@ -285,7 +284,7 @@ ARM_FUNC u16 FX_Atan2(fx32 x, fx32 y){
if (denominator == 0x0)
return 0x0;
if (positive)
- return bias + FX_AtanTable_[FX_Div(numerator, denominator) >> 5];
+ return (u16)(bias + FX_AtanTable_[FX_Div((fx32)numerator, (fx32)denominator) >> 5]);
else
- return bias - FX_AtanTable_[FX_Div(numerator, denominator) >> 5];
+ return (u16)(bias - FX_AtanTable_[FX_Div((fx32)numerator, (fx32)denominator) >> 5]);
}
diff --git a/arm9/lib/src/FX_cp.c b/arm9/lib/src/FX_cp.c
index 3b6e6c96..83967ff3 100644
--- a/arm9/lib/src/FX_cp.c
+++ b/arm9/lib/src/FX_cp.c
@@ -17,7 +17,7 @@ ARM_FUNC fx32 FX_Sqrt(fx32 x){
if (x > 0)
{
reg_CP_SQRTCNT = 0x1;
- reg_CP_SQRT_PARAM = (fx64)x << 32;
+ reg_CP_SQRT_PARAM = (u64)((fx64)x << 32);
return FX_GetSqrtResult();
}
else
@@ -27,13 +27,13 @@ ARM_FUNC fx32 FX_Sqrt(fx32 x){
}
ARM_FUNC fx64c FX_GetDivResultFx64c(){
- while (reg_CP_DIVCNT & 0x8000);
- return reg_CP_DIV_RESULT;
+ while (reg_CP_DIVCNT & 0x8000) {}
+ return (fx64c)reg_CP_DIV_RESULT;
}
ARM_FUNC fx32 FX_GetDivResult(){
- while (reg_CP_DIVCNT & 0x8000);
- return (reg_CP_DIV_RESULT + (1 << (0x14 - 1))) >> 0x14;
+ while (reg_CP_DIVCNT & 0x8000) {}
+ return (fx32)((reg_CP_DIV_RESULT + (1 << (0x14 - 1))) >> 0x14);
}
ARM_FUNC void FX_InvAsync(fx32 x){
@@ -43,13 +43,13 @@ ARM_FUNC void FX_InvAsync(fx32 x){
}
ARM_FUNC fx32 FX_GetSqrtResult(){
- while (reg_CP_SQRTCNT & 0x8000);
- return (reg_CP_SQRT_RESULT + (1 << (0xA - 1))) >> 0xA;
+ while (reg_CP_SQRTCNT & 0x8000) {}
+ return (fx32)((reg_CP_SQRT_RESULT + (1 << (0xA - 1))) >> 0xA);
}
ARM_FUNC void FX_DivAsync(fx32 numerator, fx32 denominator){
reg_CP_DIVCNT = 0x1;
- reg_CP_DIV_NUMER = (fx64)numerator << 32;
+ reg_CP_DIV_NUMER = (u64)((fx64)numerator << 32);
reg_CP_DIV_DENOM = (u32)denominator;
}
@@ -57,14 +57,14 @@ ARM_FUNC fx32 FX_DivS32(fx32 numerator, fx32 denominator){
reg_CP_DIVCNT = 0x0;
*(REGType32v *)&reg_CP_DIV_NUMER = (u32)numerator; //32bit write for some reason
reg_CP_DIV_DENOM = (u32)denominator;
- while (reg_CP_DIVCNT & 0x8000);
- return *(REGType32v *)&reg_CP_DIV_RESULT;
+ while (reg_CP_DIVCNT & 0x8000) {}
+ return (fx32)(*(REGType32v *)&reg_CP_DIV_RESULT);
}
ARM_FUNC fx32 FX_ModS32(fx32 num, fx32 mod){
reg_CP_DIVCNT = 0x0;
*(REGType32v *)&reg_CP_DIV_NUMER = (u32)num; //32bit write for some reason
reg_CP_DIV_DENOM = (u32)mod;
- while (reg_CP_DIVCNT & 0x8000);
- return *(REGType32v *)&reg_CP_DIVREM_RESULT;
+ while (reg_CP_DIVCNT & 0x8000) {}
+ return (fx32)(*(REGType32v *)&reg_CP_DIVREM_RESULT);
}
diff --git a/arm9/lib/src/FX_mtx22.c b/arm9/lib/src/FX_mtx22.c
index 38387c64..a74bb25c 100644
--- a/arm9/lib/src/FX_mtx22.c
+++ b/arm9/lib/src/FX_mtx22.c
@@ -3,10 +3,10 @@
#include "fx.h"
ARM_FUNC void MTX_ScaleApply22(struct Mtx22 *mtx, struct Mtx22 *dst, fx32 x, fx32 y){
- dst->_[0] = ((fx64)x * mtx->_[0]) >> FX32_INT_SHIFT;
- dst->_[1] = ((fx64)x * mtx->_[1]) >> FX32_INT_SHIFT;
- dst->_[2] = ((fx64)y * mtx->_[2]) >> FX32_INT_SHIFT;
- dst->_[3] = ((fx64)y * mtx->_[3]) >> FX32_INT_SHIFT;
+ dst->_[0] = (fx32)(((fx64)x * mtx->_[0]) >> FX32_INT_SHIFT);
+ dst->_[1] = (fx32)(((fx64)x * mtx->_[1]) >> FX32_INT_SHIFT);
+ dst->_[2] = (fx32)(((fx64)y * mtx->_[2]) >> FX32_INT_SHIFT);
+ dst->_[3] = (fx32)(((fx64)y * mtx->_[3]) >> FX32_INT_SHIFT);
}
ARM_FUNC asm void MTX_Identity22_(struct Mtx22 *mtx){
diff --git a/arm9/lib/src/FX_mtx33.c b/arm9/lib/src/FX_mtx33.c
index 90beddba..86169ea0 100644
--- a/arm9/lib/src/FX_mtx33.c
+++ b/arm9/lib/src/FX_mtx33.c
@@ -3,15 +3,15 @@
#include "fx.h"
ARM_FUNC void MTX_ScaleApply33(struct Mtx33 *mtx, struct Mtx33 *dst, fx32 x, fx32 y, fx32 z){
- dst->_[0] = ((fx64)x * mtx->_[0]) >> FX32_INT_SHIFT;
- dst->_[1] = ((fx64)x * mtx->_[1]) >> FX32_INT_SHIFT;
- dst->_[2] = ((fx64)x * mtx->_[2]) >> FX32_INT_SHIFT;
- dst->_[3] = ((fx64)y * mtx->_[3]) >> FX32_INT_SHIFT;
- dst->_[4] = ((fx64)y * mtx->_[4]) >> FX32_INT_SHIFT;
- dst->_[5] = ((fx64)y * mtx->_[5]) >> FX32_INT_SHIFT;
- dst->_[6] = ((fx64)z * mtx->_[6]) >> FX32_INT_SHIFT;
- dst->_[7] = ((fx64)z * mtx->_[7]) >> FX32_INT_SHIFT;
- dst->_[8] = ((fx64)z * mtx->_[8]) >> FX32_INT_SHIFT;
+ dst->_[0] = (fx32)(((fx64)x * mtx->_[0]) >> FX32_INT_SHIFT);
+ dst->_[1] = (fx32)(((fx64)x * mtx->_[1]) >> FX32_INT_SHIFT);
+ dst->_[2] = (fx32)(((fx64)x * mtx->_[2]) >> FX32_INT_SHIFT);
+ dst->_[3] = (fx32)(((fx64)y * mtx->_[3]) >> FX32_INT_SHIFT);
+ dst->_[4] = (fx32)(((fx64)y * mtx->_[4]) >> FX32_INT_SHIFT);
+ dst->_[5] = (fx32)(((fx64)y * mtx->_[5]) >> FX32_INT_SHIFT);
+ dst->_[6] = (fx32)(((fx64)z * mtx->_[6]) >> FX32_INT_SHIFT);
+ dst->_[7] = (fx32)(((fx64)z * mtx->_[7]) >> FX32_INT_SHIFT);
+ dst->_[8] = (fx32)(((fx64)z * mtx->_[8]) >> FX32_INT_SHIFT);
}
ARM_FUNC void MTX_Concat33(struct Mtx33 *a, struct Mtx33 *b, struct Mtx33 *c){
@@ -28,30 +28,30 @@ ARM_FUNC void MTX_Concat33(struct Mtx33 *a, struct Mtx33 *b, struct Mtx33 *c){
a0 = a->_[0];
a1 = a->_[1];
a2 = a->_[2];
- dst->_[0] = (((fx64)a0 * b->_[0] + (fx64)a1 * b->_[3] + (fx64)a2 * b->_[6] ) >> FX32_INT_SHIFT);
- dst->_[1] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
+ dst->_[0] = (fx32)(((fx64)a0 * b->_[0] + (fx64)a1 * b->_[3] + (fx64)a2 * b->_[6] ) >> FX32_INT_SHIFT);
+ dst->_[1] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
b0 = b->_[2];
b1 = b->_[5];
b2 = b->_[8];
- dst->_[2] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[2] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
a0 = a->_[3];
a1 = a->_[4];
a2 = a->_[5];
- dst->_[5] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
- dst->_[4] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
+ dst->_[5] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[4] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
b0 = b->_[0];
b1 = b->_[3];
b2 = b->_[6];
- dst->_[3] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[3] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
a0 = a->_[6];
a1 = a->_[7];
a2 = a->_[8];
- dst->_[6] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
- dst->_[7] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
+ dst->_[6] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[7] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
b0 = b->_[2];
b1 = b->_[5];
b2 = b->_[8];
- dst->_[8] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[8] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
if (dst == &temp)
*c = temp;
@@ -62,9 +62,9 @@ ARM_FUNC void MTX_MultVec33(struct Vecx32 *vec, struct Mtx33 *mtx, struct Vecx32
x = vec->x;
y = vec->y;
z = vec->z;
- dst->x = ((fx64)x * mtx->_[0] + (fx64)y * mtx->_[3] + (fx64)z * mtx->_[6]) >> FX32_INT_SHIFT;
- dst->y = ((fx64)x * mtx->_[1] + (fx64)y * mtx->_[4] + (fx64)z * mtx->_[7]) >> FX32_INT_SHIFT;
- dst->z = ((fx64)x * mtx->_[2] + (fx64)y * mtx->_[5] + (fx64)z * mtx->_[8]) >> FX32_INT_SHIFT;
+ dst->x = (fx32)(((fx64)x * mtx->_[0] + (fx64)y * mtx->_[3] + (fx64)z * mtx->_[6]) >> FX32_INT_SHIFT);
+ dst->y = (fx32)(((fx64)x * mtx->_[1] + (fx64)y * mtx->_[4] + (fx64)z * mtx->_[7]) >> FX32_INT_SHIFT);
+ dst->z = (fx32)(((fx64)x * mtx->_[2] + (fx64)y * mtx->_[5] + (fx64)z * mtx->_[8]) >> FX32_INT_SHIFT);
}
ARM_FUNC asm void MTX_Identity33_(struct Mtx33 *mtx){
diff --git a/arm9/lib/src/FX_mtx43.c b/arm9/lib/src/FX_mtx43.c
index 96ab4062..693dddff 100644
--- a/arm9/lib/src/FX_mtx43.c
+++ b/arm9/lib/src/FX_mtx43.c
@@ -2,6 +2,8 @@
#include "main.h"
#include "fx.h"
+void MI_Copy48B(void *src, void *dst);
+
ARM_FUNC void MTX_ScaleApply43(struct Mtx43 *mtx, struct Mtx43 *dst, fx32 x, fx32 y, fx32 z){
//this works because matrices are indexed columns first
@@ -21,21 +23,21 @@ ARM_FUNC fx32 MTX_Inverse43(struct Mtx43 *mtx, struct Mtx43 *inv){
else
dst = inv;
//subdeterminants
- det0 = ((fx64)mtx->_[4] * mtx->_[8] - (fx64)mtx->_[5] * mtx->_[7] + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT;
- det1 = ((fx64)mtx->_[3] * mtx->_[8] - (fx64)mtx->_[5] * mtx->_[6] + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT;
- det2 = ((fx64)mtx->_[3] * mtx->_[7] - (fx64)mtx->_[4] * mtx->_[6] + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT;
+ det0 = (fx32)(((fx64)mtx->_[4] * mtx->_[8] - (fx64)mtx->_[5] * mtx->_[7] + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT);
+ det1 = (fx32)(((fx64)mtx->_[3] * mtx->_[8] - (fx64)mtx->_[5] * mtx->_[6] + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT);
+ det2 = (fx32)(((fx64)mtx->_[3] * mtx->_[7] - (fx64)mtx->_[4] * mtx->_[6] + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT);
//matrix determinant
- det = ((fx64)mtx->_[0] * det0 - (fx64)mtx->_[1] * det1 + (fx64)mtx->_[2] * det2 + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT;
+ det = (fx32)(((fx64)mtx->_[0] * det0 - (fx64)mtx->_[1] * det1 + (fx64)mtx->_[2] * det2 + (fx64)(1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT);
if (det == 0)
return -1; //not invertible
FX_InvAsync(det);
- var0 = ((fx64)mtx->_[1] * mtx->_[8] - (fx64)mtx->_[7] * mtx->_[2]) >> FX32_INT_SHIFT;
- var1 = ((fx64)mtx->_[1] * mtx->_[5] - (fx64)mtx->_[4] * mtx->_[2]) >> FX32_INT_SHIFT;
- var2 = ((fx64)mtx->_[0] * mtx->_[8] - (fx64)mtx->_[6] * mtx->_[2]) >> FX32_INT_SHIFT;
- var3 = ((fx64)mtx->_[0] * mtx->_[5] - (fx64)mtx->_[3] * mtx->_[2]) >> FX32_INT_SHIFT;
+ var0 = (fx32)(((fx64)mtx->_[1] * mtx->_[8] - (fx64)mtx->_[7] * mtx->_[2]) >> FX32_INT_SHIFT);
+ var1 = (fx32)(((fx64)mtx->_[1] * mtx->_[5] - (fx64)mtx->_[4] * mtx->_[2]) >> FX32_INT_SHIFT);
+ var2 = (fx32)(((fx64)mtx->_[0] * mtx->_[8] - (fx64)mtx->_[6] * mtx->_[2]) >> FX32_INT_SHIFT);
+ var3 = (fx32)(((fx64)mtx->_[0] * mtx->_[5] - (fx64)mtx->_[3] * mtx->_[2]) >> FX32_INT_SHIFT);
fx32 ret = FX_GetDivResult();
dst->_[0] = (fx32)(((fx64)ret * det0) >> FX32_INT_SHIFT);
@@ -73,36 +75,36 @@ ARM_FUNC void MTX_Concat43(struct Mtx43 *a, struct Mtx43 *b, struct Mtx43 *c){
a0 = a->_[0];
a1 = a->_[1];
a2 = a->_[2];
- dst->_[0] = (((fx64)a0 * b->_[0] + (fx64)a1 * b->_[3] + (fx64)a2 * b->_[6] ) >> FX32_INT_SHIFT);
- dst->_[1] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
+ dst->_[0] = (fx32)(((fx64)a0 * b->_[0] + (fx64)a1 * b->_[3] + (fx64)a2 * b->_[6] ) >> FX32_INT_SHIFT);
+ dst->_[1] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
b0 = b->_[2];
b1 = b->_[5];
b2 = b->_[8];
- dst->_[2] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[2] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
a0 = a->_[3];
a1 = a->_[4];
a2 = a->_[5];
- dst->_[5] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
- dst->_[4] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
+ dst->_[5] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[4] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
b0 = b->_[0];
b1 = b->_[3];
b2 = b->_[6];
- dst->_[3] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[3] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
a0 = a->_[6];
a1 = a->_[7];
a2 = a->_[8];
- dst->_[6] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
- dst->_[7] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
+ dst->_[6] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[7] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7] ) >> FX32_INT_SHIFT);
b0 = b->_[2];
b1 = b->_[5];
b2 = b->_[8];
- dst->_[8] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
+ dst->_[8] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT);
a0 = a->_[9];
a1 = a->_[10];
a2 = a->_[11];
- dst->_[11] = ((((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT) + b->_[11]);
- dst->_[10] = ((((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7]) >> FX32_INT_SHIFT) + b->_[10]);
- dst->_[9] = ((((fx64)a0 * b->_[0] + (fx64)a1 * b->_[3] + (fx64)a2 * b->_[6]) >> FX32_INT_SHIFT) + b->_[9]);
+ dst->_[11] = (fx32)((((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2) >> FX32_INT_SHIFT) + b->_[11]);
+ dst->_[10] = (fx32)((((fx64)a0 * b->_[1] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[7]) >> FX32_INT_SHIFT) + b->_[10]);
+ dst->_[9] = (fx32)((((fx64)a0 * b->_[0] + (fx64)a1 * b->_[3] + (fx64)a2 * b->_[6]) >> FX32_INT_SHIFT) + b->_[9]);
if (dst == &temp)
*c = temp;
}
@@ -112,11 +114,11 @@ ARM_FUNC void MTX_MultVec43(struct Vecx32 *vec, struct Mtx43 *mtx, struct Vecx32
x = vec->x;
y = vec->y;
z = vec->z;
- dst->x = ((fx64)x * mtx->_[0] + (fx64)y * mtx->_[3] + (fx64)z * mtx->_[6]) >> FX32_INT_SHIFT;
+ dst->x = (fx32)(((fx64)x * mtx->_[0] + (fx64)y * mtx->_[3] + (fx64)z * mtx->_[6]) >> FX32_INT_SHIFT);
dst->x += mtx->_[9];
- dst->y = ((fx64)x * mtx->_[1] + (fx64)y * mtx->_[4] + (fx64)z * mtx->_[7]) >> FX32_INT_SHIFT;
+ dst->y = (fx32)(((fx64)x * mtx->_[1] + (fx64)y * mtx->_[4] + (fx64)z * mtx->_[7]) >> FX32_INT_SHIFT);
dst->y += mtx->_[10];
- dst->z = ((fx64)x * mtx->_[2] + (fx64)y * mtx->_[5] + (fx64)z * mtx->_[8]) >> FX32_INT_SHIFT;
+ dst->z = (fx32)(((fx64)x * mtx->_[2] + (fx64)y * mtx->_[5] + (fx64)z * mtx->_[8]) >> FX32_INT_SHIFT);
dst->z += mtx->_[11];
}
diff --git a/arm9/lib/src/FX_mtx44.c b/arm9/lib/src/FX_mtx44.c
index 8152907d..697f8709 100644
--- a/arm9/lib/src/FX_mtx44.c
+++ b/arm9/lib/src/FX_mtx44.c
@@ -29,46 +29,46 @@ ARM_FUNC void MTX_Concat44(struct Mtx44 *a, struct Mtx44 *b, struct Mtx44 *c){
a1 = a->_[1];
a2 = a->_[2];
a3 = a->_[3];
- dst->_[0] = (((fx64)a0 * b->_[0] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[8] + (fx64)a3 * b->_[12]) >> FX32_INT_SHIFT);
- dst->_[1] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
- dst->_[3] = (((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
+ dst->_[0] = (fx32)(((fx64)a0 * b->_[0] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[8] + (fx64)a3 * b->_[12]) >> FX32_INT_SHIFT);
+ dst->_[1] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
+ dst->_[3] = (fx32)(((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
b0 = b->_[2];
b1 = b->_[6];
b2 = b->_[10];
b3 = b->_[14];
- dst->_[2] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
+ dst->_[2] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
a0 = a->_[4];
a1 = a->_[5];
a2 = a->_[6];
a3 = a->_[7];
- dst->_[6] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
- dst->_[5] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
- dst->_[7] = (((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
+ dst->_[6] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
+ dst->_[5] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
+ dst->_[7] = (fx32)(((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
b0 = b->_[0];
b1 = b->_[4];
b2 = b->_[8];
b3 = b->_[12];
- dst->_[4] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
+ dst->_[4] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
a0 = a->_[8];
a1 = a->_[9];
a2 = a->_[10];
a3 = a->_[11];
- dst->_[8] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
- dst->_[9] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
- dst->_[11] = (((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
+ dst->_[8] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
+ dst->_[9] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
+ dst->_[11] = (fx32)(((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
b0 = b->_[2];
b1 = b->_[6];
b2 = b->_[10];
b3 = b->_[14];
- dst->_[10] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
+ dst->_[10] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
a0 = a->_[12];
a1 = a->_[13];
a2 = a->_[14];
a3 = a->_[15];
- dst->_[14] = (((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
- dst->_[13] = (((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
- dst->_[12] = (((fx64)a0 * b->_[0] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[8] + (fx64)a3 * b->_[12]) >> FX32_INT_SHIFT);
- dst->_[15] = (((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
+ dst->_[14] = (fx32)(((fx64)a0 * b0 + (fx64)a1 * b1 + (fx64)a2 * b2 + (fx64)a3 * b3) >> FX32_INT_SHIFT);
+ dst->_[13] = (fx32)(((fx64)a0 * b->_[1] + (fx64)a1 * b->_[5] + (fx64)a2 * b->_[9] + (fx64)a3 * b->_[13]) >> FX32_INT_SHIFT);
+ dst->_[12] = (fx32)(((fx64)a0 * b->_[0] + (fx64)a1 * b->_[4] + (fx64)a2 * b->_[8] + (fx64)a3 * b->_[12]) >> FX32_INT_SHIFT);
+ dst->_[15] = (fx32)(((fx64)a0 * b->_[3] + (fx64)a1 * b->_[7] + (fx64)a2 * b->_[11] + (fx64)a3 * b->_[15]) >> FX32_INT_SHIFT);
if (dst == &temp)
*c = temp;
}
diff --git a/arm9/lib/src/FX_vec.c b/arm9/lib/src/FX_vec.c
index 95805f33..891b980a 100644
--- a/arm9/lib/src/FX_vec.c
+++ b/arm9/lib/src/FX_vec.c
@@ -15,13 +15,13 @@ ARM_FUNC void VEC_Subtract(struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *ds
}
ARM_FUNC void VEC_Fx16Add(struct Vecx16 *a, struct Vecx16 *b, struct Vecx16 *dst){
- dst->x = a->x + b->x;
- dst->y = a->y + b->y;
- dst->z = a->z + b->z;
+ dst->x = (s16)(a->x + b->x);
+ dst->y = (s16)(a->y + b->y);
+ dst->z = (s16)(a->z + b->z);
}
ARM_FUNC fx32 VEC_DotProduct(struct Vecx32 *a, struct Vecx32 *b){
- return ((fx64)a->x * b->x + (fx64)a->y * b->y + (fx64)a->z * b->z + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT;
+ return (fx32)(((fx64)a->x * b->x + (fx64)a->y * b->y + (fx64)a->z * b->z + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT);
}
ARM_FUNC fx32 VEC_Fx16DotProduct(struct Vecx16 *a, struct Vecx16 *b){
@@ -46,9 +46,9 @@ ARM_FUNC void VEC_Fx16CrossProduct(struct Vecx16 *a, struct Vecx16 *b, struct Ve
x = ((a->y * b->z - a->z * b->y + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT);
y = ((a->z * b->x - a->x * b->z + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT);
z = ((a->x * b->y - a->y * b->x + (1 << (FX64_INT_SHIFT - 1))) >> FX64_INT_SHIFT);
- dst->x = x;
- dst->y = y;
- dst->z = z;
+ dst->x = (fx16)x;
+ dst->y = (fx16)y;
+ dst->z = (fx16)z;
}
ARM_FUNC fx32 VEC_Mag(struct Vecx32 *a){
@@ -56,8 +56,8 @@ ARM_FUNC fx32 VEC_Mag(struct Vecx32 *a){
l2 += (fx64)a->y * a->y;
l2 += (fx64)a->z * a->z;
reg_CP_SQRTCNT = 0x1;
- reg_CP_SQRT_PARAM = l2 * 4;
- while (reg_CP_SQRTCNT & 0x8000); //wait for coprocessor to finish
+ reg_CP_SQRT_PARAM = (u64)(l2 * 4);
+ while (reg_CP_SQRTCNT & 0x8000) {} //wait for coprocessor to finish
return ((fx32)reg_CP_SQRT_RESULT + 1) >> 1;
}
@@ -68,17 +68,17 @@ ARM_FUNC void VEC_Normalize(struct Vecx32 *a, struct Vecx32 *dst){
//1/sqrt(l) is computed by calculating sqrt(l)*(1/l)
reg_CP_DIVCNT = 0x2;
reg_CP_DIV_NUMER = 0x0100000000000000;
- reg_CP_DIV_DENOM = l2;
+ reg_CP_DIV_DENOM = (u64)l2;
reg_CP_SQRTCNT = 0x1;
- reg_CP_SQRT_PARAM = l2 * 4;
- while (reg_CP_SQRTCNT & 0x8000); //wait for sqrt to finish
- fx32 sqrtresult = reg_CP_SQRT_RESULT;
- while (reg_CP_DIVCNT & 0x8000); //wait for division to finish
- l2 = reg_CP_DIV_RESULT;
+ reg_CP_SQRT_PARAM = (u64)(l2 * 4);
+ while (reg_CP_SQRTCNT & 0x8000) {} //wait for sqrt to finish
+ fx32 sqrtresult = (fx32)reg_CP_SQRT_RESULT;
+ while (reg_CP_DIVCNT & 0x8000) {} //wait for division to finish
+ l2 = (fx64)reg_CP_DIV_RESULT;
l2 = sqrtresult * l2;
- dst->x = (l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D;
- dst->y = (l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D;
- dst->z = (l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D;
+ dst->x = (fx32)((l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D);
+ dst->y = (fx32)((l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D);
+ dst->z = (fx32)((l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D);
}
ARM_FUNC void VEC_Fx16Normalize(struct Vecx16 *a, struct Vecx16 *dst){
@@ -88,17 +88,17 @@ ARM_FUNC void VEC_Fx16Normalize(struct Vecx16 *a, struct Vecx16 *dst){
//1/sqrt(l) is computed by calculating sqrt(l)*(1/l)
reg_CP_DIVCNT = 0x2;
reg_CP_DIV_NUMER = 0x0100000000000000;
- reg_CP_DIV_DENOM = l2;
+ reg_CP_DIV_DENOM = (u64)l2;
reg_CP_SQRTCNT = 0x1;
- reg_CP_SQRT_PARAM = l2 * 4;
- while (reg_CP_SQRTCNT & 0x8000); //wait for sqrt to finish
- fx32 sqrtresult = reg_CP_SQRT_RESULT;
- while (reg_CP_DIVCNT & 0x8000); //wait for division to finish
- l2 = reg_CP_DIV_RESULT;
+ reg_CP_SQRT_PARAM = (u64)(l2 * 4);
+ while (reg_CP_SQRTCNT & 0x8000) {} //wait for sqrt to finish
+ fx32 sqrtresult = (fx32)reg_CP_SQRT_RESULT;
+ while (reg_CP_DIVCNT & 0x8000) {} //wait for division to finish
+ l2 = (fx64)reg_CP_DIV_RESULT;
l2 = sqrtresult * l2;
- dst->x = (l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D;
- dst->y = (l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D;
- dst->z = (l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D;
+ dst->x = (fx16)((l2 * a->x + (1LL << (0x2D - 1))) >> 0x2D);
+ dst->y = (fx16)((l2 * a->y + (1LL << (0x2D - 1))) >> 0x2D);
+ dst->z = (fx16)((l2 * a->z + (1LL << (0x2D - 1))) >> 0x2D);
}
ARM_FUNC void VEC_MultAdd(fx32 factor, struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *dst){
diff --git a/arm9/lib/src/GX.c b/arm9/lib/src/GX.c
index b1d62145..6b2f7790 100644
--- a/arm9/lib/src/GX.c
+++ b/arm9/lib/src/GX.c
@@ -10,10 +10,10 @@ static u16 sIsDispOn = TRUE;
ARM_FUNC void GX_Init(){
reg_GX_POWCNT |= 0x8000;
- reg_GX_POWCNT = (reg_GX_POWCNT & ~0x20E) | 0x20E;
- reg_GX_POWCNT = reg_GX_POWCNT | 0x1;
+ reg_GX_POWCNT = (u16)((reg_GX_POWCNT & ~0x20E) | 0x20E);
+ reg_GX_POWCNT = (u16)(reg_GX_POWCNT | 0x1);
GX_InitGXState();
- u32 temp;
+ s32 temp;
while (GXi_VRamLockId == 0)
{
temp = OS_GetLockID();
@@ -21,7 +21,7 @@ ARM_FUNC void GX_Init(){
{
OS_Terminate();
}
- GXi_VRamLockId = temp;
+ GXi_VRamLockId = (vu16)temp;
}
reg_GX_DISPSTAT = 0x0;
reg_GX_DISPCNT = 0x0;
@@ -48,7 +48,7 @@ ARM_FUNC void GX_Init(){
}
ARM_FUNC u32 GX_HBlankIntr(u32 enable){
- u32 temp = reg_GX_DISPSTAT & 0x10;
+ u32 temp = (u32)(reg_GX_DISPSTAT & 0x10);
if (enable)
{
reg_GX_DISPSTAT |= 0x10;
@@ -61,7 +61,7 @@ ARM_FUNC u32 GX_HBlankIntr(u32 enable){
}
ARM_FUNC u32 GX_VBlankIntr(u32 enable){
- u32 temp = reg_GX_DISPSTAT & 0x8;
+ u32 temp = (u32)(reg_GX_DISPSTAT & 0x8);
if (enable)
{
reg_GX_DISPSTAT |= 0x8;
@@ -76,7 +76,7 @@ ARM_FUNC u32 GX_VBlankIntr(u32 enable){
ARM_FUNC void GX_DispOff(){
u32 temp = reg_GX_DISPCNT;
sIsDispOn = 0x0;
- sDispMode = (temp & 0x30000) >> 0x10;
+ sDispMode = (u16)((temp & 0x30000) >> 0x10);
reg_GX_DISPCNT = temp & ~0x30000;
}
@@ -94,7 +94,7 @@ ARM_FUNC void GX_DispOn(){
ARM_FUNC void GX_SetGraphicsMode(u32 mode1, u32 mode2, u32 mode3){
u32 temp2 = reg_GX_DISPCNT;
- sDispMode = mode1;
+ sDispMode = (u16)mode1;
if (!sIsDispOn)
mode1 = 0;
reg_GX_DISPCNT = (mode2 | ((temp2 & 0xFFF0FFF0) | (mode1 << 0x10))) | (mode3 << 0x3);
@@ -113,10 +113,10 @@ ARM_FUNC void GXx_SetMasterBrightness_(vu16 *dst, s32 brightness){
}
else if (brightness > 0)
{
- *dst = 0x4000 | brightness;
+ *dst = (u16)(0x4000 | brightness);
}
else
{
- *dst = 0x8000 | -brightness;
+ *dst = (u16)(0x8000 | -brightness);
}
}
diff --git a/arm9/lib/src/GX_bgcnt.c b/arm9/lib/src/GX_bgcnt.c
index 2086ad16..92f2c4b8 100644
--- a/arm9/lib/src/GX_bgcnt.c
+++ b/arm9/lib/src/GX_bgcnt.c
@@ -3,7 +3,7 @@
#include "GX.h"
ARM_FUNC void *G2_GetBG0ScrPtr(){
- u32 temp = (((reg_G2_BG0CNT & 0x1F00) >> 0x8) << 0xB);
+ u32 temp = (u32)(((reg_G2_BG0CNT & 0x1F00) >> 0x8) << 0xB);
return (void *)(0x6000000 + (((reg_GX_DISPCNT & 0x38000000) >> 0x1B) << 0x10) + temp);
}
@@ -12,7 +12,7 @@ ARM_FUNC void *G2S_GetBG0ScrPtr(){
}
ARM_FUNC void *G2_GetBG1ScrPtr(){
- u32 temp = (((reg_G2_BG1CNT & 0x1F00) >> 0x8) << 0xB);
+ u32 temp = (u32)(((reg_G2_BG1CNT & 0x1F00) >> 0x8) << 0xB);
return (void *)(0x6000000 + (((reg_GX_DISPCNT & 0x38000000) >> 0x1B) << 0x10) + temp);
}
@@ -119,7 +119,7 @@ ARM_FUNC void *G2S_GetBG3ScrPtr(){
}
ARM_FUNC void *G2_GetBG0CharPtr(){
- u32 temp = (((reg_G2_BG0CNT & 0x3C) >> 0x2) << 0xE);
+ u32 temp = (u32)(((reg_G2_BG0CNT & 0x3C) >> 0x2) << 0xE);
return (void *)(0x6000000 + (((reg_GX_DISPCNT & 0x7000000) >> 0x18) << 0x10) + temp);
}
@@ -128,7 +128,7 @@ ARM_FUNC void *G2S_GetBG0CharPtr(){
}
ARM_FUNC void *G2_GetBG1CharPtr(){
- u32 temp = (((reg_G2_BG1CNT & 0x3C) >> 0x2) << 0xE);
+ u32 temp = (u32)(((reg_G2_BG1CNT & 0x3C) >> 0x2) << 0xE);
return (void *)(0x6000000 + (((reg_GX_DISPCNT & 0x7000000) >> 0x18) << 0x10) + temp);
}
@@ -137,7 +137,7 @@ ARM_FUNC void *G2S_GetBG1CharPtr(){
}
ARM_FUNC void *G2_GetBG2CharPtr(){
- s32 temp1 = (reg_GX_DISPCNT & 0x7);
+ s32 temp1 = (s32)(reg_GX_DISPCNT & 0x7);
u32 temp = reg_G2_BG2CNT;
if (temp1 < 5 || !(temp & 0x80))
{
@@ -152,7 +152,7 @@ ARM_FUNC void *G2_GetBG2CharPtr(){
}
ARM_FUNC void *G2S_GetBG2CharPtr(){
- s32 temp1 = (reg_GXS_DB_DISPCNT & 0x7);
+ s32 temp1 = (s32)(reg_GXS_DB_DISPCNT & 0x7);
u32 temp = reg_G2S_DB_BG2CNT;
if (temp1 < 5 || !(temp & 0x80))
{
@@ -166,7 +166,7 @@ ARM_FUNC void *G2S_GetBG2CharPtr(){
}
ARM_FUNC void *G2_GetBG3CharPtr(){
- s32 temp1 = (reg_GX_DISPCNT & 0x7);
+ s32 temp1 = (s32)(reg_GX_DISPCNT & 0x7);
u32 temp = reg_G2_BG3CNT;
if (temp1 < 3 || (temp1 < 6 && !(temp & 0x80)))
{
@@ -181,7 +181,7 @@ ARM_FUNC void *G2_GetBG3CharPtr(){
}
ARM_FUNC void *G2S_GetBG3CharPtr(){
- s32 temp1 = (reg_GXS_DB_DISPCNT & 0x7);
+ s32 temp1 = (s32)(reg_GXS_DB_DISPCNT & 0x7);
u32 temp = reg_G2S_DB_BG3CNT;
if (temp1 < 3 || (temp1 < 6 && !(temp & 0x80)))
{
diff --git a/arm9/lib/src/GX_g2.c b/arm9/lib/src/GX_g2.c
index 66273541..d17d4263 100644
--- a/arm9/lib/src/GX_g2.c
+++ b/arm9/lib/src/GX_g2.c
@@ -4,63 +4,63 @@
ARM_FUNC void G2x_SetBGyAffine_(u32 *ptr, struct Mtx22 *mtx, fx32 a, fx32 b, fx32 c, fx32 d){
fx32 temp0, temp1, temp2, temp3;
- ptr[0] = ((u16)(fx16)(mtx->_[0] >> 4) | (u16)(fx16)(mtx->_[1] >> 4)<< 0x10);
- ptr[1] = ((u16)(fx16)(mtx->_[2] >> 4) | (u16)(fx16)(mtx->_[3] >> 4)<< 0x10);
+ ptr[0] = (u32)((u16)(fx16)(mtx->_[0] >> 4) | (u16)(fx16)(mtx->_[1] >> 4)<< 0x10);
+ ptr[1] = (u32)((u16)(fx16)(mtx->_[2] >> 4) | (u16)(fx16)(mtx->_[3] >> 4)<< 0x10);
temp0 = c - a;
temp1 = d - b;
temp2 = mtx->_[0] * temp0 + mtx->_[1] * temp1 + (a << 0xC);
temp3 = mtx->_[2] * temp0 + mtx->_[3] * temp1 + (b << 0xC);
- ptr[2] = temp2 >> 4;
- ptr[3] = temp3 >> 4;
+ ptr[2] = (u32)(temp2 >> 4);
+ ptr[3] = (u32)(temp3 >> 4);
}
ARM_FUNC void G2x_SetBlendAlpha_(u32 *ptr, fx32 a, fx32 b, fx32 c, fx32 d){
- *ptr = ((a | 0x40) | (b << 0x8)) | ((c | (d << 0x8)) << 0x10);
+ *ptr = (u32)(((a | 0x40) | (b << 0x8)) | ((c | (d << 0x8)) << 0x10));
}
ARM_FUNC void G2x_SetBlendBrightness_(u16 *ptr, fx32 a, fx32 brightness){
if (brightness < 0)
{
- ptr[0] = a | 0xC0;
- ptr[2] = -brightness;
+ ptr[0] = (u16)(a | 0xC0);
+ ptr[2] = (u16)(-brightness);
}
else
{
- ptr[0] = a | 0x80;
- ptr[2] = brightness;
+ ptr[0] = (u16)(a | 0x80);
+ ptr[2] = (u16)brightness;
}
}
ARM_FUNC void G2x_SetBlendBrightnessExt_(u16 *ptr, fx32 a, fx32 b, fx32 c, fx32 d, fx32 brightness){
- ptr[1] = c | (d << 0x8);
+ ptr[1] = (u16)(c | (d << 0x8));
if (brightness < 0)
{
- ptr[0] = 0xC0 | a | (b << 0x8);
- ptr[2] = -brightness;
+ ptr[0] = (u16)(0xC0 | a | (b << 0x8));
+ ptr[2] = (u16)(-brightness);
}
else
{
- ptr[0] = 0x80 | a | (b << 0x8);
- ptr[2] = brightness;
+ ptr[0] = (u16)(0x80 | a | (b << 0x8));
+ ptr[2] = (u16)brightness;
}
}
-ARM_FUNC void *G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness){
+ARM_FUNC void G2x_ChangeBlendBrightness_(u16 *ptr, fx32 brightness){
u32 temp = *ptr;
if (brightness < 0)
{
if ((temp & 0xC0) == 0x80)
{
- ptr[0] = temp & ~0xC0 | 0xC0;
+ ptr[0] = (u16)(temp & ~0xC0 | 0xC0);
}
- ptr[2] = -brightness;
+ ptr[2] = (u16)(-brightness);
}
else
{
if ((temp & 0xC0) == 0xC0)
{
- ptr[0] = temp & ~0xC0 | 0x80;
+ ptr[0] = (u16)(temp & ~0xC0 | 0x80);
}
- ptr[2] = brightness;
+ ptr[2] = (u16)brightness;
}
}
diff --git a/arm9/lib/src/GX_g3_util.c b/arm9/lib/src/GX_g3_util.c
index c40a3848..6e472471 100644
--- a/arm9/lib/src/GX_g3_util.c
+++ b/arm9/lib/src/GX_g3_util.c
@@ -11,7 +11,7 @@ ARM_FUNC void G3i_PerspectiveW_(fx32 fovsin, fx32 fovcos, fx32 ratio, fx32 near,
fovcot = FX_Div(fovcos, fovsin);
if (scale != 0x1000) //!= 1.0
fovcot = (fovcot * scale) / 0x1000;
- reg_CP_DIV_NUMER = (s64)fovcot << 0x20;
+ reg_CP_DIV_NUMER = (u64)((s64)fovcot << 0x20);
reg_CP_DIV_DENOM = (u32)ratio;
if (load)
{
@@ -38,12 +38,12 @@ ARM_FUNC void G3i_PerspectiveW_(fx32 fovsin, fx32 fovcos, fx32 ratio, fx32 near,
reg_CP_DIV_DENOM = (u32)(near - far);
if (load)
{
- *reg_ptr = temp1;
+ *reg_ptr = (vu32)temp1;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
- *reg_ptr = fovcot;
+ *reg_ptr = (vu32)fovcot;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
@@ -57,15 +57,15 @@ ARM_FUNC void G3i_PerspectiveW_(fx32 fovsin, fx32 fovcos, fx32 ratio, fx32 near,
temp0 = FX_GetDivResultFx64c();
if (scale != 0x1000)
temp0 = (temp0 * scale) / 0x1000;
- temp1 = ((far + near) * temp0 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
- temp2 = (((fx32)(((fx64)(near << 1) * far + (1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT)) * temp0 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
+ temp1 = (fx32)(((far + near) * temp0 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
+ temp2 = (fx32)((((fx32)(((fx64)(near << 1) * far + (1 << (FX32_INT_SHIFT - 1))) >> FX32_INT_SHIFT)) * temp0 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
if (load)
{
- *reg_ptr = temp1;
- *reg_ptr = -scale;
+ *reg_ptr = (vu32)temp1;
+ *reg_ptr = (vu32)(-scale);
*reg_ptr = 0x0;
*reg_ptr = 0x0;
- *reg_ptr = temp2;
+ *reg_ptr = (vu32)temp2;
*reg_ptr = 0x0;
}
if (mtx)
@@ -104,10 +104,10 @@ ARM_FUNC void G3i_OrthoW_(fx32 top, fx32 bottom, fx32 left, fx32 right, fx32 nea
reg_CP_DIV_DENOM = (u32)(top - bottom);
if (scale != 0x1000)
temp1 = (temp1 * scale) / 0x1000;
- temp0 = (0x2000 * temp1 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
+ temp0 = (fx32)((0x2000 * temp1 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
if (load)
{
- *reg_ptr = temp0;
+ *reg_ptr = (vu32)temp0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
@@ -122,10 +122,10 @@ ARM_FUNC void G3i_OrthoW_(fx32 top, fx32 bottom, fx32 left, fx32 right, fx32 nea
reg_CP_DIV_DENOM = (u32)(near - far);
if (scale != 0x1000)
temp2 = (temp2 * scale) / 0x1000;
- temp0 = (0x2000 * temp2 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
+ temp0 = (fx32)((0x2000 * temp2 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
if (load)
{
- *reg_ptr = temp0;
+ *reg_ptr = (vu32)temp0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
@@ -138,25 +138,25 @@ ARM_FUNC void G3i_OrthoW_(fx32 top, fx32 bottom, fx32 left, fx32 right, fx32 nea
temp3 = FX_GetDivResultFx64c();
if (scale != 0x1000)
temp3 = (temp3 * scale) / 0x1000;
- temp0 = (0x2000 * temp3 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
+ temp0 = (fx32)((0x2000 * temp3 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
if (load)
{
- *reg_ptr = temp0;
+ *reg_ptr = (vu32)temp0;
*reg_ptr = 0x0;
}
if (mtx)
{
mtx->_[10] = temp0;
}
- temp0 = ((-(right + left)) * temp1 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
- temp4 = ((-(top + bottom)) * temp2 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
- temp5 = ((far + near) * temp3 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT;
+ temp0 = (fx32)(((-(right + left)) * temp1 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
+ temp4 = (fx32)(((-(top + bottom)) * temp2 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
+ temp5 = (fx32)(((far + near) * temp3 + ((fx64)1 << (FX64C_INT_SHIFT - 1))) >> FX64C_INT_SHIFT);
if (load)
{
- *reg_ptr = temp0;
- *reg_ptr = temp4;
- *reg_ptr = temp5;
- *reg_ptr = scale;
+ *reg_ptr = (vu32)temp0;
+ *reg_ptr = (vu32)temp4;
+ *reg_ptr = (vu32)temp5;
+ *reg_ptr = (vu32)scale;
}
if (mtx)
{
@@ -181,24 +181,24 @@ ARM_FUNC void G3i_LookAt_(struct Vecx32 *a, struct Vecx32 *b, struct Vecx32 *c,
{
reg_G3_MTX_MODE = 0x2;
reg_ptr = (vu32 *)&reg_G3_MTX_LOAD_4x3;
- *reg_ptr = temp1.x;
- *reg_ptr = temp2.x;
- *reg_ptr = temp.x;
- *reg_ptr = temp1.y;
- *reg_ptr = temp2.y;
- *reg_ptr = temp.y;
- *reg_ptr = temp1.z;
- *reg_ptr = temp2.z;
- *reg_ptr = temp.z;
+ *reg_ptr = (vu32)temp1.x;
+ *reg_ptr = (vu32)temp2.x;
+ *reg_ptr = (vu32)temp.x;
+ *reg_ptr = (vu32)temp1.y;
+ *reg_ptr = (vu32)temp2.y;
+ *reg_ptr = (vu32)temp.y;
+ *reg_ptr = (vu32)temp1.z;
+ *reg_ptr = (vu32)temp2.z;
+ *reg_ptr = (vu32)temp.z;
}
c1 = -VEC_DotProduct(a, &temp1);
c2 = -VEC_DotProduct(a, &temp2);
c3 = -VEC_DotProduct(a, &temp);
if (load)
{
- *reg_ptr = c1;
- *reg_ptr = c2;
- *reg_ptr = c3;
+ *reg_ptr = (vu32)c1;
+ *reg_ptr = (vu32)c2;
+ *reg_ptr = (vu32)c3;
}
if (mtx)
{
@@ -224,35 +224,35 @@ ARM_FUNC void G3_RotX(fx32 sinphi, fx32 cosphi){
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
- *reg_ptr = cosphi;
- *reg_ptr = sinphi;
+ *reg_ptr = (vu32)cosphi;
+ *reg_ptr = (vu32)sinphi;
*reg_ptr = 0x0;
- *reg_ptr = -sinphi;
- *reg_ptr = cosphi;
+ *reg_ptr = (vu32)(-sinphi);
+ *reg_ptr = (vu32)cosphi;
}
ARM_FUNC void G3_RotY(fx32 sinphi, fx32 cosphi){
vu32 *reg_ptr;
reg_ptr = (vu32 *)&reg_G3_MTX_MULT_3x3;
- *reg_ptr = cosphi;
+ *reg_ptr = (vu32)cosphi;
*reg_ptr = 0x0;
- *reg_ptr = -sinphi;
+ *reg_ptr = (vu32)(-sinphi);
*reg_ptr = 0x0;
*reg_ptr = 0x1000;
*reg_ptr = 0x0;
- *reg_ptr = sinphi;
+ *reg_ptr = (vu32)sinphi;
*reg_ptr = 0x0;
- *reg_ptr = cosphi;
+ *reg_ptr = (vu32)cosphi;
}
ARM_FUNC void G3_RotZ(fx32 sinphi, fx32 cosphi){
vu32 *reg_ptr;
reg_ptr = (vu32 *)&reg_G3_MTX_MULT_3x3;
- *reg_ptr = cosphi;
- *reg_ptr = sinphi;
+ *reg_ptr = (vu32)cosphi;
+ *reg_ptr = (vu32)sinphi;
*reg_ptr = 0x0;
- *reg_ptr = -sinphi;
- *reg_ptr = cosphi;
+ *reg_ptr = (vu32)(-sinphi);
+ *reg_ptr = (vu32)cosphi;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
*reg_ptr = 0x0;
diff --git a/arm9/lib/src/GX_g3b.c b/arm9/lib/src/GX_g3b.c
index 21698547..c71ff9d5 100644
--- a/arm9/lib/src/GX_g3b.c
+++ b/arm9/lib/src/GX_g3b.c
@@ -42,7 +42,7 @@ since the vector is assumed to be normalized, are used
*/
ARM_FUNC void G3B_Normal(struct GXDLInfo * displaylist, fx16 x, fx16 y, fx16 z){
*(u32 *)displaylist->curr_cmd = 0x21;
- *displaylist->curr_param = ((x >> 3) & 0x3FF) | (((y >> 3) & 0x3FF) << 0xA) | (((z >> 3) & 0x3FF) << 0x14) ;
+ *displaylist->curr_param = (u32)(((x >> 3) & 0x3FF) | (((y >> 3) & 0x3FF) << 0xA) | (((z >> 3) & 0x3FF) << 0x14));
displaylist->curr_cmd = (u8 *)displaylist->curr_param + 0x4;
displaylist->curr_param = (u32 *)displaylist->curr_cmd + 1;
}
diff --git a/arm9/lib/src/GX_g3imm.c b/arm9/lib/src/GX_g3imm.c
index 579032a6..bacd395a 100644
--- a/arm9/lib/src/GX_g3imm.c
+++ b/arm9/lib/src/GX_g3imm.c
@@ -2,6 +2,8 @@
#include "main.h"
#include "GX.h"
+void MI_Copy36B(void *src, void *dst);
+
ARM_FUNC void G3_LoadMtx43(struct Mtx43 *mtx){
reg_G3X_GXFIFO = 0x17;
GX_SendFifo48B(mtx, (void *)&reg_G3X_GXFIFO);
diff --git a/arm9/lib/src/GX_g3x.c b/arm9/lib/src/GX_g3x.c
index 31508e06..ed84f58b 100644
--- a/arm9/lib/src/GX_g3x.c
+++ b/arm9/lib/src/GX_g3x.c
@@ -4,6 +4,8 @@
extern u32 GXi_DmaId;
+void MI_Copy36B(void *src, void *dst);
+
ARM_FUNC asm void GXi_NopClearFifo128_(void *reg){
mov r1, #0x0
mov r2, #0x0
@@ -47,15 +49,15 @@ ARM_FUNC asm void GXi_NopClearFifo128_(void *reg){
ARM_FUNC void G3X_Init(){
G3X_ClearFifo();
reg_G3_END_VTXS = 0x0;
- while (reg_G3X_GXSTAT & 0x8000000); //wait for geometry engine to not be busy
+ while (reg_G3X_GXSTAT & 0x8000000) {} //wait for geometry engine to not be busy
reg_G3X_DISP3DCNT = 0x0;
reg_G3X_GXSTAT = 0x0;
reg_G2_BG0OFS = 0x0;
reg_G3X_DISP3DCNT |= 0x2000;
reg_G3X_DISP3DCNT |= 0x1000;
reg_G3X_DISP3DCNT &= ~0x3002;
- reg_G3X_DISP3DCNT = reg_G3X_DISP3DCNT & ~0x3000 | 0x10;
- reg_G3X_DISP3DCNT = reg_G3X_DISP3DCNT & (u16)~0x3004;
+ reg_G3X_DISP3DCNT = (u16)(reg_G3X_DISP3DCNT & ~0x3000 | 0x10);
+ reg_G3X_DISP3DCNT = (u16)(reg_G3X_DISP3DCNT & (u16)~0x3004);
reg_G3X_GXSTAT |= 0x8000;
reg_G3X_GXSTAT = reg_G3X_GXSTAT & ~0xC0000000 | 0x80000000;
G3X_InitMtxStack();
@@ -72,7 +74,7 @@ ARM_FUNC void G3X_Init(){
}
ARM_FUNC void G3X_ResetMtxStack(){
- while (reg_G3X_GXSTAT & 0x8000000);
+ while (reg_G3X_GXSTAT & 0x8000000) {}
reg_G3X_GXSTAT |= 0x8000;
reg_G3X_DISP3DCNT |= 0x2000;
reg_G3X_DISP3DCNT |= 0x1000;
@@ -84,14 +86,14 @@ ARM_FUNC void G3X_ResetMtxStack(){
ARM_FUNC void G3X_ClearFifo(){
GXi_NopClearFifo128_((void *)&reg_G3X_GXFIFO);
- while (reg_G3X_GXSTAT & 0x8000000);
+ while (reg_G3X_GXSTAT & 0x8000000) {}
}
ARM_FUNC void G3X_InitMtxStack(){
u32 PV_level, PJ_level;
reg_G3X_GXSTAT |= 0x8000;
- while (G3X_GetMtxStackLevelPV(&PV_level));
- while (G3X_GetMtxStackLevelPJ(&PJ_level));
+ while (G3X_GetMtxStackLevelPV(&PV_level)) {}
+ while (G3X_GetMtxStackLevelPJ(&PJ_level)) {}
reg_G3_MTX_MODE = 0x3;
reg_G3_MTX_IDENTITY = 0x0;
reg_G3_MTX_MODE = 0x0;
@@ -108,8 +110,8 @@ ARM_FUNC void G3X_InitMtxStack(){
ARM_FUNC void G3X_ResetMtxStack_2(){
u32 PV_level, PJ_level;
reg_G3X_GXSTAT |= 0x8000;
- while (G3X_GetMtxStackLevelPV(&PV_level));
- while (G3X_GetMtxStackLevelPJ(&PJ_level));
+ while (G3X_GetMtxStackLevelPV(&PV_level)) {}
+ while (G3X_GetMtxStackLevelPJ(&PJ_level)) {}
reg_G3_MTX_MODE = 0x3;
reg_G3_MTX_IDENTITY = 0x0;
reg_G3_MTX_MODE = 0x0;
@@ -127,20 +129,20 @@ ARM_FUNC void G3X_ResetMtxStack_2(){
ARM_FUNC void G3X_SetFog(u32 enable, u32 alphamode, u32 depth, s32 offset){
if (enable)
{
- reg_G3X_FOG_OFFSET = offset;
- reg_G3X_DISP3DCNT = (reg_G3X_DISP3DCNT &~0x3f40) | (((depth << 0x8)| (alphamode << 0x6)|0x80 ));
+ reg_G3X_FOG_OFFSET = (u16)offset;
+ reg_G3X_DISP3DCNT = (u16)((reg_G3X_DISP3DCNT &~0x3f40) | (((depth << 0x8)| (alphamode << 0x6)|0x80 )));
}
else
{
- reg_G3X_DISP3DCNT = reg_G3X_DISP3DCNT & (u16)~0x3080;
+ reg_G3X_DISP3DCNT = (u16)(reg_G3X_DISP3DCNT & (u16)~0x3080);
}
}
ARM_FUNC u32 G3X_GetClipMtx(struct Mtx44 *dst){
if (reg_G3X_GXSTAT & 0x8000000)
{
- return -1;
+ return (u32)-1;
}
else
{
@@ -152,7 +154,7 @@ ARM_FUNC u32 G3X_GetClipMtx(struct Mtx44 *dst){
ARM_FUNC u32 G3X_GetVectorMtx(struct Mtx33 *dst){
if (reg_G3X_GXSTAT & 0x8000000)
{
- return -1;
+ return (u32)-1;
}
else
{
@@ -174,7 +176,7 @@ ARM_FUNC void G3X_SetClearColor(u32 col, u32 alpha, u32 depth, u32 polygon_id, u
if (enable_fog)
temp |= 0x8000;
reg_G3X_CLEAR_COLOR = temp;
- reg_G3X_CLEAR_DEPTH = depth;
+ reg_G3X_CLEAR_DEPTH = (u16)depth;
}
ARM_FUNC void G3X_InitTable(){
@@ -197,7 +199,7 @@ ARM_FUNC void G3X_InitTable(){
ARM_FUNC u32 G3X_GetMtxStackLevelPV(u32 *level){
if (reg_G3X_GXSTAT & 0x4000)
{
- return -1;
+ return (u32)-1;
}
else
{
@@ -209,7 +211,7 @@ ARM_FUNC u32 G3X_GetMtxStackLevelPV(u32 *level){
ARM_FUNC u32 G3X_GetMtxStackLevelPJ(u32 *level){
if (reg_G3X_GXSTAT & 0x4000)
{
- return -1;
+ return (u32)-1;
}
else
{
@@ -221,7 +223,7 @@ ARM_FUNC u32 G3X_GetMtxStackLevelPJ(u32 *level){
ARM_FUNC u32 G3X_GetBoxTestResult(u32 *result){
if (reg_G3X_GXSTAT & 0x1)
{
- return -1;
+ return (u32)-1;
}
else
{
diff --git a/arm9/lib/src/GX_load2d.c b/arm9/lib/src/GX_load2d.c
index 2f7c0242..92669bce 100644
--- a/arm9/lib/src/GX_load2d.c
+++ b/arm9/lib/src/GX_load2d.c
@@ -135,7 +135,7 @@ ARM_FUNC void GXS_LoadBG3Char(void *src, u32 offset, u32 size){
}
ARM_FUNC void GX_BeginLoadBGExtPltt(){
- sBGExtPltt = GX_ResetBankForBGExtPltt();
+ sBGExtPltt = (s32)GX_ResetBankForBGExtPltt();
switch (sBGExtPltt)
{
case 0: //needed to match
@@ -169,7 +169,7 @@ ARM_FUNC void GX_EndLoadBGExtPltt(){
}
ARM_FUNC void GX_BeginLoadOBJExtPltt(){
- sOBJExtPltt = GX_ResetBankForOBJExtPltt();
+ sOBJExtPltt = (s32)GX_ResetBankForOBJExtPltt();
switch (sOBJExtPltt)
{
case 0: //needed to match
@@ -195,7 +195,7 @@ ARM_FUNC void GX_EndLoadOBJExtPltt(){
}
ARM_FUNC void GXS_BeginLoadBGExtPltt(){
- sSubBGExtPltt = FUN_020C6034();
+ sSubBGExtPltt = (s32)FUN_020C6034();
}
ARM_FUNC void GXS_LoadBGExtPltt(void *src, u32 offset, u32 size){
@@ -209,7 +209,7 @@ ARM_FUNC void GXS_EndLoadBGExtPltt(){
}
ARM_FUNC void GXS_BeginLoadOBJExtPltt(){
- sSubOBJExtPltt = GX_ResetBankForSubOBJ();
+ sSubOBJExtPltt = (s32)GX_ResetBankForSubOBJ();
}
ARM_FUNC void GXS_LoadOBJExtPltt(void *src, u32 offset, u32 size){
diff --git a/arm9/lib/src/GX_load3d.c b/arm9/lib/src/GX_load3d.c
index efab53ae..df057a44 100644
--- a/arm9/lib/src/GX_load3d.c
+++ b/arm9/lib/src/GX_load3d.c
@@ -52,10 +52,10 @@ static u32 sClrImgLCDCBlk = 0;
ARM_FUNC void GX_BeginLoadTex(){
u32 temp = GX_ResetBankForTex();
- sTex = temp;
- sTexLCDCBlk1 = sTexStartAddrTable[temp].blk1 << 0xC;
- sTexLCDCBlk2 = sTexStartAddrTable[temp].blk2 << 0xC;
- sSzTexBlk1 = sTexStartAddrTable[temp].szBlk1 << 0xC;
+ sTex = (s32)temp;
+ sTexLCDCBlk1 = (u32)(sTexStartAddrTable[temp].blk1 << 0xC);
+ sTexLCDCBlk2 = (u32)(sTexStartAddrTable[temp].blk2 << 0xC);
+ sSzTexBlk1 = (u32)(sTexStartAddrTable[temp].szBlk1 << 0xC);
}
ARM_FUNC void GX_LoadTex(void *src, u32 offset, u32 size){
@@ -97,9 +97,9 @@ ARM_FUNC void GX_EndLoadTex(){
}
ARM_FUNC void GX_BeginLoadTexPltt(){
- s32 temp = GX_ResetBankForTexPltt();
+ s32 temp = (s32)GX_ResetBankForTexPltt();
sTexPltt = temp;
- sTexPlttLCDCBlk = sTexPlttStartAddrTable[temp >> 4] << 0xC;
+ sTexPlttLCDCBlk = (u32)(sTexPlttStartAddrTable[temp >> 4] << 0xC);
}
ARM_FUNC void GX_LoadTexPltt(void *src, u32 offset, u32 size){
@@ -114,8 +114,8 @@ ARM_FUNC void GX_EndLoadTexPltt(){
}
ARM_FUNC void GX_BeginLoadClearImage(){
- s32 temp = GX_ResetBankForClearImage();
- sClrImg = temp;
+ u32 temp = GX_ResetBankForClearImage();
+ sClrImg = (s32)temp;
switch (temp)
{
case 2:
diff --git a/arm9/lib/src/GX_vramcnt.c b/arm9/lib/src/GX_vramcnt.c
index 67749301..6dcf34c1 100644
--- a/arm9/lib/src/GX_vramcnt.c
+++ b/arm9/lib/src/GX_vramcnt.c
@@ -28,7 +28,7 @@ ARM_FUNC void GX_VRAMCNT_SetLCDC_(u32 mask){
ARM_FUNC void GX_SetBankForBG(s32 bg){
gGXState.lcdc = (u16)(~bg & (gGXState.lcdc | gGXState.bg));
- gGXState.bg = bg;
+ gGXState.bg = (u16)bg;
switch (bg)
{
case 8:
@@ -101,7 +101,7 @@ ARM_FUNC void GX_SetBankForBG(s32 bg){
ARM_FUNC void GX_SetBankForOBJ(s32 obj){
gGXState.lcdc = (u16)(~obj & (gGXState.lcdc | gGXState.obj));
- gGXState.obj = obj;
+ gGXState.obj = (u16)obj;
switch (obj)
{
case 3:
@@ -140,7 +140,7 @@ ARM_FUNC void GX_SetBankForOBJ(s32 obj){
ARM_FUNC void GX_SetBankForBGExtPltt(s32 bgextpltt){
gGXState.lcdc = (u16)(~bgextpltt & (gGXState.lcdc | gGXState.bgExtPltt));
- gGXState.bgExtPltt = bgextpltt;
+ gGXState.bgExtPltt = (u16)bgextpltt;
switch (bgextpltt)
{
case 0x10:
@@ -166,7 +166,7 @@ ARM_FUNC void GX_SetBankForBGExtPltt(s32 bgextpltt){
ARM_FUNC void GX_SetBankForOBJExtPltt(s32 objextpltt){
gGXState.lcdc = (u16)(~objextpltt & (gGXState.lcdc | gGXState.objExtPltt));
- gGXState.objExtPltt = objextpltt;
+ gGXState.objExtPltt = (u16)objextpltt;
switch (objextpltt)
{
case 32:
@@ -186,14 +186,14 @@ ARM_FUNC void GX_SetBankForOBJExtPltt(s32 objextpltt){
ARM_FUNC void GX_SetBankForTex(s32 tex){
gGXState.lcdc = (u16)(~tex & (gGXState.lcdc | gGXState.tex));
- gGXState.tex = tex;
+ gGXState.tex = (u16)tex;
if (tex == 0)
{
reg_G3X_DISP3DCNT &= 0x0000CFFE;
}
else
{
- reg_G3X_DISP3DCNT = (reg_G3X_DISP3DCNT & ~0x3000) | 0x1;
+ reg_G3X_DISP3DCNT = (u16)((reg_G3X_DISP3DCNT & ~0x3000) | 0x1);
switch (tex)
{
case 5:
@@ -249,7 +249,7 @@ ARM_FUNC void GX_SetBankForTex(s32 tex){
ARM_FUNC void GX_SetBankForTexPltt(s32 texpltt){
gGXState.lcdc = (u16)(~texpltt & (gGXState.lcdc | gGXState.texPltt));
- gGXState.texPltt = texpltt;
+ gGXState.texPltt = (u16)texpltt;
switch (texpltt)
{
case 0: //needed to match
@@ -275,7 +275,7 @@ ARM_FUNC void GX_SetBankForTexPltt(s32 texpltt){
ARM_FUNC void GX_SetBankForClearImage(s32 clearimage){
gGXState.lcdc = (u16)(~clearimage & (gGXState.lcdc | gGXState.clrImg));
- gGXState.clrImg = clearimage;
+ gGXState.clrImg = (u16)clearimage;
switch (clearimage)
{
case 3:
@@ -306,7 +306,7 @@ ARM_FUNC void GX_SetBankForClearImage(s32 clearimage){
ARM_FUNC void GX_SetBankForARM7(s32 arm7){
gGXState.lcdc = (u16)(~arm7 & (gGXState.lcdc | gGXState.arm7));
- gGXState.arm7 = arm7;
+ gGXState.arm7 = (u16)arm7;
switch (arm7)
{
case 0: //needed to match
@@ -326,12 +326,12 @@ ARM_FUNC void GX_SetBankForARM7(s32 arm7){
ARM_FUNC void GX_SetBankForLCDC(s32 lcdc){
gGXState.lcdc |= lcdc;
- GX_VRAMCNT_SetLCDC_(lcdc);
+ GX_VRAMCNT_SetLCDC_((u32)lcdc);
}
ARM_FUNC void GX_SetBankForSubBG(s32 subbg){
gGXState.lcdc = (u16)(~subbg & (gGXState.lcdc | gGXState.sub_bg));
- gGXState.sub_bg = subbg;
+ gGXState.sub_bg = (u16)subbg;
switch (subbg)
{
case 0: //needed to match
@@ -350,7 +350,7 @@ ARM_FUNC void GX_SetBankForSubBG(s32 subbg){
ARM_FUNC void GX_SetBankForSubOBJ(s32 subobj){
gGXState.lcdc = (u16)(~subobj & (gGXState.lcdc | gGXState.sub_obj));
- gGXState.sub_obj = subobj;
+ gGXState.sub_obj = (u16)subobj;
switch (subobj)
{
case 8:
@@ -367,7 +367,7 @@ ARM_FUNC void GX_SetBankForSubOBJ(s32 subobj){
ARM_FUNC void GX_SetBankForSubBGExtPltt(s32 subbgextpltt){
gGXState.lcdc = (u16)(~subbgextpltt & (gGXState.lcdc | gGXState.sub_bgExtPltt));
- gGXState.sub_bgExtPltt = subbgextpltt;
+ gGXState.sub_bgExtPltt = (u16)subbgextpltt;
switch (subbgextpltt)
{
case 128:
@@ -383,7 +383,7 @@ ARM_FUNC void GX_SetBankForSubBGExtPltt(s32 subbgextpltt){
ARM_FUNC void GX_SetBankForSubOBJExtPltt(s32 subobjextpltt){
gGXState.lcdc = (u16)(~subobjextpltt & (gGXState.lcdc | gGXState.sub_objExtPltt));
- gGXState.sub_objExtPltt = subobjextpltt;
+ gGXState.sub_objExtPltt = (u16)subobjextpltt;
switch (subobjextpltt)
{
case 256:
diff --git a/arm9/lib/src/MATH_crc.c b/arm9/lib/src/MATH_crc.c
index ec0ccad0..cf8cc64c 100644
--- a/arm9/lib/src/MATH_crc.c
+++ b/arm9/lib/src/MATH_crc.c
@@ -15,7 +15,7 @@ ARM_FUNC void MATHi_CRC8InitTable(struct MATHCRC8Table *table, u8 poly) {
r <<= 1;
}
}
- t[i] = r;
+ t[i] = (u8)r;
}
}
@@ -29,7 +29,7 @@ ARM_FUNC void MATHi_CRC8Update(const struct MATHCRC8Table *table, MATHCRC8Contex
r = t[(r ^ *data) & 0xff];
data++;
}
- *context = r;
+ *context = (MATHCRC8Context)r;
}
ARM_FUNC void MATHi_CRC16InitTable(struct MATHCRC16Table *table, u16 poly) {
@@ -46,7 +46,7 @@ ARM_FUNC void MATHi_CRC16InitTable(struct MATHCRC16Table *table, u16 poly) {
r <<= 1;
}
}
- t[i] = r;
+ t[i] = (u16)r;
}
}
@@ -64,7 +64,7 @@ ARM_FUNC void MATHi_CRC16InitTableRev(struct MATHCRC16Table *table, u16 poly) {
r >>= 1;
}
}
- t[i] = r;
+ t[i] = (u16)r;
}
}
@@ -78,7 +78,7 @@ ARM_FUNC void MATHi_CRC16Update(const struct MATHCRC16Table *table, MATHCRC16Con
r = (r << 8) ^ t[((r >> 8) ^ *data) & 0xff];
data++;
}
- *context = r;
+ *context = (MATHCRC16Context)r;
}
ARM_FUNC void MATHi_CRC16UpdateRev(const struct MATHCRC16Table *table, MATHCRC16Context *context, const void *input, u32 length) {
@@ -91,7 +91,7 @@ ARM_FUNC void MATHi_CRC16UpdateRev(const struct MATHCRC16Table *table, MATHCRC16
r = (r >> 8) ^ t[(r ^ *data) & 0xff];
data++;
}
- *context = r;
+ *context = (MATHCRC16Context)r;
}
ARM_FUNC void MATHi_CRC32InitTableRev(struct MATHCRC32Table *table, u32 poly) {
@@ -144,7 +144,7 @@ ARM_FUNC u16 MATH_CalcCRC16CCITT(const struct MATHCRC16Table *table, const void
}
ARM_FUNC u32 MATH_CalcCRC32(const struct MATHCRC32Table *table, const void *data, u32 dataLength) {
- MATHCRC32Context ctx = ~0;
+ MATHCRC32Context ctx = (MATHCRC32Context)(~0);
MATHi_CRC32UpdateRev(table, &ctx, data, dataLength);
return ~ctx;
}
diff --git a/arm9/lib/src/OS_alloc.c b/arm9/lib/src/OS_alloc.c
index e883656e..32f386a8 100644
--- a/arm9/lib/src/OS_alloc.c
+++ b/arm9/lib/src/OS_alloc.c
@@ -94,7 +94,7 @@ ARM_FUNC void* OS_AllocFromHeap(OSArenaId id, OSHeapHandle heap, u32 size) {
OSIntrMode enabled = OS_DisableInterrupts();
heapInfo = OSiHeapInfo[id];
if (!heapInfo) {
- OS_RestoreInterrupts(enabled);
+ (void)OS_RestoreInterrupts(enabled);
return NULL;
}
@@ -114,7 +114,7 @@ ARM_FUNC void* OS_AllocFromHeap(OSArenaId id, OSHeapHandle heap, u32 size) {
}
if (cell == NULL) {
- OS_RestoreInterrupts(enabled);
+ (void)OS_RestoreInterrupts(enabled);
return NULL;
}
@@ -143,7 +143,7 @@ ARM_FUNC void* OS_AllocFromHeap(OSArenaId id, OSHeapHandle heap, u32 size) {
hd->allocated = DLAddFront(hd->allocated, cell);
- OS_RestoreInterrupts(enabled);
+ (void)OS_RestoreInterrupts(enabled);
return (void *)((char *)cell + HEADERSIZE);
}
@@ -165,5 +165,5 @@ ARM_FUNC void OS_FreeToHeap(OSArenaId id, OSHeapHandle heap, void* ptr) {
hd->allocated = DLExtract(hd->allocated, cell);
hd->free = DLInsert(hd->free, cell);
- OS_RestoreInterrupts(enabled);
+ (void)OS_RestoreInterrupts(enabled);
}
diff --git a/arm9/lib/src/OS_arena.c b/arm9/lib/src/OS_arena.c
index 31796771..ad3a4e16 100644
--- a/arm9/lib/src/OS_arena.c
+++ b/arm9/lib/src/OS_arena.c
@@ -17,7 +17,7 @@ extern void SDK_SECTION_ARENA_DTCM_START(); // TODO: technically this should be
extern void SDK_IRQ_STACKSIZE(); // TODO: technically this should be defined in the lcf
extern void SDK_SYS_STACKSIZE(); // TODO: technically this should be defined in the lcf
-ARM_FUNC void OS_InitArena() {
+ARM_FUNC void OS_InitArena(void) {
if (OSi_Initialized) {
return;
}
@@ -42,9 +42,9 @@ ARM_FUNC void OS_InitArena() {
OS_SetArenaLo(OS_ARENA_WRAM_MAIN, OS_GetInitArenaLo(OS_ARENA_WRAM_MAIN));
}
-ARM_FUNC void OS_InitArenaEx() {
- OS_SetArenaHi(2, OS_GetInitArenaHi(OS_ARENA_MAINEX));
- OS_SetArenaLo(2, OS_GetInitArenaLo(OS_ARENA_MAINEX));
+ARM_FUNC void OS_InitArenaEx(void) {
+ OS_SetArenaHi(OS_ARENA_MAINEX, OS_GetInitArenaHi(OS_ARENA_MAINEX));
+ OS_SetArenaLo(OS_ARENA_MAINEX, OS_GetInitArenaLo(OS_ARENA_MAINEX));
if (!OSi_MainExArenaEnabled || (OS_GetConsoleType() & OS_CONSOLE_SIZE_MASK) == OS_CONSOLE_SIZE_4MB) {
OS_SetProtectionRegion(1, HW_MAIN_MEM, 4MB);
@@ -73,22 +73,22 @@ ARM_FUNC void* OS_GetInitArenaHi(OSArenaId id) {
case OS_ARENA_ITCM:
return (void *)HW_ITCM_ARENA_HI_DEFAULT;
case OS_ARENA_DTCM:
- u32 irqStackLo = (u32)HW_DTCM_IRQ_STACK_END - (s32)SDK_IRQ_STACKSIZE;
+ {
+ u32 irqStackLo = (u32) HW_DTCM_IRQ_STACK_END - (s32) SDK_IRQ_STACKSIZE;
u32 sysStackLo;
- if (!(s32)SDK_SYS_STACKSIZE) {
+ if (!(s32) SDK_SYS_STACKSIZE) {
sysStackLo = HW_DTCM;
- if (sysStackLo < (u32)SDK_SECTION_ARENA_DTCM_START) {
- sysStackLo = (u32)SDK_SECTION_ARENA_DTCM_START;
+ if (sysStackLo < (u32) SDK_SECTION_ARENA_DTCM_START) {
+ sysStackLo = (u32) SDK_SECTION_ARENA_DTCM_START;
}
+ } else if ((s32) SDK_SYS_STACKSIZE < 0) {
+ sysStackLo = (u32) SDK_SECTION_ARENA_DTCM_START - (s32) SDK_SYS_STACKSIZE;
+ } else {
+ sysStackLo = irqStackLo - (s32) SDK_SYS_STACKSIZE;
}
- else if ((s32)SDK_SYS_STACKSIZE < 0) {
- sysStackLo = (u32)SDK_SECTION_ARENA_DTCM_START - (s32)SDK_SYS_STACKSIZE;
- }
- else {
- sysStackLo = irqStackLo - (s32)SDK_SYS_STACKSIZE;
- }
- return (void*)sysStackLo;
+ return (void *) sysStackLo;
+ }
case OS_ARENA_SHARED:
return (void *)HW_SHARED_ARENA_HI_DEFAULT;
case OS_ARENA_WRAM_MAIN:
diff --git a/arm9/lib/src/OS_emulator.c b/arm9/lib/src/OS_emulator.c
index c138b2bc..e92a7d9d 100644
--- a/arm9/lib/src/OS_emulator.c
+++ b/arm9/lib/src/OS_emulator.c
@@ -5,13 +5,13 @@
#include "OS_emulator.h"
#include "function_target.h"
-u32 OSi_ConsoleTypeCache = -1u; //todo fix bss
+u32 OSi_ConsoleTypeCache = -1u;
-ARM_FUNC BOOL OS_IsRunOnEmulator() {
+ARM_FUNC BOOL OS_IsRunOnEmulator(void) {
return FALSE;
}
-ARM_FUNC u32 OS_GetConsoleType() {
+ARM_FUNC u32 OS_GetConsoleType(void) {
OSi_ConsoleTypeCache = OS_CONSOLE_NITRO | OS_CONSOLE_DEV_CARD | OS_CONSOLE_SIZE_4MB;
return OSi_ConsoleTypeCache;
diff --git a/arm9/lib/src/OS_init.c b/arm9/lib/src/OS_init.c
index a34196f4..e1c7e63a 100644
--- a/arm9/lib/src/OS_init.c
+++ b/arm9/lib/src/OS_init.c
@@ -5,15 +5,15 @@
#include "function_target.h"
#include "OS_init.h"
-extern void PXI_Init();
-extern void OS_InitException();
-extern void MI_Init();
-extern void OS_InitVAlarm();
-extern void OSi_InitVramExclusive();
-extern void OS_InitThread();
-extern void CTRDG_Init();
-extern void CARD_Init();
-extern void PM_Init();
+extern void PXI_Init(void);
+extern void OS_InitException(void);
+extern void MI_Init(void);
+extern void OS_InitVAlarm(void);
+extern void OSi_InitVramExclusive(void);
+extern void OS_InitThread(void);
+extern void CTRDG_Init(void);
+extern void CARD_Init(void);
+extern void PM_Init(void);
ARM_FUNC void OS_Init(void) {
OS_InitArena();
diff --git a/arm9/lib/src/OS_interrupt.c b/arm9/lib/src/OS_interrupt.c
index 76deb069..4692fd54 100644
--- a/arm9/lib/src/OS_interrupt.c
+++ b/arm9/lib/src/OS_interrupt.c
@@ -11,7 +11,7 @@
extern OSThreadQueue OSi_IrqThreadQueue;
-ARM_FUNC void OS_InitIrqTable() {
+ARM_FUNC void OS_InitIrqTable(void) {
OS_InitThreadQueue(&OSi_IrqThreadQueue);
}
diff --git a/arm9/lib/src/OS_protectionUnit.c b/arm9/lib/src/OS_protectionUnit.c
new file mode 100644
index 00000000..6d3b7952
--- /dev/null
+++ b/arm9/lib/src/OS_protectionUnit.c
@@ -0,0 +1,22 @@
+//
+// Created by red031000 on 2020-05-24.
+//
+
+#include "function_target.h"
+#include "OS_protectionUnit.h"
+
+ARM_FUNC asm void OS_EnableProtectionUnit(void)
+{
+ mrc p15, 0x0, r0, c1, c0, 0x0
+ orr r0, r0, #0x1
+ mcr p15, 0x0, r0, c1, c0, 0x0
+ bx lr
+}
+
+ARM_FUNC asm void OS_DisableProtectionUnit(void)
+{
+ mrc p15, 0x0, r0, c1, c0, 0x0
+ bic r0, r0, #0x1
+ mcr p15, 0x0, r0, c1, c0, 0x0
+ bx lr
+}
diff --git a/arm9/lib/src/OS_reset.c b/arm9/lib/src/OS_reset.c
index 02498962..b3aff389 100644
--- a/arm9/lib/src/OS_reset.c
+++ b/arm9/lib/src/OS_reset.c
@@ -11,15 +11,15 @@
static u16 OSi_IsInitReset = 0;
vu16 OSi_IsResetOccurred = 0;
-extern void PXI_Init();
+extern void PXI_Init(void);
extern u32 PXI_IsCallbackReady(u32 param1, u32 param2);
extern void PXI_SetFifoRecvCallback(u32 param1, void* callback);
extern u32 PXI_SendWordByFifo(u32 param1, u32 data, u32 param2);
extern void CARD_LockRom(u16 lockId);
extern void MI_StopDma(u32 dma);
-extern void OSi_DoResetSystem(); //in itcm, should technically be in this file
+extern void OSi_DoResetSystem(void); //in itcm, should technically be in this file
-ARM_FUNC void OS_InitReset() {
+ARM_FUNC void OS_InitReset(void) {
if (OSi_IsInitReset) {
return;
}
@@ -55,7 +55,7 @@ ARM_FUNC void OS_ResetSystem(u32 parameter) {
MI_StopDma(2);
MI_StopDma(3);
(void)OS_SetIrqMask(0x40000);
- OS_ResetRequestIrqMask((u32)~0);
+ (void)OS_ResetRequestIrqMask((u32)~0);
*(u32 *)HW_RESET_PARAMETER_BUF = parameter;
OSi_SendToPxi(OS_PXI_COMMAND_RESET);
OSi_DoResetSystem(); //oh boy this is in itcm, that's gonna be fun to deal with Kappa
diff --git a/arm9/lib/src/OS_system.c b/arm9/lib/src/OS_system.c
index 5379433b..1d257679 100644
--- a/arm9/lib/src/OS_system.c
+++ b/arm9/lib/src/OS_system.c
@@ -5,7 +5,7 @@
#include "OS_system.h"
#include "syscall.h"
-ARM_FUNC asm OSIntrMode OS_EnableInterrupts() {
+ARM_FUNC asm OSIntrMode OS_EnableInterrupts(void) {
mrs r0, cpsr
bic r1, r0, #HW_PSR_DISABLE_IRQ
msr cpsr_c, r1
@@ -13,7 +13,7 @@ ARM_FUNC asm OSIntrMode OS_EnableInterrupts() {
bx lr
}
-ARM_FUNC asm OSIntrMode OS_DisableInterrupts() {
+ARM_FUNC asm OSIntrMode OS_DisableInterrupts(void) {
mrs r0, cpsr
orr r1, r0, #HW_PSR_DISABLE_IRQ
msr cpsr_c, r1
@@ -30,7 +30,7 @@ ARM_FUNC asm OSIntrMode OS_RestoreInterrupts(OSIntrMode state) {
bx lr
}
-ARM_FUNC asm OSIntrMode OS_DisableInterrupts_IrqAndFiq() {
+ARM_FUNC asm OSIntrMode OS_DisableInterrupts_IrqAndFiq(void) {
mrs r0, cpsr
orr r1, r0, #HW_PSR_DISABLE_IRQ_FIQ
msr cpsr_c, r1
@@ -47,25 +47,25 @@ ARM_FUNC asm OSIntrMode OS_RestoreInterrupts_IrqAndFiq(OSIntrMode state) {
bx lr
}
-ARM_FUNC asm OSIntrMode OS_GetCpsrIrq() {
+ARM_FUNC asm OSIntrMode OS_GetCpsrIrq(void) {
mrs r0, cpsr
and r0, r0, #HW_PSR_DISABLE_IRQ
bx lr
}
-ARM_FUNC asm OSProcMode OS_GetProcMode() {
+ARM_FUNC asm OSProcMode OS_GetProcMode(void) {
mrs r0, cpsr
and r0, r0, #HW_PSR_CPU_MODE_MASK
bx lr
}
-ARM_FUNC asm void OS_SpinWait() {
+ARM_FUNC asm void OS_SpinWait(void) {
subs r0, r0, #0x4
bhs OS_SpinWait
bx lr
}
-ARM_FUNC void OS_WaitVBlankIntr() {
+ARM_FUNC void OS_WaitVBlankIntr(void) {
SVC_WaitByLoop(0x1);
OS_WaitIrq(TRUE, OS_IE_V_BLANK);
}
diff --git a/arm9/lib/src/OS_tcm.c b/arm9/lib/src/OS_tcm.c
index 5a168c58..fa06e345 100644
--- a/arm9/lib/src/OS_tcm.c
+++ b/arm9/lib/src/OS_tcm.c
@@ -5,7 +5,7 @@
#include "OS_tcm.h"
#include "function_target.h"
-ARM_FUNC asm u32 OS_GetDTCMAddress() {
+ARM_FUNC asm u32 OS_GetDTCMAddress(void) {
mrc p15, 0x0, r0, c9, c1, 0x0
ldr r1, =OSi_TCM_REGION_BASE_MASK
and r0, r0, r1
diff --git a/arm9/lib/src/OS_terminate_proc.c b/arm9/lib/src/OS_terminate_proc.c
index eb267c6b..40b015d9 100644
--- a/arm9/lib/src/OS_terminate_proc.c
+++ b/arm9/lib/src/OS_terminate_proc.c
@@ -7,14 +7,14 @@
#include "function_target.h"
#include "OS_system.h"
-ARM_FUNC void OS_Terminate() {
+ARM_FUNC void OS_Terminate(void) {
while (TRUE) {
(void)OS_DisableInterrupts();
OS_Halt();
}
}
-ARM_FUNC asm void OS_Halt() {
+ARM_FUNC asm void OS_Halt(void) {
mov r0, #0x0
mcr p15, 0x0, r0, c7, c0, 0x4
bx lr
diff --git a/arm9/lib/src/custom_allocator.c b/arm9/lib/src/custom_allocator.c
index 869901ce..1b1375bc 100644
--- a/arm9/lib/src/custom_allocator.c
+++ b/arm9/lib/src/custom_allocator.c
@@ -1,7 +1,5 @@
#include "global.h"
-
-typedef void * (* AllocFunc)(u32 size);
-typedef void (* FreeFunc)(void * ptr);
+#include "custom_allocator.h"
static FreeFunc sDestructor;
static AllocFunc sAllocator;