You've already forked HackerSM64
mirror of
https://github.com/HackerN64/HackerSM64.git
synced 2026-01-21 10:35:32 -08:00
Compare commits
19 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b6d83b3291 | ||
|
|
9717d89fb8 | ||
|
|
38e9b08695 | ||
|
|
312496d769 | ||
|
|
d68233a1c0 | ||
|
|
7ef2077353 | ||
|
|
a15db3c56b | ||
|
|
e87dfa74d8 | ||
|
|
e3e1aa02ac | ||
|
|
d3d2bb9247 | ||
|
|
dc1a824ce9 | ||
|
|
efd4e3f9dc | ||
|
|
b1146308a7 | ||
|
|
b8e22f2fbd | ||
|
|
1a71619f47 | ||
|
|
7d6579971a | ||
|
|
a549e1a95a | ||
|
|
83fea6d310 | ||
|
|
8698cc0f89 |
2
.vscode/c_cpp_properties.json
vendored
2
.vscode/c_cpp_properties.json
vendored
@@ -33,7 +33,7 @@
|
||||
"compilerPath": "/usr/bin/mips-linux-gnu-gcc",
|
||||
"cStandard": "gnu17",
|
||||
"cppStandard": "gnu++14",
|
||||
"intelliSenseMode": "linux-gcc-x64"
|
||||
"intelliSenseMode": "linux-gcc-x86"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# These owners will be the default owners for everything in the repo.
|
||||
* @Reonu
|
||||
* @thecozies
|
||||
* @Mr-Wiseguy
|
||||
* @gheskett
|
||||
|
||||
# Order is important. The last matching pattern has the most precedence.
|
||||
# So if a pull request only touches javascript files, only these owners
|
||||
|
||||
26
Makefile
26
Makefile
@@ -135,10 +135,14 @@ LINK_LIBRARIES = $(foreach i,$(LIBRARIES),-l$(i))
|
||||
|
||||
# Default non-gcc opt flags
|
||||
DEFAULT_OPT_FLAGS = -Ofast
|
||||
# Note: -fno-associative-math is used here to suppress warnings, ideally we would enable this as an optimization but
|
||||
# this conflicts with -ftrapping-math apparently.
|
||||
# TODO: Figure out how to allow -fassociative-math to be enabled
|
||||
SAFETY_OPT_FLAGS = -ftrapping-math -fno-associative-math
|
||||
|
||||
# Main opt flags
|
||||
GCC_MAIN_OPT_FLAGS = \
|
||||
-Ofast \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
--param case-values-threshold=20 \
|
||||
--param max-completely-peeled-insns=10 \
|
||||
--param max-unrolled-insns=10 \
|
||||
@@ -149,7 +153,7 @@ GCC_MAIN_OPT_FLAGS = \
|
||||
|
||||
# Surface Collision
|
||||
GCC_COLLISION_OPT_FLAGS = \
|
||||
-Ofast \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
--param case-values-threshold=20 \
|
||||
--param max-completely-peeled-insns=100 \
|
||||
--param max-unrolled-insns=100 \
|
||||
@@ -162,7 +166,7 @@ GCC_COLLISION_OPT_FLAGS = \
|
||||
|
||||
# Math Util
|
||||
GCC_MATH_UTIL_OPT_FLAGS = \
|
||||
-Ofast \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
-fno-unroll-loops \
|
||||
-fno-peel-loops \
|
||||
--param case-values-threshold=20 \
|
||||
@@ -174,7 +178,7 @@ GCC_MATH_UTIL_OPT_FLAGS = \
|
||||
|
||||
# Rendering graph node
|
||||
GCC_GRAPH_NODE_OPT_FLAGS = \
|
||||
-Ofast \
|
||||
$(DEFAULT_OPT_FLAGS) $(SAFETY_OPT_FLAGS) \
|
||||
--param case-values-threshold=20 \
|
||||
--param max-completely-peeled-insns=100 \
|
||||
--param max-unrolled-insns=100 \
|
||||
@@ -689,9 +693,11 @@ $(BUILD_DIR)/%.ci4.inc.c: %.ci4.png
|
||||
$(BUILD_DIR)/%.elf: $(BUILD_DIR)/%.o
|
||||
$(call print,Linking ELF file:,$<,$@)
|
||||
$(V)$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map -o $@ $<
|
||||
# Override for leveldata.elf, which otherwise matches the above pattern
|
||||
# Override for leveldata.elf, which otherwise matches the above pattern.
|
||||
# Has to be a static pattern rule for make-4.4 and above to trigger the second
|
||||
# expansion.
|
||||
.SECONDEXPANSION:
|
||||
$(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
|
||||
$(LEVEL_ELF_FILES): $(BUILD_DIR)/levels/%/leveldata.elf: $(BUILD_DIR)/levels/%/leveldata.o $(BUILD_DIR)/bin/$$(TEXTURE_BIN).elf
|
||||
$(call print,Linking ELF file:,$<,$@)
|
||||
$(V)$(LD) -e 0 -Ttext=$(SEGMENT_ADDRESS) -Map $@.map --just-symbols=$(BUILD_DIR)/bin/$(TEXTURE_BIN).elf -o $@ $<
|
||||
|
||||
@@ -870,8 +876,16 @@ $(ELF): $(BUILD_DIR)/sm64_prelim.elf $(BUILD_DIR)/asm/debug/map.o $(O_FILES) $(Y
|
||||
$(V)$(LD) --gc-sections -L $(BUILD_DIR) -T undefined_syms.txt -T $(BUILD_DIR)/$(LD_SCRIPT) -T goddard.txt -Map $(BUILD_DIR)/sm64.$(VERSION).map --no-check-sections $(addprefix -R ,$(SEG_FILES)) -o $@ $(O_FILES) -L$(LIBS_DIR) -l$(ULTRALIB) -Llib $(LINK_LIBRARIES) -u sprintf -u osMapTLB -Llib/gcclib/$(LIBGCCDIR) -lgcc -lrtc
|
||||
|
||||
# Build ROM
|
||||
ifeq (n,$(findstring n,$(firstword -$(MAKEFLAGS))))
|
||||
# run with -n / --dry-run
|
||||
$(ROM):
|
||||
@$(PRINT) "$(BLUE)DRY RUNS ARE DISABLED$(NO_COL)\n"
|
||||
else
|
||||
# not running with -n / --dry-run
|
||||
$(ROM): $(ELF)
|
||||
$(call print,Building ROM:,$<,$@)
|
||||
endif
|
||||
|
||||
ifeq ($(CONSOLE),n64)
|
||||
$(V)$(OBJCOPY) --pad-to=0x101000 --gap-fill=0xFF $< $@ -O binary
|
||||
else ifeq ($(CONSOLE),bb)
|
||||
|
||||
@@ -39,6 +39,8 @@ ACTOR_GROUPS := \
|
||||
|
||||
LEVEL_FILES := $(addsuffix leveldata,$(LEVEL_DIRS))
|
||||
|
||||
LEVEL_ELF_FILES := $(foreach level_dir,$(LEVEL_DIRS),$(BUILD_DIR)/levels/$(level_dir)leveldata.elf)
|
||||
|
||||
SEG_FILES := \
|
||||
$(SEGMENTS:%=$(BUILD_DIR)/bin/%.elf) \
|
||||
$(ACTOR_GROUPS:%=$(BUILD_DIR)/actors/%.elf) \
|
||||
|
||||
@@ -14,7 +14,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin
|
||||
- **ArcticJaguar725**: Most audio configuration and layout changes, colored ia4 text, floombas, various bugfixes, and more
|
||||
- **CowQuack**: Adjustable skybox sizes, area-specific skybox function
|
||||
- **thecozies**: Water surface types, general maintenance, and time
|
||||
- **MrComit**: General use object defines, JUMP_KICK_FIX, LEDGE_GRABS_CHECK_SLOPE_ANGLE
|
||||
- **MrComit**: General use object defines, JUMP_KICK_FIX
|
||||
- **aglab2**: Bugfixes (particularly puppycam), refactor stuff
|
||||
- **someone2639**: math.s and crash screen disam, stack trace, map packing, shiftable segments 2, S2DEX engine
|
||||
- **Arthurtilly**: Platform Displacement 2
|
||||
@@ -61,7 +61,6 @@ Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff
|
||||
- Toggle to disable fall damage and the fall damage sound *
|
||||
- Nonstop stars *
|
||||
- Removed course-specific camera processing *
|
||||
- You can increase the number of frames that you have to perform a firsty *
|
||||
- Ability to set Mario's movement speed when hanging from a ceiling *
|
||||
- Tighter hanging controls (Mario will face the direction of the analog stick directly while hanging from a ceiling) *
|
||||
- reonucam3: custom camera by Reonu. This is included as a .patch file in the enhancements folder, you need to apply it if you want this camera.
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.0.2
|
||||
v2.0.9
|
||||
|
||||
@@ -68,14 +68,11 @@
|
||||
// Allows Mario to grab hangable ceilings from any state.
|
||||
#define HANGING_FIX
|
||||
|
||||
// The last frame after hitting a wall that will be considered a firsty when wallkicking.
|
||||
#define FIRSTY_LAST_FRAME 1
|
||||
|
||||
// The maximum angle the player can wall kick, in degrees. 0..90. To allow 45 degree wall kicks, you must supply `46` to allow 45 and under.
|
||||
#define WALL_KICK_DEGREES 45
|
||||
|
||||
// This is vanilla behavior, disable it to allow ledge grabbing regardless of floor pitch.
|
||||
// #define LEDGE_GRABS_CHECK_SLOPE_ANGLE
|
||||
// Makes Mario unable to ledge grab steep slopes to prevent false ledge grabs.
|
||||
#define DONT_LEDGE_GRAB_STEEP_SLOPES
|
||||
|
||||
// Disables BLJs and crushes SimpleFlips's dreams.
|
||||
// #define DISABLE_BLJ
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
/*---------------------------------------------------------------------
|
||||
Copyright (C) 1997, 1998 Nintendo.
|
||||
|
||||
File rtc.h
|
||||
Coded by Shigeo Kimura. Oct 14, 1997.
|
||||
Modified by Koji Mitsunari. Jan 22, 2001.
|
||||
Comments Real Time Clock Library
|
||||
---------------------------------------------------------------------*/
|
||||
#ifndef _rtc_h_
|
||||
#define _rtc_h_
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* Macro & constant definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
/* Controller type */
|
||||
#define CONT_TYPE_RTC 0x1000 /* from os.h */
|
||||
#define RTC_WAIT 300
|
||||
|
||||
/* RTC status signed 32bits */
|
||||
#define RTC_NG_NOTHING 0x8000
|
||||
#define RTC_NG_WRITE 0x0100
|
||||
#define RTC_NG_ADDR 0x0200
|
||||
#define RTC_STATUS_BUSY 0x0080
|
||||
#define RTC_STATUS_DDOWN 0x0002
|
||||
#define RTC_STATUS_BDOWN 0x0001
|
||||
|
||||
/* RTC Error Code */
|
||||
#define CONT_ERR_RTC_BUSY 16
|
||||
#define CONT_ERR_RTC_BDOWN 17
|
||||
#define CONT_ERR_RTC_DDOWN 18
|
||||
#define CONT_ERR_RTC_BDDOWN 19
|
||||
|
||||
/* RTC bit status */
|
||||
#define RTC_EALM 0x80
|
||||
#define RTC_ALM 0x20
|
||||
#define RTC_WPB1 0x02
|
||||
#define RTC_WPB0 0x01
|
||||
#define RTC_MOD 0x04
|
||||
#define RTC_CHLD 0x02
|
||||
#define RTC_ADJ 0x01
|
||||
|
||||
#define RTC_ADDR_FLAG 0
|
||||
#define RTC_ADDR_RAM 1
|
||||
#define RTC_ADDR_TIME 2
|
||||
|
||||
typedef struct{
|
||||
u8 sec; /* second 0-59 */
|
||||
u8 min; /* minute 0-59 */
|
||||
u8 hour; /* hour 0-23 */
|
||||
u8 day; /* day 1-31 */
|
||||
u8 week; /* week 0-6(sun,mon,..,sat) */
|
||||
u8 month; /* month 1-12 */
|
||||
u16 year; /* year 1901-2099 */
|
||||
} OSRTCTime;
|
||||
|
||||
/*-----------------------------------------------------------------------
|
||||
* externs
|
||||
*-----------------------------------------------------------------------*/
|
||||
|
||||
extern s32 osRTCInit( OSMesgQueue *mq);
|
||||
extern s32 osRTCReadData( OSMesgQueue *mq, u8 *);
|
||||
extern s32 osRTCWriteData( OSMesgQueue *mq, u8 *);
|
||||
extern s32 osRTCGetTime( OSMesgQueue *mq, OSRTCTime *);
|
||||
extern s32 osRTCSetTime( OSMesgQueue *mq, OSRTCTime *);
|
||||
extern u32 osRTCGetIntervalTime(OSRTCTime *, OSRTCTime *);
|
||||
extern s32 osRTCGetLaterTime(OSMesgQueue *mq, u32, OSRTCTime *);
|
||||
extern s32 osRTCSetAlarm( OSMesgQueue *mq, u8, u8);
|
||||
extern s32 osRTCGetAlarmStat(OSMesgQueue *mq, u8 *, u8 *, int *);
|
||||
extern s32 osRTCProbe( OSMesgQueue *mq);
|
||||
|
||||
#endif /* _rtc_h_ */
|
||||
@@ -244,7 +244,7 @@ enum SurfaceTypes {
|
||||
|
||||
enum SurfaceClass {
|
||||
SURFACE_CLASS_DEFAULT,
|
||||
SURFACE_CLASS_VERY_SLIPPERY = 0x0013,
|
||||
SURFACE_CLASS_VERY_SLIPPERY,
|
||||
SURFACE_CLASS_SLIPPERY,
|
||||
SURFACE_CLASS_NOT_SLIPPERY
|
||||
};
|
||||
|
||||
@@ -98,12 +98,6 @@ typedef s8 ObjAction8;
|
||||
typedef s32 ObjAction32;
|
||||
typedef s16 ColFlags;
|
||||
|
||||
// -- Angle --
|
||||
typedef s16 Angle;
|
||||
typedef u16 UAngle;
|
||||
typedef s32 Angle32;
|
||||
typedef Angle Vec3a[3];
|
||||
|
||||
// -- Collision --
|
||||
typedef ROOM_DATA_TYPE RoomData;
|
||||
typedef COLLISION_DATA_TYPE Collision; // Collision is by default an s16, but it's best to have it match the type of COLLISION_DATA_TYPE
|
||||
@@ -489,10 +483,10 @@ struct MarioState {
|
||||
Vec3f prevPos;
|
||||
f32 lateralSpeed;
|
||||
f32 moveSpeed;
|
||||
Angle movePitch;
|
||||
Angle moveYaw;
|
||||
Angle ceilYaw;
|
||||
Angle wallYaw;
|
||||
s16 movePitch;
|
||||
s16 moveYaw;
|
||||
s16 ceilYaw;
|
||||
s16 wallYaw;
|
||||
// -- HackerSM64 MarioState fields end --
|
||||
};
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size)
|
||||
#ifdef VERSION_SH
|
||||
pool->size = size - ((uintptr_t) memAddr & 0xf);
|
||||
#else
|
||||
pool->size = size;
|
||||
pool->size = ALIGN16(size);
|
||||
#endif
|
||||
pool->numAllocatedEntries = 0;
|
||||
}
|
||||
@@ -408,6 +408,8 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
u32 leftAvail, rightAvail;
|
||||
#endif
|
||||
|
||||
size = ALIGN16(size);
|
||||
|
||||
#ifdef VERSION_SH
|
||||
switch (poolIdx) {
|
||||
case 0:
|
||||
@@ -656,7 +658,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
#if defined(VERSION_SH)
|
||||
tp->entries[1].ptr = (u8 *) ((uintptr_t) (pool->start + pool->size - size) & ~0x0f);
|
||||
#else
|
||||
tp->entries[1].ptr = pool->start + pool->size - size - 0x10;
|
||||
tp->entries[1].ptr = pool->start + pool->size - size;
|
||||
#endif
|
||||
tp->entries[1].id = id;
|
||||
tp->entries[1].size = size;
|
||||
@@ -967,22 +969,6 @@ s32 audio_shut_down_and_reset_step(void) {
|
||||
}
|
||||
return (gAudioResetStatus < 3);
|
||||
}
|
||||
#else
|
||||
/**
|
||||
* Waits until a specified number of audio frames have been created
|
||||
*/
|
||||
void wait_for_audio_frames(s32 frames) {
|
||||
// VC emulator stubs this function because busy loops are not supported
|
||||
// Technically we can put infinite loop that _looks_ like -O0 for emu but this is cleaner
|
||||
//if (gIsVC) {
|
||||
return;
|
||||
//}
|
||||
gAudioFrameCount = 0;
|
||||
// Sound thread will update gAudioFrameCount
|
||||
while (gAudioFrameCount < frames) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
u8 sAudioFirstBoot = 0;
|
||||
@@ -1167,22 +1153,33 @@ void init_reverb_us(s32 presetId) {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
void audio_reset_session(struct AudioSessionSettings *preset, s32 presetId) {
|
||||
if (sAudioFirstBoot) {
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
persistent_pool_clear(&gSeqLoadedPool.persistent);
|
||||
persistent_pool_clear(&gBankLoadedPool.persistent);
|
||||
temporary_pool_clear( &gSeqLoadedPool.temporary);
|
||||
temporary_pool_clear( &gBankLoadedPool.temporary);
|
||||
reset_bank_and_seq_load_status();
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_LOADING;
|
||||
|
||||
init_reverb_us(presetId);
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
gAudioFrameCount = 0;
|
||||
if (!gIsVC) {
|
||||
while (gAudioFrameCount < 1) {
|
||||
// spin
|
||||
if (!gIsVC) {
|
||||
gAudioFrameCount = 0;
|
||||
while (gAudioFrameCount < 1) {
|
||||
// spin
|
||||
}
|
||||
}
|
||||
|
||||
for (s32 i = 0; i < gMaxSimultaneousNotes; i++) {
|
||||
gNotes[i].enabled = FALSE;
|
||||
}
|
||||
|
||||
persistent_pool_clear(&gSeqLoadedPool.persistent);
|
||||
persistent_pool_clear(&gBankLoadedPool.persistent);
|
||||
temporary_pool_clear( &gSeqLoadedPool.temporary);
|
||||
temporary_pool_clear( &gBankLoadedPool.temporary);
|
||||
reset_bank_and_seq_load_status();
|
||||
|
||||
init_reverb_us(presetId);
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
|
||||
if (gAudioLoadLock != AUDIO_LOCK_UNINITIALIZED) {
|
||||
gAudioLoadLock = AUDIO_LOCK_NOT_LOADING;
|
||||
}
|
||||
}
|
||||
bzero(&gAiBuffers[0][0], (AIBUFFER_LEN * NUMAIBUFFERS));
|
||||
return;
|
||||
}
|
||||
#else
|
||||
|
||||
@@ -38,8 +38,14 @@ struct SeqOrBankEntry {
|
||||
struct PersistentPool {
|
||||
/*0x00*/ u32 numEntries;
|
||||
/*0x04*/ struct SoundAllocPool pool;
|
||||
#ifdef EXPAND_AUDIO_HEAP // TODO: Make this a configurable define rather than using static values
|
||||
/*0x14*/ struct SeqOrBankEntry entries[64];
|
||||
// size = 0x314
|
||||
#else
|
||||
/*0x14*/ struct SeqOrBankEntry entries[32];
|
||||
}; // size = 0x194
|
||||
// size = 0x194
|
||||
#endif
|
||||
};
|
||||
|
||||
struct TemporaryPool {
|
||||
/*EU, SH*/
|
||||
@@ -64,9 +70,14 @@ struct SoundMultiPool {
|
||||
/* */ u32 pad2[4];
|
||||
}; // size = 0x1D0
|
||||
|
||||
#ifdef VERSION_SH
|
||||
struct Unk1Pool {
|
||||
struct SoundAllocPool pool;
|
||||
#ifdef EXPAND_AUDIO_HEAP
|
||||
struct SeqOrBankEntry entries[64];
|
||||
#else
|
||||
struct SeqOrBankEntry entries[32];
|
||||
#endif
|
||||
};
|
||||
|
||||
struct UnkEntry {
|
||||
@@ -85,6 +96,7 @@ struct UnkPool {
|
||||
/*0x510*/ s32 numEntries;
|
||||
/*0x514*/ u32 unk514;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern u8 gAudioHeap[];
|
||||
extern s16 gVolume;
|
||||
|
||||
@@ -24,6 +24,8 @@ struct SharedDma {
|
||||
// EU only
|
||||
void port_eu_init(void);
|
||||
|
||||
ALIGNED16 u32 dmaTempBuffer[4];
|
||||
|
||||
struct Note *gNotes;
|
||||
|
||||
struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
@@ -199,11 +201,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
|
||||
if (arg2 != 0 || *dmaIndexRef >= sSampleDmaListSize1) {
|
||||
for (i = sSampleDmaListSize1; i < gSampleDmaNumListItems; i++) {
|
||||
#if defined(VERSION_EU)
|
||||
dma = &sSampleDmas[i];
|
||||
#else
|
||||
dma = sSampleDmas + i;
|
||||
#endif
|
||||
bufferPos = devAddr - dma->source;
|
||||
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
|
||||
// We already have a DMA request for this memory range.
|
||||
@@ -220,11 +218,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
}
|
||||
dma->ttl = 60;
|
||||
*dmaIndexRef = (u8) i;
|
||||
#if defined(VERSION_EU)
|
||||
return &dma->buffer[(devAddr - dma->source)];
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,12 +231,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
hasDma = TRUE;
|
||||
}
|
||||
} else {
|
||||
#if defined(VERSION_EU)
|
||||
dma = sSampleDmas;
|
||||
dma += *dmaIndexRef;
|
||||
#else
|
||||
dma = sSampleDmas + *dmaIndexRef;
|
||||
#endif
|
||||
bufferPos = devAddr - dma->source;
|
||||
if (0 <= bufferPos && (size_t) bufferPos <= dma->bufSize - size) {
|
||||
// We already have DMA for this memory range.
|
||||
@@ -258,11 +247,7 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
sSampleDmaReuseQueueTail1++;
|
||||
}
|
||||
dma->ttl = 2;
|
||||
#if defined(VERSION_EU)
|
||||
return dma->buffer + (devAddr - dma->source);
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,21 +264,13 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
dma->ttl = 2;
|
||||
dma->source = dmaDevAddr;
|
||||
dma->sizeUnused = transfer;
|
||||
#ifdef VERSION_US
|
||||
#ifdef VERSION_US // TODO: Is there a reason this only exists in US?
|
||||
osInvalDCache(dma->buffer, transfer);
|
||||
#endif
|
||||
#if defined(VERSION_EU)
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount++], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*dmaIndexRef = dmaIndex;
|
||||
return (devAddr - dmaDevAddr) + dma->buffer;
|
||||
#else
|
||||
gCurrAudioFrameDmaCount++;
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount - 1], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*dmaIndexRef = dmaIndex;
|
||||
return dma->buffer + (devAddr - dmaDevAddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -526,8 +503,6 @@ void patch_audio_bank(struct AudioBank *mem, u8 *offset, u32 numInstruments, u32
|
||||
}
|
||||
|
||||
struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
u32 buf[4];
|
||||
|
||||
// (This is broken if the length is 1 (mod 16), but that never happens --
|
||||
// it's always divisible by 4.)
|
||||
s32 alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||
@@ -539,9 +514,9 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, buf, 0x10);
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[1];
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, dmaTempBuffer, 0x10);
|
||||
u32 numInstruments = dmaTempBuffer[0];
|
||||
u32 numDrums = dmaTempBuffer[1];
|
||||
audio_dma_copy_immediate((uintptr_t)(ctlData + 0x10), ret, alloc);
|
||||
patch_audio_bank(ret, gAlTbl->seqArray[bankId].offset, numInstruments, numDrums);
|
||||
gCtlEntries[bankId].numInstruments = (u8) numInstruments;
|
||||
@@ -553,8 +528,6 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
}
|
||||
|
||||
struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *seqPlayer) {
|
||||
u32 buf[4];
|
||||
|
||||
size_t alloc = gAlCtlHeader->seqArray[bankId].len + 0xf;
|
||||
alloc = ALIGN16(alloc);
|
||||
alloc -= 0x10;
|
||||
@@ -564,9 +537,9 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, buf, 0x10);
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[1];
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, dmaTempBuffer, 0x10);
|
||||
u32 numInstruments = dmaTempBuffer[0];
|
||||
u32 numDrums = dmaTempBuffer[1];
|
||||
seqPlayer->loadingBankId = (u8) bankId;
|
||||
#if defined(VERSION_EU)
|
||||
gCtlEntries[bankId].numInstruments = numInstruments;
|
||||
@@ -830,11 +803,8 @@ void load_sequence_internal(u32 player, u32 seqId, s32 loadAsync) {
|
||||
|
||||
// (void) must be omitted from parameters to fix stack with -framepointer
|
||||
void audio_init() {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US) || defined(VERSION_EU)
|
||||
u8 buf[0x10];
|
||||
#endif
|
||||
s32 i, /*j,*/ k;
|
||||
UNUSED u32 size;
|
||||
u32 size;
|
||||
void *data;
|
||||
|
||||
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||
@@ -909,10 +879,6 @@ void audio_init() {
|
||||
bzero(&gAiBuffers, sizeof(gAiBuffers));
|
||||
for (i = 0; i < NUMAIBUFFERS; i++) {
|
||||
gAiBuffers[i] = soundAlloc(&gAudioInitPool, AIBUFFER_LEN);
|
||||
|
||||
/*for (j = 0; j < (s32) (AIBUFFER_LEN / sizeof(s16)); j++) {
|
||||
gAiBuffers[i][j] = 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
#if defined(VERSION_EU)
|
||||
@@ -929,7 +895,7 @@ void audio_init() {
|
||||
eu_stubbed_printf_0("Main Heap Initialize.\n");
|
||||
|
||||
// Load headers for sounds and sequences
|
||||
gSeqFileHeader = (ALSeqFile *) buf;
|
||||
gSeqFileHeader = (ALSeqFile *) dmaTempBuffer;
|
||||
data = gMusicData;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, 0x10);
|
||||
gSequenceCount = gSeqFileHeader->seqCount;
|
||||
@@ -940,7 +906,7 @@ void audio_init() {
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
|
||||
// Load header for CTL (instrument metadata)
|
||||
gAlCtlHeader = (ALSeqFile *) buf;
|
||||
gAlCtlHeader = (ALSeqFile *) dmaTempBuffer;
|
||||
data = gSoundDataADSR;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gAlCtlHeader, 0x10);
|
||||
size = gAlCtlHeader->seqCount * sizeof(ALSeqData) + 4;
|
||||
@@ -951,7 +917,7 @@ void audio_init() {
|
||||
alSeqFileNew(gAlCtlHeader, data);
|
||||
|
||||
// Load header for TBL (raw sound data)
|
||||
gAlTbl = (ALSeqFile *) buf;
|
||||
gAlTbl = (ALSeqFile *) dmaTempBuffer;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gAlTbl, 0x10);
|
||||
size = gAlTbl->seqCount * sizeof(ALSeqData) + 4;
|
||||
size = ALIGN16(size);
|
||||
|
||||
@@ -412,4 +412,4 @@ make_huftable8:
|
||||
jr ra
|
||||
nop /*(Delay Slot) */
|
||||
|
||||
.end
|
||||
.end Propack_UnpackM1
|
||||
|
||||
@@ -663,11 +663,11 @@ unpack11:
|
||||
jr ra
|
||||
nop
|
||||
|
||||
.data
|
||||
.end Propack_UnpackM2
|
||||
|
||||
.data
|
||||
.align 4
|
||||
|
||||
.word 0,0,0,0,0,0,0,0,0,0,0,0
|
||||
mystack:
|
||||
.word 0
|
||||
|
||||
.end
|
||||
|
||||
@@ -20,14 +20,8 @@ ALIGNED8 u8 gThread5Stack[0x2000];
|
||||
ALIGNED8 u8 gThread6Stack[0x2000];
|
||||
#endif
|
||||
// 0x400 bytes
|
||||
#if UNF
|
||||
ALIGNED16 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
ALIGNED16 u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
#else
|
||||
// 0xc00 bytes for f3dex, 0x900 otherwise
|
||||
ALIGNED8 u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
ALIGNED8 u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
#endif // UNF
|
||||
__attribute__((aligned(32))) u8 gGfxSPTaskStack[SP_DRAM_STACK_SIZE8];
|
||||
__attribute__((aligned(32))) u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
// 0x200 bytes
|
||||
struct SaveBuffer __attribute__ ((aligned (8))) gSaveBuffer;
|
||||
// 0x190a0 bytes
|
||||
|
||||
@@ -28,7 +28,7 @@ Vec3s gVec3sOne = { 1, 1, 1 };
|
||||
static u16 gRandomSeed16;
|
||||
|
||||
// Generate a pseudorandom integer from 0 to 65535 from the random seed, and update the seed.
|
||||
u32 random_u16(void) {
|
||||
u16 random_u16(void) {
|
||||
if (gRandomSeed16 == 22026) {
|
||||
gRandomSeed16 = 0;
|
||||
}
|
||||
@@ -503,7 +503,7 @@ void mtxf_rotate_xyz_and_translate_and_mul(Vec3s rot, Vec3f trans, Mat4 dest, Ma
|
||||
* at the position 'to'. The up-vector is assumed to be (0, 1, 0), but the 'roll'
|
||||
* angle allows a bank rotation of the camera.
|
||||
*/
|
||||
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s32 roll) {
|
||||
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) {
|
||||
Vec3f colX, colY, colZ;
|
||||
register f32 dx = (to[0] - from[0]);
|
||||
register f32 dz = (to[2] - from[2]);
|
||||
@@ -543,7 +543,7 @@ void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s32 roll) {
|
||||
* 'scale' is the scale of the object.
|
||||
* 'angle' rotates the object while still facing the camera.
|
||||
*/
|
||||
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle) {
|
||||
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s16 angle) {
|
||||
register s32 i;
|
||||
register f32 sx = scale[0];
|
||||
register f32 sy = scale[1];
|
||||
@@ -592,7 +592,7 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle)
|
||||
* 'scale' is the scale of the shadow
|
||||
* 'yaw' is the angle which it should face
|
||||
*/
|
||||
void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s32 yaw) {
|
||||
void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s16 yaw) {
|
||||
Vec3f lateralDir;
|
||||
Vec3f leftDir;
|
||||
Vec3f forwardDir;
|
||||
@@ -621,7 +621,7 @@ void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s32 y
|
||||
* 'yaw' is the angle which it should face
|
||||
* 'pos' is the object's position in the world
|
||||
*/
|
||||
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s32 yaw) {
|
||||
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) {
|
||||
Vec3f lateralDir;
|
||||
Vec3f leftDir;
|
||||
Vec3f forwardDir;
|
||||
@@ -646,7 +646,7 @@ void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s32 yaw) {
|
||||
* 'pos' is the object's position in the world
|
||||
* 'radius' is the distance from each triangle vertex to the center
|
||||
*/
|
||||
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s32 yaw, f32 radius) {
|
||||
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
|
||||
struct Surface *floor;
|
||||
Vec3f point0, point1, point2;
|
||||
Vec3f forward;
|
||||
@@ -765,7 +765,7 @@ UNUSED void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
|
||||
#define MATENTRY(a, b) \
|
||||
((s16 *) mtx)[a ] = (((s32) b) >> 16); \
|
||||
((s16 *) mtx)[a + 16] = (((s32) b) & 0xFFFF);
|
||||
void mtxf_rotate_xy(Mtx *mtx, s32 angle) {
|
||||
void mtxf_rotate_xy(Mtx *mtx, s16 angle) {
|
||||
register s32 i = (coss(angle) * 0x10000);
|
||||
register s32 j = (sins(angle) * 0x10000);
|
||||
register f32 *temp = (f32 *)mtx;
|
||||
@@ -880,7 +880,7 @@ void vec3f_get_angle(Vec3f from, Vec3f to, s16 *pitch, s16 *yaw) {
|
||||
}
|
||||
|
||||
/// Finds the horizontal distance and pitch between two vectors.
|
||||
void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch) {
|
||||
void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch) {
|
||||
Vec3f d;
|
||||
vec3_diff(d, to, from);
|
||||
*lateralDist = sqrtf(sqr(d[0]) + sqr(d[2]));
|
||||
@@ -888,7 +888,7 @@ void vec3f_get_lateral_dist_and_pitch(Vec3f from, Vec3f to, f32 *lateralDist, An
|
||||
}
|
||||
|
||||
/// Finds the horizontal distance and yaw between two vectors.
|
||||
void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, Angle *yaw) {
|
||||
void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, s16 *yaw) {
|
||||
register f32 dx = (to[0] - from[0]);
|
||||
register f32 dz = (to[2] - from[2]);
|
||||
*lateralDist = sqrtf(sqr(dx) + sqr(dz));
|
||||
@@ -896,7 +896,7 @@ void vec3f_get_lateral_dist_and_yaw(Vec3f from, Vec3f to, f32 *lateralDist, Angl
|
||||
}
|
||||
|
||||
/// Finds the horizontal distance and angles between two vectors.
|
||||
void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch, Angle *yaw) {
|
||||
void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch, s16 *yaw) {
|
||||
Vec3f d;
|
||||
vec3_diff(d, to, from);
|
||||
*lateralDist = sqrtf(sqr(d[0]) + sqr(d[2]));
|
||||
@@ -905,7 +905,7 @@ void vec3f_get_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *lateralDist, An
|
||||
}
|
||||
|
||||
/// Finds the distance and angles between two vectors.
|
||||
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Angle *yaw) {
|
||||
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw) {
|
||||
Vec3f d;
|
||||
vec3_diff(d, to, from);
|
||||
register f32 xz = (sqr(d[0]) + sqr(d[2]));
|
||||
@@ -913,7 +913,7 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Ang
|
||||
*pitch = atan2s(sqrtf(xz), d[1]);
|
||||
*yaw = atan2s(d[2], d[0]);
|
||||
}
|
||||
void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Angle *yaw) {
|
||||
void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, s16 *pitch, s16 *yaw) {
|
||||
Vec3s d;
|
||||
vec3_diff(d, to, from);
|
||||
register f32 xz = (sqr(d[0]) + sqr(d[2]));
|
||||
@@ -921,7 +921,7 @@ void vec3s_get_dist_and_angle(Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Ang
|
||||
*pitch = atan2s(sqrtf(xz), d[1]);
|
||||
*yaw = atan2s(d[2], d[0]);
|
||||
}
|
||||
void vec3f_to_vec3s_get_dist_and_angle(Vec3f from, Vec3s to, f32 *dist, Angle *pitch, Angle *yaw) {
|
||||
void vec3f_to_vec3s_get_dist_and_angle(Vec3f from, Vec3s to, f32 *dist, s16 *pitch, s16 *yaw) {
|
||||
Vec3f d;
|
||||
vec3_diff(d, to, from);
|
||||
register f32 xz = (sqr(d[0]) + sqr(d[2]));
|
||||
@@ -931,7 +931,7 @@ void vec3f_to_vec3s_get_dist_and_angle(Vec3f from, Vec3s to, f32 *dist, Angle *p
|
||||
}
|
||||
|
||||
/// Finds the distance, horizontal distance, and angles between two vectors.
|
||||
void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, Angle *pitch, Angle *yaw) {
|
||||
void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, s16 *pitch, s16 *yaw) {
|
||||
Vec3f d;
|
||||
vec3_diff(d, to, from);
|
||||
register f32 xz = (sqr(d[0]) + sqr(d[2]));
|
||||
@@ -951,17 +951,17 @@ void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist,
|
||||
to[1] = (from[1] + (dist * sins(pitch))); \
|
||||
to[2] = (from[2] + (dcos * coss(yaw ))); \
|
||||
}
|
||||
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, Angle32 pitch, Angle32 yaw) {
|
||||
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw) {
|
||||
vec3_set_dist_and_angle(from, to, dist, pitch, yaw);
|
||||
}
|
||||
void vec3s_set_dist_and_angle(Vec3s from, Vec3s to, s16 dist, Angle32 pitch, Angle32 yaw) {
|
||||
void vec3s_set_dist_and_angle(Vec3s from, Vec3s to, s16 dist, s16 pitch, s16 yaw) {
|
||||
vec3_set_dist_and_angle(from, to, dist, pitch, yaw);
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to approach_s32, but converts to s16 and allows for overflow between 32767 and -32768
|
||||
*/
|
||||
s32 approach_angle(s32 current, s32 target, s32 inc) {
|
||||
s16 approach_angle(s16 current, s16 target, s16 inc) {
|
||||
s32 dist = (s16)(target - current);
|
||||
if (dist < 0) {
|
||||
dist += inc;
|
||||
@@ -972,21 +972,21 @@ s32 approach_angle(s32 current, s32 target, s32 inc) {
|
||||
}
|
||||
return (target - dist);
|
||||
}
|
||||
Bool32 approach_angle_bool(s16 *current, s32 target, s32 inc) {
|
||||
Bool32 approach_angle_bool(s16 *current, s16 target, s16 inc) {
|
||||
*current = approach_angle(*current, target, inc);
|
||||
return (*current != target);
|
||||
}
|
||||
|
||||
s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec) {
|
||||
s16 approach_s16(s16 current, s16 target, s16 inc, s16 dec) {
|
||||
s16 dist = (target - current);
|
||||
if (dist >= 0) { // target >= current
|
||||
current = ((dist > inc) ? (current + inc) : target);
|
||||
} else { // target < current
|
||||
current = ((dist < -dec) ? (current - dec) : target);
|
||||
}
|
||||
return (s16)current;
|
||||
return current;
|
||||
}
|
||||
Bool32 approach_s16_bool(s16 *current, s32 target, s32 inc, s32 dec) {
|
||||
Bool32 approach_s16_bool(s16 *current, s16 target, s16 inc, s16 dec) {
|
||||
*current = approach_s16(*current, target, inc, dec);
|
||||
return (*current != target);
|
||||
}
|
||||
@@ -1067,7 +1067,7 @@ f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier) {
|
||||
* is reached. Note: Since this function takes integers as parameters, the last argument is the
|
||||
* reciprocal of what it would be in the previous two functions.
|
||||
*/
|
||||
s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) {
|
||||
s16 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) {
|
||||
s16 temp = *current;
|
||||
if (divisor == 0) {
|
||||
*current = target;
|
||||
@@ -1084,7 +1084,7 @@ s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor) {
|
||||
* Approaches an s16 value in the same fashion as approach_f32_asymptotic, returns the new value.
|
||||
* Note: last parameter is the reciprocal of what it would be in the f32 functions
|
||||
*/
|
||||
s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) {
|
||||
s16 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) {
|
||||
s16 temp = current;
|
||||
if (divisor == 0) {
|
||||
current = target;
|
||||
@@ -1097,7 +1097,7 @@ s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor) {
|
||||
return current;
|
||||
}
|
||||
|
||||
s32 abs_angle_diff(s16 a0, s16 a1) {
|
||||
s16 abs_angle_diff(s16 a0, s16 a1) {
|
||||
register s16 diff = (a1 - a0);
|
||||
if (diff == -0x8000) return 0x7FFF;
|
||||
return abss(diff);
|
||||
@@ -1107,7 +1107,7 @@ s32 abs_angle_diff(s16 a0, s16 a1) {
|
||||
* Helper function for atan2s. Does a look up of the arctangent of y/x assuming
|
||||
* the resulting angle is in range [0, 0x2000] (1/8 of a circle).
|
||||
*/
|
||||
static u32 atan2_lookup(f32 y, f32 x) {
|
||||
static u16 atan2_lookup(f32 y, f32 x) {
|
||||
return x == 0
|
||||
? 0x0
|
||||
: atans(y / x);
|
||||
@@ -1117,7 +1117,7 @@ static u32 atan2_lookup(f32 y, f32 x) {
|
||||
* Compute the angle from (0, 0) to (x, y) as a s16. Given that terrain is in
|
||||
* the xz-plane, this is commonly called with (z, x) to get a yaw angle.
|
||||
*/
|
||||
s32 atan2s(f32 y, f32 x) {
|
||||
s16 atan2s(f32 y, f32 x) {
|
||||
u16 ret;
|
||||
if (x >= 0) {
|
||||
if (y >= 0) {
|
||||
|
||||
@@ -54,12 +54,12 @@ extern f32 gSineTable[];
|
||||
#define RAD_PER_DEG (M_PI / 180.0f)
|
||||
#define DEG_PER_RAD (180.0f / M_PI)
|
||||
|
||||
#define angle_to_degrees( x) (f32)(((Angle)(x) / 65536.0f) * 360.0f)
|
||||
#define degrees_to_angle( x) (Angle)(((f32)(x) * 0x10000 ) / 360 )
|
||||
#define angle_to_radians( x) (f32)(((Angle)(x) * M_PI ) / 0x8000)
|
||||
#define radians_to_angle( x) (Angle)(((f32)(x) / M_PI ) * 0x8000)
|
||||
#define degrees_to_radians(x) (f32)( (f32)(x) * RAD_PER_DEG )
|
||||
#define radians_to_degrees(x) (f32)( (f32)(x) * DEG_PER_RAD )
|
||||
#define angle_to_degrees( x) (f32)(((s16)(x) / 65536.0f) * 360.0f)
|
||||
#define degrees_to_angle( x) (s16)(((f32)(x) * 0x10000 ) / 360 )
|
||||
#define angle_to_radians( x) (f32)(((s16)(x) * M_PI ) / 0x8000)
|
||||
#define radians_to_angle( x) (s16)(((f32)(x) / M_PI ) * 0x8000)
|
||||
#define degrees_to_radians(x) (f32)( (f32)(x) * RAD_PER_DEG )
|
||||
#define radians_to_degrees(x) (f32)( (f32)(x) * DEG_PER_RAD )
|
||||
|
||||
#define signum_positive(x) ((x < 0) ? -1 : 1)
|
||||
|
||||
@@ -475,7 +475,7 @@ ALWAYS_INLINE s32 absi(s32 in) {
|
||||
|
||||
#define FLT_IS_NONZERO(x) (absf(x) > NEAR_ZERO)
|
||||
|
||||
u32 random_u16(void);
|
||||
u16 random_u16(void);
|
||||
f32 random_float(void);
|
||||
s32 random_sign(void);
|
||||
|
||||
@@ -538,15 +538,15 @@ void vec3f_normalize(Vec3f dest);
|
||||
void mtxf_copy(Mat4 dest, Mat4 src);
|
||||
void mtxf_identity(Mat4 mtx);
|
||||
void mtxf_translate(Mat4 dest, Vec3f b);
|
||||
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s32 roll);
|
||||
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll);
|
||||
void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f trans, Vec3s rot);
|
||||
void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f trans, Vec3s rot);
|
||||
void mtxf_rotate_zxy_and_translate_and_mul(Vec3s rot, Vec3f trans, Mat4 dest, Mat4 src);
|
||||
void mtxf_rotate_xyz_and_translate_and_mul(Vec3s rot, Vec3f trans, Mat4 dest, Mat4 src);
|
||||
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s32 angle);
|
||||
void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s32 yaw);
|
||||
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s32 yaw);
|
||||
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s32 yaw, f32 radius);
|
||||
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, Vec3f scale, s16 angle);
|
||||
void mtxf_shadow(Mat4 dest, Mat4 src, Vec3f upDir, Vec3f pos, Vec3f scale, s16 yaw);
|
||||
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw);
|
||||
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius);
|
||||
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b);
|
||||
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s);
|
||||
void mtxf_mul_vec3s(Mat4 mtx, Vec3s b);
|
||||
@@ -557,37 +557,37 @@ ALWAYS_INLINE void mtxf_to_mtx(register void *dest, register void *src) {
|
||||
// guMtxF2L(src, dest);
|
||||
}
|
||||
|
||||
void mtxf_rotate_xy(Mtx *mtx, s32 angle);
|
||||
void mtxf_rotate_xy(Mtx *mtx, s16 angle);
|
||||
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v);
|
||||
void linear_mtxf_mul_vec3f_and_translate(Mat4 m, Vec3f dst, Vec3f v);
|
||||
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v);
|
||||
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
|
||||
|
||||
void vec2f_get_lateral_dist( Vec2f from, Vec2f to, f32 *lateralDist );
|
||||
void vec3f_get_lateral_dist( Vec3f from, Vec3f to, f32 *lateralDist );
|
||||
void vec3f_get_lateral_dist_squared( Vec3f from, Vec3f to, f32 *lateralDist );
|
||||
void vec3f_get_dist( Vec3f from, Vec3f to, f32 *dist );
|
||||
void vec3f_get_dist_squared( Vec3f from, Vec3f to, f32 *dist );
|
||||
void vec3f_get_dist_and_yaw( Vec3f from, Vec3f to, f32 *dist, Angle *yaw);
|
||||
void vec3f_get_pitch( Vec3f from, Vec3f to, Angle *pitch );
|
||||
void vec3f_get_yaw( Vec3f from, Vec3f to, Angle *yaw);
|
||||
void vec3f_get_angle( Vec3f from, Vec3f to, Angle *pitch, Angle *yaw);
|
||||
void vec3f_get_lateral_dist_and_pitch( Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch );
|
||||
void vec3f_get_lateral_dist_and_yaw( Vec3f from, Vec3f to, f32 *lateralDist, Angle *yaw);
|
||||
void vec3f_get_lateral_dist_and_angle( Vec3f from, Vec3f to, f32 *lateralDist, Angle *pitch, Angle *yaw);
|
||||
void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, Angle *pitch, Angle *yaw);
|
||||
void vec3f_get_dist_and_angle( Vec3f from, Vec3f to, f32 *dist, Angle *pitch, Angle *yaw);
|
||||
void vec3s_get_dist_and_angle( Vec3s from, Vec3s to, s16 *dist, Angle *pitch, Angle *yaw);
|
||||
void vec3f_to_vec3s_get_dist_and_angle( Vec3f from, Vec3s to, f32 *dist, Angle *pitch, Angle *yaw);
|
||||
void vec3s_set_dist_and_angle( Vec3s from, Vec3s to, s16 dist, Angle32 pitch, Angle32 yaw);
|
||||
void vec3f_set_dist_and_angle( Vec3f from, Vec3f to, f32 dist, Angle32 pitch, Angle32 yaw);
|
||||
void vec2f_get_lateral_dist( Vec2f from, Vec2f to, f32 *lateralDist );
|
||||
void vec3f_get_lateral_dist( Vec3f from, Vec3f to, f32 *lateralDist );
|
||||
void vec3f_get_lateral_dist_squared( Vec3f from, Vec3f to, f32 *lateralDist );
|
||||
void vec3f_get_dist( Vec3f from, Vec3f to, f32 *dist );
|
||||
void vec3f_get_dist_squared( Vec3f from, Vec3f to, f32 *dist );
|
||||
void vec3f_get_dist_and_yaw( Vec3f from, Vec3f to, f32 *dist, s16 *yaw);
|
||||
void vec3f_get_pitch( Vec3f from, Vec3f to, s16 *pitch );
|
||||
void vec3f_get_yaw( Vec3f from, Vec3f to, s16 *yaw);
|
||||
void vec3f_get_angle( Vec3f from, Vec3f to, s16 *pitch, s16 *yaw);
|
||||
void vec3f_get_lateral_dist_and_pitch( Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch );
|
||||
void vec3f_get_lateral_dist_and_yaw( Vec3f from, Vec3f to, f32 *lateralDist, s16 *yaw);
|
||||
void vec3f_get_lateral_dist_and_angle( Vec3f from, Vec3f to, f32 *lateralDist, s16 *pitch, s16 *yaw);
|
||||
void vec3f_get_dist_and_lateral_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, f32 *lateralDist, s16 *pitch, s16 *yaw);
|
||||
void vec3f_get_dist_and_angle( Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw);
|
||||
void vec3s_get_dist_and_angle( Vec3s from, Vec3s to, s16 *dist, s16 *pitch, s16 *yaw);
|
||||
void vec3f_to_vec3s_get_dist_and_angle( Vec3f from, Vec3s to, f32 *dist, s16 *pitch, s16 *yaw);
|
||||
void vec3s_set_dist_and_angle( Vec3s from, Vec3s to, s16 dist, s16 pitch, s16 yaw);
|
||||
void vec3f_set_dist_and_angle( Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw);
|
||||
|
||||
s32 approach_angle(s32 current, s32 target, s32 inc);
|
||||
s32 approach_s16(s32 current, s32 target, s32 inc, s32 dec);
|
||||
s16 approach_angle(s16 current, s16 target, s16 inc);
|
||||
s16 approach_s16(s16 current, s16 target, s16 inc, s16 dec);
|
||||
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);
|
||||
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
|
||||
Bool32 approach_angle_bool(s16 *current, s32 target, s32 inc);
|
||||
Bool32 approach_s16_bool(s16 *current, s32 target, s32 inc, s32 dec);
|
||||
Bool32 approach_angle_bool(s16 *current, s16 target, s16 inc);
|
||||
Bool32 approach_s16_bool(s16 *current, s16 target, s16 inc, s16 dec);
|
||||
Bool32 approach_s32_bool(s32 *current, s32 target, s32 inc, s32 dec);
|
||||
Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec);
|
||||
#define approach_s16_symmetric(current, target, inc) approach_s16((current), (target), (inc), (inc))
|
||||
@@ -599,10 +599,10 @@ Bool32 approach_f32_bool(f32 *current, f32 target, f32 inc, f32 dec);
|
||||
s32 approach_f32_signed(f32 *current, f32 target, f32 inc);
|
||||
s32 approach_f32_asymptotic_bool(f32 *current, f32 target, f32 multiplier);
|
||||
f32 approach_f32_asymptotic(f32 current, f32 target, f32 multiplier);
|
||||
s32 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor);
|
||||
s32 approach_s16_asymptotic(s16 current, s16 target, s16 divisor);
|
||||
s32 abs_angle_diff(s16 a0, s16 a1);
|
||||
s32 atan2s(f32 y, f32 x);
|
||||
s16 approach_s16_asymptotic_bool(s16 *current, s16 target, s16 divisor);
|
||||
s16 approach_s16_asymptotic(s16 current, s16 target, s16 divisor);
|
||||
s16 abs_angle_diff(s16 a0, s16 a1);
|
||||
s16 atan2s(f32 y, f32 x);
|
||||
f32 atan2f(f32 a, f32 b);
|
||||
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);
|
||||
void anim_spline_init(Vec4s *keyFrames);
|
||||
|
||||
@@ -429,7 +429,7 @@ static struct Surface *find_floor_from_list(struct SurfaceNode *surfaceNode, s32
|
||||
height = get_surface_height_at_location(x, z, surf);
|
||||
|
||||
// Exclude floors lower than the previous highest floor.
|
||||
if (height < *pheight) continue;
|
||||
if (height <= *pheight) continue;
|
||||
|
||||
// Checks for floor interaction with a FIND_FLOOR_BUFFER unit buffer.
|
||||
if (bufferY < height) continue;
|
||||
@@ -704,7 +704,7 @@ s32 find_water_level(s32 x, s32 z) { // TODO: Allow y pos
|
||||
|
||||
// If the location is within a water box and it is a water box.
|
||||
// Water is less than 50 val only, while above is gas and such.
|
||||
if (loX < x && x < hiX && loZ < z && z < hiZ && val < 50) {
|
||||
if (loX <= x && x <= hiX && loZ <= z && z <= hiZ && val < 50) {
|
||||
// Set the water height. Since this breaks, only return the first height.
|
||||
waterLevel = *p;
|
||||
break;
|
||||
|
||||
@@ -178,7 +178,7 @@ static void boo_set_move_yaw_for_during_hit(s32 hurt) {
|
||||
}
|
||||
|
||||
// Boo Roll
|
||||
static Angle sBooHitRotations[] = {
|
||||
static s16 sBooHitRotations[] = {
|
||||
0x179F, 0x1620, 0x14AC, 0x1346,
|
||||
0x11EB, 0x109E, 0x0B75, 0x0E28,
|
||||
0x0D01, 0x0BE6, 0x0AD7, 0x09D5,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user