Merge branch 'mariopartyrd:main' into main

This commit is contained in:
CreateSource 2025-02-03 18:03:47 -05:00 committed by GitHub
commit 85f4997673
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
63 changed files with 5753 additions and 1322 deletions

View file

@ -370,13 +370,14 @@ lbl_1_data_203 = .data:0x00000203; // type:object size:0x10 data:string
lbl_1_data_213 = .data:0x00000213; // type:object size:0x26 data:string lbl_1_data_213 = .data:0x00000213; // type:object size:0x26 data:string
lbl_1_data_239 = .data:0x00000239; // type:object size:0x25 lbl_1_data_239 = .data:0x00000239; // type:object size:0x25
lbl_1_data_260 = .data:0x00000260; // type:object size:0x15C lbl_1_data_260 = .data:0x00000260; // type:object size:0x15C
lbl_1_data_3BC = .data:0x000003BC; // type:object size:0x178 lbl_1_data_3BC = .data:0x000003BC; // type:object size:0x15C
lbl_1_data_518 = .data:0x00000518; // type:object size:0x1C
lbl_1_data_534 = .data:0x00000534; // type:object size:0x18 lbl_1_data_534 = .data:0x00000534; // type:object size:0x18
lbl_1_data_54C = .data:0x0000054C; // type:object size:0x18 data:float lbl_1_data_54C = .data:0x0000054C; // type:object size:0x18 data:float
lbl_1_data_564 = .data:0x00000564; // type:object size:0xC data:float lbl_1_data_564 = .data:0x00000564; // type:object size:0xC data:float
lbl_1_data_570 = .data:0x00000570; // type:object size:0xC data:float lbl_1_data_570 = .data:0x00000570; // type:object size:0xC data:float
lbl_1_data_57C = .data:0x0000057C; // type:object size:0x4 lbl_1_data_57C = .data:0x0000057C; // type:object size:0x4
lbl_1_data_580 = .data:0x00000580; // type:object size:0xE data:string lbl_1_data_580 = .data:0x00000580; // type:object size:0xE scope:local data:string
lbl_1_data_590 = .data:0x00000590; // type:object size:0x1C lbl_1_data_590 = .data:0x00000590; // type:object size:0x1C
lbl_1_data_5AC = .data:0x000005AC; // type:object size:0x1C lbl_1_data_5AC = .data:0x000005AC; // type:object size:0x1C
lbl_1_data_5C8 = .data:0x000005C8; // type:object size:0x8 lbl_1_data_5C8 = .data:0x000005C8; // type:object size:0x8

View file

@ -3653,7 +3653,7 @@ lbl_8011E580 = .rodata:0x8011E580; // type:object size:0x20
lbl_8011E5A0 = .rodata:0x8011E5A0; // type:object size:0x38 lbl_8011E5A0 = .rodata:0x8011E5A0; // type:object size:0x38
lbl_8011E5D8 = .rodata:0x8011E5D8; // type:object size:0x40 lbl_8011E5D8 = .rodata:0x8011E5D8; // type:object size:0x40
fix_pool_sizes = .rodata:0x8011E618; // type:object size:0x18 scope:local data:4byte fix_pool_sizes = .rodata:0x8011E618; // type:object size:0x18 scope:local data:4byte
lbl_8011E630 = .rodata:0x8011E630; // type:object size:0xE0 lbl_8011E630 = .rodata:0x8011E630; // type:object size:0xE0 data:string
@stringBase0 = .rodata:0x8011E710; // type:object size:0x25 scope:local data:string_table @stringBase0 = .rodata:0x8011E710; // type:object size:0x25 scope:local data:string_table
Zero = .rodata:0x8011E738; // type:object size:0x10 scope:local Zero = .rodata:0x8011E738; // type:object size:0x10 scope:local
bp = .rodata:0x8011E748; // type:object size:0x10 scope:local data:double bp = .rodata:0x8011E748; // type:object size:0x10 scope:local data:double

View file

