You've already forked HackerSM64
mirror of
https://github.com/HackerN64/HackerSM64.git
synced 2026-01-21 10:35:32 -08:00
Compare commits
1 Commits
v2.0.3
...
develop/2.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3cc4f908cc |
2128
.gitignore
vendored
2128
.gitignore
vendored
File diff suppressed because it is too large
Load Diff
3
Makefile
3
Makefile
@@ -630,8 +630,7 @@ $(BUILD_DIR)/src/usb/usb.o: CFLAGS += -Wno-unused-variable -Wno-sign-compare -Wn
|
||||
$(BUILD_DIR)/src/usb/debug.o: OPT_FLAGS := -O0
|
||||
$(BUILD_DIR)/src/usb/debug.o: CFLAGS += -Wno-unused-parameter -Wno-maybe-uninitialized
|
||||
# File specific opt flags
|
||||
$(BUILD_DIR)/src/audio/heap.o: OPT_FLAGS := -Os -fno-jump-tables
|
||||
$(BUILD_DIR)/src/audio/synthesis.o: OPT_FLAGS := -Os -fno-jump-tables
|
||||
$(BUILD_DIR)/src/audio/*.o: OPT_FLAGS := -Os -fno-jump-tables
|
||||
|
||||
$(BUILD_DIR)/src/engine/surface_collision.o: OPT_FLAGS := $(COLLISION_OPT_FLAGS)
|
||||
$(BUILD_DIR)/src/engine/math_util.o: OPT_FLAGS := $(MATH_UTIL_OPT_FLAGS)
|
||||
|
||||
@@ -34,7 +34,7 @@ This is a fork of the ultrasm64 repo by CrashOveride which includes the followin
|
||||
Thanks to Frame#5375 and AloXado320 for also helping with silhouette stuff
|
||||
|
||||
**Lighting Engine by Wiseguy**
|
||||
- Lighting Engine is available on a separate branch ([base/lighting-engine](https://github.com/Reonu/HackerSM64/tree/base/lighting-engine)). Instructions on how to use it are in the readme of that branch.
|
||||
- Lighting Engine is available on a separate branch ([base/lighting-engine-wip](https://github.com/Reonu/HackerSM64/tree/base/lighting-engine-wip)). Instructions on how to use it are in the readme of that branch.
|
||||
- Alternatively, the main repo has `Puppylights` available, which is a more lightweight, but limited lighting library intended to be used to modify existing light properties. You can look at `puppylights.c` to find out how to use it.
|
||||
|
||||
**Puppycam**
|
||||
|
||||
@@ -1 +1 @@
|
||||
v2.0.3
|
||||
v2.0.1
|
||||
|
||||
@@ -10,10 +10,6 @@
|
||||
// Disables all debug options (except PUPPYPRINT).
|
||||
#define DISABLE_ALL
|
||||
|
||||
// Enables a comprehensive standalone profiler. Automatically enabled by PUPPYPRINT_DEBUG.
|
||||
// If not using PUPPYPRINT_DEBUG, press L to toggle the profiler.
|
||||
// #define USE_PROFILER
|
||||
|
||||
// TEST LEVEL
|
||||
// Uncomment this define and set a test level in order to boot straight into said level.
|
||||
// This allows you to quickly test the level you're working on.
|
||||
|
||||
@@ -40,8 +40,9 @@
|
||||
|
||||
// -- WATER RING --
|
||||
|
||||
// Fix the water rings in DDD by checking for interaction rather than normals.
|
||||
#define FIX_WATER_RINGS
|
||||
// Fix DDD water rings by checking for interaction rather than normals.
|
||||
//! NOT IMPLEMENTED
|
||||
// #define FIX_WATER_RINGS
|
||||
|
||||
// -- POWER STAR --
|
||||
|
||||
|
||||
@@ -33,21 +33,15 @@
|
||||
* config_debug.h
|
||||
*/
|
||||
|
||||
#ifdef DISABLE_ALL
|
||||
#undef DEBUG_ALL
|
||||
#undef TEST_LEVEL
|
||||
#undef DEBUG_LEVEL_SELECT
|
||||
#undef ENABLE_DEBUG_FREE_MOVE
|
||||
#undef VANILLA_DEBUG
|
||||
#undef VANILLA_STYLE_CUSTOM_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG_CYCLES
|
||||
#undef VISUAL_DEBUG
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT
|
||||
#define PUPPYPRINT
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
|
||||
#ifdef COMPLETE_SAVE_FILE
|
||||
#undef UNLOCK_ALL
|
||||
#undef COMPLETE_SAVE_FILE
|
||||
#undef DEBUG_FORCE_CRASH_ON_BOOT
|
||||
#undef USE_PROFILER
|
||||
#endif // DISABLE_ALL
|
||||
#define UNLOCK_ALL
|
||||
#endif // COMPLETE_SAVE_FILE
|
||||
|
||||
#ifdef DEBUG_ALL
|
||||
#undef DEBUG_LEVEL_SELECT
|
||||
@@ -72,17 +66,20 @@
|
||||
#define COMPLETE_SAVE_FILE
|
||||
#endif // DEBUG_ALL
|
||||
|
||||
#ifdef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT
|
||||
#define PUPPYPRINT
|
||||
#undef USE_PROFILER
|
||||
#define USE_PROFILER
|
||||
#endif // PUPPYPRINT_DEBUG
|
||||
|
||||
#ifdef COMPLETE_SAVE_FILE
|
||||
#ifdef DISABLE_ALL
|
||||
#undef DEBUG_ALL
|
||||
#undef TEST_LEVEL
|
||||
#undef DEBUG_LEVEL_SELECT
|
||||
#undef ENABLE_DEBUG_FREE_MOVE
|
||||
#undef VANILLA_DEBUG
|
||||
#undef VANILLA_STYLE_CUSTOM_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG
|
||||
#undef PUPPYPRINT_DEBUG_CYCLES
|
||||
#undef VISUAL_DEBUG
|
||||
#undef UNLOCK_ALL
|
||||
#define UNLOCK_ALL
|
||||
#endif // COMPLETE_SAVE_FILE
|
||||
#undef COMPLETE_SAVE_FILE
|
||||
#undef DEBUG_FORCE_CRASH_ON_BOOT
|
||||
#endif // DISABLE_ALL
|
||||
|
||||
|
||||
/*****************
|
||||
|
||||
@@ -973,7 +973,11 @@
|
||||
#define /*0x104*/ oSnufitBodyScalePeriod OBJECT_FIELD_S32(0x1F)
|
||||
#define /*0x108*/ oSnufitBodyBaseScale OBJECT_FIELD_S32(0x20)
|
||||
#define /*0x10C*/ oSnufitBullets OBJECT_FIELD_S32(0x21)
|
||||
#define /*0x1AC*/ oSnufitBodyScale OBJECT_FIELD_S16(0x49, 0)
|
||||
#define /*0x1AC*/ oSnufitOffsetVec OBJECT_FIELD_S16(0x49, 0) // start pos of s16 vec
|
||||
#define /*0x1AC*/ oSnufitXOffset OBJECT_FIELD_S16(0x49, 0)
|
||||
#define /*0x1AE*/ oSnufitYOffset OBJECT_FIELD_S16(0x49, 1)
|
||||
#define /*0x1B0*/ oSnufitZOffset OBJECT_FIELD_S16(0x4A, 0)
|
||||
#define /*0x1B2*/ oSnufitBodyScale OBJECT_FIELD_S16(0x4A, 1)
|
||||
|
||||
/* Spindel */
|
||||
#define /*0x0F4*/ oSpindelMoveTimer OBJECT_FIELD_S32(0x1B)
|
||||
@@ -1043,6 +1047,7 @@
|
||||
#define /*0x0F4*/ oTiltingPyramidNormalX OBJECT_FIELD_F32(O_TILTING_PYRAMID_NORMAL_X_INDEX)
|
||||
#define /*0x0F8*/ oTiltingPyramidNormalY OBJECT_FIELD_F32(O_TILTING_PYRAMID_NORMAL_Y_INDEX)
|
||||
#define /*0x0FC*/ oTiltingPyramidNormalZ OBJECT_FIELD_F32(O_TILTING_PYRAMID_NORMAL_Z_INDEX)
|
||||
#define /*0x10C*/ oTiltingPyramidMarioOnPlatform OBJECT_FIELD_S32(0x21)
|
||||
|
||||
/* Toad Message */
|
||||
#define /*0x108*/ oToadMessageDialogId OBJECT_FIELD_U32(0x20)
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
#ifdef VERSION_EU
|
||||
#include "levels/ending/cake_eu.inc.c"
|
||||
|
||||
#ifndef EU_CUSTOM_CAKE_FIX
|
||||
// 0x07023000 - 0x07023FFF
|
||||
ALIGNED8 static const Texture cake_end_texture_eu_35_thank_you[] = {
|
||||
#include "levels/ending/eu_023000.rgba16.inc.c"
|
||||
@@ -39,7 +38,6 @@ ALIGNED8 static const Texture cake_end_texture_eu_39_fin[] = {
|
||||
ALIGNED8 static const Texture cake_end_texture_eu_40_ende[] = {
|
||||
#include "levels/ending/eu_028000.rgba16.inc.c"
|
||||
};
|
||||
#endif // !EU_CUSTOM_CAKE_FIX
|
||||
|
||||
// 0x07029000 - 0x070296D8
|
||||
const Gfx dl_cake_end_screen[] = {
|
||||
|
||||
@@ -72,11 +72,11 @@ const GeoLayout intro_geo_mario_head_regular[] = {
|
||||
GEO_CLOSE_NODE(),
|
||||
#endif
|
||||
GEO_CLOSE_NODE(),
|
||||
#if defined(ENABLE_RUMBLE)
|
||||
GEO_ZBUFFER(0),
|
||||
GEO_OPEN_NODE(),
|
||||
GEO_ASM(INTRO_CONTEXT_NORMAL, geo_intro_rumble_pak_graphic),
|
||||
GEO_CLOSE_NODE(),
|
||||
#if defined(VERSION_SH)
|
||||
GEO_ZBUFFER(0),
|
||||
GEO_OPEN_NODE(),
|
||||
GEO_ASM(INTRO_CONTEXT_NORMAL, geo_intro_rumble_pak_graphic),
|
||||
GEO_CLOSE_NODE(),
|
||||
#endif
|
||||
GEO_CLOSE_NODE(),
|
||||
GEO_END(),
|
||||
@@ -105,7 +105,7 @@ const GeoLayout intro_geo_mario_head_dizzy[] = {
|
||||
GEO_CLOSE_NODE(),
|
||||
#endif
|
||||
GEO_CLOSE_NODE(),
|
||||
#if defined(ENABLE_RUMBLE)
|
||||
#if defined(VERSION_SH)
|
||||
GEO_ZBUFFER(0),
|
||||
GEO_OPEN_NODE(),
|
||||
GEO_ASM(INTRO_CONTEXT_GAME_OVER, geo_intro_rumble_pak_graphic),
|
||||
|
||||
11
libmario/Makefile
Normal file
11
libmario/Makefile
Normal file
@@ -0,0 +1,11 @@
|
||||
DECOMP_INPUT_FILES := ../src/game/mario_actions_airborne.c ../src/game/mario_actions_automatic.c ../src/game/mario_actions_cutscene.c \
|
||||
../src/game/mario_actions_moving.c ../src/game/mario_actions_object.c ../src/game/mario_actions_stationary.c ../src/game/mario_actions_submerged.c \
|
||||
../src/game/mario_misc.c ../src/game/mario_step.c ../src/game/mario.c ../src/engine/math_util.c ../src/game/object_helpers.c
|
||||
|
||||
all: libmario.dll libmario.so
|
||||
|
||||
libmario.dll: $(wildcard mariolib/*.c) $(DECOMP_INPUT_FILES)
|
||||
x86_64-w64-mingw32-gcc $^ -o $@ -shared -DNON_MATCHING -DAVOID_UB -D_LANGUAGE_C -ggdb -I.. -I../include -I../include/n64 -I../src/engine -I../src/game -I../src -Ism64 -lm -Wl,--subsystem,windows
|
||||
|
||||
libmario.so: $(wildcard mariolib/*.c) $(DECOMP_INPUT_FILES)
|
||||
gcc $^ -o $@ -shared -DNON_MATCHING -DAVOID_UB -D_LANGUAGE_C -ggdb -I.. -I../include -I../include/n64 -I../src/engine -I../src/game -I../src -Ism64 -lm -fPIC
|
||||
3679
libmario/inputs.py
Normal file
3679
libmario/inputs.py
Normal file
File diff suppressed because it is too large
Load Diff
799
libmario/mariolib/anims.c
Normal file
799
libmario/mariolib/anims.c
Normal file
File diff suppressed because it is too large
Load Diff
870
libmario/mariolib/funcs.c
Normal file
870
libmario/mariolib/funcs.c
Normal file
File diff suppressed because it is too large
Load Diff
205
libmario/test.py
Executable file
205
libmario/test.py
Executable file
@@ -0,0 +1,205 @@
|
||||
#!/usr/bin/env python3
|
||||
import inputs
|
||||
import time
|
||||
import threading
|
||||
import sys
|
||||
import fpstimer
|
||||
import os
|
||||
from ctypes import *
|
||||
|
||||
pluginPath = os.path.dirname(os.path.realpath(__file__))
|
||||
|
||||
library = 'libmario.so'
|
||||
if sys.platform == 'win32':
|
||||
library = 'libmario.dll'
|
||||
if sys.platform == 'darwin':
|
||||
library = 'libmario.dynlib'
|
||||
|
||||
libmario = CDLL(os.path.join(pluginPath, library))
|
||||
|
||||
# /*0x00*/ s16 type;
|
||||
# /*0x02*/ s16 force;
|
||||
# /*0x04*/ s8 flags;
|
||||
# /*0x05*/ s8 room;
|
||||
# /*0x06*/ s16 lowerY;
|
||||
# /*0x08*/ s16 upperY;
|
||||
# /*0x0A*/ Vec3s vertex1;
|
||||
# /*0x10*/ Vec3s vertex2;
|
||||
# /*0x16*/ Vec3s vertex3;
|
||||
# /*0x1C*/ struct {
|
||||
# f32 x;
|
||||
# f32 y;
|
||||
# f32 z;
|
||||
# } normal;
|
||||
# /*0x28*/ f32 originOffset;
|
||||
# /*0x2C*/ struct Object *object;
|
||||
|
||||
Vec3f = (c_float * 3)
|
||||
Vec3s = (c_int16 * 3)
|
||||
class Surface(Structure):
|
||||
_fields_ = [
|
||||
('type', c_int16),
|
||||
('force', c_int16),
|
||||
('flags', c_int8),
|
||||
('room', c_int8),
|
||||
('lowerY', c_int16),
|
||||
('upperY', c_int16),
|
||||
('vertex1', Vec3s),
|
||||
('vertex2', Vec3s),
|
||||
('vertex3', Vec3s),
|
||||
('normal', Vec3f),
|
||||
('origin_offset', c_float),
|
||||
('object', c_void_p)
|
||||
]
|
||||
|
||||
FindFloorHandlerType = CFUNCTYPE(c_float, c_float, c_float, c_float, POINTER(Surface), POINTER(c_int32))
|
||||
FindCeilHandlerType = CFUNCTYPE(c_float, c_float, c_float, c_float, POINTER(Surface), POINTER(c_int32))
|
||||
FindWallsHandlerType = CFUNCTYPE(c_int32, c_float, c_float, c_float, c_float, c_float, POINTER(Surface), POINTER(c_float))
|
||||
FindWaterLevelHandlerType = CFUNCTYPE(c_float, c_float, c_float)
|
||||
|
||||
libmario.init.restype = None
|
||||
libmario.init.artypes = [FindFloorHandlerType, FindCeilHandlerType, FindWallsHandlerType, FindWaterLevelHandlerType]
|
||||
|
||||
libmario.step.restype = None
|
||||
libmario.step.artypes = [c_int32, c_float, c_float]
|
||||
|
||||
libmario.getMarioPosition.restype = None
|
||||
libmario.getMarioPosition.artypes = [Vec3f]
|
||||
|
||||
libmario.getMarioVelocity.restype = None
|
||||
libmario.getMarioVelocity.artypes = [Vec3f]
|
||||
|
||||
libmario.getMarioAnimFrame.restype = c_int32
|
||||
libmario.getMarioAnimFrame.artypes = []
|
||||
|
||||
libmario.getMarioAnimIndex.restype = c_int32
|
||||
libmario.getMarioAnimIndex.artypes = []
|
||||
|
||||
CONT_A = 0x8000
|
||||
CONT_B = 0x4000
|
||||
CONT_G = 0x2000
|
||||
CONT_START = 0x1000
|
||||
CONT_UP = 0x0800
|
||||
CONT_DOWN = 0x0400
|
||||
CONT_LEFT = 0x0200
|
||||
CONT_RIGHT = 0x0100
|
||||
CONT_L = 0x0020
|
||||
CONT_R = 0x0010
|
||||
CONT_E = 0x0008
|
||||
CONT_D = 0x0004
|
||||
CONT_C = 0x0002
|
||||
CONT_F = 0x0001
|
||||
|
||||
A_BUTTON = CONT_A
|
||||
B_BUTTON = CONT_B
|
||||
L_TRIG = CONT_L
|
||||
R_TRIG = CONT_R
|
||||
Z_TRIG = CONT_G
|
||||
START_BUTTON = CONT_START
|
||||
U_JPAD = CONT_UP
|
||||
L_JPAD = CONT_LEFT
|
||||
R_JPAD = CONT_RIGHT
|
||||
D_JPAD = CONT_DOWN
|
||||
U_CBUTTONS = CONT_E
|
||||
L_CBUTTONS = CONT_C
|
||||
R_CBUTTONS = CONT_F
|
||||
D_CBUTTONS = CONT_D
|
||||
|
||||
events = []
|
||||
_t = None
|
||||
_handler = None
|
||||
|
||||
def find_floor(x, y, z, surface_out, found_out):
|
||||
found_out[0] = 1
|
||||
surface_out[0].vertex1[0] = -100
|
||||
surface_out[0].vertex1[1] = 0
|
||||
surface_out[0].vertex1[2] = -100
|
||||
|
||||
surface_out[0].vertex2[0] = 100
|
||||
surface_out[0].vertex2[1] = 0
|
||||
surface_out[0].vertex2[2] = -100
|
||||
|
||||
surface_out[0].vertex3[0] = 100
|
||||
surface_out[0].vertex3[1] = 0
|
||||
surface_out[0].vertex3[2] = 100
|
||||
|
||||
surface_out[0].normal[0] = 0.0
|
||||
surface_out[0].normal[1] = 1.0
|
||||
surface_out[0].normal[2] = 0.0
|
||||
|
||||
surface_out[0].origin_offset = 0.0
|
||||
|
||||
return -1000.0
|
||||
|
||||
def find_water_level(x, z):
|
||||
return -100.0
|
||||
|
||||
# Needs to be global to avoid getting garbage collected during execution
|
||||
find_floor_handler = FindFloorHandlerType(find_floor)
|
||||
find_water_level_handler = FindWaterLevelHandlerType(find_water_level)
|
||||
|
||||
def worker():
|
||||
global events
|
||||
while True:
|
||||
events.append(inputs.get_gamepad())
|
||||
|
||||
|
||||
def main():
|
||||
global _t
|
||||
global _handler
|
||||
global events
|
||||
if not _t :
|
||||
_t = threading.Thread(target=worker)
|
||||
_t.daemon = True
|
||||
_t.start()
|
||||
stick_x = 0.0
|
||||
stick_y = 0.0
|
||||
buttons = 0
|
||||
libmario.init(find_floor_handler, None, None, find_water_level_handler)
|
||||
timer = fpstimer.FPSTimer(30)
|
||||
try:
|
||||
while True:
|
||||
while len(events) > 0 :
|
||||
for event in events[0]:
|
||||
if event.code == "ABS_X":
|
||||
stick_x = float(event.state) / 32768.0
|
||||
elif event.code == "ABS_Y":
|
||||
stick_y = float(event.state) / 32768.0
|
||||
elif event.code == "ABS_RX":
|
||||
gpd_input = "Right Stick X"
|
||||
elif event.code == "ABS_RY":
|
||||
gpd_input = "Right Stick Y"
|
||||
elif event.code == "BTN_SOUTH":
|
||||
if event.state == 1:
|
||||
buttons |= A_BUTTON
|
||||
else:
|
||||
buttons &= ~A_BUTTON
|
||||
elif event.code == "BTN_WEST":
|
||||
if event.state == 1:
|
||||
buttons |= B_BUTTON
|
||||
else:
|
||||
buttons &= ~B_BUTTON
|
||||
elif event.code == "ABS_Z":
|
||||
if event.state == 255:
|
||||
buttons |= Z_TRIG
|
||||
else:
|
||||
buttons &= ~Z_TRIG
|
||||
elif event.code != "SYN_REPORT":
|
||||
print(event.code + ':' + str(event.state))
|
||||
events.pop(0)
|
||||
|
||||
libmario.step(buttons, c_float(stick_x), c_float(stick_y))
|
||||
pos = Vec3f()
|
||||
vel = Vec3f()
|
||||
libmario.getMarioPosition(pos)
|
||||
libmario.getMarioVelocity(vel)
|
||||
|
||||
print('Position: %8.2f %8.2f %8.2f Velocity: %8.2f %8.2f %8.2f Buttons: 0x%08X Anim: 0x%02X AnimFrame: %d' % (pos[0], pos[1], pos[2], vel[0], vel[1], vel[2], buttons, libmario.getMarioAnimIndex(), libmario.getMarioAnimFrame()))
|
||||
|
||||
timer.sleep()
|
||||
except KeyboardInterrupt:
|
||||
print("Ctrl+C pressed...")
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
@@ -343,12 +343,16 @@ f32 adsr_update(struct AdsrState *adsr) {
|
||||
s32 adsr_update(struct AdsrState *adsr) {
|
||||
#endif
|
||||
u8 action = adsr->action;
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
u8 state = adsr->state;
|
||||
switch (state) {
|
||||
#else
|
||||
switch (adsr->state) {
|
||||
#endif
|
||||
case ADSR_STATE_DISABLED:
|
||||
return 0;
|
||||
|
||||
case ADSR_STATE_INITIAL:
|
||||
case ADSR_STATE_INITIAL: {
|
||||
#if defined(VERSION_JP) || defined(VERSION_US)
|
||||
adsr->current = adsr->initial;
|
||||
adsr->target = adsr->initial;
|
||||
@@ -357,7 +361,8 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->state = ADSR_STATE_HANG;
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_START_LOOP:
|
||||
adsr->envIndex = 0;
|
||||
@@ -365,12 +370,11 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
adsr->currentHiRes = (adsr->current << 0x10);
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_LOOP;
|
||||
|
||||
#ifdef VERSION_SH
|
||||
// fallthrough
|
||||
restart:
|
||||
#endif
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_LOOP:
|
||||
adsr->delay = BSWAP16(adsr->envelope[adsr->envIndex].delay);
|
||||
switch (adsr->delay) {
|
||||
@@ -395,23 +399,25 @@ s32 adsr_update(struct AdsrState *adsr) {
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
if (adsr->delay >= 4) {
|
||||
adsr->delay = adsr->delay * gAudioBufferParameters.updatesPerFrame
|
||||
#ifdef VERSION_SH
|
||||
#ifdef VERSION_SH
|
||||
/ gAudioBufferParameters.presetUnk4
|
||||
#endif
|
||||
#endif
|
||||
/ 4;
|
||||
}
|
||||
#ifdef VERSION_SH
|
||||
#if defined(VERSION_SH)
|
||||
if (adsr->delay == 0) {
|
||||
adsr->delay = 1;
|
||||
}
|
||||
#endif
|
||||
adsr->target = (f32) BSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0f;
|
||||
#elif defined(VERSION_EU)
|
||||
adsr->target = (f32) BSWAP16(adsr->envelope[adsr->envIndex].arg) / 32767.0;
|
||||
#endif
|
||||
adsr->target = adsr->target * adsr->target;
|
||||
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
|
||||
#else // !(VERSION_EU || VERSION_SH)
|
||||
#else
|
||||
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
|
||||
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
|
||||
#endif // !(VERSION_EU || VERSION_SH)
|
||||
#endif
|
||||
adsr->state = ADSR_STATE_FADE;
|
||||
adsr->envIndex++;
|
||||
break;
|
||||
|
||||
@@ -1262,7 +1262,7 @@ static void update_game_sound(void) {
|
||||
#endif
|
||||
} else {
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
func_802ad728(0x04020000 | ((channelIndex & 0xff) << 8),
|
||||
func_802ad728((x04020000 | ((channelIndex & 0xff) << 8),
|
||||
get_sound_freq_scale(bank, soundIndex) + ((f32) sSoundMovingSpeed[bank] / 400.0f));
|
||||
#else
|
||||
value = get_sound_freq_scale(bank, soundIndex);
|
||||
|
||||
@@ -169,7 +169,7 @@ void reset_bank_and_seq_load_status(void) {
|
||||
#ifdef VERSION_SH
|
||||
bzero(&gBankLoadStatus, sizeof(gBankLoadStatus));
|
||||
bzero(&gUnkLoadStatus, sizeof(gUnkLoadStatus));
|
||||
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus));
|
||||
bzero(&gSeqLoadStatus, sizeof(gBankLoadStatus));
|
||||
#else
|
||||
bzero(&gBankLoadStatus, sizeof(gBankLoadStatus)); // Setting this array to zero is equivilent to SOUND_LOAD_STATUS_NOT_LOADED
|
||||
bzero(&gSeqLoadStatus, sizeof(gSeqLoadStatus)); // Same dealio
|
||||
@@ -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 = ALIGN16(size);
|
||||
pool->size = size;
|
||||
#endif
|
||||
pool->numAllocatedEntries = 0;
|
||||
}
|
||||
@@ -380,7 +380,7 @@ void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg
|
||||
// arg3 = 0, 1 or 2?
|
||||
|
||||
#ifdef VERSION_SH
|
||||
struct SoundMultiPool *arg0 = NULL;
|
||||
struct SoundMultiPool *arg0;
|
||||
#define isSound poolIdx
|
||||
#endif
|
||||
struct TemporaryPool *tp;
|
||||
@@ -408,8 +408,6 @@ 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:
|
||||
@@ -658,7 +656,7 @@ size = ALIGN16(size);
|
||||
#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;
|
||||
tp->entries[1].ptr = pool->start + pool->size - size - 0x10;
|
||||
#endif
|
||||
tp->entries[1].id = id;
|
||||
tp->entries[1].size = size;
|
||||
@@ -760,7 +758,7 @@ void *get_bank_or_seq(s32 poolIdx, s32 arg1, s32 id) {
|
||||
}
|
||||
void *get_bank_or_seq_inner(s32 poolIdx, s32 arg1, s32 bankId) {
|
||||
u32 i;
|
||||
struct SoundMultiPool* loadedPool = NULL;
|
||||
struct SoundMultiPool* loadedPool;
|
||||
struct TemporaryPool* temporary;
|
||||
struct PersistentPool* persistent;
|
||||
|
||||
@@ -933,7 +931,7 @@ void decrease_reverb_gain(void) {
|
||||
|
||||
#if defined(VERSION_EU) || defined(VERSION_SH)
|
||||
s32 audio_shut_down_and_reset_step(void) {
|
||||
s32 i;
|
||||
s32 i, j;
|
||||
|
||||
switch (gAudioResetStatus) {
|
||||
case 5:
|
||||
@@ -1009,7 +1007,7 @@ void init_reverb_eu(void) {
|
||||
gNumSynthesisReverbs = preset->numReverbs;
|
||||
for (j = 0; j < gNumSynthesisReverbs; j++) {
|
||||
reverb = &gSynthesisReverbs[j];
|
||||
reverbSettings = &sReverbSettings[MIN((u32)(gAudioResetPresetIdToLoad + j), (sizeof(sReverbSettings) / sizeof(struct ReverbSettingsEU)) - 1)];
|
||||
reverbSettings = &sReverbSettings[MIN((gAudioResetPresetIdToLoad + j), (sizeof(sReverbSettings) / sizeof(struct ReverbSettingsEU)) - 1)];
|
||||
reverb->windowSize = (reverbSettings->windowSize * 0x40);
|
||||
reverb->downsampleRate = reverbSettings->downsampleRate;
|
||||
reverb->reverbGain = reverbSettings->gain;
|
||||
|
||||
@@ -38,14 +38,8 @@ 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
|
||||
#endif
|
||||
};
|
||||
}; // size = 0x194
|
||||
|
||||
struct TemporaryPool {
|
||||
/*EU, SH*/
|
||||
@@ -70,14 +64,9 @@ 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 {
|
||||
@@ -96,7 +85,6 @@ struct UnkPool {
|
||||
/*0x510*/ s32 numEntries;
|
||||
/*0x514*/ u32 unk514;
|
||||
};
|
||||
#endif
|
||||
|
||||
extern u8 gAudioHeap[];
|
||||
extern s16 gVolume;
|
||||
|
||||
@@ -24,8 +24,6 @@ struct SharedDma {
|
||||
// EU only
|
||||
void port_eu_init(void);
|
||||
|
||||
ALIGNED16 u32 dmaTempBuffer[4];
|
||||
|
||||
struct Note *gNotes;
|
||||
|
||||
struct SequencePlayer gSequencePlayers[SEQUENCE_PLAYERS];
|
||||
@@ -139,8 +137,14 @@ u8 audioString49[] = "BANK LOAD MISS! FOR %d\n";
|
||||
* Performs an asynchronus (normal priority) DMA copy
|
||||
*/
|
||||
void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQueue *queue, OSIoMesg *mesg) {
|
||||
#if PUPPYPRINT_DEBUG
|
||||
OSTime first = osGetTime();
|
||||
#endif
|
||||
osInvalDCache(vAddr, nbytes);
|
||||
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, devAddr, vAddr, nbytes, queue);
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,12 +152,18 @@ void audio_dma_copy_async(uintptr_t devAddr, void *vAddr, size_t nbytes, OSMesgQ
|
||||
* to 0x1000 bytes transfer at once.
|
||||
*/
|
||||
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg) {
|
||||
#if PUPPYPRINT_DEBUG
|
||||
OSTime first = osGetTime();
|
||||
#endif
|
||||
ssize_t transfer = MIN(*remaining, 0x1000);
|
||||
*remaining -= transfer;
|
||||
osInvalDCache(*vAddr, transfer);
|
||||
osPiStartDma(mesg, OS_MESG_PRI_NORMAL, OS_READ, *devAddr, *vAddr, transfer, queue);
|
||||
*devAddr += transfer;
|
||||
*vAddr += transfer;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
}
|
||||
|
||||
void decrease_sample_dma_ttls() {
|
||||
@@ -198,10 +208,17 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
u32 i;
|
||||
u32 dmaIndex;
|
||||
ssize_t bufferPos;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
OSTime first = osGetTime();
|
||||
#endif
|
||||
|
||||
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.
|
||||
@@ -218,7 +235,14 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
}
|
||||
dma->ttl = 60;
|
||||
*dmaIndexRef = (u8) i;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
#if defined(VERSION_EU)
|
||||
return &dma->buffer[(devAddr - dma->source)];
|
||||
#else
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,7 +255,12 @@ 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.
|
||||
@@ -247,7 +276,17 @@ void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef) {
|
||||
sSampleDmaReuseQueueTail1++;
|
||||
}
|
||||
dma->ttl = 2;
|
||||
#if defined(VERSION_EU)
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
return dma->buffer + (devAddr - dma->source);
|
||||
#else
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
return (devAddr - dma->source) + dma->buffer;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,13 +303,27 @@ 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 // TODO: Is there a reason this only exists in US?
|
||||
#ifdef VERSION_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;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
return (devAddr - dmaDevAddr) + dma->buffer;
|
||||
#else
|
||||
gCurrAudioFrameDmaCount++;
|
||||
osPiStartDma(&gCurrAudioFrameDmaIoMesgBufs[gCurrAudioFrameDmaCount - 1], OS_MESG_PRI_NORMAL,
|
||||
OS_READ, dmaDevAddr, dma->buffer, transfer, &gCurrAudioFrameDmaQueue);
|
||||
*dmaIndexRef = dmaIndex;
|
||||
#if PUPPYPRINT_DEBUG
|
||||
dmaAudioTime[perfIteration] += (osGetTime() - first);
|
||||
#endif
|
||||
return dma->buffer + (devAddr - dmaDevAddr);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -503,6 +556,8 @@ 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;
|
||||
@@ -514,9 +569,9 @@ struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, dmaTempBuffer, 0x10);
|
||||
u32 numInstruments = dmaTempBuffer[0];
|
||||
u32 numDrums = dmaTempBuffer[1];
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, buf, 0x10);
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[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;
|
||||
@@ -528,6 +583,8 @@ 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;
|
||||
@@ -537,9 +594,9 @@ struct AudioBank *bank_load_async(s32 bankId, s32 arg1, struct SequencePlayer *s
|
||||
return NULL;
|
||||
}
|
||||
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, dmaTempBuffer, 0x10);
|
||||
u32 numInstruments = dmaTempBuffer[0];
|
||||
u32 numDrums = dmaTempBuffer[1];
|
||||
audio_dma_copy_immediate((uintptr_t) ctlData, buf, 0x10);
|
||||
u32 numInstruments = buf[0];
|
||||
u32 numDrums = buf[1];
|
||||
seqPlayer->loadingBankId = (u8) bankId;
|
||||
#if defined(VERSION_EU)
|
||||
gCtlEntries[bankId].numInstruments = numInstruments;
|
||||
@@ -803,8 +860,11 @@ 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;
|
||||
u32 size;
|
||||
UNUSED u32 size;
|
||||
void *data;
|
||||
|
||||
gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
|
||||
@@ -879,6 +939,10 @@ 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)
|
||||
@@ -895,7 +959,7 @@ void audio_init() {
|
||||
eu_stubbed_printf_0("Main Heap Initialize.\n");
|
||||
|
||||
// Load headers for sounds and sequences
|
||||
gSeqFileHeader = (ALSeqFile *) dmaTempBuffer;
|
||||
gSeqFileHeader = (ALSeqFile *) buf;
|
||||
data = gMusicData;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gSeqFileHeader, 0x10);
|
||||
gSequenceCount = gSeqFileHeader->seqCount;
|
||||
@@ -906,7 +970,7 @@ void audio_init() {
|
||||
alSeqFileNew(gSeqFileHeader, data);
|
||||
|
||||
// Load header for CTL (instrument metadata)
|
||||
gAlCtlHeader = (ALSeqFile *) dmaTempBuffer;
|
||||
gAlCtlHeader = (ALSeqFile *) buf;
|
||||
data = gSoundDataADSR;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gAlCtlHeader, 0x10);
|
||||
size = gAlCtlHeader->seqCount * sizeof(ALSeqData) + 4;
|
||||
@@ -917,7 +981,7 @@ void audio_init() {
|
||||
alSeqFileNew(gAlCtlHeader, data);
|
||||
|
||||
// Load header for TBL (raw sound data)
|
||||
gAlTbl = (ALSeqFile *) dmaTempBuffer;
|
||||
gAlTbl = (ALSeqFile *) buf;
|
||||
audio_dma_copy_immediate((uintptr_t) data, gAlTbl, 0x10);
|
||||
size = gAlTbl->seqCount * sizeof(ALSeqData) + 4;
|
||||
size = ALIGN16(size);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user