Reformat to something more readable for me :3
Build libsm64 / Build libsm64 for linux (push) Failing after 27s
Build libsm64 / Build libsm64 for web (push) Failing after 31s
Build libsm64 / Build libsm64 for windows (push) Failing after 22s

This commit is contained in:
2026-05-24 11:31:35 -05:00
parent 4328104536
commit 0406c215d2
156 changed files with 31087 additions and 21344 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
name: Build libsm64
on: [push, pull_request]
on: [ push, pull_request ]
jobs:
Build:
+10
View File
@@ -0,0 +1,10 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+5
View File
@@ -0,0 +1,5 @@
<component name="ProjectCodeStyleConfiguration">
<state>
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
</state>
</component>
+392
View File
@@ -0,0 +1,392 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="BackendCodeEditorSettings">
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CDeclarationWithImplicitIntType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CommentTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=ConstevalIfIsAlwaysConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractClassWithoutSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAbstractVirtualFunctionCallInCtor/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAccessSpecifierWithNoDeclarations/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppAwaiterTypeIsNotClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBooleanIncrementExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatBadCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatLegacyCode/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatMixedArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooFewArgs/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppBoostFormatTooManyArgs/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCVQualifierCanNotBeAppliedToReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassCanBeFinal/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassIsIncomplete/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeedsConstructorBecauseOfUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppClassNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCompileTimeConstantCanBeReplacedWithBooleanConstant/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConceptNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConditionalExpressionCanBeSimplified/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppConstValueFunctionReturnType/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppCoroutineCallResolveError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAArrayIndexOutOfBounds/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantConditions/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantFunctionResult/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAConstantParameter/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFADeletedPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAEndlessLoop/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInfiniteRecursion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAInvalidatedMemory/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALocalValueEscapesScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFALoopConditionNotUpdated/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAMemoryLeak/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANotInitializedField/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFANullDereference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFATimeOver/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableCode/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreachableFunctionCall/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnreadVariable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDFAUnusedValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesLocal/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationHidesUncapturedLocal/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclarationSpecifierWithoutDeclarators/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorDisambiguatedAsFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeclaratorUsedBeforeInitialization/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultCaseNotHandledInSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultInitializationWithNoUserConstructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultIsUsedAsIdentifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefaultedSpecialMemberFunctionIsImplicitlyDeleted/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDefinitionsOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeletingVoidPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTemplateWithoutTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDependentTypeWithoutTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedEntity/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedOverridenMethod/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDeprecatedRegisterStorageClassSpecifier/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDereferenceOperatorLimitExceeded/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDiscardedPostfixOperatorResult/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenSyntaxError/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUndocumentedParameter/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppDoxygenUnresolvedReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEmptyDeclaration/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersOrder/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceCVQualifiersPlacement/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceDoStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceForStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceFunctionDeclarationStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceIfStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceNestedNamespacesStyle/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingDestructorStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceOverridingFunctionStyle/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceTypeAliasCodeStyle/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnforceWhileStatementBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityAssignedButNoRead/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEntityUsedOnlyInUnevaluatedContext/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEnumeratorNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEqualOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppEvaluationFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExplicitSpecializationInNonNamespaceScope/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppExpressionWithoutSideEffects/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalFunctionInFinalClass/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFinalNonOverridingVirtualFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForLoopCanBeReplacedWithWhile/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppForwardEnumDeclarationWithoutUnderlyingType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionDoesntReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionResultShouldBeUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppFunctionalStyleCast/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHeaderHasBeenAlreadyIncluded/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHiddenFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppHidingFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIdenticalOperandsInBinaryExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIfCanBeReplacedByConstexprIf/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppImplicitDefaultConstructorNotAvailable/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompatiblePointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIncompleteSwitchStatement/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInconsistentNaming/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppIntegralToPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppInvalidLineContinuation/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppJoinDeclarationAndAssignment/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLambdaCaptureNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLocalVariableWithNonTrivialDtorIsNeverUsed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppLongFloat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeConst/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberFunctionMayBeStatic/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMemberInitializersOrder/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMismatchedClassTags/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingIncludeGuard/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMissingKeywordThrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppModulePartitionWithSeveralPartitionUnits/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtAddressOfClassRValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtBindingRValueToLvalueReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtCopyElisionInCopyInitDeclarator/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtDoubleUserConversionInCopyInit/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtNotInitializedStaticConstLocalVar/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMsExtReinterpretCastFromNullptr/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMultiCharacterWideLiteral/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMustBePublicVirtualToImplementInterface/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppMutableSpecifierOnReferenceMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNoDiscardExpression/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNodiscardFunctionWithoutReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExceptionSafeResourceAcquisition/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConversionOperator/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonExplicitConvertingConstructor/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineFunctionDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNonInlineVariableDefinitionInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppNotAllPathsReturnValue/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppObjectMemberMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOutParameterMustBeWritten/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppOverrideWithDifferentVisibility/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConst/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterMayBeConstPtrOrRef/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNamesMismatch/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPassValueParameterByConstReference/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerConversionDropsQualifiers/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPointerToIntegralConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPolymorphicClassWithNonVirtualPublicDestructor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyErroneousEmptyStatements/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUninitializedMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPossiblyUnintendedObjectSlicing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderIsNotIncluded/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrecompiledHeaderNotFound/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfBadFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfExtraArg/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfMissedArg/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrintfRiskyFormat/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppPrivateSpecialMemberFunctionIsNotImplemented/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRangeBasedForIncompatibleReference/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedefinitionOfDefaultArgumentInOverrideFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassAccessSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBaseClassInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantBooleanExpressionArgument/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantCastExpression/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantComplexityInComparison/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConditionalExpression/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantConstSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantControlFlowJump/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantDereferencingAndTakingAddress/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElaboratedTypeSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeyword/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantElseKeywordInsideCompoundStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyDeclaration/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantEmptyStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantExportKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantFwdClassOrEnumSpecifier/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantInlineSpecifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantLambdaParameterList/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantMemberInitializer/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantNamespaceDefinition/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantParentheses/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifier/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantQualifierADL/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnMemberAllocationFunction/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantStaticSpecifierOnThreadLocalLocalVariable/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateArguments/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTemplateKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantTypenameKeyword/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantVoidArgumentList/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRedundantZeroInitializerInAggregateInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReinterpretCastFromVoidPtr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppRemoveRedundantBraces/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceMemsetWithZeroInitialization/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReplaceTieWithStructuredBinding/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppReturnNoValueInNonVoidFunction/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSmartPointerVsMakeFunction/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSomeObjectMembersMightNotBeInitialized/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppSpecialFunctionWithoutNoexceptSpecification/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticAssertFailure/@EntryIndexedValue" value="ERROR" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticDataMemberInUnnamedStruct/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStaticSpecifierOnAnonymousNamespaceMember/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppStringLiteralToCharPointerConversion/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTabsAreDisallowed/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateArgumentsCanBeDeduced/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterNeverUsed/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTemplateParameterShadowing/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppThrowExpressionCanBeReplacedWithRethrow/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScope/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTooWideScopeInitStatement/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppTypeAliasNeverUsed/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedDependentBaseClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUninitializedNonStaticDataMember/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnionMemberOfReferenceType/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaEndRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnmatchedPragmaRegionDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnamedNamespaceInHeaderFile/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnnecessaryWhitespace/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnsignedZeroComparison/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUnusedIncludeDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAlgorithmWithCount/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAssociativeContains/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAuto/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseAutoForNumeric/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseElementsView/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseEraseAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseFamiliarTemplateSyntaxForGenericLambdas/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseRangeAlgorithm/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStdSize/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseStructuredBinding/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUseTypeTraitAlias/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUserDefinedLiteralSuffixDoesNotStartWithUnderscore/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppUsingResultOfAssignmentAsCondition/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVariableCanBeMadeConstexpr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionCallInsideCtor/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVirtualFunctionInFinalClass/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppVolatileParameterInDeclaration/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWarningDirective/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongIncludesOrder/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppWrongSlashesInIncludeDirective/@EntryIndexedValue" value="HINT" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroConstantCanBeReplacedWithNullptr/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=CppZeroValuedExpressionUsedAsNullPointer/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IdentifierTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=IfStdIsConstantEvaluatedCanBeReplaced/@EntryIndexedValue" value="SUGGESTION" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StdIsConstantEvaluatedWillAlwaysEvaluateToConstant/@EntryIndexedValue" value="WARNING" type="string" />
<option name="/Default/CodeInspection/Highlighting/InspectionSeverities/=StringLiteralTypo/@EntryIndexedValue" value="DO_NOT_SHOW" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppClangFormat/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInForStatement/@EntryValue" value="Required" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInIfStatement/@EntryValue" value="Required" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/BracesInWhileStatement/@EntryValue" value="Required" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppCodeStyle/UseAutoCommonCase/@EntryValue" value="Never" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_ARGUMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_BINARY_EXPRESSIONS_CHAIN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXPRESSION/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_EXTENDS_LIST/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_FOR_STMT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_PARAMETER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_ARGUMENT/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_MULTILINE_TYPE_PARAMETER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALIGN_TERNARY/@EntryValue" value="ALIGN_ALL" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/ALLOW_COMMENT_AFTER_LBRACE/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_CLASS_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_DECLARATIONS/@EntryValue" value="0" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DECLARATION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/BLANK_LINES_AROUND_FUNCTION_DEFINITION/@EntryValue" value="1" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CASE_BLOCK_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/CONTINUOUS_LINE_INDENT/@EntryValue" value="Double" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FUNCTION_DECLARATION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/FUNCTION_DEFINITION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_ACCESS_SPECIFIERS_FROM_CLASS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CASE_FROM_SWITCH/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_CLASS_MEMBERS_FROM_ACCESS_SPECIFIERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_COMMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_PREPROCESSOR_DIRECTIVES/@EntryValue" value="Normal" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_SIZE/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INDENT_STYLE/@EntryValue" value="Space" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INITIALIZER_BRACES/@EntryValue" value="END_OF_LINE_NO_SPACE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/INT_ALIGN_EQ/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/KEEP_EXISTING_ENUM_ARRANGEMENT/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LABELED_STATEMENT_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_COLON_IN_MEMBER_INITIALIZER_LISTS/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_DEREF_IN_TRAILING_RETURN_TYPES/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_AFTER_INIT_STATEMENT/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_BEFORE_DEREF_IN_TRAILING_RETURN_TYPES/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_BEFORE_FUNCTION_TRY_BLOCK/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINE_BREAK_BEFORE_REQUIRES_CLAUSE/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINKAGE_SPECIFICATION_BRACES/@EntryValue" value="NEXT_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/LINKAGE_SPECIFICATION_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/MEMBER_INITIALIZER_LIST_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/NAMESPACE_INDENTATION/@EntryValue" value="All" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_BLOCK_STYLE/@EntryValue" value="DO_NOT_CHANGE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SIMPLE_CASE_STATEMENT_STYLE/@EntryValue" value="LINE_BREAK" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_COLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_FOR_SEMICOLON/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_PTR_IN_NESTED_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBER/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_DATA_MEMBERS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_REF_IN_METHOD/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_AFTER_UNARY_OPERATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_COLON_IN_BITFIELD_DECLARATOR/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_COLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_FOR_SEMICOLON/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_PTR_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_ABSTRACT_DECL/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBER/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_DATA_MEMBERS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_REF_IN_METHOD/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_BEFORE_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_ARRAY_ACCESS_BRACKETS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_BLOCKS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_METHOD_PARENTHESES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_EMPTY_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_INITIALIZER_BRACES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPACE_WITHIN_TEMPLATE_PARAMS/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/SPECIAL_ELSE_IF_TREATMENT/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TAB_WIDTH/@EntryValue" value="4" type="int" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TOPLEVEL_FUNCTION_DECLARATION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/TOPLEVEL_FUNCTION_DEFINITION_RETURN_TYPE_STYLE/@EntryValue" value="ON_SINGLE_LINE" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_BINARY_OPSIGN/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_AFTER_DECLARATION_LPAR/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_ARGUMENTS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_BEFORE_TERNARY_OPSIGNS/@EntryValue" value="true" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_LINES/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/CodeFormatting/CppFormatting/WRAP_PARAMETERS_STYLE/@EntryValue" value="WRAP_IF_LONG" type="string" />
<option name="/Default/CodeStyle/EditorConfig/EnableClangFormatSupport/@EntryValue" value="false" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=05D45346A5B5B54F93A9F94C46B14079/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=05D45346A5B5B54F93A9F94C46B14079/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0AFB7787612DF743B09AD9412E48D4CC/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0AFB7787612DF743B09AD9412E48D4CC/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0B82708A1BA7774EB13D27F245698A56/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0B82708A1BA7774EB13D27F245698A56/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=0CBD9263BD435842828596291C4FE4B4/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;2&quot; Title=&quot;Fields&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;type Name=&quot;union member&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=1350D079A82E0740947E85445B5AF47C/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=1350D079A82E0740947E85445B5AF47C/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=18392FF80FA40749AA8CC53981A32AE0/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=18392FF80FA40749AA8CC53981A32AE0/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=1CBDD658AEE8EA4382EE1F914B5B3314/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=1CBDD658AEE8EA4382EE1F914B5B3314/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2229A2BE1AA9214483A51F028530E042/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2229A2BE1AA9214483A51F028530E042/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2AD8EC23F81C6F4AB06852FBF796A3D1/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2AD8EC23F81C6F4AB06852FBF796A3D1/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2B232F1067F0324F8FF4B9D63ACECDB2/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=2B232F1067F0324F8FF4B9D63ACECDB2/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=4203BE6F332C5149B409B4D5F7197E54/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=4203BE6F332C5149B409B4D5F7197E54/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=4F91A7364D7B63479FCEA1D063EAEA19/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;13&quot; Title=&quot;Non-Type Template Parameters&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;non-type template parameter&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=5653BA7B6222F349B94149A2A53C35B8/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=5653BA7B6222F349B94149A2A53C35B8/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=6513EEED32DF014BB4F3706393117465/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;8&quot; Title=&quot;Enumerators&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;scoped enumerator&quot; /&gt;&lt;type Name=&quot;unscoped enumerator&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=72514D5DF422D442B71A277F97B72887/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=72514D5DF422D442B71A277F97B72887/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=821F3C5CF47D5640AD3511BCBADE17C4/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=821F3C5CF47D5640AD3511BCBADE17C4/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=8B1F7EC98488B349961668DA5758DC54/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;5&quot; Title=&quot;Functions&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global function&quot; /&gt;&lt;type Name=&quot;member function&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=8F69F48E2532F54CBAA0039D4557825E/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=8F69F48E2532F54CBAA0039D4557825E/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=97F66D4C2F93FF418F4AE9D29638A2F8/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;9&quot; Title=&quot;Namespaces&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;namespace&quot; /&gt;&lt;type Name=&quot;namespace alias&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=9E4D28CA929F6B4AB5F6F3FEB9E69A47/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=9E4D28CA929F6B4AB5F6F3FEB9E69A47/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A229B5AAD2B3D44A9E9AFBB9F61DEEB3/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;11&quot; Title=&quot;Properties&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;property&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A42D627FA43B054F91D1E1C4281D8896/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A42D627FA43B054F91D1E1C4281D8896/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A4FAA2257682A94F8C2C93E123FAFC7A/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A4FAA2257682A94F8C2C93E123FAFC7A/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A7EBF16DA3BDCB42A0B710704BC8A053/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A7EBF16DA3BDCB42A0B710704BC8A053/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=A87CB78D825AFA439AD708500DC7732B/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;4&quot; Title=&quot;Parameters&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;function parameter&quot; /&gt;&lt;type Name=&quot;lambda parameter&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B28E74445B5ADE46BB06B8B2E7AF0B10/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;3&quot; Title=&quot;Variables&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global variable&quot; /&gt;&lt;type Name=&quot;lambda&quot; /&gt;&lt;type Name=&quot;local variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;aaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B6E900853D6D05429D8C57765B2E546A/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B6E900853D6D05429D8C57765B2E546A/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B82A063F0DDD98498A70D8D7EBB97F8D/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=B82A063F0DDD98498A70D8D7EBB97F8D/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BBE8AA08E662BF409B2CB08EC597C493/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BBE8AA08E662BF409B2CB08EC597C493/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BF0D1AE66D64FE4FAF613448A12051A0/@EntryIndexRemoved" value="true" type="bool" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=BF0D1AE66D64FE4FAF613448A12051A0/@EntryIndexedValue" value="" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=C0DE3DAEDDF0744889F41BE5BEA903AC/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;1&quot; Title=&quot;Types&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;__interface&quot; /&gt;&lt;type Name=&quot;class&quot; /&gt;&lt;type Name=&quot;concept&quot; /&gt;&lt;type Name=&quot;enum&quot; /&gt;&lt;type Name=&quot;struct&quot; /&gt;&lt;type Name=&quot;type alias&quot; /&gt;&lt;type Name=&quot;type template parameter&quot; /&gt;&lt;type Name=&quot;typedef&quot; /&gt;&lt;type Name=&quot;union&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=C2FB8C7FF23D70478D17C7DAF4AC9E4D/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;12&quot; Title=&quot;Events&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;event&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AaBb&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=DA7983C3DEA2E84CA44F3B120F90B3CC/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;10&quot; Title=&quot;Macros&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;Indeterminate&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;macro&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=FAAD8F52D9EFD84E8894C7AAE4F72FCA/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;7&quot; Title=&quot;Global constants&quot;&gt;&lt;Descriptor Static=&quot;Indeterminate&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;True&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;global variable&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
<option name="/Default/CodeStyle/Naming/CppNamingOptions/Rules/=FBDB26623C05204BA0FA28B9017D7101/@EntryIndexedValue" value="&lt;NamingElement Priority=&quot;6&quot; Title=&quot;Other constants&quot;&gt;&lt;Descriptor Static=&quot;True&quot; Constexpr=&quot;Indeterminate&quot; Const=&quot;True&quot; Volatile=&quot;Indeterminate&quot; Accessibility=&quot;NOT_APPLICABLE&quot;&gt;&lt;type Name=&quot;class field&quot; /&gt;&lt;type Name=&quot;local variable&quot; /&gt;&lt;type Name=&quot;struct field&quot; /&gt;&lt;/Descriptor&gt;&lt;Policy Inspect=&quot;True&quot; WarnAboutPrefixesAndSuffixes=&quot;False&quot; Prefix=&quot;&quot; Suffix=&quot;&quot; Style=&quot;AA_BB&quot; /&gt;&lt;/NamingElement&gt;" type="string" />
</component>
</project>
+4
View File
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
+19
View File
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MakefileSettings">
<option name="linkedExternalProjectsSettings">
<MakefileProjectSettings>
<option name="buildTarget" value="run" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
<option name="version" value="2" />
</MakefileProjectSettings>
</option>
</component>
<component name="MakefileWorkspace" PROJECT_DIR="$PROJECT_DIR$" />
</project>
Generated
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
+71 -71
View File
@@ -38,84 +38,84 @@ terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
+1
View File
@@ -31,6 +31,7 @@ project under the `test` directory as well, demonstrating usage of the library.
- To run the test program you'll need a SM64 US ROM in the root of the repository with the name `baserom.us.z64`.
## Building on Windows
- [Follow steps 1-4 for setting up MSYS2 MinGW 64 here](https://github.com/sm64-port/sm64-port#windows), but replace the repository URL with `https://github.com/libsm64/libsm64.git`
- Ensure the SDL2 and GLEW libraries are installed if you're building the test program.
- 64 bits: `pacman -S mingw-w64-x86_64-SDL2 mingw-w64-x86_64-glew`.
+2 -1
View File
@@ -54,6 +54,7 @@ model_inc_h = """
#include "../include/PR/gbi.h"
"""
def main():
global model_inc_h
@@ -82,7 +83,6 @@ def main():
lines.insert(0, "#include \"../../load_tex_data.h\"")
model_inc_c = "\n".join(lines)
with open("src/decomp/mario/geo.inc.c", "w") as file:
file.write(geo_inc_c_header + geo_inc_c + geo_inc_c_footer)
@@ -95,5 +95,6 @@ def main():
with open("src/decomp/mario/geo.inc.h", "w") as file:
file.write(geo_inc_h)
if __name__ == "__main__":
main()
+5 -3
View File
@@ -13,6 +13,7 @@ extern const struct SM64Surface surfaces[];
extern const size_t surfaces_count;
"""
def main():
print("Downloading " + BOB_COLLISION_URL)
in_lines = urllib.request.urlopen(BOB_COLLISION_URL).read().decode('utf8').splitlines()
@@ -28,16 +29,16 @@ def main():
tokens = line.strip().replace("(", ",").replace(")", "").split(",")
if tokens[0] == "COL_VERTEX":
verts.append([ int(tokens[1]), int(tokens[2]), int(tokens[3]) ])
verts.append([int(tokens[1]), int(tokens[2]), int(tokens[3])])
elif tokens[0] == "COL_TRI_INIT":
mode = tokens[1]
elif tokens[0] == "COL_TRI":
tris.append([ int(tokens[1]), int(tokens[2]), int(tokens[3]), mode ])
tris.append([int(tokens[1]), int(tokens[2]), int(tokens[3]), mode])
out_lines = []
for tri in tris:
out_lines.append("{%s,0,TERRAIN_SNOW,{{%s,%s,%s},{%s,%s,%s},{%s,%s,%s}}}"%(tri[3], \
out_lines.append("{%s,0,TERRAIN_SNOW,{{%s,%s,%s},{%s,%s,%s},{%s,%s,%s}}}" % (tri[3], \
verts[tri[0]][0], verts[tri[0]][1], verts[tri[0]][2], \
verts[tri[1]][0], verts[tri[1]][1], verts[tri[1]][2], \
verts[tri[2]][0], verts[tri[2]][1], verts[tri[2]][2]))
@@ -54,5 +55,6 @@ def main():
with open("test/level.h", "w") as file:
file.write(LEVEL_H)
if __name__ == "__main__":
main()
+1 -1
View File
@@ -1,3 +1,3 @@
#include "debug_print.h"
SM64DebugPrintFunctionPtr g_debug_print_func = NULL;
SM64DebugPrintFunctionPtr g_debug_print_func = nullptr;
@@ -86,10 +86,10 @@ struct Instrument **instOut = _instOut;\
_instId--; \
} \
inst = gCtlEntries[(*seqChannel).bankId].instruments[_instId]; \
if (inst == NULL) { \
if (inst == nullptr) { \
while (_instId != 0xff) { \
inst = gCtlEntries[(*seqChannel).bankId].instruments[_instId]; \
if (inst != NULL) { \
if (inst != nullptr) { \
goto gi ## l; \
} \
_instId--; \
@@ -109,12 +109,13 @@ struct Instrument **instOut = _instOut;\
goto ret ## l; \
} \
gAudioErrorFlags = _instId + 0x20000; \
*instOut = NULL; \
*instOut = nullptr; \
ret ## l: ; \
}
#endif
void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
void seq_channel_layer_process_script(struct SequenceChannelLayer *layer)
{
struct SequencePlayer *seqPlayer; // sp5C, t4
struct SequenceChannel *seqChannel; // sp58, t5
struct M64ScriptState *state;
@@ -135,40 +136,46 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
f32 temp_f12;
f32 temp_f2;
//! Copt: manually inline these functions in the scope of this routine
#ifdef __sgi
#pragma inline routine(m64_read_u8)
#pragma inline routine(m64_read_compressed_u16)
#pragma inline routine(m64_read_s16)
#pragma inline routine(get_instrument)
#endif
//! Copt: manually inline these functions in the scope of this routine
#ifdef __sgi
#pragma inline routine(m64_read_u8)
#pragma inline routine(m64_read_compressed_u16)
#pragma inline routine(m64_read_s16)
#pragma inline routine(get_instrument)
#endif
sameSound = TRUE;
if ((*layer).enabled == FALSE) {
if ((*layer).enabled == FALSE)
{
return;
}
if ((*layer).delay > 1) {
if ((*layer).delay > 1)
{
(*layer).delay--;
if (!layer->stopSomething && layer->delay <= layer->duration) {
if (!layer->stopSomething && layer->delay <= layer->duration)
{
seq_channel_layer_note_decay(layer);
layer->stopSomething = TRUE;
}
return;
}
if (!layer->continuousNotes) {
if (!layer->continuousNotes)
{
seq_channel_layer_note_decay(layer);
}
if (PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_1 ||
PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_2) {
PORTAMENTO_MODE(layer->portamento) == PORTAMENTO_MODE_2)
{
layer->portamento.mode = 0;
}
seqChannel = (*layer).seqChannel;
seqPlayer = (*seqChannel).seqPlayer;
for (;;) {
for (;;)
{
state = &layer->scriptState;
//M64_READ_U8(state, cmd);
{
@@ -177,13 +184,16 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
cmd = *_ptr_pc;
}
if (cmd <= 0xc0) {
if (cmd <= 0xc0)
{
break;
}
switch (cmd) {
switch (cmd)
{
case 0xff: // layer_end; function return or end of script
if (state->depth == 0) {
if (state->depth == 0)
{
// N.B. this function call is *not* inlined even though it's
// within the same file, unlike in the rest of this function.
seq_channel_layer_disable(layer);
@@ -204,9 +214,12 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
break;
case 0xf7: // layer_loopend
if (--state->remLoopIters[state->depth - 1] != 0) {
if (--state->remLoopIters[state->depth - 1] != 0)
{
state->pc = state->stack[state->depth - 1];
} else {
}
else
{
state->depth--;
}
break;
@@ -219,19 +232,25 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
case 0xc1: // layer_setshortnotevelocity
case 0xca: // layer_setpan
temp_a0_5 = *(state->pc++);
if (cmd == 0xc1) {
if (cmd == 0xc1)
{
layer->velocitySquare = (f32)(temp_a0_5 * temp_a0_5);
} else {
layer->pan = (f32) temp_a0_5 / US_FLOAT(128.0);
}
else
{
layer->pan = (f32)temp_a0_5 / US_FLOAT(128.0);
}
break;
case 0xc2: // layer_transpose; set transposition in semitones
case 0xc9: // layer_setshortnoteduration
temp_a0_5 = *(state->pc++);
if (cmd == 0xc9) {
if (cmd == 0xc9)
{
layer->noteDuration = temp_a0_5;
} else {
}
else
{
layer->transposition = temp_a0_5;
}
break;
@@ -242,9 +261,12 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
//layer->continuousNotes = (cmd == 0xc4) ? TRUE : FALSE;
{
u8 setting;
if (cmd == 0xc4) {
if (cmd == 0xc4)
{
setting = TRUE;
} else {
}
else
{
setting = FALSE;
}
layer->continuousNotes = setting;
@@ -260,7 +282,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
case 0xc6: // layer_setinstr
M64_READ_U8(state, cmdSemitone);
if (cmdSemitone < 127) {
if (cmdSemitone < 127)
{
GET_INSTRUMENT(seqChannel, cmdSemitone, &(*layer).instrument, &(*layer).adsr, cmdSemitone, 1);
}
break;
@@ -273,13 +296,15 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
cmdSemitone += (*layer).transposition;
cmdSemitone += (*seqPlayer).transposition;
if (cmdSemitone >= 0x80) {
if (cmdSemitone >= 0x80)
{
cmdSemitone = 0;
}
layer->portamentoTargetNote = cmdSemitone;
// If special, the next param is u8 instead of var
if (PORTAMENTO_IS_SPECIAL((*layer).portamento)) {
if (PORTAMENTO_IS_SPECIAL((*layer).portamento))
{
layer->portamentoTime = *((state)->pc++);
break;
}
@@ -293,7 +318,8 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
break;
default:
switch (cmd & 0xf0) {
switch (cmd & 0xf0)
{
case 0xd0: // layer_setshortnotevelocityfromtable
sp3A = seqPlayer->shortNoteVelocityTable[cmd & 0xf];
(*layer).velocitySquare = (f32)(sp3A * sp3A);
@@ -305,14 +331,19 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
}
}
if (cmd == 0xc0) { // layer_delay
if (cmd == 0xc0)
{ // layer_delay
M64_READ_COMPRESSED_U16(state, layer->delay);
layer->stopSomething = TRUE;
} else {
}
else
{
layer->stopSomething = FALSE;
if (seqChannel->largeNotes == TRUE) {
switch (cmd & 0xc0) {
if (seqChannel->largeNotes == TRUE)
{
switch (cmd & 0xc0)
{
case 0x00: // layer_note0 (play percentage, velocity, duration)
M64_READ_COMPRESSED_U16(state, sp3A);
vel = *((*state).pc++);
@@ -333,11 +364,13 @@ void seq_channel_layer_process_script(struct SequenceChannelLayer *layer) {
layer->noteDuration = *((*state).pc++);
goto l1090;
}
l1090:
cmdSemitone = cmd - (cmd & 0xc0);
l1090: cmdSemitone = cmd - (cmd & 0xc0);
layer->velocitySquare = vel * vel;
} else {
switch (cmd & 0xc0) {
}
else
{
switch (cmd & 0xc0)
{
case 0x00: // play note, type 0 (play percentage)
M64_READ_COMPRESSED_U16(state, sp3A);
layer->playPercentage = sp3A;
@@ -351,9 +384,7 @@ l1090:
sp3A = layer->playPercentage;
goto l1138;
}
l1138:
cmdSemitone = cmd - (cmd & 0xc0);
l1138: cmdSemitone = cmd - (cmd & 0xc0);
}
layer->delay = sp3A;
@@ -361,14 +392,20 @@ l1138:
if ((seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_STOP_NOTES) != 0)
|| seqChannel->stopSomething2
|| !seqChannel->hasInstrument
) {
)
{
layer->stopSomething = TRUE;
} else {
if (seqChannel->instOrWave == 0) { // drum
}
else
{
if (seqChannel->instOrWave == 0)
{ // drum
cmdSemitone += (*seqChannel).transposition + (*layer).transposition;
if (cmdSemitone >= gCtlEntries[seqChannel->bankId].numDrums) {
if (cmdSemitone >= gCtlEntries[seqChannel->bankId].numDrums)
{
cmdSemitone = gCtlEntries[seqChannel->bankId].numDrums;
if (cmdSemitone == 0) {
if (cmdSemitone == 0)
{
// this goto looks a bit like a function return...
layer->stopSomething = TRUE;
goto skip;
@@ -378,9 +415,12 @@ l1138:
}
drum = gCtlEntries[seqChannel->bankId].drums[cmdSemitone];
if (drum == NULL) {
if (drum == nullptr)
{
layer->stopSomething = TRUE;
} else {
}
else
{
layer->adsr.envelope = drum->envelope;
layer->adsr.releaseRate = drum->releaseRate;
layer->pan = FLOAT_CAST(drum->pan) / US_FLOAT(128.0);
@@ -389,35 +429,50 @@ l1138:
}
skip:;
} else { // instrument
}
else
{ // instrument
cmdSemitone += (*seqPlayer).transposition + (*seqChannel).transposition + (*layer).transposition;
if (cmdSemitone >= 0x80) {
if (cmdSemitone >= 0x80)
{
layer->stopSomething = TRUE;
} else {
}
else
{
instrument = layer->instrument;
if (instrument == NULL) {
if (instrument == nullptr)
{
instrument = seqChannel->instrument;
}
if (layer->portamento.mode != 0) {
if (layer->portamento.mode != 0)
{
//! copt needs a ternary:
//usedSemitone = (layer->portamentoTargetNote < cmdSemitone) ? cmdSemitone : layer->portamentoTargetNote;
if (layer->portamentoTargetNote < cmdSemitone) {
if (layer->portamentoTargetNote < cmdSemitone)
{
usedSemitone = cmdSemitone;
} else {
}
else
{
usedSemitone = layer->portamentoTargetNote;
}
if (instrument != NULL) {
sound = (u8) usedSemitone < instrument->normalRangeLo ? &instrument->lowNotesSound
: (u8) usedSemitone <= instrument->normalRangeHi ?
&instrument->normalNotesSound : &instrument->highNotesSound;
if (instrument != nullptr)
{
sound = (u8)usedSemitone < instrument->normalRangeLo
? &instrument->lowNotesSound
: (u8)usedSemitone <= instrument->normalRangeHi
? &instrument->normalNotesSound
: &instrument->highNotesSound;
sameSound = (sound == (*layer).sound);
layer->sound = sound;
tuning = (*sound).tuning;
} else {
layer->sound = NULL;
}
else
{
layer->sound = nullptr;
tuning = 1.0f;
}
@@ -425,7 +480,8 @@ l1138:
temp_f12 = gNoteFrequencies[layer->portamentoTargetNote] * tuning;
portamento = &layer->portamento;
switch (PORTAMENTO_MODE(layer->portamento)) {
switch (PORTAMENTO_MODE(layer->portamento))
{
case PORTAMENTO_MODE_1:
case PORTAMENTO_MODE_3:
case PORTAMENTO_MODE_5:
@@ -439,30 +495,35 @@ l1138:
sp24 = temp_f12;
goto l13cc;
}
l13cc:
portamento->extent = sp24 / freqScale - US_FLOAT(1.0);
if (PORTAMENTO_IS_SPECIAL((*layer).portamento)) {
l13cc: portamento->extent = sp24 / freqScale - US_FLOAT(1.0);
if (PORTAMENTO_IS_SPECIAL((*layer).portamento))
{
portamento->speed = US_FLOAT(32512.0) * FLOAT_CAST((*seqPlayer).tempo)
/ ((f32)(*layer).delay * (f32) gTempoInternalToExternal
/ ((f32)(*layer).delay * (f32)gTempoInternalToExternal
* FLOAT_CAST((*layer).portamentoTime));
} else {
}
else
{
portamento->speed = US_FLOAT(127.0) / FLOAT_CAST((*layer).portamentoTime);
}
portamento->cur = 0.0f;
layer->freqScale = freqScale;
if (PORTAMENTO_MODE((*layer).portamento) == PORTAMENTO_MODE_5) {
if (PORTAMENTO_MODE((*layer).portamento) == PORTAMENTO_MODE_5)
{
layer->portamentoTargetNote = cmdSemitone;
}
} else if (instrument != NULL) {
sound = cmdSemitone < instrument->normalRangeLo ?
&instrument->lowNotesSound : cmdSemitone <= instrument->normalRangeHi ?
&instrument->normalNotesSound : &instrument->highNotesSound;
}
else if (instrument != nullptr)
{
sound = cmdSemitone < instrument->normalRangeLo ? &instrument->lowNotesSound : cmdSemitone <= instrument->normalRangeHi ? &instrument->normalNotesSound : &instrument->highNotesSound;
sameSound = (sound == (*layer).sound);
layer->sound = sound;
layer->freqScale = gNoteFrequencies[cmdSemitone] * (*sound).tuning;
} else {
layer->sound = NULL;
}
else
{
layer->sound = nullptr;
layer->freqScale = gNoteFrequencies[cmdSemitone];
}
}
@@ -471,30 +532,41 @@ l13cc:
}
}
if (layer->stopSomething == TRUE) {
if (layer->note != NULL || layer->continuousNotes) {
if (layer->stopSomething == TRUE)
{
if (layer->note != nullptr || layer->continuousNotes)
{
seq_channel_layer_note_decay(layer);
}
return;
}
cmdSemitone = FALSE;
if (!layer->continuousNotes) {
if (!layer->continuousNotes)
{
cmdSemitone = TRUE;
} else if (layer->note == NULL || layer->status == SOUND_LOAD_STATUS_NOT_LOADED) {
}
else if (layer->note == nullptr || layer->status == SOUND_LOAD_STATUS_NOT_LOADED)
{
cmdSemitone = TRUE;
} else if (sameSound == FALSE) {
}
else if (sameSound == FALSE)
{
seq_channel_layer_note_decay(layer);
cmdSemitone = TRUE;
} else if (layer->sound == NULL) {
}
else if (layer->sound == nullptr)
{
init_synthetic_wave(layer->note, layer);
}
if (cmdSemitone != FALSE) {
if (cmdSemitone != FALSE)
{
(*layer).note = alloc_note(layer);
}
if (layer->note != NULL && layer->note->parentLayer == layer) {
if (layer->note != nullptr && layer->note->parentLayer == layer)
{
note_vibrato_init(layer->note);
}
}
+67 -51
View File
@@ -10,30 +10,46 @@ extern struct OSMesgQueue OSMesgQueue3;
#ifdef VERSION_EU
struct ReverbSettingsEU sReverbSettings[] = {
{ 0x04, 0x0c, 0x2fff },
{ 0x04, 0x0a, 0x47ff },
{ 0x04, 0x10, 0x2fff },
{ 0x04, 0x0e, 0x3fff },
{ 0x04, 0x0c, 0x4fff },
{ 0x04, 0x0a, 0x37ff }
{0x04, 0x0c, 0x2fff},
{0x04, 0x0a, 0x47ff},
{0x04, 0x10, 0x2fff},
{0x04, 0x0e, 0x3fff},
{0x04, 0x0c, 0x4fff},
{0x04, 0x0a, 0x37ff}
};
struct AudioSessionSettingsEU gAudioSessionPresets[] = {
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00 },
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00 },
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[2], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00 },
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[3], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00 },
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[4], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00 },
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00004000, 0x00006e00,
0x00003f00, 0x00002a00 },
{ 0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00004100, 0x00006e00,
0x00004400, 0x00002a80 },
{ 0x00007d00, 0x01, 0x14, 0x01, 0x00, &sReverbSettings[5], 0x7fff, 0x0000, 0x00003500, 0x00006280,
0x00004000, 0x00001b00 }
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00
},
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00
},
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[2], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00
},
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[3], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00
},
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[4], 0x7fff, 0x0000, 0x00003a40, 0x00006d00,
0x00004400, 0x00002a00
},
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[0], 0x7fff, 0x0000, 0x00004000, 0x00006e00,
0x00003f00, 0x00002a00
},
{
0x00007d00, 0x01, 0x10, 0x01, 0x00, &sReverbSettings[1], 0x7fff, 0x0000, 0x00004100, 0x00006e00,
0x00004400, 0x00002a80
},
{
0x00007d00, 0x01, 0x14, 0x01, 0x00, &sReverbSettings[5], 0x7fff, 0x0000, 0x00003500, 0x00006280,
0x00004000, 0x00001b00
}
};
#endif
@@ -51,7 +67,7 @@ struct AudioSessionSettingsEU gAudioSessionPresets[] = {
#if defined(VERSION_JP) || defined(VERSION_US)
struct AudioSessionSettings gAudioSessionPresets[18] = {
#ifdef VERSION_JP
{ 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x3900, 0x6000, 0x4400, 0x2A00 },
@@ -60,7 +76,7 @@ struct AudioSessionSettings gAudioSessionPresets[18] = {
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3F00, 0x6200, 0x4400, 0x2A80 },
{ 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x3300, 0x5500, 0x4000, 0x1B00 },
#else
{ 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0C00, 0x2FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
{ 32000, 16, 1, 0x0E00, 0x3FFF, 0x7FFF, 0x3A00, 0x6D00, 0x4400, 0x2A00 },
@@ -69,7 +85,7 @@ struct AudioSessionSettings gAudioSessionPresets[18] = {
{ 32000, 16, 1, 0x0A00, 0x47FF, 0x7FFF, 0x4100, 0x6E00, 0x4400, 0x2A80 },
{ 32000, 20, 1, 0x0800, 0x37FF, 0x7FFF, 0x34C0, 0x6280, 0x4000, 0x1B00 },
#endif
{ 27000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x2500, 0x5500, 0x7400, 0x2400 },
{ 27000, 16, 1, 0x0800, 0x2FFF, 0x7FFF, 0x2500, 0x5500, 0x7400, 0x2400 },
{ 27000, 16, 1, 0x0800, 0x3FFF, 0x7FFF, 0x2500, 0x5500, 0x7400, 0x2400 },
{ 27000, 16, 1, 0x1000, 0x2FFF, 0x7FFF, 0x2500, 0x5500, 0x7400, 0x2400 },
{ 27000, 16, 1, 0x1000, 0x3FFF, 0x7FFF, 0x2500, 0x5500, 0x7400, 0x2400 },
@@ -106,7 +122,7 @@ f32 gPitchBendFrequencyScale[256] = {
0.5f,
#else
f32 gPitchBendFrequencyScale[255] = {
#endif
#endif
0.5f, 0.502736f, 0.505488f, 0.508254f, 0.511036f, 0.513833f, 0.516645f, 0.519472f, 0.522315f,
0.525174f, 0.528048f, 0.530938f, 0.533843f, 0.536765f, 0.539702f, 0.542656f, 0.545626f, 0.548612f,
0.551614f, 0.554633f, 0.557669f, 0.560721f, 0.563789f, 0.566875f, 0.569977f, 0.573097f, 0.576233f,
@@ -171,19 +187,19 @@ u8 gDefaultShortNoteDurationTable[16] = {
#if defined(VERSION_JP) || defined(VERSION_US)
// gVibratoCurve[k] = k*8
s8 gVibratoCurve[16] = { 0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120 };
s8 gVibratoCurve[16] = {0, 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120};
#endif
struct AdsrEnvelope gDefaultEnvelope[] = {
{ BSWAP16(4), BSWAP16(32000) }, // go from 0 to 32000 over the course of 16ms
{ BSWAP16(1000), BSWAP16(32000) }, // stay there for 4.16 seconds
{ BSWAP16(ADSR_HANG), 0 } // then continue staying there
{BSWAP16(4), BSWAP16(32000)}, // go from 0 to 32000 over the course of 16ms
{BSWAP16(1000), BSWAP16(32000)}, // stay there for 4.16 seconds
{BSWAP16(ADSR_HANG), 0} // then continue staying there
};
#endif
#ifdef VERSION_EU
struct NoteSubEu gZeroNoteSub = { 0 };
struct NoteSubEu gDefaultNoteSub = { 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL } };
struct NoteSubEu gZeroNoteSub = {0};
struct NoteSubEu gDefaultNoteSub = {1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {nullptr}};
#endif
#if defined(VERSION_EU) || defined(VERSION_SH)
@@ -337,7 +353,7 @@ s16 gEuUnknownWave7[256] = {
0x0000, 0x8d2e, 0x4e20, 0xe14e, 0x0000, 0x1eb2, 0xb1e0, 0x72d2, 0x0000, 0x8d2e, 0x4e20, 0xe14e,
0x0000, 0x1eb2, 0xb1e0, 0x72d2,
};
s16 *gWaveSamples[6] = { sSawtoothWaves, sTriangleWaves, sSineWaves, sSquareWaves, sEuUnknownWave6, gEuUnknownWave7 };
s16 *gWaveSamples[6] = {sSawtoothWaves, sTriangleWaves, sSineWaves, sSquareWaves, sEuUnknownWave6, gEuUnknownWave7};
#else
// !VERSION_EU
@@ -376,7 +392,7 @@ s16 sSawtoothWave[0x40] = {
-0x4FFF, -19455, -0x47FF, -17407, -0x3FFF, -15359, -0x37FF, -13311, -0x2FFF, -11263, -10239,
-9215, -8191, -7167, -6143, -5119, -4095, -3071, -2047, -1023,
};
s16 *gWaveSamples[4] = { sSawtoothWave, sTriangleWave, sSineWave, sSquareWave };
s16 *gWaveSamples[4] = {sSawtoothWave, sTriangleWave, sSineWave, sSquareWave};
#endif
#ifdef VERSION_SH
@@ -476,38 +492,38 @@ u8 gDefaultShortNoteDurationTable[16] = {
};
struct AdsrEnvelope gDefaultEnvelope[] = {
{ BSWAP16(4), BSWAP16(32000) }, // go from 0 to 32000 over the course of 16ms
{ BSWAP16(1000), BSWAP16(32000) }, // stay there for 4.16 seconds
{ BSWAP16(ADSR_HANG), 0 } // then continue staying there
{BSWAP16(4), BSWAP16(32000)}, // go from 0 to 32000 over the course of 16ms
{BSWAP16(1000), BSWAP16(32000)}, // stay there for 4.16 seconds
{BSWAP16(ADSR_HANG), 0} // then continue staying there
};
u8 unk_sh_data2[4] = { 0, 0, 0, 0 };
u8 unk_sh_data2[4] = {0, 0, 0, 0};
struct NoteSubEu gZeroNoteSub = { 0 };
struct NoteSubEu gZeroNoteSub = {0};
struct NoteSubEu gDefaultNoteSub = {
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, { NULL },
1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, {nullptr},
#ifdef VERSION_SH
0
0
#endif
};
u16 gHeadsetPanQuantization[0x40] = {
0x3C, 0x3A, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2E,
0x2C, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1E,
0x1C, 0x1A, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0E,
0x0C, 0x0A, 0x08, 0x06, 0x04, 0x02,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0x3C, 0x3A, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2E,
0x2C, 0x2A, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1E,
0x1C, 0x1A, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0E,
0x0C, 0x0A, 0x08, 0x06, 0x04, 0x02,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
#endif
#ifdef VERSION_EU
u8 euUnknownData_8030194c[4] = { 0x40, 0x20, 0x10, 0x08 };
u8 euUnknownData_8030194c[4] = {0x40, 0x20, 0x10, 0x08};
u16 gHeadsetPanQuantization[0x10] = {
0x40, 0x40, 0x30, 0x30, 0x20, 0x20, 0x10, 0, 0, 0,
};
#elif !defined(VERSION_SH)
u16 gHeadsetPanQuantization[10] = { 0x40, 0x30, 0x20, 0x10, 0, 0, 0, 0, 0, 0 };
u16 gHeadsetPanQuantization[10] = {0x40, 0x30, 0x20, 0x10, 0, 0, 0, 0, 0, 0};
#endif
#if defined(VERSION_EU) || defined(VERSION_SH)
@@ -888,11 +904,11 @@ volatile s32 gAudioLoadLock = AUDIO_LOCK_UNINITIALIZED;
#endif
#if defined(VERSION_EU)
u8 bufferDelete2[12] = { 0 };
u8 bufferDelete2[12] = {0};
u8 D_EU_80302010 = 0;
u8 D_EU_80302014 = 0;
struct OSMesgQueue *OSMesgQueues[4] = { &OSMesgQueue0, &OSMesgQueue1, &OSMesgQueue2, &OSMesgQueue3 };
struct OSMesgQueue *OSMesgQueues[4] = {&OSMesgQueue0, &OSMesgQueue1, &OSMesgQueue2, &OSMesgQueue3};
#elif defined(VERSION_JP) || defined(VERSION_US)
s8 sUnused8033EF8 = 24;
#endif
+254 -171
View File
@@ -14,29 +14,32 @@
f32 gTrackVolume = 1.0f;
#if defined(VERSION_EU) || defined(VERSION_SH)
void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 recalculateVolume) {
void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 recalculateVolume)
{
f32 channelVolume;
s32 i;
if (seqChannel->changes.as_bitfields.volume || recalculateVolume) {
if (seqChannel->changes.as_bitfields.volume || recalculateVolume)
{
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->appliedFadeVolume;
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0)
{
channelVolume = seqChannel->seqPlayer->muteVolumeScale * channelVolume;
}
#ifdef VERSION_SH
seqChannel->appliedVolume = channelVolume * channelVolume;
seqChannel->appliedVolume= channelVolume* channelVolume;
#else
seqChannel->appliedVolume = channelVolume;
seqChannel->appliedVolume= channelVolume;
#endif
}
}
if (seqChannel->changes.as_bitfields.pan) {
seqChannel->pan = seqChannel->newPan * seqChannel->panChannelWeight;
}
for (i = 0; i < 4; ++i) {
for (i =0; i<4;++i) {
struct SequenceChannelLayer *layer = seqChannel->layers[i];
if (layer != NULL && layer->enabled && layer->note != NULL) {
if (layer != nullptr && layer->enabled && layer->note != nullptr) {
if (layer->notePropertiesNeedInit) {
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
@@ -55,58 +58,69 @@ void sequence_channel_process_sound(struct SequenceChannel *seqChannel, s32 reca
}
}
}
seqChannel->changes.as_u8 = 0;
seqChannel->changes.as_u8=0;
}
#else
static void sequence_channel_process_sound(struct SequenceChannel *seqChannel) {
static void sequence_channel_process_sound(struct SequenceChannel *seqChannel)
{
f32 channelVolume;
f32 panLayerWeight;
f32 panFromChannel;
s32 i;
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->fadeVolume;
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0) {
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & MUTE_BEHAVIOR_SOFTEN) != 0)
{
channelVolume *= seqChannel->seqPlayer->muteVolumeScale;
}
panFromChannel = seqChannel->pan * seqChannel->panChannelWeight;
panLayerWeight = US_FLOAT(1.0) - seqChannel->panChannelWeight;
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
struct SequenceChannelLayer *layer = seqChannel->layers[i];
if (layer != NULL && layer->enabled && layer->note != NULL) {
if (layer != nullptr && layer->enabled && layer->note != nullptr)
{
layer->noteFreqScale = layer->freqScale * seqChannel->freqScale;
layer->noteVelocity = layer->velocitySquare * (channelVolume * gTrackVolume);
layer->notePan = (layer->pan * panLayerWeight) + panFromChannel;
layer->notePan = layer->pan * panLayerWeight + panFromChannel;
}
}
}
#endif
void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
void sequence_player_process_sound(struct SequencePlayer *seqPlayer)
{
s32 i;
if (seqPlayer->fadeRemainingFrames != 0) {
if (seqPlayer->fadeRemainingFrames != 0)
{
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
seqPlayer->recalculateVolume = TRUE;
#endif
#endif
if (seqPlayer->fadeVolume > US_FLOAT2(1)) {
if (seqPlayer->fadeVolume > US_FLOAT2(1))
{
seqPlayer->fadeVolume = US_FLOAT2(1);
}
if (seqPlayer->fadeVolume < 0) {
if (seqPlayer->fadeVolume < 0)
{
seqPlayer->fadeVolume = 0;
}
if (--seqPlayer->fadeRemainingFrames == 0) {
#if defined(VERSION_EU) || defined(VERSION_SH)
if (seqPlayer->state == 2) {
if (--seqPlayer->fadeRemainingFrames == 0)
{
#if defined(VERSION_EU) || defined(VERSION_SH)
if (seqPlayer->state == 2)
{
sequence_player_disable(seqPlayer);
return;
}
#else
switch (seqPlayer->state) {
#else
switch (seqPlayer->state)
{
case SEQUENCE_PLAYER_STATE_FADE_OUT:
sequence_player_disable(seqPlayer);
return;
@@ -119,77 +133,85 @@ void sequence_player_process_sound(struct SequencePlayer *seqPlayer) {
case SEQUENCE_PLAYER_STATE_4:
break;
}
#endif
#endif
}
}
#if defined(VERSION_EU) || defined(VERSION_SH)
if (seqPlayer->recalculateVolume) {
#if defined(VERSION_EU) || defined(VERSION_SH)
if (seqPlayer->recalculateVolume)
{
seqPlayer->appliedFadeVolume = seqPlayer->fadeVolume * seqPlayer->fadeVolumeScale;
}
#endif
#endif
// Process channels
for (i = 0; i < CHANNELS_MAX; i++) {
for (i = 0; i < CHANNELS_MAX; i++)
{
if (IS_SEQUENCE_CHANNEL_VALID(seqPlayer->channels[i]) == TRUE
&& seqPlayer->channels[i]->enabled == TRUE) {
#if defined(VERSION_EU) || defined(VERSION_SH)
&& seqPlayer->channels[i]->enabled == TRUE)
{
#if defined(VERSION_EU) || defined(VERSION_SH)
sequence_channel_process_sound(seqPlayer->channels[i], seqPlayer->recalculateVolume);
#else
#else
sequence_channel_process_sound(seqPlayer->channels[i]);
#endif
#endif
}
}
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
seqPlayer->recalculateVolume = FALSE;
#endif
#endif
}
f32 get_portamento_freq_scale(struct Portamento *p) {
f32 get_portamento_freq_scale(struct Portamento *p)
{
u32 v0;
f32 result;
#if defined(VERSION_JP) || defined(VERSION_US)
if (p->mode == 0) {
#if defined(VERSION_JP) || defined(VERSION_US)
if (p->mode == 0)
{
return 1.0f;
}
#endif
#endif
p->cur += p->speed;
v0 = (u32) p->cur;
v0 = (u32)p->cur;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
if (v0 > 127)
#else
#else
if (v0 >= 127)
#endif
#endif
{
v0 = 127;
}
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
result = US_FLOAT(1.0) + p->extent * (gPitchBendFrequencyScale[v0 + 128] - US_FLOAT(1.0));
#else
#else
result = US_FLOAT(1.0) + p->extent * (gPitchBendFrequencyScale[v0 + 127] - US_FLOAT(1.0));
#endif
#endif
return result;
}
#if defined(VERSION_EU) || defined(VERSION_SH)
s16 get_vibrato_pitch_change(struct VibratoState *vib) {
s16 get_vibrato_pitch_change(struct VibratoState *vib)
{
s32 index;
vib->time += (s32) vib->rate;
vib->time += (s32)vib->rate;
index = (vib->time >> 10) & 0x3F;
return vib->curve[index] >> 8;
}
#else
s8 get_vibrato_pitch_change(struct VibratoState *vib) {
s8 get_vibrato_pitch_change(struct VibratoState *vib)
{
s32 index;
vib->time += vib->rate;
index = (vib->time >> 10) & 0x3F;
index = vib->time >> 10 & 0x3F;
switch (index & 0x30) {
switch (index & 0x30)
{
case 0x10:
index = 31 - index;
@@ -209,181 +231,226 @@ s8 get_vibrato_pitch_change(struct VibratoState *vib) {
}
#endif
f32 get_vibrato_freq_scale(struct VibratoState *vib) {
f32 get_vibrato_freq_scale(struct VibratoState *vib)
{
s32 pitchChange;
f32 extent;
f32 result;
if (vib->delay != 0) {
if (vib->delay != 0)
{
vib->delay--;
return 1;
}
if (vib->extentChangeTimer) {
if (vib->extentChangeTimer == 1) {
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
} else {
if (vib->extentChangeTimer)
{
if (vib->extentChangeTimer == 1)
{
vib->extent = (s32)vib->seqChannel->vibratoExtentTarget;
}
else
{
vib->extent +=
((s32) vib->seqChannel->vibratoExtentTarget - vib->extent) / (s32) vib->extentChangeTimer;
((s32)vib->seqChannel->vibratoExtentTarget - vib->extent) / (s32)vib->extentChangeTimer;
}
vib->extentChangeTimer--;
} else if (vib->seqChannel->vibratoExtentTarget != (s32) vib->extent) {
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0) {
vib->extent = (s32) vib->seqChannel->vibratoExtentTarget;
}
else if (vib->seqChannel->vibratoExtentTarget != (s32)vib->extent)
{
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0)
{
vib->extent = (s32)vib->seqChannel->vibratoExtentTarget;
}
}
if (vib->rateChangeTimer) {
if (vib->rateChangeTimer == 1) {
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
} else {
vib->rate += ((s32) vib->seqChannel->vibratoRateTarget - vib->rate) / (s32) vib->rateChangeTimer;
if (vib->rateChangeTimer)
{
if (vib->rateChangeTimer == 1)
{
vib->rate = (s32)vib->seqChannel->vibratoRateTarget;
}
else
{
vib->rate += ((s32)vib->seqChannel->vibratoRateTarget - vib->rate) / (s32)vib->rateChangeTimer;
}
vib->rateChangeTimer--;
} else if (vib->seqChannel->vibratoRateTarget != (s32) vib->rate) {
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0) {
vib->rate = (s32) vib->seqChannel->vibratoRateTarget;
}
else if (vib->seqChannel->vibratoRateTarget != (s32)vib->rate)
{
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0)
{
vib->rate = (s32)vib->seqChannel->vibratoRateTarget;
}
}
if (vib->extent == 0) {
if (vib->extent == 0)
{
return 1.0f;
}
pitchChange = get_vibrato_pitch_change(vib);
extent = (f32) vib->extent / US_FLOAT(4096.0);
extent = (f32)vib->extent / US_FLOAT(4096.0);
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
result = US_FLOAT(1.0) + extent * (gPitchBendFrequencyScale[pitchChange + 128] - US_FLOAT(1.0));
#else
#else
result = US_FLOAT(1.0) + extent * (gPitchBendFrequencyScale[pitchChange + 127] - US_FLOAT(1.0));
#endif
#endif
return result;
}
void note_vibrato_update(struct Note *note) {
#if defined(VERSION_EU) || defined(VERSION_SH)
if (note->portamento.mode != 0) {
void note_vibrato_update(struct Note *note)
{
#if defined(VERSION_EU) || defined(VERSION_SH)
if (note->portamento.mode != 0)
{
note->portamentoFreqScale = get_portamento_freq_scale(&note->portamento);
}
if (note->vibratoState.active && note->parentLayer != NO_LAYER) {
if (note->vibratoState.active && note->parentLayer != NO_LAYER)
{
note->vibratoFreqScale = get_vibrato_freq_scale(&note->vibratoState);
}
#else
if (note->vibratoState.active) {
#else
if (note->vibratoState.active)
{
note->portamentoFreqScale = get_portamento_freq_scale(&note->portamento);
if (note->parentLayer != NO_LAYER) {
if (note->parentLayer != NO_LAYER)
{
note->vibratoFreqScale = get_vibrato_freq_scale(&note->vibratoState);
}
}
#endif
#endif
}
void note_vibrato_init(struct Note *note) {
void note_vibrato_init(struct Note *note)
{
struct VibratoState *vib;
UNUSED struct SequenceChannel *seqChannel;
#if defined(VERSION_EU) || defined(VERSION_SH)
struct NotePlaybackState *seqPlayerState = (struct NotePlaybackState *) &note->priority;
#endif
UNUSED
struct SequenceChannel *seqChannel;
#if defined(VERSION_EU) || defined(VERSION_SH)
struct NotePlaybackState *seqPlayerState = (struct NotePlaybackState *)&note->priority;
#endif
note->vibratoFreqScale = 1.0f;
note->portamentoFreqScale = 1.0f;
vib = &note->vibratoState;
#if defined(VERSION_JP) || defined(VERSION_US)
#if defined(VERSION_JP) || defined(VERSION_US)
if (note->parentLayer->seqChannel->vibratoExtentStart == 0
&& note->parentLayer->seqChannel->vibratoExtentTarget == 0
&& note->parentLayer->portamento.mode == 0) {
&& note->parentLayer->portamento.mode == 0)
{
vib->active = FALSE;
return;
}
#endif
#endif
vib->active = TRUE;
vib->time = 0;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
vib->curve = gWaveSamples[2];
vib->seqChannel = note->parentLayer->seqChannel;
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0) {
if ((vib->extentChangeTimer = vib->seqChannel->vibratoExtentChangeDelay) == 0)
{
vib->extent = FLOAT_CAST(vib->seqChannel->vibratoExtentTarget);
} else {
}
else
{
vib->extent = FLOAT_CAST(vib->seqChannel->vibratoExtentStart);
}
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0) {
if ((vib->rateChangeTimer = vib->seqChannel->vibratoRateChangeDelay) == 0)
{
vib->rate = FLOAT_CAST(vib->seqChannel->vibratoRateTarget);
} else {
}
else
{
vib->rate = FLOAT_CAST(vib->seqChannel->vibratoRateStart);
}
vib->delay = vib->seqChannel->vibratoDelay;
seqPlayerState->portamento = seqPlayerState->parentLayer->portamento;
#else
#else
vib->curve = gVibratoCurve;
vib->seqChannel = note->parentLayer->seqChannel;
seqChannel = vib->seqChannel;
if ((vib->extentChangeTimer = seqChannel->vibratoExtentChangeDelay) == 0) {
if ((vib->extentChangeTimer = seqChannel->vibratoExtentChangeDelay) == 0)
{
vib->extent = seqChannel->vibratoExtentTarget;
} else {
}
else
{
vib->extent = seqChannel->vibratoExtentStart;
}
if ((vib->rateChangeTimer = seqChannel->vibratoRateChangeDelay) == 0) {
if ((vib->rateChangeTimer = seqChannel->vibratoRateChangeDelay) == 0)
{
vib->rate = seqChannel->vibratoRateTarget;
} else {
}
else
{
vib->rate = seqChannel->vibratoRateStart;
}
vib->delay = seqChannel->vibratoDelay;
note->portamento = note->parentLayer->portamento;
#endif
#endif
}
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, UNUSED s16 *volOut) {
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, UNUSED s16 *volOut)
{
adsr->action = 0;
adsr->state = ADSR_STATE_DISABLED;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
adsr->delay = 0;
adsr->envelope = envelope;
#ifdef VERSION_SH
#ifdef VERSION_SH
adsr->sustain = 0.0f;
#endif
#endif
adsr->current = 0.0f;
#else
#else
adsr->initial = 0;
adsr->delay = 0;
adsr->velocity = 0;
adsr->envelope = envelope;
adsr->volOut = volOut;
#endif
#endif
}
#if defined(VERSION_EU) || defined(VERSION_SH)
f32 adsr_update(struct AdsrState *adsr) {
f32 adsr_update(struct AdsrState *adsr)
{
#else
s32 adsr_update(struct AdsrState *adsr) {
#endif
s32 adsr_update(struct AdsrState *adsr)
{
#endif
u8 action = adsr->action;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
u8 state = adsr->state;
switch (state) {
#else
switch (adsr->state) {
#endif
#else
switch (adsr->state)
{
#endif
case ADSR_STATE_DISABLED:
return 0;
case ADSR_STATE_INITIAL: {
#if defined(VERSION_JP) || defined(VERSION_US)
case ADSR_STATE_INITIAL:
{
#if defined(VERSION_JP) || defined(VERSION_US)
adsr->current = adsr->initial;
adsr->target = adsr->initial;
#endif
if (action & ADSR_ACTION_HANG) {
#endif
if (action & ADSR_ACTION_HANG)
{
adsr->state = ADSR_STATE_HANG;
break;
}
@@ -392,18 +459,19 @@ s32 adsr_update(struct AdsrState *adsr) {
case ADSR_STATE_START_LOOP:
adsr->envIndex = 0;
#if defined(VERSION_JP) || defined(VERSION_US)
#if defined(VERSION_JP) || defined(VERSION_US)
adsr->currentHiRes = adsr->current << 0x10;
#endif
#endif
adsr->state = ADSR_STATE_LOOP;
// fallthrough
#ifdef VERSION_SH
#ifdef VERSION_SH
restart:
#endif
#endif
case ADSR_STATE_LOOP:
adsr->delay = BSWAP16(adsr->envelope[adsr->envIndex].delay);
switch (adsr->delay) {
switch (adsr->delay)
{
case ADSR_DISABLE:
adsr->state = ADSR_STATE_DISABLED;
break;
@@ -412,55 +480,59 @@ s32 adsr_update(struct AdsrState *adsr) {
break;
case ADSR_GOTO:
adsr->envIndex = BSWAP16(adsr->envelope[adsr->envIndex].arg);
#ifdef VERSION_SH
#ifdef VERSION_SH
goto restart;
#else
#else
break;
#endif
#endif
case ADSR_RESTART:
adsr->state = ADSR_STATE_INITIAL;
break;
default:
#if defined(VERSION_EU) || defined(VERSION_SH)
if (adsr->delay >= 4) {
#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;
}
#if defined(VERSION_SH)
if (adsr->delay == 0) {
#if defined(VERSION_SH)
if (adsr->delay == 0)
{
adsr->delay = 1;
}
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 = (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
#else
adsr->target = BSWAP16(adsr->envelope[adsr->envIndex].arg);
adsr->velocity = ((adsr->target - adsr->current) << 0x10) / adsr->delay;
#endif
#endif
adsr->state = ADSR_STATE_FADE;
adsr->envIndex++;
break;
}
if (adsr->state != ADSR_STATE_FADE) {
if (adsr->state != ADSR_STATE_FADE)
{
break;
}
// fallthrough
case ADSR_STATE_FADE:
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
adsr->current += adsr->velocity;
#else
#else
adsr->currentHiRes += adsr->velocity;
adsr->current = adsr->currentHiRes >> 0x10;
#endif
if (--adsr->delay <= 0) {
#endif
if (--adsr->delay <= 0)
{
adsr->state = ADSR_STATE_LOOP;
}
// fallthrough
@@ -469,77 +541,88 @@ s32 adsr_update(struct AdsrState *adsr) {
break;
case ADSR_STATE_DECAY:
case ADSR_STATE_RELEASE: {
case ADSR_STATE_RELEASE:
{
adsr->current -= adsr->fadeOutVel;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
if (adsr->sustain != 0.0f && state == ADSR_STATE_DECAY) {
#else
if (adsr->sustain != 0 && adsr->state == ADSR_STATE_DECAY) {
#endif
if (adsr->current < adsr->sustain) {
#else
if (adsr->sustain != 0 && adsr->state == ADSR_STATE_DECAY)
{
#endif
if (adsr->current < adsr->sustain)
{
adsr->current = adsr->sustain;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
adsr->delay = 128;
#else
#else
adsr->delay = adsr->sustain / 16;
#endif
#endif
adsr->state = ADSR_STATE_SUSTAIN;
}
break;
}
#if defined(VERSION_SH)
if (adsr->current < 0.00001f) {
#if defined(VERSION_SH)
if (adsr->current < 0.00001f)
{
adsr->current = 0.0f;
adsr->state = ADSR_STATE_DISABLED;
}
#elif defined(VERSION_EU)
if (adsr->current < 0) {
#elif defined(VERSION_EU)
if (adsr->current < 0)
{
adsr->current = 0.0f;
adsr->state = ADSR_STATE_DISABLED;
}
#else
if (adsr->current < 100) {
#else
if (adsr->current < 100)
{
adsr->current = 0;
adsr->state = ADSR_STATE_DISABLED;
}
#endif
#endif
break;
}
case ADSR_STATE_SUSTAIN:
adsr->delay -= 1;
if (adsr->delay == 0) {
if (adsr->delay == 0)
{
adsr->state = ADSR_STATE_RELEASE;
}
break;
}
if ((action & ADSR_ACTION_DECAY)) {
if (action & ADSR_ACTION_DECAY)
{
adsr->state = ADSR_STATE_DECAY;
adsr->action = action & ~ADSR_ACTION_DECAY;
}
if ((action & ADSR_ACTION_RELEASE)) {
if (action & ADSR_ACTION_RELEASE)
{
adsr->state = ADSR_STATE_RELEASE;
#if defined(VERSION_EU) || defined(VERSION_SH)
#if defined(VERSION_EU) || defined(VERSION_SH)
adsr->action = action & ~ADSR_ACTION_RELEASE;
#else
#else
adsr->action = action & ~(ADSR_ACTION_RELEASE | ADSR_ACTION_DECAY);
#endif
#endif
}
#if defined(VERSION_EU) || defined(VERSION_SH)
if (adsr->current < 0.0f) {
#if defined(VERSION_EU) || defined(VERSION_SH)
if (adsr->current < 0.0f)
{
return 0.0f;
}
if (adsr->current > 1.0f) {
if (adsr->current > 1.0f)
{
eu_stubbed_printf_1("Audio:Envp: overflow %f\n", adsr->current);
return 1.0f;
}
return adsr->current;
#else
#else
*adsr->volOut = adsr->current;
return 0;
#endif
#endif
}
+3
View File
@@ -36,8 +36,11 @@
extern f32 gTrackVolume;
void sequence_player_process_sound(struct SequencePlayer *seqPlayer);
void note_vibrato_update(struct Note *note);
void note_vibrato_init(struct Note *note);
void adsr_init(struct AdsrState *adsr, struct AdsrEnvelope *envelope, s16 *volOut);
#if defined(VERSION_EU) || defined(VERSION_SH)
f32 adsr_update(struct AdsrState *adsr);
File diff suppressed because it is too large Load Diff
+37 -2
View File
@@ -24,7 +24,8 @@ extern u32 gAudioRandom;
extern f32 gAudioVolume;
extern u8 gAudioReverb;
struct Sound {
struct Sound
{
s32 soundBits;
f32 *position;
}; // size = 0x8
@@ -35,39 +36,73 @@ extern u8 sSoundRequestCount;
extern u8 gAudioSPTaskYieldBuffer[]; // ucode yield data ptr; only used in JP
struct SPTask *create_next_audio_frame_task(void);
void create_next_audio_buffer(s16 *samples, u32 num_samples);
void audio_signal_game_loop_tick(void);
void update_game_sound(void);
void seq_player_fade_out(u8 player, u16 fadeDuration);
void fade_volume_scale(u8 player, u8 targetScale, u16 fadeDuration);
void seq_player_lower_volume(u8 player, u16 fadeDuration, u8 percentage);
void seq_player_unlower_volume(u8 player, u16 fadeDuration);
void set_audio_muted(u8 muted);
void sound_init(void);
void get_currently_playing_sound(u8 bank, u8 *numPlayingSounds, u8 *numSoundsInBank, u8 *soundId);
void stop_sound(u32 soundBits, f32 *pos);
void stop_sounds_from_source(f32 *pos);
void stop_sounds_from_source(f32 * pos);
void stop_sounds_in_continuous_banks(void);
void sound_banks_disable(u8 player, u16 bankMask);
void sound_banks_enable(u8 player, u16 bankMask);
void set_sound_moving_speed(u8 bank, u8 speed);
void play_dialog_sound(u8 dialogID);
void play_music(u8 player, u16 seqArgs, u16 fadeTimer);
void stop_background_music(u16 seqId);
void fadeout_background_music(u16 arg0, u16 fadeOut);
void drop_queued_background_music(void);
u16 get_current_background_music(void);
void play_secondary_music(u8 seqId, u8 bgMusicVolume, u8 volume, u16 fadeTimer);
void func_80321080(u16 fadeTimer);
void func_803210D4(u16 fadeOutTime);
void play_course_clear(void);
void play_peachs_jingle(void);
void play_puzzle_jingle(void);
void play_star_fanfare(void);
void play_power_star_jingle(u8 arg0);
void play_race_fanfare(void);
void play_toads_jingle(void);
void sound_reset(u8 presetId);
void audio_set_sound_mode(u8 arg0);
void audio_init(void); // in load.c
+799 -504
View File
File diff suppressed because it is too large Load Diff
+35 -17
View File
@@ -23,34 +23,41 @@ struct SoundAllocPool
s32 numAllocatedEntries;
}; // size = 0x10
struct SeqOrBankEntry {
struct SeqOrBankEntry
{
u8 *ptr;
u32 size;
#ifdef VERSION_SH
#ifdef VERSION_SH
s16 poolIndex;
s16 id;
#else
#else
s32 id; // seqId or bankId
#endif
#endif
}; // size = 0xC
struct PersistentPool
{
/*0x00*/ u32 numEntries;
/*0x04*/ struct SoundAllocPool pool;
/*0x14*/ struct SeqOrBankEntry entries[32];
/*0x00*/
u32 numEntries;
/*0x04*/
struct SoundAllocPool pool;
/*0x14*/
struct SeqOrBankEntry entries[32];
}; // size = 0x194
struct TemporaryPool
{
/*EU, SH*/
/*0x00, 0x00*/ u32 nextSide;
/*0x04, */ struct SoundAllocPool pool;
/*0x00, 0x00*/
u32 nextSide;
/*0x04, */
struct SoundAllocPool pool;
/*0x04, pool.start */
/*0x08, pool.cur */
/*0x0C, 0x0C pool.size */
/*0x10, 0x10 pool.numAllocatedEntries */
/*0x14, */ struct SeqOrBankEntry entries[2];
/*0x14, */
struct SeqOrBankEntry entries[2];
/*0x14, 0x14 entries[0].ptr */
/*0x18, entries[0].size*/
/*0x1C, 0x1E entries[0].id */
@@ -61,9 +68,12 @@ struct TemporaryPool
struct SoundMultiPool
{
/*0x000*/ struct PersistentPool persistent;
/*0x194*/ struct TemporaryPool temporary;
/* */ u32 pad2[4];
/*0x000*/
struct PersistentPool persistent;
/*0x194*/
struct TemporaryPool temporary;
/* */
u32 pad2[4];
}; // size = 0x1D0
struct Unk1Pool
@@ -85,10 +95,14 @@ struct UnkEntry
struct UnkPool
{
/*0x00*/ struct SoundAllocPool pool;
/*0x10*/ struct UnkEntry entries[64];
/*0x510*/ s32 numEntries;
/*0x514*/ u32 unk514;
/*0x00*/
struct SoundAllocPool pool;
/*0x10*/
struct UnkEntry entries[64];
/*0x510*/
s32 numEntries;
/*0x514*/
u32 unk514;
};
extern u8 gAudioHeap[];
@@ -115,14 +129,18 @@ extern volatile u8 gAudioResetStatus;
#endif
void *soundAlloc(struct SoundAllocPool *pool, u32 size);
void *sound_alloc_uninitialized(struct SoundAllocPool *pool, u32 size);
void sound_init_main_pools(s32 sizeForAudioInitPool);
void sound_alloc_pool_init(struct SoundAllocPool *pool, void *memAddr, u32 size);
#ifdef VERSION_SH
void *alloc_bank_or_seq(s32 poolIdx, s32 size, s32 arg3, s32 id);
void *get_bank_or_seq(s32 poolIdx, s32 arg1, s32 id);
#else
void *alloc_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 size, s32 arg3, s32 id);
void *get_bank_or_seq(struct SoundMultiPool *arg0, s32 arg1, s32 id);
#endif
#if defined(VERSION_EU) || defined(VERSION_SH)
File diff suppressed because it is too large Load Diff
+397 -272
View File
File diff suppressed because it is too large Load Diff
+7 -4
View File
@@ -56,7 +56,8 @@ extern s8 gSoundMode;
#ifdef VERSION_SH
extern OSMesgQueue gUnkQueue1;
struct UnkStructSH8034EC88 {
struct UnkStructSH8034EC88
{
u8 *endAndMediumIdentification;
struct AudioBankSample *sample;
u8 *ramAddr;
@@ -64,7 +65,8 @@ struct UnkStructSH8034EC88 {
s32 isFree;
};
struct PatchStruct {
struct PatchStruct
{
s32 bankId1;
s32 bankId2;
void *baseAddr1;
@@ -78,7 +80,8 @@ extern struct UnkStructSH8034EC88 D_SH_8034EC88[0x80];
struct AudioBank *bank_load_immediate(s32 bankId, s32 arg1);
void audio_dma_partial_copy_async(uintptr_t *devAddr, u8 **vAddr, ssize_t *remaining, OSMesgQueue *queue, OSIoMesg *mesg);
void audio_dma_partial_copy_async(uintptr_t * devAddr, u8 * *vAddr, ssize_t * remaining, OSMesgQueue * queue, OSIoMesg * mesg);
void decrease_sample_dma_ttls(void);
#ifdef VERSION_SH
void *dma_sample_data(uintptr_t devAddr, u32 size, s32 arg2, u8 *dmaIndexRef, s32 medium);
@@ -105,7 +108,7 @@ struct AudioBankSample *func_sh_802f4978(s32 bankId, s32 idx);
s32 func_sh_802f47c8(s32 bankId, u8 idx, s8 *io);
void *func_sh_802f3f08(s32 poolIdx, s32 arg1, s32 arg2, s32 arg3, OSMesgQueue *retQueue);
void func_sh_802f41e4(s32 audioResetStatus);
BAD_RETURN(s32) func_sh_802f3368(s32 bankId);
BAD_RETURN (s32) func_sh_802f3368(s32 bankId);
void *func_sh_802f3764(s32 arg0, s32 idx, s32 *arg2);
s32 func_sh_802f3024(s32 bankId, s32 instId, s32 arg2);
void func_sh_802f30f4(s32 arg0, s32 arg1, s32 arg2, OSMesgQueue *arg3);
+1 -1
View File
@@ -7,5 +7,5 @@ struct seqFile *gSoundDataRaw;
struct seqFile *gMusicData;
#ifndef VERSION_SH
unsigned char* gBankSetsData;
unsigned char *gBankSetsData;
#endif
+651 -384
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+12
View File
@@ -17,17 +17,29 @@
#define NOTE_ALLOC_GLOBAL_FREELIST 8
void process_notes(void);
void seq_channel_layer_note_decay(struct SequenceChannelLayer *seqLayer);
void seq_channel_layer_note_release(struct SequenceChannelLayer *seqLayer);
void init_synthetic_wave(struct Note *note, struct SequenceChannelLayer *seqLayer);
void init_note_lists(struct NotePool *pool);
void init_note_free_list(void);
void note_pool_clear(struct NotePool *pool);
void note_pool_fill(struct NotePool *pool, s32 count);
void audio_list_push_front(struct AudioListItem *list, struct AudioListItem *item);
void audio_list_remove(struct AudioListItem *item);
struct Note *alloc_note(struct SequenceChannelLayer *seqLayer);
void reclaim_notes(void);
void note_init_all(void);
#if defined(VERSION_SH)
+106 -62
View File
@@ -34,7 +34,8 @@ s32 audio_shut_down_and_reset_step(void);
void func_802ad7ec(u32);
#ifdef TARGET_N64
struct SPTask *create_next_audio_frame_task(void) {
struct SPTask *create_next_audio_frame_task(void)
{
u32 samplesRemainingInAI;
s32 writtenCmds;
s32 index;
@@ -46,12 +47,13 @@ struct SPTask *create_next_audio_frame_task(void) {
OSMesg sp2C;
gAudioFrameCount++;
if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0) {
if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0)
{
stubbed_printf("DAC:Lost 1 Frame.\n");
return NULL;
return nullptr;
}
osSendMesg(OSMesgQueues[0], (OSMesg) gAudioFrameCount, 0);
osSendMesg(OSMesgQueues[0], (OSMesg)gAudioFrameCount, 0);
gAudioTaskIndex ^= 1;
gCurrAiBufferIndex++;
@@ -59,28 +61,35 @@ struct SPTask *create_next_audio_frame_task(void) {
index = (gCurrAiBufferIndex - 2 + NUMAIBUFFERS) % NUMAIBUFFERS;
samplesRemainingInAI = osAiGetLength() / 4;
if (gAiBufferLengths[index] != 0) {
if (gAiBufferLengths[index] != 0)
{
osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4);
}
oldDmaCount = gCurrAudioFrameDmaCount;
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE) {
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE)
{
stubbed_printf("DMA: Request queue over.( %d )\n", oldDmaCount);
}
gCurrAudioFrameDmaCount = 0;
decrease_sample_dma_ttls();
if (osRecvMesg(OSMesgQueues[2], &sp30, 0) != -1) {
gAudioResetPresetIdToLoad = (u8) (s32) sp30;
if (osRecvMesg(OSMesgQueues[2], &sp30, 0) != -1)
{
gAudioResetPresetIdToLoad = (u8)(s32)
sp30;
gAudioResetStatus = 5;
}
if (gAudioResetStatus != 0) {
if (audio_shut_down_and_reset_step() == 0) {
if (gAudioResetStatus == 0) {
osSendMesg(OSMesgQueues[3], (OSMesg) (s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
if (gAudioResetStatus != 0)
{
if (audio_shut_down_and_reset_step() == 0)
{
if (gAudioResetStatus == 0)
{
osSendMesg(OSMesgQueues[3], (OSMesg)(s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
}
return NULL;
return nullptr;
}
}
@@ -91,15 +100,18 @@ struct SPTask *create_next_audio_frame_task(void) {
gAiBufferLengths[index] = ((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI +
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xf) + SAMPLES_TO_OVERPRODUCE;
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength)
{
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
}
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) {
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength)
{
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
}
if (osRecvMesg(OSMesgQueues[1], &sp2C, OS_MESG_NOBLOCK) != -1) {
func_802ad7ec((u32) sp2C);
if (osRecvMesg(OSMesgQueues[1], &sp2C, OS_MESG_NOBLOCK) != -1)
{
func_802ad7ec((u32)sp2C);
}
flags = 0;
@@ -108,48 +120,54 @@ struct SPTask *create_next_audio_frame_task(void) {
gAudioRandom = gAudioRandom + writtenCmds / 8;
index = gAudioTaskIndex;
gAudioTask->msgqueue = NULL;
gAudioTask->msg = NULL;
gAudioTask->msgqueue = nullptr;
gAudioTask->msg = nullptr;
task = &gAudioTask->task.t;
task->type = M_AUDTASK;
task->flags = flags;
task->ucode_boot = rspF3DBootStart;
task->ucode_boot_size = (u8 *) rspF3DBootEnd - (u8 *) rspF3DBootStart;
task->ucode_boot_size = (u8 *)rspF3DBootEnd - (u8 *)rspF3DBootStart;
task->ucode = rspAspMainStart;
task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x800; // (this size is ignored)
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
task->dram_stack = NULL;
task->dram_stack = nullptr;
task->dram_stack_size = 0;
task->output_buff = NULL;
task->output_buff_size = NULL;
task->output_buff = nullptr;
task->output_buff_size = nullptr;
task->data_ptr = gAudioCmdBuffers[index];
task->data_size = writtenCmds * sizeof(u64);
task->yield_data_ptr = NULL;
task->yield_data_ptr = nullptr;
task->yield_data_size = 0;
return gAudioTask;
}
#else
struct SPTask *create_next_audio_frame_task(void) {
return NULL;
struct SPTask *create_next_audio_frame_task(void)
{
return nullptr;
}
void create_next_audio_buffer(s16 *samples, u32 num_samples) {
void create_next_audio_buffer(s16 *samples, u32 num_samples)
{
s32 writtenCmds;
OSMesg msg;
gAudioFrameCount++;
decrease_sample_dma_ttls();
if (osRecvMesg(OSMesgQueues[2], &msg, 0) != -1) {
gAudioResetPresetIdToLoad = (u8) (intptr_t) msg;
if (osRecvMesg(OSMesgQueues[2], &msg, 0) != -1)
{
gAudioResetPresetIdToLoad = (u8)(intptr_t)
msg;
gAudioResetStatus = 5;
}
if (gAudioResetStatus != 0) {
if (gAudioResetStatus != 0)
{
audio_reset_session();
gAudioResetStatus = 0;
}
if (osRecvMesg(OSMesgQueues[1], &msg, OS_MESG_NOBLOCK) != -1) {
func_802ad7ec((u32) msg);
if (osRecvMesg(OSMesgQueues[1], &msg, OS_MESG_NOBLOCK) != -1)
{
func_802ad7ec((u32)msg);
}
synthesis_execute(gAudioCmdBuffers[0], &writtenCmds, samples, num_samples);
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
@@ -157,10 +175,12 @@ void create_next_audio_buffer(s16 *samples, u32 num_samples) {
}
#endif
void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
void eu_process_audio_cmd(struct EuAudioCmd *cmd)
{
s32 i;
switch (cmd->u.s.op) {
switch (cmd->u.s.op)
{
case 0x81:
preload_sequence(cmd->u.s.arg2, 3);
break;
@@ -172,11 +192,14 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
break;
case 0x83:
if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) {
if (cmd->u2.as_s32 == 0) {
if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE)
{
if (cmd->u2.as_s32 == 0)
{
sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]);
}
else {
else
{
seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32);
}
}
@@ -187,14 +210,16 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
break;
case 0xf1:
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
gSequencePlayers[i].muted = TRUE;
gSequencePlayers[i].recalculateVolume = TRUE;
}
break;
case 0xf2:
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
gSequencePlayers[i].muted = FALSE;
gSequencePlayers[i].recalculateVolume = TRUE;
}
@@ -212,18 +237,21 @@ extern OSMesg OSMesg1;
extern OSMesg OSMesg2;
extern OSMesg OSMesg3;
void seq_player_fade_to_zero_volume(s32 player, FadeT fadeOutTime) {
if (fadeOutTime == 0) {
void seq_player_fade_to_zero_volume(s32 player, FadeT fadeOutTime)
{
if (fadeOutTime == 0)
{
fadeOutTime = 1;
}
gSequencePlayers[player].fadeVelocity = -(gSequencePlayers[player].fadeVolume / fadeOutTime);
gSequencePlayers[player].state = 2;
gSequencePlayers[player].fadeRemainingFrames = fadeOutTime;
}
void func_8031D690(s32 player, FadeT fadeInTime) {
if (fadeInTime != 0) {
void func_8031D690(s32 player, FadeT fadeInTime)
{
if (fadeInTime != 0)
{
gSequencePlayers[player].state = 1;
gSequencePlayers[player].fadeTimerUnkEu = fadeInTime;
gSequencePlayers[player].fadeRemainingFrames = fadeInTime;
@@ -232,7 +260,8 @@ void func_8031D690(s32 player, FadeT fadeInTime) {
}
}
void port_eu_init_queues(void) {
void port_eu_init_queues(void)
{
D_EU_80302010 = 0;
D_EU_80302014 = 0;
osCreateMesgQueue(OSMesgQueues[0], &OSMesg0, 1);
@@ -241,51 +270,62 @@ void port_eu_init_queues(void) {
osCreateMesgQueue(OSMesgQueues[3], &OSMesg3, 1);
}
void func_802ad6f0(s32 arg0, s32 *arg1) {
void func_802ad6f0(s32 arg0, s32 *arg1)
{
struct EuAudioCmd *cmd = &sAudioCmd[D_EU_80302010 & 0xff];
cmd->u.first = arg0;
cmd->u2.as_u32 = *arg1;
D_EU_80302010++;
}
void func_802ad728(u32 arg0, f32 arg1) {
func_802ad6f0(arg0, (s32*) &arg1);
void func_802ad728(u32 arg0, f32 arg1)
{
func_802ad6f0(arg0, (s32 *)&arg1);
}
void func_802ad74c(u32 arg0, u32 arg1) {
func_802ad6f0(arg0, (s32*) &arg1);
void func_802ad74c(u32 arg0, u32 arg1)
{
func_802ad6f0(arg0, (s32 *)&arg1);
}
void func_802ad770(u32 arg0, s8 arg1) {
void func_802ad770(u32 arg0, s8 arg1)
{
s32 sp1C = arg1 << 24;
func_802ad6f0(arg0, &sp1C);
}
void func_802ad7a0(void) {
void func_802ad7a0(void)
{
osSendMesg(OSMesgQueues[1],
(OSMesg)(u32)((D_EU_80302014 & 0xff) << 8 | (D_EU_80302010 & 0xff)),
OS_MESG_NOBLOCK);
D_EU_80302014 = D_EU_80302010;
}
void func_802ad7ec(u32 arg0) {
void func_802ad7ec(u32 arg0)
{
struct EuAudioCmd *cmd;
struct SequencePlayer *seqPlayer;
struct SequenceChannel *chan;
u8 end = arg0 & 0xff;
u8 i = (arg0 >> 8) & 0xff;
for (;;) {
for (;;)
{
if (i == end) break;
cmd = &sAudioCmd[i++ & 0xff];
if (cmd->u.s.arg1 < SEQUENCE_PLAYERS) {
if (cmd->u.s.arg1 < SEQUENCE_PLAYERS)
{
seqPlayer = &gSequencePlayers[cmd->u.s.arg1];
if ((cmd->u.s.op & 0x80) != 0) {
if ((cmd->u.s.op & 0x80) != 0)
{
eu_process_audio_cmd(cmd);
}
else if ((cmd->u.s.op & 0x40) != 0) {
switch (cmd->u.s.op) {
else if ((cmd->u.s.op & 0x40) != 0)
{
switch (cmd->u.s.op)
{
case 0x41:
seqPlayer->fadeVolumeScale = cmd->u2.as_f32;
seqPlayer->recalculateVolume = TRUE;
@@ -304,11 +344,13 @@ void func_802ad7ec(u32 arg0) {
break;
}
}
else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) {
else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10)
{
chan = seqPlayer->channels[cmd->u.s.arg2];
if (IS_SEQUENCE_CHANNEL_VALID(chan))
{
switch (cmd->u.s.op) {
switch (cmd->u.s.op)
{
case 1:
chan->volumeScale = cmd->u2.as_f32;
chan->changes.as_bitfields.volume = TRUE;
@@ -329,7 +371,8 @@ void func_802ad7ec(u32 arg0) {
chan->reverbVol = cmd->u2.as_s8;
break;
case 6:
if (cmd->u.s.arg3 < 8) {
if (cmd->u.s.arg3 < 8)
{
chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8;
}
break;
@@ -344,7 +387,8 @@ void func_802ad7ec(u32 arg0) {
}
}
void port_eu_init(void) {
void port_eu_init(void)
{
port_eu_init_queues();
}
+205 -116
View File
@@ -24,7 +24,8 @@ void seq_player_fade_to_zero_volume(s32 arg0, s32 numFrames);
void func_802ad7ec(u32 arg0);
#ifdef TARGET_N64
struct SPTask *create_next_audio_frame_task(void) {
struct SPTask *create_next_audio_frame_task(void)
{
u32 samplesRemainingInAI;
s32 writtenCmds;
s32 index;
@@ -37,13 +38,15 @@ struct SPTask *create_next_audio_frame_task(void) {
s32 writtenCmdsCopy;
gAudioFrameCount++;
if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0) {
if ((gAudioFrameCount % gAudioBufferParameters.presetUnk4) + 1 == gAudioBufferParameters.presetUnk4) {
if (gAudioFrameCount % gAudioBufferParameters.presetUnk4 != 0)
{
if ((gAudioFrameCount % gAudioBufferParameters.presetUnk4) + 1 == gAudioBufferParameters.presetUnk4)
{
return D_SH_80314FCC;
}
return NULL;
return nullptr;
}
osSendMesg(D_SH_80350F38, (OSMesg) gAudioFrameCount, OS_MESG_NOBLOCK);
osSendMesg(D_SH_80350F38, (OSMesg)gAudioFrameCount, OS_MESG_NOBLOCK);
gAudioTaskIndex ^= 1;
gCurrAiBufferIndex++;
@@ -51,123 +54,149 @@ struct SPTask *create_next_audio_frame_task(void) {
index = (gCurrAiBufferIndex - 2 + NUMAIBUFFERS) % NUMAIBUFFERS;
samplesRemainingInAI = osAiGetLength() / 4;
if (gAudioLoadLockSH < 0x10U) {
if (gAiBufferLengths[index] != 0) {
if (gAudioLoadLockSH < 0x10U)
{
if (gAiBufferLengths[index] != 0)
{
osAiSetNextBuffer(gAiBuffers[index], gAiBufferLengths[index] * 4);
}
}
oldDmaCount = gCurrAudioFrameDmaCount;
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE) {
if (oldDmaCount > AUDIO_FRAME_DMA_QUEUE_SIZE)
{
}
gCurrAudioFrameDmaCount = 0;
decrease_sample_dma_ttls();
func_sh_802f41e4(gAudioResetStatus);
if (osRecvMesg(D_SH_80350F88, (OSMesg *) &sp38, OS_MESG_NOBLOCK) != -1) {
if (gAudioResetStatus == 0) {
if (osRecvMesg(D_SH_80350F88, (OSMesg *)&sp38, OS_MESG_NOBLOCK) != -1)
{
if (gAudioResetStatus == 0)
{
gAudioResetStatus = 5;
}
gAudioResetPresetIdToLoad = (u8) sp38;
gAudioResetPresetIdToLoad = (u8)sp38;
}
if (gAudioResetStatus != 0) {
if (audio_shut_down_and_reset_step() == 0) {
if (gAudioResetStatus == 0) {
osSendMesg(D_SH_80350FA8, (OSMesg) (s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
if (gAudioResetStatus != 0)
{
if (audio_shut_down_and_reset_step() == 0)
{
if (gAudioResetStatus == 0)
{
osSendMesg(D_SH_80350FA8, (OSMesg)(s32) gAudioResetPresetIdToLoad, OS_MESG_NOBLOCK);
}
D_SH_80314FCC = 0;
return NULL;
return nullptr;
}
}
if (gAudioLoadLockSH >= 0x11U) {
return NULL;
if (gAudioLoadLockSH >= 0x11U)
{
return nullptr;
}
if (gAudioLoadLockSH != 0) {
if (gAudioLoadLockSH != 0)
{
gAudioLoadLockSH++;
}
gAudioTask = &gAudioTasks[gAudioTaskIndex];
gAudioCmd = (u64 *) gAudioCmdBuffers[gAudioTaskIndex];
gAudioCmd = (u64 *)gAudioCmdBuffers[gAudioTaskIndex];
index = gCurrAiBufferIndex;
currAiBuffer = gAiBuffers[index];
gAiBufferLengths[index] = (s16) ((((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI) +
gAiBufferLengths[index] = (s16)((((gAudioBufferParameters.samplesPerFrameTarget - samplesRemainingInAI) +
EXTRA_BUFFERED_AI_SAMPLES_TARGET) & ~0xf) + SAMPLES_TO_OVERPRODUCE);
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength) {
if (gAiBufferLengths[index] < gAudioBufferParameters.minAiBufferLength)
{
gAiBufferLengths[index] = gAudioBufferParameters.minAiBufferLength;
}
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength) {
if (gAiBufferLengths[index] > gAudioBufferParameters.maxAiBufferLength)
{
gAiBufferLengths[index] = gAudioBufferParameters.maxAiBufferLength;
}
if (osRecvMesg(D_SH_80350F68, (OSMesg *) &sp34, 0) != -1) {
do {
if (osRecvMesg(D_SH_80350F68, (OSMesg *)&sp34, 0) != -1)
{
do
{
func_802ad7ec(sp34);
} while (osRecvMesg(D_SH_80350F68, (OSMesg *) &sp34, 0) != -1);
}
while (osRecvMesg(D_SH_80350F68, (OSMesg *)&sp34, 0) != -1);
}
flags = 0;
gAudioCmd = synthesis_execute(gAudioCmd, &writtenCmds, currAiBuffer, gAiBufferLengths[index]);
gAudioRandom = (u32) (osGetCount() * (gAudioRandom + gAudioFrameCount));
gAudioRandom = (u32) (gAiBuffers[index][gAudioFrameCount & 0xFF] + gAudioRandom);
gAudioRandom = (u32)(osGetCount() * (gAudioRandom + gAudioFrameCount));
gAudioRandom = (u32)(gAiBuffers[index][gAudioFrameCount & 0xFF] + gAudioRandom);
index = gAudioTaskIndex;
gAudioTask->msgqueue = NULL;
gAudioTask->msg = NULL;
gAudioTask->msgqueue = nullptr;
gAudioTask->msg = nullptr;
task = &gAudioTask->task.t;
task->type = M_AUDTASK;
task->flags = flags;
task->ucode_boot = rspF3DBootStart;
task->ucode_boot_size = (u8 *) rspF3DStart - (u8 *) rspF3DBootStart;
task->ucode_boot_size = (u8 *)rspF3DStart - (u8 *)rspF3DBootStart;
task->ucode = rspAspMainStart;
task->ucode_data = rspAspMainDataStart;
task->ucode_size = 0x1000;
task->ucode_data_size = (rspAspMainDataEnd - rspAspMainDataStart) * sizeof(u64);
task->dram_stack = NULL;
task->dram_stack = nullptr;
task->dram_stack_size = 0;
task->output_buff = NULL;
task->output_buff_size = NULL;
task->output_buff = nullptr;
task->output_buff_size = nullptr;
task->data_ptr = gAudioCmdBuffers[index];
task->data_size = writtenCmds * sizeof(u64);
task->yield_data_ptr = NULL;
task->yield_data_ptr = nullptr;
task->yield_data_size = 0;
writtenCmdsCopy = writtenCmds;
if (D_SH_80314FC8 < writtenCmdsCopy) {
if (D_SH_80314FC8 < writtenCmdsCopy)
{
D_SH_80314FC8 = writtenCmdsCopy;
}
if (gAudioBufferParameters.presetUnk4 == 1) {
if (gAudioBufferParameters.presetUnk4 == 1)
{
return gAudioTask;
} else {
}
else
{
D_SH_80314FCC = gAudioTask;
return NULL;
return nullptr;
}
}
#else
struct SPTask *create_next_audio_frame_task(void) {
return NULL;
struct SPTask *create_next_audio_frame_task(void)
{
return nullptr;
}
void create_next_audio_buffer(s16 *samples, u32 num_samples) {
void create_next_audio_buffer(s16 *samples, u32 num_samples)
{
s32 writtenCmds;
OSMesg msg;
gAudioFrameCount++;
decrease_sample_dma_ttls();
if (osRecvMesg(D_SH_80350F88, &msg, 0) != -1) {
gAudioResetPresetIdToLoad = (u8) (intptr_t) msg;
if (gAudioResetStatus == 0) {
if (osRecvMesg(D_SH_80350F88, &msg, 0) != -1)
{
gAudioResetPresetIdToLoad = (u8)(intptr_t)
msg;
if (gAudioResetStatus == 0)
{
gAudioResetStatus = 5;
}
}
if (gAudioResetStatus != 0) {
if (gAudioResetStatus != 0)
{
audio_reset_session();
gAudioResetStatus = 0;
}
while (osRecvMesg(D_SH_80350F68, &msg, OS_MESG_NOBLOCK) != -1) {
func_802ad7ec((u32) msg);
while (osRecvMesg(D_SH_80350F68, &msg, OS_MESG_NOBLOCK) != -1)
{
func_802ad7ec((u32)msg);
}
synthesis_execute(gAudioCmdBuffers[0], &writtenCmds, samples, num_samples);
gAudioRandom = ((gAudioRandom + gAudioFrameCount) * gAudioFrameCount);
@@ -176,12 +205,14 @@ void create_next_audio_buffer(s16 *samples, u32 num_samples) {
}
#endif
void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
void eu_process_audio_cmd(struct EuAudioCmd *cmd)
{
s32 i;
struct Note *note;
struct NoteSubEu *sub;
switch (cmd->u.s.op) {
switch (cmd->u.s.op)
{
case 0x81:
preload_sequence(cmd->u.s.arg2, 3);
break;
@@ -193,11 +224,14 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
break;
case 0x83:
if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE) {
if (cmd->u2.as_s32 == 0) {
if (gSequencePlayers[cmd->u.s.arg1].enabled != FALSE)
{
if (cmd->u2.as_s32 == 0)
{
sequence_player_disable(&gSequencePlayers[cmd->u.s.arg1]);
}
else {
else
{
seq_player_fade_to_zero_volume(cmd->u.s.arg1, cmd->u2.as_s32);
}
}
@@ -211,25 +245,31 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
break;
case 0xf1:
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
gSequencePlayers[i].muted = TRUE;
gSequencePlayers[i].recalculateVolume = TRUE;
}
break;
case 0xf2:
if (cmd->u2.as_s32 == 1) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (cmd->u2.as_s32 == 1)
{
for (i = 0; i < gMaxSimultaneousNotes; i++)
{
note = &gNotes[i];
sub = &note->noteSubEu;
if (note->noteSubEu.enabled && note->unkSH34 == 0) {
if ((note->parentLayer->seqChannel->muteBehavior & 8) != 0) {
if (note->noteSubEu.enabled && note->unkSH34 == 0)
{
if ((note->parentLayer->seqChannel->muteBehavior & 8) != 0)
{
sub->finished = TRUE;
}
}
}
}
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
gSequencePlayers[i].muted = FALSE;
gSequencePlayers[i].recalculateVolume = TRUE;
}
@@ -253,22 +293,26 @@ void eu_process_audio_cmd(struct EuAudioCmd *cmd) {
}
}
void seq_player_fade_to_zero_volume(s32 arg0, s32 fadeOutTime) {
void seq_player_fade_to_zero_volume(s32 arg0, s32 fadeOutTime)
{
struct SequencePlayer *player;
if (fadeOutTime == 0) {
if (fadeOutTime == 0)
{
fadeOutTime = 1;
}
player = &gSequencePlayers[arg0];
player->state = 2;
player->fadeRemainingFrames = fadeOutTime;
player->fadeVelocity = -(player->fadeVolume / (f32) fadeOutTime);
player->fadeVelocity = -(player->fadeVolume / (f32)fadeOutTime);
}
void func_8031D690(s32 playerIndex, s32 fadeInTime) {
void func_8031D690(s32 playerIndex, s32 fadeInTime)
{
struct SequencePlayer *player;
if (fadeInTime != 0) {
if (fadeInTime != 0)
{
player = &gSequencePlayers[playerIndex];
player->state = 1;
player->fadeTimerUnkEu = fadeInTime;
@@ -278,7 +322,8 @@ void func_8031D690(s32 playerIndex, s32 fadeInTime) {
}
}
void port_eu_init_queues(void) {
void port_eu_init_queues(void)
{
D_SH_80350F18 = 0;
D_SH_80350F19 = 0;
D_SH_80350F38 = &D_SH_80350F20;
@@ -292,36 +337,43 @@ void port_eu_init_queues(void) {
}
extern struct EuAudioCmd sAudioCmd[0x100];
void func_802ad6f0(s32 arg0, s32 *arg1) {
void func_802ad6f0(s32 arg0, s32 *arg1)
{
struct EuAudioCmd *cmd = &sAudioCmd[D_SH_80350F18 & 0xff];
cmd->u.first = arg0;
cmd->u2.as_u32 = *arg1;
D_SH_80350F18++;
if (D_SH_80350F18 == D_SH_80350F19) {
if (D_SH_80350F18 == D_SH_80350F19)
{
D_SH_80350F18--;
}
}
void func_802ad728(u32 arg0, f32 arg1) {
func_802ad6f0(arg0, (s32 *) &arg1);
void func_802ad728(u32 arg0, f32 arg1)
{
func_802ad6f0(arg0, (s32 *)&arg1);
}
void func_802ad74c(u32 arg0, u32 arg1) {
func_802ad6f0(arg0, (s32 *) &arg1);
void func_802ad74c(u32 arg0, u32 arg1)
{
func_802ad6f0(arg0, (s32 *)&arg1);
}
void func_802ad770(u32 arg0, s8 arg1) {
void func_802ad770(u32 arg0, s8 arg1)
{
s32 sp1C = arg1 << 24;
func_802ad6f0(arg0, &sp1C);
}
char shindouDebugPrint133[] = "AudioSend: %d -> %d (%d)\n";
void func_sh_802F64C8(void) {
void func_sh_802F64C8(void)
{
static s32 D_SH_8031503C = 0;
s32 mesg;
if (((D_SH_80350F18 - D_SH_80350F19 + 0x100) & 0xff) > D_SH_8031503C) {
if (((D_SH_80350F18 - D_SH_80350F19 + 0x100) & 0xff) > D_SH_8031503C)
{
D_SH_8031503C = (D_SH_80350F18 - D_SH_80350F19 + 0x100) & 0xff;
}
mesg = ((D_SH_80350F19 & 0xff) << 8) | (D_SH_80350F18 & 0xff);
@@ -329,11 +381,13 @@ void func_sh_802F64C8(void) {
D_SH_80350F19 = D_SH_80350F18;
}
void func_sh_802f6540(void) {
void func_sh_802f6540(void)
{
D_SH_80350F19 = D_SH_80350F18;
}
void func_802ad7ec(u32 arg0) {
void func_802ad7ec(u32 arg0)
{
struct EuAudioCmd *cmd;
struct SequencePlayer *seqPlayer;
struct SequenceChannel *chan;
@@ -347,35 +401,45 @@ void func_802ad7ec(u32 arg0) {
static u8 D_SH_80315098 = 0;
static u8 D_SH_8031509C = 0;
if (D_SH_8031509C == 0) {
if (D_SH_8031509C == 0)
{
D_SH_80315098 = (arg0 >> 8) & 0xff;
}
end = arg0 & 0xff;
for (;;) {
if (D_SH_80315098 == end) {
for (;;)
{
if (D_SH_80315098 == end)
{
D_SH_8031509C = 0;
break;
}
cmd = &sAudioCmd[D_SH_80315098 & 0xff];
D_SH_80315098++;
if (cmd->u.s.op == 0xf8) {
if (cmd->u.s.op == 0xf8)
{
D_SH_8031509C = 1;
break;
}
else if ((cmd->u.s.op & 0xf0) == 0xf0) {
else if ((cmd->u.s.op & 0xf0) == 0xf0)
{
eu_process_audio_cmd(cmd);
}
else if (cmd->u.s.arg1 < SEQUENCE_PLAYERS) {
else if (cmd->u.s.arg1 < SEQUENCE_PLAYERS)
{
seqPlayer = &gSequencePlayers[cmd->u.s.arg1];
if ((cmd->u.s.op & 0x80) != 0) {
if ((cmd->u.s.op & 0x80) != 0)
{
eu_process_audio_cmd(cmd);
}
else if ((cmd->u.s.op & 0x40) != 0) {
switch (cmd->u.s.op) {
else if ((cmd->u.s.op & 0x40) != 0)
{
switch (cmd->u.s.op)
{
case 0x41:
if (seqPlayer->fadeVolumeScale != cmd->u2.as_f32) {
if (seqPlayer->fadeVolumeScale != cmd->u2.as_f32)
{
seqPlayer->fadeVolumeScale = cmd->u2.as_f32;
seqPlayer->recalculateVolume = TRUE;
}
@@ -398,43 +462,51 @@ void func_802ad7ec(u32 arg0) {
break;
}
}
else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10) {
else if (seqPlayer->enabled != FALSE && cmd->u.s.arg2 < 0x10)
{
chan = seqPlayer->channels[cmd->u.s.arg2];
if (IS_SEQUENCE_CHANNEL_VALID(chan))
{
switch (cmd->u.s.op) {
switch (cmd->u.s.op)
{
case 1:
if (chan->volumeScale != cmd->u2.as_f32) {
if (chan->volumeScale != cmd->u2.as_f32)
{
chan->volumeScale = cmd->u2.as_f32;
chan->changes.as_bitfields.volume = TRUE;
}
break;
case 2:
if (chan->volume != cmd->u2.as_f32) {
if (chan->volume != cmd->u2.as_f32)
{
chan->volume = cmd->u2.as_f32;
chan->changes.as_bitfields.volume = TRUE;
}
break;
case 3:
if (chan->newPan != cmd->u2.as_s8) {
if (chan->newPan != cmd->u2.as_s8)
{
chan->newPan = cmd->u2.as_s8;
chan->changes.as_bitfields.pan = TRUE;
}
break;
case 4:
if (chan->freqScale != cmd->u2.as_f32) {
if (chan->freqScale != cmd->u2.as_f32)
{
chan->freqScale = cmd->u2.as_f32;
chan->changes.as_bitfields.freqScale = TRUE;
}
break;
case 5:
//! @bug u8 s8 comparison (but harmless)
if (chan->reverbVol != cmd->u2.as_s8) {
if (chan->reverbVol != cmd->u2.as_s8)
{
chan->reverbVol = cmd->u2.as_s8;
}
break;
case 6:
if (cmd->u.s.arg3 < 8) {
if (cmd->u.s.arg3 < 8)
{
chan->soundScriptIO[cmd->u.s.arg3] = cmd->u2.as_s8;
}
break;
@@ -452,74 +524,91 @@ void func_802ad7ec(u32 arg0) {
}
}
u32 func_sh_802f6878(s32 *arg0) {
u32 func_sh_802f6878(s32 *arg0)
{
u32 sp1C;
if (osRecvMesg(&gUnkQueue1, (OSMesg *) &sp1C, 0) == -1) {
if (osRecvMesg(&gUnkQueue1, (OSMesg *)&sp1C, 0) == -1)
{
*arg0 = 0;
return 0U;
}
*arg0 = (s32) (sp1C & 0xFFFFFF);
*arg0 = (s32)(sp1C & 0xFFFFFF);
return sp1C >> 0x18;
}
u8 *func_sh_802f68e0(u32 index, u32 *a1) {
u8 *func_sh_802f68e0(u32 index, u32 *a1)
{
return func_sh_802f3220(index, a1);
}
s32 func_sh_802f6900(void) {
s32 func_sh_802f6900(void)
{
s32 ret;
s32 sp18;
ret = osRecvMesg(D_SH_80350FA8, (OSMesg *) &sp18, 0);
ret = osRecvMesg(D_SH_80350FA8, (OSMesg *)&sp18, 0);
if (ret == -1) {
if (ret == -1)
{
return 0;
}
if (sp18 != gAudioResetPresetIdToLoad) {
if (sp18 != gAudioResetPresetIdToLoad)
{
return 0;
} else {
}
else
{
return 1;
}
}
// TODO: (Scrub C)
void func_sh_802f6958(OSMesg mesg) {
void func_sh_802f6958(OSMesg mesg)
{
s32 a;
OSMesg recvMesg;
do {
do
{
a = -1;
} while (osRecvMesg(D_SH_80350FA8, &recvMesg, OS_MESG_NOBLOCK) != a);
}
while (osRecvMesg(D_SH_80350FA8, &recvMesg, OS_MESG_NOBLOCK) != a);
func_sh_802f6540();
osSendMesg(D_SH_80350F88, mesg, OS_MESG_NOBLOCK);
}
void func_sh_802f69cc(void) {
void func_sh_802f69cc(void)
{
gAudioLoadLockSH = 1;
func_sh_802f6958(0);
gAudioResetStatus = 0;
}
s32 func_sh_802f6a08(s32 playerIndex, s32 channelIndex, s32 soundScriptIOIndex) {
s32 func_sh_802f6a08(s32 playerIndex, s32 channelIndex, s32 soundScriptIOIndex)
{
struct SequenceChannel *seqChannel;
struct SequencePlayer *player;
player = &gSequencePlayers[playerIndex];
if (player->enabled) {
if (player->enabled)
{
seqChannel = player->channels[channelIndex];
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel)) {
if (IS_SEQUENCE_CHANNEL_VALID(seqChannel))
{
return seqChannel->soundScriptIO[soundScriptIOIndex];
}
}
return -1;
}
s8 func_sh_802f6a6c(s32 playerIndex, s32 index) {
s8 func_sh_802f6a6c(s32 playerIndex, s32 index)
{
return gSequencePlayers[playerIndex].seqVariationEu[index];
}
void port_eu_init(void) {
void port_eu_init(void)
{
port_eu_init_queues();
}
@@ -540,17 +629,17 @@ char shindouDebugPrint151[] = "Audio: voiceman: progNo. undefined %d,%d\n";
char shindouDebugPrint152[] = "Audio: voiceman: No bank error %d\n";
char shindouDebugPrint153[] = "Audio: voiceman: Percussion Overflow %d,%d\n";
char shindouDebugPrint154[] = "Audio: voiceman: Percussion table pointer (bank %d) is irregular %x.\n";
char shindouDebugPrint155[] = "Audio: voiceman: Percpointer NULL %d,%d\n";
char shindouDebugPrint155[] = "Audio: voiceman: Percpointer nullptr %d,%d\n";
char shindouDebugPrint156[] = "--4 %x\n";
char shindouDebugPrint157[] = "NoteOff Comes during wait release %x (note %x)\n";
char shindouDebugPrint158[] = "Slow Release Batting\n";
u8 euUnknownData_8030194c[4] = { 0x40, 0x20, 0x10, 0x08 };
u8 euUnknownData_8030194c[4] = {0x40, 0x20, 0x10, 0x08};
char shindouDebugPrint159[] = "Audio:Wavemem: Bad voiceno (%d)\n";
char shindouDebugPrint160[] = "Audio: C-Alloc : Dealloc voice is NULL\n";
char shindouDebugPrint160[] = "Audio: C-Alloc : Dealloc voice is nullptr\n";
char shindouDebugPrint161[] = "Alloc Error:Dim voice-Alloc %d";
char shindouDebugPrint162[] = "Error:Same List Add\n";
char shindouDebugPrint163[] = "Already Cut\n";
char shindouDebugPrint164[] = "Audio: C-Alloc : lowerPrio is NULL\n";
char shindouDebugPrint164[] = "Audio: C-Alloc : lowerPrio is nullptr\n";
char shindouDebugPrint165[] = "Intterupt UseStop %d (Kill %d)\n";
char shindouDebugPrint166[] = "Intterupt RelWait %d (Kill %d)\n";
char shindouDebugPrint167[] = "Drop Voice (Prio %x)\n";
+1036 -737
View File
File diff suppressed because it is too large Load Diff
+8 -1
View File
@@ -7,12 +7,19 @@
#include "playback.h"
void seq_channel_layer_disable(struct SequenceChannelLayer *seqPlayer);
void sequence_channel_disable(struct SequenceChannel *seqPlayer);
void sequence_player_disable(struct SequencePlayer* seqPlayer);
void sequence_player_disable(struct SequencePlayer *seqPlayer);
void audio_list_push_back(struct AudioListItem *list, struct AudioListItem *item);
void *audio_list_pop_back(struct AudioListItem *list);
void process_sequences(s32 iterationsRemaining);
void init_sequence_player(u32 player);
void init_sequence_players(void);
#endif // AUDIO_SEQPLAYER_H
+3 -3
View File
@@ -6,7 +6,7 @@ char shindouDebugPrint1[] = "Terminate-Canceled Channel %d,Phase %d\n";
char shindouDebugPrint2[] = "S->W\n";
char shindouDebugPrint3[] = "W->S\n";
char shindouDebugPrint4[] = "S-Resample Pitch %x (old %d -> delay %d)\n";
s32 shindouDebugPrintPadding1[] = {0,0,0};
s32 shindouDebugPrintPadding1[] = {0, 0, 0};
// heap.c
char shindouDebugPrint5[] = "Warning:Kill Note %x \n";
@@ -60,7 +60,7 @@ char shindouDebugPrint52[] = "Try Kill %d \n";
char shindouDebugPrint53[] = "Try Kill %x %x\n";
char shindouDebugPrint54[] = "Try Kill %x %x %x\n";
char shindouDebugPrint55[] = "Rom back %x %x \n";
char shindouDebugPrint56[] = "Error sw NULL \n";
char shindouDebugPrint56[] = "Error sw nullptr \n";
char shindouDebugPrint57[] = "Request--------Single-Stay, %d\n";
char shindouDebugPrint58[] = "Try Kill %d \n";
char shindouDebugPrint59[] = "Try Kill %x %x\n";
@@ -140,7 +140,7 @@ char shindouDebugPrint127[] = "Spec Change Override. %d -> %d\n";
char shindouDebugPrint128[] = "Audio:now-max tasklen is %d / %d\n";
char shindouDebugPrint129[] = "Audio:Warning:ABI Tasklist length over (%d)\n";
s32 D_SH_80314FC8 = 0x80;
struct SPTask *D_SH_80314FCC = NULL;
struct SPTask *D_SH_80314FCC = nullptr;
char shindouDebugPrint130[] = "BGLOAD Start %d\n";
char shindouDebugPrint131[] = "Error: OverFlow Your Request\n";
char shindouDebugPrint132[] = "---AudioSending (%d->%d) \n";
File diff suppressed because it is too large Load Diff
+40 -24
View File
@@ -30,46 +30,62 @@ struct ReverbRingBufferItem
struct SynthesisReverb
{
/*0x00, 0x00, 0x00*/ u8 resampleFlags;
/*0x01, 0x01, 0x01*/ u8 useReverb;
/*0x02, 0x02, 0x02*/ u8 framesLeftToIgnore;
/*0x03, 0x03, 0x03*/ u8 curFrame;
#if defined(VERSION_EU) || defined(VERSION_SH)
/*0x00, 0x00, 0x00*/
u8 resampleFlags;
/*0x01, 0x01, 0x01*/
u8 useReverb;
/*0x02, 0x02, 0x02*/
u8 framesLeftToIgnore;
/*0x03, 0x03, 0x03*/
u8 curFrame;
#if defined(VERSION_EU) || defined(VERSION_SH)
/* 0x04, 0x04*/ u8 downsampleRate;
#ifdef VERSION_SH
#ifdef VERSION_SH
/* 0x05*/ s8 unk5;
#endif
#endif
/* 0x06, 0x06*/ u16 windowSize; // same as bufSizePerChannel
#endif
#ifdef VERSION_SH
#endif
#ifdef VERSION_SH
/* 0x08*/ u16 unk08;
#endif
/*0x04, 0x08, 0x0A*/ u16 reverbGain;
/*0x06, 0x0A, 0x0C*/ u16 resampleRate;
#ifdef VERSION_SH
#endif
/*0x04, 0x08, 0x0A*/
u16 reverbGain;
/*0x06, 0x0A, 0x0C*/
u16 resampleRate;
#ifdef VERSION_SH
/* 0x0E*/ u16 panRight;
/* 0x10*/ u16 panLeft;
#endif
/*0x08, 0x0C, 0x14*/ s32 nextRingBufferPos;
/*0x0C, 0x10, 0x18*/ s32 unkC; // never read
/*0x10, 0x14, 0x1C*/ s32 bufSizePerChannel;
#endif
/*0x08, 0x0C, 0x14*/
s32 nextRingBufferPos;
/*0x0C, 0x10, 0x18*/
s32 unkC; // never read
/*0x10, 0x14, 0x1C*/
s32 bufSizePerChannel;
struct
{
s16 *left;
s16 *right;
} ringBuffer;
/*0x1C, 0x20, 0x28*/ s16 *resampleStateLeft;
/*0x20, 0x24, 0x2C*/ s16 *resampleStateRight;
/*0x24, 0x28, 0x30*/ s16 *unk24; // never read
/*0x28, 0x2C, 0x34*/ s16 *unk28; // never read
/*0x2C, 0x30, 0x38*/ struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME];
#if defined(VERSION_EU) || defined(VERSION_SH)
/*0x1C, 0x20, 0x28*/
s16 *resampleStateLeft;
/*0x20, 0x24, 0x2C*/
s16 *resampleStateRight;
/*0x24, 0x28, 0x30*/
s16 *unk24; // never read
/*0x28, 0x2C, 0x34*/
s16 *unk28; // never read
/*0x2C, 0x30, 0x38*/
struct ReverbRingBufferItem items[2][MAX_UPDATES_PER_FRAME];
#if defined(VERSION_EU) || defined(VERSION_SH)
// Only used in sh:
/* 0x100*/ s16 *unk100;
/* 0x104*/ s16 *unk104;
/* 0x108*/ s16 *unk108;
/* 0x10C*/ s16 *unk10C;
#endif
#endif
}; // 0xCC <= size <= 0x100
#if defined(VERSION_EU) || defined(VERSION_SH)
extern struct SynthesisReverb gSynthesisReverbs[4];
+319 -148
View File
@@ -39,7 +39,8 @@
#define ALIGN(val, amnt) (((val) + (1 << amnt) - 1) & ~((1 << amnt) - 1))
struct VolumeChange {
struct VolumeChange
{
u16 sourceLeft;
u16 sourceRight;
u16 targetLeft;
@@ -65,7 +66,8 @@ struct NoteSubEu *gNoteSubsEu;
// Equivalent functionality as the US/JP version,
// just that the reverb structure is chosen from an array with index
// Identical in EU.
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex) {
void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
{
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb = &gSynthesisReverbs[reverbIndex];
s32 srcPos;
@@ -73,8 +75,10 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
s32 nSamples;
s32 excessiveSamples;
s32 UNUSED pad[3];
if (reverb->downsampleRate != 1) {
if (reverb->framesLeftToIgnore == 0) {
if (reverb->downsampleRate != 1)
{
if (reverb->framesLeftToIgnore == 0)
{
// Now that the RSP has finished, downsample the samples produced two frames ago by skipping
// samples.
item = &reverb->items[reverb->curFrame][updateIndex];
@@ -83,13 +87,15 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
osInvalDCache(item->toDownsampleLeft, DEFAULT_LEN_2CH);
for (srcPos = 0, dstPos = 0; dstPos < item->lengthA / 2;
srcPos += reverb->downsampleRate, dstPos++) {
srcPos += reverb->downsampleRate, dstPos++)
{
reverb->ringBuffer.left[item->startPos + dstPos] =
item->toDownsampleLeft[srcPos];
reverb->ringBuffer.right[item->startPos + dstPos] =
item->toDownsampleRight[srcPos];
}
for (dstPos = 0; dstPos < item->lengthB / 2; srcPos += reverb->downsampleRate, dstPos++) {
for (dstPos = 0; dstPos < item->lengthB / 2; srcPos += reverb->downsampleRate, dstPos++)
{
reverb->ringBuffer.left[dstPos] = item->toDownsampleLeft[srcPos];
reverb->ringBuffer.right[dstPos] = item->toDownsampleRight[srcPos];
}
@@ -99,13 +105,16 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
item = &reverb->items[reverb->curFrame][updateIndex];
nSamples = chunkLen / reverb->downsampleRate;
excessiveSamples = (nSamples + reverb->nextRingBufferPos) - reverb->bufSizePerChannel;
if (excessiveSamples < 0) {
if (excessiveSamples < 0)
{
// There is space in the ring buffer before it wraps around
item->lengthA = nSamples * 2;
item->lengthB = 0;
item->startPos = (s32) reverb->nextRingBufferPos;
item->startPos = (s32)reverb->nextRingBufferPos;
reverb->nextRingBufferPos += nSamples;
} else {
}
else
{
// Ring buffer wrapped around
item->lengthA = (nSamples - excessiveSamples) * 2;
item->lengthB = excessiveSamples * 2;
@@ -117,7 +126,8 @@ void prepare_reverb_ring_buffer(s32 chunkLen, u32 updateIndex, s32 reverbIndex)
item->chunkLen = chunkLen;
}
u64 *synthesis_load_reverb_ring_buffer(u64 *cmd, u16 addr, u16 srcOffset, s32 len, s32 reverbIndex) {
u64 *synthesis_load_reverb_ring_buffer(u64 *cmd, u16 addr, u16 srcOffset, s32 len, s32 reverbIndex)
{
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[srcOffset]),
addr, len);
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.right[srcOffset]),
@@ -125,7 +135,8 @@ u64 *synthesis_load_reverb_ring_buffer(u64 *cmd, u16 addr, u16 srcOffset, s32 le
return cmd;
}
u64 *synthesis_save_reverb_ring_buffer(u64 *cmd, u16 addr, u16 destOffset, s32 len, s32 reverbIndex) {
u64 *synthesis_save_reverb_ring_buffer(u64 *cmd, u16 addr, u16 destOffset, s32 len, s32 reverbIndex)
{
aSaveBuffer(cmd++, addr,
VIRTUAL_TO_PHYSICAL2(&gSynthesisReverbs[reverbIndex].ringBuffer.left[destOffset]), len);
aSaveBuffer(cmd++, addr + DEFAULT_LEN_1CH,
@@ -133,71 +144,96 @@ u64 *synthesis_save_reverb_ring_buffer(u64 *cmd, u16 addr, u16 destOffset, s32 l
return cmd;
}
void func_sh_802ed644(s32 updateIndexStart, s32 noteIndex) {
void func_sh_802ed644(s32 updateIndexStart, s32 noteIndex)
{
s32 i;
for (i = updateIndexStart + 1; i < gAudioBufferParameters.updatesPerFrame; i++) {
if (!gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].needsInit) {
for (i = updateIndexStart + 1; i < gAudioBufferParameters.updatesPerFrame; i++)
{
if (!gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].needsInit)
{
gNoteSubsEu[gMaxSimultaneousNotes * i + noteIndex].enabled = FALSE;
} else {
}
else
{
break;
}
}
}
void synthesis_load_note_subs_eu(s32 updateIndex) {
void synthesis_load_note_subs_eu(s32 updateIndex)
{
struct NoteSubEu *src;
struct NoteSubEu *dest;
s32 i;
for (i = 0; i < gMaxSimultaneousNotes; i++) {
for (i = 0; i < gMaxSimultaneousNotes; i++)
{
src = &gNotes[i].noteSubEu;
dest = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (src->enabled) {
if (src->enabled)
{
*dest = *src;
src->needsInit = FALSE;
} else {
}
else
{
dest->enabled = FALSE;
}
}
}
// TODO: (Scrub C) pointless mask and whitespace
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen)
{
s32 i, j;
u32 *aiBufPtr;
u64 *cmd = cmdBuf;
s32 chunkLen;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--)
{
process_sequences(i - 1);
synthesis_load_note_subs_eu(gAudioBufferParameters.updatesPerFrame - i);
}
aiBufPtr = (u32 *) aiBuf;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--) {
if (i == 1) {
aiBufPtr = (u32 *)aiBuf;
for (i = gAudioBufferParameters.updatesPerFrame; i > 0; i--)
{
if (i == 1)
{
chunkLen = bufLen;
} else {
if (bufLen / i >= gAudioBufferParameters.samplesPerUpdateMax) {
}
else
{
if (bufLen / i >= gAudioBufferParameters.samplesPerUpdateMax)
{
chunkLen = gAudioBufferParameters.samplesPerUpdateMax;
} else if (bufLen / i <= gAudioBufferParameters.samplesPerUpdateMin) {
}
else if (bufLen / i <= gAudioBufferParameters.samplesPerUpdateMin)
{
chunkLen = gAudioBufferParameters.samplesPerUpdateMin;
} else {
}
else
{
chunkLen = gAudioBufferParameters.samplesPerUpdate;
}
}
for (j = 0; j < gNumSynthesisReverbs; j++) {
if (gSynthesisReverbs[j].useReverb != 0) {
for (j = 0; j < gNumSynthesisReverbs; j++)
{
if (gSynthesisReverbs[j].useReverb != 0)
{
prepare_reverb_ring_buffer(chunkLen, gAudioBufferParameters.updatesPerFrame - i, j);
}
}
cmd = synthesis_do_one_audio_update((s16 *) aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
cmd = synthesis_do_one_audio_update((s16 *)aiBufPtr, chunkLen, cmd, gAudioBufferParameters.updatesPerFrame - i);
bufLen -= chunkLen;
aiBufPtr += chunkLen;
}
for (j = 0; j < gNumSynthesisReverbs; j++) {
if (gSynthesisReverbs[j].framesLeftToIgnore != 0) {
for (j = 0; j < gNumSynthesisReverbs; j++)
{
if (gSynthesisReverbs[j].framesLeftToIgnore != 0)
{
gSynthesisReverbs[j].framesLeftToIgnore--;
}
gSynthesisReverbs[j].curFrame ^= 1;
@@ -206,26 +242,32 @@ u64 *synthesis_execute(u64 *cmdBuf, s32 *writtenCmds, s16 *aiBuf, s32 bufLen) {
return cmd;
}
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex) {
u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s16 updateIndex)
{
struct ReverbRingBufferItem *item;
s16 startPad;
s16 paddedLengthA;
item = &gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex];
if (gSynthesisReverbs[reverbIndex].downsampleRate == 1) {
if (gSynthesisReverbs[reverbIndex].downsampleRate == 1)
{
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
if (item->lengthB != 0)
{
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengthA, 0, item->lengthB, reverbIndex);
}
aAddMixer(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
aMix(cmd++, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
} else {
}
else
{
startPad = (item->startPos % 8u) * 2;
paddedLengthA = ALIGN(startPad + item->lengthA, 4);
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, (item->startPos - startPad / 2), DEFAULT_LEN_1CH, reverbIndex);
if (item->lengthB != 0) {
if (item->lengthB != 0)
{
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED + paddedLengthA, 0, DEFAULT_LEN_1CH - paddedLengthA, reverbIndex);
}
@@ -238,7 +280,8 @@ u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s1
aAddMixer(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
aMix(cmd++, 0x8000 + gSynthesisReverbs[reverbIndex].reverbGain, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_2CH);
}
if (gSynthesisReverbs[reverbIndex].panRight != 0 || gSynthesisReverbs[reverbIndex].panLeft != 0) {
if (gSynthesisReverbs[reverbIndex].panRight != 0 || gSynthesisReverbs[reverbIndex].panLeft != 0)
{
// Leak some audio from the left reverb channel into the right reverb channel and vice versa (pan)
aDMEMMove(cmd++, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_RESAMPLED, DEFAULT_LEN_1CH);
aMix(cmd++, gSynthesisReverbs[reverbIndex].panRight, DMEM_ADDR_WET_RIGHT_CH, DMEM_ADDR_WET_LEFT_CH, DEFAULT_LEN_1CH);
@@ -247,7 +290,8 @@ u64 *synthesis_resample_and_mix_reverb(u64 *cmd, s32 bufLen, s16 reverbIndex, s1
return cmd;
}
u64 *synthesis_load_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
u64 *synthesis_load_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex)
{
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb;
@@ -255,22 +299,26 @@ u64 *synthesis_load_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
item = &reverb->items[reverb->curFrame][updateIndex];
// Get the oldest samples in the ring buffer into the wet channels
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
if (item->lengthB != 0)
{
// Ring buffer wrapped
cmd = synthesis_load_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED + item->lengthA, 0, item->lengthB, reverbIndex);
}
return cmd;
}
u64 *synthesis_save_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
u64 *synthesis_save_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex)
{
struct ReverbRingBufferItem *item;
item = &gSynthesisReverbs[reverbIndex].items[gSynthesisReverbs[reverbIndex].curFrame][updateIndex];
switch (gSynthesisReverbs[reverbIndex].downsampleRate) {
switch (gSynthesisReverbs[reverbIndex].downsampleRate)
{
case 1:
// Put the oldest samples in the ring buffer into the wet channels
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
if (item->lengthB != 0)
{
// Ring buffer wrapped
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_WET_LEFT_CH + item->lengthA, 0, item->lengthB, reverbIndex);
}
@@ -287,7 +335,8 @@ u64 *synthesis_save_reverb_samples(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
return cmd;
}
u64 *func_sh_802EDF24(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
u64 *func_sh_802EDF24(u64 *cmd, s16 reverbIndex, s16 updateIndex)
{
struct ReverbRingBufferItem *item;
struct SynthesisReverb *reverb;
@@ -295,14 +344,16 @@ u64 *func_sh_802EDF24(u64 *cmd, s16 reverbIndex, s16 updateIndex) {
item = &reverb->items[reverb->curFrame][updateIndex];
// Put the oldest samples in the ring buffer into the wet channels
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED, item->startPos, item->lengthA, reverbIndex);
if (item->lengthB != 0) {
if (item->lengthB != 0)
{
// Ring buffer wrapped
cmd = synthesis_save_reverb_ring_buffer(cmd, DMEM_ADDR_RESAMPLED + item->lengthA, 0, item->lengthB, reverbIndex);
}
return cmd;
}
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex) {
u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex)
{
struct NoteSubEu *noteSubEu;
u8 noteIndices[56];
s32 temp;
@@ -310,60 +361,81 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
s16 j;
s16 notePos = 0;
if (gNumSynthesisReverbs == 0) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
if (gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i].enabled) {
if (gNumSynthesisReverbs == 0)
{
for (i = 0; i < gMaxSimultaneousNotes; i++)
{
if (gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i].enabled)
{
noteIndices[notePos++] = i;
}
}
} else {
for (j = 0; j < gNumSynthesisReverbs; j++) {
for (i = 0; i < gMaxSimultaneousNotes; i++) {
}
else
{
for (j = 0; j < gNumSynthesisReverbs; j++)
{
for (i = 0; i < gMaxSimultaneousNotes; i++)
{
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (noteSubEu->enabled && j == noteSubEu->reverbIndex) {
if (noteSubEu->enabled && j == noteSubEu->reverbIndex)
{
noteIndices[notePos++] = i;
}
}
}
for (i = 0; i < gMaxSimultaneousNotes; i++) {
for (i = 0; i < gMaxSimultaneousNotes; i++)
{
noteSubEu = &gNoteSubsEu[gMaxSimultaneousNotes * updateIndex + i];
if (noteSubEu->enabled && noteSubEu->reverbIndex >= gNumSynthesisReverbs) {
if (noteSubEu->enabled && noteSubEu->reverbIndex >= gNumSynthesisReverbs)
{
noteIndices[notePos++] = i;
}
}
}
aClearBuffer(cmd++, DMEM_ADDR_LEFT_CH, DEFAULT_LEN_2CH);
i = 0;
for (j = 0; j < gNumSynthesisReverbs; j++) {
for (j = 0; j < gNumSynthesisReverbs; j++)
{
gUseReverb = gSynthesisReverbs[j].useReverb;
if (gUseReverb != 0) {
if (gUseReverb != 0)
{
cmd = synthesis_resample_and_mix_reverb(cmd, bufLen, j, updateIndex);
}
for (; i < notePos; i++) {
for (; i < notePos; i++)
{
temp = updateIndex * gMaxSimultaneousNotes;
if (j == gNoteSubsEu[temp + noteIndices[i]].reverbIndex) {
if (j == gNoteSubsEu[temp + noteIndices[i]].reverbIndex)
{
cmd = synthesis_process_note(noteIndices[i],
&gNoteSubsEu[temp + noteIndices[i]],
&gNotes[noteIndices[i]].synthesisState,
aiBuf, bufLen, cmd, updateIndex);
continue;
} else {
}
else
{
break;
}
}
if (gSynthesisReverbs[j].useReverb != 0) {
if (gSynthesisReverbs[j].unk100 != NULL) {
if (gSynthesisReverbs[j].useReverb != 0)
{
if (gSynthesisReverbs[j].unk100 != nullptr)
{
aFilter(cmd++, 0x02, bufLen * 2, gSynthesisReverbs[j].unk100);
aFilter(cmd++, gSynthesisReverbs[j].resampleFlags, DMEM_ADDR_WET_LEFT_CH, gSynthesisReverbs[j].unk108);
}
if (gSynthesisReverbs[j].unk104 != NULL) {
if (gSynthesisReverbs[j].unk104 != nullptr)
{
aFilter(cmd++, 0x02, bufLen * 2, gSynthesisReverbs[j].unk104);
aFilter(cmd++, gSynthesisReverbs[j].resampleFlags, DMEM_ADDR_WET_RIGHT_CH, gSynthesisReverbs[j].unk10C);
}
cmd = synthesis_save_reverb_samples(cmd, j, updateIndex);
if (gSynthesisReverbs[j].unk5 != -1) {
if (gSynthesisReverbs[gSynthesisReverbs[j].unk5].downsampleRate == 1) {
if (gSynthesisReverbs[j].unk5 != -1)
{
if (gSynthesisReverbs[gSynthesisReverbs[j].unk5].downsampleRate == 1)
{
cmd = synthesis_load_reverb_samples(cmd, gSynthesisReverbs[j].unk5, updateIndex);
aMix(cmd++, gSynthesisReverbs[j].unk08, DMEM_ADDR_WET_LEFT_CH, DMEM_ADDR_RESAMPLED, DEFAULT_LEN_2CH);
cmd = func_sh_802EDF24(cmd++, gSynthesisReverbs[j].unk5, updateIndex);
@@ -371,7 +443,8 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
}
}
}
for (; i < notePos; i++) {
for (; i < notePos; i++)
{
struct NoteSubEu *noteSubEu2 = &gNoteSubsEu[updateIndex * gMaxSimultaneousNotes + noteIndices[i]];
cmd = synthesis_process_note(noteIndices[i],
noteSubEu2,
@@ -385,7 +458,8 @@ u64 *synthesis_do_one_audio_update(s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateI
return cmd;
}
u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex) {
u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, UNUSED s16 *aiBuf, s32 bufLen, u64 *cmd, s32 updateIndex)
{
UNUSED s32 pad0[3];
struct AudioBankSample *audioBookSample; // sp164, sp138
struct AdpcmLoop *loopInfo; // sp160, sp134
@@ -438,10 +512,11 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
u16 addr;
u8 synthesisVolume;
curLoadedBook = NULL;
curLoadedBook = nullptr;
note = &gNotes[noteIndex];
flags = 0;
if (noteSubEu->needsInit == TRUE) {
if (noteSubEu->needsInit == TRUE)
{
flags = A_INIT;
synthesisState->restart = 0;
synthesisState->samplePosInt = 0;
@@ -461,46 +536,63 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
nSamplesToLoad = (samplesLenFixedPoint >> 0x10);
synthesisState->samplePosFrac = samplesLenFixedPoint & 0xFFFF;
if ((synthesisState->unk5 == 1) && (nParts == 2)) {
if ((synthesisState->unk5 == 1) && (nParts == 2))
{
nSamplesToLoad += 2;
sp56 = 2;
} else if ((synthesisState->unk5 == 2) && (nParts == 1)) {
}
else if ((synthesisState->unk5 == 2) && (nParts == 1))
{
nSamplesToLoad -= 4;
sp56 = 4;
} else {
}
else
{
sp56 = 0;
}
synthesisState->unk5 = nParts;
if (noteSubEu->isSyntheticWave) {
if (noteSubEu->isSyntheticWave)
{
cmd = load_wave_samples(cmd, noteSubEu, synthesisState, nSamplesToLoad);
noteSamplesDmemAddrBeforeResampling = (synthesisState->samplePosInt * 2) + DMEM_ADDR_UNCOMPRESSED_NOTE;
synthesisState->samplePosInt += nSamplesToLoad;
} else {
}
else
{
// ADPCM note
audioBookSample = noteSubEu->sound.audioBankSound->sample;
loopInfo = audioBookSample->loop;
endPos = loopInfo->end;
sampleAddr = audioBookSample->sampleAddr;
resampledTempLen = 0;
for (curPart = 0; curPart < nParts; curPart++) {
for (curPart = 0; curPart < nParts; curPart++)
{
nAdpcmSamplesProcessed = 0; // s8
s5 = 0; // s4
if (nParts == 1) {
if (nParts == 1)
{
samplesLenAdjusted = nSamplesToLoad;
} else if (nSamplesToLoad & 1) {
}
else if (nSamplesToLoad & 1)
{
samplesLenAdjusted = (nSamplesToLoad & ~1) + (curPart * 2);
} else {
}
else
{
samplesLenAdjusted = nSamplesToLoad;
}
if (audioBookSample->codec == CODEC_ADPCM) {
if (curLoadedBook != (*audioBookSample->book).book) {
if (audioBookSample->codec == CODEC_ADPCM)
{
if (curLoadedBook != (*audioBookSample->book).book)
{
u32 nEntries;
switch (noteSubEu->bookOffset) {
switch (noteSubEu->bookOffset)
{
case 1:
curLoadedBook = euUnknownData_80301950 + 1;
break;
@@ -517,7 +609,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
}
}
while (nAdpcmSamplesProcessed != samplesLenAdjusted) {
while (nAdpcmSamplesProcessed != samplesLenAdjusted)
{
s32 samplesRemaining; // v1
s32 s0;
@@ -527,30 +620,39 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
samplesRemaining = endPos - synthesisState->samplePosInt;
nSamplesToProcess = samplesLenAdjusted - nAdpcmSamplesProcessed;
if (s2 == 0 && synthesisState->restart == FALSE) {
if (s2 == 0 && synthesisState->restart == FALSE)
{
s2 = 16;
}
s6 = 16 - s2; // a1
if (nSamplesToProcess < samplesRemaining) {
if (nSamplesToProcess < samplesRemaining)
{
t0 = (nSamplesToProcess - s6 + 0xf) / 16;
s0 = t0 * 16;
s3 = s6 + s0 - nSamplesToProcess;
} else {
}
else
{
s0 = samplesRemaining - s6;
s3 = 0;
if (s0 <= 0) {
if (s0 <= 0)
{
s0 = 0;
s6 = samplesRemaining;
}
t0 = (s0 + 0xf) / 16;
if (loopInfo->count != 0) {
if (loopInfo->count != 0)
{
// Loop around and restart
restart = 1;
} else {
}
else
{
noteFinished = 1;
}
}
switch (audioBookSample->codec) {
switch (audioBookSample->codec)
{
case CODEC_ADPCM:
unk_s6 = 9;
sp88 = 0x10;
@@ -561,13 +663,18 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
sp88 = 0x10;
sp84 = 0;
break;
case CODEC_SKIP: goto skip;
case CODEC_SKIP:
goto skip;
}
if (t0 != 0) {
if (t0 != 0)
{
temp = (synthesisState->samplePosInt + sp88 - s2) / 16;
if (audioBookSample->medium == 0) {
if (audioBookSample->medium == 0)
{
v0_2 = sp84 + (temp * unk_s6) + sampleAddr;
} else {
}
else
{
v0_2 = dma_sample_data((uintptr_t)(sp84 + (temp * unk_s6) + sampleAddr),
ALIGN(t0 * unk_s6 + 16, 4), flags, &synthesisState->sampleDmaIndex, audioBookSample->medium);
}
@@ -576,18 +683,23 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(v0_2 - a3), addr, ALIGN(t0 * unk_s6 + 16, 4));
} else {
}
else
{
s0 = 0;
a3 = 0;
}
if (synthesisState->restart != FALSE) {
if (synthesisState->restart != FALSE)
{
aSetLoop(cmd++, VIRTUAL_TO_PHYSICAL2(audioBookSample->loop->state));
flags = A_LOOP; // = 2
synthesisState->restart = FALSE;
}
nSamplesInThisIteration = s0 + s6 - s3;
if (nAdpcmSamplesProcessed == 0) {
switch (audioBookSample->codec) {
if (nAdpcmSamplesProcessed == 0)
{
switch (audioBookSample->codec)
{
case CODEC_ADPCM:
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
@@ -602,9 +714,12 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
break;
}
sp130 = s2 * 2;
} else {
}
else
{
s5Aligned = ALIGN(s5 + 16, 4);
switch (audioBookSample->codec) {
switch (audioBookSample->codec)
{
case CODEC_ADPCM:
aligned = ALIGN(t0 * unk_s6 + 16, 4);
addr = (DMEM_ADDR_COMPRESSED_ADPCM_DATA - aligned) & 0xffff;
@@ -621,7 +736,8 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
aDMEMMove(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + s5Aligned + (s2 * 2), DMEM_ADDR_UNCOMPRESSED_NOTE + s5, (nSamplesInThisIteration) * 2);
}
nAdpcmSamplesProcessed += nSamplesInThisIteration;
switch (flags) {
switch (flags)
{
case A_INIT: // = 1
sp130 = 0x20;
s5 = (s0 + 0x10) * 2;
@@ -630,16 +746,19 @@ u64 *synthesis_process_note(s32 noteIndex, struct NoteSubEu *noteSubEu, struct N
s5 = (nSamplesInThisIteration) * 2 + s5;
break;
default:
if (s5 != 0) {
if (s5 != 0)
{
s5 = (nSamplesInThisIteration) * 2 + s5;
} else {
}
else
{
s5 = (s2 + (nSamplesInThisIteration)) * 2;
}
break;
}
flags = 0;
skip:
if (noteFinished) {
skip: if (noteFinished)
{
aClearBuffer(cmd++, DMEM_ADDR_UNCOMPRESSED_NOTE + s5,
(samplesLenAdjusted - nAdpcmSamplesProcessed) * 2);
noteSubEu->finished = 1;
@@ -647,25 +766,31 @@ skip:
func_sh_802ed644(updateIndex, noteIndex);
break;
}
if (restart != 0) {
if (restart != 0)
{
synthesisState->restart = TRUE;
synthesisState->samplePosInt = loopInfo->start;
} else {
}
else
{
synthesisState->samplePosInt += nSamplesToProcess;
}
}
switch (nParts) {
switch (nParts)
{
case 1:
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_UNCOMPRESSED_NOTE + sp130;
break;
case 2:
switch (curPart) {
switch (curPart)
{
case 0:
aDownsampleHalf(cmd++, ALIGN(samplesLenAdjusted / 2, 3), DMEM_ADDR_UNCOMPRESSED_NOTE + sp130, DMEM_ADDR_RESAMPLED);
resampledTempLen = samplesLenAdjusted;
noteSamplesDmemAddrBeforeResampling = DMEM_ADDR_RESAMPLED;
if (noteSubEu->finished != FALSE) {
if (noteSubEu->finished != FALSE)
{
aClearBuffer(cmd++, noteSamplesDmemAddrBeforeResampling + resampledTempLen, samplesLenAdjusted + 0x10);
}
break;
@@ -674,52 +799,65 @@ skip:
break;
}
}
if (noteSubEu->finished != FALSE) {
if (noteSubEu->finished != FALSE)
{
break;
}
}
}
flags = 0;
if (noteSubEu->needsInit == TRUE) {
if (noteSubEu->needsInit == TRUE)
{
flags = A_INIT;
noteSubEu->needsInit = FALSE;
}
flags = flags | sp56;
cmd = final_resample(cmd, synthesisState, bufLen * 2, resamplingRateFixedPoint,
noteSamplesDmemAddrBeforeResampling, flags);
if ((flags & 1) != 0) {
if ((flags & 1) != 0)
{
flags = 1;
}
if (noteSubEu->filter) {
if (noteSubEu->filter)
{
aFilter(cmd++, 0x02, bufLen * 2, noteSubEu->filter);
aFilter(cmd++, flags, DMEM_ADDR_TEMP, synthesisState->synthesisBuffers->filterBuffer);
}
if (noteSubEu->bookOffset == 3) {
if (noteSubEu->bookOffset == 3)
{
aUnknown25(cmd++, 0, bufLen * 2, DMEM_ADDR_TEMP, DMEM_ADDR_TEMP);
}
synthesisVolume = noteSubEu->synthesisVolume;
if (synthesisVolume != 0) {
if (synthesisVolume < 0x10) {
if (synthesisVolume != 0)
{
if (synthesisVolume < 0x10)
{
synthesisVolume = 0x10;
}
aHiLoGain(cmd++, synthesisVolume, (bufLen + 0x10) * 2, DMEM_ADDR_TEMP);
}
if (noteSubEu->headsetPanRight != 0 || synthesisState->prevHeadsetPanRight != 0) {
if (noteSubEu->headsetPanRight != 0 || synthesisState->prevHeadsetPanRight != 0)
{
leftRight = 1;
} else if (noteSubEu->headsetPanLeft != 0 || synthesisState->prevHeadsetPanLeft != 0) {
}
else if (noteSubEu->headsetPanLeft != 0 || synthesisState->prevHeadsetPanLeft != 0)
{
leftRight = 2;
} else {
}
else
{
leftRight = 0;
}
cmd = process_envelope(cmd, noteSubEu, synthesisState, bufLen, DMEM_ADDR_TEMP, leftRight, flags);
if (noteSubEu->usesHeadsetPanEffects) {
if ((flags & 1) == 0) {
if (noteSubEu->usesHeadsetPanEffects)
{
if ((flags & 1) == 0)
{
flags = 0;
}
cmd = note_apply_headset_pan_effects(cmd, noteSubEu, synthesisState, bufLen * 2, flags, leftRight);
@@ -728,7 +866,8 @@ skip:
return cmd;
}
u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad) {
u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *synthesisState, s32 nSamplesToLoad)
{
s32 a3;
s32 repeats;
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(noteSubEu->sound.samples),
@@ -736,9 +875,11 @@ u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthes
synthesisState->samplePosInt &= 0x3f;
a3 = 64 - synthesisState->samplePosInt;
if (a3 < nSamplesToLoad) {
if (a3 < nSamplesToLoad)
{
repeats = (nSamplesToLoad - a3 + 63) / 64;
if (repeats != 0) {
if (repeats != 0)
{
aDuplicate(cmd++,
/*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE,
/*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + 128,
@@ -748,17 +889,22 @@ u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthes
return cmd;
}
u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags) {
if (pitch == 0) {
u64 *final_resample(u64 *cmd, struct NoteSynthesisState *synthesisState, s32 count, u16 pitch, u16 dmemIn, u32 flags)
{
if (pitch == 0)
{
aClearBuffer(cmd++, DMEM_ADDR_TEMP, count);
} else {
}
else
{
aSetBuffer(cmd++, /*flags*/ 0, dmemIn, /*dmemout*/ DMEM_ADDR_TEMP, count);
aResample(cmd++, flags, pitch, VIRTUAL_TO_PHYSICAL2(synthesisState->synthesisBuffers->finalResampleState));
}
return cmd;
}
u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, UNUSED u32 flags) {
u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisState *synthesisState, s32 nSamples, u16 inBuf, s32 headsetPanSettings, UNUSED u32 flags)
{
u16 sourceRight;
u16 sourceLeft;
u16 targetLeft;
@@ -776,34 +922,45 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
targetLeft <<= 4;
targetRight <<= 4;
if (targetLeft != sourceLeft) {
if (targetLeft != sourceLeft)
{
rampLeft = (targetLeft - sourceLeft) / (nSamples >> 3);
} else {
}
else
{
rampLeft = 0;
}
if (targetRight != sourceRight) {
if (targetRight != sourceRight)
{
rampRight = (targetRight - sourceRight) / (nSamples >> 3);
} else {
}
else
{
rampRight = 0;
}
sourceReverbVol = synthesisState->reverbVol;
if (note->reverbVol != sourceReverbVol) {
if (note->reverbVol != sourceReverbVol)
{
reverbVolDiff = ((note->reverbVol & 0x7f) - (sourceReverbVol & 0x7f)) << 9;
rampReverb = reverbVolDiff / (nSamples >> 3);
synthesisState->reverbVol = note->reverbVol;
} else {
}
else
{
rampReverb = 0;
}
synthesisState->curVolLeft = sourceLeft + rampLeft * (nSamples >> 3);
synthesisState->curVolRight = sourceRight + rampRight * (nSamples >> 3);
if (note->usesHeadsetPanEffects) {
if (note->usesHeadsetPanEffects)
{
aClearBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DEFAULT_LEN_1CH);
aEnvSetup1(cmd++, (sourceReverbVol & 0x7f) * 2, rampReverb, rampLeft, rampRight);
aEnvSetup2(cmd++, sourceLeft, sourceRight);
switch (headsetPanSettings) {
switch (headsetPanSettings)
{
case 1:
aEnvMixer(cmd++,
inBuf, nSamples,
@@ -835,7 +992,9 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
DMEM_ADDR_WET_RIGHT_CH);
break;
}
} else {
}
else
{
aEnvSetup1(cmd++, (sourceReverbVol & 0x7f) * 2, rampReverb, rampLeft, rampRight);
aEnvSetup2(cmd++, sourceLeft, sourceRight);
aEnvMixer(cmd++,
@@ -850,14 +1009,16 @@ u64 *process_envelope(u64 *cmd, struct NoteSubEu *note, struct NoteSynthesisStat
return cmd;
}
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight) {
u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthesisState *note, s32 bufLen, s32 flags, s32 leftRight)
{
u16 dest;
u16 pitch;
u8 prevPanShift;
u8 panShift;
UNUSED u8 unkDebug;
switch (leftRight) {
switch (leftRight)
{
case 1:
dest = DMEM_ADDR_LEFT_CH;
panShift = noteSubEu->headsetPanRight;
@@ -877,31 +1038,41 @@ u64 *note_apply_headset_pan_effects(u64 *cmd, struct NoteSubEu *noteSubEu, struc
return cmd;
}
if (flags != 1) { // A_INIT?
if (flags != 1)
{ // A_INIT?
// Slightly adjust the sample rate in order to fit a change in pan shift
if (panShift != prevPanShift) {
if (panShift != prevPanShift)
{
pitch = (((bufLen << 0xf) / 2) - 1) / ((bufLen + panShift - prevPanShift - 2) / 2);
aSetBuffer(cmd++, 0, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP, (bufLen + panShift) - prevPanShift);
aResampleZoh(cmd++, pitch, 0);
} else {
}
else
{
aDMEMMove(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP, bufLen);
}
if (prevPanShift != 0) {
if (prevPanShift != 0)
{
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer),
DMEM_ADDR_NOTE_PAN_TEMP, ALIGN(prevPanShift, 4));
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP + prevPanShift, bufLen + panShift - prevPanShift);
} else {
}
else
{
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP, bufLen + panShift);
}
} else {
}
else
{
// Just shift right
aDMEMMove(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, DMEM_ADDR_TEMP, bufLen);
aClearBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP, panShift);
aDMEMMove(cmd++, DMEM_ADDR_TEMP, DMEM_ADDR_NOTE_PAN_TEMP + panShift, bufLen);
}
if (panShift) {
if (panShift)
{
// Save excessive samples for next iteration
aSaveBuffer(cmd++, DMEM_ADDR_NOTE_PAN_TEMP + bufLen,
VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->panSamplesBuffer), ALIGN(panShift, 4));
+161 -111
View File
@@ -6,7 +6,7 @@
#include "graph_node.h"
#include "../shim.h"
static Vec3s gVec3sZero = { 0, 0, 0 };
static Vec3s gVec3sZero = {0, 0, 0};
typedef void (*GeoLayoutCommandProc)(void);
@@ -102,53 +102,60 @@ UNUSED s16 D_8038BD7C;
s16 gGeoLayoutReturnIndex; // similar to RA register in MIPS
u8 *gGeoLayoutCommand;
u32 unused_8038B894[3] = { 0 };
u32 unused_8038B894[3] = {0};
/*
0x00: Branch and store return address
cmd+0x04: void *branchTarget
*/
void geo_layout_cmd_branch_and_link(void) {
gGeoLayoutStack[gGeoLayoutStackIndex++] = (uintptr_t) (gGeoLayoutCommand + CMD_PROCESS_OFFSET(8));
void geo_layout_cmd_branch_and_link(void)
{
gGeoLayoutStack[gGeoLayoutStackIndex++] = (uintptr_t)(gGeoLayoutCommand + CMD_PROCESS_OFFSET(8));
gGeoLayoutStack[gGeoLayoutStackIndex++] = (gCurGraphNodeIndex << 16) + gGeoLayoutReturnIndex;
gGeoLayoutReturnIndex = gGeoLayoutStackIndex;
gGeoLayoutCommand = segmented_to_virtual(cur_geo_cmd_ptr(0x04));
}
// 0x01: Terminate geo layout
void geo_layout_cmd_end(void) {
void geo_layout_cmd_end(void)
{
gGeoLayoutStackIndex = gGeoLayoutReturnIndex;
gGeoLayoutReturnIndex = gGeoLayoutStack[--gGeoLayoutStackIndex] & 0xFFFF;
gCurGraphNodeIndex = gGeoLayoutStack[gGeoLayoutStackIndex] >> 16;
gGeoLayoutCommand = (u8 *) gGeoLayoutStack[--gGeoLayoutStackIndex];
gGeoLayoutCommand = (u8 *)gGeoLayoutStack[--gGeoLayoutStackIndex];
}
/*
0x02: Branch
cmd+0x04: void *branchTarget
*/
void geo_layout_cmd_branch(void) {
if (cur_geo_cmd_u8(0x01) == 1) {
gGeoLayoutStack[gGeoLayoutStackIndex++] = (uintptr_t) (gGeoLayoutCommand + CMD_PROCESS_OFFSET(8));
void geo_layout_cmd_branch(void)
{
if (cur_geo_cmd_u8(0x01) == 1)
{
gGeoLayoutStack[gGeoLayoutStackIndex++] = (uintptr_t)(gGeoLayoutCommand + CMD_PROCESS_OFFSET(8));
}
gGeoLayoutCommand = segmented_to_virtual(cur_geo_cmd_ptr(0x04));
}
// 0x03: Return from branch
void geo_layout_cmd_return(void) {
gGeoLayoutCommand = (u8 *) gGeoLayoutStack[--gGeoLayoutStackIndex];
void geo_layout_cmd_return(void)
{
gGeoLayoutCommand = (u8 *)gGeoLayoutStack[--gGeoLayoutStackIndex];
}
// 0x04: Open node
void geo_layout_cmd_open_node(void) {
void geo_layout_cmd_open_node(void)
{
gCurGraphNodeList[gCurGraphNodeIndex + 1] = gCurGraphNodeList[gCurGraphNodeIndex];
gCurGraphNodeIndex++;
gGeoLayoutCommand += 0x04 << CMD_SIZE_SHIFT;
}
// 0x05: Close node
void geo_layout_cmd_close_node(void) {
void geo_layout_cmd_close_node(void)
{
gCurGraphNodeIndex--;
gGeoLayoutCommand += 0x04 << CMD_SIZE_SHIFT;
}
@@ -159,10 +166,12 @@ void geo_layout_cmd_close_node(void) {
Register the current node in the gGeoViews array at the given index
*/
void geo_layout_cmd_assign_as_view(void) {
void geo_layout_cmd_assign_as_view(void)
{
u16 index = cur_geo_cmd_s16(0x02);
if (index < gGeoNumViews) {
if (index < gGeoNumViews)
{
gGeoViews[index] = gCurGraphNodeList[gCurGraphNodeIndex];
}
@@ -174,11 +183,13 @@ void geo_layout_cmd_assign_as_view(void) {
cmd+0x01: u8 operation (0 = reset, 1 = set, 2 = clear)
cmd+0x02: s16 bits
*/
void geo_layout_cmd_update_node_flags(void) {
void geo_layout_cmd_update_node_flags(void)
{
u16 operation = cur_geo_cmd_u8(0x01);
u16 flagBits = cur_geo_cmd_s16(0x02);
switch (operation) {
switch (operation)
{
case GEO_CMD_FLAGS_RESET:
gCurGraphNodeList[gCurGraphNodeIndex]->flags = flagBits;
break;
@@ -201,7 +212,8 @@ void geo_layout_cmd_update_node_flags(void) {
cmd+0x08: s16 width
cmd+0x0A: s16 height
*/
void geo_layout_cmd_node_root(void) {
void geo_layout_cmd_node_root(void)
{
s32 i;
struct GraphNodeRoot *graphNode;
@@ -215,16 +227,17 @@ void geo_layout_cmd_node_root(void) {
// cmd+0x02 = 0x00: Mario face, 0x0A: all other levels
gGeoNumViews = cur_geo_cmd_s16(0x02) + 2;
graphNode = init_graph_node_root(gGraphNodePool, NULL, 0, x, y, width, height);
graphNode = init_graph_node_root(gGraphNodePool, nullptr, 0, x, y, width, height);
// gGeoViews is unused in libsm64
gGeoViews = NULL; // alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(struct GraphNode *));
gGeoViews = nullptr; // alloc_only_pool_alloc(gGraphNodePool, gGeoNumViews * sizeof(struct GraphNode *));
graphNode->views = gGeoViews;
graphNode->numViews = gGeoNumViews;
for (i = 0; i < gGeoNumViews; i++) {
gGeoViews[i] = NULL;
for (i = 0; i < gGeoNumViews; i++)
{
gGeoViews[i] = nullptr;
}
register_scene_graph_node(&graphNode->node);
@@ -236,11 +249,12 @@ void geo_layout_cmd_node_root(void) {
0x09: Create orthographic projection scene graph node
cmd+0x02: s16 scale as a percentage (usually it's 100)
*/
void geo_layout_cmd_node_ortho_projection(void) {
void geo_layout_cmd_node_ortho_projection(void)
{
struct GraphNodeOrthoProjection *graphNode;
f32 scale = (f32) cur_geo_cmd_s16(0x02) / 100.0f;
f32 scale = (f32)cur_geo_cmd_s16(0x02) / 100.0f;
graphNode = init_graph_node_ortho_projection(gGraphNodePool, NULL, scale);
graphNode = init_graph_node_ortho_projection(gGraphNodePool, nullptr, scale);
register_scene_graph_node(&graphNode->node);
@@ -255,20 +269,22 @@ void geo_layout_cmd_node_ortho_projection(void) {
cmd+0x06: s16 far
[cmd+0x08: GraphNodeFunc frustumFunc]
*/
void geo_layout_cmd_node_perspective(void) {
void geo_layout_cmd_node_perspective(void)
{
struct GraphNodePerspective *graphNode;
GraphNodeFunc frustumFunc = NULL;
GraphNodeFunc frustumFunc = nullptr;
s16 fov = cur_geo_cmd_s16(0x02);
s16 near = cur_geo_cmd_s16(0x04);
s16 far = cur_geo_cmd_s16(0x06);
if (cur_geo_cmd_u8(0x01) != 0) {
if (cur_geo_cmd_u8(0x01) != 0)
{
// optional asm function
frustumFunc = (GraphNodeFunc) cur_geo_cmd_ptr(0x08);
frustumFunc = (GraphNodeFunc)cur_geo_cmd_ptr(0x08);
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
}
graphNode = init_graph_node_perspective(gGraphNodePool, NULL, (f32) fov, near, far, frustumFunc, 0);
graphNode = init_graph_node_perspective(gGraphNodePool, nullptr, fov, near, far, frustumFunc, 0);
register_scene_graph_node(&graphNode->fnNode.node);
@@ -279,10 +295,11 @@ void geo_layout_cmd_node_perspective(void) {
0x0B: Create a scene graph node that groups other nodes without any
additional functionality
*/
void geo_layout_cmd_node_start(void) {
void geo_layout_cmd_node_start(void)
{
struct GraphNodeStart *graphNode;
graphNode = init_graph_node_start(gGraphNodePool, NULL);
graphNode = init_graph_node_start(gGraphNodePool, nullptr);
register_scene_graph_node(&graphNode->node);
@@ -290,7 +307,8 @@ void geo_layout_cmd_node_start(void) {
}
// 0x1F: No operation
void geo_layout_cmd_nop3(void) {
void geo_layout_cmd_nop3(void)
{
gGeoLayoutCommand += 0x10 << CMD_SIZE_SHIFT;
}
@@ -298,10 +316,11 @@ void geo_layout_cmd_nop3(void) {
0x0C: Create zbuffer-toggling scene graph node
cmd+0x01: u8 enableZBuffer (1 = on, 0 = off)
*/
void geo_layout_cmd_node_master_list(void) {
void geo_layout_cmd_node_master_list(void)
{
struct GraphNodeMasterList *graphNode;
graphNode = init_graph_node_master_list(gGraphNodePool, NULL, cur_geo_cmd_u8(0x01));
graphNode = init_graph_node_master_list(gGraphNodePool, nullptr, cur_geo_cmd_u8(0x01));
register_scene_graph_node(&graphNode->node);
@@ -314,12 +333,13 @@ void geo_layout_cmd_node_master_list(void) {
cmd+0x04: s16 minDistance
cmd+0x06: s16 maxDistance
*/
void geo_layout_cmd_node_level_of_detail(void) {
void geo_layout_cmd_node_level_of_detail(void)
{
struct GraphNodeLevelOfDetail *graphNode;
s16 minDistance = cur_geo_cmd_s16(0x04);
s16 maxDistance = cur_geo_cmd_s16(0x06);
graphNode = init_graph_node_render_range(gGraphNodePool, NULL, minDistance, maxDistance);
graphNode = init_graph_node_render_range(gGraphNodePool, nullptr, minDistance, maxDistance);
register_scene_graph_node(&graphNode->node);
@@ -334,14 +354,15 @@ void geo_layout_cmd_node_level_of_detail(void) {
caseSelectorFunc returns an index which is used to select the child node to render.
Used for animating coins, blinking, color selection, etc.
*/
void geo_layout_cmd_node_switch_case(void) {
void geo_layout_cmd_node_switch_case(void)
{
struct GraphNodeSwitchCase *graphNode;
graphNode =
init_graph_node_switch_case(gGraphNodePool, NULL,
init_graph_node_switch_case(gGraphNodePool, nullptr,
cur_geo_cmd_s16(0x02), // case which is initially selected
0,
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // case update function
cur_geo_cmd_ptr(0x04), // case update function
0);
register_scene_graph_node(&graphNode->fnNode.node);
@@ -360,17 +381,18 @@ void geo_layout_cmd_node_switch_case(void) {
cmd+0x0E: s16 focusZ
cmd+0x10: GraphNodeFunc func
*/
void geo_layout_cmd_node_camera(void) {
void geo_layout_cmd_node_camera(void)
{
struct GraphNodeCamera *graphNode;
s16 *cmdPos = (s16 *) &gGeoLayoutCommand[4];
s16 *cmdPos = (s16 *)&gGeoLayoutCommand[4];
Vec3f pos, focus;
cmdPos = read_vec3s_to_vec3f(pos, cmdPos);
cmdPos = read_vec3s_to_vec3f(focus, cmdPos);
graphNode = init_graph_node_camera(gGraphNodePool, NULL, pos, focus,
(GraphNodeFunc) cur_geo_cmd_ptr(0x10), cur_geo_cmd_s16(0x02));
graphNode = init_graph_node_camera(gGraphNodePool, nullptr, pos, focus,
cur_geo_cmd_ptr(0x10), cur_geo_cmd_s16(0x02));
register_scene_graph_node(&graphNode->fnNode.node);
@@ -413,18 +435,20 @@ void geo_layout_cmd_node_camera(void) {
[cmd+var: void *displayList]
*/
void geo_layout_cmd_node_translation_rotation(void) {
void geo_layout_cmd_node_translation_rotation(void)
{
struct GraphNodeTranslationRotation *graphNode;
Vec3s translation, rotation;
void *displayList = NULL;
void *displayList = nullptr;
s16 drawingLayer = 0;
s16 params = cur_geo_cmd_u8(0x01);
s16 *cmdPos = (s16 *) gGeoLayoutCommand;
s16 *cmdPos = (s16 *)gGeoLayoutCommand;
switch ((params & 0x70) >> 4) {
switch ((params & 0x70) >> 4)
{
case 0:
cmdPos = read_vec3s(translation, &cmdPos[2]);
cmdPos = read_vec3s_angle(rotation, cmdPos);
@@ -444,17 +468,18 @@ void geo_layout_cmd_node_translation_rotation(void) {
break;
}
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
if (params & 0x80)
{
displayList = *(void **)&cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2 << CMD_SIZE_SHIFT;
}
graphNode = init_graph_node_translation_rotation(gGraphNodePool, NULL, drawingLayer, displayList,
graphNode = init_graph_node_translation_rotation(gGraphNodePool, nullptr, drawingLayer, displayList,
translation, rotation);
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand = (u8 *) cmdPos;
gGeoLayoutCommand = (u8 *)cmdPos;
}
/*
@@ -467,30 +492,32 @@ void geo_layout_cmd_node_translation_rotation(void) {
cmd+0x06: s16 zTranslation
[cmd+0x08: void *displayList]
*/
void geo_layout_cmd_node_translation(void) {
void geo_layout_cmd_node_translation(void)
{
struct GraphNodeTranslation *graphNode;
Vec3s translation;
s16 drawingLayer = 0;
s16 params = cur_geo_cmd_u8(0x01);
s16 *cmdPos = (s16 *) gGeoLayoutCommand;
void *displayList = NULL;
s16 *cmdPos = (s16 *)gGeoLayoutCommand;
void *displayList = nullptr;
cmdPos = read_vec3s(translation, &cmdPos[1]);
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
if (params & 0x80)
{
displayList = *(void **)&cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2 << CMD_SIZE_SHIFT;
}
graphNode =
init_graph_node_translation(gGraphNodePool, NULL, drawingLayer, displayList, translation);
init_graph_node_translation(gGraphNodePool, nullptr, drawingLayer, displayList, translation);
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand = (u8 *) cmdPos;
gGeoLayoutCommand = (u8 *)cmdPos;
}
/*
@@ -503,29 +530,31 @@ void geo_layout_cmd_node_translation(void) {
cmd+0x06: s16 unkZ
[cmd+0x08: void *displayList]
*/
void geo_layout_cmd_node_rotation(void) {
void geo_layout_cmd_node_rotation(void)
{
struct GraphNodeRotation *graphNode;
Vec3s sp2c;
s16 drawingLayer = 0;
s16 params = cur_geo_cmd_u8(0x01);
s16 *cmdPos = (s16 *) gGeoLayoutCommand;
void *displayList = NULL;
s16 *cmdPos = (s16 *)gGeoLayoutCommand;
void *displayList = nullptr;
cmdPos = read_vec3s_angle(sp2c, &cmdPos[1]);
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
if (params & 0x80)
{
displayList = *(void **)&cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2 << CMD_SIZE_SHIFT;
}
graphNode = init_graph_node_rotation(gGraphNodePool, NULL, drawingLayer, displayList, sp2c);
graphNode = init_graph_node_rotation(gGraphNodePool, nullptr, drawingLayer, displayList, sp2c);
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand = (u8 *) cmdPos;
gGeoLayoutCommand = (u8 *)cmdPos;
}
/*
@@ -536,21 +565,23 @@ void geo_layout_cmd_node_rotation(void) {
cmd+0x04: u32 scale (0x10000 = 1.0)
[cmd+0x08: void *displayList]
*/
void geo_layout_cmd_node_scale(void) {
void geo_layout_cmd_node_scale(void)
{
struct GraphNodeScale *graphNode;
s16 drawingLayer = 0;
s16 params = cur_geo_cmd_u8(0x01);
f32 scale = cur_geo_cmd_u32(0x04) / 65536.0f;
void *displayList = NULL;
void *displayList = nullptr;
if (params & 0x80) {
if (params & 0x80)
{
displayList = cur_geo_cmd_ptr(0x08);
drawingLayer = params & 0x0F;
gGeoLayoutCommand += 4 << CMD_SIZE_SHIFT;
}
graphNode = init_graph_node_scale(gGraphNodePool, NULL, drawingLayer, displayList, scale);
graphNode = init_graph_node_scale(gGraphNodePool, nullptr, drawingLayer, displayList, scale);
register_scene_graph_node(&graphNode->node);
@@ -558,7 +589,8 @@ void geo_layout_cmd_node_scale(void) {
}
// 0x1E: No operation
void geo_layout_cmd_nop2(void) {
void geo_layout_cmd_nop2(void)
{
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
}
@@ -570,17 +602,18 @@ void geo_layout_cmd_nop2(void) {
cmd+0x06: s16 zTranslation
cmd+0x08: void *displayList
*/
void geo_layout_cmd_node_animated_part(void) {
void geo_layout_cmd_node_animated_part(void)
{
struct GraphNodeAnimatedPart *graphNode;
Vec3s translation;
s32 drawingLayer = cur_geo_cmd_u8(0x01);
void *displayList = cur_geo_cmd_ptr(0x08);
s16 *cmdPos = (s16 *) gGeoLayoutCommand;
s16 *cmdPos = (s16 *)gGeoLayoutCommand;
read_vec3s(translation, &cmdPos[1]);
graphNode =
init_graph_node_animated_part(gGraphNodePool, NULL, drawingLayer, displayList, translation);
init_graph_node_animated_part(gGraphNodePool, nullptr, drawingLayer, displayList, translation);
register_scene_graph_node(&graphNode->node);
@@ -597,27 +630,29 @@ void geo_layout_cmd_node_animated_part(void) {
cmd+0x06: s16 zTranslation
[cmd+0x08: void *displayList]
*/
void geo_layout_cmd_node_billboard(void) {
void geo_layout_cmd_node_billboard(void)
{
struct GraphNodeBillboard *graphNode;
Vec3s translation;
s16 drawingLayer = 0;
s16 params = cur_geo_cmd_u8(0x01);
s16 *cmdPos = (s16 *) gGeoLayoutCommand;
void *displayList = NULL;
s16 *cmdPos = (s16 *)gGeoLayoutCommand;
void *displayList = nullptr;
cmdPos = read_vec3s(translation, &cmdPos[1]);
if (params & 0x80) {
displayList = *(void **) &cmdPos[0];
if (params & 0x80)
{
displayList = *(void **)&cmdPos[0];
drawingLayer = params & 0x0F;
cmdPos += 2 << CMD_SIZE_SHIFT;
}
graphNode = init_graph_node_billboard(gGraphNodePool, NULL, drawingLayer, displayList, translation);
graphNode = init_graph_node_billboard(gGraphNodePool, nullptr, drawingLayer, displayList, translation);
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand = (u8 *) cmdPos;
gGeoLayoutCommand = (u8 *)cmdPos;
}
/*
@@ -625,12 +660,13 @@ void geo_layout_cmd_node_billboard(void) {
cmd+0x01: u8 drawingLayer
cmd+0x04: void *displayList
*/
void geo_layout_cmd_node_display_list(void) {
void geo_layout_cmd_node_display_list(void)
{
struct GraphNodeDisplayList *graphNode;
s32 drawingLayer = cur_geo_cmd_u8(0x01);
void *displayList = cur_geo_cmd_ptr(0x04);
graphNode = init_graph_node_display_list(gGraphNodePool, NULL, drawingLayer, displayList);
graphNode = init_graph_node_display_list(gGraphNodePool, nullptr, drawingLayer, displayList);
register_scene_graph_node(&graphNode->node);
@@ -643,13 +679,14 @@ void geo_layout_cmd_node_display_list(void) {
cmd+0x04: s16 shadowSolidity
cmd+0x06: s16 shadowScale
*/
void geo_layout_cmd_node_shadow(void) {
void geo_layout_cmd_node_shadow(void)
{
struct GraphNodeShadow *graphNode;
u8 shadowType = cur_geo_cmd_s16(0x02);
u8 shadowSolidity = cur_geo_cmd_s16(0x04);
s16 shadowScale = cur_geo_cmd_s16(0x06);
graphNode = init_graph_node_shadow(gGraphNodePool, NULL, shadowScale, shadowSolidity, shadowType);
graphNode = init_graph_node_shadow(gGraphNodePool, nullptr, shadowScale, shadowSolidity, shadowType);
register_scene_graph_node(&graphNode->node);
@@ -657,10 +694,11 @@ void geo_layout_cmd_node_shadow(void) {
}
// 0x17: Create scene graph node that manages the group of all object nodes
void geo_layout_cmd_node_object_parent(void) {
void geo_layout_cmd_node_object_parent(void)
{
struct GraphNodeObjectParent *graphNode;
graphNode = init_graph_node_object_parent(gGraphNodePool, NULL, &gObjParentGraphNode);
graphNode = init_graph_node_object_parent(gGraphNodePool, nullptr, &gObjParentGraphNode);
register_scene_graph_node(&graphNode->node);
@@ -672,11 +710,12 @@ void geo_layout_cmd_node_object_parent(void) {
cmd+0x02: s16 parameter
cmd+0x04: GraphNodeFunc func
*/
void geo_layout_cmd_node_generated(void) {
void geo_layout_cmd_node_generated(void)
{
struct GraphNodeGenerated *graphNode;
graphNode = init_graph_node_generated(gGraphNodePool, NULL,
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function
graphNode = init_graph_node_generated(gGraphNodePool, nullptr,
cur_geo_cmd_ptr(0x04), // asm function
cur_geo_cmd_s16(0x02)); // parameter
register_scene_graph_node(&graphNode->fnNode.node);
@@ -689,13 +728,14 @@ void geo_layout_cmd_node_generated(void) {
cmd+0x02: s16 background // background ID, or RGBA5551 color if backgroundFunc is null
cmd+0x04: GraphNodeFunc backgroundFunc
*/
void geo_layout_cmd_node_background(void) {
void geo_layout_cmd_node_background(void)
{
struct GraphNodeBackground *graphNode;
graphNode = init_graph_node_background(
gGraphNodePool, NULL,
gGraphNodePool, nullptr,
cur_geo_cmd_s16(0x02), // background ID, or RGBA5551 color if asm function is null
(GraphNodeFunc) cur_geo_cmd_ptr(0x04), // asm function
cur_geo_cmd_ptr(0x04), // asm function
0);
register_scene_graph_node(&graphNode->fnNode.node);
@@ -704,7 +744,8 @@ void geo_layout_cmd_node_background(void) {
}
// 0x1A: No operation
void geo_layout_cmd_nop(void) {
void geo_layout_cmd_nop(void)
{
gGeoLayoutCommand += 0x08 << CMD_SIZE_SHIFT;
}
@@ -713,22 +754,27 @@ void geo_layout_cmd_nop(void) {
to a newly created object parent node.
cmd+0x02: s16 index (of gGeoViews)
*/
void geo_layout_cmd_copy_view(void) {
void geo_layout_cmd_copy_view(void)
{
struct GraphNodeObjectParent *graphNode;
struct GraphNode *node = NULL;
struct GraphNode *node = nullptr;
s16 index = cur_geo_cmd_s16(0x02);
if (index >= 0) {
if (index >= 0)
{
node = gGeoViews[index];
if (node->type == GRAPH_NODE_TYPE_OBJECT_PARENT) {
node = ((struct GraphNodeObjectParent *) node)->sharedChild;
} else {
node = NULL;
if (node->type == GRAPH_NODE_TYPE_OBJECT_PARENT)
{
node = ((struct GraphNodeObjectParent *)node)->sharedChild;
}
else
{
node = nullptr;
}
}
graphNode = init_graph_node_object_parent(gGraphNodePool, NULL, node);
graphNode = init_graph_node_object_parent(gGraphNodePool, nullptr, node);
register_scene_graph_node(&graphNode->node);
@@ -743,14 +789,15 @@ void geo_layout_cmd_copy_view(void) {
cmd+0x06: s16 offsetZ
cmd+0x08: GraphNodeFunc nodeFunc
*/
void geo_layout_cmd_node_held_obj(void) {
void geo_layout_cmd_node_held_obj(void)
{
struct GraphNodeHeldObject *graphNode;
Vec3s offset;
read_vec3s(offset, (s16 *) &gGeoLayoutCommand[0x02]);
read_vec3s(offset, (s16 *)&gGeoLayoutCommand[0x02]);
graphNode = init_graph_node_held_object(
gGraphNodePool, NULL, NULL, offset, (GraphNodeFunc) cur_geo_cmd_ptr(0x08), cur_geo_cmd_u8(0x01));
gGraphNodePool, nullptr, nullptr, offset, cur_geo_cmd_ptr(0x08), cur_geo_cmd_u8(0x01));
register_scene_graph_node(&graphNode->fnNode.node);
@@ -762,17 +809,19 @@ void geo_layout_cmd_node_held_obj(void) {
is used for frustum culling.
cmd+0x02: s16 cullingRadius
*/
void geo_layout_cmd_node_culling_radius(void) {
void geo_layout_cmd_node_culling_radius(void)
{
struct GraphNodeCullingRadius *graphNode;
graphNode = init_graph_node_culling_radius(gGraphNodePool, NULL, cur_geo_cmd_s16(0x02));
graphNode = init_graph_node_culling_radius(gGraphNodePool, nullptr, cur_geo_cmd_s16(0x02));
register_scene_graph_node(&graphNode->node);
gGeoLayoutCommand += 0x04 << CMD_SIZE_SHIFT;
}
struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr) {
struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr)
{
// set by register_scene_graph_node when gCurGraphNodeIndex is 0
// and gCurRootGraphNode is NULL
gCurRootGraphNode = NULL;
// and gCurRootGraphNode is nullptr
gCurRootGraphNode = nullptr;
gGeoNumViews = 0; // number of entries in gGeoViews
@@ -789,7 +838,8 @@ struct GraphNode *process_geo_layout(struct AllocOnlyPool *pool, void *segptr) {
gGeoLayoutStack[0] = 0;
gGeoLayoutStack[1] = 0;
while (gGeoLayoutCommand != NULL) {
while (gGeoLayoutCommand != nullptr)
{
GeoLayoutJumpTable[gGeoLayoutCommand[0x00]]();
}
+32
View File
@@ -49,37 +49,69 @@ extern s16 D_8038BD78;
extern struct GraphNode *D_8038BCF8[];
void geo_layout_cmd_branch_and_link(void);
void geo_layout_cmd_end(void);
void geo_layout_cmd_branch(void);
void geo_layout_cmd_return(void);
void geo_layout_cmd_open_node(void);
void geo_layout_cmd_close_node(void);
void geo_layout_cmd_assign_as_view(void);
void geo_layout_cmd_update_node_flags(void);
void geo_layout_cmd_node_root(void);
void geo_layout_cmd_node_ortho_projection(void);
void geo_layout_cmd_node_perspective(void);
void geo_layout_cmd_node_start(void);
void geo_layout_cmd_nop3(void);
void geo_layout_cmd_node_master_list(void);
void geo_layout_cmd_node_level_of_detail(void);
void geo_layout_cmd_node_switch_case(void);
void geo_layout_cmd_node_camera(void);
void geo_layout_cmd_node_translation_rotation(void);
void geo_layout_cmd_node_translation(void);
void geo_layout_cmd_node_rotation(void);
void geo_layout_cmd_node_scale(void);
void geo_layout_cmd_nop2(void);
void geo_layout_cmd_node_animated_part(void);
void geo_layout_cmd_node_billboard(void);
void geo_layout_cmd_node_display_list(void);
void geo_layout_cmd_node_shadow(void);
void geo_layout_cmd_node_object_parent(void);
void geo_layout_cmd_node_generated(void);
void geo_layout_cmd_node_background(void);
void geo_layout_cmd_nop(void);
void geo_layout_cmd_copy_view(void);
void geo_layout_cmd_node_held_obj(void);
void geo_layout_cmd_node_culling_radius(void);
struct GraphNode *process_geo_layout(struct AllocOnlyPool *a0, void *segptr);
File diff suppressed because it is too large Load Diff
+221 -93
View File
@@ -70,23 +70,34 @@ typedef Gfx *(*GraphNodeFunc)(s32 callContext, struct GraphNode *node, void *con
*/
struct FnGraphNode
{
/*0x00*/ struct GraphNode node;
/*0x14*/ GraphNodeFunc func;
/*0x00*/
struct GraphNode node;
/*0x14*/
GraphNodeFunc func;
};
/** The very root of the geo tree. Specifies the viewport.
*/
struct GraphNodeRoot
{
/*0x00*/ struct GraphNode node;
/*0x14*/ u8 areaIndex;
/*0x15*/ s8 unk15; // ?
/*0x16*/ s16 x;
/*0x18*/ s16 y;
/*0x1A*/ s16 width; // half width, 160
/*0x1C*/ s16 height; // half height
/*0x1E*/ s16 numViews; // number of entries in mystery array
/*0x20*/ struct GraphNode **views;
/*0x00*/
struct GraphNode node;
/*0x14*/
u8 areaIndex;
/*0x15*/
s8 unk15; // ?
/*0x16*/
s16 x;
/*0x18*/
s16 y;
/*0x1A*/
s16 width; // half width, 160
/*0x1C*/
s16 height; // half height
/*0x1E*/
s16 numViews; // number of entries in mystery array
/*0x20*/
struct GraphNode **views;
};
/** A node that sets up an orthographic projection based on the global
@@ -94,8 +105,10 @@ struct GraphNodeRoot
*/
struct GraphNodeOrthoProjection
{
/*0x00*/ struct GraphNode node;
/*0x14*/ f32 scale;
/*0x00*/
struct GraphNode node;
/*0x14*/
f32 scale;
};
/** A node that sets up a perspective projection. Used for drawing the
@@ -104,11 +117,16 @@ struct GraphNodeOrthoProjection
*/
struct GraphNodePerspective
{
/*0x00*/ struct FnGraphNode fnNode;
/*0x18*/ s32 unused;
/*0x1C*/ f32 fov; // horizontal field of view in degrees
/*0x20*/ s16 near; // near clipping plane
/*0x22*/ s16 far; // far clipping plane
/*0x00*/
struct FnGraphNode fnNode;
/*0x18*/
s32 unused;
/*0x1C*/
f32 fov; // horizontal field of view in degrees
/*0x20*/
s16 near; // near clipping plane
/*0x22*/
s16 far; // far clipping plane
};
/** An entry in the master list. It is a linked list of display lists
@@ -128,9 +146,12 @@ struct DisplayListNode
*/
struct GraphNodeMasterList
{
/*0x00*/ struct GraphNode node;
/*0x14*/ struct DisplayListNode *listHeads[GFX_NUM_MASTER_LISTS];
/*0x34*/ struct DisplayListNode *listTails[GFX_NUM_MASTER_LISTS];
/*0x00*/
struct GraphNode node;
/*0x14*/
struct DisplayListNode *listHeads[GFX_NUM_MASTER_LISTS];
/*0x34*/
struct DisplayListNode *listTails[GFX_NUM_MASTER_LISTS];
};
/** Simply used as a parent to group multiple children.
@@ -138,7 +159,8 @@ struct GraphNodeMasterList
*/
struct GraphNodeStart
{
/*0x00*/ struct GraphNode node;
/*0x00*/
struct GraphNode node;
};
/** GraphNode that only renders its children if the current transformation matrix
@@ -149,9 +171,12 @@ struct GraphNodeStart
*/
struct GraphNodeLevelOfDetail
{
/*0x00*/ struct GraphNode node;
/*0x14*/ s16 minDistance;
/*0x16*/ s16 maxDistance;
/*0x00*/
struct GraphNode node;
/*0x14*/
s16 minDistance;
/*0x16*/
s16 maxDistance;
};
/** GraphNode that renders exactly one of its children.
@@ -161,10 +186,14 @@ struct GraphNodeLevelOfDetail
*/
struct GraphNodeSwitchCase
{
/*0x00*/ struct FnGraphNode fnNode;
/*0x18*/ s32 unused;
/*0x1C*/ s16 numCases;
/*0x1E*/ s16 selectedCase;
/*0x00*/
struct FnGraphNode fnNode;
/*0x18*/
s32 unused;
/*0x1C*/
s16 numCases;
/*0x1E*/
s16 selectedCase;
};
/**
@@ -173,8 +202,12 @@ struct GraphNodeSwitchCase
*/
struct GraphNodeCamera
{
/*0x00*/ struct FnGraphNode fnNode;
/*0x18*/ union {
/*0x00*/
struct FnGraphNode fnNode;
/*0x18*/
union
{
// When the node is created, a mode is assigned to the node.
// Later in geo_camera_main a Camera is allocated,
// the mode is passed to the struct, and the field is overridden
@@ -182,11 +215,17 @@ struct GraphNodeCamera
s32 mode;
struct Camera *camera;
} config;
/*0x1C*/ Vec3f pos;
/*0x28*/ Vec3f focus;
/*0x34*/ Mat4 *matrixPtr; // pointer to look-at matrix of this camera as a Mat4
/*0x38*/ s16 roll; // roll in look at matrix. Doesn't account for light direction unlike rollScreen.
/*0x3A*/ s16 rollScreen; // rolls screen while keeping the light direction consistent
/*0x1C*/
Vec3f pos;
/*0x28*/
Vec3f focus;
/*0x34*/
Mat4 *matrixPtr; // pointer to look-at matrix of this camera as a Mat4
/*0x38*/
s16 roll; // roll in look at matrix. Doesn't account for light direction unlike rollScreen.
/*0x3A*/
s16 rollScreen; // rolls screen while keeping the light direction consistent
};
/** GraphNode that translates and rotates its children.
@@ -197,10 +236,14 @@ struct GraphNodeCamera
*/
struct GraphNodeTranslationRotation
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x18*/ Vec3s translation;
/*0x1E*/ Vec3s rotation;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
/*0x18*/
Vec3s translation;
/*0x1E*/
Vec3s rotation;
};
/** GraphNode that translates itself and its children.
@@ -209,9 +252,12 @@ struct GraphNodeTranslationRotation
*/
struct GraphNodeTranslation
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x18*/ Vec3s translation;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
/*0x18*/
Vec3s translation;
u8 pad1E[2];
};
@@ -222,9 +268,12 @@ struct GraphNodeTranslation
*/
struct GraphNodeRotation
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x18*/ Vec3s rotation;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
/*0x18*/
Vec3s rotation;
u8 pad1E[2];
};
@@ -237,9 +286,12 @@ struct GraphNodeRotation
*/
struct GraphNodeAnimatedPart
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x18*/ Vec3s translation;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
/*0x18*/
Vec3s translation;
};
/** A GraphNode that draws a display list rotated in a way to always face the
@@ -249,9 +301,12 @@ struct GraphNodeAnimatedPart
*/
struct GraphNodeBillboard
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x18*/ Vec3s translation;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
/*0x18*/
Vec3s translation;
};
/** A GraphNode that simply draws a display list without doing any
@@ -259,8 +314,10 @@ struct GraphNodeBillboard
*/
struct GraphNodeDisplayList
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
};
/** GraphNode part that scales itself and its children.
@@ -273,9 +330,12 @@ struct GraphNodeDisplayList
*/
struct GraphNodeScale
{
/*0x00*/ struct GraphNode node;
/*0x14*/ void *displayList;
/*0x18*/ f32 scale;
/*0x00*/
struct GraphNode node;
/*0x14*/
void *displayList;
/*0x18*/
f32 scale;
};
/** GraphNode that draws a shadow under an object.
@@ -285,10 +345,14 @@ struct GraphNodeScale
*/
struct GraphNodeShadow
{
/*0x00*/ struct GraphNode node;
/*0x14*/ s16 shadowScale; // diameter (when a circle) or side (when a square) of shadow
/*0x16*/ u8 shadowSolidity; // opacity of shadow, 255 = opaque
/*0x17*/ u8 shadowType; // see ShadowType enum in shadow.h
/*0x00*/
struct GraphNode node;
/*0x14*/
s16 shadowScale; // diameter (when a circle) or side (when a square) of shadow
/*0x16*/
u8 shadowSolidity; // opacity of shadow, 255 = opaque
/*0x17*/
u8 shadowType; // see ShadowType enum in shadow.h
};
/** GraphNode that contains as its sharedChild a group node containing all
@@ -296,8 +360,10 @@ struct GraphNodeShadow
*/
struct GraphNodeObjectParent
{
/*0x00*/ struct GraphNode node;
/*0x14*/ struct GraphNode *sharedChild;
/*0x00*/
struct GraphNode node;
/*0x14*/
struct GraphNode *sharedChild;
};
/** GraphNode that draws display lists not directly in memory but generated by
@@ -310,8 +376,10 @@ struct GraphNodeObjectParent
*/
struct GraphNodeGenerated
{
/*0x00*/ struct FnGraphNode fnNode;
/*0x18*/ u32 parameter; // extra context for the function
/*0x00*/
struct FnGraphNode fnNode;
/*0x18*/
u32 parameter; // extra context for the function
};
/** GraphNode that draws a background image or a rectangle of a color.
@@ -319,19 +387,26 @@ struct GraphNodeGenerated
*/
struct GraphNodeBackground
{
/*0x00*/ struct FnGraphNode fnNode;
/*0x18*/ s32 unused;
/*0x1C*/ s32 background; // background ID, or rgba5551 color if fnNode.func is null
/*0x00*/
struct FnGraphNode fnNode;
/*0x18*/
s32 unused;
/*0x1C*/
s32 background; // background ID, or rgba5551 color if fnNode.func is null
};
/** Renders the object that Mario is holding.
*/
struct GraphNodeHeldObject
{
/*0x00*/ struct FnGraphNode fnNode;
/*0x18*/ s32 playerIndex;
/*0x1C*/ struct Object *objNode;
/*0x20*/ Vec3s translation;
/*0x00*/
struct FnGraphNode fnNode;
/*0x18*/
s32 playerIndex;
/*0x1C*/
struct Object *objNode;
/*0x20*/
Vec3s translation;
};
/** A node that allows an object to specify a different culling radius than the
@@ -341,8 +416,10 @@ struct GraphNodeHeldObject
*/
struct GraphNodeCullingRadius
{
/*0x00*/ struct GraphNode node;
/*0x14*/ s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustum culling
/*0x00*/
struct GraphNode node;
/*0x14*/
s16 cullingRadius; // specifies the 'sphere radius' for purposes of frustum culling
u8 pad1E[2];
};
@@ -363,71 +440,122 @@ extern s16 gCurGraphNodeIndex;
void init_scene_graph_node_links(struct GraphNode *graphNode, s32 type);
struct GraphNodeRoot *init_graph_node_root(struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode,
struct GraphNodeRoot *init_graph_node_root(
struct AllocOnlyPool *pool, struct GraphNodeRoot *graphNode,
s16 areaIndex, s16 x, s16 y, s16 width, s16 height);
struct GraphNodeOrthoProjection *init_graph_node_ortho_projection(struct AllocOnlyPool *pool, struct GraphNodeOrthoProjection *graphNode, f32 scale);
struct GraphNodePerspective *init_graph_node_perspective(struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode,
struct GraphNodePerspective *init_graph_node_perspective(
struct AllocOnlyPool *pool, struct GraphNodePerspective *graphNode,
f32 fov, s16 near, s16 far, GraphNodeFunc nodeFunc, s32 unused);
struct GraphNodeStart *init_graph_node_start(struct AllocOnlyPool *pool, struct GraphNodeStart *graphNode);
struct GraphNodeMasterList *init_graph_node_master_list(struct AllocOnlyPool *pool, struct GraphNodeMasterList *graphNode, s16 on);
struct GraphNodeLevelOfDetail *init_graph_node_render_range(struct AllocOnlyPool *pool, struct GraphNodeLevelOfDetail *graphNode,
struct GraphNodeLevelOfDetail *init_graph_node_render_range(
struct AllocOnlyPool *pool, struct GraphNodeLevelOfDetail *graphNode,
s16 minDistance, s16 maxDistance);
struct GraphNodeSwitchCase *init_graph_node_switch_case(struct AllocOnlyPool *pool, struct GraphNodeSwitchCase *graphNode,
struct GraphNodeSwitchCase *init_graph_node_switch_case(
struct AllocOnlyPool *pool, struct GraphNodeSwitchCase *graphNode,
s16 numCases, s16 selectedCase, GraphNodeFunc nodeFunc, s32 unused);
struct GraphNodeCamera *init_graph_node_camera(struct AllocOnlyPool *pool, struct GraphNodeCamera *graphNode,
struct GraphNodeCamera *init_graph_node_camera(
struct AllocOnlyPool *pool, struct GraphNodeCamera *graphNode,
f32 *pos, f32 *focus, GraphNodeFunc func, s32 mode);
struct GraphNodeTranslationRotation *init_graph_node_translation_rotation(struct AllocOnlyPool *pool, struct GraphNodeTranslationRotation *graphNode,
struct GraphNodeTranslationRotation *init_graph_node_translation_rotation(
struct AllocOnlyPool *pool, struct GraphNodeTranslationRotation *graphNode,
s32 drawingLayer, void *displayList, Vec3s translation, Vec3s rotation);
struct GraphNodeTranslation *init_graph_node_translation(struct AllocOnlyPool *pool, struct GraphNodeTranslation *graphNode,
struct GraphNodeTranslation *init_graph_node_translation(
struct AllocOnlyPool *pool, struct GraphNodeTranslation *graphNode,
s32 drawingLayer, void *displayList, Vec3s translation);
struct GraphNodeRotation *init_graph_node_rotation(struct AllocOnlyPool *pool, struct GraphNodeRotation *graphNode,
struct GraphNodeRotation *init_graph_node_rotation(
struct AllocOnlyPool *pool, struct GraphNodeRotation *graphNode,
s32 drawingLayer, void *displayList, Vec3s rotation);
struct GraphNodeScale *init_graph_node_scale(struct AllocOnlyPool *pool, struct GraphNodeScale *graphNode,
struct GraphNodeScale *init_graph_node_scale(
struct AllocOnlyPool *pool, struct GraphNodeScale *graphNode,
s32 drawingLayer, void *displayList, f32 scale);
struct GraphNodeObject *init_graph_node_object(struct AllocOnlyPool *pool, struct GraphNodeObject *graphNode,
struct GraphNodeObject *init_graph_node_object(
struct AllocOnlyPool *pool, struct GraphNodeObject *graphNode,
struct GraphNode *sharedChild, Vec3f pos, Vec3s angle, Vec3f scale);
struct GraphNodeCullingRadius *init_graph_node_culling_radius(struct AllocOnlyPool *pool, struct GraphNodeCullingRadius *graphNode, s16 radius);
struct GraphNodeAnimatedPart *init_graph_node_animated_part(struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart *graphNode,
struct GraphNodeAnimatedPart *init_graph_node_animated_part(
struct AllocOnlyPool *pool, struct GraphNodeAnimatedPart *graphNode,
s32 drawingLayer, void *displayList, Vec3s translation);
struct GraphNodeBillboard *init_graph_node_billboard(struct AllocOnlyPool *pool, struct GraphNodeBillboard *graphNode,
struct GraphNodeBillboard *init_graph_node_billboard(
struct AllocOnlyPool *pool, struct GraphNodeBillboard *graphNode,
s32 drawingLayer, void *displayList, Vec3s translation);
struct GraphNodeDisplayList *init_graph_node_display_list(struct AllocOnlyPool *pool, struct GraphNodeDisplayList *graphNode,
struct GraphNodeDisplayList *init_graph_node_display_list(
struct AllocOnlyPool *pool, struct GraphNodeDisplayList *graphNode,
s32 drawingLayer, void *displayList);
struct GraphNodeShadow *init_graph_node_shadow(struct AllocOnlyPool *pool, struct GraphNodeShadow *graphNode,
struct GraphNodeShadow *init_graph_node_shadow(
struct AllocOnlyPool *pool, struct GraphNodeShadow *graphNode,
s16 shadowScale, u8 shadowSolidity, u8 shadowType);
struct GraphNodeObjectParent *init_graph_node_object_parent(struct AllocOnlyPool *pool, struct GraphNodeObjectParent *sp1c,
struct GraphNodeObjectParent *init_graph_node_object_parent(
struct AllocOnlyPool *pool, struct GraphNodeObjectParent *sp1c,
struct GraphNode *sharedChild);
struct GraphNodeGenerated *init_graph_node_generated(struct AllocOnlyPool *pool, struct GraphNodeGenerated *sp1c,
struct GraphNodeGenerated *init_graph_node_generated(
struct AllocOnlyPool *pool, struct GraphNodeGenerated *sp1c,
GraphNodeFunc gfxFunc, s32 parameter);
struct GraphNodeBackground *init_graph_node_background(struct AllocOnlyPool *pool, struct GraphNodeBackground *sp1c,
struct GraphNodeBackground *init_graph_node_background(
struct AllocOnlyPool *pool, struct GraphNodeBackground *sp1c,
u16 background, GraphNodeFunc backgroundFunc, s32 zero);
struct GraphNodeHeldObject *init_graph_node_held_object(struct AllocOnlyPool *pool, struct GraphNodeHeldObject *sp1c,
struct GraphNodeHeldObject *init_graph_node_held_object(
struct AllocOnlyPool *pool, struct GraphNodeHeldObject *sp1c,
struct Object *objNode, Vec3s translation,
GraphNodeFunc nodeFunc, s32 playerIndex);
struct GraphNode *geo_add_child(struct GraphNode *parent, struct GraphNode *childNode);
struct GraphNode *geo_remove_child(struct GraphNode *graphNode);
struct GraphNode *geo_make_first_child(struct GraphNode *newFirstChild);
void geo_call_global_function_nodes_helper(struct GraphNode *graphNode, s32 callContext);
void geo_call_global_function_nodes(struct GraphNode *graphNode, s32 callContext);
void geo_reset_object_node(struct GraphNodeObject *graphNode);
void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle);
void geo_obj_init_spawninfo(struct GraphNodeObject *graphNode, struct SpawnInfo *spawn);
void geo_obj_init_animation(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr);
void geo_obj_init_animation_accel(struct GraphNodeObject *graphNode, struct Animation **animPtrAddr, u32 animAccel);
s32 retrieve_animation_index(s32 frame, u16 **attributes);
s16 geo_update_animation_frame(struct AnimInfo *obj, s32 *accelAssist);
void geo_retreive_animation_translation(struct GraphNodeObject *obj, Vec3f position);
struct GraphNodeRoot *geo_find_root(struct GraphNode *graphNode);
// graph_node_manager
s16 *read_vec3s_to_vec3f(Vec3f, s16 *src);
s16 *read_vec3s_to_vec3f(Vec3f, s16 * src);
s16 *read_vec3s(Vec3s dst, s16 *src);
s16 *read_vec3s_angle(Vec3s dst, s16 *src);
void register_scene_graph_node(struct GraphNode *graphNode);
#endif // GRAPH_NODE_H
+29 -14
View File
@@ -6,13 +6,16 @@
#include "graph_node.h"
#if IS_64_BIT
static s16 next_s16_in_geo_script(s16 **src) {
static s16 next_s16_in_geo_script(s16 **src)
{
s16 ret;
if (((uintptr_t)(*src) & 7) == 4) {
if (((uintptr_t) * src & 7) == 4)
{
*src += 2; // skip 32 bits
}
ret = *(*src)++;
if (((uintptr_t)(*src) & 7) == 4) {
if (((uintptr_t) * src & 7) == 4)
{
*src += 2; // skip 32 bits
}
return ret;
@@ -25,7 +28,8 @@ static s16 next_s16_in_geo_script(s16 **src) {
* Takes a pointer to three shorts (supplied by a geo layout script) and
* copies it to the destination float vector.
*/
s16 *read_vec3s_to_vec3f(Vec3f dst, s16 *src) {
s16 *read_vec3s_to_vec3f(Vec3f dst, s16 *src)
{
dst[0] = next_s16_in_geo_script(&src);
dst[1] = next_s16_in_geo_script(&src);
dst[2] = next_s16_in_geo_script(&src);
@@ -37,7 +41,8 @@ s16 *read_vec3s_to_vec3f(Vec3f dst, s16 *src) {
* copies it to the destination vector. It's essentially a memcpy but consistent
* with the other two 'geo-script vector to internal vector' functions.
*/
s16 *read_vec3s(Vec3s dst, s16 *src) {
s16 *read_vec3s(Vec3s dst, s16 *src)
{
dst[0] = next_s16_in_geo_script(&src);
dst[1] = next_s16_in_geo_script(&src);
dst[2] = next_s16_in_geo_script(&src);
@@ -49,7 +54,8 @@ s16 *read_vec3s(Vec3s dst, s16 *src) {
* and converts it to a vector of three in-game angle units in [-32768, 32767]
* range.
*/
s16 *read_vec3s_angle(Vec3s dst, s16 *src) {
s16 *read_vec3s_angle(Vec3s dst, s16 *src)
{
dst[0] = (next_s16_in_geo_script(&src) << 15) / 180;
dst[1] = (next_s16_in_geo_script(&src) << 15) / 180;
dst[2] = (next_s16_in_geo_script(&src) << 15) / 180;
@@ -61,19 +67,28 @@ s16 *read_vec3s_angle(Vec3s dst, s16 *src) {
* 'gCurGraphNodeList'. This is called from geo_layout commands to add nodes
* to the scene graph.
*/
void register_scene_graph_node(struct GraphNode *graphNode) {
if (graphNode != NULL) {
void register_scene_graph_node(struct GraphNode *graphNode)
{
if (graphNode != nullptr)
{
gCurGraphNodeList[gCurGraphNodeIndex] = graphNode;
if (gCurGraphNodeIndex == 0) {
if (gCurRootGraphNode == NULL) {
if (gCurGraphNodeIndex == 0)
{
if (gCurRootGraphNode == nullptr)
{
gCurRootGraphNode = graphNode;
}
} else {
if (gCurGraphNodeList[gCurGraphNodeIndex - 1]->type == GRAPH_NODE_TYPE_OBJECT_PARENT) {
((struct GraphNodeObjectParent *) gCurGraphNodeList[gCurGraphNodeIndex - 1])
}
else
{
if (gCurGraphNodeList[gCurGraphNodeIndex - 1]->type == GRAPH_NODE_TYPE_OBJECT_PARENT)
{
((struct GraphNodeObjectParent *)gCurGraphNodeList[gCurGraphNodeIndex - 1])
->sharedChild = graphNode;
} else {
}
else
{
geo_add_child(gCurGraphNodeList[gCurGraphNodeIndex - 1], graphNode);
}
}
+38 -21
View File
@@ -5,14 +5,17 @@
#endif
#ifndef GBI_FLOATS
void guMtxF2L(float mf[4][4], Mtx *m) {
void guMtxF2L(float mf[4][4], Mtx *m)
{
int r, c;
s32 tmp1;
s32 tmp2;
s32 *m1 = &m->m[0][0];
s32 *m2 = &m->m[2][0];
for (r = 0; r < 4; r++) {
for (c = 0; c < 2; c++) {
for (r = 0; r < 4; r++)
{
for (c = 0; c < 2; c++)
{
tmp1 = mf[r][2 * c] * 65536.0f;
tmp2 = mf[r][2 * c + 1] * 65536.0f;
*m1++ = (tmp1 & 0xffff0000) | ((tmp2 >> 0x10) & 0xffff);
@@ -20,53 +23,67 @@ void guMtxF2L(float mf[4][4], Mtx *m) {
}
}
}
void guMtxL2F(float mf[4][4], Mtx *m) {
void guMtxL2F(float mf[4][4], Mtx *m)
{
int r, c;
u32 tmp1;
u32 tmp2;
u32 *m1;
u32 *m2;
s32 stmp1, stmp2;
m1 = (u32 *) &m->m[0][0];
m2 = (u32 *) &m->m[2][0];
for (r = 0; r < 4; r++) {
for (c = 0; c < 2; c++) {
m1 = (u32 *)&m->m[0][0];
m2 = (u32 *)&m->m[2][0];
for (r = 0; r < 4; r++)
{
for (c = 0; c < 2; c++)
{
tmp1 = (*m1 & 0xffff0000) | ((*m2 >> 0x10) & 0xffff);
tmp2 = ((*m1++ << 0x10) & 0xffff0000) | (*m2++ & 0xffff);
stmp1 = *(s32 *) &tmp1;
stmp2 = *(s32 *) &tmp2;
stmp1 = *(s32 *)&tmp1;
stmp2 = *(s32 *)&tmp2;
mf[r][c * 2 + 0] = stmp1 / 65536.0f;
mf[r][c * 2 + 1] = stmp2 / 65536.0f;
}
}
}
#else
void guMtxF2L(float mf[4][4], Mtx *m) {
void guMtxF2L(float mf[4][4], Mtx *m)
{
memcpy(m, mf, sizeof(Mtx));
}
void guMtxL2F(float mf[4][4], Mtx *m) {
void guMtxL2F(float mf[4][4], Mtx *m)
{
memcpy(mf, m, sizeof(Mtx));
}
#endif
void guMtxIdentF(float mf[4][4]) {
void guMtxIdentF(float mf[4][4])
{
int r, c;
for (r = 0; r < 4; r++) {
for (c = 0; c < 4; c++) {
if (r == c) {
for (r = 0; r < 4; r++)
{
for (c = 0; c < 4; c++)
{
if (r == c)
{
mf[r][c] = 1.0f;
} else {
}
else
{
mf[r][c] = 0.0f;
}
}
}
}
void guMtxIdent(Mtx *m) {
#ifndef GBI_FLOATS
void guMtxIdent(Mtx *m)
{
#ifndef GBI_FLOATS
float mf[4][4];
guMtxIdentF(mf);
guMtxF2L(mf, m);
#else
#else
guMtxIdentF(m->m);
#endif
#endif
}
+1
View File
@@ -4,6 +4,7 @@
#include "../include/PR/gbi.h"
extern void guMtxF2L(float mf[4][4], Mtx *m);
extern void guMtxL2F(float mf[4][4], Mtx *m);
#endif//GUMTXF2L_H
+201 -113
View File
@@ -8,13 +8,13 @@
#include "graph_node.h"
#include "surface_collision.h"
static Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f };
static Vec3f gVec3fZero = {0.0f, 0.0f, 0.0f};
// Inlined tables
f32 gSineTable[] = {
0.000000000f, 0.0015339801f,0.0030679568f,0.004601926f,
0.0061358847f,0.007669829f, 0.009203754f, 0.010737659f,
0.012271538f, 0.0138053885f,0.015339206f, 0.016872987f,
0.000000000f, 0.0015339801f, 0.0030679568f, 0.004601926f,
0.0061358847f, 0.007669829f, 0.009203754f, 0.010737659f,
0.012271538f, 0.0138053885f, 0.015339206f, 0.016872987f,
0.018406730f, 0.019940428f, 0.021474080f, 0.023007682f,
0.024541229f, 0.026074719f, 0.027608145f, 0.029141508f,
0.030674804f, 0.032208025f, 0.033741172f, 0.035274237f,
@@ -268,11 +268,11 @@ f32 gSineTable[] = {
0.999830604f, 0.999857664f, 0.999882340f, 0.999904692f,
0.999924719f, 0.999942362f, 0.999957621f, 0.999970615f,
0.999981165f, 0.999989390f, 0.999995291f, 0.999998808f,
#ifndef AVOID_UB
#ifndef AVOID_UB
};
f32 gCosineTable[0x1000] = {
#endif
#endif
// cosine
1.000000000f, 0.999998808f, 0.999995291f, 0.999989390f,
0.999981165f, 0.999970615f, 0.999957621f, 0.999942362f,
@@ -529,12 +529,12 @@ f32 gCosineTable[0x1000] = {
0.024541229f, 0.023007682f, 0.021474080f, 0.019940428f,
0.018406730f, 0.016872987f, 0.015339206f, 0.0138053885f,
0.012271538f, 0.010737659f, 0.009203754f, 0.007669829f,
0.0061358847f,0.004601926f, 0.0030679568f,0.0015339801f,
0.0061358847f, 0.004601926f, 0.0030679568f, 0.0015339801f,
// negative sine
0.000000000f, -0.0015339801f,-0.0030679568f,-0.004601926f,
-0.0061358847f,-0.007669829f, -0.009203754f, -0.010737659f,
-0.012271538f, -0.0138053885f,-0.015339206f, -0.016872987f,
0.000000000f, -0.0015339801f, -0.0030679568f, -0.004601926f,
-0.0061358847f, -0.007669829f, -0.009203754f, -0.010737659f,
-0.012271538f, -0.0138053885f, -0.015339206f, -0.016872987f,
-0.018406730f, -0.019940428f, -0.021474080f, -0.023007682f,
-0.024541229f, -0.026074719f, -0.027608145f, -0.029141508f,
-0.030674804f, -0.032208025f, -0.033741172f, -0.035274237f,
@@ -1045,12 +1045,12 @@ f32 gCosineTable[0x1000] = {
-0.024541229f, -0.023007682f, -0.021474080f, -0.019940428f,
-0.018406730f, -0.016872987f, -0.015339206f, -0.0138053885f,
-0.012271538f, -0.010737659f, -0.009203754f, -0.007669829f,
-0.0061358847f,-0.004601926f, -0.0030679568f,-0.0015339801f,
-0.0061358847f, -0.004601926f, -0.0030679568f, -0.0015339801f,
// sine
0.000000000f, 0.0015339801f,0.0030679568f,0.004601926f,
0.0061358847f,0.007669829f, 0.009203754f, 0.010737659f,
0.012271538f, 0.0138053885f,0.015339206f, 0.016872987f,
0.000000000f, 0.0015339801f, 0.0030679568f, 0.004601926f,
0.0061358847f, 0.007669829f, 0.009203754f, 0.010737659f,
0.012271538f, 0.0138053885f, 0.015339206f, 0.016872987f,
0.018406730f, 0.019940428f, 0.021474080f, 0.023007682f,
0.024541229f, 0.026074719f, 0.027608145f, 0.029141508f,
0.030674804f, 0.032208025f, 0.033741172f, 0.035274237f,
@@ -1450,7 +1450,8 @@ int gSplineState;
#pragma GCC diagnostic ignored "-Wreturn-local-addr"
/// Copy vector 'src' to 'dest'
void *vec3f_copy(Vec3f dest, Vec3f src) {
void *vec3f_copy(Vec3f dest, Vec3f src)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
@@ -1458,7 +1459,8 @@ void *vec3f_copy(Vec3f dest, Vec3f src) {
}
/// Set vector 'dest' to (x, y, z)
void *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) {
void *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z)
{
dest[0] = x;
dest[1] = y;
dest[2] = z;
@@ -1466,7 +1468,8 @@ void *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z) {
}
/// Add vector 'a' to 'dest'
void *vec3f_add(Vec3f dest, Vec3f a) {
void *vec3f_add(Vec3f dest, Vec3f a)
{
dest[0] += a[0];
dest[1] += a[1];
dest[2] += a[2];
@@ -1474,7 +1477,8 @@ void *vec3f_add(Vec3f dest, Vec3f a) {
}
/// Make 'dest' the sum of vectors a and b.
void *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) {
void *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b)
{
dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2];
@@ -1482,7 +1486,8 @@ void *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b) {
}
/// Copy vector src to dest
void *vec3s_copy(Vec3s dest, Vec3s src) {
void *vec3s_copy(Vec3s dest, Vec3s src)
{
dest[0] = src[0];
dest[1] = src[1];
dest[2] = src[2];
@@ -1490,7 +1495,8 @@ void *vec3s_copy(Vec3s dest, Vec3s src) {
}
/// Set vector 'dest' to (x, y, z)
void *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) {
void *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z)
{
dest[0] = x;
dest[1] = y;
dest[2] = z;
@@ -1498,7 +1504,8 @@ void *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z) {
}
/// Add vector a to 'dest'
void *vec3s_add(Vec3s dest, Vec3s a) {
void *vec3s_add(Vec3s dest, Vec3s a)
{
dest[0] += a[0];
dest[1] += a[1];
dest[2] += a[2];
@@ -1506,7 +1513,8 @@ void *vec3s_add(Vec3s dest, Vec3s a) {
}
/// Make 'dest' the sum of vectors a and b.
void *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) {
void *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b)
{
dest[0] = a[0] + b[0];
dest[1] = a[1] + b[1];
dest[2] = a[2] + b[2];
@@ -1514,7 +1522,8 @@ void *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b) {
}
/// Subtract vector a from 'dest'
void *vec3s_sub(Vec3s dest, Vec3s a) {
void *vec3s_sub(Vec3s dest, Vec3s a)
{
dest[0] -= a[0];
dest[1] -= a[1];
dest[2] -= a[2];
@@ -1522,7 +1531,8 @@ void *vec3s_sub(Vec3s dest, Vec3s a) {
}
/// Convert short vector a to float vector 'dest'
void *vec3s_to_vec3f(Vec3f dest, Vec3s a) {
void *vec3s_to_vec3f(Vec3f dest, Vec3s a)
{
dest[0] = a[0];
dest[1] = a[1];
dest[2] = a[2];
@@ -1533,11 +1543,12 @@ void *vec3s_to_vec3f(Vec3f dest, Vec3s a) {
* Convert float vector a to a short vector 'dest' by rounding the components
* to the nearest integer.
*/
void *vec3f_to_vec3s(Vec3s dest, Vec3f a) {
void *vec3f_to_vec3s(Vec3s dest, Vec3f a)
{
// add/subtract 0.5 in order to round to the nearest s32 instead of truncating
dest[0] = a[0] + ((a[0] > 0) ? 0.5f : -0.5f);
dest[1] = a[1] + ((a[1] > 0) ? 0.5f : -0.5f);
dest[2] = a[2] + ((a[2] > 0) ? 0.5f : -0.5f);
dest[0] = a[0] + (a[0] > 0 ? 0.5f : -0.5f);
dest[1] = a[1] + (a[1] > 0 ? 0.5f : -0.5f);
dest[2] = a[2] + (a[2] > 0 ? 0.5f : -0.5f);
return &dest; //! warning: function returns address of local variable
}
@@ -1546,7 +1557,8 @@ void *vec3f_to_vec3s(Vec3s dest, Vec3f a) {
* It is similar to vec3f_cross, but it calculates the vectors (c-b) and (b-a)
* at the same time.
*/
void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c) {
void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c)
{
dest[0] = (b[1] - a[1]) * (c[2] - b[2]) - (c[1] - b[1]) * (b[2] - a[2]);
dest[1] = (b[2] - a[2]) * (c[0] - b[0]) - (c[2] - b[2]) * (b[0] - a[0]);
dest[2] = (b[0] - a[0]) * (c[1] - b[1]) - (c[0] - b[0]) * (b[1] - a[1]);
@@ -1554,7 +1566,8 @@ void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c)
}
/// Make vector 'dest' the cross product of vectors a and b.
void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) {
void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b)
{
dest[0] = a[1] * b[2] - b[1] * a[2];
dest[1] = a[2] * b[0] - b[2] * a[0];
dest[2] = a[0] * b[1] - b[0] * a[1];
@@ -1562,7 +1575,8 @@ void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b) {
}
/// Scale vector 'dest' so it has length 1
void *vec3f_normalize(Vec3f dest) {
void *vec3f_normalize(Vec3f dest)
{
//! Possible division by zero
f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]);
@@ -1575,12 +1589,14 @@ void *vec3f_normalize(Vec3f dest) {
#pragma GCC diagnostic pop
/// Copy matrix 'src' to 'dest'
void mtxf_copy(Mat4 dest, Mat4 src) {
void mtxf_copy(Mat4 dest, Mat4 src)
{
register s32 i;
register u32 *d = (u32 *) dest;
register u32 *s = (u32 *) src;
register u32 *d = (u32 *)dest;
register u32 *s = (u32 *)src;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
{
*d++ = *s++;
}
}
@@ -1588,22 +1604,24 @@ void mtxf_copy(Mat4 dest, Mat4 src) {
/**
* Set mtx to the identity matrix
*/
void mtxf_identity(Mat4 mtx) {
void mtxf_identity(Mat4 mtx)
{
register s32 i;
register f32 *dest;
// These loops must be one line to match on -O2
// initialize everything except the first and last cells to 0
for (dest = (f32 *) mtx + 1, i = 0; i < 14; dest++, i++) *dest = 0;
for (dest = (f32 *)mtx + 1, i = 0; i < 14; dest++, i++) *dest = 0;
// initialize the diagonal cells to 1
for (dest = (f32 *) mtx, i = 0; i < 4; dest += 5, i++) *dest = 1;
for (dest = (f32 *)mtx, i = 0; i < 4; dest += 5, i++) *dest = 1;
}
/**
* Set dest to a translation matrix of vector b
*/
void mtxf_translate(Mat4 dest, Vec3f b) {
void mtxf_translate(Mat4 dest, Vec3f b)
{
mtxf_identity(dest);
dest[3][0] = b[0];
dest[3][1] = b[1];
@@ -1616,7 +1634,8 @@ void mtxf_translate(Mat4 dest, Vec3f b) {
* at the position 'to'. The up-vector is assumed to be (0, 1, 0), but the 'roll'
* angle allows a bank rotation of the camera.
*/
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) {
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll)
{
register f32 invLength;
f32 dx;
f32 dz;
@@ -1694,7 +1713,8 @@ void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll) {
* Build a matrix that rotates around the z axis, then the x axis, then the y
* axis, and then translates.
*/
void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate) {
void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate)
{
register f32 sx = sins(rotate[0]);
register f32 cx = coss(rotate[0]);
@@ -1727,7 +1747,8 @@ void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate) {
* Build a matrix that rotates around the x axis, then the y axis, then the z
* axis, and then translates.
*/
void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c) {
void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c)
{
register f32 sx = sins(c[0]);
register f32 cx = coss(c[0]);
@@ -1764,7 +1785,8 @@ void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c) {
* 'position' is the position of the object in the world
* 'angle' rotates the object while still facing the camera.
*/
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle)
{
dest[0][0] = coss(angle);
dest[0][1] = sins(angle);
dest[0][2] = 0;
@@ -1796,7 +1818,8 @@ void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle) {
* 'yaw' is the angle which it should face
* 'pos' is the object's position in the world
*/
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) {
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw)
{
Vec3f lateralDir;
Vec3f leftDir;
Vec3f forwardDir;
@@ -1839,7 +1862,8 @@ void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw) {
* 'pos' is the object's position in the world
* 'radius' is the distance from each triangle vertex to the center
*/
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius)
{
struct SM64SurfaceCollisionData *sp74;
Vec3f point0;
Vec3f point1;
@@ -1862,15 +1886,18 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
point1[1] = find_floor(point1[0], pos[1] + 150, point1[2], &sp74);
point2[1] = find_floor(point2[0], pos[1] + 150, point2[2], &sp74);
if (point0[1] - pos[1] < minY) {
if (point0[1] - pos[1] < minY)
{
point0[1] = pos[1];
}
if (point1[1] - pos[1] < minY) {
if (point1[1] - pos[1] < minY)
{
point1[1] = pos[1];
}
if (point2[1] - pos[1] < minY) {
if (point2[1] - pos[1] < minY)
{
point2[1] = pos[1];
}
@@ -1892,7 +1919,7 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
mtx[1][0] = yColumn[0];
mtx[1][1] = yColumn[1];
mtx[1][2] = yColumn[2];
mtx[3][1] = (avgY < pos[1]) ? pos[1] : avgY;
mtx[3][1] = avgY < pos[1] ? pos[1] : avgY;
mtx[2][0] = zColumn[0];
mtx[2][1] = zColumn[1];
@@ -1913,7 +1940,8 @@ void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius) {
* The resulting matrix represents first applying transformation b and
* then a.
*/
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b) {
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b)
{
Mat4 temp;
register f32 entry0;
register f32 entry1;
@@ -1960,10 +1988,12 @@ void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b) {
/**
* Set matrix 'dest' to 'mtx' scaled by vector s
*/
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s) {
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s)
{
register s32 i;
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
dest[0][i] = mtx[0][i] * s[0];
dest[1][i] = mtx[1][i] * s[1];
dest[2][i] = mtx[2][i] * s[2];
@@ -1976,7 +2006,8 @@ void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s) {
* to the point. Note that the bottom row is assumed to be [0, 0, 0, 1], which is
* true for transformation matrices if the translation has a w component of 1.
*/
void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
void mtxf_mul_vec3s(Mat4 mtx, Vec3s b)
{
register f32 x = b[0];
register f32 y = b[1];
register f32 z = b[2];
@@ -1986,7 +2017,8 @@ void mtxf_mul_vec3s(Mat4 mtx, Vec3s b) {
b[2] = x * mtx[0][2] + y * mtx[1][2] + z * mtx[2][2] + mtx[3][2];
}
void mtxf_mul_vec3f(Mat4 mtx, Vec3f b) {
void mtxf_mul_vec3f(Mat4 mtx, Vec3f b)
{
register f32 x = b[0];
register f32 y = b[1];
register f32 z = b[2];
@@ -1995,6 +2027,7 @@ void mtxf_mul_vec3f(Mat4 mtx, Vec3f b) {
b[1] = x * mtx[0][1] + y * mtx[1][1] + z * mtx[2][1] + mtx[3][1];
b[2] = x * mtx[0][2] + y * mtx[1][2] + z * mtx[2][2] + mtx[3][2];
}
/**
* Convert float matrix 'src' to fixed point matrix 'dest'.
* The float matrix may not contain entries larger than 65536 or the console
@@ -2004,30 +2037,33 @@ void mtxf_mul_vec3f(Mat4 mtx, Vec3f b) {
* exception. On Wii and Wii U Virtual Console the value will simply be clamped
* and no crashes occur.
*/
void mtxf_to_mtx(Mtx *dest, Mat4 src) {
#ifdef AVOID_UB
void mtxf_to_mtx(Mtx *dest, Mat4 src)
{
#ifdef AVOID_UB
// Avoid type-casting which is technically UB by calling the equivalent
// guMtxF2L function. This helps little-endian systems, as well.
guMtxF2L(src, dest);
#else
#else
s32 asFixedPoint;
register s32 i;
register s16 *a3 = (s16 *) dest; // all integer parts stored in first 16 bytes
register s16 *t0 = (s16 *) dest + 16; // all fraction parts stored in last 16 bytes
register f32 *t1 = (f32 *) src;
register s16 *a3 = (s16 *)dest; // all integer parts stored in first 16 bytes
register s16 *t0 = (s16 *)dest + 16; // all fraction parts stored in last 16 bytes
register f32 *t1 = (f32 *)src;
for (i = 0; i < 16; i++) {
for (i = 0; i < 16; i++)
{
asFixedPoint = *t1++ * (1 << 16); //! float-to-integer conversion responsible for PU crashes
*a3++ = GET_HIGH_S16_OF_32(asFixedPoint); // integer part
*t0++ = GET_LOW_S16_OF_32(asFixedPoint); // fraction part
}
#endif
#endif
}
/**
* Set 'mtx' to a transformation matrix that rotates around the z axis.
*/
void mtxf_rotate_xy(Mtx *mtx, s16 angle) {
void mtxf_rotate_xy(Mtx *mtx, s16 angle)
{
Mat4 temp;
mtxf_identity(temp);
@@ -2046,7 +2082,8 @@ void mtxf_rotate_xy(Mtx *mtx, s16 angle) {
* objMtx back from screen orientation to world orientation, and then subtracting
* the camera position.
*/
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx) {
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx)
{
f32 camX = camMtx[3][0] * camMtx[0][0] + camMtx[3][1] * camMtx[0][1] + camMtx[3][2] * camMtx[0][2];
f32 camY = camMtx[3][0] * camMtx[1][0] + camMtx[3][1] * camMtx[1][1] + camMtx[3][2] * camMtx[1][2];
f32 camZ = camMtx[3][0] * camMtx[2][0] + camMtx[3][1] * camMtx[2][1] + camMtx[3][2] * camMtx[2][2];
@@ -2064,7 +2101,8 @@ void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx) {
* of that vector, as well as the yaw and pitch angles.
* Basically it converts the direction to spherical coordinates.
*/
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw) {
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw)
{
register f32 x = to[0] - from[0];
register f32 y = to[1] - from[1];
register f32 z = to[2] - from[2];
@@ -2078,7 +2116,8 @@ void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *
* Construct the 'to' point which is distance 'dist' away from the 'from' position,
* and has the angles pitch and yaw.
*/
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw) {
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw)
{
to[0] = from[0] + dist * coss(pitch) * sins(yaw);
to[1] = from[1] + dist * sins(pitch);
to[2] = from[2] + dist * coss(pitch) * coss(yaw);
@@ -2088,18 +2127,24 @@ void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw
* Return the value 'current' after it tries to approach target, going up at
* most 'inc' and going down at most 'dec'.
*/
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec) {
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec)
{
//! If target is close to the max or min s32, then it's possible to overflow
// past it without stopping.
if (current < target) {
if (current < target)
{
current += inc;
if (current > target) {
if (current > target)
{
current = target;
}
} else {
}
else
{
current -= dec;
if (current < target) {
if (current < target)
{
current = target;
}
}
@@ -2110,15 +2155,21 @@ s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec) {
* Return the value 'current' after it tries to approach target, going up at
* most 'inc' and going down at most 'dec'.
*/
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) {
if (current < target) {
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec)
{
if (current < target)
{
current += inc;
if (current > target) {
if (current > target)
{
current = target;
}
} else {
}
else
{
current -= dec;
if (current < target) {
if (current < target)
{
current = target;
}
}
@@ -2129,12 +2180,16 @@ f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec) {
* Helper function for atan2s. Does a look up of the arctangent of y/x assuming
* the resulting angle is in range [0, 0x2000] (1/8 of a circle).
*/
static u16 atan2_lookup(f32 y, f32 x) {
static u16 atan2_lookup(f32 y, f32 x)
{
u16 ret;
if (x == 0) {
if (x == 0)
{
ret = gArctanTable[0];
} else {
}
else
{
ret = gArctanTable[(s32)(y / x * 1024 + 0.5f)];
}
return ret;
@@ -2144,37 +2199,59 @@ static u16 atan2_lookup(f32 y, f32 x) {
* Compute the angle from (0, 0) to (x, y) as a s16. Given that terrain is in
* the xz-plane, this is commonly called with (z, x) to get a yaw angle.
*/
s16 atan2s(f32 y, f32 x) {
s16 atan2s(f32 y, f32 x)
{
u16 ret;
if (x >= 0) {
if (y >= 0) {
if (y >= x) {
if (x >= 0)
{
if (y >= 0)
{
if (y >= x)
{
ret = atan2_lookup(x, y);
} else {
}
else
{
ret = 0x4000 - atan2_lookup(y, x);
}
} else {
}
else
{
y = -y;
if (y < x) {
if (y < x)
{
ret = 0x4000 + atan2_lookup(y, x);
} else {
}
else
{
ret = 0x8000 - atan2_lookup(x, y);
}
}
} else {
}
else
{
x = -x;
if (y < 0) {
if (y < 0)
{
y = -y;
if (y >= x) {
if (y >= x)
{
ret = 0x8000 + atan2_lookup(x, y);
} else {
}
else
{
ret = 0xC000 - atan2_lookup(y, x);
}
} else {
if (y < x) {
}
else
{
if (y < x)
{
ret = 0xC000 + atan2_lookup(y, x);
} else {
}
else
{
ret = -atan2_lookup(x, y);
}
}
@@ -2220,14 +2297,16 @@ s16 atan2s(f32 y, f32 x) {
* [0, 0, 0, 0, 1, 2, ... n-1, n, n, n, n]
* TODO: verify the classification of the spline / figure out how polynomials were computed
*/
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c) {
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c)
{
f32 tinv = 1 - t;
f32 tinv2 = tinv * tinv;
f32 tinv3 = tinv2 * tinv;
f32 t2 = t * t;
f32 t3 = t2 * t;
switch (gSplineState) {
switch (gSplineState)
{
case CURVE_BEGIN_1:
result[0] = tinv3;
result[1] = t3 * 1.75f - t2 * 4.5f + t * 3.0f;
@@ -2236,20 +2315,20 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c) {
break;
case CURVE_BEGIN_2:
result[0] = tinv3 * 0.25f;
result[1] = t3 * (7 / 12.0f) - t2 * 1.25f + t * 0.25f + (7 / 12.0f);
result[2] = -t3 * 0.5f + t2 * 0.5f + t * 0.5f + (1 / 6.0f);
result[1] = t3 * (7 / 12.0f) - t2 * 1.25f + t * 0.25f + 7 / 12.0f;
result[2] = -t3 * 0.5f + t2 * 0.5f + t * 0.5f + 1 / 6.0f;
result[3] = t3 * (1 / 6.0f);
break;
case CURVE_MIDDLE:
result[0] = tinv3 * (1 / 6.0f);
result[1] = t3 * 0.5f - t2 + (4 / 6.0f);
result[2] = -t3 * 0.5f + t2 * 0.5f + t * 0.5f + (1 / 6.0f);
result[1] = t3 * 0.5f - t2 + 4 / 6.0f;
result[2] = -t3 * 0.5f + t2 * 0.5f + t * 0.5f + 1 / 6.0f;
result[3] = t3 * (1 / 6.0f);
break;
case CURVE_END_1:
result[0] = tinv3 * (1 / 6.0f);
result[1] = -tinv3 * 0.5f + tinv2 * 0.5f + tinv * 0.5f + (1 / 6.0f);
result[2] = tinv3 * (7 / 12.0f) - tinv2 * 1.25f + tinv * 0.25f + (7 / 12.0f);
result[1] = -tinv3 * 0.5f + tinv2 * 0.5f + tinv * 0.5f + 1 / 6.0f;
result[2] = tinv3 * (7 / 12.0f) - tinv2 * 1.25f + tinv * 0.25f + 7 / 12.0f;
result[3] = t3 * 0.25f;
break;
case CURVE_END_2:
@@ -2269,7 +2348,8 @@ void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c) {
* The array should end with three entries with s=0 (infinite keyframe duration).
* That's because the spline has a 3rd degree polynomial, so it looks 3 points ahead.
*/
void anim_spline_init(Vec4s *keyFrames) {
void anim_spline_init(Vec4s *keyFrames)
{
gSplineKeyframe = keyFrames;
gSplineKeyframeFraction = 0;
gSplineState = 1;
@@ -2280,28 +2360,33 @@ void anim_spline_init(Vec4s *keyFrames) {
* anim_spline_init should be called before polling for vectors.
* Returns TRUE when the last point is reached, FALSE otherwise.
*/
s32 anim_spline_poll(Vec3f result) {
s32 anim_spline_poll(Vec3f result)
{
Vec4f weights;
s32 i;
s32 hasEnded = FALSE;
vec3f_copy(result, gVec3fZero);
spline_get_weights(weights, gSplineKeyframeFraction, gSplineState);
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
result[0] += weights[i] * gSplineKeyframe[i][1];
result[1] += weights[i] * gSplineKeyframe[i][2];
result[2] += weights[i] * gSplineKeyframe[i][3];
}
if ((gSplineKeyframeFraction += gSplineKeyframe[0][0] / 1000.0f) >= 1) {
if ((gSplineKeyframeFraction += gSplineKeyframe[0][0] / 1000.0f) >= 1)
{
gSplineKeyframe++;
gSplineKeyframeFraction--;
switch (gSplineState) {
switch (gSplineState)
{
case CURVE_END_2:
hasEnded = TRUE;
break;
case CURVE_MIDDLE:
if (gSplineKeyframe[2][0] == 0) {
if (gSplineKeyframe[2][0] == 0)
{
gSplineState = CURVE_END_1;
}
break;
@@ -2315,7 +2400,6 @@ s32 anim_spline_poll(Vec3f result) {
}
// From object_helpers.c
/**
@@ -2326,9 +2410,11 @@ s32 anim_spline_poll(Vec3f result) {
* | 0 0 0 1 |
* i.e. a matrix representing a linear transformation over 3 space.
*/
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) {
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
{
s32 i;
for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++)
{
dst[i] = m[0][i] * v[0] + m[1][i] * v[1] + m[2][i] * v[2];
}
}
@@ -2341,9 +2427,11 @@ void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) {
* | 0 0 0 1 |
* i.e. a matrix representing a linear transformation over 3 space.
*/
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v) {
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v)
{
s32 i;
for (i = 0; i < 3; i++) {
for (i = 0; i < 3; i++)
{
dst[i] = m[i][0] * v[0] + m[i][1] * v[1] + m[i][2] * v[2];
}
}
+39 -1
View File
@@ -34,49 +34,87 @@ extern f32 gCosineTable[];
#define sqr(x) ((x) * (x))
void *vec3f_copy(Vec3f dest, Vec3f src);
void *vec3f_set(Vec3f dest, f32 x, f32 y, f32 z);
void *vec3f_add(Vec3f dest, Vec3f a);
void *vec3f_sum(Vec3f dest, Vec3f a, Vec3f b);
void *vec3s_copy(Vec3s dest, Vec3s src);
void *vec3s_set(Vec3s dest, s16 x, s16 y, s16 z);
void *vec3s_add(Vec3s dest, Vec3s a);
void *vec3s_sum(Vec3s dest, Vec3s a, Vec3s b);
void *vec3s_sub(Vec3s dest, Vec3s a);
void *vec3s_to_vec3f(Vec3f dest, Vec3s a);
void *vec3f_to_vec3s(Vec3s dest, Vec3f a);
void *find_vector_perpendicular_to_plane(Vec3f dest, Vec3f a, Vec3f b, Vec3f c);
void *vec3f_cross(Vec3f dest, Vec3f a, Vec3f b);
void *vec3f_normalize(Vec3f dest);
void mtxf_copy(Mat4 dest, Mat4 src);
void mtxf_identity(Mat4 mtx);
void mtxf_translate(Mat4 dest, Vec3f b);
void mtxf_lookat(Mat4 mtx, Vec3f from, Vec3f to, s16 roll);
void mtxf_rotate_zxy_and_translate(Mat4 dest, Vec3f translate, Vec3s rotate);
void mtxf_rotate_xyz_and_translate(Mat4 dest, Vec3f b, Vec3s c);
void mtxf_billboard(Mat4 dest, Mat4 mtx, Vec3f position, s16 angle);
void mtxf_align_terrain_normal(Mat4 dest, Vec3f upDir, Vec3f pos, s16 yaw);
void mtxf_align_terrain_triangle(Mat4 mtx, Vec3f pos, s16 yaw, f32 radius);
void mtxf_mul(Mat4 dest, Mat4 a, Mat4 b);
void mtxf_scale_vec3f(Mat4 dest, Mat4 mtx, Vec3f s);
void mtxf_mul_vec3s(Mat4 mtx, Vec3s b);
void mtxf_mul_vec3f(Mat4 mtx, Vec3f b);
void mtxf_to_mtx(Mtx *dest, Mat4 src);
void mtxf_rotate_xy(Mtx *mtx, s16 angle);
void get_pos_from_transform_mtx(Vec3f dest, Mat4 objMtx, Mat4 camMtx);
void vec3f_get_dist_and_angle(Vec3f from, Vec3f to, f32 *dist, s16 *pitch, s16 *yaw);
void vec3f_set_dist_and_angle(Vec3f from, Vec3f to, f32 dist, s16 pitch, s16 yaw);
s32 approach_s32(s32 current, s32 target, s32 inc, s32 dec);
f32 approach_f32(f32 current, f32 target, f32 inc, f32 dec);
s16 atan2s(f32 y, f32 x);
// libsm64: `atan2f()` is not used anywhere and collides with `math.h`'s definition of the function, better to remove it entirely.
// f32 atan2f(f32 a, f32 b);
void spline_get_weights(Vec4f result, f32 t, UNUSED s32 c);
void anim_spline_init(Vec4s *keyFrames);
void anim_spline_init(Vec4s * keyFrames);
s32 anim_spline_poll(Vec3f result);
// From object_helpers.c
void linear_mtxf_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v);
void linear_mtxf_transpose_mul_vec3f(Mat4 m, Vec3f dst, Vec3f v);
+144 -83
View File
@@ -8,24 +8,27 @@
/**
* Iterate through the list of ceilings and find the first ceiling over a given point.
*/
static struct SM64SurfaceCollisionData *find_ceil_from_list( f32 x, f32 y, f32 z, f32 *pheight) {
static struct SM64SurfaceCollisionData *find_ceil_from_list(f32 x, f32 y, f32 z, f32 *pheight)
{
register struct SM64SurfaceCollisionData *surf;
register f32 x1, z1, x2, z2, x3, z3;
struct SM64SurfaceCollisionData *ceil = NULL;
struct SM64SurfaceCollisionData *ceil = nullptr;
ceil = NULL;
ceil = nullptr;
uint32_t groupCount = loaded_surface_iter_group_count();
for( int i = 0; i < groupCount; ++i ) {
uint32_t surfCount = loaded_surface_iter_group_size( i );
for( int j = 0; j < surfCount; ++j ) {
surf = loaded_surface_iter_get_at_index( i, j );
for (int i = 0; i < groupCount; ++i)
{
uint32_t surfCount = loaded_surface_iter_group_size(i);
for (int j = 0; j < surfCount; ++j)
{
surf = loaded_surface_iter_get_at_index(i, j);
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
if( !surf->isValid ) continue;
if (!surf->isValid) continue;
// Do the check normally done in add_surface_to_cell
if( surf->normal.y >= -0.01f ) continue;
if (surf->normal.y >= -0.01f) continue;
x1 = surf->vertex1[0];
z1 = surf->vertex1[2];
@@ -33,17 +36,20 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list( f32 x, f32 y, f32 z
x2 = surf->vertex2[0];
// Checking if point is in bounds of the triangle laterally.
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) > 0) {
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) > 0)
{
continue;
}
// Slight optimization by checking these later.
x3 = surf->vertex3[0];
z3 = surf->vertex3[2];
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) > 0) {
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) > 0)
{
continue;
}
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) > 0) {
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) > 0)
{
continue;
}
@@ -55,7 +61,8 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list( f32 x, f32 y, f32 z
f32 height;
// If a wall, ignore it. Likely a remnant, should never occur.
if (ny == 0.0f) {
if (ny == 0.0f)
{
continue;
}
@@ -66,42 +73,47 @@ static struct SM64SurfaceCollisionData *find_ceil_from_list( f32 x, f32 y, f32 z
//! (Exposed Ceilings) Because any point above a ceiling counts
// as interacting with a ceiling, ceilings far below can cause
// "invisible walls" that are really just exposed ceilings.
if (y - (height - -78.0f) > 0.0f) {
if (y - (height - -78.0f) > 0.0f)
{
continue;
}
if( height < *pheight )
if (height < *pheight)
{
*pheight = height;
ceil = surf;
}
}
}}
}
}
return ceil;
}
/**
* Iterate through the list of floors and find the first floor under a given point.
*/
static struct SM64SurfaceCollisionData *find_floor_from_list( f32 x, f32 y, f32 z, f32 *pheight) {
static struct SM64SurfaceCollisionData *find_floor_from_list(f32 x, f32 y, f32 z, f32 *pheight)
{
register struct SM64SurfaceCollisionData *surf;
register f32 x1, z1, x2, z2, x3, z3;
f32 nx, ny, nz;
f32 oo;
f32 height;
struct SM64SurfaceCollisionData *floor = NULL;
struct SM64SurfaceCollisionData *floor = nullptr;
uint32_t groupCount = loaded_surface_iter_group_count();
for( int i = 0; i < groupCount; ++i ) {
uint32_t surfCount = loaded_surface_iter_group_size( i );
for( int j = 0; j < surfCount; ++j ) {
surf = loaded_surface_iter_get_at_index( i, j );
for (int i = 0; i < groupCount; ++i)
{
uint32_t surfCount = loaded_surface_iter_group_size(i);
for (int j = 0; j < surfCount; ++j)
{
surf = loaded_surface_iter_get_at_index(i, j);
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
if( !surf->isValid ) continue;
if (!surf->isValid) continue;
// Do the check normally done in add_surface_to_cell
if( surf->normal.y <= 0.01f ) continue;
if (surf->normal.y <= 0.01f) continue;
x1 = surf->vertex1[0];
z1 = surf->vertex1[2];
@@ -109,7 +121,8 @@ static struct SM64SurfaceCollisionData *find_floor_from_list( f32 x, f32 y, f32
z2 = surf->vertex2[2];
// Check that the point is within the triangle bounds.
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) < 0) {
if ((z1 - z) * (x2 - x1) - (x1 - x) * (z2 - z1) < 0)
{
continue;
}
@@ -117,10 +130,12 @@ static struct SM64SurfaceCollisionData *find_floor_from_list( f32 x, f32 y, f32
x3 = surf->vertex3[0];
z3 = surf->vertex3[2];
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) < 0) {
if ((z2 - z) * (x3 - x2) - (x2 - x) * (z3 - z2) < 0)
{
continue;
}
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) < 0) {
if ((z3 - z) * (x1 - x3) - (x3 - x) * (z1 - z3) < 0)
{
continue;
}
@@ -130,27 +145,31 @@ static struct SM64SurfaceCollisionData *find_floor_from_list( f32 x, f32 y, f32
oo = surf->originOffset;
// If a wall, ignore it. Likely a remnant, should never occur.
if (ny == 0.0f) {
if (ny == 0.0f)
{
continue;
}
// Find the height of the floor at a given location.
height = -(x * nx + nz * z + oo) / ny;
// Checks for floor interaction with a 78 unit buffer.
if (y - (height + -78.0f) < 0.0f) {
if (y - (height + -78.0f) < 0.0f)
{
continue;
}
if( height > *pheight )
if (height > *pheight)
{
*pheight = height;
floor = surf;
}
}}
}
}
return floor;
}
static s32 find_wall_collisions_from_list( struct SM64WallCollisionData *data) {
static s32 find_wall_collisions_from_list(struct SM64WallCollisionData *data)
{
register struct SM64SurfaceCollisionData *surf;
register f32 offset;
register f32 radius = data->radius;
@@ -163,34 +182,40 @@ static s32 find_wall_collisions_from_list( struct SM64WallCollisionData *data) {
s32 numCols = 0;
// Max collision radius = 200
if (radius > 200.0f) {
if (radius > 200.0f)
{
radius = 200.0f;
}
uint32_t groupCount = loaded_surface_iter_group_count();
for( int i = 0; i < groupCount; ++i ) {
uint32_t surfCount = loaded_surface_iter_group_size( i );
for( int j = 0; j < surfCount; ++j ) {
surf = loaded_surface_iter_get_at_index( i, j );
for (int i = 0; i < groupCount; ++i)
{
uint32_t surfCount = loaded_surface_iter_group_size(i);
for (int j = 0; j < surfCount; ++j)
{
surf = loaded_surface_iter_get_at_index(i, j);
// libsm64: Weed out surfaces whose triangles are actually line segs. TODO do this at surface load time
if( !surf->isValid ) continue;
if (!surf->isValid) continue;
// Do the check normally done in add_surface_to_cell
if( surf->normal.y < -0.01f || surf->normal.y > 0.01f ) continue;
if (surf->normal.y < -0.01f || surf->normal.y > 0.01f) continue;
if( surf->normal.x < -0.707f || surf->normal.x > 0.707f ) {
if (surf->normal.x < -0.707f || surf->normal.x > 0.707f)
{
surf->flags |= SURFACE_FLAG_X_PROJECTION;
}
// Exclude a large number of walls immediately to optimize.
if (y < surf->lowerY || y > surf->upperY) {
if (y < surf->lowerY || y > surf->upperY)
{
continue;
}
offset = surf->normal.x * x + surf->normal.y * y + surf->normal.z * z + surf->originOffset;
if (offset < -radius || offset > radius) {
if (offset < -radius || offset > radius)
{
continue;
}
@@ -200,74 +225,107 @@ static s32 find_wall_collisions_from_list( struct SM64WallCollisionData *data) {
//! (Quantum Tunneling) Due to issues with the vertices walls choose and
// the fact they are floating point, certain floating point positions
// along the seam of two walls may collide with neither wall or both walls.
if (surf->flags & SURFACE_FLAG_X_PROJECTION) {
w1 = -surf->vertex1[2]; w2 = -surf->vertex2[2]; w3 = -surf->vertex3[2];
y1 = surf->vertex1[1]; y2 = surf->vertex2[1]; y3 = surf->vertex3[1];
if (surf->flags & SURFACE_FLAG_X_PROJECTION)
{
w1 = -surf->vertex1[2];
w2 = -surf->vertex2[2];
w3 = -surf->vertex3[2];
y1 = surf->vertex1[1];
y2 = surf->vertex2[1];
y3 = surf->vertex3[1];
if (surf->normal.x > 0.0f) {
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) > 0.0f) {
if (surf->normal.x > 0.0f)
{
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) > 0.0f)
{
continue;
}
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) > 0.0f) {
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) > 0.0f)
{
continue;
}
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) > 0.0f) {
continue;
}
} else {
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) < 0.0f) {
continue;
}
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) < 0.0f) {
continue;
}
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) < 0.0f) {
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) > 0.0f)
{
continue;
}
}
} else {
w1 = surf->vertex1[0]; w2 = surf->vertex2[0]; w3 = surf->vertex3[0];
y1 = surf->vertex1[1]; y2 = surf->vertex2[1]; y3 = surf->vertex3[1];
else
{
if ((y1 - y) * (w2 - w1) - (w1 - -pz) * (y2 - y1) < 0.0f)
{
continue;
}
if ((y2 - y) * (w3 - w2) - (w2 - -pz) * (y3 - y2) < 0.0f)
{
continue;
}
if ((y3 - y) * (w1 - w3) - (w3 - -pz) * (y1 - y3) < 0.0f)
{
continue;
}
}
}
else
{
w1 = surf->vertex1[0];
w2 = surf->vertex2[0];
w3 = surf->vertex3[0];
y1 = surf->vertex1[1];
y2 = surf->vertex2[1];
y3 = surf->vertex3[1];
if (surf->normal.z > 0.0f) {
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) > 0.0f) {
if (surf->normal.z > 0.0f)
{
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) > 0.0f)
{
continue;
}
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) > 0.0f) {
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) > 0.0f)
{
continue;
}
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) > 0.0f) {
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) > 0.0f)
{
continue;
}
} else {
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) < 0.0f) {
}
else
{
if ((y1 - y) * (w2 - w1) - (w1 - px) * (y2 - y1) < 0.0f)
{
continue;
}
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) < 0.0f) {
if ((y2 - y) * (w3 - w2) - (w2 - px) * (y3 - y2) < 0.0f)
{
continue;
}
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) < 0.0f) {
if ((y3 - y) * (w1 - w3) - (w3 - px) * (y1 - y3) < 0.0f)
{
continue;
}
}
}
// Ignore camera only surfaces.
if (surf->type == SURFACE_CAMERA_BOUNDARY) {
if (surf->type == SURFACE_CAMERA_BOUNDARY)
{
continue;
}
// If an object can pass through a vanish cap wall, pass through.
if (surf->type == SURFACE_VANISH_CAP_WALLS) {
if (surf->type == SURFACE_VANISH_CAP_WALLS)
{
// If an object can pass through a vanish cap wall, pass through.
if (gCurrentObject != NULL
&& (gCurrentObject->activeFlags & ACTIVE_FLAG_MOVE_THROUGH_GRATE)) {
if (gCurrentObject != nullptr
&& gCurrentObject->activeFlags & ACTIVE_FLAG_MOVE_THROUGH_GRATE)
{
continue;
}
// If Mario has a vanish cap, pass through the vanish cap wall.
if (gCurrentObject != NULL && gCurrentObject == gMarioObject
&& (gMarioState->flags & MARIO_VANISH_CAP)) {
if (gCurrentObject != nullptr && gCurrentObject == gMarioObject
&& gMarioState->flags & MARIO_VANISH_CAP)
{
continue;
}
}
@@ -280,12 +338,14 @@ static s32 find_wall_collisions_from_list( struct SM64WallCollisionData *data) {
//! (Unreferenced Walls) Since this only returns the first four walls,
// this can lead to wall interaction being missed. Typically unreferenced walls
// come from only using one wall, however.
if (data->numWalls < 4) {
if (data->numWalls < 4)
{
data->walls[data->numWalls++] = surf;
}
numCols++;
}}
}
}
return numCols;
}
@@ -335,7 +395,7 @@ s32 find_wall_collisions(struct SM64WallCollisionData *colData)
f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct SM64SurfaceCollisionData **pceil)
{
f32 height = CELL_HEIGHT_LIMIT;
*pceil = find_ceil_from_list( posX, posY, posZ, &height );
*pceil = find_ceil_from_list(posX, posY, posZ, &height);
return height;
}
@@ -346,9 +406,10 @@ f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct SM64FloorCol
struct SM64SurfaceCollisionData *floor;
f32 floorHeight = find_floor(xPos, yPos, zPos, &floor);
*floorGeo = NULL;
*floorGeo = nullptr;
if (floor != NULL) {
if (floor != nullptr)
{
sFloorGeo.normalX = floor->normal.x;
sFloorGeo.normalY = floor->normal.y;
sFloorGeo.normalZ = floor->normal.z;
@@ -362,14 +423,14 @@ f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct SM64FloorCol
f32 find_floor_height(f32 x, f32 y, f32 z)
{
f32 height = FLOOR_LOWER_LIMIT;
find_floor_from_list( x, y, z, &height );
find_floor_from_list(x, y, z, &height);
return height;
}
f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct SM64SurfaceCollisionData **pfloor)
{
f32 height = FLOOR_LOWER_LIMIT;
*pfloor = find_floor_from_list( xPos, yPos, zPos, &height );
*pfloor = find_floor_from_list(xPos, yPos, zPos, &height);
return height;
}
+7
View File
@@ -13,12 +13,19 @@
#define FLOOR_LOWER_LIMIT -110000.f
s32 f32_find_wall_collision(f32 *xPtr, f32 *yPtr, f32 *zPtr, f32 offsetY, f32 radius);
s32 find_wall_collisions(struct SM64WallCollisionData *colData);
f32 find_ceil(f32 posX, f32 posY, f32 posZ, struct SM64SurfaceCollisionData **pceil);
f32 find_floor_height_and_data(f32 xPos, f32 yPos, f32 zPos, struct SM64FloorCollisionData **floorGeo);
f32 find_floor_height(f32 x, f32 y, f32 z);
f32 find_floor(f32 xPos, f32 yPos, f32 zPos, struct SM64SurfaceCollisionData **pfloor);
f32 find_water_level(f32 x, f32 z);
f32 find_poison_gas_level(f32 x, f32 z);
#endif // SURFACE_COLLISION_H
+113 -57
View File
@@ -9,17 +9,24 @@
struct WarpNode
{
/*00*/ u8 id;
/*01*/ u8 destLevel;
/*02*/ u8 destArea;
/*03*/ u8 destNode;
/*00*/
u8 id;
/*01*/
u8 destLevel;
/*02*/
u8 destArea;
/*03*/
u8 destNode;
};
struct ObjectWarpNode
{
/*0x00*/ struct WarpNode node;
/*0x04*/ struct Object *object;
/*0x08*/ struct ObjectWarpNode *next;
/*0x00*/
struct WarpNode node;
/*0x04*/
struct Object *object;
/*0x08*/
struct ObjectWarpNode *next;
};
// From Surface 0x1B to 0x1E
@@ -28,74 +35,118 @@ struct ObjectWarpNode
struct InstantWarp
{
/*0x00*/ u8 id; // 0 = 0x1B / 1 = 0x1C / 2 = 0x1D / 3 = 0x1E
/*0x01*/ u8 area;
/*0x02*/ Vec3s displacement;
/*0x00*/
u8 id; // 0 = 0x1B / 1 = 0x1C / 2 = 0x1D / 3 = 0x1E
/*0x01*/
u8 area;
/*0x02*/
Vec3s displacement;
};
struct SpawnInfo
{
/*0x00*/ Vec3f startPos;
/*0x06*/ Vec3s startAngle;
/*0x0C*/ s8 areaIndex;
/*0x0D*/ s8 activeAreaIndex;
/*0x10*/ u32 behaviorArg;
/*0x14*/ void *behaviorScript;
/*0x18*/ struct GraphNode *unk18;
/*0x1C*/ struct SpawnInfo *next;
/*0x00*/
Vec3f startPos;
/*0x06*/
Vec3s startAngle;
/*0x0C*/
s8 areaIndex;
/*0x0D*/
s8 activeAreaIndex;
/*0x10*/
u32 behaviorArg;
/*0x14*/
void *behaviorScript;
/*0x18*/
struct GraphNode *unk18;
/*0x1C*/
struct SpawnInfo *next;
};
struct UnusedArea28
{
/*0x00*/ s16 unk00;
/*0x02*/ s16 unk02;
/*0x04*/ s16 unk04;
/*0x06*/ s16 unk06;
/*0x08*/ s16 unk08;
/*0x00*/
s16 unk00;
/*0x02*/
s16 unk02;
/*0x04*/
s16 unk04;
/*0x06*/
s16 unk06;
/*0x08*/
s16 unk08;
};
struct Whirlpool
{
/*0x00*/ Vec3s pos;
/*0x03*/ s16 strength;
/*0x00*/
Vec3s pos;
/*0x03*/
s16 strength;
};
struct Area
{
/*0x00*/ s8 index;
/*0x01*/ s8 flags; // Only has 1 flag: 0x01 = Is this the active area?
// /*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31) ; in libsm64 terrain is defined in the Surface struct
/*0x04*/ struct GraphNodeRoot *unk04; // geometry layout data
/*0x08*/ s16 *terrainData; // collision data (set from level script cmd 0x2E)
/*0x0C*/ s8 *surfaceRooms; // (set from level script cmd 0x2F)
/*0x10*/ s16 *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39)
/*0x14*/ struct ObjectWarpNode *warpNodes;
/*0x18*/ struct WarpNode *paintingWarpNodes;
/*0x1C*/ struct InstantWarp *instantWarps;
/*0x20*/ struct SpawnInfo *objectSpawnInfos;
/*0x24*/ struct Camera *camera;
/*0x28*/ struct UnusedArea28 *unused28; // Filled by level script 0x3A, but is unused.
/*0x2C*/ struct Whirlpool *whirlpools[2];
/*0x34*/ u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30)
/*0x36*/ u16 musicParam;
/*0x38*/ u16 musicParam2;
/*0x00*/
s8 index;
/*0x01*/
s8 flags; // Only has 1 flag: 0x01 = Is this the active area?
// /*0x02*/ u16 terrainType; // default terrain of the level (set from level script cmd 0x31) ; in libsm64 terrain is defined in the Surface struct
/*0x04*/
struct GraphNodeRoot *unk04; // geometry layout data
/*0x08*/
s16 *terrainData; // collision data (set from level script cmd 0x2E)
/*0x0C*/
s8 *surfaceRooms; // (set from level script cmd 0x2F)
/*0x10*/
s16 *macroObjects; // Macro Objects Ptr (set from level script cmd 0x39)
/*0x14*/
struct ObjectWarpNode *warpNodes;
/*0x18*/
struct WarpNode *paintingWarpNodes;
/*0x1C*/
struct InstantWarp *instantWarps;
/*0x20*/
struct SpawnInfo *objectSpawnInfos;
/*0x24*/
struct Camera *camera;
/*0x28*/
struct UnusedArea28 *unused28; // Filled by level script 0x3A, but is unused.
/*0x2C*/
struct Whirlpool *whirlpools[2];
/*0x34*/
u8 dialog[2]; // Level start dialog number (set by level script cmd 0x30)
/*0x36*/
u16 musicParam;
/*0x38*/
u16 musicParam2;
};
// All the transition data to be used in screen_transition.c
struct WarpTransitionData
{
/*0x00*/ u8 red;
/*0x01*/ u8 green;
/*0x02*/ u8 blue;
/*0x00*/
u8 red;
/*0x01*/
u8 green;
/*0x02*/
u8 blue;
/*0x04*/ s16 startTexRadius;
/*0x06*/ s16 endTexRadius;
/*0x08*/ s16 startTexX;
/*0x0A*/ s16 startTexY;
/*0x0C*/ s16 endTexX;
/*0x0E*/ s16 endTexY;
/*0x04*/
s16 startTexRadius;
/*0x06*/
s16 endTexRadius;
/*0x08*/
s16 startTexX;
/*0x0A*/
s16 startTexY;
/*0x0C*/
s16 endTexX;
/*0x0E*/
s16 endTexY;
/*0x10*/ s16 texTimer; // always 0, does seems to affect transition when disabled
/*0x10*/
s16 texTimer; // always 0, does seems to affect transition when disabled
};
#define WARP_TRANSITION_FADE_FROM_COLOR 0x00
@@ -111,11 +162,16 @@ struct WarpTransitionData
struct WarpTransition
{
/*0x00*/ u8 isActive; // Is the transition active. (either TRUE or FALSE)
/*0x01*/ u8 type; // Determines the type of transition to use (circle, star, etc.)
/*0x02*/ u8 time; // Amount of time to complete the transition (in frames)
/*0x03*/ u8 pauseRendering; // Should the game stop rendering. (either TRUE or FALSE)
/*0x04*/ struct WarpTransitionData data;
/*0x00*/
u8 isActive; // Is the transition active. (either TRUE or FALSE)
/*0x01*/
u8 type; // Determines the type of transition to use (circle, star, etc.)
/*0x02*/
u8 time; // Amount of time to complete the transition (in frames)
/*0x03*/
u8 pauseRendering; // Should the game stop rendering. (either TRUE or FALSE)
/*0x04*/
struct WarpTransitionData data;
};
// extern struct GraphNode **gLoadedGraphNodes;
+8 -5
View File
@@ -4,17 +4,20 @@
#include "../shim.h"
// not sure what this is doing here. not in a behavior file.
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx) {
Gfx *geo_move_mario_part_from_parent(s32 run, UNUSED struct GraphNode *node, Mat4 mtx)
{
Mat4 sp20;
struct Object *sp1C;
if (run == TRUE) {
sp1C = (struct Object *) gCurGraphNodeObject;
if (sp1C == gMarioObject && sp1C->prevObj != NULL) {
if (run == TRUE)
{
sp1C = (struct Object *)gCurGraphNodeObject;
if (sp1C == gMarioObject && sp1C->prevObj != nullptr)
{
create_transformation_from_matrices(sp20, mtx, *gCurGraphNodeCamera->matrixPtr);
obj_update_pos_from_parent_transformation(sp20, sp1C->prevObj);
obj_set_gfx_pos_from_pos(sp1C->prevObj);
}
}
return NULL;
return nullptr;
}
+192 -96
View File
@@ -300,17 +300,24 @@ struct PlayerCameraState
/**
* Mario's action on this frame.
*/
/*0x00*/ u32 action;
/*0x04*/ Vec3f pos;
/*0x10*/ Vec3s faceAngle;
/*0x16*/ Vec3s headRotation;
/*0x1C*/ s16 unused;
/*0x00*/
u32 action;
/*0x04*/
Vec3f pos;
/*0x10*/
Vec3s faceAngle;
/*0x16*/
Vec3s headRotation;
/*0x1C*/
s16 unused;
/**
* Set to nonzero when an event, such as entering a door, starting the credits, or throwing bowser,
* has happened on this frame.
*/
/*0x1E*/ s16 cameraEvent;
/*0x20*/ struct Object *usedObj;
/*0x1E*/
s16 cameraEvent;
/*0x20*/
struct Object *usedObj;
};
/**
@@ -319,15 +326,24 @@ struct PlayerCameraState
*/
struct TransitionInfo
{
/*0x00*/ s16 posPitch;
/*0x02*/ s16 posYaw;
/*0x04*/ f32 posDist;
/*0x08*/ s16 focPitch;
/*0x0A*/ s16 focYaw;
/*0x0C*/ f32 focDist;
/*0x10*/ s32 framesLeft;
/*0x14*/ Vec3f marioPos;
/*0x20*/ u8 pad; // for the structs to align, there has to be an extra unused variable here. type is unknown.
/*0x00*/
s16 posPitch;
/*0x02*/
s16 posYaw;
/*0x04*/
f32 posDist;
/*0x08*/
s16 focPitch;
/*0x0A*/
s16 focYaw;
/*0x0C*/
f32 focDist;
/*0x10*/
s32 framesLeft;
/*0x14*/
Vec3f marioPos;
/*0x20*/
u8 pad; // for the structs to align, there has to be an extra unused variable here. type is unknown.
};
/**
@@ -336,9 +352,12 @@ struct TransitionInfo
*/
struct HandheldShakePoint
{
/*0x00*/ s8 index; // only set to -1
/*0x04 (aligned)*/ u32 pad;
/*0x08*/ Vec3s point;
/*0x00*/
s8 index; // only set to -1
/*0x04 (aligned)*/
u32 pad;
/*0x08*/
Vec3s point;
}; // size = 0x10
struct Camera;
@@ -347,7 +366,8 @@ struct Camera;
* A function that is called by CameraTriggers and cutscene shots.
* These are concurrent: multiple CameraEvents can occur on the same frame.
*/
typedef BAD_RETURN(s32) (*CameraEvent)(struct Camera *c);
typedef BAD_RETURN (s32)(*CameraEvent)(struct Camera *c);
/**
* The same type as a CameraEvent, but because these are generally longer, and happen in sequential
* order, they're are called "shots," a term taken from cinematography.
@@ -403,24 +423,32 @@ struct Cutscene
struct CameraFOVStatus
{
/// The current function being used to set the camera's field of view (before any fov shake is applied).
/*0x00*/ u8 fovFunc;
/*0x00*/
u8 fovFunc;
/// The current field of view in degrees
/*0x04*/ f32 fov;
/*0x04*/
f32 fov;
// Fields used by shake_camera_fov()
/// The amount to change the current fov by in the fov shake effect.
/*0x08*/ f32 fovOffset;
/*0x08*/
f32 fovOffset;
/// A bool set in fov_default() but unused otherwise
/*0x0C*/ u32 unusedIsSleeping;
/*0x0C*/
u32 unusedIsSleeping;
/// The range in degrees to shake fov
/*0x10*/ f32 shakeAmplitude;
/*0x10*/
f32 shakeAmplitude;
/// Used to calculate fovOffset, the phase through the shake's period.
/*0x14*/ s16 shakePhase;
/*0x14*/
s16 shakePhase;
/// How much to progress through the shake period
/*0x16*/ s16 shakeSpeed;
/*0x16*/
s16 shakeSpeed;
/// How much to decrease shakeAmplitude each frame.
/*0x18*/ s16 decay;
/*0x18*/
s16 decay;
};
/**
@@ -443,20 +471,33 @@ struct CutsceneSplinePoint
*/
struct PlayerGeometry
{
/*0x00*/ struct SM64SurfaceCollisionData *currFloor;
/*0x04*/ f32 currFloorHeight;
/*0x08*/ s16 currFloorType;
/*0x0C*/ struct SM64SurfaceCollisionData *currCeil;
/*0x10*/ s16 currCeilType;
/*0x14*/ f32 currCeilHeight;
/*0x18*/ struct SM64SurfaceCollisionData *prevFloor;
/*0x1C*/ f32 prevFloorHeight;
/*0x20*/ s16 prevFloorType;
/*0x24*/ struct SM64SurfaceCollisionData *prevCeil;
/*0x28*/ f32 prevCeilHeight;
/*0x2C*/ s16 prevCeilType;
/*0x00*/
struct SM64SurfaceCollisionData *currFloor;
/*0x04*/
f32 currFloorHeight;
/*0x08*/
s16 currFloorType;
/*0x0C*/
struct SM64SurfaceCollisionData *currCeil;
/*0x10*/
s16 currCeilType;
/*0x14*/
f32 currCeilHeight;
/*0x18*/
struct SM64SurfaceCollisionData *prevFloor;
/*0x1C*/
f32 prevFloorHeight;
/*0x20*/
s16 prevFloorType;
/*0x24*/
struct SM64SurfaceCollisionData *prevCeil;
/*0x28*/
f32 prevCeilHeight;
/*0x2C*/
s16 prevCeilType;
/// Unused, but recalculated every frame
/*0x30*/ f32 waterHeight;
/*0x30*/
f32 waterHeight;
};
/**
@@ -504,10 +545,14 @@ struct ParallelTrackingPoint
*/
struct CameraStoredInfo
{
/*0x00*/ Vec3f pos;
/*0x0C*/ Vec3f focus;
/*0x18*/ f32 panDist;
/*0x1C*/ f32 cannonYOffset;
/*0x00*/
Vec3f pos;
/*0x0C*/
Vec3f focus;
/*0x18*/
f32 panDist;
/*0x1C*/
f32 cannonYOffset;
};
/**
@@ -533,8 +578,10 @@ struct CutsceneVariable
*/
struct Camera
{
/*0x00*/ u8 mode; // What type of mode the camera uses (see defines above)
/*0x01*/ u8 defMode;
/*0x00*/
u8 mode; // What type of mode the camera uses (see defines above)
/*0x01*/
u8 defMode;
/**
* Determines what direction Mario moves in when the analog stick is moved.
*
@@ -543,24 +590,36 @@ struct Camera
* be. It's effectively the opposite of the camera's actual yaw. Use
* vec3f_get_dist_and_angle() if you need the camera's yaw.
*/
/*0x02*/ s16 yaw;
/*0x04*/ Vec3f focus;
/*0x10*/ Vec3f pos;
/*0x1C*/ Vec3f unusedVec1;
/*0x02*/
s16 yaw;
/*0x04*/
Vec3f focus;
/*0x10*/
Vec3f pos;
/*0x1C*/
Vec3f unusedVec1;
/// The x coordinate of the "center" of the area. The camera will rotate around this point.
/// For example, this is what makes the camera rotate around the hill in BoB
/*0x28*/ f32 areaCenX;
/*0x28*/
f32 areaCenX;
/// The z coordinate of the "center" of the area. The camera will rotate around this point.
/// For example, this is what makes the camera rotate around the hill in BoB
/*0x2C*/ f32 areaCenZ;
/*0x30*/ u8 cutscene;
/*0x31*/ u8 filler31[0x8];
/*0x3A*/ s16 nextYaw;
/*0x3C*/ u8 filler3C[0x28];
/*0x64*/ u8 doorStatus;
/*0x2C*/
f32 areaCenZ;
/*0x30*/
u8 cutscene;
/*0x31*/
u8 filler31[0x8];
/*0x3A*/
s16 nextYaw;
/*0x3C*/
u8 filler3C[0x28];
/*0x64*/
u8 doorStatus;
/// The y coordinate of the "center" of the area. Unlike areaCenX and areaCenZ, this is only used
/// when paused. See zoom_out_if_paused_and_outside
/*0x68*/ f32 areaCenY;
/*0x68*/
f32 areaCenY;
};
/**
@@ -576,85 +635,122 @@ struct LakituState
/**
* Lakitu's position, which (when CAM_FLAG_SMOOTH_MOVEMENT is set), approaches his goalPos every frame.
*/
/*0x00*/ Vec3f curFocus;
/*0x00*/
Vec3f curFocus;
/**
* Lakitu's focus, which (when CAM_FLAG_SMOOTH_MOVEMENT is set), approaches his goalFocus every frame.
*/
/*0x0C*/ Vec3f curPos;
/*0x0C*/
Vec3f curPos;
/**
* The focus point that lakitu turns towards every frame.
* If CAM_FLAG_SMOOTH_MOVEMENT is unset, this is the same as curFocus.
*/
/*0x18*/ Vec3f goalFocus;
/*0x18*/
Vec3f goalFocus;
/**
* The point that lakitu flies towards every frame.
* If CAM_FLAG_SMOOTH_MOVEMENT is unset, this is the same as curPos.
*/
/*0x24*/ Vec3f goalPos;
/*0x24*/
Vec3f goalPos;
/*0x30*/ u8 filler30[12]; // extra unused Vec3f?
/*0x30*/
u8 filler30[12]; // extra unused Vec3f?
/// Copy of the active camera mode
/*0x3C*/ u8 mode;
/*0x3C*/
u8 mode;
/// Copy of the default camera mode
/*0x3D*/ u8 defMode;
/*0x3D*/
u8 defMode;
/*0x3E*/ u8 filler3E[10];
/*0x3E*/
u8 filler3E[10];
/*0x48*/ f32 focusDistance; // unused
/*0x4C*/ s16 oldPitch; // unused
/*0x4E*/ s16 oldYaw; // unused
/*0x50*/ s16 oldRoll; // unused
/*0x48*/
f32 focusDistance; // unused
/*0x4C*/
s16 oldPitch; // unused
/*0x4E*/
s16 oldYaw; // unused
/*0x50*/
s16 oldRoll; // unused
/// The angular offsets added to lakitu's pitch, yaw, and roll
/*0x52*/ Vec3s shakeMagnitude;
/*0x52*/
Vec3s shakeMagnitude;
// shake pitch, yaw, and roll phase: The progression through the camera shake (a cosine wave).
// shake pitch, yaw, and roll vel: The speed of the camera shake.
// shake pitch, yaw, and roll decay: The shake's deceleration.
/*0x58*/ s16 shakePitchPhase;
/*0x5A*/ s16 shakePitchVel;
/*0x5C*/ s16 shakePitchDecay;
/*0x58*/
s16 shakePitchPhase;
/*0x5A*/
s16 shakePitchVel;
/*0x5C*/
s16 shakePitchDecay;
/*0x60*/ Vec3f unusedVec1;
/*0x6C*/ Vec3s unusedVec2;
/*0x72*/ u8 filler72[8];
/*0x60*/
Vec3f unusedVec1;
/*0x6C*/
Vec3s unusedVec2;
/*0x72*/
u8 filler72[8];
/// Used to rotate the screen when rendering.
/*0x7A*/ s16 roll;
/*0x7A*/
s16 roll;
/// Copy of the camera's yaw.
/*0x7C*/ s16 yaw;
/*0x7C*/
s16 yaw;
/// Copy of the camera's next yaw.
/*0x7E*/ s16 nextYaw;
/*0x7E*/
s16 nextYaw;
/// The actual focus point the game uses to render.
/*0x80*/ Vec3f focus;
/*0x80*/
Vec3f focus;
/// The actual position the game is rendered from.
/*0x8C*/ Vec3f pos;
/*0x8C*/
Vec3f pos;
// Shake variables: See above description
/*0x98*/ s16 shakeRollPhase;
/*0x9A*/ s16 shakeRollVel;
/*0x9C*/ s16 shakeRollDecay;
/*0x9E*/ s16 shakeYawPhase;
/*0xA0*/ s16 shakeYawVel;
/*0xA2*/ s16 shakeYawDecay;
/*0x98*/
s16 shakeRollPhase;
/*0x9A*/
s16 shakeRollVel;
/*0x9C*/
s16 shakeRollDecay;
/*0x9E*/
s16 shakeYawPhase;
/*0xA0*/
s16 shakeYawVel;
/*0xA2*/
s16 shakeYawDecay;
// focH,Vspeed: how fast lakitu turns towards his goalFocus.
/// By default HSpeed is 0.8, so lakitu turns 80% of the horz distance to his goal each frame.
/*0xA4*/ f32 focHSpeed;
/*0xA4*/
f32 focHSpeed;
/// By default VSpeed is 0.3, so lakitu turns 30% of the vert distance to his goal each frame.
/*0xA8*/ f32 focVSpeed;
/*0xA8*/
f32 focVSpeed;
// posH,Vspeed: How fast lakitu flies towards his goalPos.
/// By default they are 0.3, so lakitu will fly 30% of the way towards his goal each frame.
/*0xAC*/ f32 posHSpeed;
/*0xB0*/ f32 posVSpeed;
/*0xAC*/
f32 posHSpeed;
/*0xB0*/
f32 posVSpeed;
/// The roll offset applied during part of the key dance cutscene
/*0xB4*/ s16 keyDanceRoll;
/*0xB4*/
s16 keyDanceRoll;
/// Mario's action from the previous frame. Only used to determine if Mario just finished a dive.
/*0xB8*/ u32 lastFrameAction;
/*0xBC*/ s16 unused;
/*0xB8*/
u32 lastFrameAction;
/*0xBC*/
s16 unused;
};
File diff suppressed because it is too large Load Diff
+14
View File
@@ -99,19 +99,33 @@
s16 mario_obj_angle_to_object(struct MarioState *m, struct Object *o);
void mario_stop_riding_object(struct MarioState *m);
void mario_grab_used_object(struct MarioState *m);
void mario_drop_held_object(struct MarioState *m);
void mario_throw_held_object(struct MarioState *m);
void mario_stop_riding_and_holding(struct MarioState *m);
u32 does_mario_have_normal_cap_on_head(struct MarioState *m);
void mario_blow_off_cap(struct MarioState *m, f32 capSpeed);
u32 mario_lose_cap_to_enemy(u32 arg);
void mario_retrieve_cap(void);
struct Object *mario_get_collided_object(struct MarioState *m, u32 interactType);
u32 mario_check_object_grab(struct MarioState *m);
u32 get_door_save_file_flag(struct Object *door);
void mario_process_interactions(struct MarioState *m);
void mario_handle_special_floors(struct MarioState *m);
#endif // INTERACTION_H
+19 -10
View File
@@ -89,20 +89,29 @@
// extern u8 unused4[2];
// extern s8 sTimerRunning;
struct HudDisplay {
/*0x00*/ s16 lives;
/*0x02*/ s16 coins;
/*0x04*/ s16 stars;
/*0x06*/ s16 wedges;
/*0x08*/ s16 keys;
/*0x0A*/ s16 flags;
/*0x0C*/ u16 timer;
struct HudDisplay
{
/*0x00*/
s16 lives;
/*0x02*/
s16 coins;
/*0x04*/
s16 stars;
/*0x06*/
s16 wedges;
/*0x08*/
s16 keys;
/*0x0A*/
s16 flags;
/*0x0C*/
u16 timer;
};
// extern struct HudDisplay gHudDisplay;
// extern s8 gNeverEnteredCastle;
enum HUDDisplayFlag {
enum HUDDisplayFlag
{
HUD_DISPLAY_FLAG_LIVES = 0x0001,
HUD_DISPLAY_FLAG_COIN_COUNT = 0x0002,
HUD_DISPLAY_FLAG_STAR_COUNT = 0x0004,
@@ -111,10 +120,10 @@ enum HUDDisplayFlag {
HUD_DISPLAY_FLAG_UNKNOWN_0020 = 0x0020,
HUD_DISPLAY_FLAG_TIMER = 0x0040,
HUD_DISPLAY_FLAG_EMPHASIZE_POWER = 0x8000,
HUD_DISPLAY_NONE = 0x0000,
HUD_DISPLAY_DEFAULT = HUD_DISPLAY_FLAG_LIVES | HUD_DISPLAY_FLAG_COIN_COUNT | HUD_DISPLAY_FLAG_STAR_COUNT | HUD_DISPLAY_FLAG_CAMERA_AND_POWER | HUD_DISPLAY_FLAG_KEYS | HUD_DISPLAY_FLAG_UNKNOWN_0020
};
//
//
// u16 level_control_timer(s32 timerOp);
+681 -360
View File
File diff suppressed because it is too large Load Diff
+43
View File
@@ -7,48 +7,91 @@
#include "../include/types.h"
s32 is_anim_at_end(struct MarioState *m);
s32 is_anim_past_end(struct MarioState *m);
s16 set_mario_animation(struct MarioState *m, s32 targetAnimID);
s16 set_mario_anim_with_accel(struct MarioState *m, s32 targetAnimID, s32 accel);
void set_anim_to_frame(struct MarioState *m, s16 animFrame);
s32 is_anim_past_frame(struct MarioState *m, s16 animFrame);
s16 find_mario_anim_flags_and_translation(struct Object *o, s32 yaw, Vec3s translation);
void update_mario_pos_for_anim(struct MarioState *m);
s16 return_mario_anim_y_translation(struct MarioState *m);
void play_sound_if_no_flag(struct MarioState *m, u32 soundBits, u32 flags);
void play_mario_jump_sound(struct MarioState *m);
void adjust_sound_for_speed(struct MarioState *m);
void play_sound_and_spawn_particles(struct MarioState *m, u32 soundBits, u32 waveParticleType);
void play_mario_action_sound(struct MarioState *m, u32 soundBits, u32 waveParticleType);
void play_mario_landing_sound(struct MarioState *m, u32 soundBits);
void play_mario_landing_sound_once(struct MarioState *m, u32 soundBits);
void play_mario_heavy_landing_sound(struct MarioState *m, u32 soundBits);
void play_mario_heavy_landing_sound_once(struct MarioState *m, u32 soundBits);
void play_mario_sound(struct MarioState *m, s32 primarySoundBits, s32 scondarySoundBits);
void mario_set_forward_vel(struct MarioState *m, f32 speed);
s32 mario_get_floor_class(struct MarioState *m);
u32 mario_get_terrain_sound_addend(struct MarioState *m);
struct SM64SurfaceCollisionData *resolve_and_return_wall_collisions(Vec3f pos, f32 offset, f32 radius);
f32 vec3f_find_ceil(Vec3f pos, f32 height, struct SM64SurfaceCollisionData **ceil);
s32 mario_facing_downhill(struct MarioState *m, s32 turnYaw);
u32 mario_floor_is_slippery(struct MarioState *m);
s32 mario_floor_is_slope(struct MarioState *m);
s32 mario_floor_is_steep(struct MarioState *m);
f32 find_floor_height_relative_polar(struct MarioState *m, s16 angleFromMario, f32 distFromMario);
s16 find_floor_slope(struct MarioState *m, s16 yawOffset);
void update_mario_sound_and_camera(struct MarioState *m);
void set_steep_jump_action(struct MarioState *m);
u32 set_mario_action(struct MarioState *, u32 action, u32 actionArg);
s32 set_jump_from_landing(struct MarioState *m);
s32 set_jumping_action(struct MarioState *m, u32 action, u32 actionArg);
s32 drop_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg);
s32 hurt_and_set_mario_action(struct MarioState *m, u32 action, u32 actionArg, s16 hurtCounter);
s32 check_common_action_exits(struct MarioState *m);
s32 check_common_hold_action_exits(struct MarioState *m);
s32 transition_submerged_to_walking(struct MarioState *m);
s32 set_water_plunge_action(struct MarioState *m);
s32 execute_mario_action(UNUSED struct Object *o);
int init_mario(void);
void init_mario_from_save_file(void);
#endif // MARIO_H
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+6
View File
@@ -7,11 +7,17 @@
#include "../include/types.h"
void print_displaying_credits_entry(void);
void bhv_end_peach_loop(void);
void bhv_end_toad_loop(void);
s32 geo_switch_peach_eyes(s32 run, struct GraphNode *node, UNUSED s32 a2);
s32 mario_ready_to_speak(void);
s32 set_mario_npc_dialog(s32 actionArg);
s32 mario_execute_cutscene_action(struct MarioState *m);
#endif // MARIO_ACTIONS_CUTSCENE_H
File diff suppressed because it is too large Load Diff
+1
View File
@@ -6,6 +6,7 @@
#include "../include/types.h"
void play_step_sound(struct MarioState *m, s16 frame1, s16 frame2);
s32 mario_execute_moving_action(struct MarioState *m);
#endif // MARIO_ACTIONS_MOVING
+223 -117
View File
@@ -21,63 +21,79 @@
* Used by act_punching() to determine Mario's forward velocity during each
* animation frame.
*/
s8 sPunchingForwardVelocities[8] = { 0, 1, 1, 2, 3, 5, 7, 10 };
s8 sPunchingForwardVelocities[8] = {0, 1, 1, 2, 3, 5, 7, 10};
void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction) {
void animated_stationary_ground_step(struct MarioState *m, s32 animation, u32 endAction)
{
stationary_ground_step(m);
set_mario_animation(m, animation);
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, endAction, 0);
}
}
s32 mario_update_punch_sequence(struct MarioState *m) {
s32 mario_update_punch_sequence(struct MarioState *m)
{
u32 endAction, crouchEndAction;
s32 animFrame;
if (m->action & ACT_FLAG_MOVING) {
if (m->action & ACT_FLAG_MOVING)
{
endAction = ACT_WALKING, crouchEndAction = ACT_CROUCH_SLIDE;
} else {
}
else
{
endAction = ACT_IDLE, crouchEndAction = ACT_CROUCHING;
}
switch (m->actionArg) {
switch (m->actionArg)
{
case 0:
play_sound(SOUND_MARIO_PUNCH_YAH, m->marioObj->header.gfx.cameraToObject);
// Fall-through:
case 1:
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH);
if (is_anim_past_end(m)) {
if (is_anim_past_end(m))
{
m->actionArg = 2;
} else {
}
else
{
m->actionArg = 1;
}
if (m->marioObj->header.gfx.animInfo.animFrame >= 2) {
if (mario_check_object_grab(m)) {
if (m->marioObj->header.gfx.animInfo.animFrame >= 2)
{
if (mario_check_object_grab(m))
{
return TRUE;
}
m->flags |= MARIO_PUNCHING;
}
if (m->actionArg == 2) {
m->marioBodyState->punchState = (0 << 6) | 4;
if (m->actionArg == 2)
{
m->marioBodyState->punchState = 0 << 6 | 4;
}
break;
case 2:
set_mario_animation(m, MARIO_ANIM_FIRST_PUNCH_FAST);
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) {
if (m->marioObj->header.gfx.animInfo.animFrame <= 0)
{
m->flags |= MARIO_PUNCHING;
}
if (m->input & INPUT_B_PRESSED) {
if (m->input & INPUT_B_PRESSED)
{
m->actionArg = 3;
}
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, endAction, 0);
}
break;
@@ -87,32 +103,40 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
// Fall-through:
case 4:
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH);
if (is_anim_past_end(m)) {
if (is_anim_past_end(m))
{
m->actionArg = 5;
} else {
}
else
{
m->actionArg = 4;
}
if (m->marioObj->header.gfx.animInfo.animFrame > 0) {
if (m->marioObj->header.gfx.animInfo.animFrame > 0)
{
m->flags |= MARIO_PUNCHING;
}
if (m->actionArg == 5) {
m->marioBodyState->punchState = (1 << 6) | 4;
if (m->actionArg == 5)
{
m->marioBodyState->punchState = 1 << 6 | 4;
}
break;
case 5:
set_mario_animation(m, MARIO_ANIM_SECOND_PUNCH_FAST);
if (m->marioObj->header.gfx.animInfo.animFrame <= 0) {
if (m->marioObj->header.gfx.animInfo.animFrame <= 0)
{
m->flags |= MARIO_PUNCHING;
}
if (m->input & INPUT_B_PRESSED) {
if (m->input & INPUT_B_PRESSED)
{
m->actionArg = 6;
}
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, endAction, 0);
}
break;
@@ -120,15 +144,18 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
case 6:
play_mario_action_sound(m, SOUND_MARIO_PUNCH_HOO, 1);
animFrame = set_mario_animation(m, MARIO_ANIM_GROUND_KICK);
if (animFrame == 0) {
m->marioBodyState->punchState = (2 << 6) | 6;
if (animFrame == 0)
{
m->marioBodyState->punchState = 2 << 6 | 6;
}
if (animFrame >= 0 && animFrame < 8) {
if (animFrame >= 0 && animFrame < 8)
{
m->flags |= MARIO_KICKING;
}
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, endAction, 0);
}
break;
@@ -138,11 +165,13 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
set_mario_animation(m, MARIO_ANIM_BREAKDANCE);
animFrame = m->marioObj->header.gfx.animInfo.animFrame;
if (animFrame >= 2 && animFrame < 8) {
if (animFrame >= 2 && animFrame < 8)
{
m->flags |= MARIO_TRIPPING;
}
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, crouchEndAction, 0);
}
break;
@@ -151,26 +180,32 @@ s32 mario_update_punch_sequence(struct MarioState *m) {
return FALSE;
}
s32 act_punching(struct MarioState *m) {
if (m->input & INPUT_UNKNOWN_10) {
s32 act_punching(struct MarioState *m)
{
if (m->input & INPUT_UNKNOWN_10)
{
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
if (m->input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED | INPUT_OFF_FLOOR | INPUT_ABOVE_SLIDE)) {
if (m->input & (INPUT_NONZERO_ANALOG | INPUT_A_PRESSED | INPUT_OFF_FLOOR | INPUT_ABOVE_SLIDE))
{
return check_common_action_exits(m);
}
if (m->actionState == 0 && (m->input & INPUT_A_DOWN)) {
if (m->actionState == 0 && m->input & INPUT_A_DOWN)
{
return set_mario_action(m, ACT_JUMP_KICK, 0);
}
m->actionState = 1;
if (m->actionArg == 0) {
if (m->actionArg == 0)
{
m->actionTimer = 7;
}
mario_set_forward_vel(m, sPunchingForwardVelocities[m->actionTimer]);
if (m->actionTimer > 0) {
if (m->actionTimer > 0)
{
m->actionTimer--;
}
@@ -179,16 +214,20 @@ s32 act_punching(struct MarioState *m) {
return FALSE;
}
s32 act_picking_up(struct MarioState *m) {
if (m->input & INPUT_UNKNOWN_10) {
s32 act_picking_up(struct MarioState *m)
{
if (m->input & INPUT_UNKNOWN_10)
{
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
if (m->input & INPUT_OFF_FLOOR) {
if (m->input & INPUT_OFF_FLOOR)
{
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
}
if (m->actionState == 0 && is_anim_at_end(m)) {
if (m->actionState == 0 && is_anim_at_end(m))
{
//! While the animation is playing, it is possible for the used object
// to unload. This allows you to pick up a vacant or newly loaded object
// slot (cloning via fake object).
@@ -197,17 +236,23 @@ s32 act_picking_up(struct MarioState *m) {
m->actionState = 1;
}
if (m->actionState == 1) {
if (m->heldObj->oInteractionSubtype & INT_SUBTYPE_GRABS_MARIO) {
if (m->actionState == 1)
{
if (m->heldObj->oInteractionSubtype & INT_SUBTYPE_GRABS_MARIO)
{
m->marioBodyState->grabPos = GRAB_POS_HEAVY_OBJ;
set_mario_animation(m, MARIO_ANIM_GRAB_HEAVY_OBJECT);
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, ACT_HOLD_HEAVY_IDLE, 0);
}
} else {
}
else
{
m->marioBodyState->grabPos = GRAB_POS_LIGHT_OBJ;
set_mario_animation(m, MARIO_ANIM_PICK_UP_LIGHT_OBJ);
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, ACT_HOLD_IDLE, 0);
}
}
@@ -217,19 +262,23 @@ s32 act_picking_up(struct MarioState *m) {
return FALSE;
}
s32 act_dive_picking_up(struct MarioState *m) {
if (m->input & INPUT_UNKNOWN_10) {
s32 act_dive_picking_up(struct MarioState *m)
{
if (m->input & INPUT_UNKNOWN_10)
{
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
//! Hands-free holding. Landing on a slope or being pushed off a ledge while
// landing from a dive grab sets Mario's action to a non-holding action
// without dropping the object, causing the hands-free holding glitch.
if (m->input & INPUT_OFF_FLOOR) {
if (m->input & INPUT_OFF_FLOOR)
{
return set_mario_action(m, ACT_FREEFALL, 0);
}
if (m->input & INPUT_ABOVE_SLIDE) {
if (m->input & INPUT_ABOVE_SLIDE)
{
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
}
@@ -237,16 +286,20 @@ s32 act_dive_picking_up(struct MarioState *m) {
return FALSE;
}
s32 act_placing_down(struct MarioState *m) {
if (m->input & INPUT_UNKNOWN_10) {
s32 act_placing_down(struct MarioState *m)
{
if (m->input & INPUT_UNKNOWN_10)
{
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
if (m->input & INPUT_OFF_FLOOR) {
if (m->input & INPUT_OFF_FLOOR)
{
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
}
if (++m->actionTimer == 8) {
if (++m->actionTimer == 8)
{
mario_drop_held_object(m);
}
@@ -254,64 +307,77 @@ s32 act_placing_down(struct MarioState *m) {
return FALSE;
}
s32 act_throwing(struct MarioState *m) {
if (m->heldObj && (m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)) {
s32 act_throwing(struct MarioState *m)
{
if (m->heldObj && m->heldObj->oInteractionSubtype & INT_SUBTYPE_HOLDABLE_NPC)
{
return set_mario_action(m, ACT_PLACING_DOWN, 0);
}
if (m->input & INPUT_UNKNOWN_10) {
if (m->input & INPUT_UNKNOWN_10)
{
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
if (m->input & INPUT_OFF_FLOOR) {
if (m->input & INPUT_OFF_FLOOR)
{
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
}
if (++m->actionTimer == 7) {
if (++m->actionTimer == 7)
{
mario_throw_held_object(m);
play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED);
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
#ifdef VERSION_SH
#ifdef VERSION_SH
queue_rumble_data(3, 50);
#endif
#endif
}
animated_stationary_ground_step(m, MARIO_ANIM_GROUND_THROW, ACT_IDLE);
return FALSE;
}
s32 act_heavy_throw(struct MarioState *m) {
if (m->input & INPUT_UNKNOWN_10) {
s32 act_heavy_throw(struct MarioState *m)
{
if (m->input & INPUT_UNKNOWN_10)
{
return drop_and_set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
if (m->input & INPUT_OFF_FLOOR) {
if (m->input & INPUT_OFF_FLOOR)
{
return drop_and_set_mario_action(m, ACT_FREEFALL, 0);
}
if (++m->actionTimer == 13) {
if (++m->actionTimer == 13)
{
mario_drop_held_object(m);
play_sound_if_no_flag(m, SOUND_MARIO_WAH2, MARIO_MARIO_SOUND_PLAYED);
play_sound_if_no_flag(m, SOUND_ACTION_THROW, MARIO_ACTION_SOUND_PLAYED);
#ifdef VERSION_SH
#ifdef VERSION_SH
queue_rumble_data(3, 50);
#endif
#endif
}
animated_stationary_ground_step(m, MARIO_ANIM_HEAVY_THROW, ACT_IDLE);
return FALSE;
}
s32 act_stomach_slide_stop(struct MarioState *m) {
if (m->input & INPUT_UNKNOWN_10) {
s32 act_stomach_slide_stop(struct MarioState *m)
{
if (m->input & INPUT_UNKNOWN_10)
{
return set_mario_action(m, ACT_SHOCKWAVE_BOUNCE, 0);
}
if (m->input & INPUT_OFF_FLOOR) {
if (m->input & INPUT_OFF_FLOOR)
{
return set_mario_action(m, ACT_FREEFALL, 0);
}
if (m->input & INPUT_ABOVE_SLIDE) {
if (m->input & INPUT_ABOVE_SLIDE)
{
return set_mario_action(m, ACT_BEGIN_SLIDING, 0);
}
@@ -319,20 +385,23 @@ s32 act_stomach_slide_stop(struct MarioState *m) {
return FALSE;
}
s32 act_picking_up_bowser(struct MarioState *m) {
if (m->actionState == 0) {
s32 act_picking_up_bowser(struct MarioState *m)
{
if (m->actionState == 0)
{
m->actionState = 1;
m->angleVel[1] = 0;
m->marioBodyState->grabPos = GRAB_POS_BOWSER;
mario_grab_used_object(m);
#ifdef VERSION_SH
#ifdef VERSION_SH
queue_rumble_data(5, 80);
#endif
#endif
play_sound(SOUND_MARIO_HRMM, m->marioObj->header.gfx.cameraToObject);
}
set_mario_animation(m, MARIO_ANIM_GRAB_BOWSER);
if (is_anim_at_end(m)) {
if (is_anim_at_end(m))
{
set_mario_action(m, ACT_HOLDING_BOWSER, 0);
}
@@ -340,59 +409,78 @@ s32 act_picking_up_bowser(struct MarioState *m) {
return FALSE;
}
s32 act_holding_bowser(struct MarioState *m) {
s32 act_holding_bowser(struct MarioState *m)
{
s16 spin;
if (m->input & INPUT_B_PRESSED) {
#ifndef VERSION_JP
if (m->angleVel[1] <= -0xE00 || m->angleVel[1] >= 0xE00) {
if (m->input & INPUT_B_PRESSED)
{
#ifndef VERSION_JP
if (m->angleVel[1] <= -0xE00 || m->angleVel[1] >= 0xE00)
{
play_sound(SOUND_MARIO_SO_LONGA_BOWSER, m->marioObj->header.gfx.cameraToObject);
} else {
}
else
{
play_sound(SOUND_MARIO_HERE_WE_GO, m->marioObj->header.gfx.cameraToObject);
}
#else
#else
play_sound(SOUND_MARIO_HERE_WE_GO, m->marioObj->header.gfx.cameraToObject);
#endif
#endif
return set_mario_action(m, ACT_RELEASING_BOWSER, 0);
}
if (m->angleVel[1] == 0) {
if (m->actionTimer++ > 120) {
if (m->angleVel[1] == 0)
{
if (m->actionTimer++ > 120)
{
return set_mario_action(m, ACT_RELEASING_BOWSER, 1);
}
set_mario_animation(m, MARIO_ANIM_HOLDING_BOWSER);
} else {
}
else
{
m->actionTimer = 0;
set_mario_animation(m, MARIO_ANIM_SWINGING_BOWSER);
}
if (m->intendedMag > 20.0f) {
if (m->actionArg == 0) {
if (m->intendedMag > 20.0f)
{
if (m->actionArg == 0)
{
m->actionArg = 1;
m->twirlYaw = m->intendedYaw;
} else {
}
else
{
// spin = acceleration
spin = (s16)(m->intendedYaw - m->twirlYaw) / 0x80;
if (spin < -0x80) {
if (spin < -0x80)
{
spin = -0x80;
}
if (spin > 0x80) {
if (spin > 0x80)
{
spin = 0x80;
}
m->twirlYaw = m->intendedYaw;
m->angleVel[1] += spin;
if (m->angleVel[1] > 0x1000) {
if (m->angleVel[1] > 0x1000)
{
m->angleVel[1] = 0x1000;
}
if (m->angleVel[1] < -0x1000) {
if (m->angleVel[1] < -0x1000)
{
m->angleVel[1] = -0x1000;
}
}
} else {
}
else
{
m->actionArg = 0;
m->angleVel[1] = approach_s32(m->angleVel[1], 0, 64, 64);
}
@@ -402,40 +490,50 @@ s32 act_holding_bowser(struct MarioState *m) {
m->faceAngle[1] += m->angleVel[1];
// play sound on overflow
if (m->angleVel[1] <= -0x100 && spin < m->faceAngle[1]) {
#ifdef VERSION_SH
if (m->angleVel[1] <= -0x100 && spin < m->faceAngle[1])
{
#ifdef VERSION_SH
queue_rumble_data(4, 20);
#endif
#endif
play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject);
}
if (m->angleVel[1] >= 0x100 && spin > m->faceAngle[1]) {
#ifdef VERSION_SH
if (m->angleVel[1] >= 0x100 && spin > m->faceAngle[1])
{
#ifdef VERSION_SH
queue_rumble_data(4, 20);
#endif
#endif
play_sound(SOUND_OBJ_BOWSER_SPINNING, m->marioObj->header.gfx.cameraToObject);
}
stationary_ground_step(m);
if (m->angleVel[1] >= 0) {
if (m->angleVel[1] >= 0)
{
m->marioObj->header.gfx.angle[0] = -m->angleVel[1];
} else {
}
else
{
m->marioObj->header.gfx.angle[0] = m->angleVel[1];
}
return FALSE;
}
s32 act_releasing_bowser(struct MarioState *m) {
if (++m->actionTimer == 1) {
if (m->actionArg == 0) {
#ifdef VERSION_SH
s32 act_releasing_bowser(struct MarioState *m)
{
if (++m->actionTimer == 1)
{
if (m->actionArg == 0)
{
#ifdef VERSION_SH
queue_rumble_data(4, 50);
#endif
#endif
mario_throw_held_object(m);
} else {
#ifdef VERSION_SH
}
else
{
#ifdef VERSION_SH
queue_rumble_data(4, 50);
#endif
#endif
mario_drop_held_object(m);
}
}
@@ -445,31 +543,38 @@ s32 act_releasing_bowser(struct MarioState *m) {
return FALSE;
}
s32 check_common_object_cancels(struct MarioState *m) {
s32 check_common_object_cancels(struct MarioState *m)
{
f32 waterSurface = m->waterLevel - 100;
if (m->pos[1] < waterSurface) {
if (m->pos[1] < waterSurface)
{
return set_water_plunge_action(m);
}
if (m->input & INPUT_SQUISHED) {
if (m->input & INPUT_SQUISHED)
{
return drop_and_set_mario_action(m, ACT_SQUISHED, 0);
}
if (m->health < 0x100) {
if (m->health < 0x100)
{
return drop_and_set_mario_action(m, ACT_STANDING_DEATH, 0);
}
return FALSE;
}
s32 mario_execute_object_action(struct MarioState *m) {
s32 mario_execute_object_action(struct MarioState *m)
{
s32 cancel;
if (check_common_object_cancels(m)) {
if (check_common_object_cancels(m))
{
return TRUE;
}
if (mario_update_quicksand(m, 0.5f)) {
if (mario_update_quicksand(m, 0.5f))
{
return TRUE;
}
@@ -488,7 +593,8 @@ s32 mario_execute_object_action(struct MarioState *m) {
}
/* clang-format on */
if (!cancel && (m->input & INPUT_IN_WATER)) {
if (!cancel && m->input & INPUT_IN_WATER)
{
m->particleFlags |= PARTICLE_IDLE_WATER_WAVE;
}
+1
View File
@@ -6,6 +6,7 @@
#include "../include/types.h"
s32 mario_update_punch_sequence(struct MarioState *m);
s32 mario_execute_object_action(struct MarioState *m);
#endif // MARIO_ACTIONS_OBJECT_H
File diff suppressed because it is too large Load Diff
@@ -6,45 +6,85 @@
#include "../include/types.h"
s32 check_common_idle_cancels(struct MarioState *m);
s32 check_common_hold_idle_cancels(struct MarioState *m);
s32 act_idle(struct MarioState *m);
void play_anim_sound(struct MarioState *m, u32 actionState, s32 animFrame, u32 sound);
s32 act_start_sleeping(struct MarioState *m);
s32 act_sleeping(struct MarioState *m);
s32 act_waking_up(struct MarioState *m);
s32 act_shivering(struct MarioState *m);
s32 act_coughing(struct MarioState *m);
s32 act_standing_against_wall(struct MarioState *m);
s32 act_in_quicksand(struct MarioState *m);
s32 act_crouching(struct MarioState *m);
s32 act_panting(struct MarioState *m);
void stopping_step(struct MarioState *m, s32 animID, u32 action);
s32 act_braking_stop(struct MarioState *m);
s32 act_butt_slide_stop(struct MarioState *m);
s32 act_hold_butt_slide_stop(struct MarioState *m);
s32 act_slide_kick_slide_stop(struct MarioState *m);
s32 act_start_crouching(struct MarioState *m);
s32 act_stop_crouching(struct MarioState *m);
s32 act_start_crawling(struct MarioState *m);
s32 act_stop_crawling(struct MarioState *m);
s32 act_shockwave_bounce(struct MarioState *m);
s32 landing_step(struct MarioState *m, s32 arg1, u32 action);
s32 check_common_landing_cancels(struct MarioState *m, u32 action);
s32 act_jump_land_stop(struct MarioState *m);
s32 act_double_jump_land_stop(struct MarioState *m);
s32 act_side_flip_land_stop(struct MarioState *m);
s32 act_freefall_land_stop(struct MarioState *m);
s32 act_triple_jump_land_stop(struct MarioState *m);
s32 act_backflip_land_stop(struct MarioState *m);
s32 act_lava_boost_land(struct MarioState *m);
s32 act_long_jump_land_stop(struct MarioState *m);
s32 act_hold_jump_land_stop(struct MarioState *m);
s32 act_hold_freefall_land_stop(struct MarioState *m);
s32 act_air_throw_land(struct MarioState *m);
s32 act_twirl_land(struct MarioState *m);
s32 act_ground_pound_land(struct MarioState *m);
s32 act_first_person(struct MarioState *m);
s32 check_common_stationary_cancels(struct MarioState *m);
s32 mario_execute_stationary_action(struct MarioState *m);
#endif // MARIO_ACTIONS_STATIONARY
File diff suppressed because it is too large Load Diff
+367 -288
View File
@@ -28,7 +28,7 @@
#include "../include/object_fields.h"
#include "../include/mario_geo_switch_case_ids.h"
static Vec3s gVec3sZero = {0,0,0};
static Vec3s gVec3sZero = {0, 0, 0};
#define TOAD_STAR_1_REQUIREMENT 12
#define TOAD_STAR_2_REQUIREMENT 25
@@ -42,7 +42,8 @@ static Vec3s gVec3sZero = {0,0,0};
#define TOAD_STAR_2_DIALOG_AFTER 91 // DIALOG_155
#define TOAD_STAR_3_DIALOG_AFTER 92 // DIALOG_156
enum ToadMessageStates {
enum ToadMessageStates
{
TOAD_MESSAGE_FADED,
TOAD_MESSAGE_OPAQUE,
TOAD_MESSAGE_OPACIFYING,
@@ -50,7 +51,8 @@ enum ToadMessageStates {
TOAD_MESSAGE_TALKING
};
enum UnlockDoorStarStates {
enum UnlockDoorStarStates
{
UNLOCK_DOOR_STAR_RISING,
UNLOCK_DOOR_STAR_WAITING,
UNLOCK_DOOR_STAR_SPAWNING_PARTICLES,
@@ -61,7 +63,7 @@ enum UnlockDoorStarStates {
* The eye texture on succesive frames of Mario's blink animation.
* He intentionally blinks twice each time.
*/
static s8 gMarioBlinkAnimation[7] = { 1, 2, 1, 0, 1, 2, 1 };
static s8 gMarioBlinkAnimation[7] = {1, 2, 1, 0, 1, 2, 1};
/**
* The scale values per frame for Mario's foot/hand for his attack animation
@@ -89,13 +91,13 @@ static s8 gMarioAttackScaleAnimation[3 * 6] = {
* Geo node script that draws Mario's head on the title screen.
*/
// Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c) {
// Gfx *gfx = NULL;
// Gfx *gfx = nullptr;
// s16 sfx = 0;
// struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
// UNUSED Mat4 *transform = c;
//
// if (callContext == GEO_CONTEXT_RENDER) {
// if (gPlayerController->controllerData != NULL && !gWarpTransition.isActive) {
// if (gPlayerController->controllerData != nullptr && !gWarpTransition.isActive) {
// gd_copy_p1_contpad(gPlayer1Controller->controllerData);
// }
// gfx = (Gfx *) PHYSICAL_TO_VIRTUAL(gdm_gettestdl(asGenerated->parameter));
@@ -106,66 +108,76 @@ static s8 gMarioAttackScaleAnimation[3 * 6] = {
// return gfx;
// }
static void toad_message_faded(void) {
// if (gCurrentObject->oDistanceToMario > 700.0f) {
// gCurrentObject->oToadMessageRecentlyTalked = FALSE;
// }
// if (!gCurrentObject->oToadMessageRecentlyTalked && gCurrentObject->oDistanceToMario < 600.0f) {
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_OPACIFYING;
// }
static void toad_message_faded(void)
{
// if (gCurrentObject->oDistanceToMario > 700.0f) {
// gCurrentObject->oToadMessageRecentlyTalked = FALSE;
// }
// if (!gCurrentObject->oToadMessageRecentlyTalked && gCurrentObject->oDistanceToMario < 600.0f) {
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_OPACIFYING;
// }
}
static void toad_message_opaque(void) {
// if (gCurrentObject->oDistanceToMario > 700.0f) {
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADING;
// } else if (!gCurrentObject->oToadMessageRecentlyTalked) {
// gCurrentObject->oInteractionSubtype = INT_SUBTYPE_NPC;
// if (gCurrentObject->oInteractStatus & INT_STATUS_INTERACTED) {
// gCurrentObject->oInteractStatus = 0;
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_TALKING;
// play_toads_jingle();
// }
// }
static void toad_message_opaque(void)
{
// if (gCurrentObject->oDistanceToMario > 700.0f) {
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADING;
// } else if (!gCurrentObject->oToadMessageRecentlyTalked) {
// gCurrentObject->oInteractionSubtype = INT_SUBTYPE_NPC;
// if (gCurrentObject->oInteractStatus & INT_STATUS_INTERACTED) {
// gCurrentObject->oInteractStatus = 0;
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_TALKING;
// play_toads_jingle();
// }
// }
}
static void toad_message_talking(void) {
// if (cur_obj_update_dialog_with_cutscene(3, 1, CUTSCENE_DIALOG, gCurrentObject->oToadMessageDialogId)
// != 0) {
// gCurrentObject->oToadMessageRecentlyTalked = TRUE;
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADING;
// switch (gCurrentObject->oToadMessageDialogId) {
// case TOAD_STAR_1_DIALOG:
// gCurrentObject->oToadMessageDialogId = TOAD_STAR_1_DIALOG_AFTER;
// bhv_spawn_star_no_level_exit(0);
// break;
// case TOAD_STAR_2_DIALOG:
// gCurrentObject->oToadMessageDialogId = TOAD_STAR_2_DIALOG_AFTER;
// bhv_spawn_star_no_level_exit(1);
// break;
// case TOAD_STAR_3_DIALOG:
// gCurrentObject->oToadMessageDialogId = TOAD_STAR_3_DIALOG_AFTER;
// bhv_spawn_star_no_level_exit(2);
// break;
// }
// }
static void toad_message_talking(void)
{
// if (cur_obj_update_dialog_with_cutscene(3, 1, CUTSCENE_DIALOG, gCurrentObject->oToadMessageDialogId)
// != 0) {
// gCurrentObject->oToadMessageRecentlyTalked = TRUE;
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADING;
// switch (gCurrentObject->oToadMessageDialogId) {
// case TOAD_STAR_1_DIALOG:
// gCurrentObject->oToadMessageDialogId = TOAD_STAR_1_DIALOG_AFTER;
// bhv_spawn_star_no_level_exit(0);
// break;
// case TOAD_STAR_2_DIALOG:
// gCurrentObject->oToadMessageDialogId = TOAD_STAR_2_DIALOG_AFTER;
// bhv_spawn_star_no_level_exit(1);
// break;
// case TOAD_STAR_3_DIALOG:
// gCurrentObject->oToadMessageDialogId = TOAD_STAR_3_DIALOG_AFTER;
// bhv_spawn_star_no_level_exit(2);
// break;
// }
// }
}
static void toad_message_opacifying(void) {
if ((gCurrentObject->oOpacity += 6) == 255) {
static void toad_message_opacifying(void)
{
if ((gCurrentObject->oOpacity += 6) == 255)
{
gCurrentObject->oToadMessageState = TOAD_MESSAGE_OPAQUE;
}
}
static void toad_message_fading(void) {
if ((gCurrentObject->oOpacity -= 6) == 81) {
static void toad_message_fading(void)
{
if ((gCurrentObject->oOpacity -= 6) == 81)
{
gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADED;
}
}
void bhv_toad_message_loop(void) {
if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE) {
void bhv_toad_message_loop(void)
{
if (gCurrentObject->header.gfx.node.flags & GRAPH_RENDER_ACTIVE)
{
gCurrentObject->oInteractionSubtype = 0;
switch (gCurrentObject->oToadMessageState) {
switch (gCurrentObject->oToadMessageState)
{
case TOAD_MESSAGE_FADED:
toad_message_faded();
break;
@@ -185,40 +197,41 @@ void bhv_toad_message_loop(void) {
}
}
void bhv_toad_message_init(void) {
// s32 saveFlags = save_file_get_flags();
// s32 starCount = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1);
// s32 dialogId = (gCurrentObject->oBehParams >> 24) & 0xFF;
// s32 enoughStars = TRUE;
//
// switch (dialogId) {
// case TOAD_STAR_1_DIALOG:
// enoughStars = (starCount >= TOAD_STAR_1_REQUIREMENT);
// if (saveFlags & SAVE_FLAG_COLLECTED_TOAD_STAR_1) {
// dialogId = TOAD_STAR_1_DIALOG_AFTER;
// }
// break;
// case TOAD_STAR_2_DIALOG:
// enoughStars = (starCount >= TOAD_STAR_2_REQUIREMENT);
// if (saveFlags & SAVE_FLAG_COLLECTED_TOAD_STAR_2) {
// dialogId = TOAD_STAR_2_DIALOG_AFTER;
// }
// break;
// case TOAD_STAR_3_DIALOG:
// enoughStars = (starCount >= TOAD_STAR_3_REQUIREMENT);
// if (saveFlags & SAVE_FLAG_COLLECTED_TOAD_STAR_3) {
// dialogId = TOAD_STAR_3_DIALOG_AFTER;
// }
// break;
// }
// if (enoughStars) {
// gCurrentObject->oToadMessageDialogId = dialogId;
// gCurrentObject->oToadMessageRecentlyTalked = FALSE;
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADED;
// gCurrentObject->oOpacity = 81;
// } else {
// obj_mark_for_deletion(gCurrentObject);
// }
void bhv_toad_message_init(void)
{
// s32 saveFlags = save_file_get_flags();
// s32 starCount = save_file_get_total_star_count(gCurrSaveFileNum - 1, COURSE_MIN - 1, COURSE_MAX - 1);
// s32 dialogId = (gCurrentObject->oBehParams >> 24) & 0xFF;
// s32 enoughStars = TRUE;
//
// switch (dialogId) {
// case TOAD_STAR_1_DIALOG:
// enoughStars = (starCount >= TOAD_STAR_1_REQUIREMENT);
// if (saveFlags & SAVE_FLAG_COLLECTED_TOAD_STAR_1) {
// dialogId = TOAD_STAR_1_DIALOG_AFTER;
// }
// break;
// case TOAD_STAR_2_DIALOG:
// enoughStars = (starCount >= TOAD_STAR_2_REQUIREMENT);
// if (saveFlags & SAVE_FLAG_COLLECTED_TOAD_STAR_2) {
// dialogId = TOAD_STAR_2_DIALOG_AFTER;
// }
// break;
// case TOAD_STAR_3_DIALOG:
// enoughStars = (starCount >= TOAD_STAR_3_REQUIREMENT);
// if (saveFlags & SAVE_FLAG_COLLECTED_TOAD_STAR_3) {
// dialogId = TOAD_STAR_3_DIALOG_AFTER;
// }
// break;
// }
// if (enoughStars) {
// gCurrentObject->oToadMessageDialogId = dialogId;
// gCurrentObject->oToadMessageRecentlyTalked = FALSE;
// gCurrentObject->oToadMessageState = TOAD_MESSAGE_FADED;
// gCurrentObject->oOpacity = 81;
// } else {
// obj_mark_for_deletion(gCurrentObject);
// }
}
//static void star_door_unlock_spawn_particles(s16 angleOffset) {
@@ -232,88 +245,94 @@ void bhv_toad_message_init(void) {
// sparkleParticle->oPosY -= gCurrentObject->oUnlockDoorStarTimer * 10.0f;
//}
void bhv_unlock_door_star_init(void) {
// gCurrentObject->oUnlockDoorStarState = UNLOCK_DOOR_STAR_RISING;
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject->oUnlockDoorStarYawVel = 0x1000;
// gCurrentObject->oPosX += 30.0f * sins(gMarioState->faceAngle[1] - 0x4000);
// gCurrentObject->oPosY += 160.0f;
// gCurrentObject->oPosZ += 30.0f * coss(gMarioState->faceAngle[1] - 0x4000);
// gCurrentObject->oMoveAngleYaw = 0x7800;
// obj_scale(gCurrentObject, 0.5f);
void bhv_unlock_door_star_init(void)
{
// gCurrentObject->oUnlockDoorStarState = UNLOCK_DOOR_STAR_RISING;
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject->oUnlockDoorStarYawVel = 0x1000;
// gCurrentObject->oPosX += 30.0f * sins(gMarioState->faceAngle[1] - 0x4000);
// gCurrentObject->oPosY += 160.0f;
// gCurrentObject->oPosZ += 30.0f * coss(gMarioState->faceAngle[1] - 0x4000);
// gCurrentObject->oMoveAngleYaw = 0x7800;
// obj_scale(gCurrentObject, 0.5f);
}
void bhv_unlock_door_star_loop(void) {
// UNUSED u8 unused1[4];
// s16 prevYaw = gCurrentObject->oMoveAngleYaw;
// UNUSED u8 unused2[4];
//
// // Speed up the star every frame
// if (gCurrentObject->oUnlockDoorStarYawVel < 0x2400) {
// gCurrentObject->oUnlockDoorStarYawVel += 0x60;
// }
// switch (gCurrentObject->oUnlockDoorStarState) {
// case UNLOCK_DOOR_STAR_RISING:
// gCurrentObject->oPosY += 3.4f; // Raise the star up in the air
// gCurrentObject->oMoveAngleYaw +=
// gCurrentObject->oUnlockDoorStarYawVel; // Apply yaw velocity
// obj_scale(gCurrentObject, gCurrentObject->oUnlockDoorStarTimer / 50.0f
// + 0.5f); // Scale the star to be bigger
// if (++gCurrentObject->oUnlockDoorStarTimer == 30) {
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_WAITING
// }
// break;
// case UNLOCK_DOOR_STAR_WAITING:
// gCurrentObject->oMoveAngleYaw +=
// gCurrentObject->oUnlockDoorStarYawVel; // Apply yaw velocity
// if (++gCurrentObject->oUnlockDoorStarTimer == 30) {
// play_sound(SOUND_MENU_STAR_SOUND,
// gCurrentObject->header.gfx.cameraToObject); // Play final sound
// cur_obj_hide(); // Hide the object
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject
// ->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_SPAWNING_PARTICLES
// }
// break;
// case UNLOCK_DOOR_STAR_SPAWNING_PARTICLES:
// // Spawn two particles, opposite sides of the star.
// star_door_unlock_spawn_particles(0);
// star_door_unlock_spawn_particles(0x8000);
// if (gCurrentObject->oUnlockDoorStarTimer++ == 20) {
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_DONE
// }
// break;
// case UNLOCK_DOOR_STAR_DONE: // The object stays loaded for an additional 50 frames so that the
// // sound doesn't immediately stop.
// if (gCurrentObject->oUnlockDoorStarTimer++ == 50) {
// obj_mark_for_deletion(gCurrentObject);
// }
// break;
// }
// // Checks if the angle has cycled back to 0.
// // This means that the code will execute when the star completes a full revolution.
// if (prevYaw > (s16) gCurrentObject->oMoveAngleYaw) {
// play_sound(
// SOUND_GENERAL_SHORT_STAR,
// gCurrentObject->header.gfx.cameraToObject); // Play a sound every time the star spins once
// }
void bhv_unlock_door_star_loop(void)
{
// UNUSED u8 unused1[4];
// s16 prevYaw = gCurrentObject->oMoveAngleYaw;
// UNUSED u8 unused2[4];
//
// // Speed up the star every frame
// if (gCurrentObject->oUnlockDoorStarYawVel < 0x2400) {
// gCurrentObject->oUnlockDoorStarYawVel += 0x60;
// }
// switch (gCurrentObject->oUnlockDoorStarState) {
// case UNLOCK_DOOR_STAR_RISING:
// gCurrentObject->oPosY += 3.4f; // Raise the star up in the air
// gCurrentObject->oMoveAngleYaw +=
// gCurrentObject->oUnlockDoorStarYawVel; // Apply yaw velocity
// obj_scale(gCurrentObject, gCurrentObject->oUnlockDoorStarTimer / 50.0f
// + 0.5f); // Scale the star to be bigger
// if (++gCurrentObject->oUnlockDoorStarTimer == 30) {
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_WAITING
// }
// break;
// case UNLOCK_DOOR_STAR_WAITING:
// gCurrentObject->oMoveAngleYaw +=
// gCurrentObject->oUnlockDoorStarYawVel; // Apply yaw velocity
// if (++gCurrentObject->oUnlockDoorStarTimer == 30) {
// play_sound(SOUND_MENU_STAR_SOUND,
// gCurrentObject->header.gfx.cameraToObject); // Play final sound
// cur_obj_hide(); // Hide the object
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject
// ->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_SPAWNING_PARTICLES
// }
// break;
// case UNLOCK_DOOR_STAR_SPAWNING_PARTICLES:
// // Spawn two particles, opposite sides of the star.
// star_door_unlock_spawn_particles(0);
// star_door_unlock_spawn_particles(0x8000);
// if (gCurrentObject->oUnlockDoorStarTimer++ == 20) {
// gCurrentObject->oUnlockDoorStarTimer = 0;
// gCurrentObject->oUnlockDoorStarState++; // Sets state to UNLOCK_DOOR_STAR_DONE
// }
// break;
// case UNLOCK_DOOR_STAR_DONE: // The object stays loaded for an additional 50 frames so that the
// // sound doesn't immediately stop.
// if (gCurrentObject->oUnlockDoorStarTimer++ == 50) {
// obj_mark_for_deletion(gCurrentObject);
// }
// break;
// }
// // Checks if the angle has cycled back to 0.
// // This means that the code will execute when the star completes a full revolution.
// if (prevYaw > (s16) gCurrentObject->oMoveAngleYaw) {
// play_sound(
// SOUND_GENERAL_SHORT_STAR,
// gCurrentObject->header.gfx.cameraToObject); // Play a sound every time the star spins once
// }
}
/**
* Generate a display list that sets the correct blend mode and color for mirror Mario.
*/
static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha)
{
Gfx *gfx;
Gfx *gfxHead = NULL;
Gfx *gfxHead = nullptr;
if (alpha == 255) {
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8);
if (alpha == 255)
{
node->fnNode.node.flags = node->fnNode.node.flags & 0xFF | LAYER_OPAQUE << 8;
gfxHead = alloc_display_list(2 * sizeof(*gfxHead));
gfx = gfxHead;
} else {
node->fnNode.node.flags = (node->fnNode.node.flags & 0xFF) | (LAYER_TRANSPARENT << 8);
}
else
{
node->fnNode.node.flags = node->fnNode.node.flags & 0xFF | LAYER_TRANSPARENT << 8;
gfxHead = alloc_display_list(3 * sizeof(*gfxHead));
gfx = gfxHead;
gDPSetAlphaCompare(gfx++, G_AC_DITHER);
@@ -326,16 +345,18 @@ static Gfx *make_gfx_mario_alpha(struct GraphNodeGenerated *node, s16 alpha) {
/**
* Sets the correct blend mode and color for mirror Mario.
*/
Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
UNUSED u8 unused1[4];
Gfx *gfx = NULL;
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
Gfx *gfx = nullptr;
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
s16 alpha;
UNUSED u8 unused2[4];
if (callContext == GEO_CONTEXT_RENDER) {
alpha = (bodyState->modelState & 0x100) ? (bodyState->modelState & 0xFF) : 255;
if (callContext == GEO_CONTEXT_RENDER)
{
alpha = bodyState->modelState & 0x100 ? bodyState->modelState & 0xFF : 255;
gfx = make_gfx_mario_alpha(asGenerated, alpha);
}
return gfx;
@@ -346,72 +367,87 @@ Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED
* If Mario is standing still, he is always high poly. If he is running,
* his level of detail depends on the distance to the camera.
*/
Gfx *geo_switch_mario_stand_run(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx) {
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
Gfx *geo_switch_mario_stand_run(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx)
{
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
if (callContext == GEO_CONTEXT_RENDER) {
if (callContext == GEO_CONTEXT_RENDER)
{
// assign result. 0 if moving, 1 if stationary.
switchCase->selectedCase = ((bodyState->action & ACT_FLAG_STATIONARY) == 0);
switchCase->selectedCase = (bodyState->action & ACT_FLAG_STATIONARY) == 0;
}
return NULL;
return nullptr;
}
/**
* Geo node script that makes Mario blink
*/
Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
s16 blinkFrame;
if (callContext == GEO_CONTEXT_RENDER) {
if (bodyState->eyeState == 0) {
blinkFrame = ((switchCase->numCases * 32 + gAreaUpdateCounter) >> 1) & 0x1F;
if (blinkFrame < 7) {
if (callContext == GEO_CONTEXT_RENDER)
{
if (bodyState->eyeState == 0)
{
blinkFrame = (switchCase->numCases * 32 + gAreaUpdateCounter) >> 1 & 0x1F;
if (blinkFrame < 7)
{
switchCase->selectedCase = gMarioBlinkAnimation[blinkFrame];
} else {
}
else
{
switchCase->selectedCase = 0;
}
} else {
}
else
{
switchCase->selectedCase = bodyState->eyeState - 1;
}
}
return NULL;
return nullptr;
}
/**
* Makes Mario's upper body tilt depending on the rotation stored in his bodyState
*/
Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
s32 action = bodyState->action;
if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
if (callContext == GEO_CONTEXT_RENDER)
{
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *)node->next;
if (action != ACT_BUTT_SLIDE && action != ACT_HOLD_BUTT_SLIDE && action != ACT_WALKING
&& action != ACT_RIDING_SHELL_GROUND) {
&& action != ACT_RIDING_SHELL_GROUND)
{
vec3s_copy(bodyState->torsoAngle, gVec3sZero);
}
rotNode->rotation[0] = bodyState->torsoAngle[1];
rotNode->rotation[1] = bodyState->torsoAngle[2];
rotNode->rotation[2] = bodyState->torsoAngle[0];
}
return NULL;
return nullptr;
}
/**
* Makes Mario's head rotate with the camera angle when in C-up mode
*/
Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
struct MarioBodyState *bodyState = &gBodyStates[asGenerated->parameter];
// s32 action = bodyState->action;
if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
if (callContext == GEO_CONTEXT_RENDER)
{
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *)node->next;
// struct Camera *camera = gCurGraphNodeCamera->config.camera;
// if (camera->mode == CAMERA_MODE_C_UP) {
@@ -426,32 +462,40 @@ Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat
vec3s_set(rotNode->rotation, 0, 0, 0);
// }
}
return NULL;
return nullptr;
}
/**
* Switch between hand models.
* Possible options are described in the MarioHandGSCId enum.
*/
Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
struct MarioBodyState *bodyState = &gBodyStates[0];
if (callContext == GEO_CONTEXT_RENDER) {
if (bodyState->handState == MARIO_HAND_FISTS) {
if (callContext == GEO_CONTEXT_RENDER)
{
if (bodyState->handState == MARIO_HAND_FISTS)
{
// switch between fists (0) and open (1)
switchCase->selectedCase = ((bodyState->action & ACT_FLAG_SWIMMING_OR_FLYING) != 0);
} else {
if (switchCase->numCases == 0) {
switchCase->selectedCase = (bodyState->action & ACT_FLAG_SWIMMING_OR_FLYING) != 0;
}
else
{
if (switchCase->numCases == 0)
{
switchCase->selectedCase =
(bodyState->handState < 5) ? bodyState->handState : MARIO_HAND_OPEN;
} else {
bodyState->handState < 5 ? bodyState->handState : MARIO_HAND_OPEN;
}
else
{
switchCase->selectedCase =
(bodyState->handState < 2) ? bodyState->handState : MARIO_HAND_FISTS;
bodyState->handState < 2 ? bodyState->handState : MARIO_HAND_FISTS;
}
}
}
return NULL;
return nullptr;
}
/**
@@ -462,15 +506,19 @@ Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4
* ! Since the animation gets updated in GEO_CONTEXT_RENDER, drawing Mario multiple times
* (such as in the mirror room) results in a faster and desynced punch / kick animation.
*/
Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct GraphNodeScale *scaleNode = (struct GraphNodeScale *) node->next;
Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
struct GraphNodeScale *scaleNode = (struct GraphNodeScale *)node->next;
struct MarioBodyState *bodyState = &gBodyStates[0];
if (callContext == GEO_CONTEXT_RENDER) {
if (callContext == GEO_CONTEXT_RENDER)
{
scaleNode->scale = 1.0f;
if (asGenerated->parameter == bodyState->punchState >> 6) {
if (g_state->msMarioAttackAnimCounter != gAreaUpdateCounter && (bodyState->punchState & 0x3F) > 0) {
if (asGenerated->parameter == bodyState->punchState >> 6)
{
if (g_state->msMarioAttackAnimCounter != gAreaUpdateCounter && (bodyState->punchState & 0x3F) > 0)
{
bodyState->punchState -= 1;
g_state->msMarioAttackAnimCounter = gAreaUpdateCounter;
}
@@ -479,94 +527,121 @@ Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED
/ 10.0f;
}
}
return NULL;
return nullptr;
}
/**
* Switch between normal cap, wing cap, vanish cap and metal cap.
*/
Gfx *geo_switch_mario_cap_effect(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
Gfx *geo_switch_mario_cap_effect(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
if (callContext == GEO_CONTEXT_RENDER) {
if (callContext == GEO_CONTEXT_RENDER)
{
// switchCase->selectedCase = bodyState->modelState >> 8;
if (bodyState->modelState >> 8 >= 2){ // temporarily disables metal cap
if (bodyState->modelState >> 8 >= 2)
{ // temporarily disables metal cap
switchCase->selectedCase = 0;
} else {
}
else
{
switchCase->selectedCase = bodyState->modelState >> 8;
}
}
return NULL;
return nullptr;
}
/**
* Determine whether Mario's head is drawn with or without a cap on.
* Also sets the visibility of the wing cap wings on or off.
*/
Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
struct GraphNode *next = node->next;
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *) node;
struct GraphNodeSwitchCase *switchCase = (struct GraphNodeSwitchCase *)node;
struct MarioBodyState *bodyState = &gBodyStates[switchCase->numCases];
if (callContext == GEO_CONTEXT_RENDER) {
if (callContext == GEO_CONTEXT_RENDER)
{
switchCase->selectedCase = bodyState->capState & 1;
while (next != node) {
if (next->type == GRAPH_NODE_TYPE_TRANSLATION_ROTATION) {
if (bodyState->capState & 2) {
while (next != node)
{
if (next->type == GRAPH_NODE_TYPE_TRANSLATION_ROTATION)
{
if (bodyState->capState & 2)
{
next->flags |= GRAPH_RENDER_ACTIVE;
} else {
}
else
{
next->flags &= ~GRAPH_RENDER_ACTIVE;
}
}
next = next->next;
}
}
return NULL;
return nullptr;
}
/**
* Geo node script that makes the wings on Mario's wing cap flap.
* Should be placed before a rotation node.
*/
Gfx *geo_mario_rotate_wing_cap_wings(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
Gfx *geo_mario_rotate_wing_cap_wings(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
s16 rotX;
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *)node;
if (callContext == GEO_CONTEXT_RENDER) {
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *) node->next;
if (callContext == GEO_CONTEXT_RENDER)
{
struct GraphNodeRotation *rotNode = (struct GraphNodeRotation *)node->next;
if (!gBodyStates[asGenerated->parameter >> 1].wingFlutter) {
if (!gBodyStates[asGenerated->parameter >> 1].wingFlutter)
{
rotX = (coss((gAreaUpdateCounter & 0xF) << 12) + 1.0f) * 4096.0f;
} else {
}
else
{
rotX = (coss((gAreaUpdateCounter & 7) << 13) + 1.0f) * 6144.0f;
}
if (!(asGenerated->parameter & 1)) {
if (!(asGenerated->parameter & 1))
{
rotNode->rotation[0] = -rotX;
} else {
}
else
{
rotNode->rotation[0] = rotX;
}
}
return NULL;
return nullptr;
}
/**
* Geo node that updates the held object node and the HOLP.
*/
Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *mtx) {
struct GraphNodeHeldObject *asHeldObj = (struct GraphNodeHeldObject *) b;
Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *mtx)
{
struct GraphNodeHeldObject *asHeldObj = (struct GraphNodeHeldObject *)b;
Mat4 *curTransform = mtx;
struct MarioState *marioState = gMarioState; // &gMarioStates[asHeldObj->playerIndex]; // PATCH
if (callContext == GEO_CONTEXT_RENDER) {
asHeldObj->objNode = NULL;
if (marioState->heldObj != NULL) {
if (callContext == GEO_CONTEXT_RENDER)
{
asHeldObj->objNode = nullptr;
if (marioState->heldObj != nullptr)
{
asHeldObj->objNode = marioState->heldObj;
switch (marioState->marioBodyState->grabPos) {
switch (marioState->marioBodyState->grabPos)
{
case GRAB_POS_LIGHT_OBJ:
if (marioState->action & ACT_FLAG_THROWING) {
if (marioState->action & ACT_FLAG_THROWING)
{
vec3s_set(asHeldObj->translation, 50, 0, 0);
} else {
}
else
{
vec3s_set(asHeldObj->translation, 50, 0, 110);
}
break;
@@ -578,14 +653,16 @@ Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *
break;
}
}
} else if (callContext == GEO_CONTEXT_HELD_OBJ) {
}
else if (callContext == GEO_CONTEXT_HELD_OBJ)
{
// ! The HOLP is set here, which is why it only updates when the held object is drawn.
// This is why it won't update during a pause buffered hitstun or when the camera is very far
// away.
get_pos_from_transform_mtx(marioState->marioBodyState->heldObjLastPosition, *curTransform,
*gCurGraphNodeCamera->matrixPtr);
}
return NULL;
return nullptr;
}
// X position of the mirror
@@ -595,65 +672,67 @@ Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *
* Geo node that creates a clone of Mario's geo node and updates it to becomes
* a mirror image of the player.
*/
Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
// f32 mirroredX;
// struct Object *mario = gMarioState->marioObj; // PATCH gMarioStates[0].marioObj;
Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
// f32 mirroredX;
// struct Object *mario = gMarioState->marioObj; // PATCH gMarioStates[0].marioObj;
// switch (callContext) {
// case GEO_CONTEXT_CREATE:
// init_graph_node_object(NULL, &gMirrorMario, NULL, gVec3fZero, gVec3sZero, gVec3fOne);
// break;
// case GEO_CONTEXT_AREA_LOAD:
// geo_add_child(node, &gMirrorMario.node);
// break;
// case GEO_CONTEXT_AREA_UNLOAD:
// geo_remove_child(&gMirrorMario.node);
// break;
// case GEO_CONTEXT_RENDER:
// if (mario->header.gfx.pos[0] > 1700.0f) {
// // TODO: Is this a geo layout copy or a graph node copy?
// gMirrorMario.sharedChild = mario->header.gfx.sharedChild;
// gMirrorMario.areaIndex = mario->header.gfx.areaIndex;
// vec3s_copy(gMirrorMario.angle, mario->header.gfx.angle);
// vec3f_copy(gMirrorMario.pos, mario->header.gfx.pos);
// vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale);
// switch (callContext) {
// case GEO_CONTEXT_CREATE:
// init_graph_node_object(nullptr, &gMirrorMario, nullptr, gVec3fZero, gVec3sZero, gVec3fOne);
// break;
// case GEO_CONTEXT_AREA_LOAD:
// geo_add_child(node, &gMirrorMario.node);
// break;
// case GEO_CONTEXT_AREA_UNLOAD:
// geo_remove_child(&gMirrorMario.node);
// break;
// case GEO_CONTEXT_RENDER:
// if (mario->header.gfx.pos[0] > 1700.0f) {
// // TODO: Is this a geo layout copy or a graph node copy?
// gMirrorMario.sharedChild = mario->header.gfx.sharedChild;
// gMirrorMario.areaIndex = mario->header.gfx.areaIndex;
// vec3s_copy(gMirrorMario.angle, mario->header.gfx.angle);
// vec3f_copy(gMirrorMario.pos, mario->header.gfx.pos);
// vec3f_copy(gMirrorMario.scale, mario->header.gfx.scale);
// gMirrorMario.animInfo = mario->header.gfx.animInfo;
// mirroredX = MIRROR_X - gMirrorMario.pos[0];
// gMirrorMario.pos[0] = mirroredX + MIRROR_X;
// gMirrorMario.angle[1] = -gMirrorMario.angle[1];
// gMirrorMario.scale[0] *= -1.0f;
// ((struct GraphNode *) &gMirrorMario)->flags |= 1;
// } else {
// ((struct GraphNode *) &gMirrorMario)->flags &= ~1;
// }
// break;
// }
return NULL;
// gMirrorMario.animInfo = mario->header.gfx.animInfo;
// mirroredX = MIRROR_X - gMirrorMario.pos[0];
// gMirrorMario.pos[0] = mirroredX + MIRROR_X;
// gMirrorMario.angle[1] = -gMirrorMario.angle[1];
// gMirrorMario.scale[0] *= -1.0f;
// ((struct GraphNode *) &gMirrorMario)->flags |= 1;
// } else {
// ((struct GraphNode *) &gMirrorMario)->flags &= ~1;
// }
// break;
// }
return nullptr;
}
/**
* Since Mirror Mario has an x scale of -1, the mesh becomes inside out.
* This node corrects that by changing the culling mode accordingly.
*/
Gfx *geo_mirror_mario_backface_culling(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c) {
// struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
// Gfx *gfx = NULL;
Gfx *geo_mirror_mario_backface_culling(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c)
{
// struct GraphNodeGenerated *asGenerated = (struct GraphNodeGenerated *) node;
// Gfx *gfx = nullptr;
// if (callContext == GEO_CONTEXT_RENDER && gCurGraphNodeObject == &gMirrorMario) {
// gfx = alloc_display_list(3 * sizeof(*gfx));
// if (callContext == GEO_CONTEXT_RENDER && gCurGraphNodeObject == &gMirrorMario) {
// gfx = alloc_display_list(3 * sizeof(*gfx));
// if (asGenerated->parameter == 0) {
// gSPClearGeometryMode(&gfx[0], G_CULL_BACK);
// gSPSetGeometryMode(&gfx[1], G_CULL_FRONT);
// gSPEndDisplayList(&gfx[2]);
// } else {
// gSPClearGeometryMode(&gfx[0], G_CULL_FRONT);
// gSPSetGeometryMode(&gfx[1], G_CULL_BACK);
// gSPEndDisplayList(&gfx[2]);
// }
// asGenerated->fnNode.node.flags = (asGenerated->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8);
// }
// return gfx;
return NULL;
// if (asGenerated->parameter == 0) {
// gSPClearGeometryMode(&gfx[0], G_CULL_BACK);
// gSPSetGeometryMode(&gfx[1], G_CULL_FRONT);
// gSPEndDisplayList(&gfx[2]);
// } else {
// gSPClearGeometryMode(&gfx[0], G_CULL_FRONT);
// gSPSetGeometryMode(&gfx[1], G_CULL_BACK);
// gSPEndDisplayList(&gfx[2]);
// }
// asGenerated->fnNode.node.flags = (asGenerated->fnNode.node.flags & 0xFF) | (LAYER_OPAQUE << 8);
// }
// return gfx;
return nullptr;
}
+16
View File
@@ -8,21 +8,37 @@
// Gfx *geo_draw_mario_head_goddard(s32 callContext, struct GraphNode *node, Mat4 *c);
void bhv_toad_message_loop(void);
void bhv_toad_message_init(void);
void bhv_unlock_door_star_init(void);
void bhv_unlock_door_star_loop(void);
Gfx *geo_mirror_mario_set_alpha(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_switch_mario_stand_run(s32 callContext, struct GraphNode *node, UNUSED Mat4 *mtx);
Gfx *geo_switch_mario_eyes(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_tilt_torso(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_head_rotation(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_switch_mario_hand(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_hand_foot_scaler(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_switch_mario_cap_effect(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_switch_mario_cap_on_off(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mario_rotate_wing_cap_wings(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_switch_mario_hand_grab_pos(s32 callContext, struct GraphNode *b, Mat4 *mtx);
Gfx *geo_render_mirror_mario(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
Gfx *geo_mirror_mario_backface_culling(s32 callContext, struct GraphNode *node, UNUSED Mat4 *c);
#endif // MARIO_MISC_H
+245 -122
View File
@@ -8,11 +8,11 @@
#include "interaction.h"
#include "mario_step.h"
static s16 sMovingSandSpeeds[] = { 12, 8, 4, 0 };
static s16 sMovingSandSpeeds[] = {12, 8, 4, 0};
struct SM64SurfaceCollisionData gWaterSurfacePseudoFloor = {
SURFACE_VERY_SLIPPERY, 0, 0, 0, 0, 0, { 0, 0, 0 }, { 0, 0, 0 }, { 0, 0, 0 },
{ 0.0f, 1.0f, 0.0f }, 0.0f, 0, NULL, 0
SURFACE_VERY_SLIPPERY, 0, 0, 0, 0, 0, {0, 0, 0}, {0, 0, 0}, {0, 0, 0},
{0.0f, 1.0f, 0.0f}, 0.0f, 0, nullptr, 0
};
/**
@@ -25,7 +25,8 @@ struct SM64SurfaceCollisionData gWaterSurfacePseudoFloor = {
* known through stub_mario_step_2 and whether Mario was on it,
* and if so return a higher value than 0.
*/
f32 get_additive_y_vel_for_jumps(void) {
f32 get_additive_y_vel_for_jumps(void)
{
return 0.0f;
}
@@ -38,7 +39,8 @@ f32 get_additive_y_vel_for_jumps(void) {
* this could be used for checking if Mario was on the trampoline.
* It could, for example, make him bounce.
*/
void stub_mario_step_1(UNUSED struct MarioState *x) {
void stub_mario_step_1(UNUSED struct MarioState * x)
{
}
/**
@@ -48,10 +50,12 @@ void stub_mario_step_1(UNUSED struct MarioState *x) {
* by the trampoline to make itself known to get_additive_y_vel_for_jumps,
* or to set a variable with its intended additive Y vel.
*/
void stub_mario_step_2(void) {
void stub_mario_step_2(void)
{
}
void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2) {
void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2)
{
f32 rx = obj2->posX - obj1->posX;
f32 rz = obj2->posZ - obj1->posZ;
@@ -70,9 +74,12 @@ void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollision
//! Bully battery
}
BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius) {
if (forwardVel < 0.0f) {
BAD_RETURN (s32) init_bully_collision_data(
struct BullyCollisionData *data, f32 posX, f32 posZ,
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius)
{
if (forwardVel < 0.0f)
{
forwardVel *= -1.0f;
yaw += 0x8000;
}
@@ -85,55 +92,72 @@ BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 p
data->velZ = forwardVel * coss(yaw);
}
void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed) {
if (m->wall != NULL) {
void mario_bonk_reflection(struct MarioState *m, u32 negateSpeed)
{
if (m->wall != nullptr)
{
s16 wallAngle = atan2s(m->wall->normal.z, m->wall->normal.x);
m->faceAngle[1] = wallAngle - (s16)(m->faceAngle[1] - wallAngle);
play_sound((m->flags & MARIO_METAL_CAP) ? SOUND_ACTION_METAL_BONK : SOUND_ACTION_BONK,
play_sound(m->flags & MARIO_METAL_CAP ? SOUND_ACTION_METAL_BONK : SOUND_ACTION_BONK,
m->marioObj->header.gfx.cameraToObject);
} else {
}
else
{
play_sound(SOUND_ACTION_HIT, m->marioObj->header.gfx.cameraToObject);
}
if (negateSpeed) {
if (negateSpeed)
{
mario_set_forward_vel(m, -m->forwardVel);
} else {
}
else
{
m->faceAngle[1] += 0x8000;
}
}
u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed) {
if (m->action & ACT_FLAG_RIDING_SHELL) {
u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed)
{
if (m->action & ACT_FLAG_RIDING_SHELL)
{
m->quicksandDepth = 0.0f;
} else {
if (m->quicksandDepth < 1.1f) {
}
else
{
if (m->quicksandDepth < 1.1f)
{
m->quicksandDepth = 1.1f;
}
switch (m->floor->type) {
switch (m->floor->type)
{
case SURFACE_SHALLOW_QUICKSAND:
if ((m->quicksandDepth += sinkingSpeed) >= 10.0f) {
if ((m->quicksandDepth += sinkingSpeed) >= 10.0f)
{
m->quicksandDepth = 10.0f;
}
break;
case SURFACE_SHALLOW_MOVING_QUICKSAND:
if ((m->quicksandDepth += sinkingSpeed) >= 25.0f) {
if ((m->quicksandDepth += sinkingSpeed) >= 25.0f)
{
m->quicksandDepth = 25.0f;
}
break;
case SURFACE_QUICKSAND:
case SURFACE_MOVING_QUICKSAND:
if ((m->quicksandDepth += sinkingSpeed) >= 60.0f) {
if ((m->quicksandDepth += sinkingSpeed) >= 60.0f)
{
m->quicksandDepth = 60.0f;
}
break;
case SURFACE_DEEP_QUICKSAND:
case SURFACE_DEEP_MOVING_QUICKSAND:
if ((m->quicksandDepth += sinkingSpeed) >= 160.0f) {
if ((m->quicksandDepth += sinkingSpeed) >= 160.0f)
{
update_mario_sound_and_camera(m);
return drop_and_set_mario_action(m, ACT_QUICKSAND_DEATH, 0);
}
@@ -154,13 +178,17 @@ u32 mario_update_quicksand(struct MarioState *m, f32 sinkingSpeed) {
return FALSE;
}
u32 mario_push_off_steep_floor(struct MarioState *m, u32 action, u32 actionArg) {
u32 mario_push_off_steep_floor(struct MarioState *m, u32 action, u32 actionArg)
{
s16 floorDYaw = m->floorAngle - m->faceAngle[1];
if (floorDYaw > -0x4000 && floorDYaw < 0x4000) {
if (floorDYaw > -0x4000 && floorDYaw < 0x4000)
{
m->forwardVel = 16.0f;
m->faceAngle[1] = m->floorAngle;
} else {
}
else
{
m->forwardVel = -16.0f;
m->faceAngle[1] = m->floorAngle + 0x8000;
}
@@ -168,12 +196,14 @@ u32 mario_push_off_steep_floor(struct MarioState *m, u32 action, u32 actionArg)
return set_mario_action(m, action, actionArg);
}
u32 mario_update_moving_sand(struct MarioState *m) {
u32 mario_update_moving_sand(struct MarioState *m)
{
struct SM64SurfaceCollisionData *floor = m->floor;
s32 floorType = floor->type;
if (floorType == SURFACE_DEEP_MOVING_QUICKSAND || floorType == SURFACE_SHALLOW_MOVING_QUICKSAND
|| floorType == SURFACE_MOVING_QUICKSAND || floorType == SURFACE_INSTANT_MOVING_QUICKSAND) {
|| floorType == SURFACE_MOVING_QUICKSAND || floorType == SURFACE_INSTANT_MOVING_QUICKSAND)
{
s16 pushAngle = floor->force << 8;
f32 pushSpeed = sMovingSandSpeeds[floor->force >> 8];
@@ -186,40 +216,47 @@ u32 mario_update_moving_sand(struct MarioState *m) {
return FALSE;
}
u32 mario_update_windy_ground(struct MarioState *m) {
u32 mario_update_windy_ground(struct MarioState *m)
{
struct SM64SurfaceCollisionData *floor = m->floor;
if (floor->type == SURFACE_HORIZONTAL_WIND) {
if (floor->type == SURFACE_HORIZONTAL_WIND)
{
f32 pushSpeed;
s16 pushAngle = floor->force << 8;
if (m->action & ACT_FLAG_MOVING) {
if (m->action & ACT_FLAG_MOVING)
{
s16 pushDYaw = m->faceAngle[1] - pushAngle;
pushSpeed = m->forwardVel > 0.0f ? -m->forwardVel * 0.5f : -8.0f;
if (pushDYaw > -0x4000 && pushDYaw < 0x4000) {
if (pushDYaw > -0x4000 && pushDYaw < 0x4000)
{
pushSpeed *= -1.0f;
}
pushSpeed *= coss(pushDYaw);
} else {
pushSpeed = 3.2f + (gGlobalTimer % 4);
}
else
{
pushSpeed = 3.2f + gGlobalTimer % 4;
}
m->vel[0] += pushSpeed * sins(pushAngle);
m->vel[2] += pushSpeed * coss(pushAngle);
#if VERSION_JP
#if VERSION_JP
play_sound(SOUND_ENV_WIND2, m->marioObj->header.gfx.cameraToObject);
#endif
#endif
return TRUE;
}
return FALSE;
}
void stop_and_set_height_to_floor(struct MarioState *m) {
void stop_and_set_height_to_floor(struct MarioState *m)
{
struct Object *marioObj = m->marioObj;
mario_set_forward_vel(m, 0.0f);
@@ -232,7 +269,8 @@ void stop_and_set_height_to_floor(struct MarioState *m) {
vec3s_set(marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
}
s32 stationary_ground_step(struct MarioState *m) {
s32 stationary_ground_step(struct MarioState *m)
{
u32 takeStep;
struct Object *marioObj = m->marioObj;
u32 stepResult = GROUND_STEP_NONE;
@@ -241,9 +279,12 @@ s32 stationary_ground_step(struct MarioState *m) {
takeStep = mario_update_moving_sand(m);
takeStep |= mario_update_windy_ground(m);
if (takeStep) {
if (takeStep)
{
stepResult = perform_ground_step(m);
} else {
}
else
{
//! This is responsible for several stationary downwarps.
m->pos[1] = m->floorHeight;
@@ -254,8 +295,10 @@ s32 stationary_ground_step(struct MarioState *m) {
return stepResult;
}
static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
UNUSED struct SM64SurfaceCollisionData *lowerWall;
static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos)
{
UNUSED
struct SM64SurfaceCollisionData *lowerWall;
struct SM64SurfaceCollisionData *upperWall;
struct SM64SurfaceCollisionData *ceil;
struct SM64SurfaceCollisionData *floor;
@@ -274,18 +317,22 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
m->wall = upperWall;
if (floor == NULL) {
if (floor == nullptr)
{
return GROUND_STEP_HIT_WALL_STOP_QSTEPS;
}
if ((m->action & ACT_FLAG_RIDING_SHELL) && floorHeight < waterLevel) {
if (m->action & ACT_FLAG_RIDING_SHELL && floorHeight < waterLevel)
{
floorHeight = waterLevel;
floor = &gWaterSurfacePseudoFloor;
floor->originOffset = floorHeight; //! Wrong origin offset (no effect)
}
if (nextPos[1] > floorHeight + 100.0f) {
if (nextPos[1] + 160.0f >= ceilHeight) {
if (nextPos[1] > floorHeight + 100.0f)
{
if (nextPos[1] + 160.0f >= ceilHeight)
{
return GROUND_STEP_HIT_WALL_STOP_QSTEPS;
}
@@ -295,7 +342,8 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
return GROUND_STEP_LEFT_GROUND;
}
if (floorHeight + 160.0f >= ceilHeight) {
if (floorHeight + 160.0f >= ceilHeight)
{
return GROUND_STEP_HIT_WALL_STOP_QSTEPS;
}
@@ -303,13 +351,16 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
m->floor = floor;
m->floorHeight = floorHeight;
if (upperWall != NULL) {
if (upperWall != nullptr)
{
s16 wallDYaw = atan2s(upperWall->normal.z, upperWall->normal.x) - m->faceAngle[1];
if (wallDYaw >= 0x2AAA && wallDYaw <= 0x5555) {
if (wallDYaw >= 0x2AAA && wallDYaw <= 0x5555)
{
return GROUND_STEP_NONE;
}
if (wallDYaw <= -0x2AAA && wallDYaw >= -0x5555) {
if (wallDYaw <= -0x2AAA && wallDYaw >= -0x5555)
{
return GROUND_STEP_NONE;
}
@@ -319,18 +370,21 @@ static s32 perform_ground_quarter_step(struct MarioState *m, Vec3f nextPos) {
return GROUND_STEP_NONE;
}
s32 perform_ground_step(struct MarioState *m) {
s32 perform_ground_step(struct MarioState *m)
{
s32 i;
u32 stepResult;
Vec3f intendedPos;
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
intendedPos[0] = m->pos[0] + m->floor->normal.y * (m->vel[0] / 4.0f);
intendedPos[2] = m->pos[2] + m->floor->normal.y * (m->vel[2] / 4.0f);
intendedPos[1] = m->pos[1];
stepResult = perform_ground_quarter_step(m, intendedPos);
if (stepResult == GROUND_STEP_LEFT_GROUND || stepResult == GROUND_STEP_HIT_WALL_STOP_QSTEPS) {
if (stepResult == GROUND_STEP_LEFT_GROUND || stepResult == GROUND_STEP_HIT_WALL_STOP_QSTEPS)
{
break;
}
}
@@ -339,19 +393,22 @@ s32 perform_ground_step(struct MarioState *m) {
vec3f_copy(m->marioObj->header.gfx.pos, m->pos);
vec3s_set(m->marioObj->header.gfx.angle, 0, m->faceAngle[1], 0);
if (stepResult == GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS) {
if (stepResult == GROUND_STEP_HIT_WALL_CONTINUE_QSTEPS)
{
stepResult = GROUND_STEP_HIT_WALL;
}
return stepResult;
}
u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall, Vec3f intendedPos, Vec3f nextPos) {
u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall, Vec3f intendedPos, Vec3f nextPos)
{
struct SM64SurfaceCollisionData *ledgeFloor;
Vec3f ledgePos;
f32 displacementX;
f32 displacementZ;
if (m->vel[1] > 0) {
if (m->vel[1] > 0)
{
return FALSE;
}
@@ -360,7 +417,8 @@ u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall
// Only ledge grab if the wall displaced Mario in the opposite direction of
// his velocity.
if (displacementX * m->vel[0] + displacementZ * m->vel[2] > 0.0f) {
if (displacementX * m->vel[0] + displacementZ * m->vel[2] > 0.0f)
{
return FALSE;
}
@@ -370,7 +428,8 @@ u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall
ledgePos[2] = nextPos[2] - wall->normal.z * 60.0f;
ledgePos[1] = find_floor(ledgePos[0], nextPos[1] + 160.0f, ledgePos[2], &ledgeFloor);
if (ledgePos[1] - nextPos[1] <= 100.0f) {
if (ledgePos[1] - nextPos[1] <= 100.0f)
{
return FALSE;
}
@@ -385,7 +444,8 @@ u32 check_ledge_grab(struct MarioState *m, struct SM64SurfaceCollisionData *wall
return TRUE;
}
s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepArg) {
s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepArg)
{
s16 wallDYaw;
Vec3f nextPos;
struct SM64SurfaceCollisionData *upperWall;
@@ -407,13 +467,15 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
//waterLevel = find_water_level(nextPos[0], nextPos[2]);
waterLevel = m->waterLevel;
m->wall = NULL;
m->wall = nullptr;
//! The water pseudo floor is not referenced when your intended qstep is
// out of bounds, so it won't detect you as landing.
if (floor == NULL) {
if (nextPos[1] <= m->floorHeight) {
if (floor == nullptr)
{
if (nextPos[1] <= m->floorHeight)
{
m->pos[1] = m->floorHeight;
return AIR_STEP_LANDED;
}
@@ -422,15 +484,18 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
return AIR_STEP_HIT_WALL;
}
if ((m->action & ACT_FLAG_RIDING_SHELL) && floorHeight < waterLevel) {
if (m->action & ACT_FLAG_RIDING_SHELL && floorHeight < waterLevel)
{
floorHeight = waterLevel;
floor = &gWaterSurfacePseudoFloor;
floor->originOffset = floorHeight; //! Incorrect origin offset (no effect)
}
//! This check uses f32, but findFloor uses short (overflow jumps)
if (nextPos[1] <= floorHeight) {
if (ceilHeight - floorHeight > 160.0f) {
if (nextPos[1] <= floorHeight)
{
if (ceilHeight - floorHeight > 160.0f)
{
m->pos[0] = nextPos[0];
m->pos[2] = nextPos[2];
m->floor = floor;
@@ -444,13 +509,16 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
return AIR_STEP_LANDED;
}
if (nextPos[1] + 160.0f > ceilHeight) {
if (m->vel[1] >= 0.0f) {
if (nextPos[1] + 160.0f > ceilHeight)
{
if (m->vel[1] >= 0.0f)
{
m->vel[1] = 0.0f;
//! Uses referenced ceiling instead of ceil (ceiling hang upwarp)
if ((stepArg & AIR_STEP_CHECK_HANG) && m->ceil != NULL
&& m->ceil->type == SURFACE_HANGABLE) {
if (stepArg & AIR_STEP_CHECK_HANG && m->ceil != nullptr
&& m->ceil->type == SURFACE_HANGABLE)
{
return AIR_STEP_GRABBED_CEILING;
}
@@ -458,7 +526,8 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
}
//! Potential subframe downwarp->upwarp?
if (nextPos[1] <= m->floorHeight) {
if (nextPos[1] <= m->floorHeight)
{
m->pos[1] = m->floorHeight;
return AIR_STEP_LANDED;
}
@@ -469,8 +538,10 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
//! When the wall is not completely vertical or there is a slight wall
// misalignment, you can activate these conditions in unexpected situations
if ((stepArg & AIR_STEP_CHECK_LEDGE_GRAB) && upperWall == NULL && lowerWall != NULL) {
if (check_ledge_grab(m, lowerWall, intendedPos, nextPos)) {
if (stepArg & AIR_STEP_CHECK_LEDGE_GRAB && upperWall == nullptr && lowerWall != nullptr)
{
if (check_ledge_grab(m, lowerWall, intendedPos, nextPos))
{
return AIR_STEP_GRABBED_LEDGE;
}
@@ -484,15 +555,18 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
m->floor = floor;
m->floorHeight = floorHeight;
if (upperWall != NULL || lowerWall != NULL) {
m->wall = upperWall != NULL ? upperWall : lowerWall;
if (upperWall != nullptr || lowerWall != nullptr)
{
m->wall = upperWall != nullptr ? upperWall : lowerWall;
wallDYaw = atan2s(m->wall->normal.z, m->wall->normal.x) - m->faceAngle[1];
if (m->wall->type == SURFACE_BURNING) {
if (m->wall->type == SURFACE_BURNING)
{
return AIR_STEP_HIT_LAVA_WALL;
}
if (wallDYaw < -0x6000 || wallDYaw > 0x6000) {
if (wallDYaw < -0x6000 || wallDYaw > 0x6000)
{
m->flags |= MARIO_UNKNOWN_30;
return AIR_STEP_HIT_WALL;
}
@@ -501,122 +575,165 @@ s32 perform_air_quarter_step(struct MarioState *m, Vec3f intendedPos, u32 stepAr
return AIR_STEP_NONE;
}
void apply_twirl_gravity(struct MarioState *m) {
void apply_twirl_gravity(struct MarioState *m)
{
f32 terminalVelocity;
f32 heaviness = 1.0f;
if (m->angleVel[1] > 1024) {
if (m->angleVel[1] > 1024)
{
heaviness = 1024.0f / m->angleVel[1];
}
terminalVelocity = -75.0f * heaviness;
m->vel[1] -= 4.0f * heaviness;
if (m->vel[1] < terminalVelocity) {
if (m->vel[1] < terminalVelocity)
{
m->vel[1] = terminalVelocity;
}
}
u32 should_strengthen_gravity_for_jump_ascent(struct MarioState *m) {
if (!(m->flags & MARIO_UNKNOWN_08)) {
u32 should_strengthen_gravity_for_jump_ascent(struct MarioState *m)
{
if (!(m->flags & MARIO_UNKNOWN_08))
{
return FALSE;
}
if (m->action & (ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE)) {
if (m->action & (ACT_FLAG_INTANGIBLE | ACT_FLAG_INVULNERABLE))
{
return FALSE;
}
if (!(m->input & INPUT_A_DOWN) && m->vel[1] > 20.0f) {
if (!(m->input & INPUT_A_DOWN) && m->vel[1] > 20.0f)
{
return (m->action & ACT_FLAG_CONTROL_JUMP_HEIGHT) != 0;
}
return FALSE;
}
void apply_gravity(struct MarioState *m) {
if (m->action == ACT_TWIRLING && m->vel[1] < 0.0f) {
void apply_gravity(struct MarioState *m)
{
if (m->action == ACT_TWIRLING && m->vel[1] < 0.0f)
{
apply_twirl_gravity(m);
} else if (m->action == ACT_SHOT_FROM_CANNON) {
}
else if (m->action == ACT_SHOT_FROM_CANNON)
{
m->vel[1] -= 1.0f;
if (m->vel[1] < -75.0f) {
if (m->vel[1] < -75.0f)
{
m->vel[1] = -75.0f;
}
} else if (m->action == ACT_LONG_JUMP || m->action == ACT_SLIDE_KICK
|| m->action == ACT_BBH_ENTER_SPIN) {
}
else if (m->action == ACT_LONG_JUMP || m->action == ACT_SLIDE_KICK
|| m->action == ACT_BBH_ENTER_SPIN)
{
m->vel[1] -= 2.0f;
if (m->vel[1] < -75.0f) {
if (m->vel[1] < -75.0f)
{
m->vel[1] = -75.0f;
}
} else if (m->action == ACT_LAVA_BOOST || m->action == ACT_FALL_AFTER_STAR_GRAB) {
}
else if (m->action == ACT_LAVA_BOOST || m->action == ACT_FALL_AFTER_STAR_GRAB)
{
m->vel[1] -= 3.2f;
if (m->vel[1] < -65.0f) {
if (m->vel[1] < -65.0f)
{
m->vel[1] = -65.0f;
}
} else if (m->action == ACT_GETTING_BLOWN) {
}
else if (m->action == ACT_GETTING_BLOWN)
{
m->vel[1] -= m->unkC4;
if (m->vel[1] < -75.0f) {
if (m->vel[1] < -75.0f)
{
m->vel[1] = -75.0f;
}
} else if (should_strengthen_gravity_for_jump_ascent(m)) {
}
else if (should_strengthen_gravity_for_jump_ascent(m))
{
m->vel[1] /= 4.0f;
} else if (m->action & ACT_FLAG_METAL_WATER) {
}
else if (m->action & ACT_FLAG_METAL_WATER)
{
m->vel[1] -= 1.6f;
if (m->vel[1] < -16.0f) {
if (m->vel[1] < -16.0f)
{
m->vel[1] = -16.0f;
}
} else if ((m->flags & MARIO_WING_CAP) && m->vel[1] < 0.0f && (m->input & INPUT_A_DOWN)) {
}
else if (m->flags & MARIO_WING_CAP && m->vel[1] < 0.0f && m->input & INPUT_A_DOWN)
{
m->marioBodyState->wingFlutter = TRUE;
m->vel[1] -= 2.0f;
if (m->vel[1] < -37.5f) {
if ((m->vel[1] += 4.0f) > -37.5f) {
if (m->vel[1] < -37.5f)
{
if ((m->vel[1] += 4.0f) > -37.5f)
{
m->vel[1] = -37.5f;
}
}
} else {
}
else
{
m->vel[1] -= 4.0f;
if (m->vel[1] < -75.0f) {
if (m->vel[1] < -75.0f)
{
m->vel[1] = -75.0f;
}
}
}
void apply_vertical_wind(struct MarioState *m) {
void apply_vertical_wind(struct MarioState *m)
{
f32 maxVelY;
f32 offsetY;
if (m->action != ACT_GROUND_POUND) {
if (m->action != ACT_GROUND_POUND)
{
offsetY = m->pos[1] - -1500.0f;
if (m->floor->type == SURFACE_VERTICAL_WIND && -3000.0f < offsetY && offsetY < 2000.0f) {
if (offsetY >= 0.0f) {
if (m->floor->type == SURFACE_VERTICAL_WIND && -3000.0f < offsetY && offsetY < 2000.0f)
{
if (offsetY >= 0.0f)
{
maxVelY = 10000.0f / (offsetY + 200.0f);
} else {
}
else
{
maxVelY = 50.0f;
}
if (m->vel[1] < maxVelY) {
if ((m->vel[1] += maxVelY / 8.0f) > maxVelY) {
if (m->vel[1] < maxVelY)
{
if ((m->vel[1] += maxVelY / 8.0f) > maxVelY)
{
m->vel[1] = maxVelY;
}
}
#ifdef VERSION_JP
#ifdef VERSION_JP
play_sound(SOUND_ENV_WIND2, m->marioObj->header.gfx.cameraToObject);
#endif
#endif
}
}
}
s32 perform_air_step(struct MarioState *m, u32 stepArg) {
s32 perform_air_step(struct MarioState *m, u32 stepArg)
{
Vec3f intendedPos;
s32 i;
s32 quarterStepResult;
s32 stepResult = AIR_STEP_NONE;
m->wall = NULL;
m->wall = nullptr;
for (i = 0; i < 4; i++) {
for (i = 0; i < 4; i++)
{
intendedPos[0] = m->pos[0] + m->vel[0] / 4.0f;
intendedPos[1] = m->pos[1] + m->vel[1] / 4.0f;
intendedPos[2] = m->pos[2] + m->vel[2] / 4.0f;
@@ -627,24 +744,28 @@ s32 perform_air_step(struct MarioState *m, u32 stepArg) {
// getting 0s until your last qf. Graze a wall on your last qf, and it will
// return the stored 2 with a sharply angled reference wall. (some gwks)
if (quarterStepResult != AIR_STEP_NONE) {
if (quarterStepResult != AIR_STEP_NONE)
{
stepResult = quarterStepResult;
}
if (quarterStepResult == AIR_STEP_LANDED || quarterStepResult == AIR_STEP_GRABBED_LEDGE
|| quarterStepResult == AIR_STEP_GRABBED_CEILING
|| quarterStepResult == AIR_STEP_HIT_LAVA_WALL) {
|| quarterStepResult == AIR_STEP_HIT_LAVA_WALL)
{
break;
}
}
if (m->vel[1] >= 0.0f) {
if (m->vel[1] >= 0.0f)
{
m->peakHeight = m->pos[1];
}
m->terrainSoundAddend = mario_get_terrain_sound_addend(m);
if (m->action != ACT_FLYING) {
if (m->action != ACT_FLYING)
{
apply_gravity(m);
}
apply_vertical_wind(m);
@@ -657,13 +778,15 @@ s32 perform_air_step(struct MarioState *m, u32 stepArg) {
// They had these functions the whole time and never used them? Lol
void set_vel_from_pitch_and_yaw(struct MarioState *m) {
void set_vel_from_pitch_and_yaw(struct MarioState *m)
{
m->vel[0] = m->forwardVel * coss(m->faceAngle[0]) * sins(m->faceAngle[1]);
m->vel[1] = m->forwardVel * sins(m->faceAngle[0]);
m->vel[2] = m->forwardVel * coss(m->faceAngle[0]) * coss(m->faceAngle[1]);
}
void set_vel_from_yaw(struct MarioState *m) {
void set_vel_from_yaw(struct MarioState *m)
{
m->vel[0] = m->slideVelX = m->forwardVel * sins(m->faceAngle[1]);
m->vel[1] = 0.0f;
m->vel[2] = m->slideVelZ = m->forwardVel * coss(m->faceAngle[1]);
+28 -8
View File
@@ -5,32 +5,52 @@
#include "../include/types.h"
struct BullyCollisionData {
/*0x00*/ f32 conversionRatio;
/*0x04*/ f32 radius;
/*0x08*/ f32 posX;
/*0x0C*/ f32 posZ;
/*0x10*/ f32 velX;
/*0x14*/ f32 velZ;
struct BullyCollisionData
{
/*0x00*/
f32 conversionRatio;
/*0x04*/
f32 radius;
/*0x08*/
f32 posX;
/*0x0C*/
f32 posZ;
/*0x10*/
f32 velX;
/*0x14*/
f32 velZ;
};
extern struct SM64SurfaceCollisionData gWaterSurfacePseudoFloor;
f32 get_additive_y_vel_for_jumps(void);
void stub_mario_step_1(struct MarioState *);
void stub_mario_step_2(void);
void mario_bonk_reflection(struct MarioState *, u32);
void transfer_bully_speed(struct BullyCollisionData *obj1, struct BullyCollisionData *obj2);
BAD_RETURN(s32) init_bully_collision_data(struct BullyCollisionData *data, f32 posX, f32 posZ,
BAD_RETURN (s32) init_bully_collision_data(
struct BullyCollisionData *data, f32 posX, f32 posZ,
f32 forwardVel, s16 yaw, f32 conversionRatio, f32 radius);
u32 mario_update_quicksand(struct MarioState *, f32);
u32 mario_push_off_steep_floor(struct MarioState *, u32, u32);
u32 mario_update_moving_sand(struct MarioState *);
u32 mario_update_windy_ground(struct MarioState *);
void stop_and_set_height_to_floor(struct MarioState *);
s32 stationary_ground_step(struct MarioState *);
s32 perform_ground_step(struct MarioState *);
s32 perform_air_step(struct MarioState *, u32);
#endif // MARIO_STEP_H
+62 -45
View File
@@ -8,18 +8,20 @@
#include "../engine/math_util.h"
#include "../include/object_fields.h"
static Vec3f gVec3fZero = { 0.0f, 0.0f, 0.0f };
static Vec3s gVec3sZero = { 0, 0, 0 };
static Vec3f gVec3fZero = {0.0f, 0.0f, 0.0f};
static Vec3s gVec3sZero = {0, 0, 0};
static struct Object *try_allocate_object(void) {
static struct Object *try_allocate_object(void)
{
struct ObjectNode *nextObj;
nextObj = (struct ObjectNode *) malloc(sizeof(struct Object));
nextObj->prev = NULL;
nextObj->next = NULL;
return (struct Object *) nextObj;
nextObj = (struct ObjectNode *)malloc(sizeof(struct Object));
nextObj->prev = nullptr;
nextObj->next = nullptr;
return (struct Object *)nextObj;
}
static struct Object *allocate_object(void) {
static struct Object *allocate_object(void)
{
s32 i;
struct Object *obj = try_allocate_object();
@@ -27,17 +29,18 @@ static struct Object *allocate_object(void) {
obj->activeFlags = ACTIVE_FLAG_ACTIVE | ACTIVE_FLAG_UNK8;
obj->parentObj = obj;
obj->prevObj = NULL;
obj->prevObj = nullptr;
obj->collidedObjInteractTypes = 0;
obj->numCollidedObjs = 0;
for (i = 0; i < 0x50; i++) {
#ifdef _WIN32
for (i = 0; i < 0x50; i++)
{
#ifdef _WIN32
obj->rawData.asS32[i] = 0;
#endif
#ifdef _WIN64
obj->ptrData.asVoidPtr[i] = NULL;
#endif
#endif
#ifdef _WIN64
obj->ptrData.asVoidPtr[i] = nullptr;
#endif
}
obj->unused1 = 0;
@@ -51,23 +54,26 @@ static struct Object *allocate_object(void) {
obj->hitboxDownOffset = 0.0f;
obj->unused2 = 0;
obj->platform = NULL;
obj->collisionData = NULL;
obj->platform = nullptr;
obj->collisionData = nullptr;
obj->oIntangibleTimer = -1;
obj->oDamageOrCoinValue = 0;
obj->oHealth = 2048;
obj->oCollisionDistance = 1000.0f;
if (gCurrLevelNum == LEVEL_TTC) {
if (gCurrLevelNum == LEVEL_TTC)
{
obj->oDrawingDistance = 2000.0f;
} else {
}
else
{
obj->oDrawingDistance = 4000.0f;
}
mtxf_identity(obj->transform);
obj->respawnInfoType = RESPAWN_INFO_TYPE_NULL;
obj->respawnInfo = NULL;
obj->respawnInfo = nullptr;
obj->oDistanceToMario = 19000.0f;
obj->oRoom = -1;
@@ -76,28 +82,30 @@ static struct Object *allocate_object(void) {
obj->header.gfx.pos[0] = -10000.0f;
obj->header.gfx.pos[1] = -10000.0f;
obj->header.gfx.pos[2] = -10000.0f;
obj->header.gfx.throwMatrix = NULL;
obj->header.gfx.throwMatrix = nullptr;
return obj;
}
static struct Object *create_object(void) {
static struct Object *create_object(void)
{
struct Object *obj;
obj = allocate_object();
obj->curBhvCommand = NULL;
obj->behavior = NULL;
obj->curBhvCommand = nullptr;
obj->behavior = nullptr;
return obj;
}
static void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle) {
static void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, Vec3f pos, Vec3s angle)
{
vec3f_set(graphNode->scale, 1.0f, 1.0f, 1.0f);
vec3f_copy(graphNode->pos, pos);
vec3s_copy(graphNode->angle, angle);
graphNode->sharedChild = sharedChild;
graphNode->unk4C = 0;
graphNode->throwMatrix = NULL;
graphNode->animInfo.curAnim = NULL;
graphNode->throwMatrix = nullptr;
graphNode->animInfo.curAnim = nullptr;
graphNode->node.flags |= GRAPH_RENDER_ACTIVE;
graphNode->node.flags &= ~GRAPH_RENDER_INVISIBLE;
@@ -105,14 +113,15 @@ static void geo_obj_init(struct GraphNodeObject *graphNode, void *sharedChild, V
graphNode->node.flags &= ~GRAPH_RENDER_BILLBOARD;
}
static struct Object *spawn_object_at_origin(void) {
static struct Object *spawn_object_at_origin(void)
{
struct Object *obj;
obj = create_object();
obj->parentObj = NULL;
obj->parentObj = nullptr;
obj->header.gfx.areaIndex = 0;
obj->header.gfx.activeAreaIndex = 0;
geo_obj_init((struct GraphNodeObject *) &obj->header.gfx, NULL, gVec3fZero, gVec3sZero);
geo_obj_init(&obj->header.gfx, nullptr, gVec3fZero, gVec3sZero);
return obj;
}
@@ -121,10 +130,12 @@ static struct Object *spawn_object_at_origin(void) {
* Copy position, velocity, and angle variables from MarioState to the Mario
* object.
*/
static void copy_mario_state_to_object(void) {
static void copy_mario_state_to_object(void)
{
s32 i = 0;
// L is real
if (gCurrentObject != gMarioObject) {
if (gCurrentObject != gMarioObject)
{
i += 1;
}
@@ -157,9 +168,10 @@ struct Object *hack_allocate_mario(void)
/**
* Mario's primary behavior update function.
*/
void bhv_mario_update(void) {
void bhv_mario_update(void)
{
u32 particleFlags = 0;
// s32 i;
// s32 i;
gCurrentObject = gMarioObject;
particleFlags = execute_mario_action(gCurrentObject);
@@ -169,18 +181,19 @@ void bhv_mario_update(void) {
// to sync it with the Mario object
copy_mario_state_to_object();
// i = 0;
// while (sParticleTypes[i].particleFlag != 0) {
// if (particleFlags & sParticleTypes[i].particleFlag) {
// spawn_particle(sParticleTypes[i].activeParticleFlag, sParticleTypes[i].model,
// sParticleTypes[i].behavior);
// }
// i = 0;
// while (sParticleTypes[i].particleFlag != 0) {
// if (particleFlags & sParticleTypes[i].particleFlag) {
// spawn_particle(sParticleTypes[i].activeParticleFlag, sParticleTypes[i].model,
// sParticleTypes[i].behavior);
// }
// i++;
// }
// i++;
// }
}
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2) {
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2)
{
f32 spC, sp8, sp4;
spC = a2[3][0] * a2[0][0] + a2[3][1] * a2[0][1] + a2[3][2] * a2[0][2];
@@ -208,7 +221,9 @@ void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2) {
a0[2][3] = 0;
a0[3][3] = 1.0f;
}
void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1) {
void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1)
{
f32 spC = a1->oParentRelativePosX;
f32 sp8 = a1->oParentRelativePosY;
f32 sp4 = a1->oParentRelativePosZ;
@@ -217,7 +232,9 @@ void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1) {
a1->oPosY = spC * a0[0][1] + sp8 * a0[1][1] + sp4 * a0[2][1] + a0[3][1];
a1->oPosZ = spC * a0[0][2] + sp8 * a0[1][2] + sp4 * a0[2][2] + a0[3][2];
}
void obj_set_gfx_pos_from_pos(struct Object *obj) {
void obj_set_gfx_pos_from_pos(struct Object *obj)
{
obj->header.gfx.pos[0] = obj->oPosX;
obj->header.gfx.pos[1] = obj->oPosY;
obj->header.gfx.pos[2] = obj->oPosZ;
+4
View File
@@ -53,7 +53,11 @@
#define GRAPH_RENDER_HAS_ANIMATION (1 << 5)
struct Object *hack_allocate_mario(void);
void bhv_mario_update(void);
void create_transformation_from_matrices(Mat4 a0, Mat4 a1, Mat4 a2);
void obj_update_pos_from_parent_transformation(Mat4 a0, struct Object *a1);
void obj_set_gfx_pos_from_pos(struct Object *obj);
+54 -45
View File
@@ -16,16 +16,13 @@
* Determine if Mario is standing on a platform object, meaning that he is
* within 4 units of the floor. Set his referenced platform object accordingly.
*/
void update_mario_platform(void) {
void update_mario_platform(void)
{
struct SM64SurfaceCollisionData *floor;
UNUSED u32 unused;
f32 marioX;
f32 marioY;
f32 marioZ;
f32 floorHeight;
u32 awayFromFloor;
if (gMarioObject == NULL) {
if (gMarioObject == nullptr)
{
return;
}
@@ -34,27 +31,35 @@ void update_mario_platform(void) {
// of displacement since he is considered to be far from the platform's
// axis of rotation.
marioX = gMarioObject->oPosX;
marioY = gMarioObject->oPosY;
marioZ = gMarioObject->oPosZ;
floorHeight = find_floor(marioX, marioY, marioZ, &floor);
f32 marioX = gMarioObject->oPosX;
f32 marioY = gMarioObject->oPosY;
f32 marioZ = gMarioObject->oPosZ;
f32 floorHeight = find_floor(marioX, marioY, marioZ, &floor);
if (absfx(marioY - floorHeight) < 4.0f) {
u32 awayFromFloor;
if (absfx(marioY - floorHeight) < 4.0f)
{
awayFromFloor = 0;
} else {
}
else
{
awayFromFloor = 1;
}
switch (awayFromFloor) {
switch (awayFromFloor)
{
case 1:
gMarioObject->platform = NULL;
gMarioObject->platform = nullptr;
break;
case 0:
if (floor != NULL && floor->transform != NULL) {
if (floor != nullptr && floor->transform != nullptr)
{
gMarioObject->platform = floor->transform;
} else {
gMarioObject->platform = NULL;
}
else
{
gMarioObject->platform = nullptr;
}
break;
}
@@ -63,7 +68,8 @@ void update_mario_platform(void) {
/**
* Get Mario's position and store it in x, y, and z.
*/
static void get_mario_pos(f32 *x, f32 *y, f32 *z) {
static void get_mario_pos(f32 *x, f32 *y, f32 *z)
{
*x = gMarioState->pos[0];
*y = gMarioState->pos[1];
*z = gMarioState->pos[2];
@@ -72,7 +78,8 @@ static void get_mario_pos(f32 *x, f32 *y, f32 *z) {
/**
* Set Mario's position.
*/
static void set_mario_pos(f32 x, f32 y, f32 z) {
static void set_mario_pos(f32 x, f32 y, f32 z)
{
gMarioState->pos[0] = x;
gMarioState->pos[1] = y;
gMarioState->pos[2] = z;
@@ -82,13 +89,11 @@ static void set_mario_pos(f32 x, f32 y, f32 z) {
* Apply one frame of platform rotation to Mario or an object using the given
* platform. If isMario is false, use gCurrentObject.
*/
void apply_platform_displacement(u32 isMario, struct SM64SurfaceObjectTransform *platform) {
void apply_platform_displacement(u32 isMario, struct SM64SurfaceObjectTransform *platform)
{
f32 x;
f32 y;
f32 z;
f32 platformPosX;
f32 platformPosY;
f32 platformPosZ;
Vec3f currentObjectOffset;
Vec3f relativeOffset;
Vec3f newObjectOffset;
@@ -102,30 +107,32 @@ void apply_platform_displacement(u32 isMario, struct SM64SurfaceObjectTransform
rotation[1] = platform->aAngleVelYaw;
rotation[2] = platform->aAngleVelRoll;
// if (isMario) {
// D_8032FEC0 = 0;
// if (isMario) {
// D_8032FEC0 = 0;
get_mario_pos(&x, &y, &z);
// } else {
// x = gCurrentObject->aPosX;
// y = gCurrentObject->aPosY;
// z = gCurrentObject->aPosZ;
// }
// } else {
// x = gCurrentObject->aPosX;
// y = gCurrentObject->aPosY;
// z = gCurrentObject->aPosZ;
// }
x += platform->aVelX;
z += platform->aVelZ;
if (rotation[0] != 0 || rotation[1] != 0 || rotation[2] != 0) {
if (rotation[0] != 0 || rotation[1] != 0 || rotation[2] != 0)
{
unused1 = rotation[0];
unused2 = rotation[2];
unused3 = platform->aFaceAngleYaw;
if (isMario) {
if (isMario)
{
gMarioState->faceAngle[1] += rotation[1];
}
platformPosX = platform->aPosX;
platformPosY = platform->aPosY;
platformPosZ = platform->aPosZ;
f32 platformPosX = platform->aPosX;
f32 platformPosY = platform->aPosY;
f32 platformPosZ = platform->aPosZ;
currentObjectOffset[0] = x - platformPosX;
currentObjectOffset[1] = y - platformPosY;
@@ -150,20 +157,22 @@ void apply_platform_displacement(u32 isMario, struct SM64SurfaceObjectTransform
z = platformPosZ + newObjectOffset[2];
}
// if (isMario) {
// if (isMario) {
set_mario_pos(x, y, z);
// } else {
// gCurrentObject->oPosX = x;
// gCurrentObject->oPosY = y;
// gCurrentObject->oPosZ = z;
// }
// } else {
// gCurrentObject->oPosX = x;
// gCurrentObject->oPosY = y;
// gCurrentObject->oPosZ = z;
// }
}
/**
* If Mario's platform is not null, apply platform displacement.
*/
void apply_mario_platform_displacement(void) {
if (gMarioObject != NULL && gMarioObject->platform != NULL) {
void apply_mario_platform_displacement(void)
{
if (gMarioObject != nullptr && gMarioObject->platform != nullptr)
{
apply_platform_displacement(TRUE, gMarioObject->platform);
}
}
+1
View File
@@ -5,6 +5,7 @@
#include "../include/types.h"
void update_mario_platform(void);
void apply_mario_platform_displacement(void);
#endif // PLATFORM_DISPLACEMENT_H
File diff suppressed because it is too large Load Diff
+1
View File
@@ -27,6 +27,7 @@ extern struct GraphNodeHeldObject *gCurGraphNodeHeldObject;
#define ANIM_TYPE_ROTATION 5
void geo_process_node_and_siblings(struct GraphNode *firstNode);
//void geo_process_root(struct GraphNodeRoot *node, Vp *b, Vp *c, s32 clearColor);
void geo_process_root_hack_single_node(struct GraphNode *node);
+45 -19
View File
@@ -42,7 +42,8 @@ struct SaveFile
struct SaveBlockSignature signature;
};
enum SaveFileIndex {
enum SaveFileIndex
{
SAVE_FILE_A,
SAVE_FILE_B,
SAVE_FILE_C,
@@ -57,15 +58,15 @@ struct MainMenuSaveData
u32 coinScoreAges[NUM_SAVE_FILES];
u16 soundMode;
#ifdef VERSION_EU
#ifdef VERSION_EU
u16 language;
#define SUBTRAHEND 8
#else
#define SUBTRAHEND 6
#endif
#define SUBTRAHEND 8
#else
#define SUBTRAHEND 6
#endif
// Pad to match the EEPROM size of 0x200 (10 bytes on JP/US, 8 bytes on EU)
u8 filler[ 128 ]; // EEPROM_SIZE / 2 - SUBTRAHEND - NUM_SAVE_FILES * (4 + sizeof(struct SaveFile))];
u8 filler[128]; // EEPROM_SIZE / 2 - SUBTRAHEND - NUM_SAVE_FILES * (4 + sizeof(struct SaveFile))];
struct SaveBlockSignature signature;
};
@@ -75,7 +76,7 @@ struct SaveBuffer
// Each of the four save files has two copies. If one is bad, the other is used as a backup.
struct SaveFile files[NUM_SAVE_FILES][2];
// The main menu data has two copies. If one is bad, the other is used as a backup.
// struct MainMenuSaveData menuData[0];
// struct MainMenuSaveData menuData[0];
};
extern u8 gLastCompletedCourseNum;
@@ -120,12 +121,18 @@ extern s8 gLevelToCourseNumTable[];
// Variable for setting a warp checkpoint.
// possibly a WarpDest struct where arg is a union. TODO: Check?
struct WarpCheckpoint {
/*0x00*/ u8 actNum;
/*0x01*/ u8 courseNum;
/*0x02*/ u8 levelID;
/*0x03*/ u8 areaNum;
/*0x04*/ u8 warpNode;
struct WarpCheckpoint
{
/*0x00*/
u8 actNum;
/*0x01*/
u8 courseNum;
/*0x02*/
u8 levelID;
/*0x03*/
u8 areaNum;
/*0x04*/
u8 warpNode;
};
extern struct WarpCheckpoint gWarpCheckpoint;
@@ -134,38 +141,57 @@ extern s8 gMainMenuDataModified;
extern s8 gSaveFileModified;
void save_file_do_save(s32 fileIndex);
void save_file_erase(s32 fileIndex);
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex);
BAD_RETURN (s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex);
void save_file_load_all(void);
void save_file_reload(void);
void save_file_collect_star_or_key(s16 coinScore, s16 starIndex);
s32 save_file_exists(s32 fileIndex);
u32 save_file_get_max_coin_score(s32 courseIndex);
s32 save_file_get_course_star_count(s32 fileIndex, s32 courseIndex);
//s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse);
//void save_file_set_flags(u32 flags);
//void save_file_clear_flags(u32 flags);
//u32 save_file_get_flags(void);
u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex);
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags);
s32 save_file_get_course_coin_score(s32 fileIndex, s32 courseIndex);
s32 save_file_is_cannon_unlocked(void);
void save_file_set_cannon_unlocked(void);
void save_file_set_cap_pos(s16 x, s16 y, s16 z);
s32 save_file_get_cap_pos(Vec3s capPos);
void save_file_set_sound_mode(u16 mode);
u16 save_file_get_sound_mode(void);
void save_file_move_cap_to_default_location(void);
void disable_warp_checkpoint(void);
void check_if_should_set_warp_checkpoint(struct WarpNode *warpNode);
s32 check_warp_checkpoint(struct WarpNode *warpNode);
#ifdef VERSION_EU
enum EuLanguages {
LANGUAGE_ENGLISH,
LANGUAGE_FRENCH,
LANGUAGE_GERMAN
enum EuLanguages
{
LANGUAGE_ENGLISH, LANGUAGE_FRENCH, LANGUAGE_GERMAN
};
void eu_set_language(u16 language);
+86 -44
View File
@@ -34,8 +34,8 @@ static u16 sCurrentMusic = MUSIC_NONE;
static u16 sCurrentShellMusic = MUSIC_NONE;
static u16 sCurrentCapMusic = MUSIC_NONE;
static u8 sPlayingInfiniteStairs = FALSE;
UNUSED static u8 unused8032C6D8[16] = { 0 };
static s16 sSoundMenuModeToSoundMode[] = { SOUND_MODE_STEREO, SOUND_MODE_MONO, SOUND_MODE_HEADSET };
UNUSED static u8 unused8032C6D8[16] = {0};
static s16 sSoundMenuModeToSoundMode[] = {SOUND_MODE_STEREO, SOUND_MODE_MONO, SOUND_MODE_HEADSET};
// Only the 20th array element is used.
static u32 sMenuSoundsExtra[] = {
SOUND_MOVING_TERRAIN_SLIDE + (0 << 16),
@@ -82,15 +82,18 @@ void play_menu_sounds_extra(s32 a, void *b);
/**
* Called from threads: thread5_game_loop
*/
void reset_volume(void) {
void reset_volume(void)
{
sMusicVolume = 0;
}
/**
* Called from threads: thread5_game_loop
*/
void lower_background_noise(s32 a) {
switch (a) {
void lower_background_noise(s32 a)
{
switch (a)
{
case 1:
set_audio_muted(TRUE);
break;
@@ -104,8 +107,10 @@ void lower_background_noise(s32 a) {
/**
* Called from threads: thread5_game_loop
*/
void raise_background_noise(s32 a) {
switch (a) {
void raise_background_noise(s32 a)
{
switch (a)
{
case 1:
set_audio_muted(FALSE);
break;
@@ -119,8 +124,10 @@ void raise_background_noise(s32 a) {
/**
* Called from threads: thread5_game_loop
*/
void disable_background_sound(void) {
if (sBgMusicDisabled == FALSE) {
void disable_background_sound(void)
{
if (sBgMusicDisabled == FALSE)
{
sBgMusicDisabled = TRUE;
sound_banks_disable(SEQ_PLAYER_SFX, SOUND_BANKS_BACKGROUND);
}
@@ -129,8 +136,10 @@ void disable_background_sound(void) {
/**
* Called from threads: thread5_game_loop
*/
void enable_background_sound(void) {
if (sBgMusicDisabled == TRUE) {
void enable_background_sound(void)
{
if (sBgMusicDisabled == TRUE)
{
sBgMusicDisabled = FALSE;
sound_banks_enable(SEQ_PLAYER_SFX, SOUND_BANKS_BACKGROUND);
}
@@ -141,8 +150,10 @@ void enable_background_sound(void) {
*
* Called from threads: thread5_game_loop
*/
void set_sound_mode(u16 soundMode) {
if (soundMode < 3) {
void set_sound_mode(u16 soundMode)
{
if (soundMode < 3)
{
audio_set_sound_mode(sSoundMenuModeToSoundMode[soundMode]);
}
}
@@ -152,33 +163,51 @@ void set_sound_mode(u16 soundMode) {
*
* Called from threads: thread5_game_loop
*/
void play_menu_sounds(s16 soundMenuFlags) {
if (soundMenuFlags & SOUND_MENU_FLAG_HANDAPPEAR) {
void play_menu_sounds(s16 soundMenuFlags)
{
if (soundMenuFlags & SOUND_MENU_FLAG_HANDAPPEAR)
{
play_sound(SOUND_MENU_HAND_APPEAR, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_HANDISAPPEAR) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_HANDISAPPEAR)
{
play_sound(SOUND_MENU_HAND_DISAPPEAR, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_UNKNOWN1) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_UNKNOWN1)
{
play_sound(SOUND_MENU_UNK0C, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_PINCHMARIOFACE) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_PINCHMARIOFACE)
{
play_sound(SOUND_MENU_PINCH_MARIO_FACE, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_PINCHMARIOFACE2) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_PINCHMARIOFACE2)
{
play_sound(SOUND_MENU_PINCH_MARIO_FACE, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_LETGOMARIOFACE) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_LETGOMARIOFACE)
{
play_sound(SOUND_MENU_LET_GO_MARIO_FACE, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_CAMERAZOOMIN) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_CAMERAZOOMIN)
{
play_sound(SOUND_MENU_CAMERA_ZOOM_IN, gGlobalSoundSource);
} else if (soundMenuFlags & SOUND_MENU_FLAG_CAMERAZOOMOUT) {
}
else if (soundMenuFlags & SOUND_MENU_FLAG_CAMERAZOOMOUT)
{
play_sound(SOUND_MENU_CAMERA_ZOOM_OUT, gGlobalSoundSource);
}
if (soundMenuFlags & 0x100) {
play_menu_sounds_extra(20, NULL);
if (soundMenuFlags & 0x100)
{
play_menu_sounds_extra(20, nullptr);
}
#if ENABLE_RUMBLE
if (soundMenuFlags & SOUND_MENU_FLAG_LETGOMARIOFACE) {
#if ENABLE_RUMBLE
if (soundMenuFlags & SOUND_MENU_FLAG_LETGOMARIOFACE)
{
queue_rumble_data(10, 60);
}
#endif
#endif
}
/**
@@ -187,7 +216,7 @@ void play_menu_sounds(s16 soundMenuFlags) {
* Called from threads: thread5_game_loop
*/
//void play_painting_eject_sound(void) {
// if (gRipplingPainting != NULL && gRipplingPainting->state == PAINTING_ENTERED) {
// if (gRipplingPainting != nullptr && gRipplingPainting->state == PAINTING_ENTERED) {
// // ripple when Mario enters painting
// if (!sPaintingEjectSoundPlayed) {
// play_sound(SOUND_GENERAL_PAINTING_EJECT,
@@ -207,7 +236,7 @@ void play_menu_sounds(s16 soundMenuFlags) {
//
// /* Infinite stairs? */
// if (gCurrLevelNum == LEVEL_CASTLE && gCurrAreaIndex == 2 && gMarioState->numStars < 70) {
// if (gMarioState->floor != NULL && gMarioState->floor->room == 6) {
// if (gMarioState->floor != nullptr && gMarioState->floor->room == 6) {
// if (gMarioState->pos[2] < 2540.0f) {
// shouldPlay = TRUE;
// }
@@ -229,7 +258,7 @@ void play_menu_sounds(s16 soundMenuFlags) {
*/
//void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer) {
// if (gResetTimer == 0 && seqArgs != sCurrentMusic) {
// if (gCurrCreditsEntry != NULL) {
// if (gCurrCreditsEntry != nullptr) {
// sound_reset(7);
// } else {
// sound_reset(a);
@@ -245,7 +274,8 @@ void play_menu_sounds(s16 soundMenuFlags) {
/**
* Called from threads: thread3_main, thread5_game_loop
*/
void fadeout_music(s16 fadeOutTime) {
void fadeout_music(s16 fadeOutTime)
{
func_803210D4(fadeOutTime);
sCurrentMusic = MUSIC_NONE;
sCurrentShellMusic = MUSIC_NONE;
@@ -255,7 +285,8 @@ void fadeout_music(s16 fadeOutTime) {
/**
* Called from threads: thread5_game_loop
*/
void fadeout_level_music(s16 fadeTimer) {
void fadeout_level_music(s16 fadeTimer)
{
seq_player_fade_out(SEQ_PLAYER_LEVEL, fadeTimer);
sCurrentMusic = MUSIC_NONE;
sCurrentShellMusic = MUSIC_NONE;
@@ -265,7 +296,8 @@ void fadeout_level_music(s16 fadeTimer) {
/**
* Called from threads: thread5_game_loop
*/
void play_cutscene_music(u16 seqArgs) {
void play_cutscene_music(u16 seqArgs)
{
play_music(SEQ_PLAYER_LEVEL, seqArgs, 0);
sCurrentMusic = seqArgs;
}
@@ -273,7 +305,8 @@ void play_cutscene_music(u16 seqArgs) {
/**
* Called from threads: thread5_game_loop
*/
void play_shell_music(void) {
void play_shell_music(void)
{
play_music(SEQ_PLAYER_LEVEL, SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION), 0);
sCurrentShellMusic = SEQUENCE_ARGS(4, SEQ_EVENT_POWERUP | SEQ_VARIATION);
}
@@ -281,8 +314,10 @@ void play_shell_music(void) {
/**
* Called from threads: thread5_game_loop
*/
void stop_shell_music(void) {
if (sCurrentShellMusic != MUSIC_NONE) {
void stop_shell_music(void)
{
if (sCurrentShellMusic != MUSIC_NONE)
{
stop_background_music(sCurrentShellMusic);
sCurrentShellMusic = MUSIC_NONE;
}
@@ -291,9 +326,11 @@ void stop_shell_music(void) {
/**
* Called from threads: thread5_game_loop
*/
void play_cap_music(u16 seqArgs) {
void play_cap_music(u16 seqArgs)
{
play_music(SEQ_PLAYER_LEVEL, seqArgs, 0);
if (sCurrentCapMusic != MUSIC_NONE && sCurrentCapMusic != seqArgs) {
if (sCurrentCapMusic != MUSIC_NONE && sCurrentCapMusic != seqArgs)
{
stop_background_music(sCurrentCapMusic);
}
sCurrentCapMusic = seqArgs;
@@ -302,8 +339,10 @@ void play_cap_music(u16 seqArgs) {
/**
* Called from threads: thread5_game_loop
*/
void fadeout_cap_music(void) {
if (sCurrentCapMusic != MUSIC_NONE) {
void fadeout_cap_music(void)
{
if (sCurrentCapMusic != MUSIC_NONE)
{
fadeout_background_music(sCurrentCapMusic, 600);
}
}
@@ -311,8 +350,10 @@ void fadeout_cap_music(void) {
/**
* Called from threads: thread5_game_loop
*/
void stop_cap_music(void) {
if (sCurrentCapMusic != MUSIC_NONE) {
void stop_cap_music(void)
{
if (sCurrentCapMusic != MUSIC_NONE)
{
stop_background_music(sCurrentCapMusic);
sCurrentCapMusic = MUSIC_NONE;
}
@@ -321,7 +362,8 @@ void stop_cap_music(void) {
/**
* Called from threads: thread5_game_loop
*/
void play_menu_sounds_extra(s32 a, void *b) {
void play_menu_sounds_extra(s32 a, void *b)
{
play_sound(sMenuSoundsExtra[a], b);
}
@@ -353,7 +395,7 @@ void play_menu_sounds_extra(s32 a, void *b) {
// struct SPTask *spTask;
// profiler_log_thread4_time();
// spTask = create_next_audio_frame_task();
// if (spTask != NULL) {
// if (spTask != nullptr) {
// dispatch_audio_sptask(spTask);
// }
// profiler_log_thread4_time();
+15
View File
@@ -19,23 +19,38 @@
#define SOUND_MENU_MODE_HEADSET 2
void reset_volume(void);
void raise_background_noise(s32 a);
void lower_background_noise(s32 a);
void disable_background_sound(void);
void enable_background_sound(void);
void set_sound_mode(u16 soundMode);
void play_menu_sounds(s16 soundMenuFlags);
//void play_painting_eject_sound(void);
//void play_infinite_stairs_music(void);
//void set_background_music(u16 a, u16 seqArgs, s16 fadeTimer);
void fadeout_music(s16 fadeOutTime);
void fadeout_level_music(s16 fadeTimer);
void play_cutscene_music(u16 seqArgs);
void play_shell_music(void);
void stop_shell_music(void);
void play_cap_music(u16 seqArgs);
void fadeout_cap_music(void);
void stop_cap_music(void);
//void audio_game_loop_tick(void);
//void thread4_sound(UNUSED void *arg);
+3 -3
View File
@@ -7,8 +7,8 @@ struct GlobalState *g_state = 0;
struct GlobalState *global_state_create(void)
{
struct GlobalState *state = malloc( sizeof( struct GlobalState ));
memset( state, 0, sizeof( struct GlobalState ));
struct GlobalState *state = malloc(sizeof(struct GlobalState));
memset(state, 0, sizeof(struct GlobalState));
state->msSwimStrength = MIN_SWIM_STRENGTH;
return state;
}
@@ -20,5 +20,5 @@ void global_state_bind(struct GlobalState *state)
void global_state_delete(struct GlobalState *state)
{
free( state );
free(state);
}
+2
View File
@@ -50,5 +50,7 @@ struct GlobalState
extern struct GlobalState *g_state;
extern struct GlobalState *global_state_create(void);
extern void global_state_bind(struct GlobalState *state);
extern void global_state_delete(struct GlobalState *state);
+124 -104
View File
@@ -98,134 +98,152 @@
* Data Structures.
*/
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int gain:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int gain: 16;
unsigned int addr;
} Aadpcm;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int gain:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int gain: 16;
unsigned int addr;
} Apolef;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int pad1:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int pad1: 16;
unsigned int addr;
} Aenvelope;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:8;
unsigned int dmem:16;
unsigned int pad2:16;
unsigned int count:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 8;
unsigned int dmem: 16;
unsigned int pad2: 16;
unsigned int count: 16;
} Aclearbuff;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:8;
unsigned int pad2:16;
unsigned int inL:16;
unsigned int inR:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 8;
unsigned int pad2: 16;
unsigned int inL: 16;
unsigned int inR: 16;
} Ainterleave;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:24;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 24;
unsigned int addr;
} Aloadbuff;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int pad1:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int pad1: 16;
unsigned int addr;
} Aenvmixer;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int gain:16;
unsigned int dmemi:16;
unsigned int dmemo:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int gain: 16;
unsigned int dmemi: 16;
unsigned int dmemo: 16;
} Amixer;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int dmem2:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int dmem2: 16;
unsigned int addr;
} Apan;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int pitch:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int pitch: 16;
unsigned int addr;
} Aresample;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int pad1:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int pad1: 16;
unsigned int addr;
} Areverb;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:24;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 24;
unsigned int addr;
} Asavebuff;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:24;
unsigned int pad2:2;
unsigned int number:4;
unsigned int base:24;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 24;
unsigned int pad2: 2;
unsigned int number: 4;
unsigned int base: 24;
} Asegment;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int dmemin:16;
unsigned int dmemout:16;
unsigned int count:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int dmemin: 16;
unsigned int dmemout: 16;
unsigned int count: 16;
} Asetbuff;
typedef struct {
unsigned int cmd:8;
unsigned int flags:8;
unsigned int vol:16;
unsigned int voltgt:16;
unsigned int volrate:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int flags: 8;
unsigned int vol: 16;
unsigned int voltgt: 16;
unsigned int volrate: 16;
} Asetvol;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:8;
unsigned int dmemin:16;
unsigned int dmemout:16;
unsigned int count:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 8;
unsigned int dmemin: 16;
unsigned int dmemout: 16;
unsigned int count: 16;
} Admemmove;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:8;
unsigned int count:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 8;
unsigned int count: 16;
unsigned int addr;
} Aloadadpcm;
typedef struct {
unsigned int cmd:8;
unsigned int pad1:8;
unsigned int pad2:16;
typedef struct
{
unsigned int cmd: 8;
unsigned int pad1: 8;
unsigned int pad2: 16;
unsigned int addr;
} Asetloop;
@@ -233,33 +251,35 @@ typedef struct {
* Generic Acmd Packet
*/
typedef struct {
typedef struct
{
uintptr_t w0;
uintptr_t w1;
} Awords;
typedef union {
typedef union
{
Awords words;
#if IS_BIG_ENDIAN && !IS_64_BIT
Aadpcm adpcm;
Apolef polef;
Aclearbuff clearbuff;
Aenvelope envelope;
Ainterleave interleave;
Aloadbuff loadbuff;
Aenvmixer envmixer;
Aresample resample;
Areverb reverb;
Asavebuff savebuff;
Asegment segment;
Asetbuff setbuff;
Asetvol setvol;
Admemmove dmemmove;
Aloadadpcm loadadpcm;
Amixer mixer;
Asetloop setloop;
Aadpcm adpcm;
Apolef polef;
Aclearbuff clearbuff;
Aenvelope envelope;
Ainterleave interleave;
Aloadbuff loadbuff;
Aenvmixer envmixer;
Aresample resample;
Areverb reverb;
Asavebuff savebuff;
Asegment segment;
Asetbuff setbuff;
Asetvol setvol;
Admemmove dmemmove;
Aloadadpcm loadadpcm;
Amixer mixer;
Asetloop setloop;
#endif
long long int force_union_align; /* dummy, force alignment */
long long int force_union_align; /* dummy, force alignment */
} Acmd;
/*
+182 -142
View File
@@ -24,7 +24,6 @@
#include "ultratypes.h"
// FROM mbi.h
/*
* the SHIFT macros are used to build display list commands, inserting
@@ -51,9 +50,6 @@
#define G_OFF (0)
/*
* To use the F3DEX ucodes, define F3DEX_GBI before include this file.
*
@@ -1141,12 +1137,13 @@
/*
* Vertex (set up for use with colors)
*/
typedef struct {
#ifndef GBI_FLOATS
typedef struct
{
#ifndef GBI_FLOATS
short ob[3]; /* x, y, z */
#else
#else
float ob[3]; /* x, y, z */
#endif
#endif
unsigned short flag;
short tc[2]; /* texture coord */
unsigned char cn[4]; /* color & alpha */
@@ -1155,19 +1152,21 @@ typedef struct {
/*
* Vertex (set up for use with normals)
*/
typedef struct {
#ifndef GBI_FLOATS
typedef struct
{
#ifndef GBI_FLOATS
short ob[3]; /* x, y, z */
#else
#else
float ob[3]; /* x, y, z */
#endif
#endif
unsigned short flag;
short tc[2]; /* texture coord */
signed char n[3]; /* normal */
unsigned char a; /* alpha */
} Vtx_tn;
typedef union {
typedef union
{
Vtx_t v; /* Use this one for colors */
Vtx_tn n; /* Use this one for normals */
long long int force_structure_alignment;
@@ -1177,7 +1176,8 @@ typedef union {
* Sprite structure
*/
typedef struct {
typedef struct
{
void *SourceImagePointer;
void *TlutPointer;
short Stride;
@@ -1191,10 +1191,10 @@ typedef struct {
/* padding to bring structure size to 64 bit allignment */
char dummy[4];
} uSprite_t;
typedef union {
typedef union
{
uSprite_t s;
/* Need to make sure this is 64 bit aligned */
@@ -1204,7 +1204,8 @@ typedef union {
/*
* Triangle face
*/
typedef struct {
typedef struct
{
unsigned char flag;
unsigned char v[3];
} Tri;
@@ -1217,12 +1218,14 @@ typedef struct {
*/
typedef s32 Mtx_t[4][4];
typedef union {
typedef union
{
Mtx_t m;
long long int force_structure_alignment;
} Mtx;
#else
typedef struct {
typedef struct
{
float m[4][4];
} Mtx;
#endif
@@ -1261,13 +1264,15 @@ typedef struct {
* (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, G_MAXZ, 0,
* (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, 0, 0,
*/
typedef struct {
typedef struct
{
short vscale[4]; /* scale, 2 bits fraction */
short vtrans[4]; /* translate, 2 bits fraction */
/* both the above arrays are padded to 64-bit boundary */
} Vp_t;
typedef union {
typedef union
{
Vp_t vp;
long long int force_structure_alignment;
} Vp;
@@ -1427,7 +1432,8 @@ typedef union {
*
*/
typedef struct {
typedef struct
{
unsigned char col[3]; /* diffuse light value (rgba) */
char pad1;
unsigned char colc[3]; /* copy of diffuse light value (rgba) */
@@ -1436,77 +1442,92 @@ typedef struct {
char pad3;
} Light_t;
typedef struct {
typedef struct
{
unsigned char col[3]; /* ambient light value (rgba) */
char pad1;
unsigned char colc[3]; /* copy of ambient light value (rgba) */
char pad2;
} Ambient_t;
typedef struct {
int x1,y1,x2,y2; /* texture offsets for highlight 1/2 */
typedef struct
{
int x1, y1, x2, y2; /* texture offsets for highlight 1/2 */
} Hilite_t;
typedef union {
typedef union
{
Light_t l;
long long int force_structure_alignment[2];
} Light;
typedef union {
typedef union
{
Ambient_t l;
long long int force_structure_alignment[1];
} Ambient;
typedef struct {
typedef struct
{
Ambient a;
Light l[7];
} Lightsn;
typedef struct {
typedef struct
{
Ambient a;
Light l[1];
} Lights0;
typedef struct {
typedef struct
{
Ambient a;
Light l[1];
} Lights1;
typedef struct {
typedef struct
{
Ambient a;
Light l[2];
} Lights2;
typedef struct {
typedef struct
{
Ambient a;
Light l[3];
} Lights3;
typedef struct {
typedef struct
{
Ambient a;
Light l[4];
} Lights4;
typedef struct {
typedef struct
{
Ambient a;
Light l[5];
} Lights5;
typedef struct {
typedef struct
{
Ambient a;
Light l[6];
} Lights6;
typedef struct {
typedef struct
{
Ambient a;
Light l[7];
} Lights7;
typedef struct {
typedef struct
{
Light l[2];
} LookAt;
typedef union {
typedef union
{
Hilite_t h;
long int force_structure_alignment[4];
} Hilite;
@@ -1571,27 +1592,30 @@ typedef union {
/*
* Graphics DMA Packet
*/
typedef struct {
int cmd:8;
unsigned int par:8;
unsigned int len:16;
typedef struct
{
int cmd: 8;
unsigned int par: 8;
unsigned int len: 16;
uintptr_t addr;
} Gdma;
/*
* Graphics Immediate Mode Packet types
*/
typedef struct {
int cmd:8;
int pad:24;
typedef struct
{
int cmd: 8;
int pad: 24;
Tri tri;
} Gtri;
typedef struct {
int cmd:8;
int pad1:24;
int pad2:24;
unsigned char param:8;
typedef struct
{
int cmd: 8;
int pad1: 24;
int pad2: 24;
unsigned char param: 8;
} Gpopmtx;
/*
@@ -1603,32 +1627,36 @@ typedef struct {
* int base:24;
* } Gsegment;
*/
typedef struct {
int cmd:8;
int pad0:8;
int mw_index:8;
int number:8;
int pad1:8;
int base:24;
typedef struct
{
int cmd: 8;
int pad0: 8;
int mw_index: 8;
int number: 8;
int pad1: 8;
int base: 24;
} Gsegment;
typedef struct {
int cmd:8;
int pad0:8;
int sft:8;
int len:8;
unsigned int data:32;
typedef struct
{
int cmd: 8;
int pad0: 8;
int sft: 8;
int len: 8;
unsigned int data: 32;
} GsetothermodeL;
typedef struct {
int cmd:8;
int pad0:8;
int sft:8;
int len:8;
unsigned int data:32;
typedef struct
{
int cmd: 8;
int pad0: 8;
int sft: 8;
int len: 8;
unsigned int data: 32;
} GsetothermodeH;
typedef struct {
typedef struct
{
unsigned char cmd;
unsigned char lodscale;
unsigned char tile;
@@ -1637,15 +1665,17 @@ typedef struct {
unsigned short t;
} Gtexture;
typedef struct {
int cmd:8;
int pad:24;
typedef struct
{
int cmd: 8;
int pad: 24;
Tri line;
} Gline3D;
typedef struct {
int cmd:8;
int pad1:24;
typedef struct
{
int cmd: 8;
int pad1: 24;
short int pad2;
short int scale;
} Gperspnorm;
@@ -1654,70 +1684,76 @@ typedef struct {
/*
* RDP Packet types
*/
typedef struct {
int cmd:8;
unsigned int fmt:3;
unsigned int siz:2;
unsigned int pad:7;
unsigned int wd:12; /* really only 10 bits, extra */
typedef struct
{
int cmd: 8;
unsigned int fmt: 3;
unsigned int siz: 2;
unsigned int pad: 7;
unsigned int wd: 12; /* really only 10 bits, extra */
uintptr_t dram; /* to account for 1024 */
} Gsetimg;
typedef struct {
int cmd:8;
unsigned int muxs0:24;
unsigned int muxs1:32;
typedef struct
{
int cmd: 8;
unsigned int muxs0: 24;
unsigned int muxs1: 32;
} Gsetcombine;
typedef struct {
int cmd:8;
typedef struct
{
int cmd: 8;
unsigned char pad;
unsigned char prim_min_level;
unsigned char prim_level;
unsigned long color;
} Gsetcolor;
typedef struct {
int cmd:8;
int x0:10;
int x0frac:2;
int y0:10;
int y0frac:2;
unsigned int pad:8;
int x1:10;
int x1frac:2;
int y1:10;
int y1frac:2;
typedef struct
{
int cmd: 8;
int x0: 10;
int x0frac: 2;
int y0: 10;
int y0frac: 2;
unsigned int pad: 8;
int x1: 10;
int x1frac: 2;
int y1: 10;
int y1frac: 2;
} Gfillrect;
typedef struct {
int cmd:8;
unsigned int fmt:3;
unsigned int siz:2;
unsigned int pad0:1;
unsigned int line:9;
unsigned int tmem:9;
unsigned int pad1:5;
unsigned int tile:3;
unsigned int palette:4;
unsigned int ct:1;
unsigned int mt:1;
unsigned int maskt:4;
unsigned int shiftt:4;
unsigned int cs:1;
unsigned int ms:1;
unsigned int masks:4;
unsigned int shifts:4;
typedef struct
{
int cmd: 8;
unsigned int fmt: 3;
unsigned int siz: 2;
unsigned int pad0: 1;
unsigned int line: 9;
unsigned int tmem: 9;
unsigned int pad1: 5;
unsigned int tile: 3;
unsigned int palette: 4;
unsigned int ct: 1;
unsigned int mt: 1;
unsigned int maskt: 4;
unsigned int shiftt: 4;
unsigned int cs: 1;
unsigned int ms: 1;
unsigned int masks: 4;
unsigned int shifts: 4;
} Gsettile;
typedef struct {
int cmd:8;
unsigned int sl:12;
unsigned int tl:12;
int pad:5;
unsigned int tile:3;
unsigned int sh:12;
unsigned int th:12;
typedef struct
{
int cmd: 8;
unsigned int sl: 12;
unsigned int tl: 12;
int pad: 5;
unsigned int tile: 3;
unsigned int sh: 12;
unsigned int th: 12;
} Gloadtile;
typedef Gloadtile Gloadblock;
@@ -1726,24 +1762,26 @@ typedef Gloadtile Gsettilesize;
typedef Gloadtile Gloadtlut;
typedef struct {
unsigned int cmd:8; /* command */
unsigned int xl:12; /* X coordinate of upper left */
unsigned int yl:12; /* Y coordinate of upper left */
unsigned int pad1:5; /* Padding */
unsigned int tile:3; /* Tile descriptor index */
unsigned int xh:12; /* X coordinate of lower right */
unsigned int yh:12; /* Y coordinate of lower right */
unsigned int s:16; /* S texture coord at top left */
unsigned int t:16; /* T texture coord at top left */
unsigned int dsdx:16;/* Change in S per change in X */
unsigned int dtdy:16;/* Change in T per change in Y */
typedef struct
{
unsigned int cmd: 8; /* command */
unsigned int xl: 12; /* X coordinate of upper left */
unsigned int yl: 12; /* Y coordinate of upper left */
unsigned int pad1: 5; /* Padding */
unsigned int tile: 3; /* Tile descriptor index */
unsigned int xh: 12; /* X coordinate of lower right */
unsigned int yh: 12; /* Y coordinate of lower right */
unsigned int s: 16; /* S texture coord at top left */
unsigned int t: 16; /* T texture coord at top left */
unsigned int dsdx: 16; /* Change in S per change in X */
unsigned int dtdy: 16; /* Change in T per change in Y */
} Gtexrect;
/*
* Textured rectangles are 128 bits not 64 bits
*/
typedef struct {
typedef struct
{
unsigned long w0;
unsigned long w1;
unsigned long w2;
@@ -1757,7 +1795,8 @@ typedef struct {
/*
* Generic Gfx Packet
*/
typedef struct {
typedef struct
{
uintptr_t w0;
uintptr_t w1;
} Gwords;
@@ -1770,9 +1809,10 @@ typedef struct {
* 64-bit systems, only the 'words' member may be accessed; the rest of the
* structs don't have matching layouts for now.)
*/
typedef union {
typedef union
{
Gwords words;
#if !defined(F3D_OLD) && IS_BIG_ENDIAN && !IS_64_BIT
#if !defined(F3D_OLD) && IS_BIG_ENDIAN && !IS_64_BIT
Gdma dma;
Gtri tri;
Gline3D line;
@@ -1790,7 +1830,7 @@ typedef union {
Gloadtile loadtile; /* use for loadblock also, th is dxt */
Gsettilesize settilesize;
Gloadtlut loadtlut;
#endif
#endif
long long int force_structure_alignment;
} Gfx;
+15 -4
View File
@@ -6,8 +6,15 @@
typedef struct
{
u8 *offset __attribute__((aligned (8)));
s32 len __attribute__((aligned (8)));
u8 *offset __attribute__((aligned (8)
)
);
s32 len __attribute__((aligned (8)
)
);
} ALSeqData;
typedef struct
@@ -16,8 +23,12 @@ typedef struct
unsigned short seqCount;
unsigned int pad;
ALSeqData seqArray[1];
} __attribute__((aligned (16))) ALSeqFile;
} __attribute__((aligned (16)
void alSeqFileNew(ALSeqFile *f, u8 *base);
)
)
ALSeqFile;
void alSeqFileNew(ALSeqFile * f, u8 * base);
#endif
+26 -17
View File
@@ -32,7 +32,10 @@
#define _OS_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
@@ -49,7 +52,8 @@ extern "C" {
/*
* Structure for device manager block
*/
typedef struct {
typedef struct
{
s32 active; /* Status flag */
OSThread *thread; /* Calling thread */
OSMesgQueue *cmdQueue; /* Command queue */
@@ -57,6 +61,7 @@ typedef struct {
OSMesgQueue *acsQueue; /* Access queue */
/* Raw DMA routine */
s32 (*dma)(s32, u32, void *, u32);
s32 (*edma)(OSPiHandle *, s32, u32, void *, u32);
} OSDevMgr;
@@ -65,8 +70,8 @@ typedef struct {
*/
typedef struct {
typedef struct
{
int status;
OSMesgQueue *queue;
int channel;
@@ -83,7 +88,8 @@ typedef struct {
} OSPfs;
typedef struct {
typedef struct
{
u32 file_size; /* bytes */
u32 game_code;
u16 company_code;
@@ -94,7 +100,8 @@ typedef struct {
/*
* Structure for Profiler
*/
typedef struct {
typedef struct
{
u16 *histo_base; /* histogram base */
u32 histo_size; /* histogram size */
u32 *text_start; /* start of text segment */
@@ -431,7 +438,7 @@ typedef struct {
#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */
#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a */
/* different one */
/* different one */
#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker */
#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR
#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/
@@ -575,7 +582,6 @@ extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */
extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/
/**************************************************************************
*
* Function prototypes
@@ -584,7 +590,8 @@ extern OSPiHandle *__osDiskHandle; /* For exceptasm to get disk info*/
/* Thread operations */
extern void osCreateThread(OSThread *, OSId, void (*)(void *),
extern void osCreateThread(
OSThread *, OSId, void (*)(void *),
void *, void *, OSPri);
extern void osDestroyThread(OSThread *);
extern void osYieldThread(void);
@@ -635,7 +642,7 @@ extern void osSetTLBASID(s32);
/* Address translation routines and macros */
extern u32 osVirtualToPhysical(void *);
extern void * osPhysicalToVirtual(u32);
extern void *osPhysicalToVirtual(u32);
#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000))
#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000))
@@ -665,7 +672,8 @@ extern s32 osPiRawReadIo(u32, u32 *);
extern s32 osPiRawStartDma(s32, u32, void *, u32);
extern s32 osPiWriteIo(u32, u32);
extern s32 osPiReadIo(u32, u32 *);
extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32,
extern s32 osPiStartDma(
OSIoMesg *, s32, s32, u32, void *, u32,
OSMesgQueue *);
extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32);
@@ -691,7 +699,8 @@ extern void osCreateViManager(OSPri);
extern OSTime osGetTime(void);
extern void osSetTime(OSTime);
extern u32 osSetTimer(OSTimer *, OSTime, OSTime,
extern u32 osSetTimer(
OSTimer *, OSTime, OSTime,
OSMesgQueue *, OSMesg);
extern int osStopTimer(OSTimer *);
@@ -746,11 +755,11 @@ extern OSPiHandle *osLeoDiskInit(void);
extern OSPiHandle *osDriveRomInit(void);
extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *);
extern s32 osEPiRawWriteIo(OSPiHandle *, u32 , u32);
extern s32 osEPiRawReadIo(OSPiHandle *, u32 , u32 *);
extern s32 osEPiRawStartDma(OSPiHandle *, s32 , u32 , void *, u32 );
extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 );
extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *);
extern s32 osEPiRawWriteIo(OSPiHandle *, u32, u32);
extern s32 osEPiRawReadIo(OSPiHandle *, u32, u32 *);
extern s32 osEPiRawStartDma(OSPiHandle *, s32, u32, void *, u32);
extern s32 osEPiWriteIo(OSPiHandle *, u32, u32);
extern s32 osEPiReadIo(OSPiHandle *, u32, u32 *);
extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32);
extern s32 osEPiLinkHandle(OSPiHandle *);
+4 -1
View File
@@ -31,7 +31,10 @@
#define _OS_AI_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
+4 -1
View File
@@ -31,7 +31,10 @@
#define _OS_CACHE_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
+11 -5
View File
@@ -31,7 +31,10 @@
#define _OS_CONT_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
@@ -50,20 +53,23 @@ extern "C" {
* Structure for controllers
*/
typedef struct {
typedef struct
{
u16 type; /* Controller Type */
u8 status; /* Controller status */
u8 errnum;
}OSContStatus;
} OSContStatus;
typedef struct {
typedef struct
{
u16 button;
s8 stick_x; /* -80 <= stick_x <= 80 */
s8 stick_y; /* -80 <= stick_y <= 80 */
u8 errnum;
} OSContPad;
typedef struct {
typedef struct
{
void *address; /* Ram pad Address: 11 bits */
u8 databuffer[32]; /* address of the data buffer */
u8 addressCrc; /* CRC code for address */
+4 -1
View File
@@ -31,7 +31,10 @@
#define _OS_EEPROM_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
+4 -1
View File
@@ -31,7 +31,10 @@
#define _OS_EXCEPTION_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
+1
View File
@@ -8,6 +8,7 @@
// Old deprecated functions from strings.h, replaced by memcpy/memset.
extern void bcopy(const void *, void *, size_t);
extern void bzero(void *, size_t);
#endif
+7 -3
View File
@@ -31,7 +31,10 @@
#define _OS_MESSAGE_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
@@ -50,12 +53,13 @@ typedef u32 OSEvent;
/*
* Structure for message
*/
typedef void * OSMesg;
typedef void *OSMesg;
/*
* Structure for message queue
*/
typedef struct OSMesgQueue_s {
typedef struct OSMesgQueue_s
{
OSThread *mtqueue; /* Queue to store threads blocked
on empty mailboxes (receive) */
OSThread *fullqueue; /* Queue to store threads blocked
+1
View File
@@ -4,6 +4,7 @@
/* Miscellaneous OS functions */
void osInitialize(void);
u32 osGetCount(void);
uintptr_t osVirtualToPhysical(void *);
+33 -17
View File
@@ -6,10 +6,11 @@
/* Types */
typedef struct {
#if !defined(VERSION_EU)
typedef struct
{
#if !defined(VERSION_EU)
u32 errStatus;
#endif
#endif
void *dramAddr;
void *C2Addr;
u32 sectorSize;
@@ -17,21 +18,23 @@ typedef struct {
u32 C1ErrSector[4];
} __OSBlockInfo;
typedef struct {
typedef struct
{
u32 cmdType; // 0
u16 transferMode; // 4
u16 blockNum; // 6
s32 sectorNum; // 8
uintptr_t devAddr; // c
#if defined(VERSION_EU)
#if defined(VERSION_EU)
u32 errStatus; //error status added moved to blockinfo
#endif
#endif
u32 bmCtlShadow; // 10
u32 seqCtlShadow; // 14
__OSBlockInfo block[2]; // 18
} __OSTranxInfo;
typedef struct OSPiHandle_s {
typedef struct OSPiHandle_s
{
struct OSPiHandle_s *next;
u8 type;
u8 latency;
@@ -44,26 +47,33 @@ typedef struct OSPiHandle_s {
__OSTranxInfo transferInfo;
} OSPiHandle;
typedef struct {
typedef struct
{
u8 type;
uintptr_t address;
} OSPiInfo;
typedef struct {
typedef struct
{
u16 type;
u8 pri;
u8 status;
OSMesgQueue *retQueue;
} OSIoMesgHdr;
typedef struct {
/*0x00*/ OSIoMesgHdr hdr;
/*0x08*/ void *dramAddr;
/*0x0C*/ uintptr_t devAddr;
/*0x10*/ size_t size;
#if defined(VERSION_EU) || defined(VERSION_SH)
typedef struct
{
/*0x00*/
OSIoMesgHdr hdr;
/*0x08*/
void *dramAddr;
/*0x0C*/
uintptr_t devAddr;
/*0x10*/
size_t size;
#if defined(VERSION_EU) || defined(VERSION_SH)
OSPiHandle *piHandle; // from the official definition
#endif
#endif
} OSIoMesg;
/* Definitions */
@@ -76,13 +86,19 @@ typedef struct {
/* Functions */
s32 osPiStartDma(OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
s32 osPiStartDma(
OSIoMesg *mb, s32 priority, s32 direction, uintptr_t devAddr, void *vAddr,
size_t nbytes, OSMesgQueue *mq);
void osCreatePiManager(OSPri pri, OSMesgQueue *cmdQ, OSMesg *cmdBuf, s32 cmdMsgCnt);
OSMesgQueue *osPiGetCmdQueue(void);
s32 osPiWriteIo(uintptr_t devAddr, u32 data);
s32 osPiReadIo(uintptr_t devAddr, u32 *data);
s32 osPiRawStartDma(s32 dir, u32 cart_addr, void *dram_addr, size_t size);
s32 osEPiRawStartDma(OSPiHandle *piHandle, s32 dir, u32 cart_addr, void *dram_addr, size_t size);
#endif
+4 -1
View File
@@ -31,7 +31,10 @@
#define _OS_RDP_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
+46 -19
View File
@@ -23,19 +23,30 @@ typedef s32 OSId;
typedef union
{
struct {f32 f_odd; f32 f_even;} f;
struct
{
f32 f_odd;
f32 f_even;
} f;
} __OSfp;
typedef struct
{
/* registers */
/*0x20*/ u64 at, v0, v1, a0, a1, a2, a3;
/*0x58*/ u64 t0, t1, t2, t3, t4, t5, t6, t7;
/*0x98*/ u64 s0, s1, s2, s3, s4, s5, s6, s7;
/*0xD8*/ u64 t8, t9, gp, sp, s8, ra;
/*0x108*/ u64 lo, hi;
/*0x118*/ u32 sr, pc, cause, badvaddr, rcp;
/*0x12C*/ u32 fpcsr;
/*0x20*/
u64 at, v0, v1, a0, a1, a2, a3;
/*0x58*/
u64 t0, t1, t2, t3, t4, t5, t6, t7;
/*0x98*/
u64 s0, s1, s2, s3, s4, s5, s6, s7;
/*0xD8*/
u64 t8, t9, gp, sp, s8, ra;
/*0x108*/
u64 lo, hi;
/*0x118*/
u32 sr, pc, cause, badvaddr, rcp;
/*0x12C*/
u32 fpcsr;
__OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14;
__OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30;
} __OSThreadContext;
@@ -49,27 +60,43 @@ typedef struct
typedef struct OSThread_s
{
/*0x00*/ struct OSThread_s *next;
/*0x04*/ OSPri priority;
/*0x08*/ struct OSThread_s **queue;
/*0x0C*/ struct OSThread_s *tlnext;
/*0x10*/ u16 state;
/*0x12*/ u16 flags;
/*0x14*/ OSId id;
/*0x18*/ int fp;
/*0x1C*/ __OSThreadprofile_s *thprof;
/*0x20*/ __OSThreadContext context;
/*0x00*/
struct OSThread_s *next;
/*0x04*/
OSPri priority;
/*0x08*/
struct OSThread_s **queue;
/*0x0C*/
struct OSThread_s *tlnext;
/*0x10*/
u16 state;
/*0x12*/
u16 flags;
/*0x14*/
OSId id;
/*0x18*/
int fp;
/*0x1C*/
__OSThreadprofile_s *thprof;
/*0x20*/
__OSThreadContext context;
} OSThread;
/* Functions */
void osCreateThread(OSThread *thread, OSId id, void (*entry)(void *),
void osCreateThread(
OSThread *thread, OSId id, void (*entry)(void *),
void *arg, void *sp, OSPri pri);
OSId osGetThreadId(OSThread *thread);
OSPri osGetThreadPri(OSThread *thread);
void osSetThreadPri(OSThread *thread, OSPri pri);
void osStartThread(OSThread *thread);
void osStopThread(OSThread *thread);
#endif
+2
View File
@@ -21,7 +21,9 @@ typedef u64 OSTime;
/* Functions */
OSTime osGetTime(void);
void osSetTime(OSTime time);
u32 osSetTimer(OSTimer *, OSTime, OSTime, OSMesgQueue *, OSMesg);
#endif
+4 -1
View File
@@ -31,7 +31,10 @@
#define _OS_TLB_H_
#ifdef _LANGUAGE_C_PLUS_PLUS
extern "C" {
extern "C"
{
#endif
#include "ultratypes.h"
+31 -13
View File
@@ -58,26 +58,44 @@ typedef struct
typedef struct
{
/* 0x00 */ u16 unk00; //some kind of flags. swap buffer sets to 0x10
/* 0x02 */ u16 retraceCount;
/* 0x04 */ void* buffer;
/* 0x08 */ OSViMode *modep;
/* 0x0c */ u32 features;
/* 0x10 */ OSMesgQueue *mq;
/* 0x14 */ OSMesg *msg;
/* 0x18 */ u32 unk18;
/* 0x1c */ u32 unk1c;
/* 0x20 */ u32 unk20;
/* 0x24 */ f32 unk24;
/* 0x28 */ u16 unk28;
/* 0x2c */ u32 unk2c;
/* 0x00 */
u16 unk00; //some kind of flags. swap buffer sets to 0x10
/* 0x02 */
u16 retraceCount;
/* 0x04 */
void *buffer;
/* 0x08 */
OSViMode *modep;
/* 0x0c */
u32 features;
/* 0x10 */
OSMesgQueue *mq;
/* 0x14 */
OSMesg *msg;
/* 0x18 */
u32 unk18;
/* 0x1c */
u32 unk1c;
/* 0x20 */
u32 unk20;
/* 0x24 */
f32 unk24;
/* 0x28 */
u16 unk28;
/* 0x2c */
u32 unk2c;
} OSViContext;
void osCreateViManager(OSPri pri);
void osViSetMode(OSViMode *mode);
void osViSetEvent(OSMesgQueue *mq, OSMesg msg, u32 retraceCount);
void osViBlack(u8 active);
void osViSetSpecialFeatures(u32 func);
void osViSwapBuffer(void *vaddr);
+37 -17
View File
@@ -70,32 +70,49 @@
typedef struct
{
/*0x00*/ u32 type;
/*0x04*/ u32 flags;
/*0x00*/
u32 type;
/*0x04*/
u32 flags;
/*0x08*/ u64 *ucode_boot;
/*0x0C*/ u32 ucode_boot_size;
/*0x08*/
u64 *ucode_boot;
/*0x0C*/
u32 ucode_boot_size;
/*0x10*/ u64 *ucode;
/*0x14*/ u32 ucode_size;
/*0x10*/
u64 *ucode;
/*0x14*/
u32 ucode_size;
/*0x18*/ u64 *ucode_data;
/*0x1C*/ u32 ucode_data_size;
/*0x18*/
u64 *ucode_data;
/*0x1C*/
u32 ucode_data_size;
/*0x20*/ u64 *dram_stack;
/*0x24*/ u32 dram_stack_size;
/*0x20*/
u64 *dram_stack;
/*0x24*/
u32 dram_stack_size;
/*0x28*/ u64 *output_buff;
/*0x2C*/ u64 *output_buff_size;
/*0x28*/
u64 *output_buff;
/*0x2C*/
u64 *output_buff_size;
/*0x30*/ u64 *data_ptr;
/*0x34*/ u32 data_size;
/*0x30*/
u64 *data_ptr;
/*0x34*/
u32 data_size;
/*0x38*/ u64 *yield_data_ptr;
/*0x3C*/ u32 yield_data_size;
/*0x38*/
u64 *yield_data_ptr;
/*0x3C*/
u32 yield_data_size;
} OSTask_t; // size = 0x40
typedef union {
typedef union
{
OSTask_t t;
long long int force_structure_alignment;
} OSTask;
@@ -109,8 +126,11 @@ typedef u32 OSYieldResult;
osSpTaskStartGo(p);
void osSpTaskLoad(OSTask *task);
void osSpTaskStartGo(OSTask *task);
void osSpTaskYield(void);
OSYieldResult osSpTaskYielded(OSTask *task);
#endif
+2 -2
View File
@@ -1,8 +1,8 @@
#ifndef _ULTRA64_TYPES_H_
#define _ULTRA64_TYPES_H_
#ifndef NULL
#define NULL (void *)0
#ifndef nullptr
#define nullptr (void *)0
#endif
#define TRUE 1

Some files were not shown because too many files have changed in this diff Show More