Get rumble pak mostly working
This commit is contained in:
parent
9f14d9aac2
commit
1ef301c15e
|
@ -4,6 +4,7 @@
|
|||
#include "util/memory.h"
|
||||
#include <sched.h>
|
||||
#include "rumble_pak.h"
|
||||
#include "../util/profile.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
@ -119,17 +120,17 @@ int controllerHandleMessage() {
|
|||
gRumblePakState = RumblepakStateInitialized;
|
||||
} else {
|
||||
gRumblePakState = RumblepakStateDisconnected;
|
||||
gRumblePakOn = 0;
|
||||
}
|
||||
} if (gControllerStatus[0].status != CONT_CARD_ON) {
|
||||
gRumblePakState = RumblepakStateDisconnected;
|
||||
gRumblePakOn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
u8 gRumbleFailCount;
|
||||
|
||||
void controllersReadPendingData(void) {
|
||||
OSMesg msg;
|
||||
int shouldCheckStatus;
|
||||
|
@ -142,6 +143,8 @@ void controllersReadPendingData(void) {
|
|||
|
||||
int targetRumbleStatus = rumblePakCalculateState();
|
||||
|
||||
u64 timeStart = profileStart();
|
||||
|
||||
if (gRumblePakState == RumblepakStateInitialized) {
|
||||
if (targetRumbleStatus != gRumblePakOn) {
|
||||
shouldCheckStatus = FALSE;
|
||||
|
@ -150,16 +153,30 @@ void controllersReadPendingData(void) {
|
|||
s32 rumbleError = targetRumbleStatus ? osMotorStart(&gRumbleBackFs) : osMotorStop(&gRumbleBackFs);
|
||||
|
||||
if (rumbleError == PFS_ERR_CONTRFAIL) {
|
||||
continue;
|
||||
if (i == 2) {
|
||||
++gRumbleFailCount;
|
||||
}
|
||||
} else if (rumbleError != 0) {
|
||||
gRumblePakState = RumblepakStateDisconnected;
|
||||
gRumblePakOn = 0;
|
||||
break;
|
||||
} else {
|
||||
gRumblePakOn = targetRumbleStatus;
|
||||
break;
|
||||
gRumbleFailCount = 0;
|
||||
}
|
||||
}
|
||||
} else if (!targetRumbleStatus) {
|
||||
osMotorStop(&gRumbleBackFs);
|
||||
}
|
||||
}
|
||||
|
||||
profileEnd(timeStart, 2);
|
||||
|
||||
if (gRumbleFailCount == 3) {
|
||||
if (osMotorInit(&gControllerMsgQ, &gRumbleBackFs, 0) == 0) {
|
||||
gRumblePakState = RumblepakStateInitialized;
|
||||
} else {
|
||||
gRumblePakState = RumplepakStateUninitialized;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,8 @@ void rumblePakClipInit() {
|
|||
curr->wave = NULL;
|
||||
curr->currentSample = 0;
|
||||
curr->rumbleId = 0;
|
||||
|
||||
prev = curr;
|
||||
}
|
||||
|
||||
prev->next = NULL;
|
||||
|
@ -146,7 +148,7 @@ int rumblePakCalculateState() {
|
|||
amplitude = 3;
|
||||
}
|
||||
|
||||
int result = amplitude >= gRumbleCurrentBit;
|
||||
int result = amplitude == 3 || amplitude > gRumbleCurrentBit;
|
||||
gRumbleCurrentBit = (gRumbleCurrentBit + 1) & 0x3;
|
||||
return result;
|
||||
}
|
|
@ -6,7 +6,6 @@
|
|||
#include "../graphics/render_scene.h"
|
||||
#include "../math/mathf.h"
|
||||
#include "../scene/signals.h"
|
||||
#include "../util/profile.h"
|
||||
|
||||
#include "../build/assets/materials/static.h"
|
||||
|
||||
|
@ -28,14 +27,10 @@ void staticRenderPopulateRooms(struct FrustrumCullingInformation* cullingInfo, M
|
|||
|
||||
struct Vector3 boxCenter;
|
||||
|
||||
u64 startTime = profileStart();
|
||||
|
||||
if (transformIndex == NO_TRANSFORM_INDEX) {
|
||||
if (isOutsideFrustrum(cullingInfo, box)) {
|
||||
profileEnd(startTime, 2);
|
||||
continue;
|
||||
}
|
||||
profileEnd(startTime, 2);
|
||||
|
||||
boxCenter.x = (float)((box->minX + box->maxX) * (0.5f / SCENE_SCALE));
|
||||
boxCenter.y = (float)(box->minY + box->maxY) * (0.5f / SCENE_SCALE);
|
||||
|
@ -61,19 +56,15 @@ void staticRenderPopulateRooms(struct FrustrumCullingInformation* cullingInfo, M
|
|||
shiftedBox.maxZ = box->maxZ + z;
|
||||
|
||||
if (isOutsideFrustrum(cullingInfo, &shiftedBox)) {
|
||||
profileEnd(startTime, 2);
|
||||
continue;
|
||||
}
|
||||
profileEnd(startTime, 2);
|
||||
|
||||
boxCenter.x = (float)(shiftedBox.minX + shiftedBox.maxX) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.y = (float)(shiftedBox.minY + shiftedBox.maxY) * (0.5f / SCENE_SCALE);
|
||||
boxCenter.z = (float)(shiftedBox.minZ + shiftedBox.maxZ) * (0.5f / SCENE_SCALE);
|
||||
}
|
||||
|
||||
startTime = profileStart();
|
||||
renderSceneAdd(renderScene, gCurrentLevel->staticContent[i].displayList, matrix, gCurrentLevel->staticContent[i].materialIndex, &boxCenter, NULL);
|
||||
profileEnd(startTime, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,17 +119,9 @@ void staticRender(struct Transform* cameraTransform, struct FrustrumCullingInfor
|
|||
|
||||
struct RenderScene* renderScene = renderSceneNew(cameraTransform, renderState, MAX_RENDER_COUNT, visibleRooms);
|
||||
|
||||
u64 startTime = profileStart();
|
||||
staticRenderPopulateRooms(cullingInfo, staticTransforms, renderScene);
|
||||
profileEnd(startTime, 4);
|
||||
|
||||
startTime = profileStart();
|
||||
dynamicRenderPopulateRenderScene(dynamicList, stageIndex, renderScene, cameraTransform, cullingInfo, visibleRooms);
|
||||
profileEnd(startTime, 5);
|
||||
|
||||
startTime = profileStart();
|
||||
renderSceneGenerate(renderScene, renderState);
|
||||
profileEnd(startTime, 6);
|
||||
|
||||
renderSceneFree(renderScene);
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "sk64/skelatool_animator.h"
|
||||
#include "util/dynamic_asset_loader.h"
|
||||
#include "util/profile.h"
|
||||
#include "controls/rumble_pak.h"
|
||||
|
||||
#include "levels/levels.h"
|
||||
#include "savefile/checkpoint.h"
|
||||
|
@ -202,10 +203,11 @@ static void gameProc(void* arg) {
|
|||
contactSolverInit(&gContactSolver);
|
||||
portalSurfaceCleanupQueueInit();
|
||||
savefileLoad();
|
||||
levelLoadWithCallbacks(MAIN_MENU);
|
||||
levelLoadWithCallbacks(7);
|
||||
gCurrentTestSubject = 0;
|
||||
cutsceneRunnerReset();
|
||||
controllersInit();
|
||||
rumblePakClipInit();
|
||||
initAudio(fps);
|
||||
soundPlayerInit();
|
||||
skSetSegmentLocation(CHARACTER_ANIMATION_SEGMENT, (unsigned)_animation_segmentSegmentRomStart);
|
||||
|
@ -233,6 +235,7 @@ static void gameProc(void* arg) {
|
|||
portalSurfaceCleanupQueueInit();
|
||||
heapInit(_heapStart, memoryEnd);
|
||||
levelLoadWithCallbacks(levelGetQueued());
|
||||
rumblePakClipInit();
|
||||
cutsceneRunnerReset();
|
||||
dynamicAssetsReset();
|
||||
// if a portal fire button is being held
|
||||
|
|
|
@ -329,7 +329,7 @@ u8 gFireGunRumbleWaveData[] = {
|
|||
struct RumblePakWave gFireGunRumbleWave = {
|
||||
.samples = gFireGunRumbleWaveData,
|
||||
.sampleCount = 8,
|
||||
.samplesPerTick = 1 << 6,
|
||||
.samplesPerTick = 1 << 5,
|
||||
};
|
||||
|
||||
void sceneCheckPortals(struct Scene* scene) {
|
||||
|
|
|
@ -20,7 +20,7 @@ void profileReport() {
|
|||
OSTime reportStartTime = osGetTime();
|
||||
|
||||
gProfileData.lastReportStart = OS_CYCLES_TO_USEC(reportStartTime - gProfileData.lastReportStart);
|
||||
// gdbSendMessage(GDBDataTypeRawBinary, (char*)&gProfileData, sizeof(struct ProfileData));
|
||||
gdbSendMessage(GDBDataTypeRawBinary, (char*)&gProfileData, sizeof(struct ProfileData));
|
||||
|
||||
for (int i = 0; i < MAX_PROFILE_BINS; ++i) {
|
||||
gProfileData.timeAccumulation[i] = 0;
|
||||
|
|
Loading…
Reference in a new issue