This commit is contained in:
JHaack4 2021-10-02 22:57:58 -04:00
parent 9cb5991f85
commit 50ebf275f9
4 changed files with 24 additions and 18 deletions

View File

@ -1,18 +1,3 @@
.include "macros.inc"
.section .text, "ax" # 0x800056C0 - 0x80472F00
.global srand
srand:
/* 800C9598 000C64D8 90 6D 82 28 */ stw r3, next@sda21(r13)
/* 800C959C 000C64DC 4E 80 00 20 */ blr
.global rand
rand:
/* 800C95A0 000C64E0 3C 60 41 C6 */ lis r3, 0x41C64E6D@ha
/* 800C95A4 000C64E4 80 8D 82 28 */ lwz r4, next@sda21(r13)
/* 800C95A8 000C64E8 38 03 4E 6D */ addi r0, r3, 0x41C64E6D@l
/* 800C95AC 000C64EC 7C 64 01 D6 */ mullw r3, r4, r0
/* 800C95B0 000C64F0 38 03 30 39 */ addi r0, r3, 0x3039
/* 800C95B4 000C64F4 90 0D 82 28 */ stw r0, next@sda21(r13)
/* 800C95B8 000C64F8 54 03 84 7E */ rlwinm r3, r0, 0x10, 0x11, 0x1f
/* 800C95BC 000C64FC 4E 80 00 20 */ blr

9
include/rand.h Normal file
View File

@ -0,0 +1,9 @@
#ifndef _RAND_H
#define _RAND_H
#include "types.h"
void srand(u32);
short rand(void);
#endif

View File

@ -65,6 +65,7 @@ TEXT_O_FILES:=\
$(BUILD_DIR)/asm/Dolphin/misc_io.o\
$(BUILD_DIR)/asm/Dolphin/printf.o\
$(BUILD_DIR)/asm/Dolphin/rand.o\
$(BUILD_DIR)/src/Dolphin/rand.o\
$(BUILD_DIR)/asm/Dolphin/scanf.o\
$(BUILD_DIR)/asm/Dolphin/string.o\
$(BUILD_DIR)/asm/Dolphin/strtold.o\

View File

@ -1,12 +1,15 @@
#include "rand.h"
extern u32 next;
/*
* --INFO--
* Address: 800C9598
* Size: 000008
*/
void srand(void)
void srand(u32 seed)
{
next = seed;
/*
.loc_0x0:
stw r3, -0x7DD8(r13)
@ -19,8 +22,10 @@ void srand(void)
* Address: 800C95A0
* Size: 000020
*/
void rand(void)
short rand(void)
{
next = next * 0x41c64e6d + 0x3039;
return (s16)((u16)((u32)next >> 0x10) & 0x7fff);
/*
.loc_0x0:
lis r3, 0x41C6
@ -32,4 +37,10 @@ void rand(void)
rlwinm r3,r0,16,17,31
blr
*/
}
}
/*
{
next = next * 0x41c64e6d + 0x3039;
return (short)((ushort)((uint)next >> 0x10) & 0x7fff);
}
*/