Skip to content

Commit

Permalink
[headers 9] Add src/libc64/ and new "z64" rand.h (#2164)
Browse files Browse the repository at this point in the history
* rand.h -> libc64/qrand.h

* Add rand.h with z64 rand wrappers

* yeet comment

* code/rand.c -> libc64/qrand.c

* fixup

* move libc64 source to src/libc64/

* fix

* bss

* update file splits disasm metadata
  • Loading branch information
Dragorn421 authored Sep 8, 2024
1 parent a903f8b commit c7ec814
Show file tree
Hide file tree
Showing 19 changed files with 52 additions and 49 deletions.
10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -421,15 +421,9 @@ endif
ifeq ($(COMPILER),ido)
$(BUILD_DIR)/src/boot/driverominit.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/boot/logutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/boot/sleep.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/boot/sprintf.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/boot/stackcheck.o: OPTFLAGS := -O2

$(BUILD_DIR)/src/code/__osMalloc_n64.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/__osMalloc_gc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/code_800FC620.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/fp_math.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/rand.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/gfxprint.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/jpegutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/jpegdecoder.o: OPTFLAGS := -O2
Expand All @@ -439,9 +433,7 @@ $(BUILD_DIR)/src/code/loadfragment2_gc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/mtxuty-cvt.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/padsetup.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/padutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/printutils.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/relocation_gc.o: OPTFLAGS := -O2
$(BUILD_DIR)/src/code/system_malloc.o: OPTFLAGS := -O2

$(BUILD_DIR)/src/code/fault_n64.o: CFLAGS += -trapuv
$(BUILD_DIR)/src/code/fault_gc.o: CFLAGS += -trapuv
Expand All @@ -464,6 +456,8 @@ else
$(BUILD_DIR)/src/libc/%.o: OPTFLAGS := -O2
endif

$(BUILD_DIR)/src/libc64/%.o: OPTFLAGS := -O2

$(BUILD_DIR)/src/audio/%.o: OPTFLAGS := -O2

# Use signed chars instead of unsigned for this audio file (needed to match AudioDebug_ScrPrt)
Expand Down
2 changes: 0 additions & 2 deletions include/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,6 @@ void func_80033C30(Vec3f* arg0, Vec3f* arg1, u8 alpha, PlayState* play);
void Actor_RequestQuake(PlayState* play, s16 y, s16 duration);
void Actor_RequestQuakeWithSpeed(PlayState* play, s16 y, s16 duration, s16 speed);
void Actor_RequestQuakeAndRumble(Actor* actor, PlayState* play, s16 quakeY, s16 quakeDuration);
f32 Rand_ZeroFloat(f32 f);
f32 Rand_CenteredFloat(f32 f);
void Actor_DrawDoorLock(PlayState* play, s32 frame, s32 type);
void func_8003424C(PlayState* play, Vec3f* arg1);
void Actor_SetColorFilter(Actor* actor, s16 colorFlag, s16 colorIntensityMax, s16 bufFlag, s16 duration);
Expand Down
18 changes: 18 additions & 0 deletions include/libc64/qrand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef LIBC64_QRAND_H
#define LIBC64_QRAND_H

#include "ultra64.h"

u32 Rand_Next(void);
void Rand_Seed(u32 seed);
f32 Rand_ZeroOne(void);
void Rand_Seed_Variable(u32* rndNum, u32 seed);
u32 Rand_Next_Variable(u32* rndNum);
f32 Rand_ZeroOne_Variable(u32* rndNum);

#if !PLATFORM_N64
f32 Rand_Centered(void);
f32 Rand_Centered_Variable(u32* rndNum);
#endif

#endif
15 changes: 3 additions & 12 deletions include/rand.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
#ifndef RAND_H
#define RAND_H

#include "ultra64.h"
#include "libc64/qrand.h"

u32 Rand_Next(void);
void Rand_Seed(u32 seed);
f32 Rand_ZeroOne(void);
void Rand_Seed_Variable(u32* rndNum, u32 seed);
u32 Rand_Next_Variable(u32* rndNum);
f32 Rand_ZeroOne_Variable(u32* rndNum);

#if !PLATFORM_N64
f32 Rand_Centered(void);
f32 Rand_Centered_Variable(u32* rndNum);
#endif
f32 Rand_ZeroFloat(f32 f);
f32 Rand_CenteredFloat(f32 f);

#endif
1 change: 1 addition & 0 deletions include/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#include "jpeg.h"
#include "prerender.h"
#include "rand.h"
#include "libc64/qrand.h"
#include "sys_math.h"
#include "sys_math3d.h"
#include "fp_math.h"
Expand Down
22 changes: 11 additions & 11 deletions spec
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ beginseg
include "$(BUILD_DIR)/src/boot/stackcheck.o"
include "$(BUILD_DIR)/src/boot/logutils.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/boot/sleep.o"
include "$(BUILD_DIR)/src/libc64/sleep.o"
#endif
#if OOT_DEBUG
include "$(BUILD_DIR)/src/boot/sprintf.o"
include "$(BUILD_DIR)/src/libc64/sprintf.o"
#endif
include "$(BUILD_DIR)/src/libultra/io/piacs.o"
include "$(BUILD_DIR)/src/libultra/os/sendmesg.o"
Expand Down Expand Up @@ -614,21 +614,21 @@ beginseg
include "$(BUILD_DIR)/src/code/padutils.o"
include "$(BUILD_DIR)/src/code/padsetup.o"
#endif
include "$(BUILD_DIR)/src/code/fp_math.o"
include "$(BUILD_DIR)/src/code/fp.o"
include "$(BUILD_DIR)/src/code/system_malloc.o"
include "$(BUILD_DIR)/src/code/rand.o"
include "$(BUILD_DIR)/src/libc64/math64.o"
include "$(BUILD_DIR)/src/libc64/fp.o"
include "$(BUILD_DIR)/src/libc64/malloc.o"
include "$(BUILD_DIR)/src/libc64/qrand.o"
#if PLATFORM_N64
include "$(BUILD_DIR)/src/code/__osMalloc_n64.o"
include "$(BUILD_DIR)/src/libc64/__osMalloc_n64.o"
#else
include "$(BUILD_DIR)/src/code/__osMalloc_gc.o"
include "$(BUILD_DIR)/src/libc64/__osMalloc_gc.o"
#endif
#if !OOT_DEBUG
include "$(BUILD_DIR)/src/boot/sprintf.o"
include "$(BUILD_DIR)/src/libc64/sprintf.o"
#endif
include "$(BUILD_DIR)/src/code/printutils.o"
include "$(BUILD_DIR)/src/libc64/aprintf.o"
#if !PLATFORM_N64
include "$(BUILD_DIR)/src/boot/sleep.o"
include "$(BUILD_DIR)/src/libc64/sleep.o"
#endif
include "$(BUILD_DIR)/src/code/jpegutils.o"
include "$(BUILD_DIR)/src/code/jpegdecoder.o"
Expand Down
1 change: 1 addition & 0 deletions src/code/z_actor.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "global.h"
#include "fault.h"
#include "quake.h"
#include "rand.h"
#include "terminal.h"

#include "overlays/actors/ovl_Arms_Hook/z_arms_hook.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/code/rand.c → src/libc64/qrand.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
*
* @note Original name: qrand.c
*/
#include "rand.h"
#include "libc64/qrand.h"
#include "z64math.h"

#define RAND_MULTIPLIER 1664525
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/overlays/actors/ovl_Fishing/z_fishing.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "cic6105.h"
#endif

#pragma increment_block_number "gc-eu:141 gc-eu-mq:141 gc-jp:143 gc-jp-ce:143 gc-jp-mq:143 gc-us:143 gc-us-mq:143"
#pragma increment_block_number "gc-eu:140 gc-eu-mq:140 gc-jp:142 gc-jp-ce:142 gc-jp-mq:142 gc-us:142 gc-us-mq:142"

#define FLAGS ACTOR_FLAG_4

Expand Down
2 changes: 1 addition & 1 deletion tools/disasm/ntsc-1.2/files_boot.csv
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FD0,80001430,src/boot/z_locale
1530,80001990,src/boot/mio0
15E0,80001A40,src/boot/stackcheck
17F0,80001C50,src/boot/logutils
1910,80001D70,src/boot/sleep
1910,80001D70,src/libc64/sleep
1AB0,80001F10,src/libultra/io/piacs
1B70,80001FD0,src/libultra/os/sendmesg
1CC0,80002120,src/libultra/os/stopthread
Expand Down
26 changes: 13 additions & 13 deletions tools/disasm/ntsc-1.2/files_code.csv
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ BBA50,800CD130,src/code/loadfragment2_n64
BBF00,800CD5E0,src/code/padutils
BC110,800CD7F0,src/code/code_800FC620
BC530,800CDC10,src/code/padsetup
BC670,800CDD50,src/code/fp_math
BCA20,800CE100,src/code/fp
BCB80,800CE260,src/code/system_malloc
BCDF0,800CE4D0,src/code/rand
BCEF0,800CE5D0,src/code/__osMalloc_n64
BD8A0,800CEF80,src/boot/sprintf
BD970,800CF050,src/code/printutils
BC670,800CDD50,src/libc64/math64
BCA20,800CE100,src/libc64/fp
BCB80,800CE260,src/libc64/malloc
BCDF0,800CE4D0,src/libc64/qrand
BCEF0,800CE5D0,src/libc64/__osMalloc_n64
BD8A0,800CEF80,src/libc64/sprintf
BD970,800CF050,src/libc64/aprintf
BD9D0,800CF0B0,src/code/jpegutils
BDEE0,800CF5C0,src/code/jpegdecoder
BE4D0,800CFBB0,src/libultra/os/getintmask
Expand Down Expand Up @@ -291,9 +291,9 @@ F3330,80104A10,src/audio/session_config
F3AD0,801051B0,src/code/gfxprint
F4380,80105A60,src/code/loadfragment2_n64
F4390,80105A70,src/code/code_800FC620
F43A0,80105A80,src/code/rand
F43B0,80105A90,src/code/__osMalloc_n64
F43C0,80105AA0,src/boot/sprintf
F43A0,80105A80,src/libc64/qrand
F43B0,80105A90,src/libc64/__osMalloc_n64
F43C0,80105AA0,src/libc64/sprintf
F4400,80105AE0,src/libultra/gu/sins
F4C00,801062E0,src/libultra/io/siacs
F4C10,801062F0,src/libultra/io/controller
Expand Down Expand Up @@ -379,8 +379,8 @@ F9180,8010A860,src/audio/session_config
F9190,8010A870,src/code/gfxprint
F91D0,8010A8B0,src/code/rcp_utils
F9320,8010AA00,src/code/loadfragment2_n64
F94C0,8010ABA0,src/code/fp_math
F94E0,8010ABC0,src/code/__osMalloc_n64
F94C0,8010ABA0,src/libc64/math64
F94E0,8010ABC0,src/libc64/__osMalloc_n64
F9690,8010AD70,src/libultra/gu/sinf
F96E0,8010ADC0,src/libultra/gu/perspective
F96F0,8010ADD0,src/libultra/gu/lookathil
Expand Down Expand Up @@ -449,7 +449,7 @@ offset,vram,.bss
1139C0,801250A0,src/audio/sequence
114780,80125E60,src/audio/data
114820,80125F00,src/audio/session_config
11AC90,8012C370,src/code/system_malloc
11AC90,8012C370,src/libc64/malloc
11ACA0,8012C380,src/code/jpegdecoder
11ACB0,8012C390,src/libultra/io/sptask
11ACF0,8012C3D0,src/libultra/io/motor
Expand Down

0 comments on commit c7ec814

Please sign in to comment.