Skip to content

Commit

Permalink
start merging in MSL
Browse files Browse the repository at this point in the history
  • Loading branch information
shibbo committed Oct 29, 2024
1 parent 0ec3139 commit 0e791c7
Show file tree
Hide file tree
Showing 65 changed files with 9,124 additions and 19 deletions.
10 changes: 5 additions & 5 deletions config/RMGK01/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11123,12 +11123,12 @@ MSL_C/ansi_fp.c:
extab start:0x800067F0 end:0x80006828
extabindex start:0x80006E08 end:0x80006E5C
.text start:0x805197E4 end:0x8051B154
.rodata start:0x805622A0 end:0x80562780
.data start:0x80609868 end:0x80609AF0
.rodata start:0x805622A0 end:0x80562380
.data start:0x80609868 end:0x806099D0

MSL_C/locale.c:
.rodata start:0x80562780 end:0x80562888
.data start:0x80609AF0 end:0x80609BC8
.rodata start:0x80562380 end:0x80562888
.data start:0x806099D0 end:0x80609BC8
.sdata2 start:0x806C2390 end:0x806C23B0

MSL_C/arith.c:
Expand Down Expand Up @@ -11187,7 +11187,7 @@ MSL_C/printf.c:
.sdata start:0x806B2E38 end:0x806B2E40

MSL_C/float.c:
.sdata start:0x806B2E40 end:0x806B2E54
.sdata start:0x806B2E40 end:0x806B2E50

