Merge branch 'master' of https://github.com/Reonu/HackerSM64 into develop/merge-master-2.0.1-into-2.1.0

This commit is contained in:
Arceveti committed 2022-06-28 12:43:02 -07:00
commit e6d68e6d76
89 files changed
+3205 -1095

No files matched your search

+3 -7
View File
@@ -25,6 +25,7 @@
#include "puppyprint.h"
#include "debug_box.h"
#include "engine/colors.h"
#include "profiling.h"
struct SpawnInfo gPlayerSpawnInfos[1];
struct GraphNode *gGraphNodePointers[MODEL_ID_COUNT];
@@ -375,10 +376,6 @@ void play_transition_after_delay(s16 transType, s16 time, u8 red, u8 green, u8 b
}
void render_game(void) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
OSTime colTime = collisionTime[perfIteration];
#endif
if (gCurrentArea != NULL && !gWarpTransition.pauseRendering) {
if (gCurrentArea->graphNode) {
geo_process_root(gCurrentArea->graphNode, gViewportOverride, gViewportClip, gFBSetColor);
@@ -435,10 +432,9 @@ void render_game(void) {
gViewportOverride = NULL;
gViewportClip = NULL;
profiler_update(PROFILER_TIME_GFX);
profiler_print_times();
#if PUPPYPRINT_DEBUG
profiler_update(graphTime, first);
graphTime[perfIteration] -= (collisionTime[perfIteration] - colTime);
// graphTime[perfIteration] -= profilerTime[perfIteration]; //! Graph time is inaccurate and wrongly reaches 0 sometimes
puppyprint_render_profiler();
#endif
}
+5 -8
View File
@@ -6,18 +6,15 @@ void bhv_celebration_star_init(void) {
o->oHomeZ = gMarioObject->header.gfx.pos[2];
o->oMoveAngleYaw = gMarioObject->header.gfx.angle[1] + 0x8000;
o->oCelebStarDiameterOfRotation = 100;
if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2) {
o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_BOWSER_KEY];
o->oFaceAnglePitch = 0;
o->oFaceAnglePitch = 0;
if (obj_has_model(gMarioState->interactObj, MODEL_BOWSER_KEY)) {
o->oFaceAngleRoll = 0xC000;
cur_obj_scale(0.1f);
o->oCelebStarIsBowserKey = 1;
o->oCelebStarIsBowserKey = TRUE;
} else {
o->header.gfx.sharedChild = gLoadedGraphNodes[MODEL_STAR];
o->oFaceAnglePitch = 0;
o->oFaceAngleRoll = 0;
cur_obj_scale(0.4f);
o->oCelebStarIsBowserKey = 0;
o->oCelebStarIsBowserKey = FALSE;
}
}
@@ -42,7 +39,7 @@ void celeb_star_act_spin_around_mario(void) {
void celeb_star_act_face_camera(void) {
if (o->oTimer < 10) {
if (o->oCelebStarIsBowserKey == 0) {
if (o->oCelebStarIsBowserKey == FALSE) {
cur_obj_scale((f32) o->oTimer / 10.0f);
} else {
cur_obj_scale((f32) o->oTimer / 30.0f);
+2 -2
View File
@@ -76,7 +76,7 @@ void bhv_mr_i_iris_loop(void) {
obj_build_transform_from_pos_and_angle(o, O_PARENT_RELATIVE_POS_INDEX, O_MOVE_ANGLE_INDEX);
obj_translate_local(o, O_POS_INDEX, O_PARENT_RELATIVE_POS_INDEX);
o->oFaceAnglePitch = o->oMoveAnglePitch;
o->oGraphYOffset = o->header.gfx.scale[1] * 100.0f;
o->oGraphYOffset = o->parentObj->oGraphYOffset;
}
if (!o->parentObj->oMrIBlinking) {
@@ -128,7 +128,7 @@ void mr_i_body_act_spin_death(void) {
cur_obj_become_intangible();
spawn_mist_particles();
o->oMrIScale = scaleModifier * 0.6f;
if (o->oBehParams2ndByte != 0) {
if (o->oBehParams2ndByte != MR_I_BP_NORMAL) {
o->oPosY += 100.0f;
spawn_default_star(1370, 2000.0f, -320.0f);
obj_mark_for_deletion(o);
+3 -3
View File
@@ -38,7 +38,9 @@ Gfx *geo_snufit_move_mask(s32 callContext, struct GraphNode *node, UNUSED Mat4 *
if (callContext == GEO_CONTEXT_RENDER) {
struct Object *obj = (struct Object *) gCurGraphNodeObject;
struct GraphNodeTranslationRotation *transNode = (struct GraphNodeTranslationRotation *) node->next;
vec3s_copy(transNode->translation, &obj->oSnufitOffsetVec);
transNode->translation[0] = 0;
transNode->translation[1] = -32;
transNode->translation[2] = obj->oSnufitRecoil + 180;
}
return NULL;
@@ -147,8 +149,6 @@ void bhv_snufit_loop(void) {
o->oPosY = o->oHomeY + 8.0f * coss(4000 * gGlobalTimer);
o->oPosZ = o->oHomeZ + 100.0f * sins(o->oSnufitCircularPeriod);
o->oSnufitYOffset = -0x20;
o->oSnufitZOffset = o->oSnufitRecoil + 180;
o->oSnufitBodyScale
= (s16)(o->oSnufitBodyBaseScale + 666
+ o->oSnufitBodyBaseScale * coss(o->oSnufitBodyScalePeriod));
@@ -8,9 +8,8 @@
* Initialize the object's transform matrix with Y being up.
*/
void bhv_platform_normals_init(void) {
Mat4 *transform = &o->transform;
vec3f_set(&o->oTiltingPyramidNormalVec, 0.0f, 1.0f, 0.0f);
mtxf_align_terrain_normal(*transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0);
mtxf_align_terrain_normal(o->transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0);
}
/**
@@ -20,24 +19,32 @@ void bhv_platform_normals_init(void) {
void bhv_tilting_inverted_pyramid_loop(void) {
#ifndef PLATFORM_DISPLACEMENT_2
Vec3f posBeforeRotation, posAfterRotation;
// Mario's position
Vec3f m;
Vec3f marioPos, dist;
#endif
Vec3f targetNormal;
Mat4 *transform = &o->transform;
s32 marioOnPlatform = (gMarioObject->platform == o);
if (gMarioObject->platform == o) {
vec3_diff(targetNormal, &gMarioObject->oPosVec, &o->oPosVec);
if (marioOnPlatform) {
#ifndef PLATFORM_DISPLACEMENT_2
vec3f_copy(m, gMarioStates[0].pos);
linear_mtxf_mul_vec3f(*transform, posBeforeRotation, targetNormal);
// Target the normal in Mario's direction
vec3_diff(dist, gMarioStates[0].pos, &o->oPosVec);
// Get Mario's position before the rotation
vec3f_copy(marioPos, gMarioStates[0].pos);
linear_mtxf_mul_vec3f(*transform, posBeforeRotation, dist);
targetNormal[0] = dist[0];
targetNormal[2] = dist[2];
#else // PLATFORM_DISPLACEMENT_2
targetNormal[0] = gMarioStates[0].pos[0] - o->oPosX;
targetNormal[2] = gMarioStates[0].pos[2] - o->oPosZ;
#endif
targetNormal[1] = 500.0f;
vec3f_normalize(targetNormal);
o->oTiltingPyramidMarioOnPlatform = TRUE;
} else {
// Target normal is directly upwards when Mario is not on the platform.
vec3f_set(targetNormal, 0.0f, 1.0f, 0.0f);
o->oTiltingPyramidMarioOnPlatform = FALSE;
}
// Approach the normals by 0.01f towards the new goal, then create a transform matrix and orient the object.
@@ -45,16 +52,16 @@ void bhv_tilting_inverted_pyramid_loop(void) {
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalX, targetNormal[0], 0.01f);
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalY, targetNormal[1], 0.01f);
approach_f32_symmetric_bool(&o->oTiltingPyramidNormalZ, targetNormal[2], 0.01f);
mtxf_align_terrain_normal(*transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0);
mtxf_align_terrain_normal(*transform, &o->oTiltingPyramidNormalVec, &o->oPosVec, 0x0);
#ifndef PLATFORM_DISPLACEMENT_2
// If Mario is on the platform, adjust his position for the platform tilt.
if (o->oTiltingPyramidMarioOnPlatform) {
linear_mtxf_mul_vec3f(*transform, posAfterRotation, targetNormal);
m[0] += posAfterRotation[0] - posBeforeRotation[0];
m[1] += posAfterRotation[1] - posBeforeRotation[1];
m[2] += posAfterRotation[2] - posBeforeRotation[2];
vec3f_copy(gMarioStates[0].pos, m);
if (marioOnPlatform) {
linear_mtxf_mul_vec3f(*transform, posAfterRotation, dist);
marioPos[0] += posAfterRotation[0] - posBeforeRotation[0];
marioPos[1] += posAfterRotation[1] - posBeforeRotation[1];
marioPos[2] += posAfterRotation[2] - posBeforeRotation[2];
vec3f_copy(gMarioStates[0].pos, marioPos);
}
#endif
+23 -12
View File
@@ -1,14 +1,13 @@
// water_ring.inc.c
#ifndef FIX_WATER_RINGS
f32 water_ring_calc_mario_dist(void) {
f32 marioDistX = o->oPosX - gMarioObject->header.gfx.pos[0];
f32 marioDistY = o->oPosY - (gMarioObject->header.gfx.pos[1] + 80.0f);
f32 marioDistZ = o->oPosZ - gMarioObject->header.gfx.pos[2];
f32 marioDistInFront = marioDistX * o->oWaterRingNormalX + marioDistY * o->oWaterRingNormalY
+ marioDistZ * o->oWaterRingNormalZ;
return marioDistInFront;
Vec3f marioDist;
vec3_diff(marioDist, &o->oPosVec, gMarioObject->header.gfx.pos);
marioDist[1] += 80.0f;
return vec3_dot(marioDist, &o->oWaterRingNormalVec);
}
#endif
void water_ring_init(void) {
cur_obj_init_animation(WATER_RING_ANIM_WOBBLE);
@@ -16,6 +15,7 @@ void water_ring_init(void) {
o->oWaterRingScalePhaseY = (s32)(random_float() * 4096.0f) + 0x1000;
o->oWaterRingScalePhaseZ = (s32)(random_float() * 4096.0f) + 0x1000;
#ifndef FIX_WATER_RINGS
//! This normal calculation assumes a facing yaw of 0, which is not the case
// for the manta ray rings. It also errs by multiplying the normal X by -1.
// This cause the ring's orientation for the purposes of collision to be
@@ -32,6 +32,7 @@ void water_ring_init(void) {
//
// o->oFaceAngleYaw = 0;
// o->oFaceAngleRoll *= -1;
#endif
}
void bhv_jet_stream_water_ring_init(void) {
@@ -42,16 +43,21 @@ void bhv_jet_stream_water_ring_init(void) {
}
void water_ring_check_collection(UNUSED f32 avgScale, struct Object *ringManager) {
#ifdef FIX_WATER_RINGS
if (o->oInteractStatus & INT_STATUS_INTERACTED) {
#else
f32 marioDistInFront = water_ring_calc_mario_dist();
if (!is_point_close_to_object(o, gMarioObject->header.gfx.pos[0],
gMarioObject->header.gfx.pos[1] + 80.0f,
gMarioObject->header.gfx.pos[2], (avgScale + 0.2f) * 120.0f)) {
gMarioObject->header.gfx.pos[1] + 80.0f,
gMarioObject->header.gfx.pos[2],
(avgScale + 0.2f) * 120.0f)) {
o->oWaterRingMarioDistInFront = marioDistInFront;
return;
}
if (o->oWaterRingMarioDistInFront * marioDistInFront < 0.0f) {
#endif
struct Object *ringSpawner = o->parentObj;
if (ringSpawner) {
@@ -73,7 +79,9 @@ void water_ring_check_collection(UNUSED f32 avgScale, struct Object *ringManager
o->oAction = WATER_RING_ACT_COLLECTED;
}
#ifndef FIX_WATER_RINGS
o->oWaterRingMarioDistInFront = marioDistInFront;
#endif
}
void water_ring_set_scale(f32 avgScale) {
@@ -154,8 +162,11 @@ void water_ring_spawner_act_inactive(void) {
o->oTimer = 0;
}
if ((o->oTimer == 0) || (o->oTimer == 50) || (o->oTimer == 150) || (o->oTimer == 200)
|| (o->oTimer == 250)) {
if ((o->oTimer == 0)
|| (o->oTimer == 50)
|| (o->oTimer == 150)
|| (o->oTimer == 200)
|| (o->oTimer == 250)) {
struct Object *waterRing = spawn_object(o, MODEL_WATER_RING, bhvJetStreamWaterRing);
waterRing->oWaterRingIndex = o->oWaterRingMgrNextRingIndex;
o->oWaterRingMgrNextRingIndex++;
@@ -199,7 +210,7 @@ void manta_water_ring_act_not_collected(void) {
if (o->oTimer > 150) {
o->oOpacity -= 2;
if (o->oOpacity < 3) {
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
obj_mark_for_deletion(o);
}
}
-8
View File
@@ -2871,10 +2871,6 @@ void update_lakitu(struct Camera *c) {
* Gets controller input, checks for cutscenes, handles mode changes, and moves the camera
*/
void update_camera(struct Camera *c) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
OSTime colTime = collisionTime[perfIteration];
#endif
gCamera = c;
update_camera_hud_status(c);
if (c->cutscene == CUTSCENE_NONE
@@ -3117,10 +3113,6 @@ void update_camera(struct Camera *c) {
}
#endif
gLakituState.lastFrameAction = sMarioCamState->action;
#if PUPPYPRINT_DEBUG
profiler_update(cameraTime, first);
cameraTime[perfIteration] -= collisionTime[perfIteration]-colTime;
#endif
}
/**
-6
View File
@@ -402,9 +402,6 @@ void thread2_crash_screen(UNUSED void *arg) {
osSetEventMesg(OS_EVENT_CPU_BREAK, &gCrashScreen.mesgQueue, (OSMesg) 1);
osSetEventMesg(OS_EVENT_FAULT, &gCrashScreen.mesgQueue, (OSMesg) 2);
while (TRUE) {
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
#endif
if (thread == NULL) {
osRecvMesg(&gCrashScreen.mesgQueue, &mesg, 1);
thread = get_crashed_thread();
@@ -433,9 +430,6 @@ void thread2_crash_screen(UNUSED void *arg) {
read_controller_inputs(THREAD_2_CRASH_SCREEN);
draw_crash_screen(thread);
}
#if PUPPYPRINT_DEBUG
profiler_update(faultTime, first);
#endif
}
}
+87
View File
@@ -0,0 +1,87 @@
// This file is a modification of a file from https://github.com/danbolt/n64-jam-1, which was licensed under the MPL-2.0 License
// See the original repo for more details.
#include <ultra64.h>
#define TEX_ASCII_START '!'
#define TAB_WIDTH 16
#define G_CC_TEXT PRIMITIVE, 0, TEXEL0, 0, 0, 0, 0, TEXEL0
__asm__(
".section \".rodata\", \"a\", @progbits\n"
".global fast_font\n"
"fast_font:\n"
".incbin \"src/game/newfont2_swapped.bin\"\n"
".previous\n"
);
extern u8 fast_font[];
int computeS(unsigned char letter) {
int idx = letter;
if (letter > 'z') {
idx -= (3 + 2 + 3 + 1 + 3);
} else if (letter > '^') {
idx -= (2 + 3 + 1 + 3);
} else if (letter > 'Z') {
idx -= (3 + 1 + 3);
} else if (letter > '?') {
idx -= (1 + 3);
} else if (letter > ';') {
idx -= (3);
}
return (idx - TEX_ASCII_START) * 8;
}
static const u8 fast_text_font_kerning[] = {
/* */ 2, /*!*/ 4, /*"*/ 5, /*#*/ 0, /*$*/ 0, /*%*/ 7, /*&*/ 7, /*'*/ 2, /*(*/ 5, /*)*/ 5, /***/ 0, /*+*/ 7, /*,*/ 3, /*-*/ 7, /*.*/ 3, /*/*/ 7,
/*0*/ 7, /*1*/ 7, /*2*/ 7, /*3*/ 7, /*4*/ 7, /*5*/ 7, /*6*/ 7, /*7*/ 7, /*8*/ 7, /*9*/ 7, /*:*/ 3, /*;*/ 3, /*<*/ 0, /*=*/ 0, /*>*/ 0, /*?*/ 7,
/*@*/ 0, /*A*/ 7, /*B*/ 7, /*C*/ 7, /*D*/ 7, /*E*/ 7, /*F*/ 7, /*G*/ 7, /*H*/ 7, /*I*/ 6, /*J*/ 5, /*K*/ 7, /*L*/ 7, /*M*/ 7, /*N*/ 7, /*O*/ 7,
/*P*/ 7, /*Q*/ 7, /*R*/ 7, /*S*/ 7, /*T*/ 7, /*U*/ 7, /*V*/ 7, /*W*/ 7, /*X*/ 7, /*Y*/ 7, /*Z*/ 7, /*[*/ 0, /*\*/ 0, /*]*/ 0, /*^*/ 6, /*_*/ 0,
/*`*/ 0, /*a*/ 6, /*b*/ 6, /*c*/ 6, /*d*/ 6, /*e*/ 6, /*f*/ 6, /*g*/ 6, /*h*/ 6, /*i*/ 2, /*j*/ 6, /*k*/ 5, /*l*/ 3, /*m*/ 6, /*n*/ 6, /*o*/ 6,
/*p*/ 6, /*q*/ 6, /*r*/ 6, /*s*/ 6, /*t*/ 6, /*u*/ 6, /*v*/ 6, /*w*/ 6, /*x*/ 6, /*y*/ 6, /*z*/ 6, /*{*/ 0, /*|*/ 0, /*}*/ 0, /*~*/ 7,
};
void drawSmallString_impl(Gfx **dl, int x, int y, const char* string, int r, int g, int b) {
int i = 0;
int xPos = x;
int yPos = y;
int s = 0;
Gfx *dlHead = *dl;
gDPLoadTextureBlock_4bS(dlHead++, fast_font, G_IM_FMT_IA, 672, 12, 0, G_TX_MIRROR | G_TX_WRAP, G_TX_MIRROR | G_TX_WRAP, G_TX_NOMASK, G_TX_NOMASK, G_TX_NOLOD, G_TX_NOLOD);
gDPSetPrimColor(dlHead++, 0, 0, r, g, b, 255);
gDPSetCombineMode(dlHead++, G_CC_TEXT, G_CC_TEXT);
gDPPipeSync(dlHead++);
while (string[i] != '\0') {
unsigned int cur_char = string[i];
if (cur_char == '\n') {
xPos = x;
yPos += 12;
i++;
continue;
}
if (cur_char == '\t') {
int xDist = xPos - x + 1;
int tabCount = (xDist + TAB_WIDTH - 1) / TAB_WIDTH;
xPos = tabCount * TAB_WIDTH + x;
} else {
if (cur_char != ' ') {
s = computeS(cur_char);
gSPTextureRectangle(dlHead++, (xPos + 0) << 2, (yPos + 0) << 2, (xPos + 8) << 2, (yPos + 12) << 2, 0, s << 5, 0, 1 << 10, 1 << 10);
}
xPos += fast_text_font_kerning[cur_char - ' '];
}
i++;
}
gDPSetPrimColor(dlHead++, 0, 0, 255, 255, 255, 255);
gDPPipeSync(dlHead++);
*dl = dlHead;
}
+14
View File
@@ -0,0 +1,14 @@
#ifndef __FASTTEXT_H__
#define __FASTTEXT_H__
void drawSmallString_impl(Gfx**, int, int, const char*, int, int , int);
static inline void drawSmallString(Gfx **dl, int x, int y, const char* string) {
drawSmallString_impl(dl, x, y, string, 255, 255, 255);
}
static inline void drawSmallStringCol(Gfx **dl, int x, int y, const char* string, int r, int g, int b) {
drawSmallString_impl(dl, x, y, string, r, g, b);
}
#endif
+8 -29
View File
@@ -30,6 +30,7 @@
#include "debug_box.h"
#include "vc_check.h"
#include "vc_ultra.h"
#include "profiling.h"
// First 3 controller slots
struct Controller gControllers[3];
@@ -45,6 +46,7 @@ OSContStatus gControllerStatuses[4];
OSContPad gControllerPads[4];
u8 gControllerBits;
u8 gIsConsole = TRUE; // Needs to be initialized before audio_reset_session is called
u8 gCacheEmulated = TRUE;
u8 gBorderHeight;
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
u8 gCustomDebugMode;
@@ -409,7 +411,8 @@ void render_init(void) {
// Skip incrementing the initial framebuffer index on emulators so that they display immediately as the Gfx task finishes
// VC probably emulates osViSwapBuffer accurately so instant patch breaks VC compatibility
if (gIsConsole || gIsVC) { // Read RDP Clock Register, has a value of zero on emulators
// Currently, Ares passes the cache emulation test and has issues with single buffering so disable it there as well.
if (gIsConsole || gIsVC || gCacheEmulated) {
sRenderingFramebuffer++;
}
gGlobalTimer++;
@@ -447,8 +450,8 @@ void display_and_vsync(void) {
#ifndef UNLOCK_FPS
osRecvMesg(&gGameVblankQueue, &gMainReceivedMesg, OS_MESG_BLOCK);
#endif
// Skip swapping buffers on emulator so that they display immediately as the Gfx task finishes
if (gIsConsole || gIsVC) { // Read RDP Clock Register, has a value of zero on emulators
// Skip swapping buffers on inaccurate emulators other than VC so that they display immediately as the Gfx task finishes
if (gIsConsole || gIsVC || gCacheEmulated) {
if (++sRenderedFramebuffer == 3) {
sRenderedFramebuffer = 0;
}
@@ -725,10 +728,6 @@ void setup_game_memory(void) {
* Main game loop thread. Runs forever as long as the game continues.
*/
void thread5_game_loop(UNUSED void *arg) {
#if PUPPYPRINT_DEBUG
OSTime lastTime = 0;
#endif
setup_game_memory();
#if ENABLE_RUMBLE
init_rumble_pak_scheduler_queue();
@@ -758,19 +757,12 @@ void thread5_game_loop(UNUSED void *arg) {
render_init();
while (TRUE) {
profiler_frame_setup();
// If the reset timer is active, run the process to reset the game.
if (gResetTimer != 0) {
draw_reset_bars();
continue;
}
#if PUPPYPRINT_DEBUG
while (TRUE) {
lastTime = osGetTime();
collisionTime[perfIteration] = 0;
// graphTime[perfIteration] = 0;
behaviourTime[perfIteration] = 0;
dmaTime[perfIteration] = 0;
#endif
// If any controllers are plugged in, start read the data for when
// read_controller_inputs is called later.
@@ -784,25 +776,12 @@ void thread5_game_loop(UNUSED void *arg) {
audio_game_loop_tick();
select_gfx_pool();
read_controller_inputs(THREAD_5_GAME_LOOP);
profiler_update(PROFILER_TIME_CONTROLLERS);
addr = level_script_execute(addr);
#if !PUPPYPRINT_DEBUG && defined(VISUAL_DEBUG)
debug_box_input();
#endif
#if PUPPYPRINT_DEBUG
profiler_update(scriptTime, lastTime);
scriptTime[perfIteration] -= profilerTime[perfIteration];
scriptTime[perfIteration] -= profilerTime2[perfIteration];
if (benchmarkLoop > 0 && benchOption == 0) {
benchmarkLoop--;
benchMark[benchmarkLoop] = (osGetTime() - lastTime);
if (benchmarkLoop == 0) {
puppyprint_profiler_finished();
break;
}
} else {
break;
}
}
puppyprint_profiler_process();
#endif
+1
View File
@@ -48,6 +48,7 @@ extern u8 *gGfxPoolEnd;
extern struct GfxPool *gGfxPool;
extern u8 gControllerBits;
extern u8 gIsConsole;
extern u8 gCacheEmulated;
extern u8 gBorderHeight;
#ifdef VANILLA_STYLE_CUSTOM_DEBUG
extern u8 gCustomDebugMode;
+12 -13
View File
@@ -26,11 +26,6 @@
* cannon reticle, and the unused keys.
**/
#define HUD_POWER_METER_X 140
#define HUD_POWER_METER_EMPHASIZED_Y 166
#define HUD_POWER_METER_Y 200
#define HUD_POWER_METER_HIDDEN_Y 300
#ifdef BREATH_METER
// #ifdef DISABLE_LIVES
// #define HUD_BREATH_METER_X 64
@@ -52,6 +47,9 @@ u8 curFrameTimeIndex = 0;
#include "PR/os_convert.h"
#ifdef USE_PROFILER
float profiler_get_fps();
#else
// Call once per frame
f32 calculate_and_update_fps() {
OSTime newTime = osGetTime();
@@ -64,9 +62,14 @@ f32 calculate_and_update_fps() {
}
return ((f32)FRAMETIME_COUNT * 1000000.0f) / (s32)OS_CYCLES_TO_USEC(newTime - oldTime);
}
#endif
void print_fps(s32 x, s32 y) {
#ifdef USE_PROFILER
f32 fps = profiler_get_fps();
#else
f32 fps = calculate_and_update_fps();
#endif
char text[14];
sprintf(text, "FPS %2.2f", fps);
@@ -75,7 +78,6 @@ void print_fps(s32 x, s32 y) {
#else
print_text(x, y, text);
#endif
}
// ------------ END OF FPS COUNER -----------------
@@ -388,7 +390,6 @@ void render_hud_breath_meter(void) {
}
#endif
#define HUD_TOP_Y 209
/**
* Renders the amount of lives Mario has.
@@ -415,13 +416,11 @@ void render_debug_mode(void) {
* Renders the amount of coins collected.
*/
void render_hud_coins(void) {
print_text(168, HUD_TOP_Y, "$"); // 'Coin' glyph
print_text(184, HUD_TOP_Y, "*"); // 'X' glyph
print_text_fmt_int(198, HUD_TOP_Y, "%d", gHudDisplay.coins);
print_text(HUD_COINS_X, HUD_TOP_Y, "$"); // 'Coin' glyph
print_text((HUD_COINS_X + 16), HUD_TOP_Y, "*"); // 'X' glyph
print_text_fmt_int((HUD_COINS_X + 30), HUD_TOP_Y, "%d", gHudDisplay.coins);
}
#define HUD_STARS_X 78
/**
* Renders the amount of stars collected.
* Disables "X" glyph when Mario has 100 stars or more.
@@ -491,7 +490,7 @@ void set_hud_camera_status(s16 status) {
*/
void render_hud_camera_status(void) {
Texture *(*cameraLUT)[6] = segmented_to_virtual(&main_hud_camera_lut);
s32 x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(54);
s32 x = GFX_DIMENSIONS_RECT_FROM_RIGHT_EDGE(HUD_CAMERA_X);
s32 y = 205;
if (sCameraHUD.status == CAM_STATUS_NONE) {
+12
View File
@@ -4,6 +4,18 @@
#include <PR/ultratypes.h>
#include <PR/gbi.h>
#define HUD_POWER_METER_X 140
#define HUD_POWER_METER_EMPHASIZED_Y 166
#define HUD_POWER_METER_Y 200
#define HUD_POWER_METER_HIDDEN_Y 300
#define HUD_TOP_Y 209
#define HUD_BOTTOM_Y 19 // Same height as the Lakitu icon
#define HUD_COINS_X 168
#define HUD_STARS_X 78 // This starts counting from the right edge
#define HUD_CAMERA_X 54 // This starts counting from the right edge
enum PowerMeterAnimation {
POWER_METER_HIDDEN,
POWER_METER_EMPHASIZED,
+7 -3
View File
@@ -87,7 +87,6 @@ enum DialogBoxType {
#define DEFAULT_DIALOG_BOX_ANGLE 90.0f
#define DEFAULT_DIALOG_BOX_SCALE 19.0f
#if defined(VERSION_US) || defined(VERSION_EU)
u8 gDialogCharWidths[256] = { // TODO: Is there a way to auto generate this?
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 6, 6, 6, 6,
6, 6, 5, 6, 6, 5, 8, 8, 6, 6, 6, 6, 6, 5, 6, 6,
@@ -118,7 +117,6 @@ u8 gDialogCharWidths[256] = { // TODO: Is there a way to auto generate this?
#endif
0, 0, 5, 7, 7, 6, 6, 8, 0, 8, 10, 6, 4, 10, 0, 0
};
#endif
s8 gDialogBoxState = DIALOG_STATE_OPENING;
f32 gDialogBoxOpenTimer = DEFAULT_DIALOG_BOX_ANGLE;
@@ -1369,6 +1367,7 @@ void print_peach_letter_message(void) {
void **dialogTable;
gInGameLanguage = eu_get_language();
switch (gInGameLanguage) {
default:
case LANGUAGE_ENGLISH: dialogTable = segmented_to_virtual(dialog_table_eu_en); break;
case LANGUAGE_FRENCH: dialogTable = segmented_to_virtual(dialog_table_eu_fr); break;
case LANGUAGE_GERMAN: dialogTable = segmented_to_virtual(dialog_table_eu_de); break;
@@ -1388,10 +1387,15 @@ void print_peach_letter_message(void) {
gDPSetEnvColor(gDisplayListHead++, 20, 20, 20, gCutsceneMsgFade);
print_generic_string(STR_X, STR_Y, str);
#ifdef VERSION_JP
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
#else
gDPSetEnvColor(gDisplayListHead++, 255, 255, 255, 255);
gSPDisplayList(gDisplayListHead++, dl_ia_text_end);
gDPSetEnvColor(gDisplayListHead++, 200, 80, 120, gCutsceneMsgFade);
gSPDisplayList(gDisplayListHead++, castle_grounds_seg7_us_dl_0700F2E8);
#endif
// at the start/end of message, reset the fade.
if (gCutsceneMsgTimer == 0) {
@@ -1448,7 +1452,7 @@ void render_hud_cannon_reticle(void) {
gSPDisplayList(gDisplayListHead++, dl_draw_triangle);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
// gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
gSPPopMatrix(gDisplayListHead++, G_MTX_MODELVIEW);
}
void reset_red_coins_collected(void) {
-2
View File
@@ -112,11 +112,9 @@ enum DialogSpecialChars {
DIALOG_CHAR_I_NO_DIA = 0xEB, // 'i' without diacritic
DIALOG_CHAR_DOUBLE_LOW_QUOTE = 0xF0, // German opening quotation mark
#endif
#if defined(VERSION_US) || defined(VERSION_EU)
DIALOG_CHAR_SLASH = 0xD0,
DIALOG_CHAR_MULTI_THE = 0xD1, // 'the'
DIALOG_CHAR_MULTI_YOU = 0xD2, // 'you'
#endif
DIALOG_CHAR_PERIOD = 0x6E,
DIALOG_CHAR_COMMA = 0x6F,
DIALOG_CHAR_COLOR = 0xDF,
+6 -2
View File
@@ -764,10 +764,14 @@ u32 interact_star_or_key(struct MarioState *m, UNUSED u32 interactType, struct O
u32 starIndex;
u32 starGrabAction = ACT_STAR_DANCE_EXIT;
#ifdef NON_STOP_STARS
#ifdef KEYS_EXIT_LEVEL
u32 noExit = !obj_has_model(obj, MODEL_BOWSER_KEY);
#else
u32 noExit = TRUE;
#else
#endif
#else // !NON_STOP_STARS
u32 noExit = (obj->oInteractionSubtype & INT_SUBTYPE_NO_EXIT) != 0;
#endif
#endif // !NON_STOP_STARS
u32 grandStar = (obj->oInteractionSubtype & INT_SUBTYPE_GRAND_STAR) != 0;
if (m->health >= 0x100) {
+12
View File
@@ -65,6 +65,17 @@ const char *credits06[] = { "2COURSE DIRECTORS", "YOICHI YAMADA", "YASUHISA YAMA
const char *credits07[] = { "2COURSE DESIGNERS", "KENTA USUI", "NAOKI MORI" };
const char *credits08[] = { "3COURSE DESIGNERS", "YOSHIKI HARUHANA", "MAKOTO MIYANAGA", "KATSUHIKO KANNO" };
#ifdef VERSION_US
const char *credits09[] = { "1SOUND COMPOSER", "KOJI KONDO" };
// ...as well as sound effects and sound programmer in order to make room for screen text writer, Mario voice, and Peach voice
const char *credits10[] = { "4SOUND EFFECTS", "SOUND PROGRAMMER", "YOJI INAGAKI", "HIDEAKI SHIMIZU" };
const char *credits11[] = { "23-D ANIMATORS", "YOSHIAKI KOIZUMI", "SATORU TAKIZAWA" };
const char *credits12[] = { "1ADDITIONAL GRAPHICS", "MASANAO ARIMOTO" };
const char *credits13[] = { "3TECHNICAL SUPPORT", "TAKAO SAWANO", "HIROHITO YOSHIMOTO", "HIROTO YADA" };
const char *credits14[] = { "1TECHNICAL SUPPORT", "SGI N64 PROJECT STAFF" };
const char *credits15[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KATO" };
const char *credits16[] = { "5SCREEN TEXT WRITER", "TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" };
#else // VERSION_EU
// ...as well as sound composer, sound effects, and sound programmer, and...
const char *credits09[] = { "7SOUND COMPOSER", "SOUND EFFECTS", "SOUND PROGRAMMER", "KOJI KONDO", "YOJI INAGAKI", "HIDEAKI SHIMIZU" };
// ...3D animators and additional graphics in order to make room for screen text writer(s), Mario voice, and Peach voice
@@ -75,6 +86,7 @@ const char *credits13[] = { "2PROGRESS MANAGEMENT", "KIMIYOSHI FUKUI", "KEIZO KA
const char *credits14[] = { "5SCREEN TEXT WRITER", "ENGLISH TRANSLATION", "LESLIE SWAN", "MINA AKINO", "HIRO YAMADA" };
const char *credits15[] = { "4SCREEN TEXT WRITER", "FRENCH TRANSLATION", "JULIEN BARDAKOFF", "KENJI HARAGUCHI" };
const char *credits16[] = { "4SCREEN TEXT WRITER", "GERMAN TRANSLATION", "THOMAS GOERG", "THOMAS SPINDLER" };
#endif
#endif
+8 -23
View File
@@ -28,7 +28,7 @@ void play_far_fall_sound(struct MarioState *m) {
u32 action = m->action;
if (!(action & ACT_FLAG_INVULNERABLE) && action != ACT_TWIRLING && action != ACT_FLYING
&& !(m->flags & MARIO_FALL_SOUND_PLAYED)) {
if (m->peakHeight - m->pos[1] > 1150.0f) {
if (m->peakHeight - m->pos[1] > FALL_DAMAGE_HEIGHT_SMALL) {
play_sound(SOUND_MARIO_WAAAOOOW, m->marioObj->header.gfx.cameraToObject);
m->flags |= MARIO_FALL_SOUND_PLAYED;
}
@@ -63,30 +63,14 @@ s32 check_fall_damage(struct MarioState *m, u32 hardFallAction) {
#ifdef NO_FALL_DAMAGE
return FALSE;
#endif
f32 fallHeight;
f32 damageHeight;
fallHeight = m->peakHeight - m->pos[1];
f32 fallHeight = m->peakHeight - m->pos[1];
#pragma GCC diagnostic push
#if defined(__clang__)
#pragma GCC diagnostic ignored "-Wtautological-constant-out-of-range-compare"
#elif defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wtype-limits"
#endif
//! Never true
if (m->actionState == ACT_GROUND_POUND) {
damageHeight = 600.0f;
} else {
damageHeight = 1150.0f;
}
#pragma GCC diagnostic pop
f32 damageHeight = FALL_DAMAGE_HEIGHT_SMALL;
if (m->action != ACT_TWIRLING && m->floor->type != SURFACE_BURNING) {
if (m->vel[1] < -55.0f) {
if (fallHeight > 3000.0f) {
if (fallHeight > FALL_DAMAGE_HEIGHT_LARGE) {
m->hurtCounter += (m->flags & MARIO_CAP_ON_HEAD) ? 16 : 24;
#if ENABLE_RUMBLE
queue_rumble_data(5, 80);
@@ -116,11 +100,12 @@ s32 check_kick_or_dive_in_air(struct MarioState *m) {
return FALSE;
}
s32 should_get_stuck_in_ground(struct MarioState *m) {
#ifdef NO_GETTING_BURIED
s32 should_get_stuck_in_ground(UNUSED struct MarioState *m) {
return FALSE;
}
#else
s32 should_get_stuck_in_ground(struct MarioState *m) {
u32 terrainType = m->area->terrainType & TERRAIN_MASK;
struct Surface *floor = m->floor;
s32 flags = floor->flags;
@@ -134,8 +119,8 @@ s32 should_get_stuck_in_ground(struct MarioState *m) {
}
return FALSE;
#endif
}
#endif
s32 check_fall_damage_or_get_stuck(struct MarioState *m, u32 hardFallAction) {
if (should_get_stuck_in_ground(m)) {
+15 -3
View File
@@ -582,15 +582,27 @@ s32 act_debug_free_move(struct MarioState *m) {
}
void general_star_dance_handler(struct MarioState *m, s32 isInWater) {
struct Object *celebStar = NULL;
if (m->actionState == ACT_STATE_STAR_DANCE_CUTSCENE) {
switch (++m->actionTimer) {
case 1:
spawn_object(m->marioObj, MODEL_STAR, bhvCelebrationStar);
celebStar = spawn_object(m->marioObj, MODEL_STAR, bhvCelebrationStar);
#ifdef STAR_DANCE_USES_STARS_MODEL
celebStar->header.gfx.sharedChild = m->interactObj->header.gfx.sharedChild;
#else
if (obj_has_model(m->interactObj, MODEL_BOWSER_KEY)) {
obj_set_model(celebStar, MODEL_BOWSER_KEY);
}
#endif
disable_background_sound();
//! TODO: Is this check necessary? Both seem to do the exact same thing.
if (m->actionArg & 1) {
play_course_clear();
// No exit
play_course_clear(obj_has_model(celebStar, MODEL_BOWSER_KEY));
} else {
if (gCurrLevelNum == LEVEL_BOWSER_1 || gCurrLevelNum == LEVEL_BOWSER_2) {
// Exit
if (obj_has_model(celebStar, MODEL_BOWSER_KEY)) {
play_music(SEQ_PLAYER_ENV, SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_COLLECT_KEY), 0);
} else {
play_music(SEQ_PLAYER_ENV, SEQUENCE_ARGS(15, SEQ_EVENT_CUTSCENE_COLLECT_STAR), 0);
Binary file not shown.
+12 -20
View File
@@ -21,6 +21,7 @@
#include "spawn_object.h"
#include "puppyprint.h"
#include "puppylights.h"
#include "profiling.h"
/**
@@ -547,7 +548,10 @@ void clear_objects(void) {
*/
void update_terrain_objects(void) {
gObjectCounter = update_objects_in_list(&gObjectLists[OBJ_LIST_SPAWNER]);
profiler_update(PROFILER_TIME_SPAWNER);
gObjectCounter += update_objects_in_list(&gObjectLists[OBJ_LIST_SURFACE]);
profiler_update(PROFILER_TIME_DYNAMIC);
}
/**
@@ -559,7 +563,13 @@ void update_non_terrain_objects(void) {
s32 i = 2;
while ((listIndex = sObjectListUpdateOrder[i]) != -1) {
if (listIndex == OBJ_LIST_PLAYER) {
profiler_update(PROFILER_TIME_BEHAVIOR_BEFORE_MARIO);
}
gObjectCounter += update_objects_in_list(&gObjectLists[listIndex]);
if (listIndex == OBJ_LIST_PLAYER) {
profiler_update(PROFILER_TIME_MARIO);
}
i++;
}
}
@@ -606,13 +616,6 @@ UNUSED static u16 unused_get_elapsed_time(u64 *cycleCounts, s32 index) {
* and object surface management.
*/
void update_objects(UNUSED s32 unused) {
//s64 cycleCounts[30];
#if PUPPYPRINT_DEBUG
OSTime first = osGetTime();
OSTime colTime = collisionTime[perfIteration];
#endif
// cycleCounts[0] = get_current_clock();
gTimeStopState &= ~TIME_STOP_MARIO_OPENED_DOOR;
@@ -626,11 +629,9 @@ void update_objects(UNUSED s32 unused) {
gObjectLists = gObjectListArray;
// If time stop is not active, unload object surfaces
// cycleCounts[1] = get_clock_difference(cycleCounts[0]);
clear_dynamic_surfaces();
// Update spawners and objects with surfaces
// cycleCounts[2] = get_clock_difference(cycleCounts[0]);
update_terrain_objects();
// If Mario was touching a moving platform at the end of last frame, apply
@@ -640,24 +641,17 @@ void update_objects(UNUSED s32 unused) {
apply_mario_platform_displacement();
// Detect which objects are intersecting
// cycleCounts[3] = get_clock_difference(cycleCounts[0]);
detect_object_collisions();
// Update all other objects that haven't been updated yet
// cycleCounts[4] = get_clock_difference(cycleCounts[0]);
update_non_terrain_objects();
// Unload any objects that have been deactivated
// cycleCounts[5] = get_clock_difference(cycleCounts[0]);
unload_deactivated_objects();
// Check if Mario is on a platform object and save this object
// cycleCounts[6] = get_clock_difference(cycleCounts[0]);
update_mario_platform();
// cycleCounts[7] = get_clock_difference(cycleCounts[0]);
// cycleCounts[0] = 0;
try_print_debug_mario_object_info();
// If time stop was enabled this frame, activate it now so that it will
@@ -669,8 +663,6 @@ void update_objects(UNUSED s32 unused) {
}
gPrevFrameObjectCount = gObjectCounter;
#if PUPPYPRINT_DEBUG
profiler_update(behaviourTime, first);
behaviourTime[perfIteration] -= collisionTime[perfIteration] - colTime;
#endif
profiler_update(PROFILER_TIME_BEHAVIOR_AFTER_MARIO);
}
+279
View File
@@ -0,0 +1,279 @@
#include <ultra64.h>
#include <PR/os_internal_reg.h>
#include "game_init.h"
#include "profiling.h"
#include "fasttext.h"
#ifdef USE_PROFILER
#define RDP_CYCLE_CONV(x) ((10 * (x)) / 625) // 62.5 million cycles per frame
typedef struct {
u32 counts[PROFILING_BUFFER_SIZE];
u32 total;
} ProfileTimeData;
ProfileTimeData all_profiling_data[PROFILER_TIME_COUNT];
int profile_buffer_index = -1;
int rsp_buffer_indices[PROFILER_RSP_COUNT];
// Holds either the start time if the task is running, or the amount of time the task has run for so far if yielded
u32 rsp_pending_times[PROFILER_RSP_COUNT];
u32 prev_start;
u32 start;
u32 prev_time;
u32 audio_start;
u32 audio_buffer_index;
u32 preempted_time;
static void buffer_update(ProfileTimeData* data, u32 new, int buffer_index) {
u32 old = data->counts[buffer_index];
data->total -= old;
data->total += new;
data->counts[buffer_index] = new;
}
void profiler_update(enum ProfilerTime which) {
u32 cur_time = osGetCount();
u32 diff;
ProfileTimeData* cur_data = &all_profiling_data[which];
diff = cur_time - prev_time;
u32 saved = __osDisableInt();
u32 cur_preempted_time = preempted_time;
preempted_time = 0;
__osRestoreInt(saved);
if (cur_preempted_time > 0) {
diff -= cur_preempted_time;
start += cur_preempted_time;
}
buffer_update(cur_data, diff, profile_buffer_index);
prev_time = cur_time;
}
void profiler_rsp_started(enum ProfilerRSPTime which) {
rsp_pending_times[which] = osGetCount();
}
void profiler_rsp_completed(enum ProfilerRSPTime which) {
ProfileTimeData* cur_data = &all_profiling_data[PROFILER_TIME_RSP_GFX + which];
int cur_index = rsp_buffer_indices[which];
u32 time = osGetCount() - rsp_pending_times[which];
rsp_pending_times[which] = 0;
buffer_update(cur_data, time, cur_index);
cur_index++;
if (cur_index >= PROFILING_BUFFER_SIZE) {
cur_index = 0;
}
rsp_buffer_indices[which] = cur_index;
}
void profiler_rsp_resumed() {
rsp_pending_times[PROFILER_RSP_GFX] = osGetCount() - rsp_pending_times[PROFILER_RSP_GFX];
}
// This ends up being the same math as resumed, so we just use resumed for both
// void profiler_rsp_yielded() {
// rsp_pending_times[PROFILER_RSP_GFX] = osGetCount() - rsp_pending_times[PROFILER_RSP_GFX];
// }
void profiler_audio_started() {
audio_start = osGetCount();
}
void profiler_audio_completed() {
ProfileTimeData* cur_data = &all_profiling_data[PROFILER_TIME_AUDIO];
u32 time = osGetCount() - audio_start;
u32 cur_index = audio_buffer_index;
preempted_time = time;
buffer_update(cur_data, time, cur_index);
cur_index++;
if (cur_index >= PROFILING_BUFFER_SIZE) {
cur_index = 0;
}
audio_buffer_index = cur_index;
}
static void update_fps_timer() {
u32 diff = start - prev_start;
buffer_update(&all_profiling_data[PROFILER_TIME_FPS], diff, profile_buffer_index);
prev_start = start;
}
static void update_total_timer() {
u32 saved = __osDisableInt();
u32 cur_preempted_time = preempted_time;
preempted_time = 0;
__osRestoreInt(saved);
prev_time = start + cur_preempted_time;
profiler_update(PROFILER_TIME_TOTAL);
}
static void update_rdp_timers() {
u32 tmem = IO_READ(DPC_TMEM_REG);
u32 cmd = IO_READ(DPC_BUFBUSY_REG);
u32 pipe = IO_READ(DPC_PIPEBUSY_REG);
if (gGlobalTimer > 5) {
IO_WRITE(DPC_STATUS_REG, (DPC_CLR_CLOCK_CTR | DPC_CLR_CMD_CTR | DPC_CLR_PIPE_CTR | DPC_CLR_TMEM_CTR));
}
buffer_update(&all_profiling_data[PROFILER_TIME_TMEM], tmem, profile_buffer_index);
buffer_update(&all_profiling_data[PROFILER_TIME_CMD], cmd, profile_buffer_index);
buffer_update(&all_profiling_data[PROFILER_TIME_PIPE], pipe, profile_buffer_index);
}
#ifdef PUPPYPRINT_DEBUG
extern u8 sPPDebugPage;
extern u8 fDebug;
#endif
float profiler_get_fps() {
return (1000000.0f * PROFILING_BUFFER_SIZE) / (OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_FPS].total));
}
u32 profiler_get_cpu_cycles() {
u32 cpu_normal_time = all_profiling_data[PROFILER_TIME_TOTAL].total / PROFILING_BUFFER_SIZE;
u32 cpu_audio_time = all_profiling_data[PROFILER_TIME_AUDIO].total / PROFILING_BUFFER_SIZE;
return cpu_normal_time + cpu_audio_time * 2;
}
u32 profiler_get_rsp_cycles() {
u32 rsp_graphics_time = all_profiling_data[PROFILER_TIME_RSP_GFX].total / PROFILING_BUFFER_SIZE;
u32 rsp_audio_time = all_profiling_data[PROFILER_TIME_RSP_AUDIO].total / PROFILING_BUFFER_SIZE;
return rsp_graphics_time + rsp_audio_time;
}
u32 profiler_get_rdp_cycles() {
u32 rdp_pipe_cycles = all_profiling_data[PROFILER_TIME_PIPE].total;
u32 rdp_tmem_cycles = all_profiling_data[PROFILER_TIME_TMEM].total;
u32 rdp_cmd_cycles = all_profiling_data[PROFILER_TIME_CMD].total;
u32 rdp_max_cycles = MAX(MAX(rdp_pipe_cycles, rdp_tmem_cycles), rdp_cmd_cycles);
return rdp_max_cycles / PROFILING_BUFFER_SIZE;
}
u32 profiler_get_cpu_microseconds() {
u32 cpu_normal_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_TOTAL].total / PROFILING_BUFFER_SIZE);
u32 cpu_audio_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_AUDIO].total / PROFILING_BUFFER_SIZE);
return cpu_normal_time + cpu_audio_time * 2;
}
u32 profiler_get_rsp_microseconds() {
u32 rsp_graphics_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_RSP_GFX].total / PROFILING_BUFFER_SIZE);
u32 rsp_audio_time = OS_CYCLES_TO_USEC(all_profiling_data[PROFILER_TIME_RSP_AUDIO].total / PROFILING_BUFFER_SIZE);
return rsp_graphics_time + rsp_audio_time;
}
u32 profiler_get_rdp_microseconds() {
u32 rdp_pipe_cycles = all_profiling_data[PROFILER_TIME_PIPE].total;
u32 rdp_tmem_cycles = all_profiling_data[PROFILER_TIME_TMEM].total;
u32 rdp_cmd_cycles = all_profiling_data[PROFILER_TIME_CMD].total;
u32 rdp_max_cycles = MAX(MAX(rdp_pipe_cycles, rdp_tmem_cycles), rdp_cmd_cycles);
return RDP_CYCLE_CONV(rdp_max_cycles / PROFILING_BUFFER_SIZE);
}
void profiler_print_times() {
u32 microseconds[PROFILER_TIME_COUNT];
char text_buffer[196];
update_fps_timer();
update_total_timer();
update_rdp_timers();
#ifndef PUPPYPRINT_DEBUG
static u8 show_profiler = 0;
if (gPlayer1Controller->buttonPressed & L_TRIG) {
show_profiler ^= 1;
}
#endif
#ifdef PUPPYPRINT_DEBUG
if (fDebug && sPPDebugPage == 0) {
#else
if (show_profiler) {
#endif
for (int i = 0; i < PROFILER_TIME_COUNT; i++) {
if (i < PROFILER_TIME_TMEM) {
microseconds[i] = OS_CYCLES_TO_USEC(all_profiling_data[i].total / PROFILING_BUFFER_SIZE);
} else {
microseconds[i] = RDP_CYCLE_CONV(all_profiling_data[i].total / PROFILING_BUFFER_SIZE);
}
}
// audio time is removed from the main thread profiling, so add it back here
u32 total_cpu = microseconds[PROFILER_TIME_TOTAL] + microseconds[PROFILER_TIME_AUDIO] * 2;
u32 total_rsp = microseconds[PROFILER_TIME_RSP_GFX] + microseconds[PROFILER_TIME_RSP_AUDIO];
u32 max_rdp = MAX(MAX(microseconds[PROFILER_TIME_TMEM], microseconds[PROFILER_TIME_CMD]), microseconds[PROFILER_TIME_PIPE]);
sprintf(text_buffer,
"FPS: %5.2f\n"
"\n"
"CPU\t\t%d (%d%%)\n"
" Input\t\t%d\n"
" Dynamic\t\t%d\n"
" Mario\t\t\t%d\n"
" Behavior\t\t%d\n"
" Graph\t\t%d\n"
" Audio\t\t\t%d\n"
"\n"
"RDP\t\t%d (%d%%)\n"
" Tmem\t\t\t%d\n"
" Cmd\t\t\t%d\n"
" Pipe\t\t\t%d\n"
"\n"
"RSP\t\t%d (%d%%)\n"
" Gfx\t\t\t%d\n"
" Audio\t\t\t%d\n",
1000000.0f / microseconds[PROFILER_TIME_FPS],
total_cpu, total_cpu / 333,
microseconds[PROFILER_TIME_CONTROLLERS],
microseconds[PROFILER_TIME_DYNAMIC],
microseconds[PROFILER_TIME_MARIO],
microseconds[PROFILER_TIME_BEHAVIOR_BEFORE_MARIO] + microseconds[PROFILER_TIME_BEHAVIOR_AFTER_MARIO],
microseconds[PROFILER_TIME_GFX],
microseconds[PROFILER_TIME_AUDIO] * 2, // audio is 60Hz, so double the average
max_rdp, max_rdp / 333,
microseconds[PROFILER_TIME_TMEM],
microseconds[PROFILER_TIME_CMD],
microseconds[PROFILER_TIME_PIPE],
total_rsp, total_rsp / 333,
microseconds[PROFILER_TIME_RSP_GFX],
microseconds[PROFILER_TIME_RSP_AUDIO]
);
Gfx* dlHead = gDisplayListHead;
gDPPipeSync(dlHead++);
gDPSetCycleType(dlHead++, G_CYC_1CYCLE);
gDPSetRenderMode(dlHead++, G_RM_TEX_EDGE, G_RM_TEX_EDGE2);
gDPSetTexturePersp(dlHead++, G_TP_NONE);
gDPSetTextureFilter(dlHead++, G_TF_POINT);
gDPSetTextureLUT(dlHead++, G_TT_NONE);
drawSmallStringCol(&dlHead, 10, 10, text_buffer, 255, 255, 255);
gDisplayListHead = dlHead;
}
}
void profiler_frame_setup() {
profile_buffer_index++;
preempted_time = 0;
if (profile_buffer_index >= PROFILING_BUFFER_SIZE) {
profile_buffer_index = 0;
}
prev_time = start = osGetCount();
}
#endif
+61
View File
@@ -0,0 +1,61 @@
#ifndef __PROFILING_H__
#define __PROFILING_H__
#include <ultra64.h>
#include "macros.h"
#include "config/config_debug.h"
#include "config/config_safeguards.h"
#define PROFILING_BUFFER_SIZE 64
enum ProfilerTime {
PROFILER_TIME_FPS,
PROFILER_TIME_CONTROLLERS,
PROFILER_TIME_SPAWNER,
PROFILER_TIME_DYNAMIC,
PROFILER_TIME_BEHAVIOR_BEFORE_MARIO,
PROFILER_TIME_MARIO,
PROFILER_TIME_BEHAVIOR_AFTER_MARIO,
PROFILER_TIME_GFX,
PROFILER_TIME_AUDIO,
PROFILER_TIME_TOTAL,
PROFILER_TIME_RSP_GFX,
PROFILER_TIME_RSP_AUDIO,
PROFILER_TIME_TMEM,
PROFILER_TIME_PIPE,
PROFILER_TIME_CMD,
PROFILER_TIME_COUNT,
};
enum ProfilerRSPTime {
PROFILER_RSP_GFX,
PROFILER_RSP_AUDIO,
PROFILER_RSP_COUNT
};
#ifdef USE_PROFILER
void profiler_update(enum ProfilerTime which);
void profiler_print_times();
void profiler_frame_setup();
void profiler_rsp_started(enum ProfilerRSPTime which);
void profiler_rsp_completed(enum ProfilerRSPTime which);
void profiler_rsp_resumed();
void profiler_audio_started();
void profiler_audio_completed();
// See profiling.c to see why profiler_rsp_yielded isn't its own function
static ALWAYS_INLINE void profiler_rsp_yielded() {
profiler_rsp_resumed();
}
#else
#define profiler_update(which)
#define profiler_print_times()
#define profiler_frame_setup()
#define profiler_rsp_started(which)
#define profiler_rsp_completed(which)
#define profiler_rsp_resumed()
#define profiler_audio_started()
#define profiler_audio_completed()
#define profiler_rsp_yielded()
#endif
#endif
+2
View File
@@ -1204,6 +1204,8 @@ static void puppycam_script(void) {
gPuppyCam.yaw = volume.angles->yaw;
gPuppyCam.flags &= ~PUPPYCAM_BEHAVIOUR_YAW_ROTATION;
} else {
gPuppyCam.yaw = atan2s(gPuppyCam.pos[2] - gPuppyCam.focus[2], gPuppyCam.pos[0] - gPuppyCam.focus[0]);
}
if (volume.angles->pitch != PUPPY_NULL) {
+2 -2
View File
@@ -34,13 +34,13 @@
#include "include/command_macros_base.h"
#define PUPPYVOLUME(x, y, z, length, height, width, yaw, functionptr, anglesptr, addflags, removeflags, flagpersistance, room, shape, fov) \
CMD_BBH(0x3D, 0x24, x), \
CMD_BBH(0x3D, 0x28, x), \
CMD_HHHHHH(y, z, length, height, width, yaw), \
CMD_PTR(functionptr), \
CMD_PTR(anglesptr), \
CMD_W(addflags), \
CMD_W(removeflags), \
CMD_BBH(flagpersistance, shape, room) \
CMD_BBH(flagpersistance, shape, room), \
CMD_BBH(fov, 0x0, 0x0)
struct gPuppyOptions
+56 -191
View File
@@ -68,34 +68,9 @@ s32 benchmarkTimer = 0;
s32 benchmarkProgramTimer = 0;
s8 benchmarkType = 0;
// General
u32 cpuTime = 0;
u32 rspTime = 0;
u32 rdpTime = 0;
u32 ramTime = 0;
u32 loadTime = 0;
u32 gLastOSTime = 0;
u32 rspDelta = 0;
s32 benchMark[NUM_BENCH_ITERATIONS + 2];
// CPU
u32 collisionTime[NUM_PERF_ITERATIONS + 1];
u32 behaviourTime[NUM_PERF_ITERATIONS + 1];
u32 scriptTime[NUM_PERF_ITERATIONS + 1];
u32 graphTime[NUM_PERF_ITERATIONS + 1];
u32 audioTime[NUM_PERF_ITERATIONS + 1];
u32 dmaTime[NUM_PERF_ITERATIONS + 1];
u32 dmaAudioTime[NUM_PERF_ITERATIONS + 1];
u32 faultTime[NUM_PERF_ITERATIONS + 1];
u32 taskTime[NUM_PERF_ITERATIONS + 1];
u32 profilerTime[NUM_PERF_ITERATIONS + 1];
u32 profilerTime2[NUM_PERF_ITERATIONS + 1];
u32 cameraTime[NUM_PERF_ITERATIONS + 1];
// RSP
u32 audioTime[NUM_PERF_ITERATIONS + 1];
u32 rspGenTime[NUM_PERF_ITERATIONS + 1];
// RDP
u32 bufferTime[NUM_PERF_ITERATIONS + 1];
u32 tmemTime[NUM_PERF_ITERATIONS + 1];
u32 busTime[NUM_PERF_ITERATIONS + 1];
// RAM
s8 ramViewer = FALSE;
s32 ramsizeSegment[NUM_TLB_SEGMENTS + 1] = {
@@ -306,6 +281,7 @@ void print_ram_overview(void) {
sprintf(textBytes, "RAM: %06X/%06X (%d_)", main_pool_available(), mempool, (s32)(((f32)main_pool_available() / (f32)mempool) * 100));
print_small_text(SCREEN_CENTER_X, (SCREEN_HEIGHT - 16), textBytes, PRINT_TEXT_ALIGN_CENTRE, PRINT_ALL, FONT_OUTLINE);
puppyprint_calculate_ram_usage();
print_ram_bar();
}
@@ -477,12 +453,6 @@ extern s16 gVisualSurfaceCount;
void puppyprint_render_collision(void) {
char textBytes[200];
#ifdef PUPPYPRINT_DEBUG_CYCLES
sprintf(textBytes, "Collision:<COL_99505099> %dc", collisionTime[NUM_PERF_ITERATIONS]);
#else
sprintf(textBytes, "Collision:<COL_99505099> %dus", collisionTime[NUM_PERF_ITERATIONS]);
#endif
print_small_text(304, 48, textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, 1);
sprintf(textBytes, "Pool Size: %X#Node Size: %X#Surfaces Allocated: %d#Nodes Allocated: %d#Current Cell: %d", (SURFACE_NODE_POOL_SIZE * sizeof(struct SurfaceNode)), (SURFACE_POOL_SIZE * sizeof(struct Surface)),
gSurfacesAllocated, gSurfaceNodesAllocated, gVisualSurfaceCount);
@@ -512,55 +482,47 @@ void puppyprint_render_collision(void) {
#endif
}
struct CPUBar {
u32 *time;
ColorRGB colour;
const char str[32];
};
extern void print_fps(s32 x, s32 y);
struct CPUBar cpu_ordering_table[] = {
{ collisionTime, COLOR_RGB_RED, { "Collision: <COL_99505099>" }},
{ graphTime, COLOR_RGB_BLUE, { "Graph: <COL_50509999>" }},
{ behaviourTime, COLOR_RGB_GREEN, { "Behaviour: <COL_50995099>" }},
{ audioTime, COLOR_RGB_YELLOW, { "Audio: <COL_99995099>" }},
{ cameraTime, COLOR_RGB_CYAN, { "Camera: <COL_50999999>" }},
{ dmaTime, COLOR_RGB_MAGENTA, { "DMA: <COL_99509999>" }},
};
u32 profiler_get_cpu_cycles();
u32 profiler_get_rsp_cycles();
u32 profiler_get_rdp_cycles();
#define CPU_TABLE_MAX (sizeof(cpu_ordering_table) / sizeof(struct CPUBar))
#define ADDTIMES MAX(((collisionTime[MX] + graphTime[MX] + behaviourTime[MX] + audioTime[MX] + cameraTime[MX] + dmaTime[MX]) / 80), 1)
u32 profiler_get_cpu_microseconds();
u32 profiler_get_rsp_microseconds();
u32 profiler_get_rdp_microseconds();
void print_basic_profiling(void) {
u32 cpuTime;
u32 rspTime;
u32 rdpTime;
char textBytes[90];
print_fps(16, 40);
print_fps(16, 16);
#ifdef PUPPYPRINT_DEBUG_CYCLES
cpuTime = profiler_get_cpu_cycles();
rspTime = profiler_get_rsp_cycles();
rdpTime = profiler_get_rdp_cycles();
sprintf(textBytes, "CPU: %dc (%d_)#RSP: %dc (%d_)#RDP: %dc (%d_)",
cpuTime, (cpuTime / 15625),
rspTime, (rspTime / 15625),
rdpTime, (rdpTime / 15625));
#else
cpuTime = profiler_get_cpu_microseconds();
rspTime = profiler_get_rsp_microseconds();
rdpTime = profiler_get_rdp_microseconds();
sprintf(textBytes, "CPU: %dus (%d_)#RSP: %dus (%d_)#RDP: %dus (%d_)",
cpuTime, (cpuTime / 333),
rspTime, (rspTime / 333),
rdpTime, (rdpTime / 333));
#endif
print_small_text(16, 52, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
print_small_text(16, 28, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
}
void puppyprint_render_standard(void) {
s32 perfPercentage[CPU_TABLE_MAX];
s32 graphPos;
s32 prevGraph;
u32 i;
s32 viewedNums;
char textBytes[80];
print_basic_profiling();
sprintf(textBytes, "OBJ: %d/%d", gObjectCounter, OBJECT_POOL_CAPACITY);
print_small_text(16, 124, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
print_small_text((SCREEN_WIDTH - 16), 16, textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, FONT_OUTLINE);
#ifndef ENABLE_CREDITS_BENCHMARK
// Very little point printing useless info if Mario doesn't even exist.
@@ -571,7 +533,7 @@ void puppyprint_render_standard(void) {
(s32)(gMarioState->pos[2]),
(u16)(gMarioState->faceAngle[1]),
(u32)(gMarioState->action & ACT_ID_MASK));
print_small_text(16, 140, textBytes, PRINT_TEXT_ALIGN_LEFT, PRINT_ALL, FONT_OUTLINE);
print_small_text((SCREEN_WIDTH - 16), 32, textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, FONT_OUTLINE);
}
// Same for the camera, especially so because this will crash otherwise.
if (gCamera) {
@@ -584,64 +546,47 @@ void puppyprint_render_standard(void) {
}
#endif
// Just to keep screen estate a little friendlier.
#define MX NUM_PERF_ITERATIONS
for (i = 0; i < CPU_TABLE_MAX; i++) {
perfPercentage[i] = MAX((cpu_ordering_table[i].time[MX] / ADDTIMES), 0);
}
#undef ADDTIMES
#undef MX
// Old profiler bar code, can be restored one day if desired to work with new profiler
// s32 graphPos;
// s32 prevGraph;
// u32 i;
// s32 viewedNums;
viewedNums = 0;
for (i = 0; i < CPU_TABLE_MAX; i++) {
s32 num = cpu_ordering_table[i].time[NUM_PERF_ITERATIONS];
if (num != 0) {
#ifdef PUPPYPRINT_DEBUG_CYCLES
sprintf(textBytes, "%s%dc", cpu_ordering_table[i].str, num);
#else
sprintf(textBytes, "%s%dus", cpu_ordering_table[i].str, num);
#endif
print_small_text((SCREEN_WIDTH - 16), (40 + (viewedNums * 12)), textBytes, PRINT_TEXT_ALIGN_RIGHT, PRINT_ALL, FONT_OUTLINE);
viewedNums++;
}
}
// prepare_blank_box();
// viewedNums = 0;
s32 barY = (28 + (viewedNums * 12)) + 16;
prepare_blank_box();
viewedNums = 0;
// // Render CPU breakdown bar.
// for (i = 0; i < CPU_TABLE_MAX; i++) {
// if (perfPercentage[i] == 0
// && (i != CPU_TABLE_MAX - 1)) {
// continue;
// }
// Render CPU breakdown bar.
for (i = 0; i < CPU_TABLE_MAX; i++) {
if (perfPercentage[i] == 0
&& (i != CPU_TABLE_MAX - 1)) {
continue;
}
// if (viewedNums == 0) {
// graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
// render_blank_box((SCREEN_WIDTH - 96), barY, graphPos, (barY + 8),
// cpu_ordering_table[i].colour[0],
// cpu_ordering_table[i].colour[1],
// cpu_ordering_table[i].colour[2], 255);
// } else if (i == (CPU_TABLE_MAX - 1)) {
// graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
// render_blank_box(prevGraph, barY, (SCREEN_WIDTH - 16), (barY + 8),
// cpu_ordering_table[i].colour[0],
// cpu_ordering_table[i].colour[1],
// cpu_ordering_table[i].colour[2], 255);
// } else {
// graphPos += perfPercentage[i];
// render_blank_box(prevGraph, barY, graphPos, (barY + 8),
// cpu_ordering_table[i].colour[0],
// cpu_ordering_table[i].colour[1],
// cpu_ordering_table[i].colour[2], 255);
// }
if (viewedNums == 0) {
graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
render_blank_box((SCREEN_WIDTH - 96), barY, graphPos, (barY + 8),
cpu_ordering_table[i].colour[0],
cpu_ordering_table[i].colour[1],
cpu_ordering_table[i].colour[2], 255);
} else if (i == (CPU_TABLE_MAX - 1)) {
graphPos = ((SCREEN_WIDTH - 96) + perfPercentage[i]);
render_blank_box(prevGraph, barY, (SCREEN_WIDTH - 16), (barY + 8),
cpu_ordering_table[i].colour[0],
cpu_ordering_table[i].colour[1],
cpu_ordering_table[i].colour[2], 255);
} else {
graphPos += perfPercentage[i];
render_blank_box(prevGraph, barY, graphPos, (barY + 8),
cpu_ordering_table[i].colour[0],
cpu_ordering_table[i].colour[1],
cpu_ordering_table[i].colour[2], 255);
}
// viewedNums++;
// prevGraph = graphPos;
// }
viewedNums++;
prevGraph = graphPos;
}
finish_blank_box();
// finish_blank_box();
}
void puppyprint_render_minimal(void) {
@@ -686,12 +631,10 @@ void render_page_menu(void) {
}
void puppyprint_render_profiler(void) {
OSTime first = osGetTime();
print_set_envcolour(255, 255, 255, 255);
if (!fDebug) {
profiler_update(profilerTime, first);
return;
}
@@ -700,39 +643,9 @@ void puppyprint_render_profiler(void) {
if (sDebugMenu) {
render_page_menu();
}
profiler_update(profilerTime, first);
}
void profiler_update(u32 *time, OSTime time2) {
time[perfIteration] = (osGetTime() - time2);
}
void get_average_perf_time(u32 *time, s32 is_rdp) {
// This takes all but the last index of the timer array, and creates an average value, which is written to the last index.
s32 i = 0;
s32 total = 0;
for (i = 0; i < NUM_PERF_ITERATIONS; i++) {
total += time[i];
}
total /= NUM_PERF_ITERATIONS;
total = MAX(total, 0);
if (is_rdp)
{
time[NUM_PERF_ITERATIONS] = RDP_CYCLE_CONV(total);
}
else
{
time[NUM_PERF_ITERATIONS] = CYCLE_CONV(total);
}
}
void puppyprint_profiler_process(void) {
bufferTime[perfIteration] = (IO_READ(DPC_BUFBUSY_REG));
tmemTime[perfIteration] = (IO_READ(DPC_TMEM_REG));
busTime[perfIteration] = (IO_READ(DPC_PIPEBUSY_REG));
OSTime newTime = osGetTime();
if (fDebug && (gPlayer1Controller->buttonPressed & L_TRIG)) {
sDebugMenu ^= TRUE;
if (sDebugMenu == FALSE) {
@@ -760,54 +673,6 @@ void puppyprint_profiler_process(void) {
sDebugOption = 0;
}
}
if (!(gGlobalTimer % NUM_PERF_ITERATIONS)) {
get_average_perf_time( scriptTime, FALSE);
get_average_perf_time( behaviourTime, FALSE);
get_average_perf_time( collisionTime, FALSE);
get_average_perf_time( graphTime, FALSE);
get_average_perf_time( audioTime, FALSE);
get_average_perf_time( dmaTime, FALSE);
get_average_perf_time( dmaAudioTime, FALSE);
get_average_perf_time( faultTime, FALSE);
get_average_perf_time( taskTime, FALSE);
get_average_perf_time( profilerTime, FALSE);
get_average_perf_time( profilerTime2, FALSE);
get_average_perf_time( cameraTime, FALSE);
// Performed twice a frame without fail, so doubled to have a more representative value.
audioTime[NUM_PERF_ITERATIONS] *= 2;
dmaAudioTime[NUM_PERF_ITERATIONS] *= 2;
dmaTime[NUM_PERF_ITERATIONS] += dmaAudioTime[NUM_PERF_ITERATIONS];
get_average_perf_time(rspGenTime, FALSE);
get_average_perf_time(bufferTime, TRUE);
get_average_perf_time( tmemTime, TRUE);
get_average_perf_time( busTime, TRUE);
rdpTime = bufferTime[NUM_PERF_ITERATIONS];
rdpTime = MAX(rdpTime, tmemTime[NUM_PERF_ITERATIONS]);
rdpTime = MAX(rdpTime, busTime[NUM_PERF_ITERATIONS]);
#if BBPLAYER == 1 // iQue RDP registers need to be halved to be correct.
rdpTime /= 2;
#endif
cpuTime = (scriptTime[NUM_PERF_ITERATIONS]
+ taskTime[NUM_PERF_ITERATIONS]
+ faultTime[NUM_PERF_ITERATIONS]
+ audioTime[NUM_PERF_ITERATIONS]);
rspTime = rspGenTime[NUM_PERF_ITERATIONS];
puppyprint_calculate_ram_usage();
}
gLastOSTime = newTime;
if (gGlobalTimer > 5) {
IO_WRITE(DPC_STATUS_REG, (DPC_CLR_CLOCK_CTR | DPC_CLR_CMD_CTR | DPC_CLR_PIPE_CTR | DPC_CLR_TMEM_CTR));
}
if (perfIteration++ == (NUM_PERF_ITERATIONS - 1)) {
perfIteration = 0;
}
profiler_update(profilerTime2, newTime);
}
#endif
+1 -36
View File
@@ -2,17 +2,9 @@
#include "segment2.h"
// This is how many indexes of timers are saved at once. higher creates a smoother average, but naturally uses more RAM. 15's fine.
// #define NUM_PERF_ITERATIONS 15
#define NUM_PERF_ITERATIONS 16
#define NUM_BENCH_ITERATIONS 150
#define LOG_BUFFER_SIZE 16
#ifdef ENABLE_CREDITS_BENCHMARK
#undef NUM_PERF_ITERATIONS
#define NUM_PERF_ITERATIONS 60
#endif
struct PuppyPrintPage{
void (*func)();
char name[32];
@@ -58,35 +50,8 @@ extern s32 mempool;
extern u8 benchOption;
// General
extern u32 cpuTime;
extern u32 rspTime;
extern u32 rdpTime;
extern u32 ramTime;
extern u32 loadTime;
extern u32 rspDelta;
extern s32 benchMark[NUM_BENCH_ITERATIONS + 2];
extern s32 benchMark[NUM_BENCH_ITERATIONS + 2];
// CPU
extern u32 collisionTime[NUM_PERF_ITERATIONS + 1];
extern u32 behaviourTime[NUM_PERF_ITERATIONS + 1];
extern u32 scriptTime[NUM_PERF_ITERATIONS + 1];
extern u32 graphTime[NUM_PERF_ITERATIONS + 1];
extern u32 audioTime[NUM_PERF_ITERATIONS + 1];
extern u32 dmaTime[NUM_PERF_ITERATIONS + 1];
extern u32 dmaAudioTime[NUM_PERF_ITERATIONS + 1];
extern u32 faultTime[NUM_PERF_ITERATIONS + 1];
extern u32 taskTime[NUM_PERF_ITERATIONS + 1];
extern u32 cameraTime[NUM_PERF_ITERATIONS + 1];
extern u32 profilerTime[NUM_PERF_ITERATIONS + 1];
extern u32 profilerTime2[NUM_PERF_ITERATIONS + 1];
// RSP
extern u32 rspGenTime[NUM_PERF_ITERATIONS + 1];
// RDP
extern u32 bufferTime[NUM_PERF_ITERATIONS + 1];
extern u32 tmemTime[NUM_PERF_ITERATIONS + 1];
extern u32 busTime[NUM_PERF_ITERATIONS + 1];
extern void profiler_update(u32 *time, OSTime time2);
extern void puppyprint_profiler_process(void);
extern void puppyprint_render_profiler(void);
extern void puppyprint_profiler_finished(void);
+1 -1
View File
@@ -248,7 +248,7 @@ void switch_ucode(s32 ucode) {
switch (ucode) {
default: // GRAPH_NODE_UCODE_DEFAULT
case GRAPH_NODE_UCODE_DEFAULT:
gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_PosLight_fifo); // F3DZEX2_PosLight
gSPLoadUcodeL(gDisplayListHead++, gspF3DZEX2_NoN_PosLight_fifo); // F3DZEX2_PosLight
// Reload the necessary RSP settings
gSPDisplayList(gDisplayListHead++, init_rsp);
break;
+9 -10
View File
@@ -368,16 +368,6 @@ void save_file_load_all(void) {
}
#ifdef PUPPYCAM
void puppycam_check_save(void) {
if (gSaveBuffer.menuData.firstBoot != 4
|| gSaveBuffer.menuData.saveOptions.sensitivityX < 5
|| gSaveBuffer.menuData.saveOptions.sensitivityY < 5) {
wipe_main_menu_data();
gSaveBuffer.menuData.firstBoot = 4;
puppycam_default_config();
}
}
void puppycam_get_save(void) {
gPuppyCam.options = gSaveBuffer.menuData.saveOptions;
@@ -401,6 +391,15 @@ void puppycam_set_save(void) {
gMainMenuDataModified = TRUE;
save_main_menu_data();
}
void puppycam_check_save(void) {
if (gSaveBuffer.menuData.firstBoot != 4) {
wipe_main_menu_data();
gSaveBuffer.menuData.firstBoot = 4;
puppycam_default_config();
puppycam_set_save();
}
}
#endif
/**
+8
View File
@@ -12,6 +12,14 @@
*/
enum ShadowType {
#ifdef LEGACY_SHADOW_IDS
LEGACY_SHADOW_CIRCLE_9_VERTS = 0,
LEGACY_SHADOW_CIRCLE_4_VERTS = 1,
LEGACY_SHADOW_CIRCLE_4_VERTS_FLAT_UNUSED = 2,
LEGACY_SHADOW_SQUARE_PERMANENT = 10,
LEGACY_SHADOW_SQUARE_SCALABLE = 11,
LEGACY_SHADOW_SQUARE_TOGGLABLE = 12,
LEGACY_SHADOW_CIRCLE_PLAYER = 99,
SHADOW_CIRCLE = 5,
SHADOW_CIRCLE_PLAYER = SHADOW_CIRCLE,
SHADOW_CIRCLE_4_VERTS = SHADOW_CIRCLE,
+3 -1
View File
@@ -61,7 +61,7 @@ struct Skybox {
struct Skybox sSkyBoxInfo[2];
typedef const Texture *const SkyboxTexture[80 * SKYBOX_SIZE];
typedef const Texture *const SkyboxTexture[80 * sqr(SKYBOX_SIZE)];
extern SkyboxTexture bbh_skybox_ptrlist;
extern SkyboxTexture bidw_skybox_ptrlist;
@@ -290,10 +290,12 @@ Gfx *create_skybox_facing_camera(s8 player, s8 background, f32 fov, Vec3f pos, V
s8 colorIndex = 1;
// If the "Plunder in the Sunken Ship" star in JRB is collected, make the sky darker and slightly green
#ifdef ENABLE_VANILLA_LEVEL_SPECIFIC_CHECKS
if (background == BACKGROUND_ABOVE_CLOUDS
&& !(save_file_get_star_flags(gCurrSaveFileNum - 1, COURSE_NUM_TO_INDEX(COURSE_JRB)) & STAR_FLAG_ACT_1)) {
colorIndex = 0;
}
#endif
//! fov is always set to 90.0f. If this line is removed, then the game crashes because fov is 0 on
//! the first frame, which causes a floating point divide by 0
+8 -31
View File
@@ -15,6 +15,7 @@
#include "sound_init.h"
#include "rumble_init.h"
#include "puppyprint.h"
#include "profiling.h"
#include "config/config_audio.h"
@@ -359,10 +360,6 @@ void thread4_sound(UNUSED void *arg) {
audio_init();
sound_init();
#if PUPPYPRINT_DEBUG
OSTime lastTime;
#endif
osCreateMesgQueue(&sSoundMesgQueue, sSoundMesgBuf, ARRAY_COUNT(sSoundMesgBuf));
set_vblank_handler(1, &sSoundVblankHandler, &sSoundMesgQueue, (OSMesg) 512);
@@ -370,34 +367,14 @@ void thread4_sound(UNUSED void *arg) {
OSMesg msg;
osRecvMesg(&sSoundMesgQueue, &msg, OS_MESG_BLOCK);
#if PUPPYPRINT_DEBUG
while (TRUE) {
lastTime = osGetTime();
dmaAudioTime[perfIteration] = 0;
#endif
if (gResetTimer < 25) {
struct SPTask *spTask;
spTask = create_next_audio_frame_task();
if (spTask != NULL) {
dispatch_audio_sptask(spTask);
}
#if PUPPYPRINT_DEBUG
profiler_update(audioTime, lastTime);
audioTime[perfIteration] -= dmaAudioTime[perfIteration];
if (benchmarkLoop > 0 && benchOption == 1) {
benchmarkLoop--;
benchMark[benchmarkLoop] = osGetTime() - lastTime;
if (benchmarkLoop == 0) {
puppyprint_profiler_finished();
break;
}
} else {
break;
}
#endif
profiler_audio_started();
if (gResetTimer < 25) {
struct SPTask *spTask;
spTask = create_next_audio_frame_task();
if (spTask != NULL) {
dispatch_audio_sptask(spTask);
}
#if PUPPYPRINT_DEBUG
}
#endif
profiler_audio_completed();
}
}
+2 -1
View File
@@ -1,7 +1,8 @@
#include "version.h"
#include "src/game/version_data.h"
#if 0 // if your PC username isn't your real name feel free to uncomment
char __username__[] = __USERNAME__;
char __datetime__[] = __DATETIME__;
#endif
char __compiler__[] = __COMPILER__;
char __linker__[] = __LINKER__;
+2 -1
View File
@@ -1,8 +1,9 @@
#ifndef VER_H
#define VER_H
#if 0 // if your PC username isn't your real name feel free to uncomment
extern char __username__[];
extern char __datetime__[];
#endif
extern char __compiler__[];
extern char __linker__[];