2022-04-21 02:12:38 +02:00
|
|
|
/*-------------------------------------------------------------
|
|
|
|
|
|
|
|
sysconf.c -- SYSCONF & setting.txt support
|
|
|
|
|
|
|
|
Copyright (C) 2008 tona
|
|
|
|
|
|
|
|
Original conf.c portions written by and Copright (C) 2008
|
|
|
|
Hector Martin (marcan)
|
|
|
|
|
|
|
|
This software is provided 'as-is', without any express or implied
|
|
|
|
warranty. In no event will the authors be held liable for any
|
|
|
|
damages arising from the use of this software.
|
|
|
|
|
|
|
|
Permission is granted to anyone to use this software for any
|
|
|
|
purpose, including commercial applications, and to alter it and
|
|
|
|
redistribute it freely, subject to the following restrictions:
|
|
|
|
|
|
|
|
1. The origin of this software must not be misrepresented; you
|
|
|
|
must not claim that you wrote the original software. If you use
|
|
|
|
this software in a product, an acknowledgment in the product
|
|
|
|
documentation would be appreciated but is not required.
|
|
|
|
|
|
|
|
2. Altered source versions must be plainly marked as such, and
|
|
|
|
must not be misrepresented as being the original software.
|
|
|
|
|
|
|
|
3. This notice may not be removed or altered from any source
|
|
|
|
distribution.
|
|
|
|
|
|
|
|
-------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#if defined(HW_RVL)
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <malloc.h>
|
|
|
|
#include <ogc/ipc.h>
|
|
|
|
#include <ogc/isfs.h>
|
|
|
|
#include <ogc/es.h>
|
|
|
|
|
|
|
|
#include "sysconf.h"
|
|
|
|
|
|
|
|
#define DEBUG_SYSCONF
|
|
|
|
|
|
|
|
#ifdef DEBUG_SYSCONF
|
|
|
|
#include "wiibasics.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int __sysconf_inited = 0;
|
|
|
|
static int __sysconf_buffer_txt_decrypted = 0;
|
|
|
|
static u8 __sysconf_buffer[0x4000] ATTRIBUTE_ALIGN(32);
|
|
|
|
static char __sysconf_txt_buffer[0x101] ATTRIBUTE_ALIGN(32);
|
|
|
|
static int __sysconf_buffer_updated = 0;
|
|
|
|
static int __sysconf_txt_buffer_updated = 0;
|
|
|
|
|
|
|
|
static const char __sysconf_file[] ATTRIBUTE_ALIGN(32) = "/shared2/sys/SYSCONF";
|
2022-04-21 03:38:39 +02:00
|
|
|
// static const char __sysconf_txt_file[] ATTRIBUTE_ALIGN(32) = "/title/00000001/00000002/data/setting.txt";
|
2022-04-21 02:12:38 +02:00
|
|
|
static const char __sysconf_txt_file[] ATTRIBUTE_ALIGN(32) = "/title/00000001/00000002/data/setting.txt";
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
int __SYSCONF_EndOfTextOffset(void)
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
int i;
|
|
|
|
int offset = 0;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
for (i = 0; i < 0x100; i++)
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!memcmp(__sysconf_txt_buffer + i, "\r\n", 2))
|
2022-04-21 02:12:38 +02:00
|
|
|
offset = i;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
offset += 2;
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __SYSCONF_DecryptEncryptTextBuffer(void)
|
|
|
|
{
|
|
|
|
u32 key = 0x73B5DBFA;
|
|
|
|
int i;
|
2022-04-21 03:38:39 +02:00
|
|
|
char *end = (char *)__sysconf_txt_buffer;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (__sysconf_buffer_txt_decrypted)
|
|
|
|
end += __SYSCONF_EndOfTextOffset();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
for (i = 0; i < 0x100; i++)
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
__sysconf_txt_buffer[i] ^= key & 0xff;
|
2022-04-21 03:38:39 +02:00
|
|
|
key = (key << 1) | (key >> 31);
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
__sysconf_buffer_txt_decrypted = !__sysconf_buffer_txt_decrypted;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (__sysconf_buffer_txt_decrypted)
|
|
|
|
end += __SYSCONF_EndOfTextOffset();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
memset(end, 0, (__sysconf_txt_buffer + 0x100) - end);
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef DEBUG_SYSCONF
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
void SYSCONF_DumpBuffer(void)
|
|
|
|
{
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return;
|
2022-04-21 02:12:38 +02:00
|
|
|
hex_print_array16(__sysconf_buffer, 0x4000);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
void SYSCONF_DumpTxtBuffer(void)
|
|
|
|
{
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return;
|
|
|
|
hex_print_array16((u8 *)__sysconf_txt_buffer, 0x101);
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
void SYSCONF_DumpEncryptedTxtBuffer(void)
|
|
|
|
{
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return;
|
2022-04-21 02:12:38 +02:00
|
|
|
int was = __sysconf_buffer_txt_decrypted;
|
|
|
|
if (__sysconf_buffer_txt_decrypted)
|
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
2022-04-21 03:38:39 +02:00
|
|
|
hex_print_array16((u8 *)__sysconf_txt_buffer, 0x101);
|
2022-04-21 02:12:38 +02:00
|
|
|
if (was)
|
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
void SYSCONF_PrintAllSettings(void)
|
|
|
|
{
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return;
|
2022-04-21 02:12:38 +02:00
|
|
|
u16 i, count;
|
|
|
|
u16 *offset;
|
|
|
|
char temp[33], typestring[20];
|
|
|
|
u8 nlen;
|
2022-04-21 03:38:39 +02:00
|
|
|
offset = (u16 *)&__sysconf_buffer[6];
|
|
|
|
count = *((u16 *)(&__sysconf_buffer[4]));
|
2022-04-21 02:12:38 +02:00
|
|
|
printf("Total: %u settings.\n", count);
|
2022-04-21 03:38:39 +02:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
nlen = (__sysconf_buffer[*offset] & 0x0F) + 1;
|
|
|
|
memcpy(temp, &__sysconf_buffer[(*offset) + 1], nlen);
|
2022-04-21 02:12:38 +02:00
|
|
|
temp[nlen] = 0;
|
2022-04-21 03:38:39 +02:00
|
|
|
switch (__sysconf_buffer[*offset] >> 5)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
sprintf(typestring, "BIGARRAY[0x%X]", *((u16 *)&__sysconf_buffer[(*offset) + nlen + 1]) + 1);
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case 2:
|
|
|
|
sprintf(typestring, "SMALLARRAY[0x%X]", __sysconf_buffer[(*offset) + nlen + 1] + 1);
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case 3:
|
|
|
|
strcpy(typestring, "BYTE");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case 4:
|
|
|
|
strcpy(typestring, "SHORT");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case 5:
|
|
|
|
strcpy(typestring, "LONG");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case 7:
|
|
|
|
strcpy(typestring, "BOOL");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
default:
|
|
|
|
sprintf(typestring, "Unknown %u", __sysconf_buffer[*offset] >> 5);
|
|
|
|
}
|
|
|
|
printf("%3u. 0x%04X: %-10s Type: %s\n", i + 1, *offset, temp, typestring);
|
2022-04-21 02:12:38 +02:00
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* DEBUG_SYSCONF */
|
|
|
|
|
|
|
|
s32 SYSCONF_Init(void)
|
|
|
|
{
|
|
|
|
int fd;
|
|
|
|
int ret;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (__sysconf_inited)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fd = IOS_Open(__sysconf_file, 1);
|
|
|
|
if (fd < 0)
|
|
|
|
return fd;
|
|
|
|
|
|
|
|
memset(__sysconf_buffer, 0, 0x4000);
|
|
|
|
memset(__sysconf_txt_buffer, 0, 0x101);
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = IOS_Read(fd, __sysconf_buffer, 0x4000);
|
|
|
|
IOS_Close(fd);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret != 0x4000)
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
|
|
|
|
fd = IOS_Open(__sysconf_txt_file, 1);
|
|
|
|
if (fd < 0)
|
|
|
|
return fd;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = IOS_Read(fd, __sysconf_txt_buffer, 0x100);
|
|
|
|
IOS_Close(fd);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret != 0x100)
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
|
|
|
|
if (memcmp(__sysconf_buffer, "SCv0", 4))
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
__sysconf_inited = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __SYSCONF_WriteTxtBuffer(void)
|
|
|
|
{
|
|
|
|
u64 tid;
|
|
|
|
int ret, fd;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
|
|
|
if (!__sysconf_txt_buffer_updated)
|
|
|
|
return 0;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = ES_GetTitleID(&tid);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (tid != 0x100000002LL)
|
|
|
|
return SYSCONF_EPERMS;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (__sysconf_buffer_txt_decrypted)
|
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 3, 3, 3);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
fd = IOS_Open(__sysconf_txt_file, 2);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (fd < 0)
|
|
|
|
return fd;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = IOS_Write(fd, __sysconf_txt_buffer, 0x100);
|
|
|
|
IOS_Close(fd);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret != 0x100)
|
|
|
|
return SYSCONF_EBADWRITE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = ISFS_SetAttr(__sysconf_txt_file, 0x1000, 1, 0, 1, 1, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
__sysconf_buffer_updated = 0;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __SYSCONF_WriteBuffer(void)
|
|
|
|
{
|
|
|
|
int ret, fd;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
|
|
|
if (!__sysconf_buffer_updated)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
fd = IOS_Open(__sysconf_file, 2);
|
|
|
|
if (fd < 0)
|
|
|
|
return fd;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = IOS_Write(fd, __sysconf_buffer, 0x4000);
|
|
|
|
IOS_Close(fd);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (ret != 0x4000)
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
__sysconf_buffer_updated = 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SaveChanges(void)
|
|
|
|
{
|
|
|
|
s32 ret;
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = __SYSCONF_WriteBuffer();
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
ret = __SYSCONF_WriteTxtBuffer();
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_ERR_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __SYSCONF_ShiftTxt(char *start, s32 delta)
|
|
|
|
{
|
|
|
|
char *end;
|
|
|
|
char temp[0x100];
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (!__sysconf_buffer_txt_decrypted)
|
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
end = strchr((char *)__sysconf_txt_buffer, 0);
|
|
|
|
if (end == NULL || end > __sysconf_txt_buffer + 0x100)
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (start < __sysconf_txt_buffer || start >= end)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
memcpy(temp, start, end - start);
|
|
|
|
memcpy(start + delta, temp, end - start);
|
|
|
|
// free (temp);
|
|
|
|
*(end + delta) = 0;
|
2022-04-21 02:12:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __SYSCONF_GetTxt(const char *name, char *buf, int length)
|
|
|
|
{
|
|
|
|
char *line = __sysconf_txt_buffer;
|
|
|
|
char *delim, *end;
|
|
|
|
int slen;
|
|
|
|
int nlen = strlen(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (!__sysconf_buffer_txt_decrypted)
|
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
while (line < (__sysconf_txt_buffer + 0x100))
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
delim = strchr(line, '=');
|
2022-04-21 03:38:39 +02:00
|
|
|
if (delim && ((delim - line) == nlen) && !memcmp(name, line, nlen))
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
delim++;
|
|
|
|
end = strchr(line, '\r');
|
2022-04-21 03:38:39 +02:00
|
|
|
if (end)
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
slen = end - delim;
|
2022-04-21 03:38:39 +02:00
|
|
|
if (slen < length)
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
memcpy(buf, delim, slen);
|
|
|
|
buf[slen] = 0;
|
|
|
|
return slen;
|
2022-04-21 03:38:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// printf("Should be %u is %u", slen, length);
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_ETOOBIG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
// skip to line end
|
2022-04-21 03:38:39 +02:00
|
|
|
while (line < (__sysconf_txt_buffer + 0x100) && *line++ != '\n')
|
|
|
|
;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
return SYSCONF_ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* This function should NOT be used, and was only added for emergency recovery at one point */
|
|
|
|
int __SYSCONF_AddTxt(const char *name, const char *value)
|
|
|
|
{
|
|
|
|
char *newline;
|
|
|
|
char *temp;
|
|
|
|
char endline[10];
|
|
|
|
u32 length;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
|
|
|
newline = strchr((char *)__sysconf_txt_buffer, 0);
|
|
|
|
if (newline == NULL || newline > __sysconf_txt_buffer + 0x100)
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
newline--;
|
2022-04-21 03:38:39 +02:00
|
|
|
while (*--newline == '\r')
|
|
|
|
;
|
2022-04-21 02:12:38 +02:00
|
|
|
newline++;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
strcpy(endline, newline);
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
newline += strlen(endline);
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
length = strlen(name) + strlen(value) + strlen(endline) + 1;
|
|
|
|
|
|
|
|
if (newline + length < __sysconf_txt_buffer + 0x100)
|
|
|
|
{
|
|
|
|
temp = malloc(length + 1);
|
2022-04-21 02:12:38 +02:00
|
|
|
sprintf(temp, "%s=%s%s", name, value, endline);
|
|
|
|
strcpy(newline, temp);
|
2022-04-21 03:38:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
printf("Not worth it!");
|
|
|
|
return SYSCONF_EBADFILE;
|
|
|
|
}
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int __SYSCONF_SetTxt(const char *name, const char *value)
|
|
|
|
{
|
|
|
|
char *line = __sysconf_txt_buffer;
|
|
|
|
char *delim, *end;
|
|
|
|
int slen;
|
|
|
|
int nlen = strlen(name);
|
|
|
|
int vlen = strlen(value);
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
if (!__sysconf_buffer_txt_decrypted)
|
|
|
|
__SYSCONF_DecryptEncryptTextBuffer();
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
while (line < (__sysconf_txt_buffer + 0x100))
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
delim = strchr(line, '=');
|
2022-04-21 03:38:39 +02:00
|
|
|
if (delim && ((delim - line) == nlen) && !memcmp(name, line, nlen))
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
delim++;
|
|
|
|
end = strchr(line, '\r');
|
2022-04-21 03:38:39 +02:00
|
|
|
if (end)
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
slen = end - delim;
|
2022-04-21 03:38:39 +02:00
|
|
|
if (slen == vlen)
|
|
|
|
{
|
|
|
|
// printf("vlen: %u slen: %u\n", vlen, slen);
|
2022-04-21 02:12:38 +02:00
|
|
|
memcpy(delim, value, vlen);
|
|
|
|
__sysconf_txt_buffer_updated = 1;
|
|
|
|
return 0;
|
2022-04-21 03:38:39 +02:00
|
|
|
}
|
|
|
|
else if (vlen && (vlen < slen ||
|
|
|
|
(strchr(end, '\n') + (vlen - slen)) < __sysconf_txt_buffer + 0x100))
|
|
|
|
{
|
|
|
|
// printf("vlen: %u slen: %u\n", vlen, slen);
|
|
|
|
if (__SYSCONF_ShiftTxt(end, vlen - slen))
|
|
|
|
return -1;
|
2022-04-21 02:12:38 +02:00
|
|
|
memcpy(delim, value, vlen);
|
|
|
|
__sysconf_txt_buffer_updated = 1;
|
|
|
|
return 0;
|
2022-04-21 03:38:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
// skip to line end
|
2022-04-21 03:38:39 +02:00
|
|
|
while (line < (__sysconf_txt_buffer + 0x100) && *line++ != '\n')
|
|
|
|
;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_ENOENT;
|
|
|
|
}
|
|
|
|
|
|
|
|
u8 *__SYSCONF_Find(const char *name)
|
|
|
|
{
|
|
|
|
u16 count;
|
|
|
|
u16 *offset;
|
|
|
|
int nlen = strlen(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
count = *((u16 *)(&__sysconf_buffer[4]));
|
|
|
|
offset = (u16 *)&__sysconf_buffer[6];
|
|
|
|
|
|
|
|
while (count--)
|
|
|
|
{
|
|
|
|
if ((nlen == ((__sysconf_buffer[*offset] & 0x0F) + 1)) && !memcmp(name, &__sysconf_buffer[*offset + 1], nlen))
|
2022-04-21 02:12:38 +02:00
|
|
|
return &__sysconf_buffer[*offset];
|
|
|
|
offset++;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetLength(const char *name)
|
|
|
|
{
|
|
|
|
u8 *entry;
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
entry = __SYSCONF_Find(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!entry)
|
|
|
|
return SYSCONF_ENOENT;
|
|
|
|
|
|
|
|
switch (*entry >> 5)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return *((u16 *)&entry[strlen(name) + 1]) + 1;
|
|
|
|
case 2:
|
|
|
|
return entry[strlen(name) + 1] + 1;
|
|
|
|
case 3:
|
|
|
|
return 1;
|
|
|
|
case 4:
|
|
|
|
return 2;
|
|
|
|
case 5:
|
|
|
|
return 4;
|
|
|
|
case 7:
|
|
|
|
return 1;
|
|
|
|
default:
|
|
|
|
return SYSCONF_ENOTIMPL;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetType(const char *name)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
u8 *entry;
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
entry = __SYSCONF_Find(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!entry)
|
|
|
|
return SYSCONF_ENOENT;
|
|
|
|
|
|
|
|
return *entry >> 5;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_Get(const char *name, void *buffer, u32 length)
|
|
|
|
{
|
|
|
|
u8 *entry;
|
|
|
|
s32 len;
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
entry = __SYSCONF_Find(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!entry)
|
|
|
|
return SYSCONF_ENOENT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
len = SYSCONF_GetLength(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (len < 0)
|
|
|
|
return len;
|
|
|
|
if (len > length)
|
|
|
|
return SYSCONF_ETOOBIG;
|
|
|
|
|
|
|
|
switch (*entry >> 5)
|
|
|
|
{
|
|
|
|
case SYSCONF_BIGARRAY:
|
|
|
|
memcpy(buffer, &entry[strlen(name) + 3], len);
|
|
|
|
break;
|
|
|
|
case SYSCONF_SMALLARRAY:
|
|
|
|
memcpy(buffer, &entry[strlen(name) + 2], len);
|
|
|
|
break;
|
|
|
|
case SYSCONF_BYTE:
|
|
|
|
case SYSCONF_SHORT:
|
|
|
|
case SYSCONF_LONG:
|
|
|
|
case SYSCONF_BOOL:
|
|
|
|
memset(buffer, 0, length);
|
|
|
|
memcpy(buffer, &entry[strlen(name) + 1], len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return SYSCONF_ENOTIMPL;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
return len;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_Set(const char *name, const void *value, u32 length)
|
|
|
|
{
|
|
|
|
u8 *entry;
|
|
|
|
s32 len;
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!__sysconf_inited)
|
|
|
|
return SYSCONF_ENOTINIT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
entry = __SYSCONF_Find(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (!entry)
|
|
|
|
return SYSCONF_ENOENT;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
len = SYSCONF_GetLength(name);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (len < 0)
|
|
|
|
return len;
|
|
|
|
if (length != len)
|
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
|
|
|
|
switch (*entry >> 5)
|
|
|
|
{
|
|
|
|
case SYSCONF_BIGARRAY:
|
|
|
|
memcpy(&entry[strlen(name) + 3], value, len);
|
|
|
|
break;
|
|
|
|
case SYSCONF_SMALLARRAY:
|
|
|
|
memcpy(&entry[strlen(name) + 2], value, len);
|
|
|
|
break;
|
|
|
|
case SYSCONF_BYTE:
|
|
|
|
case SYSCONF_SHORT:
|
|
|
|
case SYSCONF_LONG:
|
|
|
|
case SYSCONF_BOOL:
|
|
|
|
// memset(buffer, 0, length);
|
|
|
|
memcpy(&entry[strlen(name) + 1], value, len);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return SYSCONF_ENOTIMPL;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
__sysconf_buffer_updated = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetShutdownMode(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
u8 idlesysconf[2] = {0, 0};
|
2022-04-21 02:12:38 +02:00
|
|
|
int res;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 2)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return idlesysconf[0];
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetIdleLedMode(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
2022-04-21 03:38:39 +02:00
|
|
|
u8 idlesysconf[2] = {0, 0};
|
2022-04-21 02:12:38 +02:00
|
|
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 2)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return idlesysconf[1];
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetProgressiveScan(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("IPL.PGS", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetEuRGB60(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("IPL.E60", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetIRSensitivity(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u32 val = 0;
|
|
|
|
res = SYSCONF_Get("BT.SENS", &val, 4);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 4)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetSensorBarPosition(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("BT.BAR", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetPadSpeakerVolume(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("BT.SPKV", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetPadMotorMode(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("BT.MOT", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetSoundMode(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("IPL.SND", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetLanguage(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("IPL.LNG", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetCounterBias(u32 *bias)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
res = SYSCONF_Get("IPL.CB", bias, 4);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 4)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_ERR_OK;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetScreenSaverMode(void)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
res = SYSCONF_Get("IPL.SSV", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetDisplayOffsetH(s8 *offset)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
res = SYSCONF_Get("IPL.DH", offset, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_GetPadDevices(sysconf_pad_device *devs, int count)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 buf[0x461];
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
res = SYSCONF_Get("BT.DINF", buf, 0x461);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if ((res < 1) || (buf[0] > 0x10))
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
if (count && devs)
|
|
|
|
{
|
|
|
|
memset(devs, 0, count * sizeof(sysconf_pad_device));
|
|
|
|
if (count < buf[0])
|
|
|
|
memcpy(devs, &buf[1], count * sizeof(sysconf_pad_device));
|
2022-04-21 02:12:38 +02:00
|
|
|
else
|
2022-04-21 03:38:39 +02:00
|
|
|
memcpy(devs, &buf[1], buf[0] * sizeof(sysconf_pad_device));
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
res = buf[0];
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetNickName(u8 *nickname)
|
|
|
|
{
|
|
|
|
int i, res;
|
|
|
|
u16 buf[11];
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
res = SYSCONF_Get("IPL.NIK", buf, 0x16);
|
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if ((res != 0x16) || (!buf[0]))
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
for (i = 0; i < 10; i++)
|
2022-04-21 02:12:38 +02:00
|
|
|
nickname[i] = buf[i];
|
|
|
|
nickname[10] = 0;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetAspectRatio(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
|
|
|
|
res = SYSCONF_Get("IPL.AR", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetEULA(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 val = 0;
|
|
|
|
|
|
|
|
res = SYSCONF_Get("IPL.EULA", &val, 1);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetParentalPassword(s8 *password)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 buf[0x4A];
|
|
|
|
|
|
|
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
memcpy(password, buf + 3, 4);
|
2022-04-21 02:12:38 +02:00
|
|
|
password[4] = 0;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetParentalAnswer(s8 *answer)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 buf[0x4A];
|
|
|
|
|
|
|
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
memcpy(answer, buf + 8, 32);
|
2022-04-21 02:12:38 +02:00
|
|
|
answer[32] = 0;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetWiiConnect24(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u32 val = 0;
|
|
|
|
|
|
|
|
res = SYSCONF_Get("NET.WCFG", &val, 4);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 4)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetRegion(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
char buf[3];
|
|
|
|
|
|
|
|
res = __SYSCONF_GetTxt("GAME", buf, 3);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (!strcmp(buf, "JP"))
|
|
|
|
return SYSCONF_REGION_JP;
|
|
|
|
if (!strcmp(buf, "US"))
|
|
|
|
return SYSCONF_REGION_US;
|
|
|
|
if (!strcmp(buf, "EU"))
|
|
|
|
return SYSCONF_REGION_EU;
|
|
|
|
if (!strcmp(buf, "KR"))
|
|
|
|
return SYSCONF_REGION_KR;
|
|
|
|
if (!strcmp(buf, "CN"))
|
|
|
|
return SYSCONF_REGION_CN;
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetArea(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
char buf[4];
|
|
|
|
|
|
|
|
res = __SYSCONF_GetTxt("AREA", buf, 4);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (!strcmp(buf, "JPN"))
|
|
|
|
return SYSCONF_AREA_JPN;
|
|
|
|
if (!strcmp(buf, "USA"))
|
|
|
|
return SYSCONF_AREA_USA;
|
|
|
|
if (!strcmp(buf, "EUR"))
|
|
|
|
return SYSCONF_AREA_EUR;
|
|
|
|
if (!strcmp(buf, "AUS"))
|
|
|
|
return SYSCONF_AREA_AUS;
|
|
|
|
if (!strcmp(buf, "BRA"))
|
|
|
|
return SYSCONF_AREA_BRA;
|
|
|
|
if (!strcmp(buf, "TWN"))
|
|
|
|
return SYSCONF_AREA_TWN;
|
|
|
|
if (!strcmp(buf, "ROC"))
|
|
|
|
return SYSCONF_AREA_ROC;
|
|
|
|
if (!strcmp(buf, "KOR"))
|
|
|
|
return SYSCONF_AREA_KOR;
|
|
|
|
if (!strcmp(buf, "HKG"))
|
|
|
|
return SYSCONF_AREA_HKG;
|
|
|
|
if (!strcmp(buf, "ASI"))
|
|
|
|
return SYSCONF_AREA_ASI;
|
|
|
|
if (!strcmp(buf, "LTN"))
|
|
|
|
return SYSCONF_AREA_LTN;
|
|
|
|
if (!strcmp(buf, "SAF"))
|
|
|
|
return SYSCONF_AREA_SAF;
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_GetVideo(void)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
char buf[5];
|
|
|
|
|
|
|
|
res = __SYSCONF_GetTxt("VIDEO", buf, 5);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (!strcmp(buf, "NTSC"))
|
|
|
|
return SYSCONF_VIDEO_NTSC;
|
|
|
|
if (!strcmp(buf, "PAL"))
|
|
|
|
return SYSCONF_VIDEO_PAL;
|
|
|
|
if (!strcmp(buf, "MPAL"))
|
|
|
|
return SYSCONF_VIDEO_MPAL;
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetShutdownMode(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
u8 idlesysconf[2] = {0, 0};
|
2022-04-21 02:12:38 +02:00
|
|
|
int res;
|
|
|
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 2)
|
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
idlesysconf[0] = value;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_Set("IPL.IDL", idlesysconf, 2);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetIdleLedMode(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
u8 idlesysconf[2] = {0, 0};
|
2022-04-21 02:12:38 +02:00
|
|
|
int res;
|
|
|
|
res = SYSCONF_Get("IPL.IDL", idlesysconf, 2);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 2)
|
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
idlesysconf[1] = value;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_Set("IPL.IDL", idlesysconf, 2);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetProgressiveScan(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.PGS", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetEuRGB60(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.E60", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetIRSensitivity(u32 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("BT.SENS", &value, 4);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetSensorBarPosition(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("BT.BAR", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetPadSpeakerVolume(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("BT.SPKV", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetPadMotorMode(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("BT.MOT", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetSoundMode(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.SND", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetLanguage(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.LNG", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetCounterBias(u32 bias)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
return SYSCONF_Set("IPL.CB", &bias, 4);
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetScreenSaverMode(u8 value)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.SSV", &value, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetDisplayOffsetH(s8 offset)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.DH", &offset, 1);
|
|
|
|
}
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
s32 SYSCONF_SetPadDevices(const sysconf_pad_device *devs, u8 count)
|
2022-04-21 02:12:38 +02:00
|
|
|
{
|
|
|
|
u8 buf[0x461] = {0};
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (count > 0x10)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
buf[0] = count;
|
2022-04-21 03:38:39 +02:00
|
|
|
|
|
|
|
if (devs)
|
|
|
|
memcpy(&buf[1], devs, count * sizeof(sysconf_pad_device));
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_Set("BT.DINF", buf, 0x461);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetNickName(const u8 *nickname, u16 length)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
u16 buf[11] = {0};
|
2022-04-21 03:38:39 +02:00
|
|
|
if (length > 10)
|
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
|
|
|
|
for (i = 0; i < length; i++)
|
2022-04-21 02:12:38 +02:00
|
|
|
buf[i] = nickname[i];
|
|
|
|
buf[10] = length;
|
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
return SYSCONF_Set("IPL.NIK", buf, 0x16);
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetAspectRatio(u8 value)
|
|
|
|
{
|
|
|
|
return SYSCONF_Set("IPL.AR", &value, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetEULA(u8 value)
|
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
if (value > 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
return SYSCONF_Set("IPL.EULA", &value, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetParentalPassword(const s8 *password, u32 length)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 buf[0x4A] = {0};
|
2022-04-21 03:38:39 +02:00
|
|
|
if (length != 4)
|
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
|
2022-04-21 02:12:38 +02:00
|
|
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
|
2022-04-21 03:38:39 +02:00
|
|
|
memcpy(buf + 3, password, 4);
|
2022-04-21 02:12:38 +02:00
|
|
|
|
|
|
|
return SYSCONF_Set("IPL.PC", buf, 0x4A);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetParentalAnswer(const s8 *answer, u32 length)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
u8 buf[0x4A] = {0};
|
2022-04-21 03:38:39 +02:00
|
|
|
if (length != 32)
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
|
|
|
|
res = SYSCONF_Get("IPL.PC", buf, 0x4A);
|
2022-04-21 03:38:39 +02:00
|
|
|
if (res < 0)
|
|
|
|
return res;
|
|
|
|
if (res != 1)
|
|
|
|
return SYSCONF_EBADVALUE;
|
|
|
|
|
|
|
|
memcpy(buf + 8, answer, length);
|
2022-04-21 02:12:38 +02:00
|
|
|
|
|
|
|
return SYSCONF_Set("IPL.PC", buf, 0x4A);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetWiiConnect24(u32 value)
|
|
|
|
{
|
|
|
|
return SYSCONF_Set("NET.WCFG", &value, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetRegion(s32 value)
|
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case SYSCONF_REGION_JP:
|
|
|
|
return __SYSCONF_SetTxt("GAME", "JP");
|
|
|
|
case SYSCONF_REGION_US:
|
|
|
|
return __SYSCONF_SetTxt("GAME", "US");
|
|
|
|
case SYSCONF_REGION_EU:
|
|
|
|
return __SYSCONF_SetTxt("GAME", "EU");
|
|
|
|
case SYSCONF_REGION_KR:
|
|
|
|
return __SYSCONF_SetTxt("GAME", "KR");
|
|
|
|
case SYSCONF_REGION_CN:
|
|
|
|
return __SYSCONF_SetTxt("GAME", "CN");
|
|
|
|
default:
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetArea(s32 value)
|
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case SYSCONF_AREA_JPN:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "JPN");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_USA:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "USA");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_EUR:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "EUR");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_AUS:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "AUS");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_BRA:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "BRA");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_TWN:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "TWN");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_ROC:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "ROC");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_KOR:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "KOR");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_HKG:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "HKG");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_ASI:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "ASI");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_LTN:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "LTN");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_AREA_SAF:
|
|
|
|
return __SYSCONF_SetTxt("AREA", "SAF");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
default:
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
s32 SYSCONF_SetVideo(s32 value)
|
|
|
|
{
|
2022-04-21 03:38:39 +02:00
|
|
|
switch (value)
|
|
|
|
{
|
|
|
|
case SYSCONF_VIDEO_NTSC:
|
|
|
|
return __SYSCONF_SetTxt("VIDEO", "NTSC");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_VIDEO_PAL:
|
|
|
|
return __SYSCONF_SetTxt("VIDEO", "PAL");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
case SYSCONF_VIDEO_MPAL:
|
|
|
|
return __SYSCONF_SetTxt("VIDEO", "MPAL");
|
2022-04-21 02:12:38 +02:00
|
|
|
break;
|
2022-04-21 03:38:39 +02:00
|
|
|
default:
|
|
|
|
return SYSCONF_EBADVALUE;
|
2022-04-21 02:12:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|