@ -227,6 +227,7 @@ cflags_thp = [
# Metrowerks library flags # Metrowerks library flags
cflags_msl = [ cflags_msl = [
*cflags_base, *cflags_base,
"-char signed",
"-use_lmw_stmw on", "-use_lmw_stmw on",
"-str reuse,pool,readonly", "-str reuse,pool,readonly",
"-common off", "-common off",
@ -676,47 +677,47 @@ config.libs = [
}, },
{ {
"lib": "MSL_C.PPCEABI.bare.H", "lib": "MSL_C.PPCEABI.bare.H",
"mw_version": config.linker_version, "mw_version": "GC/1.3",
"cflags": cflags_msl, "cflags": cflags_msl,
"host": False, "host": False,
"objects": [ "objects": [
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/abort_exit.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/abort_exit.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/alloc.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/alloc.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/errno.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/errno.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_files.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/ansi_files.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ansi_fp.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/ansi_fp.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/arith.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/arith.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/buffer_io.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/buffer_io.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/ctype.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/ctype.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/direct_io.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/direct_io.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/file_io.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/file_io.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/FILE_POS.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/FILE_POS.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/mbstring.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/mbstring.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/mem.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/mem.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/mem_funcs.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/mem_funcs.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/misc_io.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/misc_io.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/printf.c"), Object(NonMatching, "MSL_C.PPCEABI.bare.H/printf.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/float.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/float.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/signal.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/signal.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/string.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/string.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/uart_console_io.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/uart_console_io.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/wchar_io.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/wchar_io.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_acos.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_acos.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_asin.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_asin.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_atan2.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_atan2.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_fmod.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_fmod.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/e_pow.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_pow.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/e_rem_pio2.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/e_rem_pio2.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/k_cos.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/k_cos.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/k_rem_pio2.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/k_rem_pio2.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/k_sin.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/k_sin.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/k_tan.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/k_tan.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_atan.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_atan.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_copysign.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_copysign.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_cos.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_cos.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_floor.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_floor.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_frexp.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_frexp.c"),
Object(NonMatching, "MSL_C.PPCEABI.bare.H/s_ldexp.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_ldexp.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_modf.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_modf.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_sin.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_sin.c"),
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_tan.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "MSL_C.PPCEABI.bare.H/s_tan.c"),
@ -1080,7 +1081,7 @@ config.libs = [
objects={ objects={
Object(MatchingFor("GMPE01_00", "GMPE01_01"), "REL/m427Dll/main.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "REL/m427Dll/main.c"),
Object(NonMatching, "REL/m427Dll/map.c"), Object(NonMatching, "REL/m427Dll/map.c"),
Object(NonMatching, "REL/m427Dll/player.c"), Object(MatchingFor("GMPE01_00", "GMPE01_01"), "REL/m427Dll/player.c"),
}, },
), ),
Rel( Rel(

View file

@ -85,6 +85,7 @@ typedef struct _FILE {
file_modes file_mode; file_modes file_mode;
file_states file_state; file_states file_state;
unsigned char is_dynamically_allocated;
char char_buffer; char char_buffer;
char char_buffer_overflow; char char_buffer_overflow;
char ungetc_buffer[2]; char ungetc_buffer[2];
@ -104,19 +105,14 @@ typedef struct _FILE {
__io_proc write_fn; __io_proc write_fn;
__close_proc close_fn; __close_proc close_fn;
__idle_proc idle_fn; __idle_proc idle_fn;
struct _FILE* next_file_struct;
} FILE; } FILE;
typedef struct _files {
FILE _stdin;
FILE _stdout;
FILE _stderr;
} files;
#define _IONBF 0 #define _IONBF 0
#define _IOLBF 1 #define _IOLBF 1
#define _IOFBF 2 #define _IOFBF 2
extern files __files; extern FILE __files[];
extern int __close_console(__file_handle file); extern int __close_console(__file_handle file);
extern int __write_console(__file_handle file, unsigned char* buf, extern int __write_console(__file_handle file, unsigned char* buf,
size_t* count, __idle_proc idle_fn); size_t* count, __idle_proc idle_fn);

View file

@ -22,15 +22,6 @@ typedef struct decform {
short digits; short digits;
} decform; } decform;
/* void __ull2dec(decimal*, u64); void __num2dec(const decform* form, double x, decimal* d);
void __timesdec(decimal*, const decimal*, const decimal*);
void __str2dec(decimal*, const char*, short);
void __two_exp(decimal*, s16);
BOOL __equals_dec(const decimal*, const decimal*);
BOOL __less_dec(const decimal*, const decimal*);
void __minus_dec(decimal*, const decimal*, const decimal*);
void __num2dec_internal(decimal*, f64);
void __num2dec(const decform*, f64, decimal*);
f64 __dec2num(const decimal*); */
#endif #endif

View file

@ -6,8 +6,8 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/printf.h" // IWYU pragma: export #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/printf.h" // IWYU pragma: export
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/extras.h" // IWYU pragma: export #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/extras.h" // IWYU pragma: export
#define stdin (&__files._stdin) #define stdin (&__files[0])
#define stdout (&__files._stdout) #define stdout (&__files[1])
#define stderr (&__files._stderr) #define stderr (&__files[2])
#endif #endif

View file

@ -1,8 +1,16 @@
#include "dolphin.h" #include "dolphin.h"
#include "game/object.h" #include "game/object.h"
void fn_1_32F4(Process*); s32 fn_1_1788(void);
void fn_1_1798(s32 arg0, float arg8);
s32 fn_1_1884(void);
s32 fn_1_32EC(void);
void fn_1_32F4(Process* arg0);
void fn_1_3B20(s8 arg0, s16 arg1);
void fn_1_3A88(void); void fn_1_3A88(void);
void fn_1_91E0(s16 arg0, float arg8, float arg9, float argA, float argB);
float fn_1_AE78(s16 arg0, float arg8, float arg9);
void fn_1_E98C(Process*); void fn_1_E98C(Process*);
void fn_1_EC54(void); void fn_1_EC54(void);
s32 fn_1_10FE8(s16, s32*); s32 fn_1_10FE8(s16, s32*);

View file

@ -11,10 +11,7 @@ typedef struct particle_data ParticleData;
typedef void (*ParticleHook)(ModelData *model, ParticleData *particle, Mtx matrix); typedef void (*ParticleHook)(ModelData *model, ParticleData *particle, Mtx matrix);
typedef struct { typedef struct {
/* 0x00 */ union { /* 0x00 */ s16 unk00;
u16 unk00;
s16 unk00_s16;
};
/* 0x02 */ s16 unk02; /* 0x02 */ s16 unk02;
/* 0x04 */ s16 unk04; /* 0x04 */ s16 unk04;
/* 0x06 */ s16 unk06; /* 0x06 */ s16 unk06;

View file

@ -6,7 +6,7 @@
typedef struct model_data ModelData; typedef struct model_data ModelData;
typedef struct { typedef struct hsfdraw_struct_01 {
/* 0x00 */ u16 unk00; /* 0x00 */ u16 unk00;
/* 0x02 */ s16 unk02; /* 0x02 */ s16 unk02;
/* 0x04 */ s16 unk04; /* 0x04 */ s16 unk04;

View file

@ -99,7 +99,7 @@ typedef struct hsf_palette {
typedef struct hsf_attribute { typedef struct hsf_attribute {
char *name; char *name;
void *unk04; struct hsfdraw_struct_01 *unk04;
u8 unk8[4]; u8 unk8[4];
float unk0C; float unk0C;
u8 unk10[4]; u8 unk10[4];

View file

@ -10,7 +10,7 @@ char* strrchr(const char* str, int c);
char* strchr(const char* str, int c); char* strchr(const char* str, int c);
int strncmp(const char* str1, const char* str2, size_t n); int strncmp(const char* str1, const char* str2, size_t n);
int strcmp(const char* str1, const char* str2); int strcmp(const char* str1, const char* str2);
char* strcat(char* dst, const char* src); char* strcat(char* dst, const char* src, size_t n);
char* strncpy(char* dst, const char* src, size_t n); char* strncpy(char* dst, const char* src, size_t n);
char* strcpy(char* dst, const char* src); char* strcpy(char* dst, const char* src);
size_t strlen(const char* str); size_t strlen(const char* str);

View file

@ -0,0 +1,97 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h"
inline fpos_t _ftell(FILE* file) {
int charsInUndoBuffer = 0;
fpos_t position;
unsigned char tmp_kind = file->file_mode.file_kind;
if (!(tmp_kind == __disk_file || tmp_kind == __console_file) || file->file_state.error) {
errno = EFPOS;
return -1;
}
if (file->file_state.io_state == __neutral)
return (file->position);
position = file->buffer_position + (file->buffer_ptr - file->buffer);
if (file->file_state.io_state >= __rereading) {
charsInUndoBuffer = file->file_state.io_state - __rereading + 1;
position -= charsInUndoBuffer;
}
return (position);
}
long ftell(FILE* file) {
long retval;
retval = (long)_ftell(file);
return retval;
}
int _fseek(FILE* file, fpos_t offset, int file_mode) {
fpos_t position;
__pos_proc pos_proc;
unsigned char tmp_kind = file->file_mode.file_kind;
if (!(tmp_kind == __disk_file) || file->file_state.error) {
errno = EFPOS;
return (-1);
}
if (file->file_state.io_state == __writing) {
if (__flush_buffer(file, NULL) != __no_io_error) {
set_error(file);
errno = EFPOS;
return (-1);
}
}
if (file_mode == SEEK_CUR) {
file_mode = SEEK_SET;
if ((position = _ftell(file)) < 0)
position = 0;
offset += position;
}
if ((file_mode != SEEK_END) && (file->file_mode.io_mode != __read_write) &&
((file->file_state.io_state == __reading) || (file->file_state.io_state == __rereading)))
{
if (offset >= file->position || offset < file->buffer_position) {
file->file_state.io_state = __neutral;
} else {
file->buffer_ptr = file->buffer + (offset - file->buffer_position);
file->buffer_length = file->position - offset;
file->file_state.io_state = __reading;
}
} else {
file->file_state.io_state = __neutral;
}
if (file->file_state.io_state == __neutral) {
if ((pos_proc = file->position_fn) != NULL && pos_proc(file->handle, &offset, file_mode, file->idle_fn)) {
set_error(file);
errno = EFPOS;
return -1;
}
file->file_state.eof = 0;
file->position = offset;
file->buffer_length = 0;
}
return 0;
}
int fseek(FILE * file, long offset, int file_mode)
{
fpos_t real_offset = (fpos_t)offset;
int retval;
retval = _fseek(file, real_offset, file_mode);
return(retval);
}

410
src/MSL_C.PPCEABI.bare.H/alloc.c Executable file
View file

@ -0,0 +1,410 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/alloc.h"
typedef struct Block {
struct Block* prev;
struct Block* next;
unsigned long max_size;
unsigned long size;
} Block;
typedef struct SubBlock {
unsigned long size;
Block* block;
struct SubBlock* prev;
struct SubBlock* next;
} SubBlock;
struct FixSubBlock;
typedef struct FixBlock {
struct FixBlock* prev_;
struct FixBlock* next_;
unsigned long client_size_;
struct FixSubBlock* start_;
unsigned long n_allocated_;
} FixBlock;
typedef struct FixSubBlock {
FixBlock* block_;
struct FixSubBlock* next_;
} FixSubBlock;
typedef struct FixStart {
FixBlock* tail_;
FixBlock* head_;
} FixStart;
typedef struct __mem_pool_obj {
Block* start_;
FixStart fix_start[6];
} __mem_pool_obj;
typedef struct __mem_pool {
void* reserved[14];
} __mem_pool;
typedef signed long tag_word;
typedef struct block_header {
tag_word tag;
struct block_header * prev;
struct block_header * next;
} block_header;
typedef struct list_header {
block_header * rover;
block_header header;
} list_header;
typedef struct heap_header {
struct heap_header* prev;
struct heap_header* next;
} heap_header;
struct mem_pool_obj;
typedef void * (*sys_alloc_ptr)(unsigned long, struct mem_pool_obj*);
typedef void (*sys_free_ptr)(void *, struct mem_pool_obj*);
typedef struct pool_options{
sys_alloc_ptr sys_alloc_func;
sys_free_ptr sys_free_func;
unsigned long min_heap_size;
int always_search_first;
} pool_options;
typedef struct mem_pool_obj {
list_header free_list;
pool_options options;
heap_header* heap_list;
void* userData;
} mem_pool_obj;
mem_pool_obj __malloc_pool;
static int initialized = 0;
static SubBlock* SubBlock_merge_prev(SubBlock*, SubBlock**);
static void SubBlock_merge_next(SubBlock* , SubBlock** );
static const unsigned long fix_pool_sizes[] = {4, 12, 20, 36, 52, 68};
#define SubBlock_size(ths) ((ths)->size & 0xFFFFFFF8)
#define SubBlock_block(ths) ((Block*)((unsigned long)((ths)->block) & ~0x1))
#define Block_size(ths) ((ths)->size & 0xFFFFFFF8)
#define Block_start(ths) (*(SubBlock**)((char*)(ths) + Block_size((ths)) - sizeof(unsigned long)))
#define SubBlock_set_free(ths) \
unsigned long this_size = SubBlock_size((ths)); \
(ths)->size &= ~0x2; \
*(unsigned long*)((char*)(ths) + this_size) &= ~0x4; \
*(unsigned long*)((char*)(ths) + this_size - sizeof(unsigned long)) = this_size
#define SubBlock_is_free(ths) !((ths)->size & 2)
#define SubBlock_set_size(ths, sz) \
(ths)->size &= ~0xFFFFFFF8; \
(ths)->size |= (sz) & 0xFFFFFFF8; \
if (SubBlock_is_free((ths))) \
*(unsigned long*)((char*)(ths) + (sz) - sizeof(unsigned long)) = (sz)
#define SubBlock_from_pointer(ptr) ((SubBlock*)((char*)(ptr) - 8))
#define FixSubBlock_from_pointer(ptr) ((FixSubBlock*)((char*)(ptr) - 4))
#define FixBlock_client_size(ths) ((ths)->client_size_)
#define FixSubBlock_size(ths) (FixBlock_client_size((ths)->block_))
#define classify(ptr) (*(unsigned long*)((char*)(ptr) - sizeof(unsigned long)) & 1)
#define __msize_inline(ptr) (!classify(ptr) ? FixSubBlock_size(FixSubBlock_from_pointer(ptr)) : SubBlock_size(SubBlock_from_pointer(ptr)) - 8)
#define Block_empty(ths) \
(_sb = (SubBlock*)((char*)(ths) + 16)), \
SubBlock_is_free(_sb) && SubBlock_size(_sb) == Block_size((ths)) - 24
//unused
void Block_subBlock(){
}
void Block_link(Block* ths, SubBlock* sb) {
SubBlock** st;
SubBlock_set_free(sb);
st = &Block_start(ths);
if (*st != 0)
{
sb->prev = (*st)->prev;
sb->prev->next = sb;
sb->next = *st;
(*st)->prev = sb;
*st = sb;
*st = SubBlock_merge_prev(*st, st);
SubBlock_merge_next(*st, st);
}
else
{
*st = sb;
sb->prev = sb;
sb->next = sb;
}
if (ths->max_size < SubBlock_size(*st))
ths->max_size = SubBlock_size(*st);
}
static SubBlock* SubBlock_merge_prev(SubBlock *ths, SubBlock **start) {
unsigned long prevsz;
SubBlock* p;
if (!(ths->size & 0x04))
{
prevsz = *(unsigned long*)((char*)ths - sizeof(unsigned long));
if (prevsz & 0x2)
return ths;
p = (SubBlock*)((char*)ths - prevsz);
SubBlock_set_size(p, prevsz + SubBlock_size(ths));
if (*start == ths)
*start = (*start)->next;
ths->next->prev = ths->prev;
ths->next->prev->next = ths->next;
return p;
}
return ths;
}
static void SubBlock_merge_next(SubBlock *pBlock, SubBlock **pStart) {
SubBlock* next_sub_block;
unsigned long this_cur_size;
next_sub_block = (SubBlock*)((char*)pBlock + (pBlock->size & 0xFFFFFFF8));
if (!(next_sub_block->size & 2)) {
this_cur_size = (pBlock->size & 0xFFFFFFF8) + (next_sub_block->size & 0xFFFFFFF8);
pBlock->size &= ~0xFFFFFFF8;
pBlock->size |= this_cur_size & 0xFFFFFFF8;
if (!(pBlock->size & 2)) {
*(unsigned long*)((char*)(pBlock) + (this_cur_size) - 4) = (this_cur_size);
}
if (!(pBlock->size & 2)) {
*(unsigned long *)((char*)pBlock + this_cur_size) &= ~4;
}
else {
*(unsigned long *)((char*)pBlock + this_cur_size) |= 4;
}
if (*pStart == next_sub_block) {
*pStart = (*pStart)->next;
}
if (*pStart == next_sub_block) {
*pStart = 0;
}
next_sub_block->next->prev = next_sub_block->prev;
next_sub_block->prev->next = next_sub_block->next;
}
}
static Block* __unlink(__mem_pool_obj* pool_obj, Block* bp) {
Block* result = bp->next;
if (result == bp) {
result = 0;
}
if (pool_obj->start_ == bp) {
pool_obj->start_ = result;
}
if (result != 0) {
result->prev = bp->prev;
result->prev->next = result;
}
bp->next = 0;
bp->prev = 0;
return result;
}
//unused
void allocate_from_var_pools(){
}
//unused
void soft_allocate_from_var_pools(){
}
static void deallocate_from_var_pools(__mem_pool_obj* pool_obj, void *ptr) {
SubBlock* sb = SubBlock_from_pointer(ptr);
SubBlock* _sb;
Block* bp = SubBlock_block(sb);
Block_link(bp, sb);
if (Block_empty(bp)) {
__unlink(pool_obj, bp);
__sys_free(bp);
}
}
//unused
void FixBlock_construct(){
}
void __init_pool_obj(__mem_pool* pool_obj) {
memset(pool_obj, 0, sizeof(__mem_pool_obj));
}
static __mem_pool* get_malloc_pool(void) {
static __mem_pool protopool;
static unsigned char init = 0;
if (!init) {
__init_pool_obj(&protopool);
init = 1;
}
return &protopool;
}
//unused
void allocate_from_fixed_pools(){
}
void deallocate_from_fixed_pools(__mem_pool_obj* pool_obj, void* ptr, unsigned long size) {
unsigned long i = 0;
FixSubBlock* p;
FixBlock* b;
FixStart* fs;
while (size > fix_pool_sizes[i]) {
++i;
}
fs = &pool_obj->fix_start[i];
p = FixSubBlock_from_pointer(ptr);
b = p->block_;
if (b->start_ == 0 && fs->head_ != b) {
if (fs->tail_ == b) {
fs->head_ = fs->head_->prev_;
fs->tail_ = fs->tail_->prev_;
}
else {
b->prev_->next_ = b->next_;
b->next_->prev_ = b->prev_;
b->next_ = fs->head_;
b->prev_ = b->next_->prev_;
b->prev_->next_ = b;
b->next_->prev_ = b;
fs->head_ = b;
}
}
p->next_ = b->start_;
b->start_ = p;
if (--b->n_allocated_ == 0) {
if (fs->head_ == b) {
fs->head_ = b->next_;
}
if (fs->tail_ == b) {
fs->tail_ = b->prev_;
}
b->prev_->next_ = b->next_;
b->next_->prev_ = b->prev_;
if (fs->head_ == b) {
fs->head_ = 0;
}
if (fs->tail_ == b) {
fs->tail_ = 0;
}
deallocate_from_var_pools(pool_obj, b);
}
}
//unused
void __pool_allocate_resize(){
}
//unused
void __msize(){
}
//unused
void __pool_alloc(){
}
//unused
void __allocate_size(){
}
//unused
void __allocate(){
}
//unused
void __allocate_resize(){
}
//unused
void __allocate_expand(){
}
void __pool_free(__mem_pool *pool, void *ptr) {
__mem_pool_obj* pool_obj;
unsigned long size;
if (ptr == 0) {
return;
}
pool_obj = (__mem_pool_obj*)pool;
size = __msize_inline(ptr);
if (size <= 68) {
deallocate_from_fixed_pools(pool_obj, ptr, size);
}
else {
deallocate_from_var_pools(pool_obj, ptr);
}
}
//unused
void __pool_realloc(){
}
//unused
void __pool_alloc_clear(){
}
//unused
void malloc(){
}
void free(void *ptr) {
__pool_free(get_malloc_pool(), ptr);
}
//unused
void realloc(){
}
//unused
void calloc(){
}
//unused
void __pool_free_all(){
}
//unused
void __malloc_free_all(){
}

View file

@ -1,95 +1,111 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/file_io.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/file_io.h"
extern files __files = { static unsigned char stdin_buff[0x100];
{ static unsigned char stdout_buff[0x100];
0, static unsigned char stderr_buff[0x100];
0,
1, FILE __files[4] = {
0, {0,
2, {0, 1, 1, 2, 0},
0, {0, 0, 0, 0},
0,
0,
0,
0,
0, 0,
0, 0,
0, 0,
{0, 0}, {0, 0},
{0, 0}, {0, 0},
0, 0,
(unsigned char*)&__files._stdin.char_buffer, stdin_buff,
1, sizeof(stdin_buff),
(unsigned char*)&__files._stdin.char_buffer, stdin_buff,
0, 0,
0, 0,
0, 0,
0, 0,
NULL, NULL,
__read_console, &__read_console,
__write_console, &__write_console,
__close_console, &__close_console,
NULL,
},
{
0,
0,
2,
0,
2,
0,
0,
0,
0,
0, 0,
&__files[1]},
{1,
{0, 2, 1, 2, 0},
{0, 0, 0, 0},
0, 0,
0, 0,
0, 0,
{0, 0}, {0, 0},
{0, 0}, {0, 0},
0, 0,
(unsigned char*)&__files._stdout.char_buffer, stdout_buff,
1, sizeof(stdout_buff),
(unsigned char*)&__files._stdout.char_buffer, stdout_buff,
0, 0,
0, 0,
0, 0,
0, 0,
NULL, NULL,
__read_console, &__read_console,
__write_console, &__write_console,
__close_console, &__close_console,
NULL,
},
{
0,
0,
2,
0,
2,
0,
0,
0,
0,
0, 0,
&__files[2]},
{2,
{0, 2, 0, 2, 0},
{0, 0, 0, 0},
0, 0,
0, 0,
0, 0,
{0, 0}, {0, 0},
{0, 0}, {0, 0},
0, 0,
(unsigned char*)&__files._stderr.char_buffer, stderr_buff,
1, sizeof(stderr_buff),
(unsigned char*)&__files._stderr.char_buffer, stderr_buff,
0, 0,
0, 0,
0, 0,
0, 0,
NULL, NULL,
__read_console, &__read_console,
__write_console, &__write_console,
__close_console, &__close_console,
NULL, 0,
}, &__files[3]},
}; };
void __close_all() {
FILE* p = &__files[0];
FILE* plast;
while (p != NULL) {
if (p->file_mode.file_kind != __closed_file) {
fclose(p);
}
plast = p;
p = p->next_file_struct;
if (plast->is_dynamically_allocated)
free(plast);
else {
plast->file_mode.file_kind = __string_file;
if ((p != NULL) && p->is_dynamically_allocated)
plast->next_file_struct = NULL;
}
}
}
unsigned int __flush_all() {
unsigned int retval = 0;
FILE* __stream;
__stream = &__files[0];
while (__stream) {
if ((__stream->file_mode.file_kind) && (fflush(__stream))) {
retval = -1;
}
__stream = __stream->next_file_struct;
};
return retval;
}

View file

@ -0,0 +1,393 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_fp.h"
static int __count_trailing_zerol(unsigned int arg0) {
int var_r4;
int var_r5;
int var_r6;
int var_r7;
unsigned int var_r8;
var_r5 = 0x20;
var_r8 = 0xFFFF;
var_r6 = 0x10;
var_r4 = 0;
var_r7 = 0x10;
while (var_r5 != 0) {
if (!(arg0 & var_r8)) {
var_r4 += var_r7;
arg0 >>= var_r7;
var_r5 -= var_r7;
} else if (var_r8 == 1) {
break;
}
if (var_r6 > 1) {
var_r6 /= 2;
}
if (var_r8 > 1) {
var_r8 >>= var_r6;
var_r7 -= var_r6;
}
}
return var_r4;
}
static inline int __count_trailing_zero(double n){
if (__LO(n) != 0U) {
return __count_trailing_zerol(__LO(n));
} else {
return 32 + __count_trailing_zerol(__HI(n) | 0x100000);
}
}
static void __ull2dec(decimal* result, unsigned long long val) {
result->sign = 0;
if (val == 0) {
result->exp = 0;
result->sig.length = 1;
result->sig.text[0] = 0;
return;
}
result->sig.length = 0;
for(; val != 0; val /= 10) {
result->sig.text[result->sig.length++] = val % 10;
}
{
unsigned char* i = result->sig.text;
unsigned char* j = result->sig.text + result->sig.length;
for (; i < --j; ++i) {
unsigned char t = *i;
*i = *j;
*j = t;
}
}
result->exp = result->sig.length - 1;
}
static inline void __dorounddecup(decimal* d, int digits){
unsigned char* b = d->sig.text;
unsigned char* i = b + digits - 1;
while(1){
if (*i < 9) {
*i += 1;
break;
}
if (i == b) {
*i = 1;
d->exp++;
break;
}
*i-- = 0;
}
}
static void __timesdec(decimal* result, const decimal* x, const decimal* y) {
unsigned int accumulator = 0;
unsigned char mantissa[SIGDIGLEN * 2];
int i = x->sig.length + y->sig.length - 1;
unsigned char* pDigit;
unsigned char* ip = mantissa + i + 1;
unsigned char* ep = ip;
result->sign = 0;
for(; i > 0; i--) {
int k = y->sig.length - 1;
int j = i - k - 1;
int l;
int t;
const unsigned char* jp;
const unsigned char* kp;
if (j < 0) {
j = 0;
k = i - 1;
}
jp = x->sig.text + j;
kp = y->sig.text + k;
l = k + 1;
t = x->sig.length - j;
if (l > t) l = t;
for (; l > 0; l--, jp++, kp--) {
accumulator += *jp * *kp;
}
*--ip = accumulator % 10;
accumulator /= 10;
}
result->exp = (short)(x->exp + y->exp);
if (accumulator) {
*--ip = accumulator;
result->exp++;
}
for (i = 0; i < SIGDIGLEN && ip < ep; i++, ip++) {
result->sig.text[i] = *ip;
}
result->sig.length = i;
if (ip < ep && *ip >= 5){
if (*ip == 5){
unsigned char* jp = ip + 1;
for (; jp < ep; jp++) {
if (*jp != 0) goto round;
}
if ((ip[-1] & 1) == 0) return;
}
round:
__dorounddecup(result, result->sig.length);
}
}
static void __str2dec(decimal* d, const signed char* s, short exp) {
int i;
d->exp = exp;
d->sign = 0;
for (i = 0; i < SIGDIGLEN && *s; ) {
d->sig.text[i++] = *s++ - '0';
}
d->sig.length = i;
if (*s != 0 && *s >= 5) {
const signed char* p = s + 1;
for (; *p != 0; p++) {
if (*p != '0') goto round;
}
if ((d->sig.text[i - 1] & 1) == 0) return;
round:
__dorounddecup(d, d->sig.length);
}
}
// TODO: ideally, these strings should be used as literals in the function below.
// However, the first one (179769313486231580793729011405303420, corresponding to
// 2^1024) is not used in the function and messes up alignment.
const signed char lbl_8011E630[] =
"179769313486231580793729011405303420\000" \
"542101086242752217003726400434970855712890625\000" \
"11102230246251565404236316680908203125\000" \
"23283064365386962890625\000" \
"152587890625\000" \
"390625\000" \
"78125\000" \
"15625\000" \
"3125\000" \
"625\000" \
"125\000" \
"25\000" \
"5\000" \
"1\000" \
"2\000" \
"4\000" \
"8\000" \
"16\000" \
"32\000" \
"64\000" \
"128\000" \
"256";
static void __two_exp(decimal* result, short exp) {
decimal sp8C;
decimal sp60;
decimal sp34;
decimal sp8;
switch (exp) {
case -64:
__str2dec(result, lbl_8011E630 + 0x25, -20);
break;
case -53:
__str2dec(result, lbl_8011E630 + 0x53, -16);
break;
case -32:
__str2dec(result, lbl_8011E630 + 0x7A, -10);
break;
case -16:
__str2dec(result, lbl_8011E630 + 0x92, -5);
break;
case -8:
__str2dec(result, lbl_8011E630 + 0x9F, -3);
break;
case -7:
__str2dec(result, lbl_8011E630 + 0xA6, -3);
break;
case -6:
__str2dec(result, lbl_8011E630 + 0xAC, -2);
break;
case -5:
__str2dec(result, lbl_8011E630 + 0xB2, -2);
break;
case -4:
__str2dec(result, lbl_8011E630 + 0xB7, -2);
break;
case -3:
__str2dec(result, lbl_8011E630 + 0xBB, -1);
break;
case -2:
__str2dec(result, lbl_8011E630 + 0xBF, -1);
break;
case -1:
__str2dec(result, lbl_8011E630 + 0xC2, -1);
break;
case 0:
__str2dec(result, lbl_8011E630 + 0xC4, 0);
break;
case 1:
__str2dec(result, lbl_8011E630 + 0xC6, 0);
break;
case 2:
__str2dec(result, lbl_8011E630 + 0xC8, 0);
break;
case 3:
__str2dec(result, lbl_8011E630 + 0xCA, 0);
break;
case 4:
__str2dec(result, lbl_8011E630 + 0xCC, 1);
break;
case 5:
__str2dec(result, lbl_8011E630 + 0xCF, 1);
break;
case 6:
__str2dec(result, lbl_8011E630 + 0xD2, 1);
break;
case 7:
__str2dec(result, lbl_8011E630 + 0xD5, 2);
break;
case 8:
__str2dec(result, lbl_8011E630 + 0xD9, 2);
break;
default:
__two_exp(&sp8C, exp / 2);
__timesdec(result, &sp8C, &sp8C);
if (exp & 1) {
sp60 = *result;
if (exp > 0) {
__str2dec(&sp34, lbl_8011E630 + 0xC6, 0);
__timesdec(result, &sp60, &sp34);
} else {
__str2dec(&sp8, lbl_8011E630 + 0xC2, -1);
__timesdec(result, &sp60, &sp8);
}
}
break;
}
}
static void __num2dec_internal(decimal* d, double x) {
signed char sign = (signbit(x) != 0);
if (x == 0) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
d->sig.text[0] = 0;
return;
}
if (!isfinite(x)) {
d->sign = sign;
d->exp = 0;
d->sig.length = 1;
d->sig.text[0] = (fpclassify(x) == 1) ? 'N' : 'I';
return;
}
if (sign != 0) {
x = -x;
}
{
int exp;
double frac = frexp(x, &exp);
short num_bits_extract = DBL_MANT_DIG - __count_trailing_zero(frac);
decimal int_d, pow2_d;
double sp30;
__two_exp(&pow2_d, exp - num_bits_extract);
modf(ldexp(frac, num_bits_extract), &sp30);
__ull2dec(&int_d, sp30);
__timesdec(d, &int_d, &pow2_d);
d->sign = sign;
}
}
static inline int __must_round(const decimal* d, int digits){
unsigned char const* i = d->sig.text + digits;
if (*i > 5) {
return 1;
}
if (*i < 5) {
return -1;
}
{
unsigned char const* e = d->sig.text + d->sig.length;
for(i++; i < e; i++){
if (*i != 0) {
return 1;
}
}
}
if (d->sig.text[digits - 1] & 1) {
return 1;
}
return -1;
}
static inline void __rounddec(decimal* d, int digits){
if (digits > 0 && digits < d->sig.length) {
int unkBool = __must_round(d,digits);
d->sig.length = digits;
if (unkBool >= 0) {
__dorounddecup(d, digits);
}
}
}
void __num2dec(const decform* form, double x, decimal* d) {
short digits = form->digits;
int i;
__num2dec_internal(d, x);
if (d->sig.text[0] > 9) {
return;
}
if (digits > SIGDIGLEN) {
digits = SIGDIGLEN;
}
__rounddec(d, digits);
while(d->sig.length < digits){
d->sig.text[d->sig.length++] = 0;
}
d->exp -= d->sig.length - 1;
for(i = 0; i < d->sig.length; i++) {
d->sig.text[i] += '0';
}
}

View file

@ -0,0 +1,13 @@
int abs(int n) {
if (n < 0)
return (-n);
else
return (n);
}
long labs(long n) {
if (n < 0)
return (-n);
else
return (n);
}

View file

@ -1,84 +1,84 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/direct_io.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/direct_io.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/buffer_io.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/misc_io.h"
#include "string.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/wchar_io.h"
size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream) size_t fwrite(const void* ptr, size_t memb_size, size_t num_memb, FILE* file) {
{ size_t retval;
retval = __fwrite(ptr, memb_size, num_memb, file);
return (retval);
}
size_t __fwrite(const void* ptr, size_t memb_size, size_t num_memb, FILE* file) {
unsigned char* write_ptr; unsigned char* write_ptr;
size_t num_bytes, bytes_to_go, bytes_written; size_t num_bytes, bytes_to_go, bytes_written;
int ioresult, always_buffer; int ioresult, always_buffer;
if (fwide(stream, 0) == 0) #ifndef __NO_WIDE_CHAR
fwide(stream, -1); if (fwide(file, 0) == 0)
fwide(file, -1);
#endif
bytes_to_go = size * count; bytes_to_go = memb_size * num_memb;
if (!bytes_to_go || stream->file_state.error if (!bytes_to_go || file->file_state.error || file->file_mode.file_kind == __closed_file)
|| stream->file_mode.file_kind == __closed_file)
return 0; return 0;
if ((int)stream->file_mode.file_kind == __console_file) if (file->file_mode.file_kind == __console_file)
__stdio_atexit(); __stdio_atexit();
always_buffer = !stream->file_mode.binary_io always_buffer =
|| (int)stream->file_mode.file_kind == __string_file !file->file_mode.binary_io || file->file_mode.buffer_mode == _IOFBF || file->file_mode.buffer_mode == _IOLBF;
|| stream->file_mode.buffer_mode == _IOFBF
|| stream->file_mode.buffer_mode == _IOLBF;
if (stream->file_state.io_state == __neutral) { if (file->file_state.io_state == __neutral) {
if (stream->file_mode.io_mode & __write) { if (file->file_mode.io_mode & __write) {
stream->file_state.io_state = __writing; if (file->file_mode.io_mode & __append) {
if (fseek(file, 0, SEEK_END))
return 0;
}
file->file_state.io_state = __writing;
__prep_buffer(stream); __prep_buffer(file);
} }
} }
if (stream->file_state.io_state != __writing) { if (file->file_state.io_state != __writing) {
set_error(stream); set_error(file);
return 0; return 0;
} }
write_ptr = (unsigned char*)buffer; write_ptr = (unsigned char*)ptr;
bytes_written = 0; bytes_written = 0;
if (bytes_to_go if (bytes_to_go && (file->buffer_ptr != file->buffer || always_buffer)) {
&& (stream->buffer_ptr != stream->buffer || always_buffer)) { file->buffer_length = file->buffer_size - (file->buffer_ptr - file->buffer);
stream->buffer_length
= stream->buffer_size - (stream->buffer_ptr - stream->buffer);
do { do {
unsigned char* newline = NULL; unsigned char* newline = NULL;
num_bytes = stream->buffer_length; num_bytes = file->buffer_length;
if (num_bytes > bytes_to_go) if (num_bytes > bytes_to_go)
num_bytes = bytes_to_go; num_bytes = bytes_to_go;
if (file->file_mode.buffer_mode == _IOLBF && num_bytes)
if ((newline = (unsigned char*)__memrchr(write_ptr, '\n', num_bytes)) != NULL)
num_bytes = newline + 1 - write_ptr;
if (num_bytes) { if (num_bytes) {
memcpy(stream->buffer_ptr, write_ptr, num_bytes); memcpy(file->buffer_ptr, write_ptr, num_bytes);
write_ptr += num_bytes; write_ptr += num_bytes;
bytes_written += num_bytes; bytes_written += num_bytes;
bytes_to_go -= num_bytes; bytes_to_go -= num_bytes;
stream->buffer_ptr += num_bytes; file->buffer_ptr += num_bytes;
stream->buffer_length -= num_bytes; file->buffer_length -= num_bytes;
} }
if (!file->buffer_length || newline != NULL ||
if (!stream->buffer_length (file->file_mode.buffer_mode == _IONBF))
&& (int)stream->file_mode.file_kind == __string_file) { {
bytes_written += bytes_to_go; ioresult = __flush_buffer(file, NULL);
break;
}
if (!stream->buffer_length || newline != NULL
|| (stream->file_mode.buffer_mode == _IONBF)) {
ioresult = __flush_buffer(stream, NULL);
if (ioresult) { if (ioresult) {
set_error(stream); set_error(file);
bytes_to_go = 0; bytes_to_go = 0;
break; break;
} }
@ -87,28 +87,28 @@ size_t fwrite(const void* buffer, size_t size, size_t count, FILE* stream)
} }
if (bytes_to_go && !always_buffer) { if (bytes_to_go && !always_buffer) {
unsigned char* save_buffer = stream->buffer; unsigned char* save_buffer = file->buffer;
size_t save_size = stream->buffer_size; size_t save_size = file->buffer_size;
stream->buffer = write_ptr; file->buffer = write_ptr;
stream->buffer_size = bytes_to_go; file->buffer_size = bytes_to_go;
stream->buffer_ptr = write_ptr + bytes_to_go; file->buffer_ptr = write_ptr + bytes_to_go;
if (__flush_buffer(stream, &num_bytes) != __no_io_error) if (__flush_buffer(file, &num_bytes) != __no_io_error)
set_error(stream); set_error(file);
bytes_written += num_bytes; bytes_written += num_bytes;
stream->buffer = save_buffer; file->buffer = save_buffer;
stream->buffer_size = save_size; file->buffer_size = save_size;
__prep_buffer(stream); __prep_buffer(file);
stream->buffer_length = 0; file->buffer_length = 0;
} }
if (stream->file_mode.buffer_mode != _IOFBF) if (file->file_mode.buffer_mode != _IOFBF)
stream->buffer_length = 0; file->buffer_length = 0;
return ((bytes_written + size - 1) / size); return ((bytes_written + memb_size - 1) / memb_size);
} }

View file

@ -1,5 +1,5 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#include "math.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math.h"
#ifdef __STDC__ #ifdef __STDC__
static const double static const double

View file

@ -1,5 +1,5 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#include "math.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math.h"
#ifdef __STDC__ #ifdef __STDC__
static const double static const double

View file

@ -57,7 +57,7 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h"
#include "math.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math.h"
#ifdef __STDC__ #ifdef __STDC__
static const double static const double
@ -302,7 +302,7 @@ ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
z = one-(r-z); z = one-(r-z);
j = __HI(z); j = __HI(z);
j += (n<<20); j += (n<<20);
if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */ if((j>>20)<=0) z = ldexp(z,n); /* subnormal output */
else __HI(z) += (n<<20); else __HI(z) += (n<<20);
return s*z; return s*z;
} }

View file

@ -0,0 +1,175 @@
/* @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*
*/
/* __ieee754_rem_pio2(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
* use __kernel_rem_pio2()
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math.h"
/*
* Table of constants for 2/pi, 396 Hex digits (476 decimal) of 2/pi
*/
#ifdef __STDC__
static const int two_over_pi[] = {
#else
static int two_over_pi[] = {
#endif
0xA2F983, 0x6E4E44, 0x1529FC, 0x2757D1, 0xF534DD, 0xC0DB62,
0x95993C, 0x439041, 0xFE5163, 0xABDEBB, 0xC561B7, 0x246E3A,
0x424DD2, 0xE00649, 0x2EEA09, 0xD1921C, 0xFE1DEB, 0x1CB129,
0xA73EE8, 0x8235F5, 0x2EBB44, 0x84E99C, 0x7026B4, 0x5F7E41,
0x3991D6, 0x398353, 0x39F49C, 0x845F8B, 0xBDF928, 0x3B1FF8,
0x97FFDE, 0x05980F, 0xEF2F11, 0x8B5A0A, 0x6D1F6D, 0x367ECF,
0x27CB09, 0xB74F46, 0x3F669E, 0x5FEA2D, 0x7527BA, 0xC7EBE5,
0xF17B3D, 0x0739F7, 0x8A5292, 0xEA6BFB, 0x5FB11F, 0x8D5D08,
0x560330, 0x46FC7B, 0x6BABF0, 0xCFBC20, 0x9AF436, 0x1DA9E3,
0x91615E, 0xE61B08, 0x659985, 0x5F14A0, 0x68408D, 0xFFD880,
0x4D7327, 0x310606, 0x1556CA, 0x73A8C9, 0x60E27B, 0xC08C6B,
};
#ifdef __STDC__
static const int npio2_hw[] = {
#else
static int npio2_hw[] = {
#endif
0x3FF921FB, 0x400921FB, 0x4012D97C, 0x401921FB, 0x401F6A7A, 0x4022D97C,
0x4025FDBB, 0x402921FB, 0x402C463A, 0x402F6A7A, 0x4031475C, 0x4032D97C,
0x40346B9C, 0x4035FDBB, 0x40378FDB, 0x403921FB, 0x403AB41B, 0x403C463A,
0x403DD85A, 0x403F6A7A, 0x40407E4C, 0x4041475C, 0x4042106C, 0x4042D97C,
0x4043A28C, 0x40446B9C, 0x404534AC, 0x4045FDBB, 0x4046C6CB, 0x40478FDB,
0x404858EB, 0x404921FB,
};
/*
* invpio2: 53 bits of 2/pi
* pio2_1: first 33 bit of pi/2
* pio2_1t: pi/2 - pio2_1
* pio2_2: second 33 bit of pi/2
* pio2_2t: pi/2 - (pio2_1+pio2_2)
* pio2_3: third 33 bit of pi/2
* pio2_3t: pi/2 - (pio2_1+pio2_2+pio2_3)
*/
#ifdef __STDC__
static const double
#else
static double
#endif
zero = 0.00000000000000000000e+00, /* 0x00000000, 0x00000000 */
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
invpio2 = 6.36619772367581382433e-01, /* 0x3FE45F30, 0x6DC9C883 */
pio2_1 = 1.57079632673412561417e+00, /* 0x3FF921FB, 0x54400000 */
pio2_1t = 6.07710050650619224932e-11, /* 0x3DD0B461, 0x1A626331 */
pio2_2 = 6.07710050630396597660e-11, /* 0x3DD0B461, 0x1A600000 */
pio2_2t = 2.02226624879595063154e-21, /* 0x3BA3198A, 0x2E037073 */
pio2_3 = 2.02226624871116645580e-21, /* 0x3BA3198A, 0x2E000000 */
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
#ifdef __STDC__
int __ieee754_rem_pio2(double x, double *y)
#else
int __ieee754_rem_pio2(x,y)
double x,y[];
#endif
{
double z,w,t,r,fn;
double tx[3];
int e0,i,j,nx,n,ix,hx;
hx = __HI(x); /* high word of x */
ix = hx&0x7fffffff;
if(ix<=0x3fe921fb) /* |x| ~<= pi/4 , no need for reduction */
{y[0] = x; y[1] = 0; return 0;}
if(ix<0x4002d97c) { /* |x| < 3pi/4, special case with n=+-1 */
if(hx>0) {
z = x - pio2_1;
if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */
y[0] = z - pio2_1t;
y[1] = (z-y[0])-pio2_1t;
} else { /* near pi/2, use 33+33+53 bit pi */
z -= pio2_2;
y[0] = z - pio2_2t;
y[1] = (z-y[0])-pio2_2t;
}
return 1;
} else { /* negative x */
z = x + pio2_1;
if(ix!=0x3ff921fb) { /* 33+53 bit pi is good enough */
y[0] = z + pio2_1t;
y[1] = (z-y[0])+pio2_1t;
} else { /* near pi/2, use 33+33+53 bit pi */
z += pio2_2;
y[0] = z + pio2_2t;
y[1] = (z-y[0])+pio2_2t;
}
return -1;
}
}
if(ix<=0x413921fb) { /* |x| ~<= 2^19*(pi/2), medium size */
t = fabs(x);
n = (int) (t*invpio2+half);
fn = (double)n;
r = t-fn*pio2_1;
w = fn*pio2_1t; /* 1st round good to 85 bit */
if(n<32&&ix!=npio2_hw[n-1]) {
y[0] = r-w; /* quick check no cancellation */
} else {
j = ix>>20;
y[0] = r-w;
i = j-(((__HI(y[0]))>>20)&0x7ff);
if(i>16) { /* 2nd iteration needed, good to 118 */
t = r;
w = fn*pio2_2;
r = t-w;
w = fn*pio2_2t-((t-r)-w);
y[0] = r-w;
i = j-(((__HI(y[0]))>>20)&0x7ff);
if(i>49) { /* 3rd iteration need, 151 bits acc */
t = r; /* will cover all possible cases */
w = fn*pio2_3;
r = t-w;
w = fn*pio2_3t-((t-r)-w);
y[0] = r-w;
}
}
}
y[1] = (r-y[0])-w;
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
else return n;
}
/*
* all other (large) arguments
*/
if(ix>=0x7ff00000) { /* x is inf or NaN */
y[0]=y[1]=x-x; return 0;
}
/* set z = scalbn(|x|,ilogb(x)-23) */
__LO(z) = __LO(x);
e0 = (ix>>20)-1046; /* e0 = ilogb(z)-23; */
__HI(z) = ix - (e0<<20);
for(i=0;i<2;i++) {
tx[i] = (double)((int)(z));
z = (z-tx[i])*two24;
}
tx[2] = z;
nx = 3;
while(tx[nx-1]==zero) nx--; /* skip zero term */
n = __kernel_rem_pio2(tx,y,e0,nx,2,two_over_pi);
if(hx<0) {y[0] = -y[0]; y[1] = -y[1]; return -n;}
return n;
}

View file

@ -0,0 +1,58 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/file_io.h"
int fclose(FILE* file) {
int flush_result, close_result;
if (file == NULL) {
return -1;
}
if (file->file_mode.file_kind == __closed_file) {
return 0;
}
flush_result = fflush(file);
close_result = file->close_fn(file->handle);
file->file_mode.file_kind = __closed_file;
file->handle = NULL;
if (file->file_state.free_buffer) {
free(file->buffer);
}
return (flush_result || close_result) ? -1 : 0;
}
int fflush(FILE* file) {
unsigned long pos;
if (file == NULL) {
return __flush_all();
}
if (file->file_state.error != 0 || file->file_mode.file_kind == __closed_file) {
return -1;
}
if (file->file_mode.io_mode == __read) {
return 0;
}
if (file->file_state.io_state >= __rereading) {
file->file_state.io_state = __reading;
}
if (file->file_state.io_state == __reading) {
file->buffer_length = 0;
}
if (file->file_state.io_state != __writing) {
file->file_state.io_state = __neutral;
return 0;
}
if (file->file_mode.file_kind != __disk_file) {
pos = 0;
} else {
pos = ftell(file);
}
if (__flush_buffer(file, 0) != __no_io_error) {
file->file_state.error = 1;
file->buffer_length = 0;
return -1;
}
file->file_state.io_state = __neutral;
file->position = pos;
file->buffer_length = 0;
return 0;
}

View file

@ -0,0 +1,91 @@
/* @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* __kernel_cos( x, y )
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
* Input x is assumed to be bounded by ~pi/4 in magnitude.
* Input y is the tail of x.
*
* Algorithm
* 1. Since cos(-x) = cos(x), we need only to consider positive x.
* 2. if x < 2^-27 (hx<0x3e400000 0), return 1 with inexact if x!=0.
* 3. cos(x) is approximated by a polynomial of degree 14 on
* [0,pi/4]
* 4 14
* cos(x) ~ 1 - x*x/2 + C1*x + ... + C6*x
* where the remez error is
*
* | 2 4 6 8 10 12 14 | -58
* |cos(x)-(1-.5*x +C1*x +C2*x +C3*x +C4*x +C5*x +C6*x )| <= 2
* | |
*
* 4 6 8 10 12 14
* 4. let r = C1*x +C2*x +C3*x +C4*x +C5*x +C6*x , then
* cos(x) = 1 - x*x/2 + r
* since cos(x+y) ~ cos(x) - sin(x)*y
* ~ cos(x) - x*y,
* a correction term is necessary in cos(x) and hence
* cos(x+y) = 1 - (x*x/2 - (r - x*y))
* For better accuracy when x > 0.3, let qx = |x|/4 with
* the last 32 bits mask off, and if x > 0.78125, let qx = 0.28125.
* Then
* cos(x+y) = (1-qx) - ((x*x/2-qx) - (r-x*y)).
* Note that 1-qx and (x*x/2-qx) is EXACT here, and the
* magnitude of the latter is at least a quarter of x*x/2,
* thus, reducing the rounding error in the subtraction.
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const double
#else
static double
#endif
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
C1 = 4.16666666666666019037e-02, /* 0x3FA55555, 0x5555554C */
C2 = -1.38888888888741095749e-03, /* 0xBF56C16C, 0x16C15177 */
C3 = 2.48015872894767294178e-05, /* 0x3EFA01A0, 0x19CB1590 */
C4 = -2.75573143513906633035e-07, /* 0xBE927E4F, 0x809C52AD */
C5 = 2.08757232129817482790e-09, /* 0x3E21EE9E, 0xBDB4B1C4 */
C6 = -1.13596475577881948265e-11; /* 0xBDA8FAE9, 0xBE8838D4 */
#ifdef __STDC__
double __kernel_cos(double x, double y)
#else
double __kernel_cos(x, y)
double x,y;
#endif
{
double a,hz,z,r,qx;
int ix;
ix = __HI(x)&0x7fffffff; /* ix = |x|'s high word*/
if(ix<0x3e400000) { /* if x < 2**27 */
if(((int)x)==0) return one; /* generate inexact */
}
z = x*x;
r = z*(C1+z*(C2+z*(C3+z*(C4+z*(C5+z*C6)))));
if(ix < 0x3FD33333) /* if |x| < 0.3 */
return one - (0.5*z - (z*r - x*y));
else {
if(ix > 0x3fe90000) { /* x > 0.78125 */
qx = 0.28125;
} else {
__HI(qx) = ix-0x00200000; /* x/4 */
__LO(qx) = 0;
}
hz = 0.5*z-qx;
a = one-qx;
return a - (hz - (z*r-x*y));
}
}

View file

@ -0,0 +1,316 @@
/* @(#)k_rem_pio2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
* double x[],y[]; int e0,nx,prec; int ipio2[];
*
* __kernel_rem_pio2 return the last three digits of N with
* y = x - N*pi/2
* so that |y| < pi/2.
*
* The method is to compute the integer (mod 8) and fraction parts of
* (2/pi)*x without doing the full multiplication. In general we
* skip the part of the product that are known to be a huge integer (
* more accurately, = 0 mod 8 ). Thus the number of operations are
* independent of the exponent of the input.
*
* (2/pi) is represented by an array of 24-bit integers in ipio2[].
*
* Input parameters:
* x[] The input value (must be positive) is broken into nx
* pieces of 24-bit integers in double precision format.
* x[i] will be the i-th 24 bit of x. The scaled exponent
* of x[0] is given in input parameter e0 (i.e., x[0]*2^e0
* match x's up to 24 bits.
*
* Example of breaking a double positive z into x[0]+x[1]+x[2]:
* e0 = ilogb(z)-23
* z = ldexp(z,-e0)
* for i = 0,1,2
* x[i] = floor(z)
* z = (z-x[i])*2**24
*
*
* y[] ouput result in an array of double precision numbers.
* The dimension of y[] is:
* 24-bit precision 1
* 53-bit precision 2
* 64-bit precision 2
* 113-bit precision 3
* The actual value is the sum of them. Thus for 113-bit
* precison, one may have to do something like:
*
* long double t,w,r_head, r_tail;
* t = (long double)y[2] + (long double)y[1];
* w = (long double)y[0];
* r_head = t+w;
* r_tail = w - (r_head - t);
*
* e0 The exponent of x[0]
*
* nx dimension of x[]
*
* prec an integer indicating the precision:
* 0 24 bits (single)
* 1 53 bits (double)
* 2 64 bits (extended)
* 3 113 bits (quad)
*
* ipio2[]
* integer array, contains the (24*i)-th to (24*i+23)-th
* bit of 2/pi after binary point. The corresponding
* floating value is
*
* ipio2[i] * 2^(-24(i+1)).
*
* External function:
* double ldexp(), floor();
*
*
* Here is the description of some local variables:
*
* jk jk+1 is the initial number of terms of ipio2[] needed
* in the computation. The recommended value is 2,3,4,
* 6 for single, double, extended,and quad.
*
* jz local integer variable indicating the number of
* terms of ipio2[] used.
*
* jx nx - 1
*
* jv index for pointing to the suitable ipio2[] for the
* computation. In general, we want
* ( 2^e0*x[0] * ipio2[jv-1]*2^(-24jv) )/8
* is an integer. Thus
* e0-3-24*jv >= 0 or (e0-3)/24 >= jv
* Hence jv = max(0,(e0-3)/24).
*
* jp jp+1 is the number of terms in PIo2[] needed, jp = jk.
*
* q[] double array with integral value, representing the
* 24-bits chunk of the product of x and 2/pi.
*
* q0 the corresponding exponent of q[0]. Note that the
* exponent for q[i] would be q0-24*i.
*
* PIo2[] double precision array, obtained by cutting pi/2
* into 24 bits chunks.
*
* f[] ipio2[] in floating point
*
* iq[] integer array by breaking up q[] in 24-bits chunk.
*
* fq[] final product of x*(2/pi) in fq[0],..,fq[jk]
*
* ih integer. If >0 it indicates q[] is >= 0.5, hence
* it also indicates the *sign* of the result.
*
*/
/*
* Constants:
* The hexadecimal values are the intended ones for the following
* constants. The decimal values may be used, provided that the
* compiler will convert from decimal to binary accurately enough
* to produce the hexadecimal values shown.
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const int init_jk[] = {2,3,4,6}; /* initial value for jk */
#else
static int init_jk[] = {2,3,4,6};
#endif
#ifdef __STDC__
static const double PIo2[] = {
#else
static double PIo2[] = {
#endif
1.57079625129699707031e+00, /* 0x3FF921FB, 0x40000000 */
7.54978941586159635335e-08, /* 0x3E74442D, 0x00000000 */
5.39030252995776476554e-15, /* 0x3CF84698, 0x80000000 */
3.28200341580791294123e-22, /* 0x3B78CC51, 0x60000000 */
1.27065575308067607349e-29, /* 0x39F01B83, 0x80000000 */
1.22933308981111328932e-36, /* 0x387A2520, 0x40000000 */
2.73370053816464559624e-44, /* 0x36E38222, 0x80000000 */
2.16741683877804819444e-51, /* 0x3569F31D, 0x00000000 */
};
#ifdef __STDC__
static const double
#else
static double
#endif
zero = 0.0,
one = 1.0,
two24 = 1.67772160000000000000e+07, /* 0x41700000, 0x00000000 */
twon24 = 5.96046447753906250000e-08; /* 0x3E700000, 0x00000000 */
#ifdef __STDC__
int __kernel_rem_pio2(double *x, double *y, int e0, int nx, int prec, const int *ipio2)
#else
int __kernel_rem_pio2(x,y,e0,nx,prec,ipio2)
double x[], y[]; int e0,nx,prec; int ipio2[];
#endif
{
int jz,jx,jv,jp,jk,carry,n,iq[20],i,j,k,m,q0,ih;
double z,fw,f[20],fq[20],q[20];
/* initialize jk*/
jk = init_jk[prec];
jp = jk;
/* determine jx,jv,q0, note that 3>q0 */
jx = nx-1;
jv = (e0-3)/24; if(jv<0) jv=0;
q0 = e0-24*(jv+1);
/* set up f[0] to f[jx+jk] where f[jx+jk] = ipio2[jv+jk] */
j = jv-jx; m = jx+jk;
for(i=0;i<=m;i++,j++) f[i] = (j<0)? zero : (double) ipio2[j];
/* compute q[0],q[1],...q[jk] */
for (i=0;i<=jk;i++) {
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j]; q[i] = fw;
}
jz = jk;
recompute:
/* distill q[] into iq[] reversingly */
for(i=0,j=jz,z=q[jz];j>0;i++,j--) {
fw = (double)((int)(twon24* z));
iq[i] = (int)(z-two24*fw);
z = q[j-1]+fw;
}
/* compute n */
z = ldexp(z,q0); /* actual value of z */
z -= 8.0*floor(z*0.125); /* trim off integer >= 8 */
n = (int) z;
z -= (double)n;
ih = 0;
if(q0>0) { /* need iq[jz-1] to determine n */
i = (iq[jz-1]>>(24-q0)); n += i;
iq[jz-1] -= i<<(24-q0);
ih = iq[jz-1]>>(23-q0);
}
else if(q0==0) ih = iq[jz-1]>>23;
else if(z>=0.5) ih=2;
if(ih>0) { /* q > 0.5 */
n += 1; carry = 0;
for(i=0;i<jz ;i++) { /* compute 1-q */
j = iq[i];
if(carry==0) {
if(j!=0) {
carry = 1; iq[i] = 0x1000000- j;
}
} else iq[i] = 0xffffff - j;
}
if(q0>0) { /* rare case: chance is 1 in 12 */
switch(q0) {
case 1:
iq[jz-1] &= 0x7fffff; break;
case 2:
iq[jz-1] &= 0x3fffff; break;
}
}
if(ih==2) {
z = one - z;
if(carry!=0) z -= ldexp(one,q0);
}
}
/* check if recomputation is needed */
if(z==zero) {
j = 0;
for (i=jz-1;i>=jk;i--) j |= iq[i];
if(j==0) { /* need recomputation */
for(k=1;iq[jk-k]==0;k++); /* k = no. of terms needed */
for(i=jz+1;i<=jz+k;i++) { /* add q[jz+1] to q[jz+k] */
f[jx+i] = (double) ipio2[jv+i];
for(j=0,fw=0.0;j<=jx;j++) fw += x[j]*f[jx+i-j];
q[i] = fw;
}
jz += k;
goto recompute;
}
}
/* chop off zero terms */
if(z==0.0) {
jz -= 1; q0 -= 24;
while(iq[jz]==0) { jz--; q0-=24;}
} else { /* break z into 24-bit if necessary */
z = ldexp(z,-q0);
if(z>=two24) {
fw = (double)((int)(twon24*z));
iq[jz] = (int)(z-two24*fw);
jz += 1; q0 += 24;
iq[jz] = (int) fw;
} else iq[jz] = (int) z ;
}
/* convert integer "bit" chunk to floating-point value */
fw = ldexp(one,q0);
for(i=jz;i>=0;i--) {
q[i] = fw*(double)iq[i]; fw*=twon24;
}
/* compute PIo2[0,...,jp]*q[jz,...,0] */
for(i=jz;i>=0;i--) {
for(fw=0.0,k=0;k<=jp&&k<=jz-i;k++) fw += PIo2[k]*q[i+k];
fq[jz-i] = fw;
}
/* compress fq[] into y[] */
switch(prec) {
case 0:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
y[0] = (ih==0)? fw: -fw;
break;
case 1:
case 2:
fw = 0.0;
for (i=jz;i>=0;i--) fw += fq[i];
y[0] = (ih==0)? fw: -fw;
fw = fq[0]-fw;
for (i=1;i<=jz;i++) fw += fq[i];
y[1] = (ih==0)? fw: -fw;
break;
case 3: /* painful */
for (i=jz;i>0;i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (i=jz;i>1;i--) {
fw = fq[i-1]+fq[i];
fq[i] += fq[i-1]-fw;
fq[i-1] = fw;
}
for (fw=0.0,i=jz;i>=2;i--) fw += fq[i];
if(ih==0) {
y[0] = fq[0]; y[1] = fq[1]; y[2] = fw;
} else {
y[0] = -fq[0]; y[1] = -fq[1]; y[2] = -fw;
}
}
return n&7;
}

View file

@ -0,0 +1,73 @@
/* @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/* __kernel_sin( x, y, iy)
* kernel sin function on [-pi/4, pi/4], pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
* Input y is the tail of x.
* Input iy indicates whether y is 0. (if iy=0, y assume to be 0).
*
* Algorithm
* 1. Since sin(-x) = -sin(x), we need only to consider positive x.
* 2. if x < 2^-27 (hx<0x3e400000 0), return x with inexact if x!=0.
* 3. sin(x) is approximated by a polynomial of degree 13 on
* [0,pi/4]
* 3 13
* sin(x) ~ x + S1*x + ... + S6*x
* where
*
* |sin(x) 2 4 6 8 10 12 | -58
* |----- - (1+S1*x +S2*x +S3*x +S4*x +S5*x +S6*x )| <= 2
* | x |
*
* 4. sin(x+y) = sin(x) + sin'(x')*y
* ~ sin(x) + (1-x*x/2)*y
* For better accuracy, let
* 3 2 2 2 2
* r = x *(S2+x *(S3+x *(S4+x *(S5+x *S6))))
* then 3 2
* sin(x) = x + (S1*x + (x *(r-y/2)+y))
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const double
#else
static double
#endif
half = 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
S3 = -1.98412698298579493134e-04, /* 0xBF2A01A0, 0x19C161D5 */
S4 = 2.75573137070700676789e-06, /* 0x3EC71DE3, 0x57B1FE7D */
S5 = -2.50507602534068634195e-08, /* 0xBE5AE5E6, 0x8A2B9CEB */
S6 = 1.58969099521155010221e-10; /* 0x3DE5D93A, 0x5ACFD57C */
#ifdef __STDC__
double __kernel_sin(double x, double y, int iy)
#else
double __kernel_sin(x, y, iy)
double x,y; int iy; /* iy=0 if y is zero */
#endif
{
double z,r,v;
int ix;
ix = __HI(x)&0x7fffffff; /* high word of x */
if(ix<0x3e400000) /* |x| < 2**-27 */
{if((int)x==0) return x;} /* generate inexact */
z = x*x;
v = z*x;
r = S2+z*(S3+z*(S4+z*(S5+z*S6)));
if(iy==0) return x+v*(S1+z*r);
else return x-((z*(half*y-v*r)-y)-v*S1);
}

134
src/MSL_C.PPCEABI.bare.H/k_tan.c Executable file
View file

@ -0,0 +1,134 @@
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/* INDENT OFF */
/* __kernel_tan( x, y, k )
* kernel tan function on [-pi/4, pi/4], pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
* Input y is the tail of x.
* Input k indicates whether tan (if k = 1) or -1/tan (if k = -1) is returned.
*
* Algorithm
* 1. Since tan(-x) = -tan(x), we need only to consider positive x.
* 2. if x < 2^-28 (hx<0x3e300000 0), return x with inexact if x!=0.
* 3. tan(x) is approximated by a odd polynomial of degree 27 on
* [0,0.67434]
* 3 27
* tan(x) ~ x + T1*x + ... + T13*x
* where
*
* |tan(x) 2 4 26 | -59.2
* |----- - (1+T1*x +T2*x +.... +T13*x )| <= 2
* | x |
*
* Note: tan(x+y) = tan(x) + tan'(x)*y
* ~ tan(x) + (1+x*x)*y
* Therefore, for better accuracy in computing tan(x+y), let
* 3 2 2 2 2
* r = x *(T2+x *(T3+x *(...+x *(T12+x *T13))))
* then
* 3 2
* tan(x+y) = x + (T1*x + (x *(r+y)+y))
*
* 4. For x in [0.67434,pi/4], let y = pi/4 - x, then
* tan(x) = tan(pi/4-y) = (1-tan(y))/(1+tan(y))
* = 1 - 2*(tan(y) - (tan(y)^2)/(1+tan(y)))
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/math.h"
static const double xxx[] = {
3.33333333333334091986e-01, /* 3FD55555, 55555563 */
1.33333333333201242699e-01, /* 3FC11111, 1110FE7A */
5.39682539762260521377e-02, /* 3FABA1BA, 1BB341FE */
2.18694882948595424599e-02, /* 3F9664F4, 8406D637 */
8.86323982359930005737e-03, /* 3F8226E3, E96E8493 */
3.59207910759131235356e-03, /* 3F6D6D22, C9560328 */
1.45620945432529025516e-03, /* 3F57DBC8, FEE08315 */
5.88041240820264096874e-04, /* 3F4344D8, F2F26501 */
2.46463134818469906812e-04, /* 3F3026F7, 1A8D1068 */
7.81794442939557092300e-05, /* 3F147E88, A03792A6 */
7.14072491382608190305e-05, /* 3F12B80F, 32F0A7E9 */
-1.85586374855275456654e-05, /* BEF375CB, DB605373 */
2.59073051863633712884e-05, /* 3EFB2A70, 74BF7AD4 */
};
#define pio4 7.85398163397448278999e-01
#define pio4lo 3.06161699786838301793e-17
#define T xxx
/* INDENT ON */
double
__kernel_tan(double x, double y, int iy) {
double z, r, v, w, s;
int ix, hx;
hx = __HI(x); /* high word of x */
ix = hx & 0x7fffffff; /* high word of |x| */
if (ix < 0x3e300000) { /* x < 2**-28 */
if ((int) x == 0) { /* generate inexact */
if (((ix | __LO(x)) | (iy + 1)) == 0)
return 1 / fabs(x);
else {
if (iy == 1)
return x;
else
return -1 / x;
}
}
}
if (ix >= 0x3FE59428) { /* |x| >= 0.6744 */
if (hx < 0) {
x = -x;
y = -y;
}
z = pio4 - x;
w = pio4lo - y;
x = z + w;
y = 0.0;
}
z = x * x;
w = z * z;
/*
* Break x^5*(T[1]+x^2*T[2]+...) into
* x^5(T[1]+x^4*T[3]+...+x^20*T[11]) +
* x^5(x^2*(T[2]+x^4*T[4]+...+x^22*[T12]))
*/
r = T[1] + w * (T[3] + w * (T[5] + w * (T[7] + w * (T[9] +
w * T[11]))));
v = z * (T[2] + w * (T[4] + w * (T[6] + w * (T[8] + w * (T[10] +
w * T[12])))));
s = z * x;
r = y + z * (s * (r + v) + y);
r += T[0] * s;
w = x + r;
if (ix >= 0x3FE59428) {
v = (double) iy;
return (double) (1 - ((hx >> 30) & 2)) *
(v - 2.0 * (x - (w * w / (w + v) - r)));
}
if (iy == 1)
return w;
else {
/*
* if allow error up to 2 ulp, simply return
* -1.0 / (x+r) here
*/
/* compute -1.0 / (x+r) accurately */
double a, t;
z = w;
__LO(z) = 0;
v = r - (z - x); /* z+v = r+x */
t = a = -1.0 / w; /* a = -1.0/w */
__LO(t) = 0;
s = 1.0 + t * z;
return t + a * (s + t * v);
}
}

View file

@ -1,18 +1,64 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/mbstring.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n) static int unicode_to_UTF8(char* s, wchar_t wchar) {
{ int number_of_bytes;
wchar_t next; char* target_ptr;
size_t chars_written; char first_byte_mark[4] = {0x00, 0x00, 0xc0, 0xe0};
int i;
chars_written = 0; if (!s) {
for (i = 0; i < n; ++i) { return 0;
next = *pwcs++; }
*s++ = (char)next;
if ((char)next == '\0') if (wchar < 0x0080)
number_of_bytes = 1;
else if (wchar < 0x0800)
number_of_bytes = 2;
else
number_of_bytes = 3;
target_ptr = s + number_of_bytes;
switch (number_of_bytes) {
case 3:
*--target_ptr = (wchar & 0x003f) | 0x80;
wchar >>= 6;
case 2:
*--target_ptr = (wchar & 0x003f) | 0x80;
wchar >>= 6;
case 1:
*--target_ptr = wchar | first_byte_mark[number_of_bytes];
}
return (number_of_bytes);
}
static inline int wctomb(char* s, wchar_t wchar) {
return (unicode_to_UTF8(s, wchar));
}
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n) {
int chars_written = 0;
int result;
char temp[3];
wchar_t* source;
if (!s || !pwcs)
return (0);
source = (wchar_t*)pwcs;
while (chars_written <= n) {
if (!*source) {
*(s + chars_written) = '\0';
break;
} else {
result = wctomb(temp, *source++);
if ((chars_written + result) <= n) {
strcat(s + chars_written, temp, result);
chars_written += result;
} else
break; break;
++chars_written;
} }
return chars_written; }
return (chars_written);
} }

View file

@ -1 +1,6 @@
void __stdio_atexit(void) { } #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/abort_exit.h"
void __stdio_atexit(void) {
__stdio_exit = __close_all;
}

View file

@ -49,9 +49,7 @@ typedef struct {
int precision; int precision;
} print_format; } print_format;
static const char* parse_format(const char* format_string, va_list* arg, static const char* parse_format(const char *format_string, va_list *arg, print_format *format) {
print_format* format)
{
print_format f; print_format f;
const char* s = format_string; const char* s = format_string;
int c; int c;
@ -100,7 +98,8 @@ static const char* parse_format(const char* format_string, va_list* arg,
if (flag_found) { if (flag_found) {
c = *++s; c = *++s;
} else { }
else {
break; break;
} }
} }
@ -112,7 +111,8 @@ static const char* parse_format(const char* format_string, va_list* arg,
} }
c = *++s; c = *++s;
} else { }
else {
while (isdigit(c)) { while (isdigit(c)) {
f.field_width = (f.field_width * 10) + (c - '0'); f.field_width = (f.field_width * 10) + (c - '0');
c = *++s; c = *++s;
@ -134,7 +134,8 @@ static const char* parse_format(const char* format_string, va_list* arg,
} }
c = *++s; c = *++s;
} else { }
else {
while (isdigit(c)) { while (isdigit(c)) {
f.precision = (f.precision * 10) + (c - '0'); f.precision = (f.precision * 10) + (c - '0');
c = *++s; c = *++s;
@ -193,14 +194,15 @@ static const char* parse_format(const char* format_string, va_list* arg,
if (!f.precision_specified) { if (!f.precision_specified) {
f.precision = 1; f.precision = 1;
} else if (f.justification_options == zero_fill) { }
else if (f.justification_options == zero_fill) {
f.justification_options = right_justification; f.justification_options = right_justification;
} }
break; break;
case 'f': case 'f':
if (f.argument_options == short_argument case 'F':
|| f.argument_options == long_long_argument) { if (f.argument_options == short_argument || f.argument_options == long_long_argument) {
f.conversion_char = 0xFF; f.conversion_char = 0xFF;
break; break;
} }
@ -210,6 +212,18 @@ static const char* parse_format(const char* format_string, va_list* arg,
} }
break; break;
case 'a':
case 'A':
if (!f.precision_specified) {
f.precision = 0xD;
}
if (f.argument_options == short_argument || f.argument_options == long_long_argument || f.argument_options == char_argument) {
f.conversion_char = 0xFF;
}
break;
case 'g': case 'g':
case 'G': case 'G':
if (!f.precision) { if (!f.precision) {
@ -218,9 +232,7 @@ static const char* parse_format(const char* format_string, va_list* arg,
case 'e': case 'e':
case 'E': case 'E':
if (f.argument_options == short_argument if (f.argument_options == short_argument || f.argument_options == long_long_argument || f.argument_options == char_argument) {
|| f.argument_options == long_long_argument
|| f.argument_options == char_argument) {
f.conversion_char = 0xFF; f.conversion_char = 0xFF;
break; break;
} }
@ -240,9 +252,9 @@ static const char* parse_format(const char* format_string, va_list* arg,
case 'c': case 'c':
if (f.argument_options == long_argument) { if (f.argument_options == long_argument) {
f.argument_options = wchar_argument; f.argument_options = wchar_argument;
} else { }
if (f.precision_specified else {
|| f.argument_options != normal_argument) { if (f.precision_specified || f.argument_options != normal_argument) {
f.conversion_char = 0xFF; f.conversion_char = 0xFF;
} }
} }
@ -252,7 +264,8 @@ static const char* parse_format(const char* format_string, va_list* arg,
case 's': case 's':
if (f.argument_options == long_argument) { if (f.argument_options == long_argument) {
f.argument_options = wchar_argument; f.argument_options = wchar_argument;
} else { }
else {
if (f.argument_options != normal_argument) { if (f.argument_options != normal_argument) {
f.conversion_char = 0xFF; f.conversion_char = 0xFF;
} }
@ -276,7 +289,7 @@ static const char* parse_format(const char* format_string, va_list* arg,
return ((const char*)s + 1); return ((const char*)s + 1);
} }
static char* long2str(signed long num, char* buff, print_format* format) static char* long2str(long num, char* buff, print_format format)
{ {
unsigned long unsigned_num, base; unsigned long unsigned_num, base;
char* p; char* p;
@ -289,12 +302,12 @@ static char* long2str(signed long num, char* buff, print_format* format)
*--p = 0; *--p = 0;
digits = 0; digits = 0;
if (!num && !format->precision if (!num && !format.precision
&& !(format->alternate_form && format->conversion_char == 'o')) { && !(format.alternate_form && format.conversion_char == 'o')) {
return p; return p;
} }
switch (format->conversion_char) { switch (format.conversion_char) {
case 'd': case 'd':
case 'i': case 'i':
base = 10; base = 10;
@ -307,18 +320,18 @@ static char* long2str(signed long num, char* buff, print_format* format)
case 'o': case 'o':
base = 8; base = 8;
format->sign_options = only_minus; format.sign_options = only_minus;
break; break;
case 'u': case 'u':
base = 10; base = 10;
format->sign_options = only_minus; format.sign_options = only_minus;
break; break;
case 'x': case 'x':
case 'X': case 'X':
base = 16; base = 16;
format->sign_options = only_minus; format.sign_options = only_minus;
break; break;
} }
@ -331,7 +344,7 @@ static char* long2str(signed long num, char* buff, print_format* format)
} else { } else {
n -= 10; n -= 10;
if (format->conversion_char == 'x') { if (format.conversion_char == 'x') {
n += 'a'; n += 'a';
} else { } else {
n += 'A'; n += 'A';
@ -342,46 +355,46 @@ static char* long2str(signed long num, char* buff, print_format* format)
++digits; ++digits;
} while (unsigned_num != 0); } while (unsigned_num != 0);
if (base == 8 && format->alternate_form && *p != '0') { if (base == 8 && format.alternate_form && *p != '0') {
*--p = '0'; *--p = '0';
++digits; ++digits;
} }
if (format->justification_options == zero_fill) { if (format.justification_options == zero_fill) {
format->precision = format->field_width; format.precision = format.field_width;
if (minus || format->sign_options != only_minus) if (minus || format.sign_options != only_minus)
--format->precision; --format.precision;
if (base == 16 && format->alternate_form) if (base == 16 && format.alternate_form)
format->precision -= 2; format.precision -= 2;
} }
if (buff - p + format->precision > 509) if (buff - p + format.precision > 509)
return (0); return (0);
while (digits < format->precision) { while (digits < format.precision) {
*--p = '0'; *--p = '0';
++digits; ++digits;
} }
if (base == 16 && format->alternate_form) { if (base == 16 && format.alternate_form) {
*--p = format->conversion_char; *--p = format.conversion_char;
*--p = '0'; *--p = '0';
} }
if (minus) { if (minus) {
*--p = '-'; *--p = '-';
} else if (format->sign_options == sign_always) { } else if (format.sign_options == sign_always) {
*--p = '+'; *--p = '+';
} else if (format->sign_options == space_holder) { } else if (format.sign_options == space_holder) {
*--p = ' '; *--p = ' ';
} }
return p; return p;
} }
static char* longlong2str(signed long long num, char* pBuf, print_format* fmt) static char* longlong2str(long long num, char* pBuf, print_format fmt)
{ {
unsigned long long unsigned_num, base; unsigned long long unsigned_num, base;
char* p; char* p;
@ -393,12 +406,12 @@ static char* longlong2str(signed long long num, char* pBuf, print_format* fmt)
*--p = 0; *--p = 0;
digits = 0; digits = 0;
if (!num && !fmt->precision if (!num && !fmt.precision
&& !(fmt->alternate_form && fmt->conversion_char == 'o')) { && !(fmt.alternate_form && fmt.conversion_char == 'o')) {
return p; return p;
} }
switch (fmt->conversion_char) { switch (fmt.conversion_char) {
case 'd': case 'd':
case 'i': case 'i':
base = 10; base = 10;
@ -410,16 +423,16 @@ static char* longlong2str(signed long long num, char* pBuf, print_format* fmt)
break; break;
case 'o': case 'o':
base = 8; base = 8;
fmt->sign_options = only_minus; fmt.sign_options = only_minus;
break; break;
case 'u': case 'u':
base = 10; base = 10;
fmt->sign_options = only_minus; fmt.sign_options = only_minus;
break; break;
case 'x': case 'x':
case 'X': case 'X':
base = 16; base = 16;
fmt->sign_options = only_minus; fmt.sign_options = only_minus;
break; break;
} }
@ -431,7 +444,7 @@ static char* longlong2str(signed long long num, char* pBuf, print_format* fmt)
n += '0'; n += '0';
} else { } else {
n -= 10; n -= 10;
if (fmt->conversion_char == 'x') { if (fmt.conversion_char == 'x') {
n += 'a'; n += 'a';
} else { } else {
n += 'A'; n += 'A';
@ -442,48 +455,50 @@ static char* longlong2str(signed long long num, char* pBuf, print_format* fmt)
++digits; ++digits;
} while (unsigned_num != 0); } while (unsigned_num != 0);
if (base == 8 && fmt->alternate_form && *p != '0') { if (base == 8 && fmt.alternate_form && *p != '0') {
*--p = '0'; *--p = '0';
++digits; ++digits;
} }
if (fmt->justification_options == zero_fill) { if (fmt.justification_options == zero_fill) {
fmt->precision = fmt->field_width; fmt.precision = fmt.field_width;
if (minus || fmt->sign_options != only_minus) { if (minus || fmt.sign_options != only_minus) {
--fmt->precision; --fmt.precision;
} }
if (base == 16 && fmt->alternate_form) { if (base == 16 && fmt.alternate_form) {
fmt->precision -= 2; fmt.precision -= 2;
} }
} }
if (pBuf - p + fmt->precision > 509) { if (pBuf - p + fmt.precision > 509) {
return 0; return 0;
} }
while (digits < fmt->precision) { while (digits < fmt.precision) {
*--p = '0'; *--p = '0';
++digits; ++digits;
} }
if (base == 16 && fmt->alternate_form) { if (base == 16 && fmt.alternate_form) {
*--p = fmt->conversion_char; *--p = fmt.conversion_char;
*--p = '0'; *--p = '0';
} }
if (minus) { if (minus) {
*--p = '-'; *--p = '-';
} else if (fmt->sign_options == sign_always) { } else if (fmt.sign_options == sign_always) {
*--p = '+'; *--p = '+';
} else if (fmt->sign_options == space_holder) { } else if (fmt.sign_options == space_holder) {
*--p = ' '; *--p = ' ';
} }
return p; return p;
} }
static char * double2hex(long double num, char * buff, print_format format);
static void round_decimal(decimal* dec, int new_length) static void round_decimal(decimal* dec, int new_length)
{ {
char c; char c;
@ -492,7 +507,6 @@ static void round_decimal(decimal* dec, int new_length)
if (new_length < 0) { if (new_length < 0) {
return_zero: return_zero:
dec->sign = 0;
dec->exp = 0; dec->exp = 0;
dec->sig.length = 1; dec->sig.length = 1;
*dec->sig.text = '0'; *dec->sig.text = '0';
@ -539,24 +553,15 @@ static void round_decimal(decimal* dec, int new_length)
dec->sig.length = new_length; dec->sig.length = new_length;
} }
static char* float2str(va_list arg, char* buff, print_format* format, static char* float2str(long double num, char *buff, print_format format) {
int vecIndex)
{
decimal dec; decimal dec;
decform form; decform form;
char* p; char* p;
char* q; char* q;
int n, digits, sign; int n, digits, sign;
int int_digits, frac_digits; int int_digits, frac_digits;
long double num;
if (format->argument_options == long_double_argument) { if (format.precision > 509) {
num = va_arg(arg, long double);
} else {
num = va_arg(arg, double);
}
if (format->precision > 509) {
return 0; return 0;
} }
@ -577,17 +582,47 @@ static char* float2str(va_list arg, char* buff, print_format* format,
case 'I': case 'I':
if (num < 0) { if (num < 0) {
p = buff - 5; p = buff - 5;
strcpy(p, "-Inf");
} else { if (isupper(format.conversion_char)) {
strcpy(p, "-INF");
}
else {
strcpy(p, "-inf");
}
}
else {
p = buff - 4; p = buff - 4;
strcpy(p, "Inf"); if (isupper(format.conversion_char)) {
strcpy(p, "INF");
}
else {
strcpy(p, "inf");
}
} }
return p; return p;
case 'N': case 'N':
if (dec.sign) {
p = buff - 5;
if (isupper(format.conversion_char)) {
strcpy(p, "-NAN");
}
else {
strcpy(p, "-nan");
}
}
else {
p = buff - 4; p = buff - 4;
strcpy(p, "NaN"); if (isupper(format.conversion_char)) {
strcpy(p, "NAN");
}
else {
strcpy(p, "nan");
}
}
return p; return p;
} }
@ -595,35 +630,40 @@ static char* float2str(va_list arg, char* buff, print_format* format,
p = buff; p = buff;
*--p = 0; *--p = 0;
switch (format->conversion_char) { switch (format.conversion_char)
{
case 'g': case 'g':
case 'G': case 'G':
if (dec.sig.length > format->precision) { if (dec.sig.length > format.precision) {
round_decimal(&dec, format->precision); round_decimal(&dec, format.precision);
} }
if (dec.exp < -4 || dec.exp >= format->precision) { if (dec.exp < -4 || dec.exp >= format.precision)
if (format->alternate_form) { {
--format->precision; if (format.alternate_form) {
} else { --format.precision;
format->precision = dec.sig.length - 1; }
else {
format.precision = dec.sig.length - 1;
} }
if (format->conversion_char == 'g') { if (format.conversion_char == 'g') {
format->conversion_char = 'e'; format.conversion_char = 'e';
} else { }
format->conversion_char = 'E'; else {
format.conversion_char = 'E';
} }
goto e_format; goto e_format;
} }
if (format->alternate_form) { if (format.alternate_form) {
format->precision -= dec.exp + 1; format.precision -= dec.exp + 1;
} else { }
if ((format->precision = dec.sig.length - (dec.exp + 1)) < 0) { else {
format->precision = 0; if ((format.precision = dec.sig.length - (dec.exp + 1)) < 0) {
format.precision = 0;
} }
} }
@ -633,8 +673,8 @@ static char* float2str(va_list arg, char* buff, print_format* format,
case 'E': case 'E':
e_format: e_format:
if (dec.sig.length > format->precision + 1) { if (dec.sig.length > format.precision + 1) {
round_decimal(&dec, format->precision + 1); round_decimal(&dec, format.precision + 1);
} }
n = dec.exp; n = dec.exp;
@ -651,24 +691,23 @@ static char* float2str(va_list arg, char* buff, print_format* format,
} }
*--p = sign; *--p = sign;
*--p = format->conversion_char; *--p = format.conversion_char;
if (buff - p + format->precision > 509) { if (buff - p + format.precision > 509) {
return 0; return 0;
} }
if (dec.sig.length < format->precision + 1) { if (dec.sig.length < format.precision + 1) {
for (n = format->precision + 1 - dec.sig.length + 1; --n;) { for (n = format.precision + 1 - dec.sig.length + 1; --n;) {
*--p = '0'; *--p = '0';
} }
} }
for (n = dec.sig.length, q = (char*)dec.sig.text + dec.sig.length; for (n = dec.sig.length, q = (char*)dec.sig.text + dec.sig.length; --n;) {
--n;) {
*--p = *--q; *--p = *--q;
} }
if (format->precision || format->alternate_form) { if (format.precision || format.alternate_form) {
*--p = '.'; *--p = '.';
} }
@ -676,22 +715,22 @@ static char* float2str(va_list arg, char* buff, print_format* format,
if (dec.sign) if (dec.sign)
*--p = '-'; *--p = '-';
else if (format->sign_options == sign_always) else if (format.sign_options == sign_always)
*--p = '+'; *--p = '+';
else if (format->sign_options == space_holder) else if (format.sign_options == space_holder)
*--p = ' '; *--p = ' ';
break; break;
case 'f': case 'f':
case 'F':
f_format: f_format:
if ((frac_digits = -dec.exp + dec.sig.length - 1) < 0) if ((frac_digits = -dec.exp + dec.sig.length - 1) < 0)
frac_digits = 0; frac_digits = 0;
if (frac_digits > format->precision) { if (frac_digits > format.precision) {
round_decimal(&dec, round_decimal(&dec, dec.sig.length - (frac_digits - format.precision));
dec.sig.length - (frac_digits - format->precision));
if ((frac_digits = -dec.exp + dec.sig.length - 1) < 0) if ((frac_digits = -dec.exp + dec.sig.length - 1) < 0)
frac_digits = 0; frac_digits = 0;
@ -705,17 +744,16 @@ static char* float2str(va_list arg, char* buff, print_format* format,
q = (char *) dec.sig.text + dec.sig.length; q = (char *) dec.sig.text + dec.sig.length;
for (digits = 0; digits < (format->precision - frac_digits); ++digits) for (digits = 0; digits < (format.precision - frac_digits); ++digits)
*--p = '0'; *--p = '0';
for (digits = 0; digits < frac_digits && digits < dec.sig.length; for (digits = 0; digits < frac_digits && digits < dec.sig.length; ++digits)
++digits)
*--p = *--q; *--p = *--q;
for (; digits < frac_digits; ++digits) for (; digits < frac_digits; ++digits)
*--p = '0'; *--p = '0';
if (format->precision || format->alternate_form) if (format.precision || format.alternate_form)
*--p = '.'; *--p = '.';
if (int_digits) { if (int_digits) {
@ -726,15 +764,18 @@ static char* float2str(va_list arg, char* buff, print_format* format,
for (; digits < int_digits; ++digits) { for (; digits < int_digits; ++digits) {
*--p = *--q; *--p = *--q;
} }
} else { }
else {
*--p = '0'; *--p = '0';
} }
if (dec.sign) { if (dec.sign) {
*--p = '-'; *--p = '-';
} else if (format->sign_options == sign_always) { }
else if (format.sign_options == sign_always) {
*--p = '+'; *--p = '+';
} else if (format->sign_options == space_holder) { }
else if (format.sign_options == space_holder) {
*--p = ' '; *--p = ' ';
} }
@ -744,15 +785,14 @@ static char* float2str(va_list arg, char* buff, print_format* format,
return p; return p;
} }
static int __pformatter(void* (*WriteProc)(void*, const char*, size_t), static int __pformatter(void *(*WriteProc)(void *, const char *, size_t), void *WriteProcArg, const char * format_str, va_list arg) {
void* WriteProcArg, const char* format_str, va_list arg)
{
int num_chars, chars_written, field_width; int num_chars, chars_written, field_width;
const char* format_ptr; const char* format_ptr;
const char* curr_format; const char* curr_format;
print_format format; print_format format;
signed long long_num; long long_num;
signed long long long_long_num; long long long_long_num;
long double long_double_num;
char buff[512]; char buff[512];
char* buff_ptr; char* buff_ptr;
char* string_end; char* string_end;
@ -766,8 +806,7 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
num_chars = strlen(format_ptr); num_chars = strlen(format_ptr);
chars_written += num_chars; chars_written += num_chars;
if (num_chars if (num_chars && !(*WriteProc)(WriteProcArg, format_ptr, num_chars)) {
&& !(*WriteProc)(WriteProcArg, format_ptr, num_chars)) {
return -1; return -1;
} }
@ -788,15 +827,17 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
case 'd': case 'd':
case 'i': case 'i':
if (format.argument_options == long_argument) { if (format.argument_options == long_argument) {
long_num = va_arg(arg, signed long); long_num = va_arg(arg, long);
} else if (format.argument_options == long_long_argument) { }
long_long_num = va_arg(arg, signed long long); else if (format.argument_options == long_long_argument) {
} else { long_long_num = va_arg(arg, long long);
}
else {
long_num = va_arg(arg, int); long_num = va_arg(arg, int);
} }
if (format.argument_options == short_argument) { if (format.argument_options == short_argument) {
long_num = (signed short)long_num; long_num = (short)long_num;
} }
if (format.argument_options == char_argument) { if (format.argument_options == char_argument) {
@ -804,12 +845,12 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
} }
if (format.argument_options == long_long_argument) { if (format.argument_options == long_long_argument) {
if (!(buff_ptr if (!(buff_ptr = longlong2str(long_long_num, buff + 512, format))) {
= longlong2str(long_long_num, buff + 512, &format))) {
goto conversion_error; goto conversion_error;
} }
} else { }
if (!(buff_ptr = long2str(long_num, buff + 512, &format))) { else {
if (!(buff_ptr = long2str(long_num, buff + 512, format))) {
goto conversion_error; goto conversion_error;
} }
} }
@ -823,9 +864,11 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
case 'X': case 'X':
if (format.argument_options == long_argument) { if (format.argument_options == long_argument) {
long_num = va_arg(arg, unsigned long); long_num = va_arg(arg, unsigned long);
} else if (format.argument_options == long_long_argument) { }
long_long_num = va_arg(arg, signed long long); else if (format.argument_options == long_long_argument) {
} else { long_long_num = va_arg(arg, long long);
}
else {
long_num = va_arg(arg, unsigned int); long_num = va_arg(arg, unsigned int);
} }
@ -838,12 +881,12 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
} }
if (format.argument_options == long_long_argument) { if (format.argument_options == long_long_argument) {
if (!(buff_ptr if (!(buff_ptr = longlong2str(long_long_num, buff + 512, format))) {
= longlong2str(long_long_num, buff + 512, &format))) {
goto conversion_error; goto conversion_error;
} }
} else { }
if (!(buff_ptr = long2str(long_num, buff + 512, &format))) { else {
if (!(buff_ptr = long2str(long_num, buff + 512, format))) {
goto conversion_error; goto conversion_error;
} }
} }
@ -852,11 +895,35 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
break; break;
case 'f': case 'f':
case 'F':
case 'e': case 'e':
case 'E': case 'E':
case 'g': case 'g':
case 'G': case 'G':
if (!(buff_ptr = float2str(arg, buff + 512, &format, 0))) { if (format.argument_options == long_double_argument) {
long_double_num = va_arg(arg, long double);
}
else {
long_double_num = va_arg(arg, double);
}
if (!(buff_ptr = float2str(long_double_num, buff + 512, format))) {
goto conversion_error;
}
num_chars = buff + 512 - 1 - buff_ptr;
break;
case 'a':
case 'A':
if (format.argument_options == long_double_argument) {
long_double_num = va_arg(arg, long double);
}
else {
long_double_num = va_arg(arg, double);
}
if (!(buff_ptr = double2hex(long_double_num, buff + 512, format))) {
goto conversion_error; goto conversion_error;
} }
@ -876,7 +943,8 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
} }
buff_ptr = &buff[0]; buff_ptr = &buff[0];
} else { }
else {
buff_ptr = va_arg(arg, char *); buff_ptr = va_arg(arg, char *);
} }
@ -887,19 +955,18 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
if (format.alternate_form) { if (format.alternate_form) {
num_chars = (unsigned char)*buff_ptr++; num_chars = (unsigned char)*buff_ptr++;
if (format.precision_specified if (format.precision_specified && num_chars > format.precision) {
&& num_chars > format.precision) {
num_chars = format.precision; num_chars = format.precision;
} }
} else if (format.precision_specified) { }
else if (format.precision_specified) {
num_chars = format.precision; num_chars = format.precision;
if ((string_end if ((string_end = (char*)memchr((unsigned char*)buff_ptr, 0, num_chars)) != 0) {
= (char*)memchr((unsigned char*)buff_ptr, 0, num_chars))
!= 0) {
num_chars = string_end - buff_ptr; num_chars = string_end - buff_ptr;
} }
} else { }
else {
num_chars = strlen(buff_ptr); num_chars = strlen(buff_ptr);
} }
@ -913,13 +980,13 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
*(int*)buff_ptr = chars_written; *(int*)buff_ptr = chars_written;
break; break;
case short_argument: case short_argument:
*(signed short*)buff_ptr = chars_written; *(short*)buff_ptr = chars_written;
break; break;
case long_argument: case long_argument:
*(signed long*)buff_ptr = chars_written; *(long*)buff_ptr = chars_written;
break; break;
case long_long_argument: case long_long_argument:
*(signed long long*)buff_ptr = chars_written; *(long long*)buff_ptr = chars_written;
break; break;
} }
@ -943,8 +1010,7 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
num_chars = strlen(curr_format); num_chars = strlen(curr_format);
chars_written += num_chars; chars_written += num_chars;
if (num_chars if (num_chars && !(*WriteProc)(WriteProcArg, curr_format, num_chars)) {
&& !(*WriteProc)(WriteProcArg, curr_format, num_chars)) {
return -1; return -1;
} }
@ -957,8 +1023,7 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
if (format.justification_options != left_justification) { if (format.justification_options != left_justification) {
fill_char = (format.justification_options == zero_fill) ? '0' : ' '; fill_char = (format.justification_options == zero_fill) ? '0' : ' ';
if (((*buff_ptr == '+') || (*buff_ptr == '-')) if (((*buff_ptr == '+') || (*buff_ptr == '-') || (*buff_ptr == ' ')) && (fill_char == '0')) {
&& (fill_char == '0')) {
if ((*WriteProc)(WriteProcArg, buff_ptr, 1) == 0) { if ((*WriteProc)(WriteProcArg, buff_ptr, 1) == 0) {
return -1; return -1;
} }
@ -998,23 +1063,22 @@ static int __pformatter(void* (*WriteProc)(void*, const char*, size_t),
return chars_written; return chars_written;
} }
static void* __FileWrite(void* pFile, const char* pBuffer, size_t char_num) void* __FileWrite(void* pFile, const char* pBuffer, size_t char_num)
{ {
return (fwrite(pBuffer, 1, char_num, (FILE*)pFile) == char_num ? pFile : 0); return (fwrite(pBuffer, 1, char_num, (FILE*)pFile) == char_num ? pFile : 0);
} }
static void* __StringWrite(void* pCtrl, const char* pBuffer, size_t char_num) void* __StringWrite(void* pCtrl, const char* pBuffer, size_t char_num)
{ {
size_t chars; size_t chars;
__OutStrCtrl* ctrl = (__OutStrCtrl*)pCtrl; __OutStrCtrl* ctrl = (__OutStrCtrl*)pCtrl;
void* res;
chars = ((ctrl->CharsWritten + char_num) <= ctrl->MaxCharCount) chars = ((ctrl->CharsWritten + char_num) <= ctrl->MaxCharCount)
? char_num ? char_num
: ctrl->MaxCharCount - ctrl->CharsWritten; : ctrl->MaxCharCount - ctrl->CharsWritten;
res = memcpy(ctrl->CharStr + ctrl->CharsWritten, pBuffer, chars); memcpy(ctrl->CharStr + ctrl->CharsWritten, pBuffer, chars);
ctrl->CharsWritten += chars; ctrl->CharsWritten += chars;
return res; return (void*) 1;
} }
int printf(const char* format, ...) int printf(const char* format, ...)
@ -1056,16 +1120,15 @@ int vsnprintf(char* s, size_t n, const char* format, va_list arg)
end = __pformatter(&__StringWrite, &osc, format, arg); end = __pformatter(&__StringWrite, &osc, format, arg);
if (s) {
s[(end < n) ? end : n - 1] = '\0'; s[(end < n) ? end : n - 1] = '\0';
}
return end; return end;
} }
int snprintf(char* s, size_t n, const char* format, ...) int vsprintf(char *s, const char *format, va_list arg) {
{ return vsnprintf(s, 0xFFFFFFFF, format, arg);
va_list args;
va_start(args, format);
return vsnprintf(s, n, format, args);
} }
int sprintf(char* s, const char* format, ...) int sprintf(char* s, const char* format, ...)

View file

@ -0,0 +1,78 @@
/* @(#)s_floor.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunSoft, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
/*
* floor(x)
* Return x rounded toward -inf to integral value
* Method:
* Bit twiddling.
* Exception:
* Inexact flag raised if x not equal to floor(x).
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#ifdef __STDC__
static const double huge = 1.0e300;
#else
static double huge = 1.0e300;
#endif
#ifdef __STDC__
double floor(double x)
#else
double floor(x)
double x;
#endif
{
int i0,i1,j0;
unsigned i,j;
i0 = __HI(x);
i1 = __LO(x);
j0 = ((i0>>20)&0x7ff)-0x3ff;
if(j0<20) {
if(j0<0) { /* raise inexact if x != 0 */
if(huge+x>0.0) {/* return 0*sign(x) if |x|<1 */
if(i0>=0) {i0=i1=0;}
else if(((i0&0x7fffffff)|i1)!=0)
{ i0=0xbff00000;i1=0;}
}
} else {
i = (0x000fffff)>>j0;
if(((i0&i)|i1)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0<0) i0 += (0x00100000)>>j0;
i0 &= (~i); i1=0;
}
}
} else if (j0>51) {
if(j0==0x400) return x+x; /* inf or NaN */
else return x; /* x is integral */
} else {
i = ((unsigned)(0xffffffff))>>(j0-20);
if((i1&i)==0) return x; /* x is integral */
if(huge+x>0.0) { /* raise inexact flag */
if(i0<0) {
if(j0==20) i0+=1;
else {
j = i1+(1<<(52-j0));
if(j<i1) i0 +=1 ; /* got a carry */
i1=j;
}
}
i1 &= (~i);
}
}
__HI(x) = i0;
__LO(x) = i1;
return x;
}

View file

@ -1,4 +1,4 @@
/* @(#)s_ldexp.c 1.3 95/01/18 */ /* @(#)s_scalbn.c 1.3 95/01/18 */
/* /*
* ==================================================== * ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@ -10,18 +10,55 @@
* ==================================================== * ====================================================
*/ */
/*
* scalbn (double x, int n)
* scalbn(x,n) returns x* 2**n computed by exponent
* manipulation rather than by actually performing an
* exponentiation or a multiplication.
*/
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/float.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h" #include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common_Embedded/Math/fdlibm.h"
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/errno.h"
#ifdef __STDC__ #ifdef __STDC__
double ldexp(double value, int exp) static const double
#else #else
double ldexp(value, exp) static double
double value; int exp; #endif
two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
twom54 = 5.55111512312578270212e-17, /* 0x3C900000, 0x00000000 */
huge = 1.0e+300,
tiny = 1.0e-300;
#ifdef __STDC__
double ldexp (double x, int n)
#else
double ldexp (x,n)
double x; int n;
#endif #endif
{ {
if(!finite(value)||value==0.0) return value; int k,hx,lx;
value = scalbn(value,exp); if(!isfinite(x)||x==0.0) return x;
if(!finite(value)||value==0.0) errno = ERANGE; hx = __HI(x);
return value; lx = __LO(x);
k = (hx&0x7ff00000)>>20; /* extract exponent */
if (k==0) { /* 0 or subnormal x */
if ((lx|(hx&0x7fffffff))==0) return x; /* +-0 */
x *= two54;
hx = __HI(x);
k = ((hx&0x7ff00000)>>20) - 54;
if (n< -50000) return tiny*x; /*underflow*/
}
if (k==0x7ff) return x+x; /* NaN or Inf */
k = k+n;
if (k > 0x7fe) return huge*copysign(huge,x); /* overflow */
if (k > 0) /* normal result */
{__HI(x) = (hx&0x800fffff)|(k<<20); return x;}
if (k <= -54)
if (n > 50000) /* in case integer overflow in n+k */
return huge*copysign(huge,x); /*overflow*/
else return tiny*copysign(tiny,x); /*underflow*/
k += 54; /* subnormal result */
__HI(x) = (hx&0x800fffff)|(k<<20);
return x*twom54;
} }

View file

@ -0,0 +1,24 @@
#include <stddef.h>
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/signal.h"
__signal_func_ptr signal_funcs[6];
int raise(int sig) {
__signal_func_ptr temp_r31;
if (sig < 1 || sig > 6) {
return -1;
}
temp_r31 = signal_funcs[sig - 1];
if ((unsigned long) temp_r31 != 1) {
signal_funcs[sig - 1] = NULL;
}
if ((unsigned long) temp_r31 == 1 || (temp_r31 == NULL && sig == 1)) {
return 0;
}
if (temp_r31 == NULL) {
exit(0);
}
temp_r31(sig);
return 0;
}

View file

@ -1,8 +1,8 @@
#include "string.h" #include "string.h"
#include "stddef.h" #include "stddef.h"
static int K1 = 0x80808080; #define K1 0x80808080
static int K2 = 0xFEFEFEFF; #define K2 0xFEFEFEFF
size_t strlen(const char* str) size_t strlen(const char* str)
{ {
@ -20,8 +20,6 @@ char* strcpy(char* dst, const char* src)
{ {
register unsigned char *destb, *fromb; register unsigned char *destb, *fromb;
register unsigned long w, t, align; register unsigned long w, t, align;
register unsigned int k1;
register unsigned int k2;
fromb = (unsigned char*)src; fromb = (unsigned char*)src;
destb = (unsigned char*)dst; destb = (unsigned char*)dst;
@ -44,14 +42,11 @@ char* strcpy(char* dst, const char* src)
++fromb; ++fromb;
} }
k1 = K1;
k2 = K2;
w = *((int*)(fromb)); w = *((int*)(fromb));
t = w + k2; t = w + K2;
t &= k1; t &= K1;
if (t) { if (t) {
goto bytecopy; goto bytecopy;
} }
@ -61,8 +56,8 @@ char* strcpy(char* dst, const char* src)
*(++((int*)(destb))) = w; *(++((int*)(destb))) = w;
w = *(++((int*)(fromb))); w = *(++((int*)(fromb)));
t = w + k2; t = w + K2;
t &= k1; t &= K1;
if (t) { if (t) {
goto adjust; goto adjust;
} }
@ -103,16 +98,21 @@ char* strncpy(char* dst, const char* src, size_t n)
return dst; return dst;
} }
char* strcat(char* dst, const char* src) // TODO: same implementation as strncpy?
char* strcat(char* dst, const char* src, size_t n)
{ {
const unsigned char* p = (unsigned char*)src - 1; const unsigned char* p = (const unsigned char*)src - 1;
unsigned char* q = (unsigned char*)dst - 1; unsigned char* q = (unsigned char*)dst - 1;
while (*++q) { } n++;
while (--n) {
q--; if (!(*++q = *++p)) {
while (--n) {
while (*++q = *++p) { } *++q = 0;
}
break;
}
}
return dst; return dst;
} }
@ -196,6 +196,22 @@ bytecopy:
} while (1); } while (1);
} }
int strncmp(const char* str1, const char* str2, size_t n)
{
const unsigned char* p1 = (unsigned char*)str1 - 1;
const unsigned char* p2 = (unsigned char*)str2 - 1;
unsigned long c1, c2;
n++;
while (--n)
if ((c1 = *++p1) != (c2 = *++p2))
return (c1 - c2);
else if (!c1)
break;
return 0;
}
char* strchr(const char* str, int c) char* strchr(const char* str, int c)
{ {
const unsigned char* p = (unsigned char*)str - 1; const unsigned char* p = (unsigned char*)str - 1;

View file

@ -0,0 +1,32 @@
#include "PowerPC_EABI_Support/Msl/MSL_C/MSL_Common/ansi_files.h"
static inline int __init_uart_console(void) {
int err = 0;
static int initialized = 0;
if (initialized == 0) {
err = InitializeUART(57600);
if (err == 0)
initialized = 1;
}
return (err);
}
int __write_console(__file_handle handle, unsigned char* buffer, size_t* count, __idle_proc idle_proc) {
if (__init_uart_console() != 0) {
return 1;
}
if (WriteUARTN(buffer, *count) != 0) {
*count = 0;
return 1;
}
__TRK_write_console(handle, buffer, count, idle_proc);
return 0;
}
int __close_console() {
return 0;
}

View file

@ -2,7 +2,7 @@
int fwide(FILE* file, int mode) int fwide(FILE* file, int mode)
{ {
if (file->file_mode.file_kind == __closed_file) { if (!file || file->file_mode.file_kind == __closed_file) {
return 0; return 0;
} }

View file

@ -449,15 +449,15 @@ void fn_1_A37C(ModelData *model, ParticleData *particle, Mtx matrix)
else { else {
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) { for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) {
if (temp_r31->unk00_s16) { if (temp_r31->unk00) {
temp_r31->unk34.x += temp_r31->unk08.x; temp_r31->unk34.x += temp_r31->unk08.x;
temp_r31->unk34.y += temp_r31->unk08.y; temp_r31->unk34.y += temp_r31->unk08.y;
temp_r31->unk34.z += temp_r31->unk08.z; temp_r31->unk34.z += temp_r31->unk08.z;
temp_r31->unk2C += temp_r31->unk14.x; temp_r31->unk2C += temp_r31->unk14.x;
temp_r31->unk14.y -= temp_r31->unk14.z; temp_r31->unk14.y -= temp_r31->unk14.z;
temp_r31->unk40.a = temp_r31->unk14.y; temp_r31->unk40.a = temp_r31->unk14.y;
if (--temp_r31->unk00_s16 == 0) { if (--temp_r31->unk00 == 0) {
temp_r31->unk00_s16 = 0; temp_r31->unk00 = 0;
temp_r31->unk2C = 0; temp_r31->unk2C = 0;
temp_r31->unk40.a = 0; temp_r31->unk40.a = 0;
} }
@ -477,10 +477,10 @@ void fn_1_A4E8(s32 arg0, Vec *arg1, u32 arg2)
if (temp_r30->unk_00) { if (temp_r30->unk_00) {
temp_r31 = temp_r30->unk_48; temp_r31 = temp_r30->unk_48;
for (temp_r29 = 0; temp_r29 < temp_r30->unk_30; temp_r29++, temp_r31++) { for (temp_r29 = 0; temp_r29 < temp_r30->unk_30; temp_r29++, temp_r31++) {
if (temp_r31->unk00_s16 != 0) { if (temp_r31->unk00 != 0) {
continue; continue;
} }
temp_r31->unk00_s16 = 60.0f * (((1.5f / 1000.0f) * frandmod(1000)) + 1.0f); temp_r31->unk00 = 60.0f * (((1.5f / 1000.0f) * frandmod(1000)) + 1.0f);
temp_r31->unk34.x = arg1->x; temp_r31->unk34.x = arg1->x;
temp_r31->unk34.y = 12000; temp_r31->unk34.y = 12000;
temp_r31->unk34.z = arg1->z; temp_r31->unk34.z = arg1->z;
@ -491,7 +491,7 @@ void fn_1_A4E8(s32 arg0, Vec *arg1, u32 arg2)
temp_r31->unk2C = 10; temp_r31->unk2C = 10;
temp_r31->unk40.a = frandmod(127) + 64; temp_r31->unk40.a = frandmod(127) + 64;
temp_r31->unk14.y = temp_r31->unk40.a; temp_r31->unk14.y = temp_r31->unk40.a;
temp_r31->unk14.z = temp_r31->unk14.y * (1.0f / temp_r31->unk00_s16); temp_r31->unk14.z = temp_r31->unk14.y * (1.0f / temp_r31->unk00);
temp_f31 = frandmod(1000) * (1.0f / 1000.0f); temp_f31 = frandmod(1000) * (1.0f / 1000.0f);
temp_r31->unk40.r = (temp_f31 * 55) + 200; temp_r31->unk40.r = (temp_f31 * 55) + 200;
temp_r31->unk40.g = (temp_f31 * 50) + 205; temp_r31->unk40.g = (temp_f31 * 50) + 205;
@ -549,7 +549,7 @@ void fn_1_A894(ModelData *model, ParticleData *particle, Mtx matrix)
else { else {
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) { for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) {
if (temp_r31->unk00_s16 == 0) { if (temp_r31->unk00 == 0) {
continue; continue;
} }
sp8.x = sind(CRot.y) * cosd(CRot.x); sp8.x = sind(CRot.y) * cosd(CRot.x);
@ -649,7 +649,7 @@ void fn_1_AFF4(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r30 = particle->unk_48; temp_r30 = particle->unk_48;
temp_f30 = 0; temp_f30 = 0;
for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r30++) { for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r30++) {
if (temp_r30->unk00_s16 == 0) { if (temp_r30->unk00 == 0) {
continue; continue;
} }
temp_f30 += 1.0f / particle->unk_30; temp_f30 += 1.0f / particle->unk_30;
@ -751,15 +751,15 @@ void fn_1_BDE0(void)
Vec sp14; Vec sp14;
Vec sp8; Vec sp8;
temp_r31 = lbl_1_bss_A4[0]; temp_r31 = lbl_1_bss_A4[0];
temp_r31->unk00_s16++; temp_r31->unk00++;
if (temp_r31->unk00_s16 < 339.0f) { if (temp_r31->unk00 < 339.0f) {
return; return;
} }
if (temp_r31->unk00_s16 >= 600.0f) { if (temp_r31->unk00 >= 600.0f) {
temp_r31->unk00_s16 = 601; temp_r31->unk00 = 601;
for (temp_r30 = 0; temp_r30 < lbl_1_bss_A0; temp_r30++) { for (temp_r30 = 0; temp_r30 < lbl_1_bss_A0; temp_r30++) {
temp_r31 = lbl_1_bss_A4[temp_r30]; temp_r31 = lbl_1_bss_A4[temp_r30];
temp_r31->unk00_s16 = 0; temp_r31->unk00 = 0;
temp_r31->unk2C = 0; temp_r31->unk2C = 0;
temp_r31->unk40.a = 0; temp_r31->unk40.a = 0;
} }

View file

@ -1127,7 +1127,7 @@ void fn_1_5AB4(ModelData *model, ParticleData *particle, Mtx matrix)
} }
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) { for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) {
if (temp_r31->unk00_s16 == 0 || temp_r31->unk00_s16 != 1) { if (temp_r31->unk00 == 0 || temp_r31->unk00 != 1) {
continue; continue;
} }
temp_r31->unk02++; temp_r31->unk02++;
@ -1163,7 +1163,7 @@ void fn_1_5DCC(s32 arg0, Vec *arg1, u32 arg2)
if (temp_r29->unk_00 != 0) { if (temp_r29->unk_00 != 0) {
temp_r31 = temp_r29->unk_48; temp_r31 = temp_r29->unk_48;
for (temp_r28 = 0; temp_r28 < temp_r29->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < temp_r29->unk_30; temp_r28++, temp_r31++) {
if (temp_r31->unk00_s16) { if (temp_r31->unk00) {
continue; continue;
} }
temp_r31->unk00 = 1; temp_r31->unk00 = 1;

View file

@ -1332,8 +1332,8 @@ void fn_1_15658(ModelData *model, ParticleData *particle, Mtx matrix)
} }
temp_r31->unk40.a = temp_r29; temp_r31->unk40.a = temp_r29;
} }
temp_r31->unk00_s16--; temp_r31->unk00--;
if (temp_r31->unk00_s16 <= 0) { if (temp_r31->unk00 <= 0) {
temp_r31->unk2C = 0; temp_r31->unk2C = 0;
} }
} }
@ -1501,8 +1501,8 @@ void fn_1_15D64(ModelData *model, ParticleData *particle, Mtx matrix)
} }
temp_r31->unk40.a = temp_r28; temp_r31->unk40.a = temp_r28;
} }
temp_r31->unk00_s16--; temp_r31->unk00--;
if (temp_r31->unk00_s16 <= 0) { if (temp_r31->unk00 <= 0) {
temp_r31->unk2C = 0; temp_r31->unk2C = 0;
} }
} }

View file

@ -413,7 +413,7 @@ s16 fn_1_D978(AnimData *arg0, s16 arg1, ParticleHook arg2)
} }
temp_r30 = HuMemDirectMallocNum(HEAP_SYSTEM, sizeof(HsfanimStruct01), MEMORY_DEFAULT_NUM); temp_r30 = HuMemDirectMallocNum(HEAP_SYSTEM, sizeof(HsfanimStruct01), MEMORY_DEFAULT_NUM);
temp_r29->unk_1C = temp_r30; temp_r29->unk_1C = temp_r30;
temp_r30->unk00_s16 = temp_r28; temp_r30->unk00 = temp_r28;
temp_r30->unk02 = 0; temp_r30->unk02 = 0;
for (temp_r31 = 0; temp_r31 < 32; temp_r31++) { for (temp_r31 = 0; temp_r31 < 32; temp_r31++) {
// Ugly expression to match store without new type // Ugly expression to match store without new type
@ -449,7 +449,7 @@ void fn_1_DA6C(ModelData *model, ParticleData *particle, Mtx matrix)
for (temp_r28 = 0; temp_r28 < 100; temp_r28++) { for (temp_r28 = 0; temp_r28 < 100; temp_r28++) {
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r27 = 0; temp_r27 < particle->unk_30; temp_r27++, temp_r31++) { for (temp_r27 = 0; temp_r27 < particle->unk_30; temp_r27++, temp_r31++) {
if (!temp_r31->unk00_s16) { if (!temp_r31->unk00) {
break; break;
} }
} }
@ -472,13 +472,13 @@ void fn_1_DA6C(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk2C = (0.01 * (frand() % 2000)) + 30.0; temp_r31->unk2C = (0.01 * (frand() % 2000)) + 30.0;
temp_r31->unk2C *= 0.1f; temp_r31->unk2C *= 0.1f;
temp_r31->unk40.a = 255; temp_r31->unk40.a = 255;
temp_r31->unk00_s16 = 30; temp_r31->unk00 = 30;
} }
break; break;
} }
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
if (temp_r31->unk00_s16 == 0) { if (temp_r31->unk00 == 0) {
continue; continue;
} }
temp_f30 = temp_r31->unk14.x; temp_f30 = temp_r31->unk14.x;
@ -493,7 +493,7 @@ void fn_1_DA6C(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk08.y += 0.1f; temp_r31->unk08.y += 0.1f;
if (temp_r31->unk40.a < 2) { if (temp_r31->unk40.a < 2) {
temp_r31->unk40.a = 0; temp_r31->unk40.a = 0;
temp_r31->unk00_s16 = 0; temp_r31->unk00 = 0;
particle->unk_00++; particle->unk_00++;
} }
} }
@ -566,7 +566,7 @@ void fn_1_E310(ModelData *model, ParticleData *particle, Mtx matrix)
temp_f30 = 360.0f / particle->unk_30; temp_f30 = 360.0f / particle->unk_30;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
temp_r31->unk00_s16 = (s32)(360.0 * ((1.0 / 65536.0) * (float)fn_1_11670())); temp_r31->unk00 = (s32)(360.0 * ((1.0 / 65536.0) * (float)fn_1_11670()));
temp_r31->unk34.x = temp_r31->unk34.y = temp_r31->unk34.z = 0; temp_r31->unk34.x = temp_r31->unk34.y = temp_r31->unk34.z = 0;
temp_r26 = (temp_f30 * temp_r28) + (int)((temp_f30 * 0.5f) * ((1.0 / 32768.0) * (float)(fn_1_11670() - 32768))); temp_r26 = (temp_f30 * temp_r28) + (int)((temp_f30 * 0.5f) * ((1.0 / 32768.0) * (float)(fn_1_11670() - 32768)));
temp_r31->unk20 = temp_r26; temp_r31->unk20 = temp_r26;
@ -598,15 +598,15 @@ void fn_1_E310(ModelData *model, ParticleData *particle, Mtx matrix)
case 1: case 1:
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
temp_r31->unk00_s16 += 4; temp_r31->unk00 += 4;
if (temp_r31->unk00_s16 >= 360) { if (temp_r31->unk00 >= 360) {
temp_r31->unk00_s16 -= 360; temp_r31->unk00 -= 360;
} }
temp_r31->unk34.x = temp_r31->unk14.x; temp_r31->unk34.x = temp_r31->unk14.x;
temp_r31->unk34.y = temp_r31->unk14.y; temp_r31->unk34.y = temp_r31->unk14.y;
temp_r31->unk34.z = temp_r31->unk14.z; temp_r31->unk34.z = temp_r31->unk14.z;
temp_r31->unk30 = M_PI * (90 + (temp_r31->unk20 + temp_r29->unk_04.z)) / 180; temp_r31->unk30 = M_PI * (90 + (temp_r31->unk20 + temp_r29->unk_04.z)) / 180;
temp_r31->unk2C = temp_r31->unk24 * ((0.1f * sind(temp_r31->unk00_s16)) + 1.0); temp_r31->unk2C = temp_r31->unk24 * ((0.1f * sind(temp_r31->unk00)) + 1.0);
} }
break; break;
} }
@ -627,7 +627,7 @@ void fn_1_E9B4(ModelData *model, ParticleData *particle, Mtx matrix)
case 0: case 0:
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
temp_r31->unk00_s16 = fn_1_11670() % 360; temp_r31->unk00 = fn_1_11670() % 360;
temp_r31->unk34.x = temp_r31->unk34.y = temp_r31->unk34.z = 0; temp_r31->unk34.x = temp_r31->unk34.y = temp_r31->unk34.z = 0;
temp_r27 = fn_1_11670() % 360; temp_r27 = fn_1_11670() % 360;
temp_r31->unk20 = temp_r27; temp_r31->unk20 = temp_r27;
@ -653,14 +653,14 @@ void fn_1_E9B4(ModelData *model, ParticleData *particle, Mtx matrix)
case 1: case 1:
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
temp_r31->unk00_s16 += 2; temp_r31->unk00 += 2;
if (temp_r31->unk00_s16 >= 360) { if (temp_r31->unk00 >= 360) {
temp_r31->unk00_s16 -= 360; temp_r31->unk00 -= 360;
} }
temp_r31->unk34.x = temp_r31->unk14.x; temp_r31->unk34.x = temp_r31->unk14.x;
temp_r31->unk34.y = temp_r31->unk14.y; temp_r31->unk34.y = temp_r31->unk14.y;
temp_r31->unk34.z = temp_r31->unk14.z; temp_r31->unk34.z = temp_r31->unk14.z;
temp_r31->unk2C = temp_r31->unk24 * ((0.1f * sind(temp_r31->unk00_s16)) + 1.0); temp_r31->unk2C = temp_r31->unk24 * ((0.1f * sind(temp_r31->unk00)) + 1.0);
} }
break; break;
} }
@ -718,7 +718,7 @@ void fn_1_F06C(ModelData *model, ParticleData *particle, Mtx matrix)
case 0: case 0:
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
temp_r31->unk00_s16 = temp_r31->unk02 = 0; temp_r31->unk00 = temp_r31->unk02 = 0;
} }
temp_r29->unk_02++; temp_r29->unk_02++;
break; break;
@ -726,8 +726,8 @@ void fn_1_F06C(ModelData *model, ParticleData *particle, Mtx matrix)
case 1: case 1:
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r28++, temp_r31++) {
if (temp_r31->unk00_s16) { if (temp_r31->unk00) {
temp_r31->unk00_s16--; temp_r31->unk00--;
continue; continue;
} }
if (temp_r31->unk02 == 0) { if (temp_r31->unk02 == 0) {
@ -739,7 +739,7 @@ void fn_1_F06C(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk40.r = temp_r31->unk40.g = temp_r31->unk40.b = temp_r31->unk40.a = 192; temp_r31->unk40.r = temp_r31->unk40.g = temp_r31->unk40.b = temp_r31->unk40.a = 192;
temp_r31->unk40.b = 160; temp_r31->unk40.b = 160;
temp_r31->unk2C = 0; temp_r31->unk2C = 0;
temp_r31->unk00_s16 = (s32)(90.0 * ((1.0 / 65536.0) * (float)fn_1_11670())); temp_r31->unk00 = (s32)(90.0 * ((1.0 / 65536.0) * (float)fn_1_11670()));
temp_r31->unk02 = 60; temp_r31->unk02 = 60;
} }
temp_r31->unk40.a = 248 * sind(temp_r31->unk02 * 3); temp_r31->unk40.a = 248 * sind(temp_r31->unk02 * 3);

View file

@ -1425,7 +1425,6 @@ static inline void PadInline(void)
(void)var_f27; (void)var_f27;
} }
// fn_1_6814: https://decomp.me/scratch/WQPjD
void fn_1_6814(unkStruct3 *arg0) void fn_1_6814(unkStruct3 *arg0)
{ {
Vec sp104; Vec sp104;

View file

@ -1609,7 +1609,7 @@ void fn_1_613C(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk34.y = (64.0f * ((1.0f / 256.0f) * frand8())); temp_r31->unk34.y = (64.0f * ((1.0f / 256.0f) * frand8()));
temp_r31->unk34.z = (4.0f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1)); temp_r31->unk34.z = (4.0f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1));
temp_r31->unk30 = 360.0f * ((1.0f / 256.0f) * frand8()); temp_r31->unk30 = 360.0f * ((1.0f / 256.0f) * frand8());
temp_r31->unk00_s16 = frand8(); temp_r31->unk00 = frand8();
temp_r31->unk02 = (frand() & 0x3) + 4; temp_r31->unk02 = (frand() & 0x3) + 4;
} }
temp_f29 = temp_f28 = 0; temp_f29 = temp_f28 = 0;
@ -1620,7 +1620,7 @@ void fn_1_613C(ModelData *model, ParticleData *particle, Mtx matrix)
} }
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r31++, temp_r29++) { for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r31++, temp_r29++) {
temp_f30 = temp_r31->unk00_s16 / 255.0f; temp_f30 = temp_r31->unk00 / 255.0f;
temp_f31 = temp_f30 * temp_f30; temp_f31 = temp_f30 * temp_f30;
temp_r31->unk34.x += temp_f29 * temp_f31; temp_r31->unk34.x += temp_f29 * temp_f31;
temp_r31->unk34.y = 60.0f * temp_f30; temp_r31->unk34.y = 60.0f * temp_f30;
@ -1628,12 +1628,12 @@ void fn_1_613C(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk40.a = 255.0f * (1.0f - temp_f30); temp_r31->unk40.a = 255.0f * (1.0f - temp_f30);
temp_f31 = 0.5 * (1 + sind(270.0f * temp_f30)); temp_f31 = 0.5 * (1 + sind(270.0f * temp_f30));
temp_r31->unk2C = temp_f31 * (temp_r31->unk08.x * temp_f31); temp_r31->unk2C = temp_f31 * (temp_r31->unk08.x * temp_f31);
temp_r31->unk00_s16 += temp_r31->unk02; temp_r31->unk00 += temp_r31->unk02;
if (temp_r31->unk00_s16 > 255) { if (temp_r31->unk00 > 255) {
temp_r31->unk34.x = (4.0f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1)); temp_r31->unk34.x = (4.0f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1));
temp_r31->unk34.y = 0; temp_r31->unk34.y = 0;
temp_r31->unk34.z = (4.0f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1)); temp_r31->unk34.z = (4.0f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1));
temp_r31->unk00_s16 = 0; temp_r31->unk00 = 0;
} }
} }
DCStoreRangeNoSync(particle->unk_48, particle->unk_30 * sizeof(HsfanimStruct01)); DCStoreRangeNoSync(particle->unk_48, particle->unk_30 * sizeof(HsfanimStruct01));
@ -1664,7 +1664,7 @@ void fn_1_6640(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk08.z = temp_f30 * cosd(temp_f31); temp_r31->unk08.z = temp_f30 * cosd(temp_f31);
temp_r31->unk40.r = temp_r31->unk40.g = temp_r31->unk40.b = 255; temp_r31->unk40.r = temp_r31->unk40.g = temp_r31->unk40.b = 255;
temp_r31->unk40.a = 0; temp_r31->unk40.a = 0;
temp_r31->unk00_s16 = ((float)particle->unk_3C) * ((float)temp_r28 / (float)particle->unk_30); temp_r31->unk00 = ((float)particle->unk_3C) * ((float)temp_r28 / (float)particle->unk_30);
} }
} }
else { else {
@ -1674,25 +1674,25 @@ void fn_1_6640(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r27 = 0; temp_r27 = 0;
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r31++, temp_r28++) { for (temp_r28 = 0; temp_r28 < particle->unk_30; temp_r31++, temp_r28++) {
if (temp_r31->unk00_s16 >= 0) { if (temp_r31->unk00 >= 0) {
if (temp_r31->unk00_s16 == 0) { if (temp_r31->unk00 == 0) {
temp_r31->unk34.x += temp_r31->unk08.x + temp_f29; temp_r31->unk34.x += temp_r31->unk08.x + temp_f29;
temp_r31->unk34.y += temp_r31->unk08.y; temp_r31->unk34.y += temp_r31->unk08.y;
temp_r31->unk34.z += temp_r31->unk08.z + temp_f28; temp_r31->unk34.z += temp_r31->unk08.z + temp_f28;
temp_r31->unk08.y += -1.0000001f; temp_r31->unk08.y += -1.0000001f;
if (temp_r31->unk40.a) { if (temp_r31->unk40.a) {
if (--temp_r31->unk40.a == 0) { if (--temp_r31->unk40.a == 0) {
temp_r31->unk00_s16 = -1; temp_r31->unk00 = -1;
} }
} }
if (temp_r31->unk34.y < 0.0f) { if (temp_r31->unk34.y < 0.0f) {
temp_r31->unk34.y = 0; temp_r31->unk34.y = 0;
temp_r31->unk00_s16 = -1; temp_r31->unk00 = -1;
temp_r31->unk40.a = 0; temp_r31->unk40.a = 0;
} }
} }
else { else {
if (--temp_r31->unk00_s16 == 0) { if (--temp_r31->unk00 == 0) {
temp_r31->unk40.a = 255; temp_r31->unk40.a = 255;
} }
} }
@ -1728,12 +1728,12 @@ void fn_1_6AE8(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r31->unk08.y = 100.0f * (0.05f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1.0f)); temp_r31->unk08.y = 100.0f * (0.05f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1.0f));
temp_r31->unk08.z = 100.0f * (0.05f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1.0f)); temp_r31->unk08.z = 100.0f * (0.05f * (((1.0f / 256.0f) * ((s32)frand() & 0x1FF)) - 1.0f));
temp_r31->unk40.a = 128; temp_r31->unk40.a = 128;
temp_r31->unk00_s16 = 0; temp_r31->unk00 = 0;
} }
} }
temp_r31 = particle->unk_48; temp_r31 = particle->unk_48;
for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) { for (temp_r29 = 0; temp_r29 < particle->unk_30; temp_r29++, temp_r31++) {
if (temp_r31->unk00_s16 < 0) { if (temp_r31->unk00 < 0) {
temp_r27++; temp_r27++;
continue; continue;
} }
@ -1746,7 +1746,7 @@ void fn_1_6AE8(ModelData *model, ParticleData *particle, Mtx matrix)
temp_r28 = temp_r31->unk40.a; temp_r28 = temp_r31->unk40.a;
temp_r28 -= 4; temp_r28 -= 4;
if (temp_r28 < 0) { if (temp_r28 < 0) {
temp_r31->unk00_s16 = -1; temp_r31->unk00 = -1;
temp_r28 = 0; temp_r28 = 0;
} }
temp_r31->unk40.a = temp_r28; temp_r31->unk40.a = temp_r28;

View file

@ -892,7 +892,7 @@ void fn_1_6B94(ModelData *model, ParticleData *particle, float (*matrix)[4])
particle->unk_00++; particle->unk_00++;
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
@ -900,16 +900,16 @@ void fn_1_6B94(ModelData *model, ParticleData *particle, float (*matrix)[4])
} }
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16) { if (var_r31->unk00) {
var_r31->unk34.x += var_r31->unk08.x; var_r31->unk34.x += var_r31->unk08.x;
var_r31->unk34.y += var_r31->unk08.y; var_r31->unk34.y += var_r31->unk08.y;
var_r31->unk34.z += var_r31->unk08.z; var_r31->unk34.z += var_r31->unk08.z;
var_r31->unk08.y += -0.27222225f; var_r31->unk08.y += -0.27222225f;
if (var_r31->unk00_s16 < 12.0f) { if (var_r31->unk00 < 12.0f) {
var_r31->unk40.a = 0.88f * var_r31->unk40.a; var_r31->unk40.a = 0.88f * var_r31->unk40.a;
} }
if (!(--var_r31->unk00_s16)) { if (!(--var_r31->unk00)) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
@ -951,7 +951,7 @@ void fn_1_6D64(s32 arg0, u32 arg1, float arg8, float arg9, float argA)
var_f27 = 0.0f; var_f27 = 0.0f;
} }
for (var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16) { if (var_r31->unk00) {
continue; continue;
} }
var_r31->unk00 = 60.0f * (1.0f + (0.0005f * frandmod(1000))); var_r31->unk00 = 60.0f * (1.0f + (0.0005f * frandmod(1000)));

View file

@ -1606,14 +1606,14 @@ void fn_1_9C38(ModelData *model, ParticleData *particle, Mtx matrix)
s32 var_r29; s32 var_r29;
for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk2C += 2.0f; var_r31->unk2C += 2.0f;
var_r31->unk40.a *= 0.98f; var_r31->unk40.a *= 0.98f;
if (var_r31->unk00_s16 < 24.0f) { if (var_r31->unk00 < 24.0f) {
var_r31->unk40.a = 0.9f * var_r31->unk40.a; var_r31->unk40.a = 0.9f * var_r31->unk40.a;
} }
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
@ -1649,10 +1649,10 @@ void fn_1_9DD0(omObjData *object, Vec *arg1)
spC[2] = (220.0f + (0.13725491f * sp14.b)) - sp10[2]; spC[2] = (220.0f + (0.13725491f * sp14.b)) - sp10[2];
var_r26 = 0x64; var_r26 = 0x64;
for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
continue; continue;
} }
var_r31->unk00_s16 = 60.0f * (0.6f + (0.0005f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.6f + (0.0005f * frandmod(0x3E8)));
var_f31 = frandmod(0x168); var_f31 = frandmod(0x168);
var_f30 = frandmod(0x168); var_f30 = frandmod(0x168);
sp18.y = sind(var_f31); sp18.y = sind(var_f31);

View file

@ -1402,7 +1402,7 @@ void fn_1_9410(ModelData *model, ParticleData *particle, Mtx matrix)
if (particle->unk_34 < 50) { if (particle->unk_34 < 50) {
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (i = 0; i < particle->unk_30; i++, var_r31++) { for (i = 0; i < particle->unk_30; i++, var_r31++) {
var_r31->unk00_s16 = particle->unk_34 + 41; var_r31->unk00 = particle->unk_34 + 41;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
@ -1410,7 +1410,7 @@ void fn_1_9410(ModelData *model, ParticleData *particle, Mtx matrix)
if (particle->unk_34 >= 255) { if (particle->unk_34 >= 255) {
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (i = 0; i < particle->unk_30; i++, var_r31++) { for (i = 0; i < particle->unk_30; i++, var_r31++) {
var_r31->unk00_s16 = 255; var_r31->unk00 = 255;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
@ -1423,7 +1423,7 @@ void fn_1_9410(ModelData *model, ParticleData *particle, Mtx matrix)
} }
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (i = 0; i < particle->unk_30; i++, var_r31++) { for (i = 0; i < particle->unk_30; i++, var_r31++) {
if (var_r31->unk00_s16 == 104) { if (var_r31->unk00 == 104) {
var_r31->unk34.x = var_r31->unk34.z = 0.0f; var_r31->unk34.x = var_r31->unk34.z = 0.0f;
var_r31->unk34.y = 72.0f; var_r31->unk34.y = 72.0f;
temp_f31 = frandu8() * 360 / 256; temp_f31 = frandu8() * 360 / 256;
@ -1440,7 +1440,7 @@ void fn_1_9410(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk2C = 50.0f; var_r31->unk2C = 50.0f;
VECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34); VECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34);
} }
if (var_r31->unk00_s16 < 240) { if (var_r31->unk00 < 240) {
VECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34); VECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34);
var_r31->unk08.x *= 0.9f; var_r31->unk08.x *= 0.9f;
var_r31->unk08.z *= 0.9f; var_r31->unk08.z *= 0.9f;
@ -1456,7 +1456,7 @@ void fn_1_9410(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
} }
var_r31->unk00_s16 += (var_r31->unk00_s16 < 0x8000); var_r31->unk00 += (var_r31->unk00 < 0x8000);
} }
} }

View file

@ -1300,14 +1300,14 @@ void fn_1_4A88(ModelData *model, ParticleData *particle, Mtx matrix)
switch (var_r29->unk_04) { switch (var_r29->unk_04) {
case 0: case 0:
for (var_r31 = particle->unk_48, var_r28 = 0; var_r28 < particle->unk_30; var_r28++, var_r31++) { for (var_r31 = particle->unk_48, var_r28 = 0; var_r28 < particle->unk_30; var_r28++, var_r31++) {
var_r31->unk00_s16 = var_r31->unk02 = 0; var_r31->unk00 = var_r31->unk02 = 0;
} }
var_r29->unk_04++; var_r29->unk_04++;
break; break;
case 1: case 1:
for (var_r31 = particle->unk_48, var_r28 = 0; var_r28 < particle->unk_30; var_r28++, var_r31++) { for (var_r31 = particle->unk_48, var_r28 = 0; var_r28 < particle->unk_30; var_r28++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
var_r31->unk00_s16--; var_r31->unk00--;
} }
else { else {
if (var_r31->unk02 == 0) { if (var_r31->unk02 == 0) {
@ -1325,7 +1325,7 @@ void fn_1_4A88(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk40.r = var_r31->unk40.g = var_r31->unk40.b = var_r31->unk40.a = 0xC0; var_r31->unk40.r = var_r31->unk40.g = var_r31->unk40.b = var_r31->unk40.a = 0xC0;
var_r31->unk40.b = 0xA0; var_r31->unk40.b = 0xA0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk00_s16 = (s32)(90.0 * (1.52587890625e-05 * (float)fn_1_64D4())); var_r31->unk00 = (s32)(90.0 * (1.52587890625e-05 * (float)fn_1_64D4()));
var_r31->unk02 = 0x3C; var_r31->unk02 = 0x3C;
var_r31->unk40.r = 0xC0; var_r31->unk40.r = 0xC0;
var_r31->unk40.g = 0xE0; var_r31->unk40.g = 0xE0;

2361
src/REL/m427Dll/player.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -631,7 +631,7 @@ void fn_1_6280(ModelData *arg1, ParticleData *particle, Mtx matrix)
break; break;
} }
for (var_r31 = particle->unk_48, var_r27 = 0, var_r28 = 0; var_r28 < particle->unk_30; var_r28++, var_r31++) { for (var_r31 = particle->unk_48, var_r27 = 0, var_r28 = 0; var_r28 < particle->unk_30; var_r28++, var_r31++) {
switch (var_r31->unk00_s16) { switch (var_r31->unk00) {
case 0: case 0:
if (((var_r28 > (0.4f * particle->unk_30)) && (particle->unk_04.x == 0.0f)) || (var_r27 >= (10.0f + (0.75f * particle->unk_04.x)))) { if (((var_r28 > (0.4f * particle->unk_30)) && (particle->unk_04.x == 0.0f)) || (var_r27 >= (10.0f + (0.75f * particle->unk_04.x)))) {
var_r31->unk2C = 0.01f; var_r31->unk2C = 0.01f;
@ -662,7 +662,7 @@ void fn_1_6280(ModelData *arg1, ParticleData *particle, Mtx matrix)
var_r31->unk40.r = var_r31->unk40.g = var_r31->unk40.b = 0xFF; var_r31->unk40.r = var_r31->unk40.g = var_r31->unk40.b = 0xFF;
var_r31->unk02 = 0; var_r31->unk02 = 0;
var_r27++; var_r27++;
var_r31->unk00_s16++; var_r31->unk00++;
} }
break; break;
case 1: case 1:

View file

@ -2044,7 +2044,7 @@ void fn_1_11D70(void)
var_r25 = &Hu3DData[var_r31->unk_04]; var_r25 = &Hu3DData[var_r31->unk_04];
var_r29 = var_r25->unk_120; var_r29 = var_r25->unk_120;
for (var_r30 = var_r29->unk_48, var_r27 = 0; var_r27 < var_r29->unk_30; var_r27++, var_r30++) { for (var_r30 = var_r29->unk_48, var_r27 = 0; var_r27 < var_r29->unk_30; var_r27++, var_r30++) {
if (++var_r30->unk00_s16 > var_r30->unk02) { if (++var_r30->unk00 > var_r30->unk02) {
var_r24 = var_r30->unk40.a - 9; var_r24 = var_r30->unk40.a - 9;
if (var_r24 < 0) { if (var_r24 < 0) {
var_r30->unk2C = 0.0f; var_r30->unk2C = 0.0f;

View file

@ -1637,15 +1637,15 @@ void fn_1_AD04(ModelData *model, ParticleData *particle, Mtx matrix)
return; return;
} }
for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
VECScale(&var_r31->unk08, &var_r31->unk08, 0.97f); VECScale(&var_r31->unk08, &var_r31->unk08, 0.97f);
if (var_r31->unk00_s16 < 24.0f) { if (var_r31->unk00 < 24.0f) {
var_r31->unk40.a = 0.9f * var_r31->unk40.a; var_r31->unk40.a = 0.9f * var_r31->unk40.a;
} }
var_r31->unk2C += 1.5f; var_r31->unk2C += 1.5f;
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
@ -1676,7 +1676,7 @@ void fn_1_AEE0(s32 arg0, Vec *arg1, float arg8, float arg9)
var_r27 = 1; var_r27 = 1;
var_f28 = 30.0f; var_f28 = 30.0f;
for (var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk00 = 60.0f * (0.5f + (0.0005f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.5f + (0.0005f * frandmod(0x3E8)));
var_f30 = (0.002f * frandmod(0x3E8)) - 1.0f; var_f30 = (0.002f * frandmod(0x3E8)) - 1.0f;
var_f30 = arg8 + (var_f30 * var_f28); var_f30 = arg8 + (var_f30 * var_f28);
@ -1714,22 +1714,22 @@ void fn_1_B394(ModelData *model, ParticleData *var_r30, Mtx matrix)
if ((var_r30->unk_00 == 0) || (lbl_1_bss_5C != 0)) { if ((var_r30->unk_00 == 0) || (lbl_1_bss_5C != 0)) {
var_r30->unk_00++; var_r30->unk_00++;
for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
return; return;
} }
for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
var_r31->unk00_s16--; var_r31->unk00--;
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk2C += 0.5f; var_r31->unk2C += 0.5f;
if (var_r31->unk00_s16 < 30.0) { if (var_r31->unk00 < 30.0) {
var_r31->unk40.a = 0.98f * var_r31->unk40.a; var_r31->unk40.a = 0.98f * var_r31->unk40.a;
} }
if ((var_r31->unk34.y < -40.0f) || (var_r31->unk00_s16 == 0)) { if ((var_r31->unk34.y < -40.0f) || (var_r31->unk00 == 0)) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
@ -1766,8 +1766,8 @@ void fn_1_B570(s32 arg0, Vec *arg1, float arg8, float arg9, Vec *arg2)
VECScale(arg2, &sp1C, 0.2f); VECScale(arg2, &sp1C, 0.2f);
sp1C.x = 0.0f; sp1C.x = 0.0f;
for (var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk00_s16 = 60.0f * (0.5f + (0.0005f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.5f + (0.0005f * frandmod(0x3E8)));
var_f30 = (0.002f * frandmod(0x3E8)) - 1.0f; var_f30 = (0.002f * frandmod(0x3E8)) - 1.0f;
var_f30 = arg8 + sp14[var_r29 & 1] + (var_f30 * var_f28); var_f30 = arg8 + sp14[var_r29 & 1] + (var_f30 * var_f28);
sp28.x = sind(var_f30); sp28.x = sind(var_f30);

View file

@ -2174,7 +2174,7 @@ void fn_1_BD48(omObjData *object)
for (var_r27 = ((ParticleData *)Hu3DData[var_r28].unk_120)->unk_48, var_r29 = 0; var_r29 < 0xC8; var_r29++, var_r27++) { for (var_r27 = ((ParticleData *)Hu3DData[var_r28].unk_120)->unk_48, var_r29 = 0; var_r29 < 0xC8; var_r29++, var_r27++) {
var_r27->unk2C = 0.0f; var_r27->unk2C = 0.0f;
var_r27->unk40.a = 0; var_r27->unk40.a = 0;
var_r27->unk00_s16 = 0; var_r27->unk00 = 0;
} }
object->model[9] = Hu3DModelCreateFile(DATA_MAKE_NUM(DATADIR_M433, 2)); object->model[9] = Hu3DModelCreateFile(DATA_MAKE_NUM(DATADIR_M433, 2));
Hu3DModelScaleSet(object->model[9], 1.05f, 1.05f, 1.05f); Hu3DModelScaleSet(object->model[9], 1.05f, 1.05f, 1.05f);
@ -2581,18 +2581,18 @@ void fn_1_D6A8(ModelData *model, ParticleData *particle, Mtx matrix)
s32 var_r29; s32 var_r29;
for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk08.x *= 0.92f; var_r31->unk08.x *= 0.92f;
var_r31->unk08.z *= 0.92f; var_r31->unk08.z *= 0.92f;
var_r31->unk08.y += -0.27222225f; var_r31->unk08.y += -0.27222225f;
var_r31->unk2C += 2.0f; var_r31->unk2C += 2.0f;
var_r31->unk40.a *= 0.99f; var_r31->unk40.a *= 0.99f;
if (var_r31->unk00_s16 < 24.0f) { if (var_r31->unk00 < 24.0f) {
var_r31->unk40.a = 0.9f * var_r31->unk40.a; var_r31->unk40.a = 0.9f * var_r31->unk40.a;
} }
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
@ -2613,8 +2613,8 @@ void fn_1_D888(Vec *arg0, float arg8)
var_r31 = ((ParticleData *)Hu3DData[lbl_1_bss_7CC->model[5]].unk_120)->unk_48; var_r31 = ((ParticleData *)Hu3DData[lbl_1_bss_7CC->model[5]].unk_120)->unk_48;
var_r28 = 3.0f + (12.0f * arg8); var_r28 = 3.0f + (12.0f * arg8);
for (var_r29 = 0; var_r29 < 0xC8; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < 0xC8; var_r29++, var_r31++) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk00_s16 = 60.0f * (0.6f + (0.0006f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.6f + (0.0006f * frandmod(0x3E8)));
var_f30 = frandmod(0x168); var_f30 = frandmod(0x168);
sp8.x = sind(var_f30); sp8.x = sind(var_f30);
sp8.y = 0.0f; sp8.y = 0.0f;

View file

@ -377,15 +377,15 @@ void fn_1_C764(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk08.x *= 0.95f; var_r31->unk08.x *= 0.95f;
var_r31->unk08.z *= 0.95f; var_r31->unk08.z *= 0.95f;
var_r31->unk08.y += -0.27222225f; var_r31->unk08.y += -0.27222225f;
if (var_r31->unk00_s16 < 24.0f) { if (var_r31->unk00 < 24.0f) {
var_r31->unk40.a = 0.9f * var_r31->unk40.a; var_r31->unk40.a = 0.9f * var_r31->unk40.a;
} }
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
@ -404,16 +404,16 @@ void fn_1_C8E8(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk08.x *= 0.92f; var_r31->unk08.x *= 0.92f;
var_r31->unk08.z *= 0.92f; var_r31->unk08.z *= 0.92f;
var_r31->unk2C += 5.0f; var_r31->unk2C += 5.0f;
var_r31->unk40.a *= 0.99f; var_r31->unk40.a *= 0.99f;
if (var_r31->unk00_s16 < 24.0f) { if (var_r31->unk00 < 24.0f) {
var_r31->unk40.a = 0.9f * var_r31->unk40.a; var_r31->unk40.a = 0.9f * var_r31->unk40.a;
} }
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
@ -440,8 +440,8 @@ void fn_1_CAB0(f32 arg8)
for (var_r30 = 0; var_r30 < 0x96; var_r30++) { for (var_r30 = 0; var_r30 < 0x96; var_r30++) {
var_r31 = lbl_1_bss_E34[var_r30]; var_r31 = lbl_1_bss_E34[var_r30];
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk00_s16 = 60.0f * (0.6f + (0.0006f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.6f + (0.0006f * frandmod(0x3E8)));
temp_f31 = ((0.002f * frandmod(0x3E8)) - 1.0f); temp_f31 = ((0.002f * frandmod(0x3E8)) - 1.0f);
temp_f31 = arg8 + (temp_f31 * temp_f28); temp_f31 = arg8 + (temp_f31 * temp_f28);
sp8.x = sind(temp_f31); sp8.x = sind(temp_f31);
@ -471,8 +471,8 @@ void fn_1_CAB0(f32 arg8)
var_r31 = ((ParticleData *)(Hu3DData[lbl_1_bss_108C[0]->model[6]].unk_120))->unk_48; var_r31 = ((ParticleData *)(Hu3DData[lbl_1_bss_108C[0]->model[6]].unk_120))->unk_48;
var_r29 = 0xF; var_r29 = 0xF;
for (var_r30 = 0; var_r30 < 0x32; var_r30++, var_r31++) { for (var_r30 = 0; var_r30 < 0x32; var_r30++, var_r31++) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk00_s16 = 60.0f * (0.6f + (0.0006f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.6f + (0.0006f * frandmod(0x3E8)));
temp_f31 = ((0.002f * frandmod(0x3E8)) - 1.0f); temp_f31 = ((0.002f * frandmod(0x3E8)) - 1.0f);
temp_f31 = arg8 + (temp_f31 * temp_f28); temp_f31 = arg8 + (temp_f31 * temp_f28);
sp8.x = sind(temp_f31); sp8.x = sind(temp_f31);
@ -513,14 +513,14 @@ void fn_1_D3FC(ModelData *model, ParticleData *particle, Mtx matrix)
lbl_1_bss_E2C = 0; lbl_1_bss_E2C = 0;
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk08.y += -0.27222225f; var_r31->unk08.y += -0.27222225f;
if (var_r31->unk00_s16 < 12.0f) { if (var_r31->unk00 < 12.0f) {
var_r31->unk40.a = (0.8f * var_r31->unk40.a); var_r31->unk40.a = (0.8f * var_r31->unk40.a);
} }
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
} }
@ -543,8 +543,8 @@ void fn_1_D57C(Vec *arg0, f32 arg1)
var_r29 = (u32)(3.0f + (15.0f * arg1)); var_r29 = (u32)(3.0f + (15.0f * arg1));
for (var_r30 = 0; var_r30 < 0x1F4; var_r30++, var_r31++) { for (var_r30 = 0; var_r30 < 0x1F4; var_r30++, var_r31++) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk00_s16 = 60.0f * (0.3f + (0.0003f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.3f + (0.0003f * frandmod(0x3E8)));
var_r31->unk34 = *arg0; var_r31->unk34 = *arg0;
var_r31->unk34.x += arg1 * (0.07f * (frandmod(0x3E8) - 0x1F4)); var_r31->unk34.x += arg1 * (0.07f * (frandmod(0x3E8) - 0x1F4));
var_r31->unk34.z += arg1 * (0.07f * (frandmod(0x3E8) - 0x1F4)); var_r31->unk34.z += arg1 * (0.07f * (frandmod(0x3E8) - 0x1F4));

View file

@ -1138,15 +1138,15 @@ void fn_1_8E34(s32 arg0)
var_r31 = temp_r30->unk_48; var_r31 = temp_r30->unk_48;
for (var_r29 = 0; var_r29 < temp_r30->unk_30; var_r29++, var_r31++) { for (var_r29 = 0; var_r29 < temp_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
var_r31->unk08.z -= 0.3f; var_r31->unk08.z -= 0.3f;
var_r31->unk2C += 2.0f; var_r31->unk2C += 2.0f;
var_r31->unk40.a *= 0.98f; var_r31->unk40.a *= 0.98f;
if (var_r31->unk00_s16 < 24.0f) { if (var_r31->unk00 < 24.0f) {
var_r31->unk40.a = var_r31->unk40.a * 0.9f; var_r31->unk40.a = var_r31->unk40.a * 0.9f;
} }
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
@ -1183,10 +1183,10 @@ void fn_1_8FFC(u32 arg0, Point3d *arg1, f32 arg2, f32 arg3)
var_r31 = temp_r29->unk_48; var_r31 = temp_r29->unk_48;
for (var_r28 = 0; var_r28 < temp_r29->unk_30; var_r28++, var_r31++) { for (var_r28 = 0; var_r28 < temp_r29->unk_30; var_r28++, var_r31++) {
if (var_r31->unk00_s16 != 0) if (var_r31->unk00 != 0)
continue; continue;
var_r31->unk00_s16 = (60.0f * (0.6f + (0.0005f * frandmod(0x3E8)))); var_r31->unk00 = (60.0f * (0.6f + (0.0005f * frandmod(0x3E8))));
var_f29 = isEven(var_r27); var_f29 = isEven(var_r27);
temp_f31 = 0.030000001f * frandmod(0x3E8); temp_f31 = 0.030000001f * frandmod(0x3E8);
var_r31->unk34.x = arg1->x + var_f29 * (70.0f + (0.07f * frandmod(0x3E8))); var_r31->unk34.x = arg1->x + var_f29 * (70.0f + (0.07f * frandmod(0x3E8)));

View file

@ -391,7 +391,7 @@ void fn_1_9F40(ModelData *model, ParticleData *particle, Mtx matrix)
if (particle->unk_00 == 0) { if (particle->unk_00 == 0) {
particle->unk_00 = 1; particle->unk_00 = 1;
for (i = 0, var_r31 = particle->unk_48; i < particle->unk_30; i++, var_r31++) { for (i = 0, var_r31 = particle->unk_48; i < particle->unk_30; i++, var_r31++) {
var_r31->unk00_s16 = i * 5; var_r31->unk00 = i * 5;
var_r31->unk02 = 0; var_r31->unk02 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.r = sp8.r; var_r31->unk40.r = sp8.r;
@ -401,7 +401,7 @@ void fn_1_9F40(ModelData *model, ParticleData *particle, Mtx matrix)
} }
} }
for (i = 0, var_r27 = 0, var_r31 = particle->unk_48; i < particle->unk_30; i++, var_r31++) { for (i = 0, var_r27 = 0, var_r31 = particle->unk_48; i < particle->unk_30; i++, var_r31++) {
if (var_r31->unk00_s16 > 0 && --var_r31->unk00_s16 > 0) { if (var_r31->unk00 > 0 && --var_r31->unk00 > 0) {
continue; continue;
} }
if (var_r31->unk02 == 0 && temp_r29->unk04 == 5 && temp_r29->unk10.z > -700.0f) { if (var_r31->unk02 == 0 && temp_r29->unk04 == 5 && temp_r29->unk10.z > -700.0f) {

View file

@ -444,7 +444,7 @@ void fn_1_2DAC(ModelData *model, ParticleData *particle, Mtx matrix)
} }
} }
for (i = 0, var_r31 = particle->unk_48; i < particle->unk_30; i++, var_r31++) { for (i = 0, var_r31 = particle->unk_48; i < particle->unk_30; i++, var_r31++) {
if (var_r31->unk00_s16 < 0) { if (var_r31->unk00 < 0) {
continue; continue;
} }
var_r31->unk34.x += var_r31->unk08.x; var_r31->unk34.x += var_r31->unk08.x;

View file

@ -1498,7 +1498,7 @@ void fn_1_7DC4(ModelData *model, ParticleData *particle, Mtx matrix)
if (particle->unk_34 == 0) { if (particle->unk_34 == 0) {
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (i = 0; i < particle->unk_30; i++, var_r31++) { for (i = 0; i < particle->unk_30; i++, var_r31++) {
var_r31->unk00_s16 = i * 2 + 100; var_r31->unk00 = i * 2 + 100;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
@ -1511,8 +1511,8 @@ void fn_1_7DC4(ModelData *model, ParticleData *particle, Mtx matrix)
} }
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (i = 0; i < particle->unk_30; i++, var_r31++) { for (i = 0; i < particle->unk_30; i++, var_r31++) {
if (var_r31->unk00_s16 == 100) { if (var_r31->unk00 == 100) {
var_r31->unk00_s16 = (lbl_1_data_1DC[0] == 0.0f && lbl_1_data_1DC[1] == 0.0f && lbl_1_data_1DC[2] == 0.0f) ? 0 : var_r31->unk00_s16; var_r31->unk00 = (lbl_1_data_1DC[0] == 0.0f && lbl_1_data_1DC[1] == 0.0f && lbl_1_data_1DC[2] == 0.0f) ? 0 : var_r31->unk00;
var_r31->unk34.x = lbl_1_data_1DC[0] + 75.0 * (rand8() / 255.0); var_r31->unk34.x = lbl_1_data_1DC[0] + 75.0 * (rand8() / 255.0);
var_r31->unk34.y = lbl_1_data_1DC[1] + 75.0 * (rand8() / 255.0); var_r31->unk34.y = lbl_1_data_1DC[1] + 75.0 * (rand8() / 255.0);
var_r31->unk34.z = lbl_1_data_1DC[2] + 75.0 * (rand8() / 255.0); var_r31->unk34.z = lbl_1_data_1DC[2] + 75.0 * (rand8() / 255.0);
@ -1523,14 +1523,14 @@ void fn_1_7DC4(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk30 = 0.785f; var_r31->unk30 = 0.785f;
var_r31->unk2C = 40.0f; var_r31->unk2C = 40.0f;
} }
if (var_r31->unk00_s16 <= 100) { if (var_r31->unk00 <= 100) {
var_r31->unk34.y -= 3.0f; var_r31->unk34.y -= 3.0f;
var_r31->unk2C = ((var_r31->unk00_s16 > 50) ? (var_r31->unk00_s16 - 50) / 50.0 : 0.0) * (rand8() * 80 / 255.0); var_r31->unk2C = ((var_r31->unk00 > 50) ? (var_r31->unk00 - 50) / 50.0 : 0.0) * (rand8() * 80 / 255.0);
} }
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
var_r31->unk00_s16 -= (var_r31->unk00_s16 > 0); var_r31->unk00 -= (var_r31->unk00 > 0);
} }
} }

View file

@ -1697,7 +1697,7 @@ void fn_1_7F94(ModelData *model, ParticleData *particle, Mtx matrix)
} }
} }
for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) { for (var_r31 = particle->unk_48, var_r29 = 0; var_r29 < particle->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 == 1) { if (var_r31->unk00 == 1) {
var_f31 = ((frand() & 0xFF) * 0x168) >> 8; var_f31 = ((frand() & 0xFF) * 0x168) >> 8;
var_f30 = 0.5 + (1.5 * (rand8() / 256.0)); var_f30 = 0.5 + (1.5 * (rand8() / 256.0));
var_r31->unk08.x = 2.5 * (var_f30 * sind(var_f31)); var_r31->unk08.x = 2.5 * (var_f30 * sind(var_f31));
@ -1715,7 +1715,7 @@ void fn_1_7F94(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk40.a = 0xFF; var_r31->unk40.a = 0xFF;
var_r31->unk2C = 50.0f; var_r31->unk2C = 50.0f;
} }
if (var_r31->unk00_s16 < 0xF0) { if (var_r31->unk00 < 0xF0) {
VECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34); VECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34);
var_r31->unk08.x *= 0.9f; var_r31->unk08.x *= 0.9f;
var_r31->unk08.z *= 0.9f; var_r31->unk08.z *= 0.9f;
@ -1730,8 +1730,8 @@ void fn_1_7F94(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
} }
var_r31->unk00_s16 += var_r31->unk00_s16 < 0x8000; var_r31->unk00 += var_r31->unk00 < 0x8000;
if (var_r31->unk00_s16 >= 0xF0) { if (var_r31->unk00 >= 0xF0) {
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }

View file

@ -1096,7 +1096,7 @@ void fn_1_6A6C(omObjData *object)
HsfanimStruct01 *data = particleP->unk_48; HsfanimStruct01 *data = particleP->unk_48;
s32 j; s32 j;
for(j=0; j<particleP->unk_30; j++, data++) { for(j=0; j<particleP->unk_30; j++, data++) {
if(++data->unk00_s16 > data->unk02) { if(++data->unk00 > data->unk02) {
s32 alpha = data->unk40.a-1; s32 alpha = data->unk40.a-1;
if(alpha < 0) { if(alpha < 0) {
data->unk2C = 0; data->unk2C = 0;
@ -1163,7 +1163,7 @@ s32 fn_1_6CB0(Vec *arg0, float arg1)
temp_r30->unk08.x = temp_f31*(0.65f*(50.0*(temp_f28*sind(temp_f29)))); temp_r30->unk08.x = temp_f31*(0.65f*(50.0*(temp_f28*sind(temp_f29))));
temp_r30->unk08.z = temp_f31*(0.65f*(50.0*(temp_f28*cosd(temp_f29)))); temp_r30->unk08.z = temp_f31*(0.65f*(50.0*(temp_f28*cosd(temp_f29))));
temp_r30->unk08.y = temp_f31*(50*temp_f26*temp_f25); temp_r30->unk08.y = temp_f31*(50*temp_f26*temp_f25);
temp_r30->unk00_s16 = 0; temp_r30->unk00 = 0;
temp_r30->unk02 = ((s32)frand()%16)+45; temp_r30->unk02 = ((s32)frand()%16)+45;
temp_r30->unk30 = (s32)frand()%360; temp_r30->unk30 = (s32)frand()%360;
temp_r30->unk2C = 145; temp_r30->unk2C = 145;
@ -1280,10 +1280,10 @@ void fn_1_76B0(omObjData *object)
if(temp_r30->unk2C <= 0.0f) { if(temp_r30->unk2C <= 0.0f) {
continue; continue;
} }
if(++temp_r30->unk00_s16 > 360) { if(++temp_r30->unk00 > 360) {
temp_r30->unk00_s16 -= 360; temp_r30->unk00 -= 360;
} }
temp_r30->unk34.x += temp_r30->unk08.x*sind(2.0f*temp_r30->unk00_s16); temp_r30->unk34.x += temp_r30->unk08.x*sind(2.0f*temp_r30->unk00);
temp_r30->unk34.y += temp_r30->unk08.y; temp_r30->unk34.y += temp_r30->unk08.y;
if(temp_r30->unk34.y >= 0.0f) { if(temp_r30->unk34.y >= 0.0f) {
fn_1_6698(&temp_r30->unk34, 0.00625f*temp_r30->unk2C, 1, 15); fn_1_6698(&temp_r30->unk34, 0.00625f*temp_r30->unk2C, 1, 15);
@ -1322,7 +1322,7 @@ s32 fn_1_79C8(Vec *pos, float scale)
temp_r31->unk08.x = (1.5f+(0.2f*(0.007874016f*((s32)frand() & 0x7F))))*0.5f; temp_r31->unk08.x = (1.5f+(0.2f*(0.007874016f*((s32)frand() & 0x7F))))*0.5f;
temp_r31->unk08.z = (1.5f+(0.2f*(0.007874016f*((s32)frand() & 0x7F)))); temp_r31->unk08.z = (1.5f+(0.2f*(0.007874016f*((s32)frand() & 0x7F))));
temp_r31->unk08.y = (1.5f+(0.2f*(0.007874016f*((s32)frand() & 0x7F))))*2.0f; temp_r31->unk08.y = (1.5f+(0.2f*(0.007874016f*((s32)frand() & 0x7F))))*2.0f;
temp_r31->unk00_s16 = (s32)frand()%360; temp_r31->unk00 = (s32)frand()%360;
temp_r31->unk2C = 20*scale; temp_r31->unk2C = 20*scale;
return i; return i;
} }

View file

@ -991,7 +991,7 @@ void fn_1_659C(omObjData *object)
HsfanimStruct01 *data = particleP->unk_48; HsfanimStruct01 *data = particleP->unk_48;
s32 j; s32 j;
for (j = 0; j < particleP->unk_30; j++, data++) { for (j = 0; j < particleP->unk_30; j++, data++) {
if (++data->unk00_s16 > data->unk02) { if (++data->unk00 > data->unk02) {
s32 alpha = data->unk40.a - 1; s32 alpha = data->unk40.a - 1;
if (alpha < 0) { if (alpha < 0) {
data->unk2C = 0; data->unk2C = 0;
@ -1060,7 +1060,7 @@ s32 fn_1_67E0(Vec *arg0, float arg1)
temp_r30->unk08.x = temp_f31 * (0.65f * (50.0 * (temp_f28 * sind(temp_f29)))); temp_r30->unk08.x = temp_f31 * (0.65f * (50.0 * (temp_f28 * sind(temp_f29))));
temp_r30->unk08.z = temp_f31 * (0.65f * (50.0 * (temp_f28 * cosd(temp_f29)))); temp_r30->unk08.z = temp_f31 * (0.65f * (50.0 * (temp_f28 * cosd(temp_f29))));
temp_r30->unk08.y = temp_f31 * (50 * temp_f26 * temp_f25); temp_r30->unk08.y = temp_f31 * (50 * temp_f26 * temp_f25);
temp_r30->unk00_s16 = 0; temp_r30->unk00 = 0;
temp_r30->unk02 = ((s32)frand() % 16) + 45; temp_r30->unk02 = ((s32)frand() % 16) + 45;
temp_r30->unk30 = (s32)frand() % 360; temp_r30->unk30 = (s32)frand() % 360;
temp_r30->unk2C = 145.0f; temp_r30->unk2C = 145.0f;
@ -1174,10 +1174,10 @@ void fn_1_71E0(omObjData *object)
if (temp_r30->unk2C <= 0.0f) { if (temp_r30->unk2C <= 0.0f) {
continue; continue;
} }
if (++temp_r30->unk00_s16 > 360) { if (++temp_r30->unk00 > 360) {
temp_r30->unk00_s16 -= 360; temp_r30->unk00 -= 360;
} }
temp_r30->unk34.x += temp_r30->unk08.x * sind(2.0f * temp_r30->unk00_s16); temp_r30->unk34.x += temp_r30->unk08.x * sind(2.0f * temp_r30->unk00);
temp_r30->unk34.y += temp_r30->unk08.y; temp_r30->unk34.y += temp_r30->unk08.y;
if (temp_r30->unk34.y >= 0.0f) { if (temp_r30->unk34.y >= 0.0f) {
fn_1_61C8(&temp_r30->unk34, 0.00625f * temp_r30->unk2C, 1, REFRESH_RATE / 4); fn_1_61C8(&temp_r30->unk34, 0.00625f * temp_r30->unk2C, 1, REFRESH_RATE / 4);
@ -1221,7 +1221,7 @@ s32 fn_1_74F8(Vec *pos, float scale)
temp_r31->unk08.z = (1.5f + (0.2f * (0.007874016f * ((s32)frand() & 0x7F)))); temp_r31->unk08.z = (1.5f + (0.2f * (0.007874016f * ((s32)frand() & 0x7F))));
temp_r31->unk08.y = (1.5f + (0.2f * (0.007874016f * ((s32)frand() & 0x7F)))) * 2.0f; temp_r31->unk08.y = (1.5f + (0.2f * (0.007874016f * ((s32)frand() & 0x7F)))) * 2.0f;
#endif #endif
temp_r31->unk00_s16 = (s32)frand() % 360; temp_r31->unk00 = (s32)frand() % 360;
temp_r31->unk2C = 20 * scale; temp_r31->unk2C = 20 * scale;
return i; return i;
} }

View file

@ -408,7 +408,7 @@ void fn_1_7B94(s32 arg0)
var_r30 = Hu3DData[arg0].unk_120; var_r30 = Hu3DData[arg0].unk_120;
for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) { for (var_r31 = var_r30->unk_48, var_r29 = 0; var_r29 < var_r30->unk_30; var_r29++, var_r31++) {
if (var_r31->unk00_s16 != 0) { if (var_r31->unk00 != 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
switch (var_r31->unk02) { switch (var_r31->unk02) {
case 0: case 0:
@ -425,11 +425,11 @@ void fn_1_7B94(s32 arg0)
var_r31->unk20 *= 0.995f; var_r31->unk20 *= 0.995f;
break; break;
} }
if (var_r31->unk00_s16 < 12.0f) { if (var_r31->unk00 < 12.0f) {
var_r31->unk20 = 0.9f * var_r31->unk20; var_r31->unk20 = 0.9f * var_r31->unk20;
} }
var_r31->unk40.a = var_r31->unk20; var_r31->unk40.a = var_r31->unk20;
if (--var_r31->unk00_s16 == 0) { if (--var_r31->unk00 == 0) {
var_r31->unk00 = 0; var_r31->unk00 = 0;
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
var_r31->unk40.a = 0; var_r31->unk40.a = 0;
@ -459,7 +459,7 @@ void fn_1_7DA8(omObjData *object, Vec *arg1, u32 arg2)
} }
var_r27 = sp10[arg2]; var_r27 = sp10[arg2];
for (var_r31 = var_r30->unk_48, var_r28 = 0; var_r28 < var_r30->unk_30; var_r28++, var_r31++) { for (var_r31 = var_r30->unk_48, var_r28 = 0; var_r28 < var_r30->unk_30; var_r28++, var_r31++) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
var_r31->unk02 = arg2; var_r31->unk02 = arg2;
sp1C.x = 100.0f * ((0.0026f * frandmod(0x3E8)) - 1.3f); sp1C.x = 100.0f * ((0.0026f * frandmod(0x3E8)) - 1.3f);
sp1C.y = 0.0f; sp1C.y = 0.0f;
@ -468,7 +468,7 @@ void fn_1_7DA8(omObjData *object, Vec *arg1, u32 arg2)
var_r31->unk30 = 0.0031415902f * frandmod(0x3E8); var_r31->unk30 = 0.0031415902f * frandmod(0x3E8);
switch (arg2) { switch (arg2) {
case 0: case 0:
var_r31->unk00_s16 = 60.0f * (0.8f + (0.0007f * frandmod(0x3E8))); var_r31->unk00 = 60.0f * (0.8f + (0.0007f * frandmod(0x3E8)));
var_r31->unk08.x = 1.6666667f * (0.000100000005f * frandmod(0x3E8) - 0.05f); var_r31->unk08.x = 1.6666667f * (0.000100000005f * frandmod(0x3E8) - 0.05f);
var_r31->unk08.y = 1.6666667f * (0.05f + (0.00020000001f * frandmod(0x3E8))); var_r31->unk08.y = 1.6666667f * (0.05f + (0.00020000001f * frandmod(0x3E8)));
var_r31->unk08.z = 1.6666667f * (0.1f + (0.0006f * frandmod(0x3E8))); var_r31->unk08.z = 1.6666667f * (0.1f + (0.0006f * frandmod(0x3E8)));

View file

@ -253,7 +253,7 @@ void fn_1_1E820(ModelData* model, ParticleData* particle, Mtx matrix) {
if (!var_r31->unk2C) { if (!var_r31->unk2C) {
continue; continue;
} }
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
PSVECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34); PSVECAdd(&var_r31->unk08, &var_r31->unk34, &var_r31->unk34);
var_r31->unk08.x *= 0.999f; var_r31->unk08.x *= 0.999f;
var_r31->unk08.y -= 0.5f; var_r31->unk08.y -= 0.5f;
@ -262,19 +262,19 @@ void fn_1_1E820(ModelData* model, ParticleData* particle, Mtx matrix) {
PSVECScale(&var_r31->unk08, &var_r31->unk08, 1.0 - ((var_r31->unk02 - (temp_r26 - temp_r26 / 5.0)) / (temp_r26 / 5.0))); PSVECScale(&var_r31->unk08, &var_r31->unk08, 1.0 - ((var_r31->unk02 - (temp_r26 - temp_r26 / 5.0)) / (temp_r26 / 5.0)));
} }
if (var_r31->unk02 == temp_r26) { if (var_r31->unk02 == temp_r26) {
var_r31->unk00_s16++; var_r31->unk00++;
} }
if (var_r31->unk34.y <= 0.0f) { if (var_r31->unk34.y <= 0.0f) {
var_r31->unk08.y = 0.5f * -var_r31->unk08.y; var_r31->unk08.y = 0.5f * -var_r31->unk08.y;
var_r31->unk34.y = 0.0f; var_r31->unk34.y = 0.0f;
} }
} else if (var_r31->unk00_s16 == 1) { } else if (var_r31->unk00 == 1) {
sp8 = temp_r28->unk00[var_r29]; sp8 = temp_r28->unk00[var_r29];
PSVECSubtract(&sp8, &var_r31->unk34, &sp8); PSVECSubtract(&sp8, &var_r31->unk34, &sp8);
if (PSVECMag(&sp8) <= 1.0 + temp_f31) { if (PSVECMag(&sp8) <= 1.0 + temp_f31) {
var_r23++; var_r23++;
var_r31->unk34 = temp_r28->unk00[var_r29]; var_r31->unk34 = temp_r28->unk00[var_r29];
var_r31->unk00_s16++; var_r31->unk00++;
continue; continue;
} }
PSVECNormalize(&sp8, &sp8); PSVECNormalize(&sp8, &sp8);
@ -286,7 +286,7 @@ void fn_1_1E820(ModelData* model, ParticleData* particle, Mtx matrix) {
} else { } else {
var_r23++; var_r23++;
} }
if (var_r31->unk00_s16 >= 1) { if (var_r31->unk00 >= 1) {
var_r27 = var_r31->unk40.r; var_r27 = var_r31->unk40.r;
var_r27 += (var_r27 - 0xFF) / 20; var_r27 += (var_r27 - 0xFF) / 20;
if (var_r27 > 0xFF) { if (var_r27 > 0xFF) {

View file

@ -1942,7 +1942,7 @@ static void LampParticleUpdate(ModelData *model, ParticleData *particle, Mtx mat
var_r31->unk2C = 25.0f; var_r31->unk2C = 25.0f;
temp_f30 = 175.0f + frand8() * 0x50 * 0.003921569f; temp_f30 = 175.0f + frand8() * 0x50 * 0.003921569f;
var_r31->unk40.r = var_r31->unk40.g = var_r31->unk40.b = temp_f30; var_r31->unk40.r = var_r31->unk40.g = var_r31->unk40.b = temp_f30;
var_r31->unk00_s16 = 0; var_r31->unk00 = 0;
} }
} }
} }
@ -1952,7 +1952,7 @@ static void LampParticleUpdate(ModelData *model, ParticleData *particle, Mtx mat
var_r31 = particle->unk_48; var_r31 = particle->unk_48;
for (i = 0; i < particle->unk_30; i++, var_r31++) { for (i = 0; i < particle->unk_30; i++, var_r31++) {
if (var_r31->unk2C != 0.0f) { if (var_r31->unk2C != 0.0f) {
if (var_r31->unk00_s16 == 0) { if (var_r31->unk00 == 0) {
VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34); VECAdd(&var_r31->unk34, &var_r31->unk08, &var_r31->unk34);
VECScale(&var_r31->unk08, &var_r31->unk08, 0.95f); VECScale(&var_r31->unk08, &var_r31->unk08, 0.95f);
var_r31->unk2C += 8.0f; var_r31->unk2C += 8.0f;
@ -1963,7 +1963,7 @@ static void LampParticleUpdate(ModelData *model, ParticleData *particle, Mtx mat
var_r31->unk08.x = 6.0 * cosd(temp_f31); var_r31->unk08.x = 6.0 * cosd(temp_f31);
var_r31->unk08.y = -4.0f; var_r31->unk08.y = -4.0f;
var_r31->unk08.z = 6.0 * sind(temp_f31); var_r31->unk08.z = 6.0 * sind(temp_f31);
var_r31->unk00_s16 = 1; var_r31->unk00 = 1;
} }
var_r31->unk40.a = var_r31->unk14.y; var_r31->unk40.a = var_r31->unk14.y;
} }

View file

@ -911,7 +911,7 @@ static void UpdateEffect(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk40.a = var_r28; var_r31->unk40.a = var_r28;
if (var_r31->unk2C) { if (var_r31->unk2C) {
if (temp_r30[i].unk00 & 1) { if (temp_r30[i].unk00 & 1) {
var_r31->unk2C = var_r31->unk28 * (((var_r31->unk00_s16 + i) & 1) ? 1.0 : 0.5); var_r31->unk2C = var_r31->unk28 * (((var_r31->unk00 + i) & 1) ? 1.0 : 0.5);
} }
else { else {
var_r31->unk2C = var_r31->unk28; var_r31->unk2C = var_r31->unk28;
@ -921,7 +921,7 @@ static void UpdateEffect(ModelData *model, ParticleData *particle, Mtx matrix)
var_r31->unk2C = 0.0f; var_r31->unk2C = 0.0f;
} }
} }
var_r31->unk00_s16++; var_r31->unk00++;
} }
else { else {
switch (var_r31->unk02) { switch (var_r31->unk02) {
@ -947,11 +947,11 @@ static void RotateEffect(HsfanimStruct01 *arg0)
float var_f31; float var_f31;
temp_r30 = &Hu3DData[(s32)arg0->unk08.x]; temp_r30 = &Hu3DData[(s32)arg0->unk08.x];
if (arg0->unk00_s16 < 8) { if (arg0->unk00 < 8) {
var_f31 = 0.3 + sind(40.0f + 10.0f * (arg0->unk00_s16 + 1)); var_f31 = 0.3 + sind(40.0f + 10.0f * (arg0->unk00 + 1));
arg0->unk2C = 50.0f * var_f31 * temp_r30->scale.x; arg0->unk2C = 50.0f * var_f31 * temp_r30->scale.x;
arg0->unk40.a = 0xFF; arg0->unk40.a = 0xFF;
var_f31 = 0.3 + sind(15.0f * (arg0->unk00_s16 + 1)); var_f31 = 0.3 + sind(15.0f * (arg0->unk00 + 1));
} }
else { else {
var_f31 = 0.3 + sind(135); var_f31 = 0.3 + sind(135);
@ -960,14 +960,14 @@ static void RotateEffect(HsfanimStruct01 *arg0)
arg0->unk34.x = temp_r30->pos.x + arg0->unk14.x * var_f31; arg0->unk34.x = temp_r30->pos.x + arg0->unk14.x * var_f31;
arg0->unk34.y = temp_r30->pos.y + arg0->unk08.y * temp_r30->scale.x + arg0->unk14.y * var_f31; arg0->unk34.y = temp_r30->pos.y + arg0->unk08.y * temp_r30->scale.x + arg0->unk14.y * var_f31;
arg0->unk34.z = temp_r30->pos.z + arg0->unk14.z * var_f31; arg0->unk34.z = temp_r30->pos.z + arg0->unk14.z * var_f31;
if (arg0->unk00_s16 > 0x14) { if (arg0->unk00 > 0x14) {
arg0->unk40.a -= 0x20; arg0->unk40.a -= 0x20;
arg0->unk2C -= 8.0f * temp_r30->scale.x; arg0->unk2C -= 8.0f * temp_r30->scale.x;
if (arg0->unk2C < 0.0f) { if (arg0->unk2C < 0.0f) {
arg0->unk2C = 0.0f; arg0->unk2C = 0.0f;
} }
} }
arg0->unk00_s16++; arg0->unk00++;
} }
static float voiceParam[16] static float voiceParam[16]
@ -984,7 +984,7 @@ static void PlayEffectSound(HsfanimStruct01 *arg0)
temp_r28 = arg0->unk08.x; temp_r28 = arg0->unk08.x;
temp_r29 = &charInstance[temp_r28]; temp_r29 = &charInstance[temp_r28];
temp_r30 = &Hu3DData[temp_r29->unk00]; temp_r30 = &Hu3DData[temp_r29->unk00];
if (arg0->unk00_s16 < 0x14 && arg0->unk2C < 40.0f * temp_r30->scale.x) { if (arg0->unk00 < 0x14 && arg0->unk2C < 40.0f * temp_r30->scale.x) {
arg0->unk2C += 4.0f * temp_r30->scale.x; arg0->unk2C += 4.0f * temp_r30->scale.x;
} }
arg0->unk40.a = 0xFF; arg0->unk40.a = 0xFF;
@ -994,15 +994,15 @@ static void PlayEffectSound(HsfanimStruct01 *arg0)
else { else {
var_r25 = voiceParam[temp_r28 * 2 + 1]; var_r25 = voiceParam[temp_r28 * 2 + 1];
} }
temp_r26 = (arg0->unk00_s16 * 5) % 360; temp_r26 = (arg0->unk00 * 5) % 360;
arg0->unk34.x = temp_r30->pos.x + 40.0 * sind(arg0->unk08.y + temp_r26) * temp_r30->scale.x; arg0->unk34.x = temp_r30->pos.x + 40.0 * sind(arg0->unk08.y + temp_r26) * temp_r30->scale.x;
arg0->unk34.y = temp_r30->pos.y + var_r25 * temp_r30->scale.x; arg0->unk34.y = temp_r30->pos.y + var_r25 * temp_r30->scale.x;
arg0->unk34.z = temp_r30->pos.z + 40.0 * cosd(arg0->unk08.y + temp_r26) * temp_r30->scale.x; arg0->unk34.z = temp_r30->pos.z + 40.0 * cosd(arg0->unk08.y + temp_r26) * temp_r30->scale.x;
arg0->unk00_s16++; arg0->unk00++;
if (arg0->unk00_s16 >= 0x8F) { if (arg0->unk00 >= 0x8F) {
arg0->unk00_s16 = 0x48; arg0->unk00 = 0x48;
} }
if (temp_r29->unk04 != 0x15 && temp_r29->unk04 != 0x16 && temp_r29->unk04 != 0x79 && arg0->unk00_s16 > 0x1E) { if (temp_r29->unk04 != 0x15 && temp_r29->unk04 != 0x16 && temp_r29->unk04 != 0x79 && arg0->unk00 > 0x1E) {
arg0->unk2C -= 4.0f * temp_r30->scale.x; arg0->unk2C -= 4.0f * temp_r30->scale.x;
if (arg0->unk2C < 0.0f) { if (arg0->unk2C < 0.0f) {
arg0->unk2C = 0.0f; arg0->unk2C = 0.0f;
@ -1501,7 +1501,7 @@ static void OrbitEffect(HsfanimStruct01 *arg0)
float var_f30; float var_f30;
s16 temp_r30; s16 temp_r30;
var_f30 = 20.0f + 3.75f * arg0->unk00_s16; var_f30 = 20.0f + 3.75f * arg0->unk00;
if (var_f30 > 90.0f) { if (var_f30 > 90.0f) {
var_f30 = 90.0f; var_f30 = 90.0f;
} }
@ -1514,7 +1514,7 @@ static void OrbitEffect(HsfanimStruct01 *arg0)
if (arg0->unk20 < 1.0f) { if (arg0->unk20 < 1.0f) {
arg0->unk20 = 1.0f; arg0->unk20 = 1.0f;
} }
if (arg0->unk00_s16 > 8) { if (arg0->unk00 > 8) {
temp_r30 = arg0->unk40.a; temp_r30 = arg0->unk40.a;
temp_r30 -= 8; temp_r30 -= 8;
if (temp_r30 < 0) { if (temp_r30 < 0) {
@ -1525,7 +1525,7 @@ static void OrbitEffect(HsfanimStruct01 *arg0)
arg0->unk40.a = temp_r30; arg0->unk40.a = temp_r30;
} }
} }
arg0->unk00_s16++; arg0->unk00++;
} }
static EffectParamData coinParticleParam static EffectParamData coinParticleParam

View file

@ -55,7 +55,7 @@ s16 Hu3DAnimCreate(void *arg0, s16 arg1, char *arg2) {
Hu3DTexAnimDataStruct *var_r31; Hu3DTexAnimDataStruct *var_r31;
HsfAttribute *var_r29; HsfAttribute *var_r29;
HsfData *temp_r27; HsfData *temp_r27;
HsfanimStruct01 *var_r30; HsfdrawStruct01 *var_r30;
s16 i; s16 i;
s16 var_r25; s16 var_r25;
s16 var_r28; s16 var_r28;
@ -75,7 +75,7 @@ s16 Hu3DAnimCreate(void *arg0, s16 arg1, char *arg2) {
for (i = var_r25 = 0; i < temp_r27->attributeCnt; i++, var_r29++) { for (i = var_r25 = 0; i < temp_r27->attributeCnt; i++, var_r29++) {
if (strcmp(arg2, var_r29->bitmap->name) == 0) { if (strcmp(arg2, var_r29->bitmap->name) == 0) {
if (!var_r29->unk04) { if (!var_r29->unk04) {
var_r30 = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfanimStruct01), (u32) Hu3DData[arg1].unk_48); var_r30 = HuMemDirectMallocNum(HEAP_DATA, sizeof(*var_r30), (u32) Hu3DData[arg1].unk_48);
var_r29->unk04 = var_r30; var_r29->unk04 = var_r30;
var_r30->unk00 = 0; var_r30->unk00 = 0;
} else { } else {
@ -84,7 +84,7 @@ s16 Hu3DAnimCreate(void *arg0, s16 arg1, char *arg2) {
var_r30->unk00 |= 1; var_r30->unk00 |= 1;
var_r30->unk02 = var_r28; var_r30->unk02 = var_r28;
var_r30->unk2C = var_r30->unk30 = 1.0f; var_r30->unk2C = var_r30->unk30 = 1.0f;
var_r30->unk34.x = var_r30->unk34.y = 0.0f; var_r30->unk34 = var_r30->unk38 = 0.0f;
var_r25++; var_r25++;
} }
} }
@ -112,7 +112,7 @@ s16 Hu3DAnimLink(s16 arg0, s16 arg1, char *arg2) {
AnimData *temp_r4; AnimData *temp_r4;
HsfAttribute *var_r29; HsfAttribute *var_r29;
HsfData *temp_r27; HsfData *temp_r27;
HsfanimStruct01 *var_r30; HsfdrawStruct01 *var_r30;
s16 var_r28; s16 var_r28;
s16 i; s16 i;
s16 var_r25; s16 var_r25;
@ -132,14 +132,14 @@ s16 Hu3DAnimLink(s16 arg0, s16 arg1, char *arg2) {
for (i = var_r25 = 0; i < temp_r27->attributeCnt; i++, var_r29++) { for (i = var_r25 = 0; i < temp_r27->attributeCnt; i++, var_r29++) {
if (strcmp(arg2, var_r29->bitmap->name) == 0) { if (strcmp(arg2, var_r29->bitmap->name) == 0) {
if (!var_r29->unk04) { if (!var_r29->unk04) {
var_r30 = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfanimStruct01), (u32) Hu3DData[arg1].unk_48); var_r30 = HuMemDirectMallocNum(HEAP_DATA, sizeof(*var_r30), (u32) Hu3DData[arg1].unk_48);
var_r29->unk04 = var_r30; var_r29->unk04 = var_r30;
} else { } else {
var_r30 = var_r29->unk04; var_r30 = var_r29->unk04;
} }
var_r30->unk02 = var_r28; var_r30->unk02 = var_r28;
var_r30->unk2C = var_r30->unk30 = 1.0f; var_r30->unk2C = var_r30->unk30 = 1.0f;
var_r30->unk34.x = var_r30->unk34.y = 0.0f; var_r30->unk34 = var_r30->unk38 = 0.0f;
var_r25++; var_r25++;
} }
} }
@ -162,7 +162,7 @@ void Hu3DAnimKill(s16 arg0) {
Hu3DTexAnimDataStruct *temp_r31 = &Hu3DTexAnimData[arg0]; Hu3DTexAnimDataStruct *temp_r31 = &Hu3DTexAnimData[arg0];
HsfData *temp_r28 = Hu3DData[temp_r31->unk06].hsfData; HsfData *temp_r28 = Hu3DData[temp_r31->unk06].hsfData;
HsfAttribute *var_r30; HsfAttribute *var_r30;
HsfanimStruct01 *temp_r29; HsfdrawStruct01 *temp_r29;
s16 i; s16 i;
if (temp_r28) { if (temp_r28) {
@ -242,7 +242,7 @@ void Hu3DAnmNoSet(s16 arg0, u16 arg1) {
} }
s32 Hu3DAnimSet(ModelData *arg0, HsfAttribute *arg1, s16 arg2) { s32 Hu3DAnimSet(ModelData *arg0, HsfAttribute *arg1, s16 arg2) {
HsfanimStruct01 *temp_r30; HsfdrawStruct01 *temp_r30;
Hu3DTexAnimDataStruct *temp_r29; Hu3DTexAnimDataStruct *temp_r29;
AnimData *temp_r27; AnimData *temp_r27;
AnimBmpData *temp_r28; AnimBmpData *temp_r28;
@ -268,8 +268,8 @@ s32 Hu3DAnimSet(ModelData *arg0, HsfAttribute *arg1, s16 arg2) {
(arg0->attr & HU3D_ATTR_TEX_NEAR) ? GX_NEAR : GX_LINEAR); (arg0->attr & HU3D_ATTR_TEX_NEAR) ? GX_NEAR : GX_LINEAR);
temp_r30->unk2C = (float) temp_r31->sizeX / temp_r28->sizeX; temp_r30->unk2C = (float) temp_r31->sizeX / temp_r28->sizeX;
temp_r30->unk30 = (float) temp_r31->sizeY / temp_r28->sizeY; temp_r30->unk30 = (float) temp_r31->sizeY / temp_r28->sizeY;
temp_r30->unk34.x = (float) temp_r31->startX / temp_r28->sizeX; temp_r30->unk34 = (float) temp_r31->startX / temp_r28->sizeX;
temp_r30->unk34.y = (float) temp_r31->startY / temp_r28->sizeY; temp_r30->unk38 = (float) temp_r31->startY / temp_r28->sizeY;
return 1; return 1;
} }
@ -359,7 +359,7 @@ s16 Hu3DTexScrollCreate(s16 arg0, char *arg1) {
Hu3DTexScrDataStruct *var_r31; Hu3DTexScrDataStruct *var_r31;
HsfData *temp_r27; HsfData *temp_r27;
HsfAttribute *var_r29; HsfAttribute *var_r29;
HsfanimStruct01 *var_r30; HsfdrawStruct01 *var_r30;
s16 i; s16 i;
s16 var_r25; s16 var_r25;
s16 var_r28; s16 var_r28;
@ -379,7 +379,7 @@ s16 Hu3DTexScrollCreate(s16 arg0, char *arg1) {
for (i = var_r25 = 0; i < temp_r27->attributeCnt; i++, var_r29++) { for (i = var_r25 = 0; i < temp_r27->attributeCnt; i++, var_r29++) {
if (strcmp(arg1, var_r29->bitmap->name) == 0) { if (strcmp(arg1, var_r29->bitmap->name) == 0) {
if (!var_r29->unk04) { if (!var_r29->unk04) {
var_r30 = HuMemDirectMallocNum(HEAP_DATA, sizeof(HsfanimStruct01), (u32) Hu3DData[arg0].unk_48); var_r30 = HuMemDirectMallocNum(HEAP_DATA, sizeof(*var_r30), (u32) Hu3DData[arg0].unk_48);
var_r29->unk04 = var_r30; var_r29->unk04 = var_r30;
var_r30->unk00 = 0; var_r30->unk00 = 0;
} else { } else {
@ -388,7 +388,7 @@ s16 Hu3DTexScrollCreate(s16 arg0, char *arg1) {
var_r30->unk00 |= 2; var_r30->unk00 |= 2;
var_r30->unk04 = var_r28; var_r30->unk04 = var_r28;
var_r30->unk2C = var_r30->unk30 = 1.0f; var_r30->unk2C = var_r30->unk30 = 1.0f;
var_r30->unk34.x = var_r30->unk34.y = 0.0f; var_r30->unk34 = var_r30->unk38 = 0.0f;
var_r25++; var_r25++;
} }
} }
@ -408,7 +408,7 @@ void Hu3DTexScrollKill(s16 arg0) {
Hu3DTexScrDataStruct *temp_r28 = &Hu3DTexScrData[arg0]; Hu3DTexScrDataStruct *temp_r28 = &Hu3DTexScrData[arg0];
HsfData *temp_r29 = Hu3DData[temp_r28->unk02].hsfData; HsfData *temp_r29 = Hu3DData[temp_r28->unk02].hsfData;
HsfAttribute *var_r31; HsfAttribute *var_r31;
HsfanimStruct01 *temp_r30; HsfdrawStruct01 *temp_r30;
s16 i; s16 i;
if (temp_r29) { if (temp_r29) {
@ -1241,7 +1241,7 @@ static void ParManHook(ModelData *model, ParticleData *particle, Mtx matrix) {
var_r29->unk2C = var_r29->unk28; var_r29->unk2C = var_r29->unk28;
} }
if (!(temp_r28->unk02 & 0x80)) { if (!(temp_r28->unk02 & 0x80)) {
sp8 = var_r29->unk00_s16; sp8 = var_r29->unk00;
var_r29->unk34.x += var_r29->unk08.x + var_r29->unk14.x; var_r29->unk34.x += var_r29->unk08.x + var_r29->unk14.x;
var_r29->unk34.y += var_r29->unk08.y + var_r29->unk14.y; var_r29->unk34.y += var_r29->unk08.y + var_r29->unk14.y;
var_r29->unk34.z += var_r29->unk08.z + var_r29->unk14.z; var_r29->unk34.z += var_r29->unk08.z + var_r29->unk14.z;
@ -1261,7 +1261,7 @@ static void ParManHook(ModelData *model, ParticleData *particle, Mtx matrix) {
} }
} }
var_r29->unk28 *= temp_r26->unk28; var_r29->unk28 *= temp_r26->unk28;
var_f30 = (float) var_r29->unk00_s16 / temp_r26->unk00; var_f30 = (float) var_r29->unk00 / temp_r26->unk00;
if (var_f30 > 1.0f) { if (var_f30 > 1.0f) {
var_f30 = 1.0f; var_f30 = 1.0f;
} }
@ -1272,10 +1272,10 @@ static void ParManHook(ModelData *model, ParticleData *particle, Mtx matrix) {
var_r29->unk40.g = temp_r27->g + var_f30 * (temp_r24->g - temp_r27->g); var_r29->unk40.g = temp_r27->g + var_f30 * (temp_r24->g - temp_r27->g);
var_r29->unk40.b = temp_r27->b + var_f30 * (temp_r24->b - temp_r27->b); var_r29->unk40.b = temp_r27->b + var_f30 * (temp_r24->b - temp_r27->b);
var_r29->unk40.a = temp_r27->a + var_f30 * (temp_r24->a - temp_r27->a); var_r29->unk40.a = temp_r27->a + var_f30 * (temp_r24->a - temp_r27->a);
if (var_r29->unk2C < 0.01 || var_r29->unk00_s16 >= temp_r26->unk00) { if (var_r29->unk2C < 0.01 || var_r29->unk00 >= temp_r26->unk00) {
var_r29->unk2C = 0.0f; var_r29->unk2C = 0.0f;
} }
var_r29->unk00_s16++; var_r29->unk00++;
} }
} }
} }