MSL_C/scanf.c:
extab start:0x800068E8 end:0x80006900
Expand Down
6 changes: 3 additions & 3 deletions config/RMGK01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -60963,13 +60963,13 @@ __files = .data:0x80609728; // type:object size:0x140 scope:global
@1249 = .data:0x80609868; // type:object size:0x124 scope:local align:4
lbl_80609990 = .data:0x80609990; // type:object size:0x40
lbl_806099D0 = .data:0x806099D0; // type:object size:0x38 data:4byte
lbl_80609A08 = .data:0x80609A08; // type:object size:0x28
_loc_ctyp_C = .data:0x80609A08; // type:object size:0x28
lbl_80609A30 = .data:0x80609A30; // type:object size:0xC0
_loc_coll_C = .data:0x80609AF0; // type:object size:0x1C scope:global align:4
_loc_mon_C = .data:0x80609B0C; // type:object size:0x34 scope:global align:4
_loc_num_C = .data:0x80609B40; // type:object size:0x14 scope:global align:4
lbl_80609B58 = .data:0x80609B58; // type:object size:0x28
lbl_80609B80 = .data:0x80609B80; // type:object size:0x48
_current_locale = .data:0x80609B80; // type:object size:0x48
@2263 = .data:0x80609BC8; // type:object size:0xE0 scope:local align:4
@2262 = .data:0x80609CA8; // type:object size:0x44 scope:local align:4
@2301 = .data:0x80609CEC; // type:object size:0x84 scope:local align:4
Expand Down Expand Up @@ -62651,7 +62651,7 @@ fragmentID = .sdata:0x806B2E30; // type:object size:0x4 scope:global align:4 dat
@wstringBase0 = .sdata:0x806B2E38; // type:object size:0x2 scope:local align:4
__float_nan = .sdata:0x806B2E40; // type:object size:0x4 scope:global align:4 data:float
__float_huge = .sdata:0x806B2E44; // type:object size:0x4 scope:global align:4 data:float
lbl_806B2E48 = .sdata:0x806B2E48; // type:object size:0x8 data:double
__double_huge = .sdata:0x806B2E48; // type:object size:0x8 data:double
lbl_806B2E50 = .sdata:0x806B2E50; // type:object size:0x1 data:byte
lbl_806B2E60 = .sbss:0x806B2E60; // type:object size:0x1 data:byte
fog$5710 = .sbss:0x806B2E64; // type:object size:0x4 scope:local align:4 data:byte
Expand Down
23 changes: 12 additions & 11 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@
"-str reuse",
"-enc SJIS",
"-ipa file",
"-i libs/MSL_C/include",
"-i libs/MetroTRK/include",
"-i libs/RVL_SDK/include",
"-i libs/Runtime/include",
Expand Down Expand Up @@ -2770,17 +2771,17 @@ def JSysLib(lib_name: str, objects: List[Object]) -> Dict[str, Any]:
MSLib(
"MSL_C",
[
Object(NonMatching, "MSL_C/alloc.c"),
Object(NonMatching, "MSL_C/ansi_files.c"),
Object(NonMatching, "MSL_C/ansi_fp.c"),
Object(NonMatching, "MSL_C/arith.c"),
Object(NonMatching, "MSL_C/buffer_io.c"),
Object(NonMatching, "MSL_C/ctype.c"),
Object(NonMatching, "MSL_C/direct_io.c"),
Object(NonMatching, "MSL_C/errno.c"),
Object(NonMatching, "MSL_C/file_io.c"),
Object(NonMatching, "MSL_C/FILE_POS.c"),
Object(NonMatching, "MSL_C/float.c"),
Object(Matching, "MSL_C/alloc.c"),
Object(Matching, "MSL_C/ansi_files.c"),
Object(Matching, "MSL_C/ansi_fp.c"),
Object(Matching, "MSL_C/arith.c"),
Object(Matching, "MSL_C/buffer_io.c"),
Object(Matching, "MSL_C/ctype.c"),
Object(Matching, "MSL_C/direct_io.c"),
Object(Matching, "MSL_C/errno.c"),
Object(Matching, "MSL_C/file_io.c"),
Object(Matching, "MSL_C/FILE_POS.c"),
Object(Matching, "MSL_C/float.c"),
Object(NonMatching, "MSL_C/locale.c"),
Object(NonMatching, "MSL_C/mbstring.c"),
Object(NonMatching, "MSL_C/mem.c"),
Expand Down
98 changes: 98 additions & 0 deletions src/MSL_C/FILE_POS.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#include "file_struct.h"
#include "buffer_io.h"
#include <cerrno>

long _ftell(FILE *pFile) {
int buf = 0;
long pos;

unsigned char file_kind = pFile->mode.file;

if (!(file_kind == file_disk || file_kind == file_console) || pFile->state.error) {
errno = 40;
return -1;
}

if (pFile->state.io_state == neutral) {
return pFile->pos;
}

pos = pFile->buffer_pos + (pFile->buffer_ptr - pFile->buffer);

if (pFile->state.io_state >= rereading) {
buf = pFile->state.io_state - rereading + 1;
pos -= buf;
}

if (!pFile->mode.binary) {
long dist = pFile->buffer_ptr - pFile->buffer - buf;
unsigned char* cur_buf = pFile->buffer;

while (dist--) {
if (*cur_buf++ == '\n') {
pos++;
}
}
}

return pos;
}

long ftell(FILE *pFile) {
return _ftell(pFile);
}

int _fseek(FILE *pFile, long offs, int file_mode) {
__pos_proc position_proc_func;
unsigned char file_kind = pFile->mode.file;

if (!(file_kind == file_disk) || pFile->state.error) {
errno = 40;
return -1;
}

if (pFile->state.io_state == writing) {
if (__flush_buffer(pFile, 0) != 0) {
pFile->state.error = 1;
pFile->buffer_len = 0;
errno = 40;
return -1;
}
}

if (file_mode == 1) {
file_mode = 0;
offs += _ftell(pFile);
}

if ((file_mode != 2) && (pFile->mode.io != 3) && ((pFile->state.io_state == reading) || (pFile->state.io_state == rereading))) {
if ((offs >= pFile->pos || offs < pFile->buffer_pos)) {
pFile->state.io_state = neutral;
}
else {
pFile->buffer_ptr = pFile->buffer + (offs - pFile->buffer_pos);
pFile->buffer_len = pFile->pos - offs;
pFile->state.io_state = reading;
}
}
else {
pFile->state.io_state = neutral;
}

if (pFile->state.io_state == neutral) {
position_proc_func = pFile->pos_proc;

if (position_proc_func != 0 && (*position_proc_func)(pFile->handle, &offs, file_mode, pFile->ref)) {
pFile->state.error = 1;
pFile->buffer_len = 0;
errno = 40;
return -1;
}

pFile->state.eof = 0;
pFile->pos = offs;
pFile->buffer_len = 0;
}

return 0;
}
13 changes: 13 additions & 0 deletions src/MSL_C/abort_exit_ppc_eabi.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include <cstdlib>

int raise(int);
int exit(int);

void (*__stdio_exit)(void) = 0;
int __aborting = 0;

void abort(void) {
raise(1);
__aborting = 1;
exit(1);
}
Loading

0 comments on commit 0e791c7

Please sign in to comment.